Skip to content

Conversation

Peponks9
Copy link

Motivation

Closes #9933

During blockchain reorgs, event logs from removed blocks should be re-emitted with removed: true to notify subscribers that those logs are no longer valid. However, they were always emitted with removed: false, making it impossible for clients to properly handle reorgs.

Solution

  • Add ReorgedBlockNotification system alongside existing NewBlockNotification
  • Modify rollback() to collect block data and receipts before unwinding storage
  • Update LogsSubscription to listen for reorg notifications and emit logs with removed: true
  • Enhance filter_logs function to accept a removed parameter

PR Checklist

  • Added Test - test_reorg_logs_removed_field using SimpleStorage contract
  • Added Documentation - Comments explaining reorg notification flow
  • Breaking changes - No breaking changes after running cargocommands at CONTRIBUTING.md

- Add ReorgedBlockNotification system for proper reorg handling
- Collect block data before unwinding storage during rollbacks
- Update LogsSubscription to emit logs with removed=true for reorged blocks
- Add comprehensive test using SimpleStorage contract

Fixes foundry-rs#9933
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

bug(anvil): log's remove field is always false if re-org
1 participant