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

chore: rename requests root to requests hash #1379

Merged
merged 1 commit into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions crates/consensus/src/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,12 @@ pub struct Header {
/// The beacon roots contract handles root storage, enhancing Ethereum's functionalities.
#[cfg_attr(feature = "serde", serde(default, skip_serializing_if = "Option::is_none"))]
pub parent_beacon_block_root: Option<B256>,
/// The Keccak 256-bit hash of the root node of the trie structure populated with each
/// The Keccak 256-bit hash of the an RLP encoded list with each
/// [EIP-7685] request in the block body.
///
/// [EIP-7685]: https://eips.ethereum.org/EIPS/eip-7685
#[cfg_attr(feature = "serde", serde(default, skip_serializing_if = "Option::is_none"))]
pub requests_root: Option<B256>,
pub requests_hash: Option<B256>,
/// An arbitrary byte array containing data relevant to this block. This must be 32 bytes or
/// fewer; formally Hx.
pub extra_data: Bytes,
Expand Down Expand Up @@ -162,7 +162,7 @@ impl Default for Header {
blob_gas_used: None,
excess_blob_gas: None,
parent_beacon_block_root: None,
requests_root: None,
requests_hash: None,
}
}
}
Expand Down Expand Up @@ -328,7 +328,7 @@ impl Header {
length += parent_beacon_block_root.length();
}

// Encode requests root length.
// Encode requests hash length.
//
// If new fields are added, the above pattern will
// need to be repeated and placeholder length added. Otherwise, it's impossible to
Expand All @@ -337,8 +337,8 @@ impl Header {
// * A header is created with a withdrawals root, but no base fee. Shanghai blocks are
// post-London, so this is technically not valid. However, a tool like proptest would
// generate a block like this.
if let Some(requests_root) = self.requests_root {
length += requests_root.length();
if let Some(requests_hash) = self.requests_hash {
length += requests_hash.length();
}

length
Expand Down Expand Up @@ -454,7 +454,7 @@ impl Encodable for Header {
parent_beacon_block_root.encode(out);
}

// Encode requests root.
// Encode requests hash.
//
// If new fields are added, the above pattern will need to
// be repeated and placeholders added. Otherwise, it's impossible to tell _which_
Expand All @@ -463,8 +463,8 @@ impl Encodable for Header {
// * A header is created with a withdrawals root, but no base fee. Shanghai blocks are
// post-London, so this is technically not valid. However, a tool like proptest would
// generate a block like this.
if let Some(ref requests_root) = self.requests_root {
requests_root.encode(out);
if let Some(ref requests_hash) = self.requests_hash {
requests_hash.encode(out);
}
}

Expand Down Expand Up @@ -504,7 +504,7 @@ impl Decodable for Header {
blob_gas_used: None,
excess_blob_gas: None,
parent_beacon_block_root: None,
requests_root: None,
requests_hash: None,
};

if started_len - buf.len() < rlp_head.payload_length {
Expand Down Expand Up @@ -603,7 +603,7 @@ pub(crate) const fn generate_valid_header(
}

// Placeholder for future EIP adjustments
header.requests_root = None;
header.requests_hash = None;

header
}
Expand Down Expand Up @@ -633,7 +633,7 @@ impl<'a> arbitrary::Arbitrary<'a> for Header {
blob_gas_used: u.arbitrary()?,
excess_blob_gas: u.arbitrary()?,
parent_beacon_block_root: u.arbitrary()?,
requests_root: u.arbitrary()?,
requests_hash: u.arbitrary()?,
withdrawals_root: u.arbitrary()?,
};

Expand Down Expand Up @@ -706,8 +706,8 @@ pub trait BlockHeader {
/// Retrieves the parent beacon block root of the block, if available
fn parent_beacon_block_root(&self) -> Option<B256>;

/// Retrieves the requests root of the block, if available
fn requests_root(&self) -> Option<B256>;
/// Retrieves the requests hash of the block, if available
fn requests_hash(&self) -> Option<B256>;

/// Retrieves the block's extra data field
fn extra_data(&self) -> &Bytes;
Expand Down Expand Up @@ -790,8 +790,8 @@ impl BlockHeader for Header {
self.parent_beacon_block_root
}

fn requests_root(&self) -> Option<B256> {
self.requests_root
fn requests_hash(&self) -> Option<B256> {
self.requests_hash
}

fn extra_data(&self) -> &Bytes {
Expand Down
14 changes: 7 additions & 7 deletions crates/rpc-types-eth/src/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,9 @@ pub struct Header {
/// EIP-4788 parent beacon block root
#[cfg_attr(feature = "serde", serde(default, skip_serializing_if = "Option::is_none"))]
pub parent_beacon_block_root: Option<B256>,
/// EIP-7685 requests root.
/// EIP-7685 requests hash.
#[cfg_attr(feature = "serde", serde(default, skip_serializing_if = "Option::is_none"))]
pub requests_root: Option<B256>,
pub requests_hash: Option<B256>,
}

impl Header {
Expand Down Expand Up @@ -199,7 +199,7 @@ impl TryFrom<Header> for alloy_consensus::Header {
blob_gas_used,
excess_blob_gas,
parent_beacon_block_root,
requests_root,
requests_hash,
// not included in the consensus header
hash: _hash,
total_difficulty: _total_difficulty,
Expand All @@ -224,7 +224,7 @@ impl TryFrom<Header> for alloy_consensus::Header {
blob_gas_used,
excess_blob_gas,
parent_beacon_block_root,
requests_root,
requests_hash,
extra_data,
})
}
Expand Down Expand Up @@ -441,7 +441,7 @@ mod tests {
blob_gas_used: None,
excess_blob_gas: None,
parent_beacon_block_root: None,
requests_root: None,
requests_hash: None,
},
uncles: vec![B256::with_last_byte(17)],
transactions: vec![B256::with_last_byte(18)].into(),
Expand Down Expand Up @@ -484,7 +484,7 @@ mod tests {
blob_gas_used: None,
excess_blob_gas: None,
parent_beacon_block_root: None,
requests_root: None,
requests_hash: None,
},
uncles: vec![],
transactions: BlockTransactions::Uncle,
Expand Down Expand Up @@ -527,7 +527,7 @@ mod tests {
blob_gas_used: None,
excess_blob_gas: None,
parent_beacon_block_root: None,
requests_root: None,
requests_hash: None,
},
uncles: vec![B256::with_last_byte(17)],
transactions: vec![B256::with_last_byte(18)].into(),
Expand Down