From e6a6d41390682ae342504c8b8dd52c9a26da7f11 Mon Sep 17 00:00:00 2001 From: Michael Zaikin Date: Tue, 2 Jul 2024 22:45:47 +0100 Subject: [PATCH 1/2] EVM/Kernel: tune FA bridge tick & gas model --- etherlink/CHANGES_KERNEL.md | 2 + .../evm_execution/src/fa_bridge/mod.rs | 48 +++++++++++------ .../src/precompiles/fa_bridge.rs | 51 ++++++++++++++----- .../src/precompiles/withdrawal.rs | 15 +++--- etherlink/kernel_evm/kernel/src/lib.rs | 4 +- etherlink/tezt/tests/evm_rollup.ml | 10 ++-- 6 files changed, 89 insertions(+), 41 deletions(-) diff --git a/etherlink/CHANGES_KERNEL.md b/etherlink/CHANGES_KERNEL.md index 066c995d8a55..71db07d255ac 100644 --- a/etherlink/CHANGES_KERNEL.md +++ b/etherlink/CHANGES_KERNEL.md @@ -31,6 +31,8 @@ - L1 proxy address is added as a field to the FA withdrawal event. (!14260) - Forbids in the code module to overwrite the code storage of an account. Execution forbid this. (!14317) +- Tick model is updated with regards to FA deposits and withdrawals. (!14016) +- Gas cost of XTZ/FA withdrawals is increased to prevent abuses. (!14016) ## Version 4f4457e2527cb227a90bb1c56d3a83f39c0f78fd diff --git a/etherlink/kernel_evm/evm_execution/src/fa_bridge/mod.rs b/etherlink/kernel_evm/evm_execution/src/fa_bridge/mod.rs index 083030b87235..6c0c732ce8bd 100644 --- a/etherlink/kernel_evm/evm_execution/src/fa_bridge/mod.rs +++ b/etherlink/kernel_evm/evm_execution/src/fa_bridge/mod.rs @@ -62,25 +62,40 @@ mod tests; #[cfg(any(test, feature = "fa_bridge_testing"))] pub mod test_utils; -/// TODO: Gas limit for calling "deposit" method of the proxy contract call. +/// Gas limit for calling "deposit" method of the proxy contract call. /// Since we cannot control a particular destination, /// we need to make sure there's no DoS attack vector. -pub const FA_DEPOSIT_PROXY_GAS_LIMIT: u64 = 1_200_000; +/// +/// Current value reflects roughly the fees paid on L1 for initiating +/// the deposit. Since only smart contracts can mint tickets and send +/// internal inbox messages, the lower bound for a single deposit is +/// approximately 0.0005ꜩ; assuming current price per L2 gas of 1 Gwei +/// the equivalent amount of gas is 0.0005 * 10^18 / 10^9 = 500_000 +/// +/// Multiplying by two to enable more involved proxy contract implementations. +pub const FA_DEPOSIT_PROXY_GAS_LIMIT: u64 = 1_000_000; -/// TODO: Overapproximation of the amount of ticks for updating +/// Overapproximation of the amount of ticks for updating /// the global ticket table and emitting deposit event. -pub const FA_DEPOSIT_INNER_TICKS: u64 = 2_000_000; - -/// Number of ticks used to parse FA deposit -pub const TICKS_PER_FA_DEPOSIT_PARSING: u64 = 2_000_000; - -/// TODO: Overapproximation of the amount of ticks required -/// to execute a FA deposit. -pub const FA_DEPOSIT_TOTAL_TICKS: u64 = 10_000_000; +/// +/// It does not include the ticks consumed by the ERC proxy execution +/// as it is accounted independently by the EVM hander. +/// +/// Obtained by running the `bench_fa_deposit` script and examining the +/// `run_transaction_ticks` for the maximum value. +/// The final ticks amount has +50% safe reserve. +pub const FA_DEPOSIT_EXECUTE_TICKS: u64 = 2_250_000; -/// TODO: Overapproximation of the amount of ticks for updating -/// the global ticket table, and emitting withdraw event. -pub const FA_WITHDRAWAL_INNER_TICKS: u64 = 3_000_000; +/// Overapproximation of the amount of ticks for parsing FA deposit. +/// Also includes hashing costs. +/// +/// Obtained by running the `bench_fa_deposit` and examining both +/// `hashing_ticks` and `signature_verification_ticks` (parsing). +/// The final value is maximum total plus +50% reserve. +/// +/// NOTE that we have a hard cap because of the maximum inbox message size limitation. +/// If it is lifted at some point in the future, we need to reflect that. +pub const TICKS_PER_FA_DEPOSIT_PARSING: u64 = 3_500_000; macro_rules! create_outcome_error { ($($arg:tt)*) => { @@ -158,7 +173,7 @@ pub fn execute_fa_deposit<'a, Host: Runtime>( // Adjust resource consumption to account for the outer transaction outcome.gas_used += config.gas_transaction_call; - outcome.estimated_ticks_used += FA_DEPOSIT_INNER_TICKS; + outcome.estimated_ticks_used += FA_DEPOSIT_EXECUTE_TICKS; Ok(outcome) } @@ -207,7 +222,8 @@ pub fn execute_fa_withdrawal( exit_status, withdrawals, output: vec![], - estimated_ticks: FA_WITHDRAWAL_INNER_TICKS, + // Precompile and inner proxy calls have already registered their costs + estimated_ticks: 0, }) } diff --git a/etherlink/kernel_evm/evm_execution/src/precompiles/fa_bridge.rs b/etherlink/kernel_evm/evm_execution/src/precompiles/fa_bridge.rs index d71fde9a4d55..8a062e9d1f6a 100644 --- a/etherlink/kernel_evm/evm_execution/src/precompiles/fa_bridge.rs +++ b/etherlink/kernel_evm/evm_execution/src/precompiles/fa_bridge.rs @@ -24,13 +24,32 @@ use crate::{ use super::{PrecompileOutcome, FA_BRIDGE_PRECOMPILE_ADDRESS}; -/// TODO: Overapproximation of the amount of ticks for parsing -/// FA withdrawal from calldata, and checking transfer value. -pub const FA_WITHDRAWAL_OUTER_TICKS: u64 = 3_000_000; - -/// TODO: Cost of doing FA withdrawal excluding the gas consumed -/// by the inner proxy contract call. -pub const FA_WITHDRAWAL_OUTER_GAS_COST: u64 = 1500; +/// Overapproximation of the amount of ticks for parsing +/// FA withdrawal from calldata, checking transfer value, +/// and executing the FA withdrawal, excluding the ticks consumed by +/// the inner proxy call. +/// +/// Linear regression parameters are obtained by running `bench_fa_withdrawal` +/// script, evaluating `run_transaction_ticks` against `data_size`. +/// Intercept is extended with +50% safe reserve. +pub const FA_WITHDRAWAL_PRECOMPILE_TICKS_INTERCEPT: u64 = 4_000_000; +pub const FA_WITHDRAWAL_PRECOMPILE_TICKS_SLOPE: u64 = 700; + +/// Added ("artificial") cost of doing FA withdrawal not including actual gas +/// spent for executing the withdrawal (and inner proxy contract call). +/// +/// This is roughly the implied costs of executing the outbox message on L1 +/// as a spam prevention mechanism (outbox queue clogging). +/// In particular it prevents cases when a big number of withdrawals is batched +/// together in a single transaction which exploits the system. +/// +/// An execution of a single outbox message carrying a FA withdrawal +/// costs around 0.0025ꜩ on L1; assuming current price per L2 gas of 1 Gwei +/// the equivalent amount of gas is 0.0025 * 10^18 / 10^9 = 2_500_000 +/// +/// Multiplying by 2 to have a safe reserve but at the same time keeping +/// L2 fees per withdrawal below 1 cent. +pub const FA_WITHDRAWAL_PRECOMPILE_ADDED_GAS_COST: u64 = 5_000_000; macro_rules! precompile_outcome_error { ($($arg:tt)*) => { @@ -40,7 +59,7 @@ macro_rules! precompile_outcome_error { )), withdrawals: vec![], output: vec![], - estimated_ticks: FA_WITHDRAWAL_OUTER_TICKS, + estimated_ticks: 0, } }; } @@ -54,9 +73,17 @@ pub fn fa_bridge_precompile( is_static: bool, transfer: Option, ) -> Result { - fail_if_too_much!(FA_WITHDRAWAL_OUTER_TICKS, handler); - - if handler.record_cost(FA_WITHDRAWAL_OUTER_GAS_COST).is_err() { + // We register the cost of the precompile early to prevent cases where inner proxy call + // consumes more ticks than allowed. + let estimated_ticks = FA_WITHDRAWAL_PRECOMPILE_TICKS_SLOPE * (input.len() as u64) + + FA_WITHDRAWAL_PRECOMPILE_TICKS_INTERCEPT; + handler.estimated_ticks_used += fail_if_too_much!(estimated_ticks, handler); + + // We also record gas cost which consists of computation cost (1 gas unit per 1000 ticks) + // and added FA withdrawal cost (spam prevention measure). + let estimated_gas_cost = + estimated_ticks / 1000 + FA_WITHDRAWAL_PRECOMPILE_ADDED_GAS_COST; + if handler.record_cost(estimated_gas_cost).is_err() { return Ok(precompile_outcome_error!( "FA withdrawal: gas limit too low" )); @@ -366,7 +393,7 @@ mod tests { ticket_owner, None, input, - Some(40000), + Some(6000000), false, ); assert!(outcome.is_success()); diff --git a/etherlink/kernel_evm/evm_execution/src/precompiles/withdrawal.rs b/etherlink/kernel_evm/evm_execution/src/precompiles/withdrawal.rs index 0471996ac640..4ddbc478ac3a 100644 --- a/etherlink/kernel_evm/evm_execution/src/precompiles/withdrawal.rs +++ b/etherlink/kernel_evm/evm_execution/src/precompiles/withdrawal.rs @@ -39,7 +39,10 @@ use tezos_smart_rollup_encoding::outbox::{OutboxMessage, OutboxMessageTransactio /// Cost of doing a withdrawal. A valid call to this precompiled contract /// takes almost 880000 ticks, and one gas unit takes 1000 ticks. /// The ticks/gas ratio is from benchmarks on `ecrecover`. -const WITHDRAWAL_COST: u64 = 880; +/// +/// Also includes the implied costs of executing the outbox message on L1 +/// see FA_WITHDRAWAL_PRECOMPILE_GAS_COST constant for more details. +const WITHDRAWAL_COST: u64 = 880 + 5_000_000; /// Keccak256 of Withdrawal(uint256,address,bytes22,uint256) /// This is main topic (non-anonymous event): https://docs.soliditylang.org/en/latest/abi-spec.html#events @@ -412,7 +415,7 @@ mod tests { value: eth_from_mutez(value_mutez), }); - let result = execute_precompiled(target, input, transfer, Some(25000), false); + let result = execute_precompiled(target, input, transfer, Some(6000000), false); let expected_output = vec![]; let message = make_message( @@ -487,7 +490,7 @@ mod tests { value: eth_from_mutez(value_mutez), }); - let result = execute_precompiled(target, input, transfer, Some(25000), false); + let result = execute_precompiled(target, input, transfer, Some(6000000), false); let expected_output = vec![]; let message = make_message( @@ -551,7 +554,7 @@ mod tests { let transfer: Option = None; - let result = execute_precompiled(target, input, transfer, Some(25000), false); + let result = execute_precompiled(target, input, transfer, Some(6000000), false); let expected_gas = 21000 // base cost, no additional cost for withdrawal + 1032 // transaction data cost (90 zero bytes + 42 non zero bytes) @@ -589,7 +592,7 @@ mod tests { estimated_ticks_used: 880_000, }; - let result = execute_precompiled(target, input, transfer, Some(25000), false); + let result = execute_precompiled(target, input, transfer, Some(6000000), false); assert_eq!(Ok(expected), result); @@ -613,7 +616,7 @@ mod tests { estimated_ticks_used: 880_000, }; - let result = execute_precompiled(target, input, transfer, Some(25000), true); + let result = execute_precompiled(target, input, transfer, Some(6000000), true); assert_eq!(Ok(expected), result); } diff --git a/etherlink/kernel_evm/kernel/src/lib.rs b/etherlink/kernel_evm/kernel/src/lib.rs index 7f40e1b8e082..ac68212ccc98 100644 --- a/etherlink/kernel_evm/kernel/src/lib.rs +++ b/etherlink/kernel_evm/kernel/src/lib.rs @@ -706,7 +706,7 @@ mod tests { 0, gas_price, gas_price, - 2000000, + 10_000_000, Some(to), U256::from(1000000000000000000u64), data, @@ -945,7 +945,7 @@ mod tests { 0, gas_price, gas_price, - 2000000, + 10_000_000, Some(to), U256::zero(), data, diff --git a/etherlink/tezt/tests/evm_rollup.ml b/etherlink/tezt/tests/evm_rollup.ml index 52e2ca243241..506523ed6324 100644 --- a/etherlink/tezt/tests/evm_rollup.ml +++ b/etherlink/tezt/tests/evm_rollup.ml @@ -2355,7 +2355,7 @@ let call_withdraw ?expect_failure ~sender ~endpoint ~value ~produce_block ~address:"0xff00000000000000000000000000000000000001" ~method_call:(sf {|withdraw_base58("%s")|} receiver) ~value - ~gas:50_000 + ~gas:6_000_000 in wait_for_application ~produce_block call_withdraw @@ -2551,7 +2551,7 @@ let test_withdraw_via_calls = ~abi_label:call_withdrawal.label ~address:contract ~method_call:"testCall()" - ~gas:100_000 + ~gas:6_000_000 ~value:(Wei.of_eth_int 1) in let* tx = wait_for_application ~produce_block call in @@ -2567,7 +2567,7 @@ let test_withdraw_via_calls = ~abi_label:call_withdrawal.label ~address:contract ~method_call:"testDelegatecall()" - ~gas:100_000 + ~gas:6_000_000 ~value:(Wei.of_eth_int 1) in let* tx = wait_for_application ~produce_block delegate_call in @@ -2583,7 +2583,7 @@ let test_withdraw_via_calls = ~abi_label:call_withdrawal.label ~address:contract ~method_call:"testStaticcall()" - ~gas:100_000 + ~gas:6_000_000 ~value:(Wei.of_eth_int 1) in let* tx = wait_for_application ~produce_block static_call in @@ -2603,7 +2603,7 @@ let test_withdraw_via_calls = ~abi_label:callcode_withdrawal.label ~address:contract ~method_call:"testCallcode()" - ~gas:100_000 + ~gas:6_000_000 ~value:(Wei.of_eth_int 1) in let* tx = wait_for_application ~produce_block callcode in -- GitLab From a695166dd70f1e491c206cb67c14ffb568764ea1 Mon Sep 17 00:00:00 2001 From: Michael Zaikin Date: Tue, 13 Aug 2024 15:50:31 +0100 Subject: [PATCH 2/2] Added gas cost for XTZ/FA withdrawals --- .../src/precompiles/fa_bridge.rs | 33 +++++++--- .../src/precompiles/withdrawal.rs | 62 ++++++++++++++----- etherlink/kernel_evm/kernel/src/lib.rs | 2 +- etherlink/tezt/tests/evm_rollup.ml | 10 +-- etherlink/tezt/tests/evm_sequencer.ml | 6 +- 5 files changed, 78 insertions(+), 35 deletions(-) diff --git a/etherlink/kernel_evm/evm_execution/src/precompiles/fa_bridge.rs b/etherlink/kernel_evm/evm_execution/src/precompiles/fa_bridge.rs index 8a062e9d1f6a..5d85a859c2ab 100644 --- a/etherlink/kernel_evm/evm_execution/src/precompiles/fa_bridge.rs +++ b/etherlink/kernel_evm/evm_execution/src/precompiles/fa_bridge.rs @@ -11,8 +11,8 @@ //! * Alters ticket table (changes balance) //! * Increments outbox counter -use evm::{Context, Transfer}; -use primitive_types::H160; +use evm::{Context, Handler, Transfer}; +use primitive_types::{H160, U256}; use tezos_smart_rollup_host::runtime::Runtime; use crate::{ @@ -44,12 +44,26 @@ pub const FA_WITHDRAWAL_PRECOMPILE_TICKS_SLOPE: u64 = 700; /// together in a single transaction which exploits the system. /// /// An execution of a single outbox message carrying a FA withdrawal -/// costs around 0.0025ꜩ on L1; assuming current price per L2 gas of 1 Gwei -/// the equivalent amount of gas is 0.0025 * 10^18 / 10^9 = 2_500_000 +/// costs around 0.0025ꜩ on L1; the equivalent amount of gas units on L2 is: +/// +/// 0.0025 * 10^18 / GAS_PRICE /// -/// Multiplying by 2 to have a safe reserve but at the same time keeping -/// L2 fees per withdrawal below 1 cent. -pub const FA_WITHDRAWAL_PRECOMPILE_ADDED_GAS_COST: u64 = 5_000_000; +/// Multiplying the numerator by 2 for a safe reserve and this is our cost in Wei. +pub const FA_WITHDRAWAL_PRECOMPILE_ADDED_COST: u64 = 5_000_000_000_000_000; + +/// Hard cap for the added gas cost (0.5 of the maximum gas limit per transaction). +/// If gas price drops the gas amount rises, but we don't want it to hit the transaction +/// gas limit. +pub const FA_WITHDRAWAL_PRECOMPILE_MAX_ADDED_CAS_COST: u64 = 15_000_000; + +/// Calculate precompile gas cost given the estimated amount of ticks and gas price. +fn estimate_gas_cost(estimated_ticks: u64, gas_price: U256) -> u64 { + // Using 1 gas unit ~= 1000 ticks convert ratio + let execution_cost = estimated_ticks / 1000; + let added_cost = U256::from(FA_WITHDRAWAL_PRECOMPILE_MAX_ADDED_CAS_COST) + .min(U256::from(FA_WITHDRAWAL_PRECOMPILE_ADDED_COST) / gas_price); + execution_cost + added_cost.as_u64() +} macro_rules! precompile_outcome_error { ($($arg:tt)*) => { @@ -81,8 +95,7 @@ pub fn fa_bridge_precompile( // We also record gas cost which consists of computation cost (1 gas unit per 1000 ticks) // and added FA withdrawal cost (spam prevention measure). - let estimated_gas_cost = - estimated_ticks / 1000 + FA_WITHDRAWAL_PRECOMPILE_ADDED_GAS_COST; + let estimated_gas_cost = estimate_gas_cost(estimated_ticks, handler.gas_price()); if handler.record_cost(estimated_gas_cost).is_err() { return Ok(precompile_outcome_error!( "FA withdrawal: gas limit too low" @@ -393,7 +406,7 @@ mod tests { ticket_owner, None, input, - Some(6000000), + Some(30_000_000), false, ); assert!(outcome.is_success()); diff --git a/etherlink/kernel_evm/evm_execution/src/precompiles/withdrawal.rs b/etherlink/kernel_evm/evm_execution/src/precompiles/withdrawal.rs index 4ddbc478ac3a..971dd6197095 100644 --- a/etherlink/kernel_evm/evm_execution/src/precompiles/withdrawal.rs +++ b/etherlink/kernel_evm/evm_execution/src/precompiles/withdrawal.rs @@ -17,6 +17,7 @@ use crate::precompiles::{SYSTEM_ACCOUNT_ADDRESS, WITHDRAWAL_ADDRESS}; use crate::read_ticketer; use crate::withdrawal_counter::WithdrawalCounter; use crate::{abi, fail_if_too_much, EthereumError}; +use evm::Handler; use evm::{Context, ExitReason, ExitRevert, ExitSucceed, Transfer}; use host::runtime::Runtime; use primitive_types::H160; @@ -36,13 +37,25 @@ use tezos_smart_rollup_encoding::michelson::{ }; use tezos_smart_rollup_encoding::outbox::{OutboxMessage, OutboxMessageTransaction}; -/// Cost of doing a withdrawal. A valid call to this precompiled contract -/// takes almost 880000 ticks, and one gas unit takes 1000 ticks. -/// The ticks/gas ratio is from benchmarks on `ecrecover`. +/// Added cost of doing a withdrawal. /// -/// Also includes the implied costs of executing the outbox message on L1 -/// see FA_WITHDRAWAL_PRECOMPILE_GAS_COST constant for more details. -const WITHDRAWAL_COST: u64 = 880 + 5_000_000; +/// This is roughly the implied costs of executing the outbox message on L1 +/// as a spam prevention mechanism (outbox queue clogging). +/// In particular it prevents cases when a big number of withdrawals is batched +/// together in a single transaction which exploits the system. +/// +/// An execution of a single outbox message carrying a XTZ withdrawal +/// costs around 0.0025ꜩ on L1; the equivalent amount of gas units on L2 is: +/// +/// 0.0025 * 10^18 / GAS_PRICE +/// +/// Multiplying the numerator by 2 for a safe reserve and this is our cost in Wei. +const WITHDRAWAL_PRECOMPILE_ADDED_COST: u64 = 5_000_000_000_000_000_000; + +/// Hard cap for the added gas cost (0.5 of the maximum gas limit per transaction). +/// If gas price drops the gas amount rises, but we don't want it to hit the transaction +/// gas limit. +const WITHDRAWAL_PRECOMPILE_MAX_ADDED_CAS_COST: u64 = 15_000_000; /// Keccak256 of Withdrawal(uint256,address,bytes22,uint256) /// This is main topic (non-anonymous event): https://docs.soliditylang.org/en/latest/abi-spec.html#events @@ -51,6 +64,15 @@ pub const WITHDRAWAL_EVENT_TOPIC: [u8; 32] = [ 102, 53, 63, 221, 233, 204, 248, 19, 244, 91, 132, 250, 130, ]; +/// Calculate precompile gas cost given the estimated amount of ticks and gas price. +fn estimate_gas_cost(estimated_ticks: u64, gas_price: U256) -> u64 { + // Using 1 gas unit ~= 1000 ticks convert ratio + let execution_cost = estimated_ticks / 1000; + let added_cost = U256::from(WITHDRAWAL_PRECOMPILE_MAX_ADDED_CAS_COST) + .min(U256::from(WITHDRAWAL_PRECOMPILE_ADDED_COST) / gas_price); + execution_cost + added_cost.as_u64() +} + fn prepare_message( parameters: RouterInterface, destination: Contract, @@ -87,7 +109,8 @@ pub fn withdrawal_precompile( } } - if let Err(err) = handler.record_cost(WITHDRAWAL_COST) { + let estimated_gas_cost = estimate_gas_cost(estimated_ticks, handler.gas_price()); + if let Err(err) = handler.record_cost(estimated_gas_cost) { log!( handler.borrow_host(), Info, @@ -285,7 +308,7 @@ mod tests { handler::{ExecutionOutcome, Withdrawal}, precompiles::{ test_helpers::{execute_precompiled, DUMMY_TICKETER}, - withdrawal::{WITHDRAWAL_COST, WITHDRAWAL_EVENT_TOPIC}, + withdrawal::WITHDRAWAL_EVENT_TOPIC, WITHDRAWAL_ADDRESS, }, }; @@ -415,7 +438,8 @@ mod tests { value: eth_from_mutez(value_mutez), }); - let result = execute_precompiled(target, input, transfer, Some(6000000), false); + let result = + execute_precompiled(target, input, transfer, Some(30_000_000), false); let expected_output = vec![]; let message = make_message( @@ -426,7 +450,8 @@ mod tests { let expected_gas = 21000 // base cost, no additional cost for withdrawal + 1032 // transaction data cost (90 zero bytes + 42 non zero bytes) - + WITHDRAWAL_COST; // cost of calling withdrawal precompiled contract + + 880 // gas for ticks + + 15_000_000; // cost of calling withdrawal precompiled contract (hard cap because of low gas price) let expected_log = Log { address: H160::zero(), @@ -490,7 +515,8 @@ mod tests { value: eth_from_mutez(value_mutez), }); - let result = execute_precompiled(target, input, transfer, Some(6000000), false); + let result = + execute_precompiled(target, input, transfer, Some(30_000_000), false); let expected_output = vec![]; let message = make_message( @@ -501,7 +527,8 @@ mod tests { let expected_gas = 21000 // base cost, no additional cost for withdrawal + 1032 // transaction data cost (90 zero bytes + 42 non zero bytes) - + WITHDRAWAL_COST; // cost of calling withdrawal precompiled contract + + 880 // gas for ticks + + 15_000_000; // cost of calling withdrawal precompiled contract (hard cap because of low gas price) let expected_log = Log { address: H160::zero(), @@ -554,11 +581,13 @@ mod tests { let transfer: Option = None; - let result = execute_precompiled(target, input, transfer, Some(6000000), false); + let result = + execute_precompiled(target, input, transfer, Some(30_000_000), false); let expected_gas = 21000 // base cost, no additional cost for withdrawal + 1032 // transaction data cost (90 zero bytes + 42 non zero bytes) - + WITHDRAWAL_COST; // cost of calling the withdrawals precompiled contract. + + 880 // gas for ticks + + 15_000_000; // cost of calling withdrawal precompiled contract (hard cap because of low gas price) let expected = ExecutionOutcome { gas_used: expected_gas, @@ -592,7 +621,8 @@ mod tests { estimated_ticks_used: 880_000, }; - let result = execute_precompiled(target, input, transfer, Some(6000000), false); + let result = + execute_precompiled(target, input, transfer, Some(30_000_000), false); assert_eq!(Ok(expected), result); @@ -616,7 +646,7 @@ mod tests { estimated_ticks_used: 880_000, }; - let result = execute_precompiled(target, input, transfer, Some(6000000), true); + let result = execute_precompiled(target, input, transfer, Some(30_000_000), true); assert_eq!(Ok(expected), result); } diff --git a/etherlink/kernel_evm/kernel/src/lib.rs b/etherlink/kernel_evm/kernel/src/lib.rs index ac68212ccc98..8b0e5e6061f4 100644 --- a/etherlink/kernel_evm/kernel/src/lib.rs +++ b/etherlink/kernel_evm/kernel/src/lib.rs @@ -706,7 +706,7 @@ mod tests { 0, gas_price, gas_price, - 10_000_000, + 30_000_000, Some(to), U256::from(1000000000000000000u64), data, diff --git a/etherlink/tezt/tests/evm_rollup.ml b/etherlink/tezt/tests/evm_rollup.ml index 506523ed6324..b0b67b534815 100644 --- a/etherlink/tezt/tests/evm_rollup.ml +++ b/etherlink/tezt/tests/evm_rollup.ml @@ -2355,7 +2355,7 @@ let call_withdraw ?expect_failure ~sender ~endpoint ~value ~produce_block ~address:"0xff00000000000000000000000000000000000001" ~method_call:(sf {|withdraw_base58("%s")|} receiver) ~value - ~gas:6_000_000 + ~gas:16_000_000 in wait_for_application ~produce_block call_withdraw @@ -2551,7 +2551,7 @@ let test_withdraw_via_calls = ~abi_label:call_withdrawal.label ~address:contract ~method_call:"testCall()" - ~gas:6_000_000 + ~gas:16_000_000 ~value:(Wei.of_eth_int 1) in let* tx = wait_for_application ~produce_block call in @@ -2567,7 +2567,7 @@ let test_withdraw_via_calls = ~abi_label:call_withdrawal.label ~address:contract ~method_call:"testDelegatecall()" - ~gas:6_000_000 + ~gas:16_000_000 ~value:(Wei.of_eth_int 1) in let* tx = wait_for_application ~produce_block delegate_call in @@ -2583,7 +2583,7 @@ let test_withdraw_via_calls = ~abi_label:call_withdrawal.label ~address:contract ~method_call:"testStaticcall()" - ~gas:6_000_000 + ~gas:16_000_000 ~value:(Wei.of_eth_int 1) in let* tx = wait_for_application ~produce_block static_call in @@ -2603,7 +2603,7 @@ let test_withdraw_via_calls = ~abi_label:callcode_withdrawal.label ~address:contract ~method_call:"testCallcode()" - ~gas:6_000_000 + ~gas:16_000_000 ~value:(Wei.of_eth_int 1) in let* tx = wait_for_application ~produce_block callcode in diff --git a/etherlink/tezt/tests/evm_sequencer.ml b/etherlink/tezt/tests/evm_sequencer.ml index 616a25231ee6..dce726f3df2f 100644 --- a/etherlink/tezt/tests/evm_sequencer.ml +++ b/etherlink/tezt/tests/evm_sequencer.ml @@ -4290,8 +4290,8 @@ let test_outbox_size_limit_resilience ~slow = sequencer in - (* Create and topup 30 accounts (to overcome single account per block limitation) *) - let* wallets = Cast.gen_wallets ~number:30 () in + (* Create and topup many accounts (to overcome single account per block limitation) *) + let* wallets = Cast.gen_wallets ~number:150 () in let addresses = List.map (fun (w : Cast.wallet) -> sf "\"%s\"" w.address) wallets in @@ -4319,7 +4319,7 @@ let test_outbox_size_limit_resilience ~slow = ~value:(Wei.of_eth_int 0) ~address:spammer_contract ~signature:"doWithdrawals(uint256)" - ~arguments:["5"] + ~arguments:["1"] in let* withdraw_txs = List.map (fun w -> withdraw_tx ~wallet:w ()) wallets |> Lwt.all -- GitLab