Skip to content

Commit

Permalink
fix: add multiple witness version check (#271)
Browse files Browse the repository at this point in the history
  • Loading branch information
atanmarko authored Jun 10, 2024
1 parent e8e6071 commit 4ab700e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
4 changes: 2 additions & 2 deletions trace_decoder/src/compact/compact_prestate_processing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>, u8),

/// Failure due to a trie operation error.
#[error("Trie operation error: {0}")]
Expand Down
9 changes: 6 additions & 3 deletions trace_decoder/src/processed_block_trace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -214,9 +214,12 @@ fn process_multiple_storage_tries(
fn process_compact_trie(trie: TrieCompact) -> CompactParsingResult<ProcessedBlockTracePreImages> {
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,
));
}
Expand Down

0 comments on commit 4ab700e

Please sign in to comment.