fix(stages): send revert chain notification instead of a reorg on unwind (#7808)

This commit is contained in:
Alexey Shekhirin
2024-04-23 11:36:00 +01:00
committed by GitHub
parent d6b861ea5d
commit d1e38966a1

View File

@ -248,7 +248,7 @@ impl<EF: ExecutorFactory> ExecutionStage<EF> {
let state = executor.take_output_state(); let state = executor.take_output_state();
let write_preparation_duration = time.elapsed(); let write_preparation_duration = time.elapsed();
// Check if we should send a [`CanonStateNotification`] to execution extensions. // Check if we should send a [`ExExNotification`] to execution extensions.
// //
// Note: Since we only write to `blocks` if there are any ExEx's we don't need to perform // Note: Since we only write to `blocks` if there are any ExEx's we don't need to perform
// the `has_exexs` check here as well // the `has_exexs` check here as well
@ -427,18 +427,17 @@ impl<EF: ExecutorFactory, DB: Database> Stage<DB> for ExecutionStage<EF> {
// This also updates `PlainStorageState` and `PlainAccountState`. // This also updates `PlainStorageState` and `PlainAccountState`.
let bundle_state_with_receipts = provider.unwind_or_peek_state::<true>(range.clone())?; let bundle_state_with_receipts = provider.unwind_or_peek_state::<true>(range.clone())?;
// Construct a `CanonStateNotification` if we have ExEx's installed. // Construct a `ExExNotification` if we have ExEx's installed.
if self.exex_manager_handle.has_exexs() { if self.exex_manager_handle.has_exexs() {
// Get the blocks for the unwound range. This is needed for `CanonStateNotification`. // Get the blocks for the unwound range. This is needed for `ExExNotification`.
let blocks = provider.get_take_block_range::<false>(range.clone())?; let blocks = provider.get_take_block_range::<false>(range.clone())?;
let chain = Chain::new(blocks, bundle_state_with_receipts, None); let chain = Chain::new(blocks, bundle_state_with_receipts, None);
// NOTE: We can ignore the error here, since an error means that the channel is closed, // NOTE: We can ignore the error here, since an error means that the channel is closed,
// which means the manager has died, which then in turn means the node is shutting down. // which means the manager has died, which then in turn means the node is shutting down.
let _ = self.exex_manager_handle.send(ExExNotification::ChainReorged { let _ = self
old: Arc::new(chain), .exex_manager_handle
new: Arc::new(Chain::default()), .send(ExExNotification::ChainReverted { old: Arc::new(chain) });
});
} }
// Unwind all receipts for transactions in the block range // Unwind all receipts for transactions in the block range