feat(staking): add basic key rotation#26440
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #26440 +/- ##
==========================================
+ Coverage 64.82% 64.86% +0.03%
==========================================
Files 810 811 +1
Lines 56157 56357 +200
==========================================
+ Hits 36406 36555 +149
- Misses 19751 19802 +51
🚀 New features to boost your workflow:
|
Greptile SummaryThis PR introduces the foundational "happy path" consensus key rotation for validators, as specified in ADR-16. The msg server queues rotations into four new KV-store indexes; the EndBlocker applies them as paired ABCI
Confidence Score: 4/5Safe to merge as an explicitly incomplete foundation; no blocking bugs found in the happy-path flow. The core state machine — queuing, applying, and pruning rotations — is logically correct. Previous thread concerns (iterator mutation, same-block collision, fee routing, jailed guard) have all been addressed. The two remaining findings are non-blocking quality issues: an exported constant that is never read by the enforcement path, and a dead x/staking/keeper/rotation.go — the Important Files Changed
|
…onInUnbondingWindow
…s in use Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
|
@greptile re review |
…make sure it is initialized
|
@greptile review again, that test you are referencing has already been fixed |
|
@greptile review again |
|
@greptile review again. review specifically looking for other issues similar to the previous issue you found Same-block rotation collision corrupts validator state |
|
@greptile review again |
|
approving. a few things to track for follow-up: genesis import/export missing, rotation state won't survive an export/import cycle. fee + max-rotations hardcoded, may be fine depending on whether these need to be governable. possible block-stm gap: lock check in msg_server reads RotationLockedConsAddrIndexKey before SetConsKeyRotation writes it. under parallel execution two txns targeting the same new key in the same block could both pass validation. worth verifying. |
|
doesn't call |
@aljo242 good callout here, im making a ticket to track this as a follow up (dont allow CreateValidator on locked consensus keys) |
Description
Adds the ability for validators to rotate their consensus keys. This is currently just the happy path implementation and is explicitly not feature complete. This is missing major features that will be implemented as follow up such as:
1000000ofDefaultBondDenomcurrently).The design implemented here and in future PR's is following ADR-16. Reading the ADR would be a very helpful starting point to review this PR. There was a previous implementation of this here. This PR and future PR's are also largely using this as a reference point.
The main files to review here are:
x/staking/keeper/msg_server.go- TheRotateConsPubKeymethod does basic validation to ensure that the validator is allowed to do a rotation, and then schedules the rotation to happen during theEndBlocker(since the rotation is really a set of ABCIValidatorUpdate's, it must happen during the end blocker and not during the msg handling).x/staking/types/keys.go- There are four new keys implemented to facilitate key rotation.UnappliedConsKeyRotationKey- A queue of rotations that needs to happen during the nextEndBlockerRotatedConsAddrIndexKey- Lookup of old keys to new keys. Pruned during when the rotation of old -> new happened longer than 1 unbending period ago.ValidatorConsKeyRotationKey- Lookup of validators that have rotated during within 1 unbonding period ago.ConsKeyRotationQueueKey- Queue of rotations that have happened within this unbending period. Used to pruneRotatedConsAddrIndexKeyandValidatorConsKeyRotationKeywhen the rotation is no longer relevant.x/staking/keeper/val_state_change.go-EndBlockerimplementation. Calls to do the actual key rotation in state, creating theValidatorUpdate's, cleaning up the stores.x/staking/keeper/rotation.go- Keeper helpers related to key rotation.Closes: STACK-2805