Skip to content

Commit

Permalink
chore: rename requests root to requests hash (#1379)
Browse files Browse the repository at this point in the history
  • Loading branch information
onbjerg authored Oct 17, 2024
1 parent 5b49e5b commit 0b8fd17
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 23 deletions.
32 changes: 16 additions & 16 deletions crates/consensus/src/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,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 @@ -155,7 +155,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 @@ -310,7 +310,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 @@ -319,8 +319,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 @@ -436,7 +436,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 @@ -445,8 +445,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 @@ -486,7 +486,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 @@ -585,7 +585,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 @@ -615,7 +615,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 @@ -688,8 +688,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 @@ -772,8 +772,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 @@ -442,7 +442,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 @@ -485,7 +485,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 @@ -528,7 +528,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

0 comments on commit 0b8fd17

Please sign in to comment.