Skip to content

Commit

Permalink
Merge pull request #85 from NethermindEth/anshu/registry-validator-re…
Browse files Browse the repository at this point in the history
…striction

Only allow the preconfer to add validator for itself
  • Loading branch information
AnshuJalan authored Aug 24, 2024
2 parents a8fbe0d + 37eafd0 commit 92ceda2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
9 changes: 4 additions & 5 deletions SmartContracts/src/avs/PreconfRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,11 @@ contract PreconfRegistry is IPreconfRegistry, ISignatureUtils, BLSSignatureCheck
function addValidators(AddValidatorParam[] calldata addValidatorParams) external {
for (uint256 i; i < addValidatorParams.length; ++i) {
// Revert if preconfer is not registered
if (preconferToIndex[addValidatorParams[i].preconfer] == 0) {
if (preconferToIndex[msg.sender] == 0) {
revert PreconferNotRegistered();
}

bytes memory message =
_createMessage(ValidatorOp.ADD, addValidatorParams[i].signatureExpiry, addValidatorParams[i].preconfer);
bytes memory message = _createMessage(ValidatorOp.ADD, addValidatorParams[i].signatureExpiry, msg.sender);

// Revert if any signature is invalid
if (!verifySignature(message, addValidatorParams[i].signature, addValidatorParams[i].pubkey)) {
Expand All @@ -129,7 +128,7 @@ contract PreconfRegistry is IPreconfRegistry, ISignatureUtils, BLSSignatureCheck
) {
unchecked {
validators[pubKeyHash] = Validator({
preconfer: addValidatorParams[i].preconfer,
preconfer: msg.sender,
// The delay is crucial in order to not contradict the lookahead
startProposingAt: uint40(block.timestamp + PreconfConstants.TWO_EPOCHS),
stopProposingAt: uint40(0)
Expand All @@ -140,7 +139,7 @@ contract PreconfRegistry is IPreconfRegistry, ISignatureUtils, BLSSignatureCheck
revert ValidatorAlreadyActive();
}

emit ValidatorAdded(pubKeyHash, addValidatorParams[i].preconfer);
emit ValidatorAdded(pubKeyHash, msg.sender);
}
}

Expand Down
2 changes: 0 additions & 2 deletions SmartContracts/src/interfaces/IPreconfRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ interface IPreconfRegistry {
BLS12381.G2Point signature;
// The timestamp at which the above signature expires
uint256 signatureExpiry;
// The preconfer that the validator will be proposing for
address preconfer;
}

struct RemoveValidatorParam {
Expand Down

0 comments on commit 92ceda2

Please sign in to comment.