-
Notifications
You must be signed in to change notification settings - Fork 15
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: Refactor CommitPubRand
#233
base: main
Are you sure you want to change the base?
Conversation
4ca005d
to
dc93487
Compare
@@ -316,9 +373,17 @@ func (fp *FinalityProviderInstance) hasVotingPower(b *types.BlockInfo) (bool, er | |||
zap.Uint64("block_height", b.Height), | |||
) | |||
|
|||
if fp.GetStatus() == proto.FinalityProviderStatus_ACTIVE { | |||
fp.MustSetStatus(proto.FinalityProviderStatus_INACTIVE) |
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.
Nit: not a huge fan of this, it's a bit hidden away that this function updates state. I suggest making it return the voting power or something like (bool, uint64, err), and then the function caller can decide what to do with it.
Alternatively, add comment saying that it also updates local status
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.
Good point. Did some refactoring in 757156e
@@ -173,41 +171,42 @@ func (fp *FinalityProviderInstance) finalitySigSubmissionLoop() { | |||
defer fp.wg.Done() | |||
|
|||
for { | |||
// start submission in the first iteration | |||
pollerBlocks := fp.getAllBlocksFromChan() |
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.
nice, I bet we do this a lot throughout the codebases, that we wait before the first iteration
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 just realized that we can't do it for every loop for cases where we have continue
upon error. If we do, then we the loop will go forever. Need to figure out other ways for it
9c904b3
to
5ec5a77
Compare
5ec5a77
to
edb1eb0
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.
Great work!
Closes #225. The major goal of this pr is to refactor
CommitPubRand
but turned out included many small refactorings along the way (sorry for the mixup). Notable changes are:retryCommitPubRandUntilBlockFinalized
intoShouldCommitRandomness
andCommitPubRand
. The former checks whether a new commit should be made based on the last committed height and the tip height. Iftrue
, it also returns the start height of the commit. The latter makes a new commit based on the start height returned by the former.config.MinRandHeightGap
toconfig.TimestampingDelayBlocks
which is an estimated value of the latency between a commit is submitted and it is timestamped by the btc-timestamping protocolProcessBlocksToVote
Reviewers, please take a careful look at
fp_instance.go
, especially howShouldCommitRandomness
determines the start height with consideration of btc-timestamping delay