-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
polygon/bridge: fix bridge integration in stage mode #11646
Conversation
taratorio
commented
Aug 16, 2024
•
edited
Loading
edited
- fixes bridge breaks astrid stage integration #11705
- fixes restarts - bridge starting from where it left off previously
- fixes starts from snapshots - when the bridge is run as part of the astrid stage integration
…ge-synchronisation-fix
…tech/erigon into astrid-bridge-synchronisation-fix
…watch/erigon into astrid-bridge-synchronisation-fix
…e-synchronisation-fix
This reverts commit 9d3c54b.
…ge-synchronisation-fix
…ge-synchronisation-fix
…ge-synchronisation-fix
epbCursor, err := tx.RwCursor(kv.BorEventProcessedBlocks) | ||
if err != nil { | ||
return deleted, err | ||
} | ||
|
||
defer epbCursor.Close() | ||
counter = blocksDeleteLimit | ||
for k, _, err = epbCursor.First(); err == nil && k != nil && counter > 0; k, _, err = epbCursor.Next() { | ||
blockNum := binary.BigEndian.Uint64(k) | ||
if blockNum >= blockTo { | ||
break | ||
} | ||
|
||
if err = epbCursor.DeleteCurrent(); err != nil { | ||
return deleted, err | ||
} | ||
|
||
deleted++ | ||
counter-- | ||
} | ||
if err != nil { | ||
return deleted, err | ||
} |
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.
This can be extracted into a sub-function.
return deleted, err | ||
} | ||
|
||
// spans |
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.
Can be extracted to a DeleteSpans
function.
@@ -30,6 +30,7 @@ import ( | |||
// doesn't change sequences of kv.EthTx | |||
// doesn't delete Receipts, Senders, Canonical markers, TotalDifficulty | |||
func PruneBorBlocks(tx kv.RwTx, blockTo uint64, blocksDeleteLimit int, SpanIdAt func(number uint64) uint64) (deleted int, err error) { |
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.
Can you explain the return value also? Is deleted
the total number of objects deleted?
@@ -88,6 +115,9 @@ func PruneBorBlocks(tx kv.RwTx, blockTo uint64, blocksDeleteLimit int, SpanIdAt | |||
deleted++ | |||
counter-- | |||
} | |||
if err != nil { | |||
return deleted, err | |||
} | |||
|
|||
if snaptype.CheckpointsEnabled() { | |||
checkpointCursor, err := tx.RwCursor(kv.BorCheckpoints) |
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.
I know this isn't part or purpose of the PR, but since this function is a bit long, you could split it into smaller sub-functions each deleting from a certain table.
fetchedEventsSignal chan struct{} | ||
lastFetchedEventTime atomic.Uint64 | ||
processedBlocksSignal chan struct{} |
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.
Could you add a small description about what these signals are for?