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

chore: Replace fast sync with batch processing #132

Merged
merged 11 commits into from
Nov 20, 2024

Conversation

gitferry
Copy link
Member

@gitferry gitferry commented Nov 19, 2024

Closes #118. Notable changes:

  • remove fast sync completely
  • introduce batch process for catching up
  • introduce signature submission interval to config
  • introduce batch submission size to config

@gitferry gitferry force-pushed the gai/replace-fast-sync-with-batch-processing branch from e0a35a8 to df7421a Compare November 19, 2024 04:05
@gitferry gitferry force-pushed the gai/replace-fast-sync-with-batch-processing branch from df7421a to 9976e23 Compare November 19, 2024 04:07
@gitferry gitferry marked this pull request as ready for review November 19, 2024 06:16
Copy link
Member

@Lazar955 Lazar955 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm! Good job simplifying the logic!


latestFinalisedBlocks, err := fp.latestFinalizedBlocksWithRetry(1)
if err != nil {
return 0, err
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: wrap errors

// error will be returned if maximum retries have been reached or the query to the consumer chain fails
func (fp *FinalityProviderInstance) retrySubmitFinalitySignatureUntilBlockFinalized(targetBlock *types.BlockInfo) (*types.TxResponse, error) {
func (fp *FinalityProviderInstance) retrySubmitFinalitySignaturesUntilBlocksFinalized(targetBlocks []*types.BlockInfo) (*types.TxResponse, error) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: fcn name is quite long suggestion retrySubmitSignatures

defaultSignatureSubmissionInterval = 1 * time.Second
defaultMaxSubmissionRetries = 20
defaultBitcoinNetwork = "signet"
defaultDataDirname = "data"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we add a config for batch processing size? what's the current code behavior if it lags way behind?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. Fixed.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the fp lags behind, the poller should quickly poll blocks (that's why we should have a short polling interval). Then the fp will do batch submission

@@ -4,7 +4,7 @@ import "time"

var (
defaultBufferSize = uint32(1000)
defaultPollingInterval = 20 * time.Second
defaultPollingInterval = 100 * time.Millisecond
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think the polling interval shouldn't be less than the chain block-producing time. OP chain is usually 2-3 seconds. what's the block time for Babylon chain?

Copy link
Member Author

@gitferry gitferry Nov 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would argue that we should have a short polling interval for a quick catching up. Would ms level interval be a concern in practice?

Copy link
Contributor

@bap2pecs bap2pecs Nov 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Catching up is not a common case. If it's way behind, people should just change the config file temporarily to speed up. imo default value should be for normal submission cases

Copy link
Member Author

@gitferry gitferry Nov 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense. Changed it to 1s to cover most surprises and added notes there

@gitferry
Copy link
Member Author

I would wait for one more approval before merge

Copy link
Contributor

@bap2pecs bap2pecs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm. can we cherrypick this to the base consumer branch?

@gitferry
Copy link
Member Author

lgtm. can we cherrypick this to the base consumer branch?

Sure.

Copy link

@KonradStaniec KonradStaniec left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks much cleaner now 👍

func (fp *FinalityProviderInstance) getAllBlocksFromChan() []*types.BlockInfo {
var pollerBlocks []*types.BlockInfo
for {
select {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you could also add:

case <-fp.quit:

to this select, to not wait long time for quit in case of many blocks pending on poller channel.

@gitferry gitferry merged commit e052ab3 into main Nov 20, 2024
12 checks passed
@gitferry gitferry deleted the gai/replace-fast-sync-with-batch-processing branch November 20, 2024 08:43
@bap2pecs
Copy link
Contributor

@gitferry do you plan to backport this to the base branch?

@gitferry
Copy link
Member Author

@bap2pecs not sure it's efficient to backport every change to the base branch. Do we have a routine to periodically backport changes to the base branch?

@bap2pecs
Copy link
Contributor

@bap2pecs not sure it's efficient to backport every change to the base branch. Do we have a routine to periodically backport changes to the base branch?

actually it's probably the opposite. I feel it's probably always better to backport right away or context will be lost. for example, #153 is not a straightforward backport due to some interface level difference between main and base branch. but I can quickly backport it b/c my memory was fresh so I know where to change

also, i'd say for important changes like this, we should proritize. this one is currently blocking some of our works (e.g. e2e test refactoring) so we'd appreciate if it can be backported

@gitferry
Copy link
Member Author

@bap2pecs Make sense. I'll backport it

gitferry added a commit that referenced this pull request Nov 25, 2024
Closes #118. Notable changes:
* remove fast sync completely
* introduce batch process for catching up
* introduce signature submission interval to config
* introduce batch submission size to config
gitferry added a commit that referenced this pull request Nov 25, 2024
Closes #118. Notable changes:
* remove fast sync completely
* introduce batch process for catching up
* introduce signature submission interval to config
* introduce batch submission size to config
@bap2pecs
Copy link
Contributor

@bap2pecs Make sense. I'll backport it

thanks a lot! I remember @vitsalis told me in Bangkok that this backport issue will be solved soon but i don't remember the conversation

do you guys feel that backporting takes lots of engineering time for your team? @gitferry @SebastianElvis

gitferry added a commit that referenced this pull request Nov 25, 2024
Closes #118. Notable changes:
* remove fast sync completely
* introduce batch process for catching up
* introduce signature submission interval to config
* introduce batch submission size to config
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.

Cherry-pick batch submission to replace fast sync
4 participants