Skip to content

Commit

Permalink
Merge branch 'tiago/dont-export-wasm-mem' (#3258)
Browse files Browse the repository at this point in the history
* origin/tiago/dont-export-wasm-mem:
  Changelog for #3258
  Remove unused WASM memory export
  • Loading branch information
brentstone committed May 21, 2024
2 parents 2ee654c + 8362b9a commit bbaadc7
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Remove unused WASM memory export.
([\#3258](https://github.com/anoma/namada/pull/3258))
7 changes: 1 addition & 6 deletions crates/namada/src/vm/wasm/host_env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@

use namada_state::{DBIter, StorageHasher, DB};
use wasmer::{
Function, HostEnvInitError, ImportObject, Instance, Memory, Store,
WasmerEnv,
Function, HostEnvInitError, ImportObject, Instance, Store, WasmerEnv,
};

use crate::vm::host_env::{TxVmEnv, VpEvaluator, VpVmEnv};
Expand Down Expand Up @@ -47,7 +46,6 @@ where
#[allow(clippy::too_many_arguments)]
pub fn tx_imports<D, H, CA>(
wasm_store: &Store,
initial_memory: Memory,
env: TxVmEnv<'static, WasmMemory, D, H, CA>,
) -> ImportObject
where
Expand All @@ -58,7 +56,6 @@ where
wasmer::imports! {
// default namespace
"env" => {
"memory" => initial_memory,
// Wasm middleware gas injection hook
"gas" => Function::new_native_with_env(wasm_store, env.clone(), host_env::tx_charge_gas),
"namada_tx_read" => Function::new_native_with_env(wasm_store, env.clone(), host_env::tx_read),
Expand Down Expand Up @@ -96,7 +93,6 @@ where
/// validity predicate code
pub fn vp_imports<D, H, EVAL, CA>(
wasm_store: &Store,
initial_memory: Memory,
env: VpVmEnv<'static, WasmMemory, D, H, EVAL, CA>,
) -> ImportObject
where
Expand All @@ -108,7 +104,6 @@ where
wasmer::imports! {
// default namespace
"env" => {
"memory" => initial_memory,
// Wasm middleware gas injection hook
"gas" => Function::new_native_with_env(wasm_store, env.clone(), host_env::vp_charge_gas),
"namada_vp_read_pre" => Function::new_native_with_env(wasm_store, env.clone(), host_env::vp_read_pre),
Expand Down
13 changes: 3 additions & 10 deletions crates/namada/src/vm/wasm/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,9 +210,7 @@ where
tx_wasm_cache,
);

let initial_memory =
memory::prepare_tx_memory(&store).map_err(Error::MemoryError)?;
let imports = tx_imports(&store, initial_memory, env);
let imports = tx_imports(&store, env);

// Instantiate the wasm module
let instance = wasmer::Instance::new(&module, &imports)
Expand Down Expand Up @@ -328,10 +326,8 @@ where
&mut vp_wasm_cache,
);

let initial_memory =
memory::prepare_vp_memory(&store).map_err(Error::MemoryError)?;
let yielded_value_borrow = env.ctx.yielded_value.clone();
let imports = vp_imports(&store, initial_memory, env);
let imports = vp_imports(&store, env);

run_vp(
module,
Expand Down Expand Up @@ -520,15 +516,12 @@ where
gas_meter,
)?;

let initial_memory =
memory::prepare_vp_memory(&store).map_err(Error::MemoryError)?;

let env = VpVmEnv {
memory: WasmMemory::default(),
ctx,
};
let yielded_value_borrow = env.ctx.yielded_value.clone();
let imports = vp_imports(&store, initial_memory, env);
let imports = vp_imports(&store, env);

run_vp(
module,
Expand Down

0 comments on commit bbaadc7

Please sign in to comment.