Skip to content

Commit

Permalink
chore: update eigenlayer ref + mocks
Browse files Browse the repository at this point in the history
  • Loading branch information
shaspitz committed Nov 7, 2024
1 parent 4223760 commit c7b4e87
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 57 deletions.
2 changes: 1 addition & 1 deletion contracts/lib/eigenlayer-contracts
5 changes: 3 additions & 2 deletions contracts/test/validator-registry/avs/AVSDirectoryMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
// Eigenlayer core does not define their own mock for AVSDirectory.sol, hence we define our own.
contract AVSDirectoryMock is IAVSDirectory, Test {
mapping(address => bool) public isOperatorRegistered;
address public avs_;

bytes32 public constant OPERATOR_AVS_REGISTRATION_TYPEHASH =
keccak256("OperatorAVSRegistration(address operator,address avs,bytes32 salt,uint256 expiry)");
Expand Down Expand Up @@ -85,7 +84,9 @@ contract AVSDirectoryMock is IAVSDirectory, Test {
return digestHash;
}

function domainSeparator() public view returns (bytes32) {
function cancelSalt(bytes32 salt) external override { }

function domainSeparator() public view override returns (bytes32) {
return keccak256(abi.encode(DOMAIN_TYPEHASH, keccak256(bytes("EigenLayer")), block.chainid, address(this)));
}
}
7 changes: 0 additions & 7 deletions contracts/test/validator-registry/avs/EigenPodManagerMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {IEigenPodManager} from "eigenlayer-contracts/src/contracts/interfaces/IE
import {IEigenPod} from "eigenlayer-contracts/src/contracts/interfaces/IEigenPod.sol";
import {IStrategy} from "eigenlayer-contracts/src/contracts/interfaces/IStrategy.sol";
import "@openzeppelin/contracts/proxy/beacon/IBeacon.sol";
import {IBeaconChainOracle} from "eigenlayer-contracts/src/contracts/interfaces/IBeaconChainOracle.sol";
import {IETHPOSDeposit} from "eigenlayer-contracts/src/contracts/interfaces/IETHPOSDeposit.sol";
import {ISlasher} from "eigenlayer-contracts/src/contracts/interfaces/ISlasher.sol";
import {IStrategyManager} from "eigenlayer-contracts/src/contracts/interfaces/IStrategyManager.sol";
Expand Down Expand Up @@ -42,16 +41,10 @@ contract EigenPodManagerMock is IEigenPodManager, Test {

function recordBeaconChainETHBalanceUpdate(address /*podOwner*/, int256 /*sharesDelta*/) external pure {}

function updateBeaconChainOracle(IBeaconChainOracle /*newBeaconChainOracle*/) external pure {}

function ownerToPod(address /*podOwner*/) external pure returns(IEigenPod) {
return IEigenPod(address(0));
}

function beaconChainOracle() external pure returns(IBeaconChainOracle) {
return IBeaconChainOracle(address(0));
}

function getBlockRootAtTimestamp(uint64 /*timestamp*/) external pure returns(bytes32) {
return bytes32(0);
}
Expand Down
86 changes: 42 additions & 44 deletions contracts/test/validator-registry/avs/EigenPodMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
pragma solidity 0.8.26;

import "forge-std/Test.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "eigenlayer-contracts/src/contracts/interfaces/IEigenPod.sol";
import {IEigenPodManager} from "eigenlayer-contracts/src/contracts/interfaces/IEigenPodManager.sol";
import "eigenlayer-contracts/src/contracts/interfaces/IEigenPodManager.sol";
import "eigenlayer-contracts/src/contracts/libraries/BeaconChainProofs.sol";

// Similar to eigenlayer core's EigenPodMock but their mocks don't use virtual functions.
contract EigenPodMock is IEigenPod, Test {
Expand All @@ -13,69 +15,65 @@ contract EigenPodMock is IEigenPod, Test {
validatorInfo[validatorPubkey] = info;
}

function validatorPubkeyToInfo(bytes memory validatorPubkey)
external view virtual override returns(ValidatorInfo memory) {
function validatorPubkeyToInfo(bytes calldata validatorPubkey)
external view override returns(ValidatorInfo memory) {
return validatorInfo[validatorPubkey];
}

function MAX_RESTAKED_BALANCE_GWEI_PER_VALIDATOR() external view returns(uint64) {}
function validatorPubkeyHashToInfo(bytes32 validatorPubkeyHash) external view override returns (ValidatorInfo memory) {}

function nonBeaconChainETHBalanceWei() external view returns(uint256) {}
function initialize(address owner) external override {}

function withdrawableRestakedExecutionLayerGwei() external view returns(uint64) {}
function stake(bytes calldata pubkey, bytes calldata signature, bytes32 depositDataRoot) external payable override {}

function initialize(address owner) external {}
function withdrawRestakedBeaconChainETH(address recipient, uint256 amount) external override {}

function stake(bytes calldata pubkey, bytes calldata signature, bytes32 depositDataRoot) external payable {}
function startCheckpoint(bool revertIfNoBalance) external override {}

function withdrawRestakedBeaconChainETH(address recipient, uint256 amount) external {}
function verifyCheckpointProofs(
BeaconChainProofs.BalanceContainerProof calldata balanceContainerProof,
BeaconChainProofs.BalanceProof[] calldata proofs
) external override {}

function eigenPodManager() external view returns (IEigenPodManager) {}
function verifyWithdrawalCredentials(
uint64 beaconTimestamp,
BeaconChainProofs.StateRootProof calldata stateRootProof,
uint40[] calldata validatorIndices,
bytes[] calldata validatorFieldsProofs,
bytes32[][] calldata validatorFields
) external override {}

function podOwner() external view returns (address) {}
function verifyStaleBalance(
uint64 beaconTimestamp,
BeaconChainProofs.StateRootProof calldata stateRootProof,
BeaconChainProofs.ValidatorProof calldata proof
) external override {}

function hasRestaked() external view returns (bool) {}
function recoverTokens(IERC20[] memory tokenList, uint256[] memory amountsToWithdraw, address recipient) external override {}

function mostRecentWithdrawalTimestamp() external view returns (uint64) {}
function setProofSubmitter(address newProofSubmitter) external override {}

function validatorPubkeyHashToInfo(bytes32 validatorPubkeyHash) external view returns (ValidatorInfo memory) {}
function proofSubmitter() external view override returns (address) {}

function provenWithdrawal(bytes32 validatorPubkeyHash, uint64 slot) external view returns (bool) {}
function withdrawableRestakedExecutionLayerGwei() external view override returns (uint64) {}

function validatorStatus(bytes32 pubkeyHash) external view returns(VALIDATOR_STATUS) {}
function eigenPodManager() external view override returns (IEigenPodManager) {}

function verifyWithdrawalCredentials(
uint64 oracleTimestamp,
BeaconChainProofs.StateRootProof calldata stateRootProof,
uint40[] calldata validatorIndices,
bytes[] calldata withdrawalCredentialProofs,
bytes32[][] calldata validatorFields
) external {}

function verifyBalanceUpdates(
uint64 oracleTimestamp,
uint40[] calldata validatorIndices,
BeaconChainProofs.StateRootProof calldata stateRootProof,
bytes[] calldata validatorFieldsProofs,
bytes32[][] calldata validatorFields
) external {}
function podOwner() external view override returns (address) {}

function verifyAndProcessWithdrawals(
uint64 oracleTimestamp,
BeaconChainProofs.StateRootProof calldata stateRootProof,
BeaconChainProofs.WithdrawalProof[] calldata withdrawalProofs,
bytes[] calldata validatorFieldsProofs,
bytes32[][] calldata validatorFields,
bytes32[][] calldata withdrawalFields
) external {}
function validatorStatus(bytes32 pubkeyHash) external view override returns(VALIDATOR_STATUS) {}

function validatorStatus(bytes calldata validatorPubkey) external view override returns (VALIDATOR_STATUS){}

function activeValidatorCount() external view override returns (uint256) {}

function activateRestaking() external {}
function lastCheckpointTimestamp() external view override returns (uint64) {}

function withdrawBeforeRestaking() external {}
function currentCheckpointTimestamp() external view override returns (uint64) {}

function withdrawNonBeaconChainETHBalanceWei(address recipient, uint256 amountToWithdraw) external {}
function currentCheckpoint() external view override returns (Checkpoint memory) {}

function recoverTokens(IERC20[] memory tokenList, uint256[] memory amountsToWithdraw, address recipient) external {}
function checkpointBalanceExitedGwei(uint64) external view override returns (uint64) {}

function validatorStatus(bytes calldata pubkey) external view returns (VALIDATOR_STATUS){}
function getParentBlockRoot(uint64 timestamp) external view override returns (bytes32) {}
}
6 changes: 3 additions & 3 deletions contracts/test/validator-registry/avs/MevCommitAVSTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ contract MevCommitAVSTest is Test {
mockPod.setMockValidatorInfo(valPubkeys[0], IEigenPod.ValidatorInfo({
validatorIndex: 1,
restakedBalanceGwei: 1,
mostRecentBalanceUpdateTimestamp: 1,
lastCheckpointedAt: 1,
status: IEigenPod.VALIDATOR_STATUS.INACTIVE
}));
eigenPodManagerMock.setMockPod(podOwner, mockPod);
Expand All @@ -294,14 +294,14 @@ contract MevCommitAVSTest is Test {
mockPod.setMockValidatorInfo(valPubkeys[0], IEigenPod.ValidatorInfo({
validatorIndex: 1,
restakedBalanceGwei: 1,
mostRecentBalanceUpdateTimestamp: 1,
lastCheckpointedAt: 1,
status: IEigenPod.VALIDATOR_STATUS.ACTIVE
}));

mockPod.setMockValidatorInfo(valPubkeys[1], IEigenPod.ValidatorInfo({
validatorIndex: 2,
restakedBalanceGwei: 1,
mostRecentBalanceUpdateTimestamp: 1,
lastCheckpointedAt: 1,
status: IEigenPod.VALIDATOR_STATUS.ACTIVE
}));

Expand Down

0 comments on commit c7b4e87

Please sign in to comment.