Repository navigation
fix(firehose): emit the built block access list when a block has no sidecar #99
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
Merged
UlysseCorbeil
merged 2 commits into
streamingfast:release/reth-2.x
from
valvecitydev:sf/bal-without-sidecar
Nov 13, 2026
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
97 changes: 97 additions & 0 deletions
97
crates/engine/tree/tests/firehose_live_tracing_bal_without_sidecar.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,97 @@ | ||
| //! Regression test: the tracer emits the block access list of a downloaded Amsterdam block that | ||
| //! arrives without its BAL sidecar. | ||
| //! | ||
| //! A peer serves the block body but no BAL, so the engine downloads the block, executes it, builds | ||
| //! its access list, and checks that list against the header's `block_access_list_hash`. The | ||
| //! emitted Firehose header must then carry the RLP of the built list. Without the fix, the | ||
| //! validator passes only a sidecar's BAL to the tracer, and the header has no BAL RLP. | ||
| //! | ||
| //! It lives in its own integration-test binary because it installs the process-wide tracer. | ||
|
|
||
| use std::{sync::Arc, time::Duration}; | ||
|
|
||
| use alloy_primitives::keccak256; | ||
| use alloy_rpc_types_engine::{ForkchoiceState, PayloadStatusEnum}; | ||
| use futures::StreamExt; | ||
| use reth_chainspec::EthereumHardfork; | ||
| use reth_e2e_test_utils::{test_chain_spec, transaction::TransactionTestContext, E2ETestSetupExt}; | ||
| use reth_engine_primitives::ConsensusEngineEvent; | ||
| use reth_ethereum_primitives::EthPrimitives; | ||
| use reth_firehose::init_tracer_with_buffer; | ||
| use reth_firehose_tests::parse_fire_block_for; | ||
| use reth_network::{test_utils::Testnet, Peers}; | ||
| use reth_node_ethereum::EthereumNode; | ||
| use reth_payload_primitives::BuiltPayload; | ||
| use reth_provider::test_utils::MockEthProvider; | ||
|
|
||
| #[tokio::test(flavor = "multi_thread")] | ||
| async fn emits_the_built_bal_of_a_block_downloaded_without_a_sidecar() -> eyre::Result<()> { | ||
| let buffer = init_tracer_with_buffer(1, Some(0), Some(0), Some(0)); | ||
| let chain_spec = test_chain_spec(EthereumHardfork::Amsterdam); | ||
|
|
||
| let (mut node, wallet) = EthereumNode::test_setup(1, chain_spec.clone()).build_single().await?; | ||
|
|
||
| // Build a valid Amsterdam block without submitting it to the engine. | ||
| let raw_tx = TransactionTestContext::transfer_tx_bytes(1, wallet.inner).await; | ||
| node.rpc.inject_tx(raw_tx).await?; | ||
| let payload = node.new_payload().await?; | ||
| let bal = payload.block_access_list().cloned().expect("an Amsterdam payload has a BAL"); | ||
| let block = payload.block().clone(); | ||
| let block_number = block.header().number; | ||
| let block_hash = block.hash(); | ||
| let bal_hash = block.header().block_access_list_hash.expect("an Amsterdam header has one"); | ||
| let genesis_hash = node.block_hash(0); | ||
|
|
||
| // The peer serves the block but not its BAL, so the node downloads it without a sidecar. | ||
| let peer_provider = Arc::new( | ||
| MockEthProvider::<EthPrimitives>::new() | ||
| .with_chain_spec((*chain_spec).clone()) | ||
| .with_genesis_block(), | ||
| ); | ||
| peer_provider.add_block(block_hash, block.into_block()); | ||
|
|
||
| let testnet = Testnet::create_with(1, peer_provider).await.with_request_handlers().spawn(); | ||
| let [peer] = testnet.peers_array(); | ||
|
|
||
| node.inner.network.add_peer(*peer.peer_id(), peer.local_addr()); | ||
| assert_eq!(node.network.next_session_established().await, Some(*peer.peer_id())); | ||
|
|
||
| let mut engine_events = node.inner.add_ons_handle.consensus_engine_events().new_listener(); | ||
| let state = ForkchoiceState { | ||
| head_block_hash: block_hash, | ||
| safe_block_hash: genesis_hash, | ||
| finalized_block_hash: genesis_hash, | ||
| }; | ||
| let response = | ||
| node.inner.add_ons_handle.beacon_engine_handle.fork_choice_updated(state, None).await?; | ||
| assert_eq!(response.payload_status.status, PayloadStatusEnum::Syncing); | ||
|
|
||
| tokio::time::timeout(Duration::from_secs(20), async { | ||
| while let Some(event) = engine_events.next().await { | ||
| match event { | ||
| ConsensusEngineEvent::CanonicalBlockAdded(block, _) | ||
| if block.recovered_block().hash() == block_hash => | ||
| { | ||
| return | ||
| } | ||
| ConsensusEngineEvent::InvalidBlock { block, error } | ||
| if block.hash() == block_hash => | ||
| { | ||
| panic!("downloaded block is invalid: {error}") | ||
| } | ||
| _ => {} | ||
| } | ||
| } | ||
| panic!("consensus engine event stream ended") | ||
| }) | ||
| .await?; | ||
|
|
||
| let emitted = parse_fire_block_for(&buffer.get_bytes(), block_number)?; | ||
| assert_eq!(emitted.hash, block_hash.to_vec(), "emitted another block"); | ||
| let header = emitted.header.as_ref().expect("emitted block has a header"); | ||
| let bal_rlp = header.block_access_list_rlp.as_deref().expect("emitted no BAL RLP"); | ||
| assert_eq!(bal_rlp, bal.as_ref(), "emitted another BAL"); | ||
| assert_eq!(keccak256(bal_rlp), bal_hash, "BAL RLP does not hash to the header's"); | ||
|
|
||
| Ok(()) | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The tests only cover
firehose_bal_rlp, not this line.Add a test that has the node download a block from a peer that serves no BAL, with the tracer on, and checks that the emitted header has the BAL bytes.
That's the case this PR fixes, and the test should fail without it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added in 8ad0429:
crates/engine/tree/tests/firehose_live_tracing_bal_without_sidecar.rs. With the tracer on, the node downloads an Amsterdam block from a peer that serves no BAL. The test checks that the emitted header carries the BAL RLP and that it hashes to the header'sblock_access_list_hash. With thepayload_validator.rschanges reverted, it fails withemitted no BAL RLP. With them, it passes.