Skip to content

Commit 38cae97

Browse files
committed
Add tests for validator locking
1 parent 6117a5f commit 38cae97

File tree

7 files changed

+313
-25
lines changed

7 files changed

+313
-25
lines changed

contracts/contract/megapool/RocketMegapoolDelegate.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,7 @@ contract RocketMegapoolDelegate is RocketMegapoolDelegateBase, RocketMegapoolDel
508508
function notifyNotExit(uint32 _validatorId, uint64 _slot) override external onlyRocketMegapoolManager {
509509
ValidatorInfo memory validator = validators[_validatorId];
510510
// Check required state
511-
require(validator.locked, "Validator is not locked");
511+
require(validator.locked, "Validator not locked");
512512
require(_slot >= validator.lockedSlot, "Proof is older than challenge");
513513
// Update validator state to exiting/locked
514514
validator.locked = false;
@@ -580,7 +580,7 @@ contract RocketMegapoolDelegate is RocketMegapoolDelegateBase, RocketMegapoolDel
580580
function _notifyFinalBalance(uint32 _validatorId, uint64 _amountInGwei, uint64 _withdrawalSlot) internal {
581581
ValidatorInfo memory validator = validators[_validatorId];
582582
require(!validator.exited, "Already exited");
583-
require(validator.exiting, "Validator is not exiting");
583+
require(validator.exiting, "Validator not exiting");
584584
require(!validator.dissolved, "Validator dissolved");
585585
require(_withdrawalSlot >= validator.withdrawableEpoch * slotsPerEpoch, "Not full withdrawal");
586586
// Mark as exited

contracts/contract/megapool/RocketMegapoolManager.sol

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ contract RocketMegapoolManager is RocketBase, RocketMegapoolManagerInterface {
3737
setUint(keccak256(abi.encodePacked("megapool.validator.set", index)), encoded);
3838
}
3939

40+
/// @notice Returns the last trusted member to execute a challenge
41+
function getLastChallenger() override external view returns (address) {
42+
return getAddress(challengerKey);
43+
}
44+
4045
/// @notice Returns validator info for the given global megapool validator index
4146
/// @param _index The index of the validator to query
4247
function getValidatorInfo(uint256 _index) override external view returns (RocketMegapoolStorageLayout.ValidatorInfo memory validatorInfo, address megapool, uint32 validatorId) {
@@ -93,7 +98,7 @@ contract RocketMegapoolManager is RocketBase, RocketMegapoolManagerInterface {
9398
BeaconStateVerifierInterface beaconStateVerifier = BeaconStateVerifierInterface(getContractAddress("beaconStateVerifier"));
9499
require(beaconStateVerifier.verifyValidator(_proof), "Invalid proof");
95100
// Verify correct withdrawable_epoch
96-
require(_proof.validator.withdrawableEpoch < farFutureEpoch, "Validator is not exiting");
101+
require(_proof.validator.withdrawableEpoch < farFutureEpoch, "Validator not exiting");
97102
// Verify matching validator index
98103
RocketMegapoolStorageLayout.ValidatorInfo memory validatorInfo = _megapool.getValidatorInfo(_validatorId);
99104
require(_proof.validatorIndex == validatorInfo.validatorIndex, "Invalid proof");

contracts/interface/megapool/RocketMegapoolManagerInterface.sol

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ interface RocketMegapoolManagerInterface {
1313

1414
function getValidatorCount() external view returns (uint256);
1515
function addValidator(address _megapoolAddress, uint32 _validatorId) external;
16+
function getLastChallenger() external view returns (address);
1617
function getValidatorInfo(uint256 _index) external view returns (RocketMegapoolStorageLayout.ValidatorInfo memory validatorInfo, address megapool, uint32 validatorId);
1718
function stake(RocketMegapoolInterface megapool, uint32 _validatorId, ValidatorProof calldata _proof) external;
1819
function dissolve(RocketMegapoolInterface megapool, uint32 _validatorId, ValidatorProof calldata _proof) external;

0 commit comments

Comments
 (0)