feat(registry): take historical validator snapshots #99
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 completes Stage 1: Administration of the roadmap for using the
PodRegistry
contract on Ethereum as the source of truth for pod validators (ultimately, with staking & slashing). It introduces a validator lifecycle model with active/inactive states, allowing validators to temporarily deactivate (e.g., for maintenance) and later reactivate. The contract owner can also ban/unban validators, where banning permanently removes a validator from the active set until explicitly unbanned.The contract now also supports historical validator set tracking via snapshots. Each time the active validator set changes (addition, ban/unban, deactivate/reactivate), a snapshot of the validator bitmap and the block number is stored. This enables efficient historical proofs of validator membership using a witness index and block reference.
Breaking Changes
removeValidator()
; replaced bybanValidator()
andunbanValidator()
.validatorCount
from storage; validator counts are now derived fromactiveValidatorBitmap
.computeWeight()
signature requiringblockNumber
andsnapshotIndex
for historical validation.computeWeight()
computes the number of validators in the given subset that were active at a specific historical block using the provided snapshot index as a witness. Ensures the snapshot is valid for the given block and counts unique active validators without duplication.Important Notes
history[]
and indexed by block; usefindSnapshotIndex()
view function for binary search off-chain.activeValidatorBitmap
; supports up to 255 validators.activeValidatorBitmap
instead of using a stored counter.computeWeight()
checks that the provided snapshot index is neither too old nor too new for the given block.