From c38ea0bff9b9bb8b41c0dd11bee03b8b352fae54 Mon Sep 17 00:00:00 2001 From: Valentin Chaboche Date: Wed, 3 Jul 2024 10:16:50 +0200 Subject: [PATCH 1/2] EVM/Kernel: use config call stack limit for recursive calls --- etherlink/kernel_evm/evm_evaluation/src/runner.rs | 2 +- etherlink/kernel_evm/evm_execution/src/handler.rs | 2 +- etherlink/kernel_evm/evm_execution/src/lib.rs | 8 ++++---- etherlink/kernel_evm/kernel/src/lib.rs | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/etherlink/kernel_evm/evm_evaluation/src/runner.rs b/etherlink/kernel_evm/evm_evaluation/src/runner.rs index 1a7ca4621466..113cd0c595d1 100644 --- a/etherlink/kernel_evm/evm_evaluation/src/runner.rs +++ b/etherlink/kernel_evm/evm_evaluation/src/runner.rs @@ -331,7 +331,7 @@ pub fn run_test( for (spec_name, tests) in &unit.post { let config = match spec_name { SpecName::Shanghai => Config { - stack_limit: 256, + call_stack_limit: 256, ..Config::shanghai() }, // TODO: enable future configs when parallelization is enabled. diff --git a/etherlink/kernel_evm/evm_execution/src/handler.rs b/etherlink/kernel_evm/evm_execution/src/handler.rs index a196648c676c..b3e898f54885 100644 --- a/etherlink/kernel_evm/evm_execution/src/handler.rs +++ b/etherlink/kernel_evm/evm_execution/src/handler.rs @@ -949,7 +949,7 @@ impl<'a, Host: Runtime> EvmHandler<'a, Host> { // we can reproduce the exact same check on the stack from the Ethereum yellow paper (p.37). match ( self.has_enough_fund(caller, value), - self.stack_depth() < self.config.stack_limit, + self.stack_depth() < self.config.call_stack_limit, ) { (Ok(true), true) => Precondition::PassPrecondition, (Ok(false), _) => { diff --git a/etherlink/kernel_evm/evm_execution/src/lib.rs b/etherlink/kernel_evm/evm_execution/src/lib.rs index 64f1a93fa149..eeeb6faf4693 100644 --- a/etherlink/kernel_evm/evm_execution/src/lib.rs +++ b/etherlink/kernel_evm/evm_execution/src/lib.rs @@ -311,10 +311,10 @@ mod test { "60fe47b1000000000000000000000000000000000000000000000000000000000000002a"; const CONFIG: Config = Config { - // The current implementation doesn't support Shanghai stack limit of 256. - // We need to set a lower limit until we have switched to a head-based - // recursive calls. - stack_limit: 256, + // The current implementation doesn't support Shanghai call + // stack limit of 256. We need to set a lower limit until we + // have switched to a head-based recursive calls. + call_stack_limit: 256, ..Config::shanghai() }; diff --git a/etherlink/kernel_evm/kernel/src/lib.rs b/etherlink/kernel_evm/kernel/src/lib.rs index 5b99c47c9fd5..41219e85595c 100644 --- a/etherlink/kernel_evm/kernel/src/lib.rs +++ b/etherlink/kernel_evm/kernel/src/lib.rs @@ -74,14 +74,14 @@ pub const CHAIN_ID: u32 = 1337; /// The configuration for the EVM execution. const CONFIG: Config = Config { - // The current implementation doesn't support Shanghai stack limit of 256. + // The current implementation doesn't support Shanghai call stack limit of 256. // We need to set a lower limit until we have switched to a head-based // recursive calls. // // TODO: When this limitation is removed, some evm evaluation tests needs // to be reactivated. As well as tests `call_too_deep_not_revert` and // `multiple_call_all_the_way_to_1024` in the evm execution crate. - stack_limit: 256, + call_stack_limit: 256, ..Config::shanghai() }; -- GitLab From c5c5c9526a350ef5f4557f3fc38319af253b2417 Mon Sep 17 00:00:00 2001 From: Valentin Chaboche Date: Wed, 3 Jul 2024 10:28:12 +0200 Subject: [PATCH 2/2] EVM/Evaluation: reactivate tests :-) --- etherlink/kernel_evm/evm_evaluation/src/main.rs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/etherlink/kernel_evm/evm_evaluation/src/main.rs b/etherlink/kernel_evm/evm_evaluation/src/main.rs index dbe1f4a7209c..d771ece07d75 100644 --- a/etherlink/kernel_evm/evm_evaluation/src/main.rs +++ b/etherlink/kernel_evm/evm_evaluation/src/main.rs @@ -341,9 +341,6 @@ pub fn check_skip(test_file_path: &Path) -> bool { | "chainId.json" // Reason: we temporarily reduce stack limit to 256. - | "stackOverflowM1PUSH.json" - | "stackOverflowM1DUP.json" - | "stackOverflowM1.json" | "Call1024PreCalls.json" | "gasPriceDiffPlaces.json" | "Create2Recursive.json" @@ -366,7 +363,6 @@ pub fn check_skip(test_file_path: &Path) -> bool { | "Create2OnDepth1023.json" | "CallRecursiveBomb2.json" | "ABAcalls2.json" - | "stacksanitySWAP.json" | "diffPlaces.json" | "Delegatecall1024OOG.json" | "CallRecursiveBomb0.json" -- GitLab