diff --git a/wasm/vp_implicit/Cargo.toml b/wasm/vp_implicit/Cargo.toml index 8780efd5a3..89e1b54348 100644 --- a/wasm/vp_implicit/Cargo.toml +++ b/wasm/vp_implicit/Cargo.toml @@ -13,7 +13,6 @@ namada_tx_prelude.workspace = true namada_vp_prelude.workspace = true wee_alloc.workspace = true getrandom.workspace = true -once_cell.workspace = true [dev-dependencies] namada = {path = "../../crates/namada"} diff --git a/wasm/vp_user/Cargo.toml b/wasm/vp_user/Cargo.toml index b51bbbd6b5..f94e5e6b85 100644 --- a/wasm/vp_user/Cargo.toml +++ b/wasm/vp_user/Cargo.toml @@ -13,7 +13,6 @@ namada_tx_prelude.workspace = true namada_vp_prelude.workspace = true wee_alloc.workspace = true getrandom.workspace = true -once_cell.workspace = true [dev-dependencies] namada = {path = "../../crates/namada"} diff --git a/wasm_for_tests/Cargo.toml b/wasm_for_tests/Cargo.toml index 2716bfb8af..069ca169cc 100644 --- a/wasm_for_tests/Cargo.toml +++ b/wasm_for_tests/Cargo.toml @@ -2,19 +2,24 @@ resolver = "2" members = [ + "tx_fail", + "tx_infinite_guest_gas", + "tx_infinite_host_gas", + "tx_invalid_data", "tx_memory_limit", "tx_no_op", - "tx_fail", + "tx_proposal_code", + "tx_proposal_ibc_token_inflation", + "tx_proposal_masp_reward", "tx_read_storage_key", "tx_write", "vp_always_false", "vp_always_true", "vp_eval", + "vp_infinite_guest_gas", + "vp_infinite_host_gas", "vp_memory_limit", "vp_read_storage_key", - "tx_proposal_code", - "tx_proposal_masp_reward", - "tx_proposal_ibc_token_inflation", ] [workspace.package] diff --git a/wasm_for_tests/Makefile b/wasm_for_tests/Makefile index 707ac5aa41..fc63e4bfea 100644 --- a/wasm_for_tests/Makefile +++ b/wasm_for_tests/Makefile @@ -5,19 +5,24 @@ nightly := $(shell cat ../rust-nightly-version) # All the wasms that can be built from this source, switched via Cargo features # Wasms can be added via the Cargo.toml `[features]` list. -wasms := tx_memory_limit +wasms := tx_fail +wasms += tx_infinite_guest_gas +wasms += tx_infinite_host_gas +wasms += tx_invalid_data +wasms += tx_memory_limit wasms += tx_no_op -wasms += tx_fail +wasms += tx_proposal_code +wasms += tx_proposal_ibc_token_inflation +wasms += tx_proposal_masp_reward wasms += tx_read_storage_key wasms += tx_write wasms += vp_always_false wasms += vp_always_true wasms += vp_eval +wasms += vp_infinite_guest_gas +wasms += vp_infinite_host_gas wasms += vp_memory_limit wasms += vp_read_storage_key -wasms += tx_proposal_code -wasms += tx_proposal_masp_reward -wasms += tx_proposal_ibc_token_inflation # Build all wasms in release mode diff --git a/wasm_for_tests/tx_fail/src/lib.rs b/wasm_for_tests/tx_fail/src/lib.rs index b36c1379c4..df94e287d4 100644 --- a/wasm_for_tests/tx_fail/src/lib.rs +++ b/wasm_for_tests/tx_fail/src/lib.rs @@ -1,6 +1,6 @@ use namada_tx_prelude::*; -#[transaction(gas = 1000)] +#[transaction] fn apply_tx(_ctx: &mut Ctx, _tx_data: Tx) -> TxResult { Err(Error::SimpleMessage("failed tx")) -} \ No newline at end of file +} diff --git a/wasm_for_tests/tx_infinite_guest_gas/Cargo.toml b/wasm_for_tests/tx_infinite_guest_gas/Cargo.toml new file mode 100644 index 0000000000..d4734326ff --- /dev/null +++ b/wasm_for_tests/tx_infinite_guest_gas/Cargo.toml @@ -0,0 +1,29 @@ +[package] +name = "tx_infinite_guest_gas" +description = "Wasm transaction used for testing." +authors.workspace = true +edition.workspace = true +license.workspace = true +version.workspace = true + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +namada_test_utils.workspace = true +namada_tx_prelude.workspace = true +namada_vp_prelude.workspace = true +wee_alloc.workspace = true +getrandom.workspace = true + +[dev-dependencies] +namada_tests = { path = "../../crates/tests", default-features = false, features = [ + "wasm-runtime", +] } + +proptest = "1.4.0" +test-log = {version = "0.2.14", default-features = false, features = ["trace"]} +tracing = "0.1.30" +tracing-subscriber = {version = "0.3.7", default-features = false, features = ["env-filter", "fmt"]} + +[lib] +crate-type = ["cdylib"] \ No newline at end of file diff --git a/wasm_for_tests/tx_infinite_guest_gas/src/lib.rs b/wasm_for_tests/tx_infinite_guest_gas/src/lib.rs new file mode 100644 index 0000000000..a6d63067ac --- /dev/null +++ b/wasm_for_tests/tx_infinite_guest_gas/src/lib.rs @@ -0,0 +1,8 @@ +use namada_tx_prelude::*; + +/// A tx that endlessly charges gas from the guest environment +#[transaction] +fn apply_tx(_ctx: &mut Ctx, _tx_data: Tx) -> TxResult { + #[allow(clippy::empty_loop)] + loop {} +} diff --git a/wasm_for_tests/tx_infinite_host_gas/Cargo.toml b/wasm_for_tests/tx_infinite_host_gas/Cargo.toml new file mode 100644 index 0000000000..1c6167e9ba --- /dev/null +++ b/wasm_for_tests/tx_infinite_host_gas/Cargo.toml @@ -0,0 +1,29 @@ +[package] +name = "tx_infinite_host_gas" +description = "Wasm transaction used for testing." +authors.workspace = true +edition.workspace = true +license.workspace = true +version.workspace = true + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +namada_test_utils.workspace = true +namada_tx_prelude.workspace = true +namada_vp_prelude.workspace = true +wee_alloc.workspace = true +getrandom.workspace = true + +[dev-dependencies] +namada_tests = { path = "../../crates/tests", default-features = false, features = [ + "wasm-runtime", +] } + +proptest = "1.4.0" +test-log = {version = "0.2.14", default-features = false, features = ["trace"]} +tracing = "0.1.30" +tracing-subscriber = {version = "0.3.7", default-features = false, features = ["env-filter", "fmt"]} + +[lib] +crate-type = ["cdylib"] \ No newline at end of file diff --git a/wasm_for_tests/tx_infinite_host_gas/src/lib.rs b/wasm_for_tests/tx_infinite_host_gas/src/lib.rs new file mode 100644 index 0000000000..b15e7ab276 --- /dev/null +++ b/wasm_for_tests/tx_infinite_host_gas/src/lib.rs @@ -0,0 +1,12 @@ +use namada_tx_prelude::*; + +/// A tx that endlessly charges gas from the host environment +#[transaction] +fn apply_tx(ctx: &mut Ctx, _tx_data: Tx) -> TxResult { + let target_key = parameters_storage::get_tx_allowlist_storage_key(); + loop { + // NOTE: don't propagate the error to verify that execution abortion + // is done in host and does not require guest cooperation + let _ = ctx.write(&target_key, vec!["hash"]); + } +} diff --git a/wasm_for_tests/tx_invalid_data/Cargo.toml b/wasm_for_tests/tx_invalid_data/Cargo.toml new file mode 100644 index 0000000000..329aa86081 --- /dev/null +++ b/wasm_for_tests/tx_invalid_data/Cargo.toml @@ -0,0 +1,29 @@ +[package] +name = "tx_invalid_data" +description = "Wasm transaction used for testing." +authors.workspace = true +edition.workspace = true +license.workspace = true +version.workspace = true + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +namada_test_utils.workspace = true +namada_tx_prelude.workspace = true +namada_vp_prelude.workspace = true +wee_alloc.workspace = true +getrandom.workspace = true + +[dev-dependencies] +namada_tests = { path = "../../crates/tests", default-features = false, features = [ + "wasm-runtime", +] } + +proptest = "1.4.0" +test-log = {version = "0.2.14", default-features = false, features = ["trace"]} +tracing = "0.1.30" +tracing-subscriber = {version = "0.3.7", default-features = false, features = ["env-filter", "fmt"]} + +[lib] +crate-type = ["cdylib"] \ No newline at end of file diff --git a/wasm_for_tests/tx_invalid_data/src/lib.rs b/wasm_for_tests/tx_invalid_data/src/lib.rs new file mode 100644 index 0000000000..eda9df65c4 --- /dev/null +++ b/wasm_for_tests/tx_invalid_data/src/lib.rs @@ -0,0 +1,11 @@ +use namada_tx_prelude::*; + +#[transaction] +fn apply_tx(ctx: &mut Ctx, tx_data: Tx) -> TxResult { + let signed = tx_data; + let _data = signed.data().ok_or_err_msg("Missing data").map_err(|err| { + ctx.set_commitment_sentinel(); + err + })?; + Ok(()) +} diff --git a/wasm_for_tests/tx_memory_limit/src/lib.rs b/wasm_for_tests/tx_memory_limit/src/lib.rs index caf81a14a3..a9a17ebde5 100644 --- a/wasm_for_tests/tx_memory_limit/src/lib.rs +++ b/wasm_for_tests/tx_memory_limit/src/lib.rs @@ -1,6 +1,6 @@ use namada_tx_prelude::*; -#[transaction(gas = 1000)] +#[transaction] fn apply_tx(_ctx: &mut Ctx, tx_data: Tx) -> TxResult { let len = usize::try_from_slice(&tx_data.data().as_ref().unwrap()[..]).unwrap(); diff --git a/wasm_for_tests/tx_no_op/src/lib.rs b/wasm_for_tests/tx_no_op/src/lib.rs index e175f398f7..a819b73be6 100644 --- a/wasm_for_tests/tx_no_op/src/lib.rs +++ b/wasm_for_tests/tx_no_op/src/lib.rs @@ -1,6 +1,6 @@ use namada_tx_prelude::*; -#[transaction(gas = 1000)] +#[transaction] fn apply_tx(_ctx: &mut Ctx, _tx_data: Tx) -> TxResult { Ok(()) } diff --git a/wasm_for_tests/tx_proposal_code/src/lib.rs b/wasm_for_tests/tx_proposal_code/src/lib.rs index f3b9f420df..2d050755e7 100644 --- a/wasm_for_tests/tx_proposal_code/src/lib.rs +++ b/wasm_for_tests/tx_proposal_code/src/lib.rs @@ -1,13 +1,13 @@ use namada_tx_prelude::*; -#[transaction(gas = 1000)] +#[transaction] fn apply_tx(ctx: &mut Ctx, _tx_data: Tx) -> TxResult { // governance - let target_key = gov_storage::keys::get_min_proposal_grace_epoch_key(); + let target_key = gov_storage::keys::get_min_proposal_grace_epochs_key(); ctx.write(&target_key, 9_u64)?; // parameters - let target_key = parameters_storage::get_tx_allowlist_storage_key(); + let target_key = parameters_storage::get_vp_allowlist_storage_key(); ctx.write(&target_key, vec!["hash"])?; Ok(()) -} \ No newline at end of file +} diff --git a/wasm_for_tests/tx_proposal_ibc_token_inflation/src/lib.rs b/wasm_for_tests/tx_proposal_ibc_token_inflation/src/lib.rs index e7f5d9bf47..176dc0eeaa 100644 --- a/wasm_for_tests/tx_proposal_ibc_token_inflation/src/lib.rs +++ b/wasm_for_tests/tx_proposal_ibc_token_inflation/src/lib.rs @@ -8,7 +8,7 @@ const IBC_TOKEN_DENOM: u8 = 0; const CHANNEL_ID: &str = "channel-0"; const BASE_TOKEN: &str = "tnam1qyvfwdkz8zgs9n3qn9xhp8scyf8crrxwuq26r6gy"; -#[transaction(gas = 1000)] +#[transaction] fn apply_tx(ctx: &mut Ctx, _tx_data: Tx) -> TxResult { let ibc_denom = format!("transfer/{CHANNEL_ID}/{BASE_TOKEN}"); let ibc_token = ibc::ibc_token(&ibc_denom); @@ -27,14 +27,12 @@ fn apply_tx(ctx: &mut Ctx, _tx_data: Tx) -> TxResult { token::storage_key::masp_kd_gain_key(&ibc_token); let token_map_key = token::storage_key::masp_token_map_key(); - let mut token_map: masp::TokenMap = ctx.read(&token_map_key)?.unwrap_or_default(); + let mut token_map: masp::TokenMap = + ctx.read(&token_map_key)?.unwrap_or_default(); token_map.insert(ibc_denom, ibc_token); ctx.write(&token_map_key, token_map)?; - ctx.write( - &shielded_token_last_inflation_key, - token::Amount::zero(), - )?; + ctx.write(&shielded_token_last_inflation_key, token::Amount::zero())?; ctx.write( &shielded_token_last_locked_amount_key, token::Amount::zero(), @@ -56,4 +54,4 @@ fn apply_tx(ctx: &mut Ctx, _tx_data: Tx) -> TxResult { Dec::from_str("120000").unwrap(), )?; Ok(()) -} \ No newline at end of file +} diff --git a/wasm_for_tests/tx_proposal_masp_reward/src/lib.rs b/wasm_for_tests/tx_proposal_masp_reward/src/lib.rs index 92767b9242..5ca9e23d77 100644 --- a/wasm_for_tests/tx_proposal_masp_reward/src/lib.rs +++ b/wasm_for_tests/tx_proposal_masp_reward/src/lib.rs @@ -3,7 +3,7 @@ use std::str::FromStr; use dec::Dec; use namada_tx_prelude::*; -#[transaction(gas = 1000)] +#[transaction] fn apply_tx(ctx: &mut Ctx, _tx_data: Tx) -> TxResult { let native_token = ctx.get_native_token()?; let shielded_rewards_key = @@ -12,4 +12,4 @@ fn apply_tx(ctx: &mut Ctx, _tx_data: Tx) -> TxResult { ctx.write(&shielded_rewards_key, Dec::from_str("0.05").unwrap())?; Ok(()) -} \ No newline at end of file +} diff --git a/wasm_for_tests/tx_read_storage_key/src/lib.rs b/wasm_for_tests/tx_read_storage_key/src/lib.rs index 4aaef9ad89..fab14f404a 100644 --- a/wasm_for_tests/tx_read_storage_key/src/lib.rs +++ b/wasm_for_tests/tx_read_storage_key/src/lib.rs @@ -1,6 +1,6 @@ use namada_tx_prelude::*; -#[transaction(gas = 1000)] +#[transaction] fn apply_tx(ctx: &mut Ctx, tx_data: Tx) -> TxResult { // Allocates a memory of size given from the `tx_data (usize)` let key = @@ -9,4 +9,4 @@ fn apply_tx(ctx: &mut Ctx, tx_data: Tx) -> TxResult { log_string(format!("key {}", key)); let _result: Vec = ctx.read(&key)?.unwrap(); Ok(()) -} \ No newline at end of file +} diff --git a/wasm_for_tests/tx_write/src/lib.rs b/wasm_for_tests/tx_write/src/lib.rs index 022ad27a25..f8fd53f71b 100644 --- a/wasm_for_tests/tx_write/src/lib.rs +++ b/wasm_for_tests/tx_write/src/lib.rs @@ -1,61 +1,58 @@ use namada_test_utils::tx_data::TxWriteData; - use namada_tx_prelude::{ - log_string, transaction, BorshDeserialize, Ctx, StorageRead, - StorageWrite, Tx, TxEnv, TxResult, - }; +use namada_tx_prelude::*; - const TX_NAME: &str = "tx_write"; +const TX_NAME: &str = "tx_write"; - fn log(msg: &str) { - log_string(format!("[{}] {}", TX_NAME, msg)) - } +fn log(msg: &str) { + log_string(format!("[{}] {}", TX_NAME, msg)) +} - fn fatal(msg: &str, err: impl std::error::Error) -> ! { - log(&format!("ERROR: {} - {:?}", msg, err)); - panic!() - } +fn fatal(msg: &str, err: impl std::error::Error) -> ! { + log(&format!("ERROR: {} - {:?}", msg, err)); + panic!() +} - fn fatal_msg(msg: &str) -> ! { - log(msg); - panic!() - } +fn fatal_msg(msg: &str) -> ! { + log(msg); + panic!() +} - #[transaction(gas = 1000)] - fn apply_tx(ctx: &mut Ctx, tx_data: Tx) -> TxResult { - let signed = tx_data; - let data = match signed.data() { - Some(data) => { - log(&format!("got data ({} bytes)", data.len())); - data - } - None => { - fatal_msg("no data provided"); +#[transaction] +fn apply_tx(ctx: &mut Ctx, tx_data: Tx) -> TxResult { + let signed = tx_data; + let data = match signed.data() { + Some(data) => { + log(&format!("got data ({} bytes)", data.len())); + data + } + None => { + fatal_msg("no data provided"); + } + }; + let TxWriteData { key, value } = + match TxWriteData::try_from_slice(&data[..]) { + Ok(write_op) => { + log(&format!( + "parsed WriteOp to key {} ({} bytes)", + &write_op.key, + &write_op.value.len(), + )); + write_op } + Err(error) => fatal("deserializing WriteOp", error), }; - let TxWriteData { key, value } = - match TxWriteData::try_from_slice(&data[..]) { - Ok(write_op) => { - log(&format!( - "parsed WriteOp to key {} ({} bytes)", - &write_op.key, - &write_op.value.len(), - )); - write_op - } - Err(error) => fatal("deserializing WriteOp", error), - }; - let existing_value: Option = ctx.read(&key)?; - match existing_value { - Some(existing_value) => { - log(&format!("already present value is {}", existing_value)); - } - None => { - log("no already present value"); - } + let existing_value: Option = ctx.read(&key)?; + match existing_value { + Some(existing_value) => { + log(&format!("already present value is {}", existing_value)); + } + None => { + log("no already present value"); } - log(&format!("attempting to write new value to key {}", key)); - // using `ctx.write_bytes` instead of `ctx.write` here, as we want to - // write the actual bytes, not a Borsh-serialization of a `Vec` - ctx.write_bytes(&key, &value[..])?; - Ok(()) - } \ No newline at end of file + } + log(&format!("attempting to write new value to key {}", key)); + // using `ctx.write_bytes` instead of `ctx.write` here, as we want to + // write the actual bytes, not a Borsh-serialization of a `Vec` + ctx.write_bytes(&key, &value[..])?; + Ok(()) +} diff --git a/wasm_for_tests/vp_always_false/src/lib.rs b/wasm_for_tests/vp_always_false/src/lib.rs index ffdefedfd9..17b64ddbd6 100644 --- a/wasm_for_tests/vp_always_false/src/lib.rs +++ b/wasm_for_tests/vp_always_false/src/lib.rs @@ -1,6 +1,6 @@ use namada_vp_prelude::*; -#[validity_predicate(gas = 1000)] +#[validity_predicate] fn validate_tx( _ctx: &Ctx, _tx_data: Tx, diff --git a/wasm_for_tests/vp_always_true/src/lib.rs b/wasm_for_tests/vp_always_true/src/lib.rs index c8a21d0511..55daff519a 100644 --- a/wasm_for_tests/vp_always_true/src/lib.rs +++ b/wasm_for_tests/vp_always_true/src/lib.rs @@ -1,6 +1,6 @@ use namada_vp_prelude::*; -#[validity_predicate(gas = 1000)] +#[validity_predicate] fn validate_tx( _ctx: &Ctx, _tx_data: Tx, diff --git a/wasm_for_tests/vp_eval/src/lib.rs b/wasm_for_tests/vp_eval/src/lib.rs index 1b393e311d..be8deecb96 100644 --- a/wasm_for_tests/vp_eval/src/lib.rs +++ b/wasm_for_tests/vp_eval/src/lib.rs @@ -1,6 +1,6 @@ use namada_vp_prelude::*; -#[validity_predicate(gas = 1000)] +#[validity_predicate] fn validate_tx( ctx: &Ctx, tx_data: Tx, @@ -14,5 +14,5 @@ fn validate_tx( input, }: EvalVp = EvalVp::try_from_slice(&tx_data.data().as_ref().unwrap()[..]).unwrap(); - ctx.eval(vp_code_hash, input) + ctx.eval(vp_code_hash, input).into_vp_error() } diff --git a/wasm_for_tests/vp_infinite_guest_gas/Cargo.toml b/wasm_for_tests/vp_infinite_guest_gas/Cargo.toml new file mode 100644 index 0000000000..976e458fef --- /dev/null +++ b/wasm_for_tests/vp_infinite_guest_gas/Cargo.toml @@ -0,0 +1,29 @@ +[package] +name = "vp_infinite_guest_gas" +description = "Wasm vp used for testing." +authors.workspace = true +edition.workspace = true +license.workspace = true +version.workspace = true + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +namada_test_utils.workspace = true +namada_tx_prelude.workspace = true +namada_vp_prelude.workspace = true +wee_alloc.workspace = true +getrandom.workspace = true + +[dev-dependencies] +namada_tests = { path = "../../crates/tests", default-features = false, features = [ + "wasm-runtime", +] } + +proptest = "1.4.0" +test-log = {version = "0.2.14", default-features = false, features = ["trace"]} +tracing = "0.1.30" +tracing-subscriber = {version = "0.3.7", default-features = false, features = ["env-filter", "fmt"]} + +[lib] +crate-type = ["cdylib"] \ No newline at end of file diff --git a/wasm_for_tests/vp_infinite_guest_gas/src/lib.rs b/wasm_for_tests/vp_infinite_guest_gas/src/lib.rs new file mode 100644 index 0000000000..5e7f66e08d --- /dev/null +++ b/wasm_for_tests/vp_infinite_guest_gas/src/lib.rs @@ -0,0 +1,15 @@ + +use namada_vp_prelude::*; + +/// A vp that endlessly charges gas from the guest environment +#[validity_predicate] +fn validate_tx( + _ctx: &Ctx, + _tx_data: Tx, + _addr: Address, + _keys_changed: BTreeSet, + _verifiers: BTreeSet
, +) -> VpResult { + #[allow(clippy::empty_loop)] + loop {} +} diff --git a/wasm_for_tests/vp_infinite_host_gas/Cargo.toml b/wasm_for_tests/vp_infinite_host_gas/Cargo.toml new file mode 100644 index 0000000000..5908f8a48d --- /dev/null +++ b/wasm_for_tests/vp_infinite_host_gas/Cargo.toml @@ -0,0 +1,29 @@ +[package] +name = "vp_infinite_host_gas" +description = "Wasm vp used for testing." +authors.workspace = true +edition.workspace = true +license.workspace = true +version.workspace = true + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +namada_test_utils.workspace = true +namada_tx_prelude.workspace = true +namada_vp_prelude.workspace = true +wee_alloc.workspace = true +getrandom.workspace = true + +[dev-dependencies] +namada_tests = { path = "../../crates/tests", default-features = false, features = [ + "wasm-runtime", +] } + +proptest = "1.4.0" +test-log = {version = "0.2.14", default-features = false, features = ["trace"]} +tracing = "0.1.30" +tracing-subscriber = {version = "0.3.7", default-features = false, features = ["env-filter", "fmt"]} + +[lib] +crate-type = ["cdylib"] \ No newline at end of file diff --git a/wasm_for_tests/vp_infinite_host_gas/src/lib.rs b/wasm_for_tests/vp_infinite_host_gas/src/lib.rs new file mode 100644 index 0000000000..bf0ee79041 --- /dev/null +++ b/wasm_for_tests/vp_infinite_host_gas/src/lib.rs @@ -0,0 +1,19 @@ +use namada_vp_prelude::*; + +/// A vp that endlessly charges gas from the host environment +#[validity_predicate] +fn validate_tx( + ctx: &Ctx, + _tx_data: Tx, + _addr: Address, + _keys_changed: BTreeSet, + _verifiers: BTreeSet
, +) -> VpResult { + let target_key = + namada_tx_prelude::parameters_storage::get_tx_allowlist_storage_key(); + loop { + // NOTE: don't propagate the error to verify that execution abortion + // is done in host and does not require guest cooperation + let _ = ctx.read_bytes_pre(&target_key); + } +} diff --git a/wasm_for_tests/vp_memory_limit/src/lib.rs b/wasm_for_tests/vp_memory_limit/src/lib.rs index 57ef95c7d4..09284f61b1 100644 --- a/wasm_for_tests/vp_memory_limit/src/lib.rs +++ b/wasm_for_tests/vp_memory_limit/src/lib.rs @@ -1,6 +1,6 @@ use namada_vp_prelude::*; -#[validity_predicate(gas = 1000)] +#[validity_predicate] fn validate_tx( _ctx: &Ctx, tx_data: Tx, diff --git a/wasm_for_tests/vp_read_storage_key/src/lib.rs b/wasm_for_tests/vp_read_storage_key/src/lib.rs index a930a364b1..40bc8a4a53 100644 --- a/wasm_for_tests/vp_read_storage_key/src/lib.rs +++ b/wasm_for_tests/vp_read_storage_key/src/lib.rs @@ -1,6 +1,6 @@ use namada_vp_prelude::*; -#[validity_predicate(gas = 1000)] +#[validity_predicate] fn validate_tx( ctx: &Ctx, tx_data: Tx, @@ -13,6 +13,6 @@ fn validate_tx( storage::Key::try_from_slice(&tx_data.data().as_ref().unwrap()[..]) .unwrap(); log_string(format!("key {}", key)); - let _result: Vec = ctx.read_pre(&key)?.unwrap(); + let _result: Vec = ctx.read_pre(&key).into_vp_error()?.unwrap(); accept() }