Skip to content

Commit

Permalink
feat: add are_blocks_valid function for individual block verification
Browse files Browse the repository at this point in the history
Add a new function that verifies blocks individually without checking parent links.
This allows for more flexible block verification when chain continuity is not required.
  • Loading branch information
ametel01 committed Jan 15, 2025
1 parent fde970d commit 4320207
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions crates/eth-rlp-verify/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,21 @@ pub fn are_blocks_and_chain_valid(block_headers: &[VerifiableBlockHeader], chain
true
}

pub fn are_blocks_valid(block_headers: &[VerifiableBlockHeader], chain_id: u64) -> bool {
for block in block_headers.iter() {
let block_hash = block.block_hash.clone();
let block_number = block.number;

let is_valid = verify_block(block_number as u64, block.clone(), &block_hash, chain_id);

if !is_valid {
return false;
}
}

true
}

/// Verifies the validity of an Ethereum block header based on the block number and expected hash.
///
/// This function determines the appropriate Ethereum era based on the block number, retrieves the corresponding
Expand Down

0 comments on commit 4320207

Please sign in to comment.