Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only allow the preconfer to add validator for itself #85

Merged
merged 1 commit into from
Aug 24, 2024
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
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