Skip to content
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
10 changes: 10 additions & 0 deletions CHANGELOG.sf.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,16 @@ The `sf-release.yml` workflow publishes the top-most version section here as the
GitHub release notes (via `sfreleaser changelog extract-section`), so keep the
most recent release at the top.

## Unreleased

### Fixed

* With `--proofs-history`, the proofs ExEx no longer prints a second `FIRE BLOCK` for each block
it re-executes to build its proof storage. Blocks it caught up on at startup or after falling
behind, blocks without precomputed trie data and blocks picked by
`--proofs-history.verification-interval` appeared twice in the Firehose output, often out of
order.

## op-reth-v2.8.2-fh3.1

Bumps the SF op-reth fork to upstream `op-reth/v2.8.2` (18 upstream commits on top of
Expand Down
1 change: 1 addition & 0 deletions rust/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions rust/op-reth/crates/trie/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ reth-chainspec.workspace = true
reth-db-common.workspace = true
reth-ethereum-primitives.workspace = true
reth-evm-ethereum.workspace = true
reth-firehose.workspace = true
reth-storage-errors.workspace = true
secp256k1 = { workspace = true, features = ["rand", "std"] }
mockall.workspace = true
Expand Down
9 changes: 6 additions & 3 deletions rust/op-reth/crates/trie/src/engine/tasks/execute_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,14 @@ where
let state_provider = state.memory.state_provider(block.parent_hash(), inner_provider);

let db = StateProviderDatabase::new(&state_provider);
let block_executor = state.evm_config.batch_executor(db);
let execution_result = block_executor.execute(block)?;
// Must stay `execute_one`, not `execute`: the node's Firehose executor traces `execute` and
// would print a second `FIRE BLOCK` for a block reth's import already traced.
let mut block_executor = state.evm_config.batch_executor(db);
block_executor.execute_one(block)?;
let bundle_state = block_executor.into_state().take_bundle();
let execution_duration = start.elapsed();

let hashed_state = state_provider.hashed_post_state(&execution_result.state)?;
let hashed_state = state_provider.hashed_post_state(&bundle_state)?;
let (state_root, trie_updates) =
state_provider.state_root_with_updates(hashed_state.clone())?;
let state_root_duration = start.elapsed() - execution_duration;
Expand Down
52 changes: 52 additions & 0 deletions rust/op-reth/crates/trie/tests/live.rs
Original file line number Diff line number Diff line change
Expand Up @@ -715,3 +715,55 @@ fn execute_deployed_contract_without_reth_parent_state() -> eyre::Result<()> {
assert_eq!(storage.provider_ro()?.get_latest_block()?.number, 2);
Ok(())
}

/// The proofs engine re-executes blocks reth has already imported and traced, so it must not print
/// them to the Firehose output a second time.
#[test]
#[serial]
fn execute_block_emits_no_firehose_block() -> eyre::Result<()> {
let key_pair = Keypair::new(&Secp256k1::new(), &mut rng());
let sender = public_key_to_address(key_pair.public_key());
let chain_spec = chain_spec_with_address(sender);
// The only test in this binary that installs the process-wide Firehose tracer.
let firehose_output =
reth_firehose::init_tracer_with_buffer(chain_spec.chain.id(), None, None, None);

let factory = create_test_provider_factory_with_chain_spec(chain_spec.clone());
init_genesis(&factory)?;
let storage: OpProofsStorage<Arc<MdbxProofsStorage>> = create_mdbx_proofs_storage().into();
{
let tx = factory.db_ref().tx()?;
InitializationJob::new(storage.clone(), tx, RethTrieStorageLayout::Legacy)
.run(0, chain_spec.genesis_hash())?;
}
let blockchain = BlockchainProvider::new(factory.clone())?;
let pruner = OpProofStoragePruner::new(storage.clone(), blockchain.clone(), 1000);
let engine = EngineHandle::spawn(
reth_firehose::FirehoseEvmConfig::new(EthEvmConfig::ethereum(chain_spec.clone())),
blockchain,
storage,
pruner,
);

let transfer =
BlockSpec::new(vec![TxSpec::transfer(Address::repeat_byte(0x42), U256::from(1))]);
let mut nonce = 0;
let mut block = create_block_from_spec(
&transfer,
1,
chain_spec.genesis_hash(),
&chain_spec,
key_pair,
&mut nonce,
);
execute_block(&mut block, &factory, &chain_spec)?;
// Returns once the engine has executed the block and matched its state root.
engine.execute_block(&block)?;

let output = String::from_utf8(firehose_output.get_bytes())?;
assert!(
!output.contains("FIRE BLOCK"),
"the proofs engine printed a Firehose block:\n{output}"
);
Ok(())
}
Loading