Skip to content

Commit

Permalink
refactor: custom err when non-valid podOwner registers with avs (#414)
Browse files Browse the repository at this point in the history
* improve ux

* abi+binding
  • Loading branch information
shaspitz authored Sep 27, 2024
1 parent 4200e9b commit 00df501
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 1 deletion.
11 changes: 11 additions & 0 deletions contracts-abi/abi/MevCommitAVS.abi
Original file line number Diff line number Diff line change
Expand Up @@ -1563,6 +1563,17 @@
"name": "NoEigenStrategyDeposits",
"inputs": []
},
{
"type": "error",
"name": "NoPodExists",
"inputs": [
{
"name": "podOwner",
"type": "address",
"internalType": "address"
}
]
},
{
"type": "error",
"name": "NotInitializing",
Expand Down
2 changes: 1 addition & 1 deletion contracts-abi/clients/MevCommitAVS/MevCommitAVS.go

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions contracts/contracts/interfaces/IMevCommitAVS.sol
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ interface IMevCommitAVS {
error UnfreezeTransferFailed();
error RefundFailed();
error OperatorDeregAlreadyRequested();
error NoPodExists(address podOwner);
error ValidatorNotActiveWithEigenCore(bytes valPubKey);
error ValidatorDeregAlreadyRequested();
error FrozenValidatorCannotDeregister();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,7 @@ contract MevCommitAVS is IMevCommitAVS, MevCommitAVSStorage,
address operator = _delegationManager.delegatedTo(podOwner);
require(operatorRegistrations[operator].exists, IMevCommitAVS.OperatorNotRegistered(operator));
require(!operatorRegistrations[operator].deregRequestOccurrence.exists, IMevCommitAVS.OperatorDeregAlreadyRequested());
require(_eigenPodManager.hasPod(podOwner), IMevCommitAVS.NoPodExists(podOwner));
IEigenPod pod = _eigenPodManager.getPod(podOwner);
uint256 len = valPubKeys.length;
for (uint256 i = 0; i < len; ++i) {
Expand Down
13 changes: 13 additions & 0 deletions contracts/test/validator-registry/avs/MevCommitAVSTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,19 @@ contract MevCommitAVSTest is Test {
assertFalse(regInfo0.deregRequestOccurrence.exists);
assertFalse(regInfo1.deregRequestOccurrence.exists);

address[] memory invalidPodOwners = new address[](1);
invalidPodOwners[0] = address(0x1423432432423432);
vm.prank(invalidPodOwners[0]);
delegationManagerMock.delegateTo(operator, sig, bytes32("salt"));
vm.expectRevert(abi.encodeWithSelector(IMevCommitAVS.NoPodExists.selector, invalidPodOwners[0]));
vm.prank(invalidPodOwners[0]);
mevCommitAVS.registerValidatorsByPodOwners(arrayValPubkeys, invalidPodOwners);

eigenPodManagerMock.setMockPod(invalidPodOwners[0], new EigenPodMock());
vm.expectRevert(abi.encodeWithSelector(IMevCommitAVS.ValidatorNotActiveWithEigenCore.selector, sampleValPubkey1));
vm.prank(invalidPodOwners[0]);
mevCommitAVS.registerValidatorsByPodOwners(arrayValPubkeys, invalidPodOwners);

vm.expectEmit(true, true, true, true);
emit ValidatorRegistered(sampleValPubkey1, podOwner);
vm.expectEmit(true, true, true, true);
Expand Down

0 comments on commit 00df501

Please sign in to comment.