Skip to content

Commit

Permalink
Increases gas limits in unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
grarco committed Mar 18, 2024
1 parent 571dba2 commit e225cb5
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 26 deletions.
35 changes: 15 additions & 20 deletions crates/apps/src/lib/node/ledger/shell/finalize_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -800,7 +800,8 @@ mod test_finalize_block {
FinalizeBlock, ProcessedTx,
};

const GAS_LIMIT_MULTIPLIER: u64 = 100_000_000;
const GAS_LIMIT: u64 = 10_000_000_000;
const WRAPPER_GAS_LIMIT: u64 = 20_000;

/// Make a wrapper tx and a processed tx from the wrapped tx that can be
/// added to `FinalizeBlock` request.
Expand All @@ -816,7 +817,7 @@ mod test_finalize_block {
},
keypair.ref_to(),
Epoch(0),
GAS_LIMIT_MULTIPLIER.into(),
WRAPPER_GAS_LIMIT.into(),
None,
))));
wrapper_tx.header.chain_id = shell.chain_id.clone();
Expand Down Expand Up @@ -857,7 +858,7 @@ mod test_finalize_block {
},
keypair.ref_to(),
Epoch(0),
GAS_LIMIT_MULTIPLIER.into(),
WRAPPER_GAS_LIMIT.into(),
None,
))));
outer_tx.header.chain_id = shell.chain_id.clone();
Expand Down Expand Up @@ -973,7 +974,7 @@ mod test_finalize_block {
},
keypair.ref_to(),
Epoch(0),
GAS_LIMIT_MULTIPLIER.into(),
WRAPPER_GAS_LIMIT.into(),
None,
))));
outer_tx.header.chain_id = shell.chain_id.clone();
Expand Down Expand Up @@ -1027,7 +1028,7 @@ mod test_finalize_block {
},
keypair.ref_to(),
Epoch(0),
GAS_LIMIT_MULTIPLIER.into(),
WRAPPER_GAS_LIMIT.into(),
None,
))));
let processed_tx = ProcessedTx {
Expand Down Expand Up @@ -2758,7 +2759,7 @@ mod test_finalize_block {
},
keypair.ref_to(),
Epoch(0),
GAS_LIMIT_MULTIPLIER.into(),
WRAPPER_GAS_LIMIT.into(),
None,
))));
wrapper.header.chain_id = shell.chain_id.clone();
Expand All @@ -2775,7 +2776,7 @@ mod test_finalize_block {
},
keypair_2.ref_to(),
Epoch(0),
GAS_LIMIT_MULTIPLIER.into(),
WRAPPER_GAS_LIMIT.into(),
None,
))));
new_wrapper.add_section(Section::Signature(Signature::new(
Expand Down Expand Up @@ -2816,8 +2817,8 @@ mod test_finalize_block {
})
}

shell.enqueue_tx(wrapper.clone(), GAS_LIMIT_MULTIPLIER.into());
shell.enqueue_tx(new_wrapper.clone(), GAS_LIMIT_MULTIPLIER.into());
shell.enqueue_tx(wrapper.clone(), GAS_LIMIT.into());
shell.enqueue_tx(new_wrapper.clone(), GAS_LIMIT.into());
// merkle tree root before finalize_block
let root_pre = shell.shell.state.in_mem().block.tree.root();

Expand Down Expand Up @@ -2884,7 +2885,7 @@ mod test_finalize_block {
},
keypair.ref_to(),
Epoch(0),
GAS_LIMIT_MULTIPLIER.into(),
WRAPPER_GAS_LIMIT.into(),
None,
))));
unsigned_wrapper.header.chain_id = shell.chain_id.clone();
Expand Down Expand Up @@ -2965,16 +2966,10 @@ mod test_finalize_block {
}

shell.enqueue_tx(out_of_gas_wrapper.clone(), Gas::default());
shell.enqueue_tx(
undecryptable_wrapper.clone(),
GAS_LIMIT_MULTIPLIER.into(),
);
shell.enqueue_tx(undecryptable_wrapper.clone(), GAS_LIMIT.into());
shell.enqueue_tx(unsigned_wrapper.clone(), u64::MAX.into()); // Prevent out of gas which would still make the test pass
shell.enqueue_tx(
wrong_commitment_wrapper.clone(),
GAS_LIMIT_MULTIPLIER.into(),
);
shell.enqueue_tx(failing_wrapper.clone(), GAS_LIMIT_MULTIPLIER.into());
shell.enqueue_tx(wrong_commitment_wrapper.clone(), GAS_LIMIT.into());
shell.enqueue_tx(failing_wrapper.clone(), GAS_LIMIT.into());
// merkle tree root before finalize_block
let root_pre = shell.shell.state.in_mem().block.tree.root();

Expand Down Expand Up @@ -3138,7 +3133,7 @@ mod test_finalize_block {
},
keypair.ref_to(),
Epoch(0),
GAS_LIMIT_MULTIPLIER.into(),
WRAPPER_GAS_LIMIT.into(),
None,
))));
wrapper.header.chain_id = shell.chain_id.clone();
Expand Down
2 changes: 1 addition & 1 deletion crates/namada/src/ledger/native_vp/ibc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ mod tests {

const ADDRESS: Address = Address::Internal(InternalAddress::Ibc);
const COMMITMENT_PREFIX: &[u8] = b"ibc";
const TX_GAS_LIMIT: u64 = 1_000_000;
const TX_GAS_LIMIT: u64 = 10_000_000_000;

fn get_client_id() -> ClientId {
let id = format!("{}-0", MOCK_CLIENT_TYPE);
Expand Down
2 changes: 1 addition & 1 deletion crates/namada/src/vm/wasm/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -834,7 +834,7 @@ mod tests {
use crate::vm::host_env::TxRuntimeError;
use crate::vm::wasm;

const TX_GAS_LIMIT: u64 = 10_000_000_000;
const TX_GAS_LIMIT: u64 = 10_000_000_000_000;
const OUT_OF_GAS_LIMIT: u64 = 10_000;

/// Test that we sanitize accesses to invalid addresses in wasm memory.
Expand Down
4 changes: 2 additions & 2 deletions crates/tests/src/vm_host_env/ibc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ pub fn validate_ibc_vp_from_tx<'a>(
wasm::compilation_cache::common::testing::cache();

let gas_meter = RefCell::new(VpGasMeter::new_from_tx_meter(
&TxGasMeter::new_from_sub_limit(1_000_000.into()),
&TxGasMeter::new_from_sub_limit(10_000_000_000.into()),
));
let sentinel = RefCell::new(VpSentinel::default());
let ctx = Ctx::new(
Expand Down Expand Up @@ -187,7 +187,7 @@ pub fn validate_multitoken_vp_from_tx<'a>(
wasm::compilation_cache::common::testing::cache();

let gas_meter = RefCell::new(VpGasMeter::new_from_tx_meter(
&TxGasMeter::new_from_sub_limit(1_000_000.into()),
&TxGasMeter::new_from_sub_limit(10_000_000_000.into()),
));
let sentinel = RefCell::new(VpSentinel::default());
let ctx = Ctx::new(
Expand Down
2 changes: 1 addition & 1 deletion crates/tests/src/vm_host_env/tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ impl Default for TestTxEnv {
state,
iterators: PrefixIterators::default(),
gas_meter: RefCell::new(TxGasMeter::new_from_sub_limit(
100_000_000.into(),
100_000_000_000.into(),
)),
sentinel: RefCell::new(TxSentinel::default()),
tx_index: TxIndex::default(),
Expand Down
2 changes: 1 addition & 1 deletion crates/tests/src/vm_host_env/vp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ impl Default for TestVpEnv {
state,
iterators: PrefixIterators::default(),
gas_meter: RefCell::new(VpGasMeter::new_from_tx_meter(
&TxGasMeter::new_from_sub_limit(10_000_000_000.into()),
&TxGasMeter::new_from_sub_limit(1_000_000_000_000.into()),
)),
sentinel: RefCell::new(VpSentinel::default()),
tx,
Expand Down

0 comments on commit e225cb5

Please sign in to comment.