-
Notifications
You must be signed in to change notification settings - Fork 14
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
feat: batch processing non-finalised blocks #57
Conversation
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 is an algorithm-level change so let's get approval from @gitferry : What do you think about submitting finality signatures for all blocks if multiple blocks are in the channel?
Also, if this idea is approved, how about we merge it to main
?
default: | ||
goto processBlocks |
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.
Is there a way to avoid the goto
statement, as it seems not a good practice.
Here default
is hit when the channel becomes empty. Can we replace this goto
with break
then?
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.
Using a boolean fetchMoreBlocks
, it replaced goto
statement.
yes and also #54. we can cherry pick the PRs |
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.
In general I like the batching solution. Left some suggestion in code-wise. We'd better add a test case to ensure the solution works
@@ -194,52 +193,51 @@ func (fp *FinalityProviderInstance) IsRunning() bool { | |||
func (fp *FinalityProviderInstance) finalitySigSubmissionLoop() { | |||
defer fp.wg.Done() | |||
|
|||
var targetHeight uint64 | |||
for { | |||
select { | |||
case b := <-fp.poller.GetBlockInfoChan(): |
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 think we can put it in the default case where we have getAllBlocksFromChan()
to drain the channel and then try to process each block and do batch send
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.
Do you mean to put the var targetHeight uint64
in the default
case of the inner loop?
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 meant the entire block fetching logic can be put in the default
case so that we can have a method to fetch them all other than fetch one, and the rest
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.
Got it. Updated.
// due to lack of voting power or public randomness, so we may | ||
// have gaps during processing | ||
pollerBlocks := []*types.BlockInfo{b} | ||
fetchMoreBlocks := true |
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.
we probably don't need this flag. We can use for {}
and inject break
in default
case
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.
yes, it is removed.
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.
LGTM! We should test this case but can be done in a separate PR
@lesterli have we tested this using our demo app to see how long it takes after this change? |
Summary
This PR fixes the issue #55
Test Plan