Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add ensure_transaction_root_valid method for SealedBlock #6163

Merged
merged 2 commits into from
Jan 22, 2024

Conversation

tcoratger
Copy link
Contributor

Description

This pull request introduces a new method, ensure_transaction_root_valid, for the SealedBlock type. The method checks whether the transaction root in the block header is valid. The transaction root is verified by comparing it with the calculated Keccak 256-bit hash of the root node of the trie structure populated with each transaction in the transactions list portion of the block.

Changes Made

  • Added ensure_transaction_root_valid method to the SealedBlock type.

Usage

The new method returns a Result<(), GotExpected<B256>>, where success (Ok(())) indicates a valid transaction root, and an error (Err) contains details about the unexpected root.

Example

// Assuming `block` is an instance of `SealedBlock`
match block.ensure_transaction_root_valid() {
    Ok(()) => println!("Transaction root is valid."),
    Err(error) => println!("Transaction root check failed: {:?}", error),
}

@tcoratger tcoratger requested a review from gakonst as a code owner January 22, 2024 17:14
Copy link
Collaborator

@mattsse mattsse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sweet!

tysm!

@mattsse mattsse added this pull request to the merge queue Jan 22, 2024
@mattsse mattsse added the C-debt A clean up/refactor of existing code label Jan 22, 2024
Merged via the queue into paradigmxyz:main with commit a30d149 Jan 22, 2024
28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-debt A clean up/refactor of existing code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants