Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory Progress #609

Closed
wants to merge 90 commits into from
Closed

Memory Progress #609

wants to merge 90 commits into from

Conversation

faddat
Copy link
Contributor

@faddat faddat commented Jan 11, 2025

This is another attempt at replacing wasmer with wazero. It is close, and contracts do respond to stuff from time to time.

But there seem to be memory issues, which we really need to get cleaned up.

I am merging this to #582, since it gets testfloats working

- Updated `MockEnv` to use `types.Uint64` for time representation.
- Introduced helper functions for memory operations: `readMemory` and `writeMemory`.
- Replaced direct memory read/write calls in `hostGet` and other functions with the new helpers.
- Removed the `MemoryAllocator` struct and related functions, simplifying memory management.
- Cleaned up unused code and deleted obsolete files in the `libwasmvm` directory.
- Adjusted function signatures and error handling for better clarity and consistency.

This commit enhances the overall structure and readability of the codebase while ensuring proper memory handling.
run tests
faddat added 27 commits January 5, 2025 19:58
…ve memory management error handling

- Added `combined_code.txt` to .gitignore to prevent tracking of combined code files.
- Improved debug output in `hostAbort` and `callContractFn` methods for better traceability during contract execution.
- Enhanced memory management in `wazeroruntime.go` by adding error checks for deallocation calls and validating memory region sizes, ensuring safer memory operations.
- Updated logging to provide clearer insights into memory reads and writes, including detailed error messages for better debugging.
- Introduced a new `parseParams` function to streamline the extraction and validation of common parameters across multiple contract methods.
- Updated `Instantiate`, `Execute`, `Migrate`, `MigrateWithInfo`, `Sudo`, `Reply`, `Query`, `IBCChannelOpen`, `IBCChannelConnect`, `IBCChannelClose`, `IBCPacketReceive`, `IBCPacketAck`, `IBCPacketTimeout`, `IBCSourceCallback`, and `IBCDestinationCallback` methods to utilize the new parameter parsing logic, enhancing code maintainability and reducing redundancy.
- Improved error handling for missing or invalid parameters, ensuring more robust contract function calls.
… debug logging

- Refactored the `callContractFn` method in `wazeroruntime.go` to improve memory management by implementing region-based approaches for writing environment, message, and info data.
- Added detailed debug logging to track memory operations and function calls, enhancing traceability during contract execution.
- Introduced helper functions for memory allocation and reading, ensuring safer and more efficient memory handling.
- Improved error handling for memory operations, validating regions and ensuring robust contract function calls.
- Updated comments throughout the method to clarify the purpose of each section, improving code readability and maintainability.
@faddat
Copy link
Contributor Author

faddat commented Jan 12, 2025

Closing because it is merged into #582

@faddat faddat closed this Jan 12, 2025
@faddat faddat mentioned this pull request Jan 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant