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

fix: Non-determinism while jailing #342

Merged
merged 8 commits into from
Dec 13, 2024
Merged

Conversation

gitferry
Copy link
Member

@gitferry gitferry commented Dec 13, 2024

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

@gitferry gitferry changed the title fix: Jailing non-determinism fix: Non-determinism while jailing Dec 13, 2024
@gitferry gitferry marked this pull request as ready for review December 13, 2024 07:49
@gitferry gitferry requested a review from a team as a code owner December 13, 2024 07:49
@gitferry gitferry requested review from KonradStaniec, samricotta and SebastianElvis and removed request for a team December 13, 2024 07:49
@@ -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 {
Copy link
Collaborator

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

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. 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

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.

Amazing work identifying and fixing this!

@gitferry
Copy link
Member Author

@KonradStaniec Local tested with #344 and worked. Merging it now

@gitferry gitferry merged commit ccc00b7 into main Dec 13, 2024
19 checks passed
@gitferry gitferry deleted the gai/fix-jailing-non-determinism branch December 13, 2024 10:20
gitferry added a commit that referenced this pull request Dec 13, 2024
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`
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.

3 participants