-
Notifications
You must be signed in to change notification settings - Fork 19
feat: index BackwardLET event
#1379
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
base: develop
Are you sure you want to change the base?
Conversation
1ddf2c5 to
851ecb5
Compare
## 🔄 Changes Summary This PR adds a function to rewind merkle tree to a previous root index. (This will be used for backwarding of `LocalExitTree`). ##⚠️ Breaking Changes NA ## 📋 Config Updates NA ## ✅ Testing - 🤖 **Automatic**: `aggkit` CI
bf95c12 to
e3839b7
Compare
e3839b7 to
275aed8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR implements support for indexing the BackwardLET (Backward Local Exit Tree) event in the bridge syncer, enabling the system to handle rollbacks of the local exit tree when they occur on the L2 bridge contract. The implementation includes archiving deleted bridges for potential restoration during reorgs, along with comprehensive test coverage for the new BackwardToIndex functionality in the tree package.
Key Changes:
- Added BackwardLET event handling that deletes bridges with deposit counts beyond the rollback point and updates the tree state accordingly
- Introduced a bridge_archive table with a trigger to automatically archive deleted bridges, enabling restoration during reorg scenarios
- Implemented BackwardToIndex method on the tree to roll back the Merkle tree to a specific index by deleting higher-indexed roots
Reviewed changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated 13 comments.
Show a summary per file
| File | Description |
|---|---|
| bridgesync/processor.go | Adds BackwardLET event processing logic, bridge archiving/restoration during reorgs, and updates exitTree field type to interface |
| bridgesync/downloader.go | Adds BackwardLET event signature and handler for parsing/appending BackwardLET events from logs |
| bridgesync/downloader_test.go | Adds test coverage for BackwardLET event appender and unknown deployment kind error handling |
| bridgesync/processor_test.go | Adds BackwardLET event to test data and includes reorg test scenario |
| bridgesync/migrations/bridgesync0011.sql | Creates backward_let and bridge_archive tables with archiving trigger |
| bridgesync/migrations/migrations.go | Refactors migration loading to use embed.FS and adds GetUpTo helper function |
| bridgesync/migrations/migrations_test.go | Updates tests to use new GetUpTo helper instead of hardcoded migration lists |
| tree/tree.go | Implements BackwardToIndex method and refactors storeNodes loop for cleaner code |
| tree/tree_test.go | Adds comprehensive test coverage for BackwardToIndex including edge cases |
| tree/types/interfaces.go | Adds BackwardToIndex method to ReorganizeTreer interface |
| tree/types/mocks/*.go | Updates mocks with BackwardToIndex method implementation |
| db/types/interface.go | Adds ExecContext method to Querier interface |
| db/mocks/*.go | Updates mocks with ExecContext method implementation |
Comments suppressed due to low confidence (1)
bridgesync/processor.go:523
- The Event.String() method doesn't include BackwardLET in the string representation. When logging or debugging events that contain BackwardLET, this information will be missing. Add a check for e.BackwardLET and append its string representation to parts.
func (e Event) String() string {
parts := []string{}
if e.Bridge != nil {
parts = append(parts, e.Bridge.String())
}
if e.Claim != nil {
parts = append(parts, e.Claim.String())
}
if e.TokenMapping != nil {
parts = append(parts, e.TokenMapping.String())
}
if e.LegacyTokenMigration != nil {
parts = append(parts, e.LegacyTokenMigration.String())
}
if e.RemoveLegacyToken != nil {
parts = append(parts, e.RemoveLegacyToken.String())
}
if e.UnsetClaim != nil {
parts = append(parts, e.UnsetClaim.String())
}
if e.SetClaim != nil {
parts = append(parts, e.SetClaim.String())
}
return "Event{" + strings.Join(parts, ", ") + "}"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 17 out of 17 changed files in this pull request and generated 6 comments.
Comments suppressed due to low confidence (1)
bridgesync/processor.go:538
- The Event.String() method is missing the BackwardLET field in its string representation. Add a check for e.BackwardLET and append it to the parts slice to ensure complete event logging and debugging output.
func (e Event) String() string {
parts := []string{}
if e.Bridge != nil {
parts = append(parts, e.Bridge.String())
}
if e.Claim != nil {
parts = append(parts, e.Claim.String())
}
if e.TokenMapping != nil {
parts = append(parts, e.TokenMapping.String())
}
if e.LegacyTokenMigration != nil {
parts = append(parts, e.LegacyTokenMigration.String())
}
if e.RemoveLegacyToken != nil {
parts = append(parts, e.RemoveLegacyToken.String())
}
if e.UnsetClaim != nil {
parts = append(parts, e.UnsetClaim.String())
}
if e.SetClaim != nil {
parts = append(parts, e.SetClaim.String())
}
return "Event{" + strings.Join(parts, ", ") + "}"
cece1d3 to
2e09385
Compare
2e09385 to
72fa419
Compare
1451afc to
04f3b2e
Compare
…bset of bridges that were not removed by reorg
6de407e to
3eeb0b9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 19 out of 19 changed files in this pull request and generated 6 comments.
BackwardLET event
|



🔄 Changes Summary
Implement support for indexing of
BackwardLETevent in the bridge syncer. Also implementedBackwardToIndexmethod on the tree to roll back the Merkle tree to a specific index by deleting higher-indexed rootsIndex of
BackwardLETeventOnce we index the
BackwardLETevent, we remove all the bridges whose deposit_count is greater than the new deposit count from the event. We also store the removed bridges into newly introducedbridge_archivetable, in order to be able to bring them back in caseBackwardLETevent gets reorged.Reorg of
BackwardLETeventOnce certain
BackwardLETevents get reorged, we figure out which ranges of bridges, by deposit counts, are affected and we restore them back from thebridge_archiveinto thebridgetable.N/A
📋 Config Updates
N/A
✅ Testing
🐞 Issues
BackwardLETevent in bridge syncer #1359🔗 Related PRs
📝 Notes