diff --git a/apps/src/lib/bench_utils.rs b/apps/src/lib/bench_utils.rs index e8a0c464c54..4c8eda1ae29 100644 --- a/apps/src/lib/bench_utils.rs +++ b/apps/src/lib/bench_utils.rs @@ -257,7 +257,7 @@ impl BenchShell { wasm_code_path: &str, data: impl BorshSerialize, shielded: Option, - extra_section: Option>, + extra_sections: Option>, signer: Option<&SecretKey>, ) -> Tx { let mut tx = @@ -279,7 +279,7 @@ impl BenchShell { tx.add_section(Section::MaspTx(transaction)); } - if let Some(sections) = extra_section { + if let Some(sections) = extra_sections { for section in sections { if let Section::ExtraData(_) = section { tx.add_section(section); @@ -289,7 +289,7 @@ impl BenchShell { if let Some(signer) = signer { tx.add_section(Section::Signature(Signature::new( - tx.sechashes(), + vec![tx.raw_header_hash()], [(0, signer.clone())].into_iter().collect(), None, ))); diff --git a/apps/src/lib/cli.rs b/apps/src/lib/cli.rs index dc510e21f3b..4f4ee68ed1b 100644 --- a/apps/src/lib/cli.rs +++ b/apps/src/lib/cli.rs @@ -2771,7 +2771,7 @@ pub mod args { pub const FEE_PAYER_OPT: ArgOpt = arg_opt("gas-payer"); pub const FORCE: ArgFlag = flag("force"); pub const GAS_LIMIT: ArgDefault = - arg_default("gas-limit", DefaultFn(|| GasLimit::from(20_000))); + arg_default("gas-limit", DefaultFn(|| GasLimit::from(25_000))); pub const FEE_TOKEN: ArgDefaultFromCtx = arg_default_from_ctx("gas-token", DefaultFn(|| "NAM".parse().unwrap())); pub const FEE_PAYER: Arg = arg("fee-payer"); diff --git a/apps/src/lib/node/ledger/shell/mod.rs b/apps/src/lib/node/ledger/shell/mod.rs index 0b7237e9c11..f643710cb0c 100644 --- a/apps/src/lib/node/ledger/shell/mod.rs +++ b/apps/src/lib/node/ledger/shell/mod.rs @@ -2808,7 +2808,7 @@ mod shell_tests { Tx::from_type(TxType::Wrapper(Box::new(WrapperTx::new( Fee { amount_per_gas_unit: 100.into(), - token: address::btc(), + token: address::apfel(), }, crate::wallet::defaults::albert_keypair().ref_to(), Epoch(0), diff --git a/apps/src/lib/node/ledger/shell/process_proposal.rs b/apps/src/lib/node/ledger/shell/process_proposal.rs index 32f4b5c11c6..69535757d06 100644 --- a/apps/src/lib/node/ledger/shell/process_proposal.rs +++ b/apps/src/lib/node/ledger/shell/process_proposal.rs @@ -2532,7 +2532,7 @@ mod test_process_proposal { Tx::from_type(TxType::Wrapper(Box::new(WrapperTx::new( Fee { amount_per_gas_unit: 100.into(), - token: address::btc(), + token: address::apfel(), }, crate::wallet::defaults::albert_keypair().ref_to(), Epoch(0), diff --git a/apps/src/lib/node/ledger/storage/mod.rs b/apps/src/lib/node/ledger/storage/mod.rs index 7a1f44e6f90..f8b7c7aade5 100644 --- a/apps/src/lib/node/ledger/storage/mod.rs +++ b/apps/src/lib/node/ledger/storage/mod.rs @@ -54,6 +54,7 @@ mod tests { use std::collections::HashMap; use itertools::Itertools; + use namada::ledger::gas::STORAGE_ACCESS_GAS_PER_BYTE; use namada::ledger::parameters::{EpochDuration, Parameters}; use namada::ledger::storage::write_log::WriteLog; use namada::ledger::storage::{ @@ -91,10 +92,10 @@ mod tests { // before insertion let (result, gas) = storage.has_key(&key).expect("has_key failed"); assert!(!result); - assert_eq!(gas, key.len() as u64); + assert_eq!(gas, key.len() as u64 * STORAGE_ACCESS_GAS_PER_BYTE); let (result, gas) = storage.read(&key).expect("read failed"); assert_eq!(result, None); - assert_eq!(gas, key.len() as u64); + assert_eq!(gas, key.len() as u64 * STORAGE_ACCESS_GAS_PER_BYTE); // insert storage.write(&key, value_bytes).expect("write failed"); @@ -102,13 +103,17 @@ mod tests { // read let (result, gas) = storage.has_key(&key).expect("has_key failed"); assert!(result); - assert_eq!(gas, key.len() as u64); + assert_eq!(gas, key.len() as u64 * STORAGE_ACCESS_GAS_PER_BYTE); let (result, gas) = storage.read(&key).expect("read failed"); let read_value: u64 = types::decode(result.expect("value doesn't exist")) .expect("decoding failed"); assert_eq!(read_value, value); - assert_eq!(gas, key.len() as u64 + value_bytes_len as u64); + assert_eq!( + gas, + (key.len() as u64 + value_bytes_len as u64) + * STORAGE_ACCESS_GAS_PER_BYTE + ); // delete storage.delete(&key).expect("delete failed"); @@ -276,7 +281,7 @@ mod tests { storage.commit_block(batch).expect("commit failed"); let (iter, gas) = storage.iter_prefix(&prefix); - assert_eq!(gas, prefix.len() as u64); + assert_eq!(gas, (prefix.len() as u64) * STORAGE_ACCESS_GAS_PER_BYTE); for (k, v, gas) in iter { match expected.pop() { Some((expected_key, expected_val)) => { @@ -312,7 +317,7 @@ mod tests { let (vp, gas) = storage.validity_predicate(&addr).expect("VP load failed"); assert_eq!(vp, None); - assert_eq!(gas, key.len() as u64); + assert_eq!(gas, (key.len() as u64) * STORAGE_ACCESS_GAS_PER_BYTE); // insert let vp1 = Hash::sha256("vp1".as_bytes()); @@ -322,7 +327,10 @@ mod tests { let (vp_code_hash, gas) = storage.validity_predicate(&addr).expect("VP load failed"); assert_eq!(vp_code_hash.expect("no VP"), vp1); - assert_eq!(gas, (key.len() + vp1.len()) as u64); + assert_eq!( + gas, + ((key.len() + vp1.len()) as u64) * STORAGE_ACCESS_GAS_PER_BYTE + ); } proptest! { diff --git a/benches/vps.rs b/benches/vps.rs index 0158d26c245..9023e38bcda 100644 --- a/benches/vps.rs +++ b/benches/vps.rs @@ -149,7 +149,7 @@ fn vp_user(c: &mut Criterion) { b.iter(|| { assert!( // NOTE: the wasm code is always in cache so we don't - // include here the cost to read and compile the code + // include here the cost to read and compile the vp code run::vp( vp_code_hash, signed_tx, diff --git a/core/src/ledger/gas.rs b/core/src/ledger/gas.rs index 0b068574e83..0fefccd983a 100644 --- a/core/src/ledger/gas.rs +++ b/core/src/ledger/gas.rs @@ -58,7 +58,7 @@ pub const IBC_ACTION_EXECUTE_GAS: u64 = 47_452; pub type Result = std::result::Result; /// Decimal scale of Gas units -const SCALE: u64 = 1_000; +const SCALE: u64 = 10_000; /// Helper function to retrieve the `max_block_gas` protocol parameter from /// storage diff --git a/core/src/ledger/storage/write_log.rs b/core/src/ledger/storage/write_log.rs index dae32b6e915..0cb7b91a2e8 100644 --- a/core/src/ledger/storage/write_log.rs +++ b/core/src/ledger/storage/write_log.rs @@ -750,7 +750,7 @@ mod tests { // read a non-existing key let (value, gas) = write_log.read(&key); assert!(value.is_none()); - assert_eq!(gas, key.len() as u64); + assert_eq!(gas, (key.len() as u64) * MEMORY_ACCESS_GAS_PER_BYTE); // delete a non-existing key let (gas, diff) = write_log.delete(&key).unwrap(); @@ -774,7 +774,10 @@ mod tests { } _ => panic!("unexpected read result"), } - assert_eq!(gas, (key.len() + inserted.len()) as u64); + assert_eq!( + gas, + ((key.len() + inserted.len()) as u64) * MEMORY_ACCESS_GAS_PER_BYTE + ); // update the value let updated = "updated".as_bytes().to_vec(); diff --git a/shared/src/vm/wasm/run.rs b/shared/src/vm/wasm/run.rs index 2607eaaf783..b318f51373d 100644 --- a/shared/src/vm/wasm/run.rs +++ b/shared/src/vm/wasm/run.rs @@ -566,7 +566,7 @@ mod tests { use crate::types::validity_predicate::EvalVp; use crate::vm::wasm; - const TX_GAS_LIMIT: u64 = 100_000_000; + const TX_GAS_LIMIT: u64 = 10_000_000_000; /// Test that when a transaction wasm goes over the stack-height limit, the /// execution is aborted. diff --git a/tests/src/vm_host_env/vp.rs b/tests/src/vm_host_env/vp.rs index 69d7af9bb1b..ca2fc025bc0 100644 --- a/tests/src/vm_host_env/vp.rs +++ b/tests/src/vm_host_env/vp.rs @@ -75,7 +75,7 @@ impl Default for TestVpEnv { wl_storage, iterators: PrefixIterators::default(), gas_meter: VpGasMeter::new_from_tx_meter( - &TxGasMeter::new_from_sub_limit(10_000_000.into()), + &TxGasMeter::new_from_sub_limit(10_000_000_000.into()), ), tx, tx_index: TxIndex::default(),