From c7e701750aa1d7abd012a78514da3bb6ddf725a6 Mon Sep 17 00:00:00 2001 From: Shawn <44221603+shaspitz@users.noreply.github.com> Date: Wed, 3 Jul 2024 23:57:29 -0700 Subject: [PATCH] chore: deploy local avs w/ anvil --- contracts/Makefile | 4 ++ .../avs/DeployAVSWithMockEigen.s.sol | 67 +++++++++++++++++++ .../avs/AVSDirectoryMock.sol | 6 +- 3 files changed, 75 insertions(+), 2 deletions(-) create mode 100644 contracts/scripts/validator-registry/avs/DeployAVSWithMockEigen.s.sol diff --git a/contracts/Makefile b/contracts/Makefile index e786bd067..bf9cbf42d 100644 --- a/contracts/Makefile +++ b/contracts/Makefile @@ -13,6 +13,10 @@ deploy-core: forge clean DEPLOY_TYPE="core" RPC_URL="http://localhost:8545" PRIVATE_KEY="0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80" CHAIN_ID="17864" ./entrypoint.sh +deploy-avs-with-mock-eigen: + forge clean + forge script scripts/validator-registry/avs/DeployAVSWithMockEigen.s.sol:DeployAVSWithMockEigen --rpc-url http://localhost:8545 --private-key 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 --via-ir --broadcast + run-stake-example: forge script scripts/validator-registry/ValidatorExampleScript.s.sol:StakeExample --rpc-url http://localhost:8545 --private-key 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 --via-ir --broadcast diff --git a/contracts/scripts/validator-registry/avs/DeployAVSWithMockEigen.s.sol b/contracts/scripts/validator-registry/avs/DeployAVSWithMockEigen.s.sol new file mode 100644 index 000000000..02ddc5627 --- /dev/null +++ b/contracts/scripts/validator-registry/avs/DeployAVSWithMockEigen.s.sol @@ -0,0 +1,67 @@ +// SPDX-License-Identifier: BSL 1.1 +pragma solidity ^0.8.20; + +import "forge-std/Script.sol"; +import {Upgrades} from "openzeppelin-foundry-upgrades/Upgrades.sol"; +import {MevCommitAVS} from "../../../contracts/validator-registry/avs/MevCommitAVS.sol"; +import {StrategyManagerMock} from "eigenlayer-contracts/src/test/mocks/StrategyManagerMock.sol"; +import {DelegationManagerMock} from "eigenlayer-contracts/src/test/mocks/DelegationManagerMock.sol"; +import {EigenPodManagerMock} from "../../../test/validator-registry/avs/EigenPodManagerMock.sol"; +import {AVSDirectoryMock} from "../../../test/validator-registry/avs/AVSDirectoryMock.sol"; + +contract DeployAVSWithMockEigen is Script { + function run() external { + require(block.chainid == 31337, "must deploy on anvil"); + vm.startBroadcast(); + + StrategyManagerMock strategyManagerMock = new StrategyManagerMock(); + DelegationManagerMock delegationManagerMock = new DelegationManagerMock(); + EigenPodManagerMock eigenPodManagerMock = new EigenPodManagerMock(); + AVSDirectoryMock avsDirectoryMock = new AVSDirectoryMock(); + + address[] memory restakeableStrategies = new address[](3); + restakeableStrategies[0] = address(0x1); + restakeableStrategies[1] = address(0x2); + restakeableStrategies[2] = address(0x3); + + address freezeOracle = address(0x5); + uint256 unfreezeFee = 1 ether; + address unfreezeReceiver = address(0x6); + uint256 unfreezePeriodBlocks = 100; + uint256 operatorDeregPeriodBlocks = 200; + uint256 validatorDeregPeriodBlocks = 300; + uint256 lstRestakerDeregPeriodBlocks = 400; + string memory metadataUrl = "https://raw.githubusercontent.com/primev/mev-commit/main/static/avs-metadata.json"; + + address proxy = Upgrades.deployUUPSProxy( + "MevCommitAVS.sol", + abi.encodeCall(MevCommitAVS.initialize, ( + msg.sender, + delegationManagerMock, + eigenPodManagerMock, + strategyManagerMock, + avsDirectoryMock, + restakeableStrategies, + freezeOracle, + unfreezeFee, + unfreezeReceiver, + unfreezePeriodBlocks, + operatorDeregPeriodBlocks, + validatorDeregPeriodBlocks, + lstRestakerDeregPeriodBlocks, + metadataUrl + )) + ); + MevCommitAVS mevCommitAVS = MevCommitAVS(payable(proxy)); + + console.log("StrategyManagerMock deployed at:", address(strategyManagerMock)); + console.log("DelegationManagerMock deployed at:", address(delegationManagerMock)); + console.log("EigenPodManagerMock deployed at:", address(eigenPodManagerMock)); + console.log("AVSDirectoryMock deployed at:", address(avsDirectoryMock)); + console.log("MevCommitAVS deployed at:", address(mevCommitAVS)); + + delegationManagerMock.setIsOperator(msg.sender, true); + + vm.stopBroadcast(); + } +} diff --git a/contracts/test/validator-registry/avs/AVSDirectoryMock.sol b/contracts/test/validator-registry/avs/AVSDirectoryMock.sol index 950fefb7f..6b02e818d 100644 --- a/contracts/test/validator-registry/avs/AVSDirectoryMock.sol +++ b/contracts/test/validator-registry/avs/AVSDirectoryMock.sol @@ -25,8 +25,10 @@ contract AVSDirectoryMock is IAVSDirectory, Test { address operator, ISignatureUtils.SignatureWithSaltAndExpiry memory operatorSignature ) external override { - require(operator != address(0), "Operator cannot be zero"); - require(operatorSignature.salt != bytes32(0), "Salt cannot be zero"); + require(operator != address(0), "Operator required"); + require(keccak256(operatorSignature.signature) != keccak256(bytes("")), "Signature required"); + require(operatorSignature.salt != bytes32(0), "Salt required"); + require(operatorSignature.expiry != 0, "Expiry required"); isOperatorRegistered[operator] = true; emit OperatorAVSRegistrationStatusUpdated(operator, msg.sender, OperatorAVSRegistrationStatus.REGISTERED); }