Add additional checks to consensus contracts #382
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds the following checks to
Authority
andQuorum
:lastProcessedBlockNumber < block.number
: validators cannot process blocks in the futurelastProcessedBlockNumber % epochLength == (epochLength - 1)
: validators have to validate blocks until the last block of an epochThe last point is implemented differently for
Authority
andQuorum
:Both contracts use OpenZeppelin's bitmap data structure to store sets.
In Authority, epochs are identified by their number (
lastProcessedBlockNumber / epochLength
)In Quorum, validators are identified by their ID.
Because of how OpenZepplein implements bitmaps and how these numbers are close to one another, this saves gas because fewer storage slots have to be read/written.
Other notable things about this PR:
require(bool, CustomError)
syntax)IConsensus
for each of these checksIQuorum
to consult information about validators that have submitted any claim for a particular epoch (basically exposing the newly-added state variables through the interface).