Skip to content

Commit

Permalink
fix: reorgs with forks including invalid blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
fgimenez committed Aug 15, 2024
1 parent 15306f4 commit 755a57d
Show file tree
Hide file tree
Showing 2 changed files with 257 additions and 45 deletions.
13 changes: 9 additions & 4 deletions crates/chain-state/src/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ use crate::{
use alloy_signer::SignerSync;
use alloy_signer_local::PrivateKeySigner;
use rand::{thread_rng, Rng};
use reth_chainspec::ChainSpec;
use reth_chainspec::{ChainSpec, EthereumHardfork};
use reth_execution_types::{Chain, ExecutionOutcome};
use reth_primitives::{
constants::{EIP1559_INITIAL_BASE_FEE, EMPTY_ROOT_HASH},
proofs::{calculate_receipt_root, calculate_transaction_root},
proofs::{calculate_receipt_root, calculate_transaction_root, calculate_withdrawals_root},
Address, BlockNumber, Header, Receipt, Receipts, Requests, SealedBlock, SealedBlockWithSenders,
Signature, Transaction, TransactionSigned, TransactionSignedEcRecovered, TxEip1559, B256, U256,
};
Expand Down Expand Up @@ -156,15 +156,20 @@ impl TestBlockBuilder {
),
)])),
// use the number as the timestamp so it is monotonically increasing
timestamp: number,
timestamp: number +
EthereumHardfork::Cancun.activation_timestamp(self.chain_spec.chain).unwrap(),
withdrawals_root: Some(calculate_withdrawals_root(&[])),
blob_gas_used: Some(0),
excess_blob_gas: Some(0),
parent_beacon_block_root: Some(B256::random()),
..Default::default()
};

let block = SealedBlock {
header: header.seal_slow(),
body: transactions.into_iter().map(|tx| tx.into_signed()).collect(),
ommers: Vec::new(),
withdrawals: None,
withdrawals: Some(vec![].into()),
requests: None,
};

Expand Down
Loading

0 comments on commit 755a57d

Please sign in to comment.