-
Notifications
You must be signed in to change notification settings - Fork 106
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
use wazero #582
Draft
faddat
wants to merge
55
commits into
CosmWasm:main
Choose a base branch
from
faddat:merged-chaos
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
use wazero #582
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
faddat
changed the title
merged chaos
use wazero, and intraoduce an abstraction for the virtual macine
Dec 19, 2024
faddat
changed the title
use wazero, and intraoduce an abstraction for the virtual macine
use wazero, and introduce an abstraction for the virtual macine
Dec 20, 2024
- 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
changed the title
use wazero, and introduce an abstraction for the virtual macine
use wazero
Dec 23, 2024
… parameter handling
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
what?
To ensure that contracts can run reliably without stopping chains, we shall endeavor to swap out wasmer for wazero. Wasmer is a great wasm vm written in rust, a great programming language. Wazero is a great web assembly virtual machine written in go, a great programming language (with horrible c interop). Both languages get spicy around interop, so it is best to code an entire blockchain application in just one programming language. Additionally, Go memory management breaks when using cgo to import C.
why?
Because cgo doesn't work all that well, and messes up some basic features of Go. Also, similar ABI issues and c interop issues on the rust side, so it is probably not a good idea to use cgo / unsafe in go / unsafe in rust on >40 production networks, even if we are just accounting for the extreme increase in random explosions cause by cgo. But in fact we will be able to reduce explosions in many other ways too.
How?
Clean up wasmvm
Create an interface for runtimes so that the runtime interface is clear
implement wazero in the runtime folder
implement the
whats the trick?
The trick is that cosmwasm's vm package is imported by libwasmvm and provides a lot of functions. We will need to recreate that for wazero and use the
host functions
feature.there's a pretty clear migration path to wazero insrtead of wasmer in wasmvm.
When I began to work on cosmwasgo, I made a design mistake and made things less modular.
Today, I began to go through all of the code file by file, and I was able to get to a pretty good place. I still need to reconcile your last commit though.
Although I have hardcoded the runtime, I think you can see how using the
runtime
folder and theruntime
interface allows for a pretty singificant simplification of wasmvm.There are still remaining questions around gas metering, and a few other things.
cheers!
-Jacob
Note: even if you do not reveiw or merge this, I would appreciate not closing it. Among other things I am using the PR to compare.
Random notes that I will add to as I go: