diff --git a/contracts/contracts/strategies/NativeStaking/CompoundingStakingSSVStrategy.sol b/contracts/contracts/strategies/NativeStaking/CompoundingStakingSSVStrategy.sol index ba132fa879..dd4b1b3675 100644 --- a/contracts/contracts/strategies/NativeStaking/CompoundingStakingSSVStrategy.sol +++ b/contracts/contracts/strategies/NativeStaking/CompoundingStakingSSVStrategy.sol @@ -68,6 +68,10 @@ contract CompoundingStakingSSVStrategy is CompoundingStakingStrategy { // Hash the public key using the Beacon Chain's format bytes32 pubKeyHash = _hashPubKey(publicKey); + if (validator[pubKeyHash].state != ValidatorState.NON_REGISTERED) { + revert NotRegisteredOrVerified(); + } + // Store the validator state as registered validator[pubKeyHash].state = ValidatorState.REGISTERED; diff --git a/contracts/test/strategies/compoundingSSVStaking.js b/contracts/test/strategies/compoundingSSVStaking.js index 90c8922ca4..4497eadfa1 100644 --- a/contracts/test/strategies/compoundingSSVStaking.js +++ b/contracts/test/strategies/compoundingSSVStaking.js @@ -1082,7 +1082,52 @@ describe("Unit test: Compounding SSV Staking Strategy", function () { emptyCluster, { value: ethUnits("2") } ) - ).to.be.reverted; + ).to.be.revertedWithCustomError("NotRegisteredOrVerified()"); + }); + + it("Should revert when re-registering a removed validator", async () => { + const { compoundingStakingSSVStrategy, validatorRegistrator } = fixture; + + const testValidator = testValidators[0]; + + // Register a new validator with the SSV Network + await compoundingStakingSSVStrategy + .connect(validatorRegistrator) + .registerSsvValidator( + testValidator.publicKey, + testValidator.operatorIds, + testValidator.sharesData, + emptyCluster, + { value: ethUnits("2") } + ); + + await compoundingStakingSSVStrategy + .connect(validatorRegistrator) + .removeSsvValidator( + testValidator.publicKey, + testValidator.operatorIds, + emptyCluster + ); + + expect( + ( + await compoundingStakingSSVStrategy.validator( + testValidator.publicKeyHash + ) + ).state + ).to.equal(7, "Validator state not 7 (REMOVED)"); + + await expect( + compoundingStakingSSVStrategy + .connect(validatorRegistrator) + .registerSsvValidator( + testValidator.publicKey, + testValidator.operatorIds, + testValidator.sharesData, + emptyCluster, + { value: ethUnits("2") } + ) + ).to.be.revertedWithCustomError("NotRegisteredOrVerified()"); }); it("Should revert when staking because of insufficient ETH balance", async () => {