Skip to content

Commit

Permalink
chore: deploy local avs w/ anvil
Browse files Browse the repository at this point in the history
  • Loading branch information
shaspitz committed Jul 10, 2024
1 parent 3946648 commit c7e7017
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 2 deletions.
4 changes: 4 additions & 0 deletions contracts/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
@@ -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();
}
}
6 changes: 4 additions & 2 deletions contracts/test/validator-registry/avs/AVSDirectoryMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit c7e7017

Please sign in to comment.