-
Notifications
You must be signed in to change notification settings - Fork 50
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
fix: Non-determinism while jailing #342
Conversation
x/finality/keeper/liveness.go
Outdated
@@ -21,7 +22,15 @@ func (k Keeper) HandleLiveness(ctx context.Context, height int64) { | |||
// Iterate over all the finality providers which *should* have signed this block | |||
// store whether or not they have actually signed it, identify sluggish | |||
// ones, and apply punishment (TBD) | |||
// Create a sorted slice of keys for deterministic iteration | |||
fpPkHexes := make([]string, 0, len(fpSet)) | |||
for fpPkHex := range fpSet { |
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.
From what I remember the elements in votingPowerBbnBlockHeightStore
are ordered by voting power (sorting and saving happens during block tallying)
What do you think about introducing new function to finality keeper like GetVotingPowerTableOrdered
that will return something like []*FpWithVotingPower
where:
type FpWithVotingPower struct {
fpKeyHex string
votingPower uint64
}
that will just collect values from votingPowerBbnBlockHeightStore
into list.
This way:
- we will avoid this intermediate
map[string]uint64
steap - we will avoid this additional sorting and use the same order we have in
votingPowerBbnBlockHeightStore
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. I thought the ordering of the iterator is implicit but the benefits are clear if we can assume it is already ordered. Fixed in 68d5397
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.
Amazing work identifying and fixing this!
@KonradStaniec Local tested with #344 and worked. Merging it now |
The voting power table is a map which causes random order of processing jailing events. If more than one fps jailed at one block, non-determinism could happen. The PR fixed this by introducing ordered voting power table which retains the order from interating the `votingPowerBbnBlockHeightStore`
The voting power table is a map which causes random order of processing jailing events. If more than one fps jailed at one block, non-determinism could happen. The PR fixed this by introducing ordered voting power table which retains the order from interating the
votingPowerBbnBlockHeightStore