From c44117075e8321664d7e8ceabc898e88adbc3338 Mon Sep 17 00:00:00 2001 From: Dan Cline <6798349+Rjected@users.noreply.github.com> Date: Tue, 16 May 2023 14:19:59 -0400 Subject: [PATCH] fix: update rpc latest block from mining task (#2700) --- crates/consensus/auto-seal/src/task.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/crates/consensus/auto-seal/src/task.rs b/crates/consensus/auto-seal/src/task.rs index ff772a13f1..8c3d13d09a 100644 --- a/crates/consensus/auto-seal/src/task.rs +++ b/crates/consensus/auto-seal/src/task.rs @@ -7,7 +7,7 @@ use reth_primitives::{ proofs, Block, BlockBody, ChainSpec, Header, IntoRecoveredTransaction, ReceiptWithBloom, SealedBlockWithSenders, EMPTY_OMMER_ROOT, U256, }; -use reth_provider::{CanonStateNotificationSender, Chain, StateProviderFactory}; +use reth_provider::{CanonChainTracker, CanonStateNotificationSender, Chain, StateProviderFactory}; use reth_revm::{ database::{State, SubState}, executor::Executor, @@ -85,7 +85,7 @@ impl MiningTask { impl Future for MiningTask where - Client: StateProviderFactory + Clone + Unpin + 'static, + Client: StateProviderFactory + CanonChainTracker + Clone + Unpin + 'static, Pool: TransactionPool + Unpin + 'static, ::Transaction: IntoRecoveredTransaction, { @@ -249,6 +249,11 @@ where SealedBlockWithSenders::new(sealed_block, senders) .expect("senders are valid"); + // update canon chain for rpc + client.set_canonical_head(header.clone().seal(new_hash)); + client.set_safe(header.clone().seal(new_hash)); + client.set_finalized(header.clone().seal(new_hash)); + debug!(target: "consensus::auto", header=?sealed_block_with_senders.hash(), "sending block notification"); let chain =