From 2fb534a744bac94abe7bbfb1e172f6354ddeccea Mon Sep 17 00:00:00 2001 From: Luciano Freitas Date: Fri, 7 Feb 2025 11:32:59 +0100 Subject: [PATCH 1/2] Kernel: fix temporary WORLD_STATE_PATH --- etherlink/bin_node/lib_dev/block_storage_setup.ml | 8 ++++++-- etherlink/kernel_evm/runtime/src/safe_storage.rs | 9 ++++----- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/etherlink/bin_node/lib_dev/block_storage_setup.ml b/etherlink/bin_node/lib_dev/block_storage_setup.ml index 06806c40cfed..2d80798954ff 100644 --- a/etherlink/bin_node/lib_dev/block_storage_setup.ml +++ b/etherlink/bin_node/lib_dev/block_storage_setup.ml @@ -60,6 +60,9 @@ let enable ~keep_alive ?evm_node_endpoint store = | Error trace -> Stdlib.failwith Format.(asprintf "%a" Error_monad.pp_print_trace trace) in + let tmp_path = "/tmp" in + let world_state_path = "/evm/world_state" in + let tmp_world_state_path = tmp_path ^ world_state_path in let store_get_hash tree key = let open Lwt_syntax in let enable_fallback = @@ -76,7 +79,7 @@ let enable ~keep_alive ?evm_node_endpoint store = any assumption on the running kernel. *) false in - if enable_fallback && key = "/tmp/evm/world_state/transactions_receipts" + if enable_fallback && key = tmp_world_state_path ^ "/transactions_receipts" then Lwt_preemptive.run_in_main @@ fun () -> let* pred = Evm_state.current_block_height tree in @@ -84,7 +87,8 @@ let enable ~keep_alive ?evm_node_endpoint store = let+ block = get_block_exn n in let s = Ethereum_types.hash_to_bytes block.receiptRoot in Ok (Bytes.unsafe_of_string s) - else if enable_fallback && key = "/tmp/evm/world_state/transactions_objects" + else if + enable_fallback && key = tmp_world_state_path ^ "/transactions_objects" then Lwt_preemptive.run_in_main @@ fun () -> let* pred = Evm_state.current_block_height tree in diff --git a/etherlink/kernel_evm/runtime/src/safe_storage.rs b/etherlink/kernel_evm/runtime/src/safe_storage.rs index d55feb706e33..006bb94963a8 100644 --- a/etherlink/kernel_evm/runtime/src/safe_storage.rs +++ b/etherlink/kernel_evm/runtime/src/safe_storage.rs @@ -20,7 +20,6 @@ use tezos_smart_rollup_host::{ pub const TMP_PATH: RefPath = RefPath::assert_from(b"/tmp"); pub const WORLD_STATE_PATH: RefPath = RefPath::assert_from(b"/evm/world_state"); -pub const TMP_WORLD_STATE_PATH: RefPath = RefPath::assert_from(b"/tmp/evm/world_state"); pub const TRACE_PATH: RefPath = RefPath::assert_from(b"/evm/trace"); pub const TMP_TRACE_PATH: RefPath = RefPath::assert_from(b"/tmp/evm/trace"); @@ -236,13 +235,13 @@ impl Verbosity for SafeStorage<&mut Host> { impl SafeStorage<&mut Host> { pub fn start(&mut self) -> Result<(), RuntimeError> { - self.host - .store_copy(&WORLD_STATE_PATH, &TMP_WORLD_STATE_PATH) + let tmp_path = safe_path(&WORLD_STATE_PATH)?; + self.host.store_copy(&WORLD_STATE_PATH, &tmp_path) } pub fn promote(&mut self) -> Result<(), RuntimeError> { - self.host - .store_move(&TMP_WORLD_STATE_PATH, &WORLD_STATE_PATH) + let tmp_path = safe_path(&WORLD_STATE_PATH)?; + self.host.store_move(&tmp_path, &WORLD_STATE_PATH) } // Only used in tracing mode, so that the trace doesn't polute the world -- GitLab From cf0245e78545307b37248784551fa8a3a8ca4efb Mon Sep 17 00:00:00 2001 From: Luciano Freitas Date: Tue, 11 Feb 2025 08:22:21 +0100 Subject: [PATCH 2/2] Kernel: use safe_path for TRACE --- etherlink/kernel_evm/runtime/src/safe_storage.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/etherlink/kernel_evm/runtime/src/safe_storage.rs b/etherlink/kernel_evm/runtime/src/safe_storage.rs index 006bb94963a8..13b9c68909db 100644 --- a/etherlink/kernel_evm/runtime/src/safe_storage.rs +++ b/etherlink/kernel_evm/runtime/src/safe_storage.rs @@ -21,7 +21,6 @@ use tezos_smart_rollup_host::{ pub const TMP_PATH: RefPath = RefPath::assert_from(b"/tmp"); pub const WORLD_STATE_PATH: RefPath = RefPath::assert_from(b"/evm/world_state"); pub const TRACE_PATH: RefPath = RefPath::assert_from(b"/evm/trace"); -pub const TMP_TRACE_PATH: RefPath = RefPath::assert_from(b"/tmp/evm/trace"); pub fn safe_path(path: &T) -> Result { concat(&TMP_PATH, path).map_err(|_| RuntimeError::PathNotFound) @@ -247,8 +246,9 @@ impl SafeStorage<&mut Host> { // Only used in tracing mode, so that the trace doesn't polute the world // state but is still promoted at the end and accessible from the node. pub fn promote_trace(&mut self) -> Result<(), RuntimeError> { - if let Ok(Some(_)) = self.host.store_has(&TMP_TRACE_PATH) { - self.host.store_move(&TMP_TRACE_PATH, &TRACE_PATH)? + let tmp_path = safe_path(&TRACE_PATH)?; + if let Ok(Some(_)) = self.host.store_has(&tmp_path) { + self.host.store_move(&tmp_path, &TRACE_PATH)? } Ok(()) } -- GitLab