Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
47 changes: 46 additions & 1 deletion contracts/test/strategies/compoundingSSVStaking.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down
Loading