validation of bal_hash

This commit is contained in:
Ishika Choudhury
2025-08-24 19:00:21 +05:30
parent f5bc91f69d
commit 609a7dd2ea
8 changed files with 68 additions and 31 deletions

64
Cargo.lock generated
View File

@@ -98,7 +98,7 @@ checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923"
[[package]]
name = "alloy-block-access-list"
version = "1.0.23"
source = "git+https://github.com/Soubhik-10/alloy?branch=bal#9a80ffc8d58b430fbdabc015a86d3014613a2b00"
source = "git+https://github.com/Soubhik-10/alloy?branch=bal#5394d6928162a4689ad1654d1f48afa92022217e"
dependencies = [
"alloy-primitives",
"alloy-rlp",
@@ -123,7 +123,7 @@ dependencies = [
[[package]]
name = "alloy-consensus"
version = "1.0.23"
source = "git+https://github.com/Soubhik-10/alloy?branch=bal#9a80ffc8d58b430fbdabc015a86d3014613a2b00"
source = "git+https://github.com/Soubhik-10/alloy?branch=bal#5394d6928162a4689ad1654d1f48afa92022217e"
dependencies = [
"alloy-block-access-list",
"alloy-eips",
@@ -149,7 +149,7 @@ dependencies = [
[[package]]
name = "alloy-consensus-any"
version = "1.0.23"
source = "git+https://github.com/Soubhik-10/alloy?branch=bal#9a80ffc8d58b430fbdabc015a86d3014613a2b00"
source = "git+https://github.com/Soubhik-10/alloy?branch=bal#5394d6928162a4689ad1654d1f48afa92022217e"
dependencies = [
"alloy-consensus",
"alloy-eips",
@@ -163,7 +163,7 @@ dependencies = [
[[package]]
name = "alloy-contract"
version = "1.0.23"
source = "git+https://github.com/Soubhik-10/alloy?branch=bal#9a80ffc8d58b430fbdabc015a86d3014613a2b00"
source = "git+https://github.com/Soubhik-10/alloy?branch=bal#5394d6928162a4689ad1654d1f48afa92022217e"
dependencies = [
"alloy-consensus",
"alloy-dyn-abi",
@@ -245,7 +245,7 @@ dependencies = [
[[package]]
name = "alloy-eips"
version = "1.0.23"
source = "git+https://github.com/Soubhik-10/alloy?branch=bal#9a80ffc8d58b430fbdabc015a86d3014613a2b00"
source = "git+https://github.com/Soubhik-10/alloy?branch=bal#5394d6928162a4689ad1654d1f48afa92022217e"
dependencies = [
"alloy-eip2124",
"alloy-eip2930",
@@ -288,7 +288,7 @@ dependencies = [
[[package]]
name = "alloy-genesis"
version = "1.0.23"
source = "git+https://github.com/Soubhik-10/alloy?branch=bal#9a80ffc8d58b430fbdabc015a86d3014613a2b00"
source = "git+https://github.com/Soubhik-10/alloy?branch=bal#5394d6928162a4689ad1654d1f48afa92022217e"
dependencies = [
"alloy-eips",
"alloy-primitives",
@@ -327,7 +327,7 @@ dependencies = [
[[package]]
name = "alloy-json-rpc"
version = "1.0.23"
source = "git+https://github.com/Soubhik-10/alloy?branch=bal#9a80ffc8d58b430fbdabc015a86d3014613a2b00"
source = "git+https://github.com/Soubhik-10/alloy?branch=bal#5394d6928162a4689ad1654d1f48afa92022217e"
dependencies = [
"alloy-primitives",
"alloy-sol-types",
@@ -341,7 +341,7 @@ dependencies = [
[[package]]
name = "alloy-network"
version = "1.0.23"
source = "git+https://github.com/Soubhik-10/alloy?branch=bal#9a80ffc8d58b430fbdabc015a86d3014613a2b00"
source = "git+https://github.com/Soubhik-10/alloy?branch=bal#5394d6928162a4689ad1654d1f48afa92022217e"
dependencies = [
"alloy-consensus",
"alloy-consensus-any",
@@ -366,7 +366,7 @@ dependencies = [
[[package]]
name = "alloy-network-primitives"
version = "1.0.23"
source = "git+https://github.com/Soubhik-10/alloy?branch=bal#9a80ffc8d58b430fbdabc015a86d3014613a2b00"
source = "git+https://github.com/Soubhik-10/alloy?branch=bal#5394d6928162a4689ad1654d1f48afa92022217e"
dependencies = [
"alloy-consensus",
"alloy-eips",
@@ -436,7 +436,7 @@ dependencies = [
[[package]]
name = "alloy-provider"
version = "1.0.23"
source = "git+https://github.com/Soubhik-10/alloy?branch=bal#9a80ffc8d58b430fbdabc015a86d3014613a2b00"
source = "git+https://github.com/Soubhik-10/alloy?branch=bal#5394d6928162a4689ad1654d1f48afa92022217e"
dependencies = [
"alloy-chains",
"alloy-consensus",
@@ -481,7 +481,7 @@ dependencies = [
[[package]]
name = "alloy-pubsub"
version = "1.0.23"
source = "git+https://github.com/Soubhik-10/alloy?branch=bal#9a80ffc8d58b430fbdabc015a86d3014613a2b00"
source = "git+https://github.com/Soubhik-10/alloy?branch=bal#5394d6928162a4689ad1654d1f48afa92022217e"
dependencies = [
"alloy-json-rpc",
"alloy-primitives",
@@ -524,7 +524,7 @@ dependencies = [
[[package]]
name = "alloy-rpc-client"
version = "1.0.23"
source = "git+https://github.com/Soubhik-10/alloy?branch=bal#9a80ffc8d58b430fbdabc015a86d3014613a2b00"
source = "git+https://github.com/Soubhik-10/alloy?branch=bal#5394d6928162a4689ad1654d1f48afa92022217e"
dependencies = [
"alloy-json-rpc",
"alloy-primitives",
@@ -549,7 +549,7 @@ dependencies = [
[[package]]
name = "alloy-rpc-types"
version = "1.0.23"
source = "git+https://github.com/Soubhik-10/alloy?branch=bal#9a80ffc8d58b430fbdabc015a86d3014613a2b00"
source = "git+https://github.com/Soubhik-10/alloy?branch=bal#5394d6928162a4689ad1654d1f48afa92022217e"
dependencies = [
"alloy-primitives",
"alloy-rpc-types-engine",
@@ -561,7 +561,7 @@ dependencies = [
[[package]]
name = "alloy-rpc-types-admin"
version = "1.0.23"
source = "git+https://github.com/Soubhik-10/alloy?branch=bal#9a80ffc8d58b430fbdabc015a86d3014613a2b00"
source = "git+https://github.com/Soubhik-10/alloy?branch=bal#5394d6928162a4689ad1654d1f48afa92022217e"
dependencies = [
"alloy-genesis",
"alloy-primitives",
@@ -572,7 +572,7 @@ dependencies = [
[[package]]
name = "alloy-rpc-types-anvil"
version = "1.0.23"
source = "git+https://github.com/Soubhik-10/alloy?branch=bal#9a80ffc8d58b430fbdabc015a86d3014613a2b00"
source = "git+https://github.com/Soubhik-10/alloy?branch=bal#5394d6928162a4689ad1654d1f48afa92022217e"
dependencies = [
"alloy-primitives",
"alloy-rpc-types-eth",
@@ -583,7 +583,7 @@ dependencies = [
[[package]]
name = "alloy-rpc-types-any"
version = "1.0.23"
source = "git+https://github.com/Soubhik-10/alloy?branch=bal#9a80ffc8d58b430fbdabc015a86d3014613a2b00"
source = "git+https://github.com/Soubhik-10/alloy?branch=bal#5394d6928162a4689ad1654d1f48afa92022217e"
dependencies = [
"alloy-consensus-any",
"alloy-rpc-types-eth",
@@ -593,7 +593,7 @@ dependencies = [
[[package]]
name = "alloy-rpc-types-beacon"
version = "1.0.23"
source = "git+https://github.com/Soubhik-10/alloy?branch=bal#9a80ffc8d58b430fbdabc015a86d3014613a2b00"
source = "git+https://github.com/Soubhik-10/alloy?branch=bal#5394d6928162a4689ad1654d1f48afa92022217e"
dependencies = [
"alloy-eips",
"alloy-primitives",
@@ -610,7 +610,7 @@ dependencies = [
[[package]]
name = "alloy-rpc-types-debug"
version = "1.0.23"
source = "git+https://github.com/Soubhik-10/alloy?branch=bal#9a80ffc8d58b430fbdabc015a86d3014613a2b00"
source = "git+https://github.com/Soubhik-10/alloy?branch=bal#5394d6928162a4689ad1654d1f48afa92022217e"
dependencies = [
"alloy-primitives",
"derive_more",
@@ -620,7 +620,7 @@ dependencies = [
[[package]]
name = "alloy-rpc-types-engine"
version = "1.0.23"
source = "git+https://github.com/Soubhik-10/alloy?branch=bal#9a80ffc8d58b430fbdabc015a86d3014613a2b00"
source = "git+https://github.com/Soubhik-10/alloy?branch=bal#5394d6928162a4689ad1654d1f48afa92022217e"
dependencies = [
"alloy-consensus",
"alloy-eips",
@@ -640,7 +640,7 @@ dependencies = [
[[package]]
name = "alloy-rpc-types-eth"
version = "1.0.23"
source = "git+https://github.com/Soubhik-10/alloy?branch=bal#9a80ffc8d58b430fbdabc015a86d3014613a2b00"
source = "git+https://github.com/Soubhik-10/alloy?branch=bal#5394d6928162a4689ad1654d1f48afa92022217e"
dependencies = [
"alloy-block-access-list",
"alloy-consensus",
@@ -662,7 +662,7 @@ dependencies = [
[[package]]
name = "alloy-rpc-types-mev"
version = "1.0.23"
source = "git+https://github.com/Soubhik-10/alloy?branch=bal#9a80ffc8d58b430fbdabc015a86d3014613a2b00"
source = "git+https://github.com/Soubhik-10/alloy?branch=bal#5394d6928162a4689ad1654d1f48afa92022217e"
dependencies = [
"alloy-consensus",
"alloy-eips",
@@ -676,7 +676,7 @@ dependencies = [
[[package]]
name = "alloy-rpc-types-trace"
version = "1.0.23"
source = "git+https://github.com/Soubhik-10/alloy?branch=bal#9a80ffc8d58b430fbdabc015a86d3014613a2b00"
source = "git+https://github.com/Soubhik-10/alloy?branch=bal#5394d6928162a4689ad1654d1f48afa92022217e"
dependencies = [
"alloy-primitives",
"alloy-rpc-types-eth",
@@ -689,7 +689,7 @@ dependencies = [
[[package]]
name = "alloy-rpc-types-txpool"
version = "1.0.23"
source = "git+https://github.com/Soubhik-10/alloy?branch=bal#9a80ffc8d58b430fbdabc015a86d3014613a2b00"
source = "git+https://github.com/Soubhik-10/alloy?branch=bal#5394d6928162a4689ad1654d1f48afa92022217e"
dependencies = [
"alloy-primitives",
"alloy-rpc-types-eth",
@@ -700,7 +700,7 @@ dependencies = [
[[package]]
name = "alloy-serde"
version = "1.0.23"
source = "git+https://github.com/Soubhik-10/alloy?branch=bal#9a80ffc8d58b430fbdabc015a86d3014613a2b00"
source = "git+https://github.com/Soubhik-10/alloy?branch=bal#5394d6928162a4689ad1654d1f48afa92022217e"
dependencies = [
"alloy-primitives",
"arbitrary",
@@ -711,7 +711,7 @@ dependencies = [
[[package]]
name = "alloy-signer"
version = "1.0.23"
source = "git+https://github.com/Soubhik-10/alloy?branch=bal#9a80ffc8d58b430fbdabc015a86d3014613a2b00"
source = "git+https://github.com/Soubhik-10/alloy?branch=bal#5394d6928162a4689ad1654d1f48afa92022217e"
dependencies = [
"alloy-primitives",
"async-trait",
@@ -725,7 +725,7 @@ dependencies = [
[[package]]
name = "alloy-signer-local"
version = "1.0.23"
source = "git+https://github.com/Soubhik-10/alloy?branch=bal#9a80ffc8d58b430fbdabc015a86d3014613a2b00"
source = "git+https://github.com/Soubhik-10/alloy?branch=bal#5394d6928162a4689ad1654d1f48afa92022217e"
dependencies = [
"alloy-consensus",
"alloy-network",
@@ -812,7 +812,7 @@ dependencies = [
[[package]]
name = "alloy-transport"
version = "1.0.23"
source = "git+https://github.com/Soubhik-10/alloy?branch=bal#9a80ffc8d58b430fbdabc015a86d3014613a2b00"
source = "git+https://github.com/Soubhik-10/alloy?branch=bal#5394d6928162a4689ad1654d1f48afa92022217e"
dependencies = [
"alloy-json-rpc",
"alloy-primitives",
@@ -835,7 +835,7 @@ dependencies = [
[[package]]
name = "alloy-transport-http"
version = "1.0.23"
source = "git+https://github.com/Soubhik-10/alloy?branch=bal#9a80ffc8d58b430fbdabc015a86d3014613a2b00"
source = "git+https://github.com/Soubhik-10/alloy?branch=bal#5394d6928162a4689ad1654d1f48afa92022217e"
dependencies = [
"alloy-json-rpc",
"alloy-transport",
@@ -849,7 +849,7 @@ dependencies = [
[[package]]
name = "alloy-transport-ipc"
version = "1.0.23"
source = "git+https://github.com/Soubhik-10/alloy?branch=bal#9a80ffc8d58b430fbdabc015a86d3014613a2b00"
source = "git+https://github.com/Soubhik-10/alloy?branch=bal#5394d6928162a4689ad1654d1f48afa92022217e"
dependencies = [
"alloy-json-rpc",
"alloy-pubsub",
@@ -868,7 +868,7 @@ dependencies = [
[[package]]
name = "alloy-transport-ws"
version = "1.0.23"
source = "git+https://github.com/Soubhik-10/alloy?branch=bal#9a80ffc8d58b430fbdabc015a86d3014613a2b00"
source = "git+https://github.com/Soubhik-10/alloy?branch=bal#5394d6928162a4689ad1654d1f48afa92022217e"
dependencies = [
"alloy-pubsub",
"alloy-transport",
@@ -905,7 +905,7 @@ dependencies = [
[[package]]
name = "alloy-tx-macros"
version = "1.0.23"
source = "git+https://github.com/Soubhik-10/alloy?branch=bal#9a80ffc8d58b430fbdabc015a86d3014613a2b00"
source = "git+https://github.com/Soubhik-10/alloy?branch=bal#5394d6928162a4689ad1654d1f48afa92022217e"
dependencies = [
"alloy-primitives",
"darling 0.20.11",
@@ -7557,6 +7557,7 @@ dependencies = [
"alloy-consensus",
"alloy-eips",
"alloy-primitives",
"alloy-rlp",
"rand 0.9.2",
"reth-chainspec",
"reth-consensus",
@@ -9637,6 +9638,7 @@ dependencies = [
name = "reth-primitives-traits"
version = "1.6.0"
dependencies = [
"alloy-block-access-list",
"alloy-consensus",
"alloy-eips",
"alloy-genesis",

View File

@@ -18,7 +18,9 @@ reth-consensus.workspace = true
# ethereum
reth-primitives-traits.workspace = true
alloy-consensus.workspace = true
alloy-primitives.workspace = true
alloy-eips.workspace = true
alloy-rlp.workspace = true
[dev-dependencies]
alloy-primitives = { workspace = true, features = ["rand"] }

View File

@@ -123,6 +123,18 @@ where
}
_ => return Err(ConsensusError::WithdrawalsRootUnexpected),
}
if header.block_access_list_hash().is_some() &&
alloy_primitives::keccak256(alloy_rlp::encode(&body.block_access_list())) !=
header.block_access_list_hash().unwrap()
{
return Err(ConsensusError::BodyBlockAccessListHashDiff(
GotExpected {
got: alloy_primitives::keccak256(alloy_rlp::encode(&body.block_access_list())),
expected: header.block_access_list_hash().unwrap(),
}
.into(),
))
}
Ok(())
}

View File

@@ -395,6 +395,11 @@ pub enum ConsensusError {
/// The block's timestamp.
timestamp: u64,
},
/// Error when the hash of block access list is different from the expected hash.
#[error("mismatched block access list hash: {0}")]
BodyBlockAccessListHashDiff(GotExpectedBoxed<B256>),
/// Other, likely an injected L2 error.
#[error("{0}")]
Other(String),

View File

@@ -22,6 +22,7 @@ alloy-genesis.workspace = true
alloy-primitives = { workspace = true, features = ["k256"] }
alloy-rlp.workspace = true
alloy-trie.workspace = true
alloy-block-access-list.workspace = true
revm-primitives.workspace = true
revm-bytecode.workspace = true
revm-state.workspace = true

View File

@@ -5,6 +5,7 @@ use crate::{
MaybeSerdeBincodeCompat, SignedTransaction,
};
use alloc::{fmt, vec::Vec};
use alloy_block_access_list::BlockAccessList;
use alloy_consensus::{Transaction, Typed2718};
use alloy_eips::{eip2718::Encodable2718, eip4895::Withdrawals};
use alloy_primitives::{Address, Bytes, B256};
@@ -195,6 +196,9 @@ pub trait BlockBody:
{
self.recover_signers_unchecked()
}
/// Returns the block access list for the block body.
fn block_access_list(&self) -> &BlockAccessList;
}
impl<T, H> BlockBody for alloy_consensus::BlockBody<T, H>
@@ -224,6 +228,10 @@ where
fn ommers(&self) -> Option<&[Self::OmmerHeader]> {
Some(&self.ommers)
}
fn block_access_list(&self) -> &BlockAccessList {
self.block_access_list.as_ref().unwrap()
}
}
/// This is a helper alias to make it easy to refer to the inner `Transaction` associated type of a

View File

@@ -449,6 +449,10 @@ impl<B: Block> BlockHeader for RecoveredBlock<B> {
self.header().requests_hash()
}
fn block_access_list_hash(&self) -> Option<B256> {
self.header().block_access_list_hash()
}
fn extra_data(&self) -> &Bytes {
self.header().extra_data()
}

View File

@@ -69,6 +69,9 @@ impl alloy_consensus::BlockHeader for CustomHeader {
self.inner.beneficiary()
}
fn block_access_list_hash(&self) -> Option<B256> {
self.inner.block_access_list_hash()
}
fn state_root(&self) -> B256 {
self.inner.state_root()
}