Documentation ¶
Overview ¶
Package groupselection implements the random beacon group selection protocol - an interactive, ticket-based method of selecting a candidate group from the set of all stakers given a pseudorandom seed value.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CandidateToNewGroup ¶
func CandidateToNewGroup( relayChain relaychain.Interface, blockCounter chain.BlockCounter, chainConfig *config.Chain, staker chain.Staker, newEntry *big.Int, startBlockHeight uint64, onGroupSelected func(*Result), ) error
CandidateToNewGroup attempts to generate and submit tickets for the staker to join a new group.
To minimize the submitter's cost by minimizing the number of redundant tickets that are not selected into the group, tickets are submitted in N rounds, each round taking 6 blocks. As the basic principle, the number of leading zeros in the ticket value is subtracted from the number of rounds to determine the round the ticket should be submitted in: - in round 0, tickets with N or more leading zeros are submitted - in round 1, tickets with N-1 or more leading zeros are submitted (...) - in round N, tickets with no leading zeros are submitted.
In each round, group member candidate needs to monitor tickets submitted by other candidates and compare them against tickets of the candidate not yet submitted to determine if continuing with ticket submission still makes sense.
After the last round, there is a 12 blocks mining lag allowing all outstanding ticket submissions to have a higher chance of being mined before the deadline.
Types ¶
type Result ¶
type Result struct { SelectedStakers []relaychain.StakerAddress GroupSelectionEndBlock uint64 }
Result represents the result of group selection protocol. It contains the list of all stakers selected to the candidate group as well as the number of block at which the group selection protocol completed.