From 4ab700e0d0da6158665f8cc78a28fc258ec6812c Mon Sep 17 00:00:00 2001 From: Marko Atanasievski Date: Mon, 10 Jun 2024 15:42:27 +0200 Subject: [PATCH] fix: add multiple witness version check (#271) --- trace_decoder/src/compact/compact_prestate_processing.rs | 4 ++-- trace_decoder/src/processed_block_trace.rs | 9 ++++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/trace_decoder/src/compact/compact_prestate_processing.rs b/trace_decoder/src/compact/compact_prestate_processing.rs index 84e821b8e..397be5b12 100644 --- a/trace_decoder/src/compact/compact_prestate_processing.rs +++ b/trace_decoder/src/compact/compact_prestate_processing.rs @@ -123,8 +123,8 @@ pub enum CompactParsingError { KeyError(#[from] FromHexPrefixError), /// Failure due to an incompatible version. - #[error("Incompatible version, expected: {0}, actual: {1}")] - IncompatibleVersion(u8, u8), + #[error("Incompatible version, expected one of: {0:?}, actual: {1}")] + IncompatibleVersion(Vec, u8), /// Failure due to a trie operation error. #[error("Trie operation error: {0}")] diff --git a/trace_decoder/src/processed_block_trace.rs b/trace_decoder/src/processed_block_trace.rs index 557e9b08e..92d90d3fb 100644 --- a/trace_decoder/src/processed_block_trace.rs +++ b/trace_decoder/src/processed_block_trace.rs @@ -33,7 +33,7 @@ pub(crate) struct ProcessedBlockTrace { pub(crate) withdrawals: Vec<(Address, U256)>, } -const COMPATIBLE_HEADER_VERSION: u8 = 1; +const COMPATIBLE_HEADER_VERSIONS: [u8; 2] = [0, 1]; impl BlockTrace { /// Processes and returns the [GenerationInputs] for all transactions in the @@ -214,9 +214,12 @@ fn process_multiple_storage_tries( fn process_compact_trie(trie: TrieCompact) -> CompactParsingResult { let out = process_compact_prestate_debug(trie)?; - if !out.header.version_is_compatible(COMPATIBLE_HEADER_VERSION) { + if !COMPATIBLE_HEADER_VERSIONS + .iter() + .any(|&v| out.header.version_is_compatible(v)) + { return Err(CompactParsingError::IncompatibleVersion( - COMPATIBLE_HEADER_VERSION, + COMPATIBLE_HEADER_VERSIONS.to_vec(), out.header.version, )); }