Module agora.consensus.EnrollmentManager
Manages this node's Enrollment, the ValidatorSet
, and EnrollmentPool
This class currently has 3 responsibilities:
- It's a bridge to the ValidatorSet
, where the list of currently active
validators is stored;
- It stores Enrollment
s that are not yet part of the validator set;
- Most importantly, if this node is a validator, it manages this node's
Enrollment
data, including pre-images.
The consensus protocol requires each validator to commit to a hash and
to reveal a pre-image for the next ValidatorCycle
blocks (currently 1008).
That newly-revealed hash is used as a basis for various operations,
such as deriving the new signature noise (in order to make signature
aggregation possible) and both as a source of randomness for the node
itself (e.g. for the quorum balancing) and as part of the network
randomness function, when aggregated with other node's pre-images.
As a result, revealing the pre-image in time is absolutely critical and
not doing so will lead to penalties.
In order to ensure that we will never lose the ability to reveal
pre-images, this implementation uses a reproducible scheme:
on the first run, we generate a "cycle seed" which is derived from a hash
of the private key, a constant string, and a constant value (0).
Using this cycle seed, we generate a large amount of pre-images
(currently 5_040_000). Then out of this range of
[0 .. 5_040_000] pre-images, we reveal the last 1008 (ValidatorCycle
),
or in D terms [$ - 1008 .. $]
.
When the first enrollment runs out, we reveal the next last 1008,
or in D terms [$ - 2016 .. $ - 1008]
.
When the cycle is expired, we re-generate a new cycle seed.
By using this scheme, a node that would start from scratch with
an already-enrolled key will be able to recover its
cycle index by scanning the blockchain, and resume validating.
Classes
Name | Description |
---|---|
EnrollmentManager
|
Handle enrollment data and manage the validators set |