Skip to content

fix(anvil): log's removed field always false during reorg #11298

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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