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

Implement cosmwasm_vm Move Bind #2553

Merged
merged 51 commits into from
Sep 26, 2024

Conversation

yubing744
Copy link
Collaborator

@yubing744 yubing744 commented Sep 1, 2024

Summary

Summary about this PR

TODO

  • The Backend implementation of cosmwasm-vm is replaced by mock_backend with move_backend

Copy link

vercel bot commented Sep 1, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
rooch-portal ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 25, 2024 3:15pm
rooch-portal-v2.1 ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 25, 2024 3:15pm
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
rooch ⬜️ Ignored (Inspect) Visit Preview Sep 25, 2024 3:15pm

@yubing744
Copy link
Collaborator Author

@jolestar help review.

})?;

// Save WASM bytecode and get checksum
let checksum = WASM_CACHE.save_wasm(&bytecode).map_err(|e| {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里的 wasm 最后存哪里去了呢?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Cache module of cosmwasm-vm is implemented in three layers at the base level:

  1. Fixed Memory Cache: Modules that are pinned are stored in this cache layer.
  2. In-Memory Cache: Modules that are not pinned but remain in memory.
  3. File System Cache: Modules stored on disk.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The third disk storage is the configured system temporary directory.

Comment on lines +30 to +45
public fun from_code(code: vector<u8>): Result<Instance, Error> {
features::ensure_wasm_enabled();

let store = table::new<String, vector<u8>>();
let store_handle = table::handle(&store);

let (checksum, error_code) = native_create_instance(code, store_handle);
if (error_code == 0) {
ok(Instance {
code_checksum: checksum,
store: store,
})
} else {
table::drop(store);
new_error_result(error_code, string::utf8(b"native_create_instance_error"))
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

感觉这里应该返回 Object, 这样就不需要那个 table 了,直接把 Object 动态字短作为 store。

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using Object is also possible, but it seems that using Table here makes the logic clearer.

@jolestar
Copy link
Contributor

cc @steelgeek091

Copy link
Contributor

@jolestar jolestar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merge this PR frist, and discuss the refactoring on the dev meeting

@yubing744
Copy link
Collaborator Author

Merge this PR frist, and discuss the refactoring on the dev meeting

OK

@yubing744 yubing744 merged commit 3e7c63c into rooch-network:main Sep 26, 2024
9 checks passed
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.

2 participants