Skip to content

Commit

Permalink
Merge pull request #9 from Hydrogen-Labs/anzen-working-branch
Browse files Browse the repository at this point in the history
Moar features
  • Loading branch information
diyahir authored Aug 22, 2024
2 parents bd4ace7 + acb0e07 commit 72afe73
Show file tree
Hide file tree
Showing 40 changed files with 286 additions and 72 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,6 @@ id_rsa
*/holesky/*.yaml
!*/holesky/*sample*.yaml
tests/keys/holesky*.json

*.env
!sample*.env
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ deploy-all-to-anvil-and-save-state: deploy-eigenlayer-contracts-to-anvil-and-sav
start-anvil-chain-with-el-and-avs-deployed: ## starts anvil from a saved state file (with el and avs contracts deployed)
./tests/anvil/start-anvil-chain-with-el-and-avs-deployed.sh

onboard-avs-to-anvil-anzen:
./tests/anvil/onboard-avs-to-anzen.sh

bindings: ## generates contract bindings
cd contracts && ./generate-go-bindings.sh

Expand Down Expand Up @@ -80,7 +83,7 @@ start-aggregator: ##

start-aggregator-holesky:
go run aggregator/cmd/main.go --config config-files/holesky/aggregator.yaml \
--anzen-deployment ${HOLESKY_FILES_DIR}/holesky_anzen_avs_deployment_output.json \
--anzen-deployment ${HOLESKY_FILES_DIR}/anzen_avs_deployment_output.json \
--ecdsa-private-key ${AGGREGATOR_ECDSA_PRIV_KEY} \
2>&1 | zap-pretty

Expand Down
20 changes: 20 additions & 0 deletions aggregator.docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
version: "3"

services:
aggregator:
image: ghcr.io/hydrogen-labs/anzen-avs/aggregator/cmd/main.go:latest
container_name: anzen-aggregator
volumes:
- ./:/anzen/
working_dir: /anzen
ports:
- "8090:8090"
command:
- --config
- config-files/holesky/aggregator.yaml
- --anzen-deployment
- contracts/script/output/17000/anzen_avs_deployment_output.json
- --ecdsa-private-key
- ${ECDSA_PRIVATE_KEY}
env_file:
- .env
4 changes: 1 addition & 3 deletions aggregator/aggregator.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ func (agg *Aggregator) oracleTaskCreatorChronJob() error {
continue
}
} else {
agg.logger.Info("Safety factor is not stale. Skipping.")
agg.logger.Debug("Safety factor is not stale. Skipping.")
continue
}

Expand Down Expand Up @@ -251,8 +251,6 @@ func (agg *Aggregator) sendNewOraclePullTask(oracleIndex *big.Int) error {
agg.logger.Error("Aggregator failed to get safety factor info", "err", err)
return err
}

// TODO: Implement policy on when to update the safety factor
newPullTask, taskIndex, err := agg.avsWriter.SendNewOraclePullTask(context.Background(), oracleIndex, proposedSafetyFactorInfo.SF, types.QUORUM_THRESHOLD_NUMERATOR, types.QUORUM_NUMBERS)

if err != nil {
Expand Down
1 change: 1 addition & 0 deletions cli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ func main() {
Name: "deregister-operator-with-avs",
Aliases: []string{"d"},
Action: func(ctx *cli.Context) error {
// TODO: Implement this
log.Fatal("Command not implemented.")
return nil
},
Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions config-files/anvil/operator-2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,4 @@ register_operator_on_startup: true
# address of token to deposit tokens into when registering on startup
# addresses.erc20MockStrategy in tests/anvil/anzen_avs_deployment_output.json
token_strategy_addr: 0xc5a5C42992dECbae36851359345FE25997F5C42d
deposit_amount: 1000
1 change: 1 addition & 0 deletions config-files/anvil/operator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,4 @@ register_operator_on_startup: true
# address of token to deposit tokens into when registering on startup
# addresses.erc20MockStrategy in tests/anvil/anzen_avs_deployment_output.json
token_strategy_addr: 0xc5a5C42992dECbae36851359345FE25997F5C42d
deposit_amount: 1000
1 change: 1 addition & 0 deletions config-files/holesky/sample.operator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,4 @@ register_operator_on_startup: true
# address of token to deposit tokens into when registering on startup
# addresses.erc20MockStrategy in tests/anvil/anzen_avs_deployment_output.json
token_strategy_addr: 0x80528D6e9A2BAbFc766965E0E26d5aB08D9CFaF9
deposit_amount: 1000
4 changes: 3 additions & 1 deletion contracts/sample.env
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
RPC_URL=""
DEPLOYER_PRIVATE_KEY=""
DEPLOYER_ADDR=""
DEPLOYMENT_SALT=""
DEPLOYMENT_SALT=""
INIT_AGGREGATOR_ADDR=""
INIT_TASK_GENERATOR_ADDR=""
1 change: 0 additions & 1 deletion contracts/script/AddNewAvsToAnzen.s.sol

This file was deleted.

19 changes: 9 additions & 10 deletions contracts/script/AnzenDeployer.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ contract AnzenDeployer is Script, Utils {
AVSReservesManagerFactory public avsReservesManagerFactory;
AVSReservesManagerFactory public avsReservesManagerFactoryImplementation;

address public mockAVSRM;
address public mockAVSRMImplementation;
address public anzenAvsReservesManager;
address public anzenAvsReservesManagerImplementation;

function run() external {
// Eigenlayer contracts
Expand Down Expand Up @@ -309,19 +309,16 @@ contract AnzenDeployer is Script, Utils {

SafetyFactorConfig memory safetyFactorConfig = SafetyFactorConfig(200_000, 300_000, 200_000, 200_000, 1 days);

(mockAVSRM, mockAVSRMImplementation) = avsReservesManagerFactory.createAVSReservesManager(
(anzenAvsReservesManager, anzenAvsReservesManagerImplementation) = avsReservesManagerFactory
.createAVSReservesManager(
address(anzenProxyAdmin),
safetyFactorConfig,
anzenCommunityMultisig,
address(anzenServiceManager),
new address[](0),
new uint256[](0),
50
new uint256[](0)
);

// TODO: Add the avsReservesManager address
// safetyFactorOracle.addProtocol(0, address(anzenServiceManager));

// Third, upgrade the proxy contracts to use the correct implementation contracts and initialize them.
anzenProxyAdmin.upgradeAndCall(
TransparentUpgradeableProxy(payable(address(anzenTaskManager))),
Expand Down Expand Up @@ -364,8 +361,6 @@ contract AnzenDeployer is Script, Utils {
"avsReservesManagerFactoryImplementation",
address(avsReservesManagerFactoryImplementation)
);
vm.serializeAddress(deployed_addresses, "mockAVSRM", mockAVSRM);
vm.serializeAddress(deployed_addresses, "mockAVSRMImplementation", mockAVSRMImplementation);

string memory deployed_addresses_output =
vm.serializeAddress(deployed_addresses, "operatorStateRetriever", address(operatorStateRetriever));
Expand All @@ -374,5 +369,9 @@ contract AnzenDeployer is Script, Utils {
string memory finalJson = vm.serializeString(parent_object, deployed_addresses, deployed_addresses_output);

writeOutput(finalJson, "anzen_avs_deployment_output");

writeAvsOnboardingOutput(
address(anzenProxyAdmin), anzenAvsReservesManager, anzenAvsReservesManagerImplementation, 0
);
}
}
18 changes: 5 additions & 13 deletions contracts/script/HoleskyAnzenDeployer.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,9 @@ contract AnzenDeployer is Script, Utils {
uint256 public constant QUORUM_THRESHOLD_PERCENTAGE = 100;
uint32 public constant TASK_RESPONSE_WINDOW_BLOCK = 30;
uint32 public constant TASK_DURATION_BLOCKS = 0;
// TODO: right now hardcoding these (this address is anvil's default address 9)
address public constant AGGREGATOR_ADDR = 0xa0Ee7A142d267C1f36714E4a8F75612F20a79720;
address public constant TASK_GENERATOR_ADDR = 0xa0Ee7A142d267C1f36714E4a8F75612F20a79720;

address public AGGREGATOR_ADDR = vm.envAddress("INIT_AGGREGATOR_ADDR");
address public TASK_GENERATOR_ADDR = vm.envAddress("INIT_TASK_GENERATOR_ADDR");
bytes32 public salt = keccak256(abi.encodePacked(vm.envString("DEPLOYMENT_SALT")));

// ERC20 and Strategy: we need to deploy this erc20, create a strategy for it, and whitelist this strategy in the strategymanager
Expand Down Expand Up @@ -292,13 +291,9 @@ contract AnzenDeployer is Script, Utils {
anzenCommunityMultisig,
address(anzenServiceManager),
new address[](0),
new uint256[](0),
0
new uint256[](0)
);

// TODO: Add the avsReservesManager address
// safetyFactorOracle.addProtocol(0, address(anzenServiceManager));

// Third, upgrade the proxy contracts to use the correct implementation contracts and initialize them.
anzenProxyAdmin.upgradeAndCall(
TransparentUpgradeableProxy(payable(address(anzenTaskManager))),
Expand Down Expand Up @@ -341,18 +336,15 @@ contract AnzenDeployer is Script, Utils {
"avsReservesManagerFactoryImplementation",
address(avsReservesManagerFactoryImplementation)
);
vm.serializeAddress(deployed_addresses, "anzenReservesManager", anzenReservesManager);
vm.serializeAddress(
deployed_addresses, "anzenReservesManagerImplementation", anzenReservesManagerImplementation
);

string memory deployed_addresses_output =
vm.serializeAddress(deployed_addresses, "operatorStateRetriever", address(operatorStateRetriever));

// serialize all the data
string memory finalJson = vm.serializeString(parent_object, deployed_addresses, deployed_addresses_output);

writeOutput(finalJson, "holesky_anzen_avs_deployment_output");
writeOutput(finalJson, "anzen_avs_deployment_output");
writeAvsOnboardingOutput(address(anzenProxyAdmin), anzenReservesManager, anzenReservesManagerImplementation, 0);
}

function _churnSalt() internal {
Expand Down
78 changes: 78 additions & 0 deletions contracts/script/OnboardNewAvsToAnzen.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.9;

import "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol";

import {AnzenServiceManager, IServiceManager} from "../src/AnzenServiceManager.sol";
import {AVSReservesManagerFactory} from "../src/AVSReservesManagerFactory.sol";
import {SafetyFactorConfig} from "../src/SafetyFactorOracle.sol";
import "../../src/tests/mocks/ERC20Mock.sol";

import {Utils} from "./utils/Utils.sol";

import "forge-std/Test.sol";
import "forge-std/Script.sol";
import "forge-std/StdJson.sol";
import "forge-std/console.sol";

// # To deploy and verify our contract
// forge script script/OnboardNewAvsToAnzen.s.sol:OnboardNewAvsToAnzen --rpc-url $RPC_URL --private-key $PRIVATE_KEY --broadcast -vvvv
contract OnboardNewAvsToAnzen is Script, Utils {
// DEPLOYMENT CONSTANTS

bytes32 public salt = keccak256(abi.encodePacked(vm.envString("DEPLOYMENT_SALT")));
AVSReservesManagerFactory public avsReservesManagerFactory;

address public avsServiceManagerAddr;

ProxyAdmin public avsProxyAdmin;
address public newAvsReservesManager;
address public newAvsReservesManagerImplementation;
uint32 public avsId;

function run() external {
address anzenCommunityMultisig = msg.sender;

string memory anzenDeployedContracts = readOutput("anzen_avs_deployment_output");

avsReservesManagerFactory = AVSReservesManagerFactory(
stdJson.readAddress(anzenDeployedContracts, ".addresses.avsReservesManagerFactory")
);

avsId = avsReservesManagerFactory.lastAVSReservesManagerId();

vm.startBroadcast();
_onboardAVSToAnzen(anzenCommunityMultisig);
vm.stopBroadcast();
}

function _onboardAVSToAnzen(address anzenCommunityMultisig) internal {
// deploy proxy admin for ability to upgrade proxy contracts
avsProxyAdmin = new ProxyAdmin();

// hard-coded inputs
_churnSalt();

// TODO: make all of this inputs configurable with the environment
SafetyFactorConfig memory safetyFactorConfig = SafetyFactorConfig(200_000, 300_000, 200_000, 200_000, 1 days);

(newAvsReservesManager, newAvsReservesManagerImplementation) = avsReservesManagerFactory
.createAVSReservesManager(
address(avsProxyAdmin),
safetyFactorConfig,
anzenCommunityMultisig,
avsServiceManagerAddr,
new address[](0),
new uint256[](0)
);

// write the output
writeAvsOnboardingOutput(
address(avsProxyAdmin), newAvsReservesManager, newAvsReservesManagerImplementation, avsId
);
}

function _churnSalt() internal {
salt = keccak256(abi.encode(salt));
}
}
17 changes: 17 additions & 0 deletions contracts/script/output/17000/anzen_avs_deployment_output.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"addresses": {
"anzenProxyAdmin": "0x2f54a8eb31eE7dB69ab1274E639b6D10be06bE38",
"anzenServiceManager": "0x08F06c24c5D1A1dDb622648c1D4E7c154c9a6c99",
"anzenServiceManagerImplementation": "0x119F2D9Cfc02Fe209389797590191a186f77C2a2",
"anzenTaskManager": "0xCeCb4eD0260FDa2F7A6E7C82aD4446c9342A4dca",
"anzenTaskManagerImplementation": "0x473639B80374CF706a3e1F60047a873E546F6A2a",
"avsReservesManagerFactory": "0x0DCac0E6A5CeFe3EA3DE4154C73C71D9D2425835",
"avsReservesManagerFactoryImplementation": "0xcd4Bfca45dA1B2af66aB31a7f53D859322253DB9",
"erc20Strategy": "0x80528D6e9A2BAbFc766965E0E26d5aB08D9CFaF9",
"operatorStateRetriever": "0x2BC7cD9f76a157eeAc36913190d4bdA737039474",
"registryCoordinator": "0xFE5F9f731bfC44e232bFCDe65B224122fCCd40fe",
"registryCoordinatorImplementation": "0x4160558A8D206dAFD0a918FB1C4C58D258e976fc",
"safetyFactorOracle": "0xd99652eD79836802615D2C4bE76826fCeF988b8a",
"safetyFactorOracleImplementation": "0x15A5E4b17e42Be4Cbf4bF7A888515beF1a4Ed97e"
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"avs_addresses": {
"avsProxyAdmin": "0x2f54a8eb31eE7dB69ab1274E639b6D10be06bE38",
"avsReservesManager": "0x17bb61b6a2F3F75F9E4371a305AB1985A2eA6712",
"avsReservesManagerImplementation": "0xfF476333eDacBb5a2baf8c7CB15c6aB57c1fe675"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
"avsReservesManagerFactoryImplementation": "0x2bdCC0de6bE1f7D2ee689a0342D76F52E8EFABa3",
"erc20Mock": "0x09635F643e140090A9A8Dcd712eD6285858ceBef",
"erc20MockStrategy": "0xc5a5C42992dECbae36851359345FE25997F5C42d",
"mockAVSRM": "0x3c5bb6747794374fA8E812f2BAA33f63349cAB40",
"mockAVSRMImplementation": "0x47b36E824631e97E94d462F822181Ed08A459384",
"operatorStateRetriever": "0x4826533B4897376654Bb4d4AD88B7faFD0C98528",
"registryCoordinator": "0x1613beB3B2C4f22Ee086B2b38C1476A3cE7f78E8",
"registryCoordinatorImplementation": "0x809d550fca64d94Bd9F66E60752A544199cfAC3D",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"avs_addresses": {
"avsProxyAdmin": "0xE6E340D132b5f46d1e472DebcD681B2aBc16e57E",
"avsReservesManager": "0x3c5bb6747794374fA8E812f2BAA33f63349cAB40",
"avsReservesManagerImplementation": "0x47b36E824631e97E94d462F822181Ed08A459384"
}
}
28 changes: 28 additions & 0 deletions contracts/script/utils/Utils.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.12;

import "@openzeppelin/contracts/utils/Strings.sol";

import "@eigenlayer-middleware/src/interfaces/IRegistryCoordinator.sol";
import "@eigenlayer/contracts/strategies/StrategyBase.sol";
import "../../src/tests/mocks/ERC20Mock.sol";
Expand Down Expand Up @@ -62,4 +64,30 @@ contract Utils is Script {
string memory outputFilePath = string.concat(outputDir, chainDir, outputFileName, ".json");
vm.writeJson(outputJson, outputFilePath);
}

function writeAvsOnboardingOutput(
address avsProxyAdminAddr,
address avsReservesManagerAddr,
address avsReservesManagerImplementationAddr,
uint32 avsId
) internal {
string memory parent_object = "parent object avs onboarding";

string memory deployed_addresses = "avs_addresses";

vm.serializeAddress(deployed_addresses, "avsProxyAdmin", avsProxyAdminAddr);

vm.serializeAddress(deployed_addresses, "avsReservesManager", avsReservesManagerAddr);

string memory deployed_addresses_output = vm.serializeAddress(
deployed_addresses, "avsReservesManagerImplementation", avsReservesManagerImplementationAddr
);

// serialize all the data
string memory finalJson = vm.serializeString(parent_object, deployed_addresses, deployed_addresses_output);

string memory file_name = string.concat("onboarded_avs_outputs/", Strings.toString(avsId), "_deployment_output");

writeOutput(finalJson, file_name);
}
}
Loading

0 comments on commit 72afe73

Please sign in to comment.