From 97d1358a28f92d43489b5a323b4e300c18460353 Mon Sep 17 00:00:00 2001 From: Roshan <48975233+pythonberg1997@users.noreply.github.com> Date: Tue, 27 Aug 2024 19:33:53 +0800 Subject: [PATCH] fix: bsc snapshot issues (#122) --- crates/blockchain-tree/src/chain.rs | 11 ++++++++--- crates/bsc/evm/src/execute.rs | 3 ++- crates/cli/commands/src/stage/drop.rs | 1 + 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/crates/blockchain-tree/src/chain.rs b/crates/blockchain-tree/src/chain.rs index 7dfdce696..d7d259532 100644 --- a/crates/blockchain-tree/src/chain.rs +++ b/crates/blockchain-tree/src/chain.rs @@ -214,13 +214,18 @@ impl AppendableChain { let block = block.unseal(); let state = executor.execute((&block, U256::MAX, ancestor_blocks).into())?; - let BlockExecutionOutput { state, receipts, requests, .. } = state; + let BlockExecutionOutput { state, receipts, requests, gas_used: _, snapshot } = state; externals .consensus .validate_block_post_execution(&block, PostExecutionInput::new(&receipts, &requests))?; - let initial_execution_outcome = - ExecutionOutcome::new(state, receipts.into(), block.number, vec![requests.into()]); + let initial_execution_outcome = ExecutionOutcome::new_with_snapshots( + state, + receipts.into(), + block.number, + vec![requests.into()], + vec![snapshot.unwrap_or_default()], + ); // check state root if the block extends the canonical chain __and__ if state root // validation was requested. diff --git a/crates/bsc/evm/src/execute.rs b/crates/bsc/evm/src/execute.rs index 121193135..927f44ae3 100644 --- a/crates/bsc/evm/src/execute.rs +++ b/crates/bsc/evm/src/execute.rs @@ -928,9 +928,10 @@ where self.parlia.chain_spec().is_bohr_active_at_timestamp(header.timestamp), ) .ok_or_else(|| BscBlockExecutionError::ApplySnapshotFailed)?; + + cache.put(snap.block_hash, snap.clone()); } - cache.put(snap.block_hash, snap.clone()); Ok(snap) } diff --git a/crates/cli/commands/src/stage/drop.rs b/crates/cli/commands/src/stage/drop.rs index ec7a91b6d..e5e6e581e 100644 --- a/crates/cli/commands/src/stage/drop.rs +++ b/crates/cli/commands/src/stage/drop.rs @@ -97,6 +97,7 @@ impl Command { tx.clear::()?; tx.clear::()?; tx.clear::()?; + tx.clear::()?; tx.put::( StageId::Execution.to_string(), Default::default(),