Skip to content
Merged
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
19 changes: 13 additions & 6 deletions crates/cli/commands/src/init_state/without_evm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ where

let static_file_provider = provider_rw.static_file_provider();
// Write EVM dummy data up to `header - 1` block
append_dummy_chain(&static_file_provider, header.number() - 1)?;
append_dummy_chain(&static_file_provider, header.number() - 1, |number| Header {
number,
..Default::default()
})?;

info!(target: "reth::cli", "Appending first valid block.");

Expand Down Expand Up @@ -97,10 +100,15 @@ where
/// * Headers: It will push an empty block.
/// * Transactions: It will not push any tx, only increments the end block range.
/// * Receipts: It will not push any receipt, only increments the end block range.
fn append_dummy_chain<N: NodePrimitives<BlockHeader = Header>>(
fn append_dummy_chain<N, F>(
sf_provider: &StaticFileProvider<N>,
target_height: BlockNumber,
) -> ProviderResult<()> {
header_factory: F,
) -> ProviderResult<()>
where
N: NodePrimitives,
F: Fn(BlockNumber) -> N::BlockHeader + Send + Sync + 'static,
{
let (tx, rx) = std::sync::mpsc::channel();

// Spawn jobs for incrementing the block end range of transactions and receipts
Expand All @@ -122,12 +130,11 @@ fn append_dummy_chain<N: NodePrimitives<BlockHeader = Header>>(
// Spawn job for appending empty headers
let provider = sf_provider.clone();
std::thread::spawn(move || {
let mut empty_header = Header::default();
let result = provider.latest_writer(StaticFileSegment::Headers).and_then(|mut writer| {
for block_num in 1..=target_height {
// TODO: should we fill with real parent_hash?
empty_header.number = block_num;
writer.append_header(&empty_header, U256::ZERO, &B256::ZERO)?;
let header = header_factory(block_num);
writer.append_header(&header, U256::ZERO, &B256::ZERO)?;
}
Ok(())
});
Expand Down
Loading