Skip to content
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

Merged
merged 50 commits into from
Aug 24, 2024

Conversation

taratorio
Copy link
Member

@taratorio taratorio commented Aug 16, 2024

  1. fixes bridge breaks astrid stage integration #11705
  2. fixes restarts - bridge starting from where it left off previously
  3. fixes starts from snapshots - when the bridge is run as part of the astrid stage integration

polygon/bridge/bridge.go Outdated Show resolved Hide resolved
polygon/bridge/bridge.go Outdated Show resolved Hide resolved
polygon/bridge/bridge.go Outdated Show resolved Hide resolved
polygon/bridge/bridge.go Outdated Show resolved Hide resolved
@taratorio taratorio marked this pull request as ready for review August 23, 2024 14:07
@taratorio taratorio changed the title polygon/bridge: fix synhronisation issues polygon/bridge: fix bridge integration in stage mode Aug 23, 2024
Comment on lines +75 to +97
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
}
Copy link
Member

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
Copy link
Member

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) {
Copy link
Member

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)
Copy link
Member

@antonis19 antonis19 Aug 23, 2024

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.

Comment on lines +71 to +73
fetchedEventsSignal chan struct{}
lastFetchedEventTime atomic.Uint64
processedBlocksSignal chan struct{}
Copy link
Member

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?

@mh0lt mh0lt merged commit ba16134 into main Aug 24, 2024
10 checks passed
@mh0lt mh0lt deleted the astrid-bridge-synchronisation-fix branch August 24, 2024 08:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bridge breaks astrid stage integration
4 participants