Skip to content

Conversation

@re-gius
Copy link
Contributor

@re-gius re-gius commented Jan 21, 2026

Description

This PR builds on top of the work of #10453 (thanks @AlexandruCihodaru ) and adds support for handling blockchain reverts, useful in testing environments with RPCs like evm_revert or anvil_reset.

Changes

  • Add ChainEvent::Reverted variant to represent backward blockchain progression
  • Add EnactmentAction::HandleReversion to route revert events appropriately
  • Implement handle_reverted() method that:
    • identifies and removes all views beyond the revert point (both active and inactive)
    • collects transactions from retracted blocks via included_transactions cache or API
    • removes those transactions from mempool (they can be resubmitted later)
    • creates a fresh view at the new head populated from the current mempool state
    • atomically updates most_recent_view and cleans up listener references

Review Notes

  • We always create a fresh view at the revert target block rather than reusing stale views, ensuring the view reflects the current mempool state
  • Pending transactions will appear in the new view only if they pass revalidation against the new head's state
  • Transactions from reverted blocks are removed without banning, allowing resubmission
  • View removal and most_recent_view update are performed atomically by holding all three locks (most_recent_view,
    active_views, inactive_views) simultaneously, following the same pattern as ViewStore::insert_new_view_sync to prevent race conditions, as suggested by @michalkucharczyk

@re-gius
Copy link
Contributor Author

re-gius commented Jan 21, 2026

/cmd prdoc --audience runtime_dev --bump patch

@re-gius re-gius added the T0-node This PR/Issue is related to the topic “node”. label Jan 21, 2026
@re-gius re-gius self-assigned this Jan 21, 2026
@paritytech-workflow-stopper
Copy link

All GitHub workflows were cancelled due to failure one of the required jobs.
Failed workflow url: https://github.com/paritytech/polkadot-sdk/actions/runs/21218327371
Failed job name: fmt

@re-gius
Copy link
Contributor Author

re-gius commented Jan 22, 2026

/cmd fmt

@re-gius re-gius force-pushed the re-gius/handle-blockchain-revert branch from fab1f92 to c56de2e Compare January 22, 2026 11:20
@re-gius re-gius changed the base branch from master to acihodaru/chain_event_revert January 22, 2026 11:20
@re-gius re-gius merged commit 8a2b338 into acihodaru/chain_event_revert Jan 22, 2026
150 of 154 checks passed
@re-gius re-gius deleted the re-gius/handle-blockchain-revert branch January 22, 2026 11:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

T0-node This PR/Issue is related to the topic “node”.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants