Crates.io | eth-rlp-verify |
lib.rs | eth-rlp-verify |
version | 0.1.0 |
source | src |
created_at | 2024-10-08 19:29:05.247747 |
updated_at | 2024-10-08 19:29:05.247747 |
description | Ethereum block header verification across multiple eras using RLP encoding and Keccak256 hashing. |
homepage | |
repository | https://github.com/ametel01/eth-rlp-verify |
max_upload_size | |
id | 1401609 |
size | 138,411 |
eth-rlp-verify
eth-rlp-verify
is a Rust crate that provides functionality for verifying Ethereum block headers across multiple eras, such as London, Paris (The Merge), Shapella, and Dencun. The library automatically determines the correct Ethereum era based on the block number and validates the block header by computing its hash and comparing it to the expected block hash.
Ethereum has undergone several significant upgrades, each introducing changes to the block header structure and consensus mechanism. The eth-rlp-verify
crate provides a solution for verifying block headers in different eras of Ethereum. It supports Recursive Length Prefix (RLP) encoding, Keccak256 hashing, and era-specific validation logic to ensure the authenticity of Ethereum block headers.
To use eth-rlp-verify
in your project, add the following to your Cargo.toml
:
[dependencies]
eth-rlp-verify = "0.1.0"
Then, import the necessary modules:
use eth_rlp_verify::verify_block;
use eth_rlp_verify::block_header::BlockHeader;
You must provide a BlockHeader
struct containing the necessary fields (such as parent_hash
, state_root
, transactions_root
, etc.) to verify a block. This struct will vary slightly depending on the Ethereum era.
The eth_rlp_verify
crate automatically determines the correct era based on the block number and applies the appropriate verification logic for that era:
let block_number = 17_034_870; // Shapella era
let is_valid = verify_block(block_number, block_header, block_hash);
eth-rlp-verify
supports the following Ethereum eras:
block_header
Contains the BlockHeader
struct and related traits for managing and encoding block header data across different Ethereum eras.
constants
Defines constants for block ranges corresponding to different Ethereum eras. Example:
pub const GENESIS_END: u64 = 12_964_999;
pub const LONDON_START: u64 = 12_965_000;
pub const LONDON_END: u64 = 15_537_393;
pub const PARIS_START: u64 = 15_537_394;
pub const SHAPELLA_START: u64 = 17_034_870;
pub const DENCUN_START: u64 = 19_426_587;
eras
Handles the logic for determining which Ethereum era a block belongs to based on the block number. The determine_era
function returns the appropriate block header verification function for that era.
pub fn determine_era(block_number: u64) -> Option<fn(String, VerifiableBlockHeader) -> bool>;
We welcome contributions! If you’d like to improve or extend the eth-rlp-verify
crate, follow these steps:
If you're interested in adding support for future Ethereum upgrades, check out the eras
module, where the logic for handling block verification by era is implemented. You can extend this module to include new Ethereum upgrades as they are introduced.
This project is licensed under the MIT License. For more information, see the LICENSE file.
Feel free to adjust the README as you see fit!