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

Re use contracts wasm compilation #8

Conversation

Kayanski
Copy link

@Kayanski Kayanski commented Sep 4, 2024

This PR aims at avoiding multiple compilation of wasm modules.

@Kayanski Kayanski marked this pull request as draft September 4, 2024 08:24
@Kayanski Kayanski marked this pull request as ready for review September 4, 2024 11:22
@Kayanski Kayanski changed the base branch from adapt_for_local_execution to clone-test/cosmwasm-2 September 4, 2024 11:23
@@ -237,7 +236,7 @@ where
/// Registers contract code (like uploading wasm bytecode on a chain),
/// so it can later be used to instantiate a contract.
/// Only for wasm codes
pub fn store_wasm_code(&mut self, code: WasmContract) -> u64 {
pub fn store_wasm_code(&mut self, code: Vec<u8>) -> u64 {
Copy link
Author

Choose a reason for hiding this comment

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

This allows for cw-multi-test handling of module caching... The interface is also simpler for users

@@ -128,7 +130,7 @@ pub trait Wasm<ExecC, QueryC: CustomQuery>: AllWasmQuerier {
pub type LocalRustContract<ExecC, QueryC> = *mut dyn Contract<ExecC, QueryC>;
pub struct WasmKeeper<ExecC: 'static, QueryC: CustomQuery + 'static> {
/// Contract codes that stand for wasm code in real-life blockchain.
pub code_base: HashMap<usize, WasmContract>,
pub code_base: RefCell<HashMap<usize, WasmContract>>,
Copy link
Author

Choose a reason for hiding this comment

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

Allows for storing new code modules while executing transactions and queries

pub struct DistantCodeId {
pub code_id: u64,
pub module: (Engine, Module),
Copy link
Author

Choose a reason for hiding this comment

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

Engine and Modules go together and MUST be used together, otherwise segmentation faults can happen

Choose a reason for hiding this comment

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

Wow, that's wild Engine that can't be reused with different module


#[derive(Serialize, Deserialize, Debug)]
#[derive(Debug)]
Copy link
Author

Choose a reason for hiding this comment

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

Remove useless derive

@Kayanski Kayanski changed the title Nicolas/orc 161 re use contracts wasm compilation Re use contracts wasm compilation Sep 4, 2024
@Kayanski Kayanski merged commit 6a9cc70 into clone-test/cosmwasm-2 Sep 4, 2024
@Kayanski Kayanski deleted the nicolas/orc-161-re-use-contracts-wasm-compilation branch September 4, 2024 12:22
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.

3 participants