From a68874f57913b43284c7989778af80e224516022 Mon Sep 17 00:00:00 2001 From: supernovahs Date: Fri, 3 Jan 2025 17:53:31 +0530 Subject: [PATCH] working --- Cargo.lock | 38 +++--- Cargo.toml | 35 ++--- .../src/commands/avs/mod.rs | 122 +++++++----------- .../script/IncredibleSquaringDeployer.s.sol | 4 +- .../script/WriteToContractsRegistry.s.sol | 2 + contracts/script/deployments/core/31337.json | 2 +- .../incredible-squaring/31337.json | 2 +- contracts/script/utils/CoreDeploymentLib.sol | 3 + .../utils/WriteToContractsRegistryLib.sol | 2 + crates/aggregator/Cargo.toml | 1 + crates/aggregator/src/error.rs | 2 +- crates/aggregator/src/fake_aggregator.rs | 11 +- crates/aggregator/src/lib.rs | 40 ++++-- crates/config/src/lib.rs | 22 ++++ crates/operator/src/client.rs | 4 +- crates/task_generator/src/lib.rs | 11 +- 16 files changed, 161 insertions(+), 140 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 35b1dd0b..5080af2d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2377,7 +2377,7 @@ dependencies = [ [[package]] name = "eigen-cli" version = "0.1.1" -source = "git+https://github.com/Layr-Labs/eigensdk-rs?rev=9db6e24#9db6e2461b4dcbc10e09a0b7c1e3101708d8b491" +source = "git+https://github.com/Layr-Labs/eigensdk-rs?rev=bea517d#bea517d489381a48924a71b589fdc3fd5e852ff3" dependencies = [ "alloy", "alloy-json-rpc", @@ -2410,7 +2410,7 @@ dependencies = [ [[package]] name = "eigen-client-avsregistry" version = "0.1.1" -source = "git+https://github.com/Layr-Labs/eigensdk-rs?rev=9db6e24#9db6e2461b4dcbc10e09a0b7c1e3101708d8b491" +source = "git+https://github.com/Layr-Labs/eigensdk-rs?rev=bea517d#bea517d489381a48924a71b589fdc3fd5e852ff3" dependencies = [ "alloy", "alloy-primitives", @@ -2431,10 +2431,12 @@ dependencies = [ [[package]] name = "eigen-client-elcontracts" version = "0.1.1" -source = "git+https://github.com/Layr-Labs/eigensdk-rs?rev=9db6e24#9db6e2461b4dcbc10e09a0b7c1e3101708d8b491" +source = "git+https://github.com/Layr-Labs/eigensdk-rs?rev=bea517d#bea517d489381a48924a71b589fdc3fd5e852ff3" dependencies = [ "alloy", "alloy-primitives", + "alloy-sol-types", + "eigen-crypto-bls", "eigen-logging", "eigen-types", "eigen-utils", @@ -2445,7 +2447,7 @@ dependencies = [ [[package]] name = "eigen-client-eth" version = "0.1.1" -source = "git+https://github.com/Layr-Labs/eigensdk-rs?rev=9db6e24#9db6e2461b4dcbc10e09a0b7c1e3101708d8b491" +source = "git+https://github.com/Layr-Labs/eigensdk-rs?rev=bea517d#bea517d489381a48924a71b589fdc3fd5e852ff3" dependencies = [ "alloy", "alloy-json-rpc", @@ -2462,7 +2464,7 @@ dependencies = [ [[package]] name = "eigen-crypto-bls" version = "0.1.1" -source = "git+https://github.com/Layr-Labs/eigensdk-rs?rev=9db6e24#9db6e2461b4dcbc10e09a0b7c1e3101708d8b491" +source = "git+https://github.com/Layr-Labs/eigensdk-rs?rev=bea517d#bea517d489381a48924a71b589fdc3fd5e852ff3" dependencies = [ "alloy-primitives", "ark-bn254 0.5.0", @@ -2479,7 +2481,7 @@ dependencies = [ [[package]] name = "eigen-crypto-bn254" version = "0.1.1" -source = "git+https://github.com/Layr-Labs/eigensdk-rs?rev=9db6e24#9db6e2461b4dcbc10e09a0b7c1e3101708d8b491" +source = "git+https://github.com/Layr-Labs/eigensdk-rs?rev=bea517d#bea517d489381a48924a71b589fdc3fd5e852ff3" dependencies = [ "ark-bn254 0.5.0", "ark-ec 0.5.0", @@ -2490,7 +2492,7 @@ dependencies = [ [[package]] name = "eigen-logging" version = "0.1.1" -source = "git+https://github.com/Layr-Labs/eigensdk-rs?rev=9db6e24#9db6e2461b4dcbc10e09a0b7c1e3101708d8b491" +source = "git+https://github.com/Layr-Labs/eigensdk-rs?rev=bea517d#bea517d489381a48924a71b589fdc3fd5e852ff3" dependencies = [ "ctor", "once_cell", @@ -2501,7 +2503,7 @@ dependencies = [ [[package]] name = "eigen-metrics" version = "0.1.1" -source = "git+https://github.com/Layr-Labs/eigensdk-rs?rev=9db6e24#9db6e2461b4dcbc10e09a0b7c1e3101708d8b491" +source = "git+https://github.com/Layr-Labs/eigensdk-rs?rev=bea517d#bea517d489381a48924a71b589fdc3fd5e852ff3" dependencies = [ "eigen-logging", "metrics 0.24.1", @@ -2512,7 +2514,7 @@ dependencies = [ [[package]] name = "eigen-metrics-collectors-rpc-calls" version = "0.1.1" -source = "git+https://github.com/Layr-Labs/eigensdk-rs?rev=9db6e24#9db6e2461b4dcbc10e09a0b7c1e3101708d8b491" +source = "git+https://github.com/Layr-Labs/eigensdk-rs?rev=bea517d#bea517d489381a48924a71b589fdc3fd5e852ff3" dependencies = [ "eigen-logging", "metrics 0.24.1", @@ -2521,7 +2523,7 @@ dependencies = [ [[package]] name = "eigen-nodeapi" version = "0.1.1" -source = "git+https://github.com/Layr-Labs/eigensdk-rs?rev=9db6e24#9db6e2461b4dcbc10e09a0b7c1e3101708d8b491" +source = "git+https://github.com/Layr-Labs/eigensdk-rs?rev=bea517d#bea517d489381a48924a71b589fdc3fd5e852ff3" dependencies = [ "ntex", "serde", @@ -2533,7 +2535,7 @@ dependencies = [ [[package]] name = "eigen-services-avsregistry" version = "0.1.1" -source = "git+https://github.com/Layr-Labs/eigensdk-rs?rev=9db6e24#9db6e2461b4dcbc10e09a0b7c1e3101708d8b491" +source = "git+https://github.com/Layr-Labs/eigensdk-rs?rev=bea517d#bea517d489381a48924a71b589fdc3fd5e852ff3" dependencies = [ "alloy-primitives", "ark-bn254 0.5.0", @@ -2549,7 +2551,7 @@ dependencies = [ [[package]] name = "eigen-services-blsaggregation" version = "0.1.1" -source = "git+https://github.com/Layr-Labs/eigensdk-rs?rev=9db6e24#9db6e2461b4dcbc10e09a0b7c1e3101708d8b491" +source = "git+https://github.com/Layr-Labs/eigensdk-rs?rev=bea517d#bea517d489381a48924a71b589fdc3fd5e852ff3" dependencies = [ "alloy", "alloy-primitives", @@ -2558,6 +2560,7 @@ dependencies = [ "eigen-client-avsregistry", "eigen-crypto-bls", "eigen-crypto-bn254", + "eigen-logging", "eigen-services-avsregistry", "eigen-types", "parking_lot 0.12.3", @@ -2570,7 +2573,7 @@ dependencies = [ [[package]] name = "eigen-services-operatorsinfo" version = "0.1.1" -source = "git+https://github.com/Layr-Labs/eigensdk-rs?rev=9db6e24#9db6e2461b4dcbc10e09a0b7c1e3101708d8b491" +source = "git+https://github.com/Layr-Labs/eigensdk-rs?rev=bea517d#bea517d489381a48924a71b589fdc3fd5e852ff3" dependencies = [ "alloy", "alloy-primitives", @@ -2591,16 +2594,14 @@ dependencies = [ [[package]] name = "eigen-testing-utils" version = "0.1.1" -source = "git+https://github.com/Layr-Labs/eigensdk-rs?rev=9db6e24#9db6e2461b4dcbc10e09a0b7c1e3101708d8b491" +source = "git+https://github.com/Layr-Labs/eigensdk-rs?rev=bea517d#bea517d489381a48924a71b589fdc3fd5e852ff3" dependencies = [ "alloy", "alloy-primitives", "alloy-provider", "alloy-rpc-types", - "alloy-signer-local", "alloy-transport", "eigen-utils", - "eyre", "serde", "serde_json", "testcontainers", @@ -2610,7 +2611,7 @@ dependencies = [ [[package]] name = "eigen-types" version = "0.1.1" -source = "git+https://github.com/Layr-Labs/eigensdk-rs?rev=9db6e24#9db6e2461b4dcbc10e09a0b7c1e3101708d8b491" +source = "git+https://github.com/Layr-Labs/eigensdk-rs?rev=bea517d#bea517d489381a48924a71b589fdc3fd5e852ff3" dependencies = [ "alloy-primitives", "eigen-crypto-bls", @@ -2623,7 +2624,7 @@ dependencies = [ [[package]] name = "eigen-utils" version = "0.1.1" -source = "git+https://github.com/Layr-Labs/eigensdk-rs?rev=9db6e24#9db6e2461b4dcbc10e09a0b7c1e3101708d8b491" +source = "git+https://github.com/Layr-Labs/eigensdk-rs?rev=bea517d#bea517d489381a48924a71b589fdc3fd5e852ff3" dependencies = [ "alloy", "reqwest 0.12.9", @@ -3988,6 +3989,7 @@ version = "0.0.1-alpha" dependencies = [ "alloy", "ark-bn254 0.5.0", + "ark-ec 0.5.0", "ark-serialize 0.4.2", "ark-std 0.4.0", "eigen-client-avsregistry", diff --git a/Cargo.toml b/Cargo.toml index e7b67357..85b5abe5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -35,6 +35,7 @@ rustdoc.all = "warn" [workspace.dependencies] +ark-ec = "0.5.0" clap = "4.5.11" eyre = "0.6.12" tokio = { version = "1.21", default-features = false } @@ -72,21 +73,21 @@ incredible-operator-2 = {path = "crates/operator_2/" , features = ["default"]} incredible-slasher = {path = "crates/slasher/"} # eigensdk-rs -eigen-client-avsregistry = { git = "https://github.com/Layr-Labs/eigensdk-rs", rev = "9db6e24"} -eigen-testing-utils ={ git = "https://github.com/Layr-Labs/eigensdk-rs", rev = "9db6e24"} -eigen-crypto-bls = { git = "https://github.com/Layr-Labs/eigensdk-rs", rev = "9db6e24"} -eigen-types = { git = "https://github.com/Layr-Labs/eigensdk-rs", rev = "9db6e24"} -eigen-metrics = { git = "https://github.com/Layr-Labs/eigensdk-rs", rev = "9db6e24"} -eigen-utils = { git = "https://github.com/Layr-Labs/eigensdk-rs", rev = "9db6e24"} -eigen-contract-bindings = { git = "https://github.com/Layr-Labs/eigensdk-rs", rev = "9db6e24"} -eigen-cli ={ git = "https://github.com/Layr-Labs/eigensdk-rs", rev = "9db6e24"} -eigen-logging ={ git = "https://github.com/Layr-Labs/eigensdk-rs", rev = "9db6e24"} -eigen-crypto-bn254 = { git = "https://github.com/Layr-Labs/eigensdk-rs", rev = "9db6e24"} -eigen-client-elcontracts = { git = "https://github.com/Layr-Labs/eigensdk-rs", rev = "9db6e24"} -eigen-services-operatorsinfo = { git = "https://github.com/Layr-Labs/eigensdk-rs", rev = "9db6e24"} -eigen-services-avsregistry = { git = "https://github.com/Layr-Labs/eigensdk-rs", rev = "9db6e24"} -eigen-services-blsaggregation = { git = "https://github.com/Layr-Labs/eigensdk-rs", rev = "9db6e24"} -eigen-metrics-collectors-rpc-calls = { git = "https://github.com/Layr-Labs/eigensdk-rs", rev = "9db6e24"} -eigen-client-eth = { git = "https://github.com/Layr-Labs/eigensdk-rs", rev = "9db6e24"} -eigen-nodeapi = { git = "https://github.com/Layr-Labs/eigensdk-rs", rev = "9db6e24"} +eigen-client-avsregistry = { git = "https://github.com/Layr-Labs/eigensdk-rs", rev = "bea517d"} +eigen-testing-utils ={ git = "https://github.com/Layr-Labs/eigensdk-rs", rev = "bea517d"} +eigen-crypto-bls = { git = "https://github.com/Layr-Labs/eigensdk-rs", rev = "bea517d"} +eigen-types = { git = "https://github.com/Layr-Labs/eigensdk-rs", rev = "bea517d"} +eigen-metrics = { git = "https://github.com/Layr-Labs/eigensdk-rs", rev = "bea517d"} +eigen-utils = { git = "https://github.com/Layr-Labs/eigensdk-rs", rev = "bea517d"} +eigen-contract-bindings = { git = "https://github.com/Layr-Labs/eigensdk-rs", rev = "bea517d"} +eigen-cli ={ git = "https://github.com/Layr-Labs/eigensdk-rs", rev = "bea517d"} +eigen-logging ={ git = "https://github.com/Layr-Labs/eigensdk-rs", rev = "bea517d"} +eigen-crypto-bn254 = { git = "https://github.com/Layr-Labs/eigensdk-rs", rev = "bea517d"} +eigen-client-elcontracts = { git = "https://github.com/Layr-Labs/eigensdk-rs", rev = "bea517d"} +eigen-services-operatorsinfo = { git = "https://github.com/Layr-Labs/eigensdk-rs", rev = "bea517d"} +eigen-services-avsregistry = { git = "https://github.com/Layr-Labs/eigensdk-rs", rev = "bea517d"} +eigen-services-blsaggregation = { git = "https://github.com/Layr-Labs/eigensdk-rs", rev = "bea517d"} +eigen-metrics-collectors-rpc-calls = { git = "https://github.com/Layr-Labs/eigensdk-rs", rev = "bea517d"} +eigen-client-eth = { git = "https://github.com/Layr-Labs/eigensdk-rs", rev = "bea517d"} +eigen-nodeapi = { git = "https://github.com/Layr-Labs/eigensdk-rs", rev = "bea517d"} diff --git a/bin/incredible-squaring-avs/src/commands/avs/mod.rs b/bin/incredible-squaring-avs/src/commands/avs/mod.rs index 9f9fcdb2..32a98894 100644 --- a/bin/incredible-squaring-avs/src/commands/avs/mod.rs +++ b/bin/incredible-squaring-avs/src/commands/avs/mod.rs @@ -1,9 +1,9 @@ +use ::hex::FromHex; use alloy::dyn_abi::DynSolValue; use alloy::hex; use alloy::primitives::aliases::U96; -use alloy::primitives::{Address, Bytes, FixedBytes, U256}; +use alloy::primitives::{address, Address, Bytes, FixedBytes, U256}; use alloy::providers::Provider; -use alloy::rpc::types::serde_helpers::quantity::vec; use alloy::signers::local::{LocalSigner, PrivateKeySigner}; use clap::value_parser; use clap::{Args, Parser}; @@ -18,6 +18,7 @@ use eigen_logging::{get_logger, init_logger, log_level::LogLevel}; use eigen_metrics::prometheus::init_registry; use eigen_testing_utils::anvil_constants::{ get_allocation_manager_address, get_avs_directory_address, get_delegation_manager_address, + get_permission_controller_address, get_rewards_coordinator_address, get_strategy_manager_address, ANVIL_HTTP_URL, }; use eigen_types::operator::Operator; @@ -27,6 +28,7 @@ use eigen_utils::delegationmanager::DelegationManager; use eigen_utils::iregistrycoordinator::IRegistryCoordinator::OperatorSetParam; use eigen_utils::istakeregistry::IStakeRegistry::StrategyParams; use eigen_utils::registrycoordinator::RegistryCoordinator; +use eigen_utils::stakeregistry::StakeRegistry; use eigen_utils::{get_provider, get_signer}; use incredible_avs::builder::{AvsBuilder, DefaultAvsLauncher, LaunchAvs}; use incredible_bindings::incrediblesquaringservicemanager::{ @@ -212,7 +214,7 @@ pub struct AvsCommand { #[arg(long, value_name = "SOCKET", default_value = "incredible-socket")] socket: String, - #[arg(long, value_name = "QUORUM_NUMBER", default_value = "00")] + #[arg(long, value_name = "QUORUM_NUMBER", default_value = "01")] quorum_number: String, #[arg(long, value_name = "SIG_EXPIRY")] @@ -318,7 +320,8 @@ impl AvsCommand { get_delegation_manager_address(ANVIL_HTTP_URL.to_string()).await; let avs_directory_address_anvil = get_avs_directory_address(ANVIL_HTTP_URL.to_string()).await; - + let rewards_coordinator_address_anvil = + get_rewards_coordinator_address(ANVIL_HTTP_URL.to_string()).await; let strategy_manager_address_anvil = get_strategy_manager_address(ANVIL_HTTP_URL.to_string()).await; let erc20_mock_strategy_address_anvil = get_incredible_squaring_strategy_address().await; @@ -326,6 +329,8 @@ impl AvsCommand { get_incredible_squaring_task_manager().await; let allocation_manager_address_anvil = get_allocation_manager_address(ANVIL_HTTP_URL.to_string()).await; + let permission_controller_address_anvil = + get_permission_controller_address(ANVIL_HTTP_URL.to_string()).await; let service_manager_address_anvil = get_incredible_squaring_service_manager().await; let default_anvil = AnvilValues::new( registry_coordinator_address_anvil, @@ -402,6 +407,7 @@ impl AvsCommand { config.set_operator_registration_sig_salt(operator_to_avs_registration_sig_salt); config.set_socket(socket); + info!("operator1 quorum num {:?}", quorum_number); config.set_quorum_number(quorum_number); config.set_operator_id(operator_id); config.set_operator_address(operator_address); @@ -416,7 +422,7 @@ impl AvsCommand { .clone() .unwrap_or(delegation_manager_address_anvil.to_string()), ); - config.set_operator_2_quorum_number("00".to_string()); + config.set_operator_2_quorum_number("01".to_string()); config.set_avs_directory_address( avs_directory_addr.unwrap_or(avs_directory_address_anvil.to_string()), ); @@ -440,7 +446,8 @@ impl AvsCommand { config.set_task_manager_address( task_manager_addr.unwrap_or(incredible_squaring_task_manager_address_anvil.to_string()), ); - + config.set_rewards_coordinator_address(rewards_coordinator_address_anvil.to_string()); + config.set_permission_controller_address(permission_controller_address_anvil.to_string()); config.set_ecdsa_keystore_2_path(ecdsa_keystore_2_path.clone()); config.set_ecdsa_keystore_2_pasword(ecdsa_keystore_2_password.clone()); config @@ -479,10 +486,9 @@ impl AvsCommand { ) .await?; info!(tx_hash = %enable_operator_sets_tx_hash,"enable operator sets tx_hash"); - // let create_operator_hash = create_operator_sets(service_manager_address_anvil,vec![config.erc20_mock_strategy_addr()?],vec![0],config.operator_pvt_key(),config.ecdsa_keystore_path(),config.ecdsa_keystore_password(),&rpc_url).await?; - // info!(tx_hash = %create_operator_hash,"create operator tx_hash"); + let total_delegated_quorum_create_tx_hash = create_total_delegated_stake_quorum( - config.strategy_manager_addr()?, + config.erc20_mock_strategy_addr()?, config.registry_coordinator_addr()?, config.operator_pvt_key(), config.ecdsa_keystore_path(), @@ -493,29 +499,25 @@ impl AvsCommand { info!(tx_hash = %total_delegated_quorum_create_tx_hash,"total delegated stake quorum create tx_hash"); let allocation = AllocationManager::new(allocation_manager_address_anvil, get_provider(&rpc_url)); + let reg_ = allocation .getAVSRegistrar(service_manager_address_anvil) .call() .await? ._0; - info!("regcc{:?}", reg_); - // let operatorcount = allocation.isOperatorSet(OperatorSet{avs:service_manager_address_anvil,id:0}).call().await?._0; - // info!("operator_set_count{:?}",operatorcount); - // let regcoord = RegistryCoordinator::new(config.registry_coordinator_addr()?, get_provider(&rpc_url)); - // let is = regcoord.isOperatorSetAVS().call().await?._0; - // info!("isoperatorsetavs{:?}",is); - // let id = regcoord.quorumCount().call().await?._0 -1; - // info!("op_id{:?}",id); - // let ism2quorum = regcoord.isM2Quorum(id).call().await?._0; - // info!("is m2 quorum ?{:?}",ism2quorum); - // let create_operator_set_tx_hash = create_operator_sets(service_manager_address_anvil,vec![config.erc20_mock_strategy_addr()?],vec![0],config.operator_pvt_key(),config.ecdsa_keystore_path(),config.ecdsa_keystore_password(),&rpc_url).await?; - // info!("create operator set for operator id {:?} with tx_hash {:?}",vec![0],create_operator_set_tx_hash); + let regcoord = + RegistryCoordinator::new(config.registry_coordinator_addr()?, get_provider(&rpc_url)); + let id = regcoord.quorumCount().call().await?._0 - 1; + info!("op_id{:?}", id); if register_operator { let _ = register_operator_with_el_and_avs( config.operator_pvt_key(), rpc_url.clone(), ecdsa_keystore_path.clone(), ecdsa_keystore_password.clone(), + config.permission_controller_address()?, + config.rewards_coordinator_address()?, + allocation_manager_address_anvil, config.registry_coordinator_addr()?, config.operator_state_retriever_addr()?, config.delegation_manager_addr()?, @@ -528,7 +530,7 @@ impl AvsCommand { config.sig_expiry()?, config.quorum_number()?, config.socket().to_string(), - U256::from(5000), + "5000000000000000000000".parse().unwrap(), ) .await; @@ -537,6 +539,9 @@ impl AvsCommand { rpc_url.clone(), ecdsa_keystore_2_path.clone(), ecdsa_keystore_2_password.clone(), + config.permission_controller_address()?, + config.rewards_coordinator_address()?, + allocation_manager_address_anvil, config.registry_coordinator_addr()?, config.operator_state_retriever_addr()?, config.delegation_manager_addr()?, @@ -549,7 +554,7 @@ impl AvsCommand { config.operator_2_sig_expiry()?, config.operator_2_quorum_number()?, config.operator_2_socket().to_string(), - U256::from(7000), + "7000000000000000000000".parse().unwrap(), ) .await; @@ -647,6 +652,7 @@ impl AvsCommand { } mine_anvil_block(&rpc_url, current_block_number); } + let avs_launcher = DefaultAvsLauncher::new(); let avs_builder = AvsBuilder::new(config); let _ = avs_launcher.launch_avs(avs_builder).await; @@ -662,6 +668,9 @@ pub async fn register_operator_with_el_and_avs( rpc_url: String, ecdsa_keystore_path: String, ecdsa_keystore_password: String, + permission_controller_address: Address, + rewards_coordinator: Address, + allocation_manager: Address, registry_coordinator_address: Address, operator_state_retriever_address: Address, delegation_manager_address: Address, @@ -676,6 +685,7 @@ pub async fn register_operator_with_el_and_avs( socket: String, deposit_tokens: U256, ) -> eyre::Result<()> { + info!("strategy_manager{:?}", strategy_manager_address); let signer; if let Some(operator_key) = operator_pvt_key { signer = PrivateKeySigner::from_str(&operator_key)?; @@ -700,15 +710,19 @@ pub async fn register_operator_with_el_and_avs( let key_pair = BlsKeyPair::new(fr_key)?; let el_chain_reader = ELChainReader::new( get_logger(), - Address::ZERO, + allocation_manager, delegation_manager_address, avs_directory_address, + permission_controller_address, rpc_url.clone(), ); let el_chain_writer = ELChainWriter::new( delegation_manager_address, strategy_manager_address, - Address::ZERO, + rewards_coordinator, + permission_controller_address, + allocation_manager, + registry_coordinator_address, el_chain_reader.clone(), rpc_url.clone(), hex::encode(s).to_string(), @@ -728,18 +742,7 @@ pub async fn register_operator_with_el_and_avs( let _ = el_chain_writer .register_as_operator(operator_details) .await?; - deposit_into_strategy(erc20_strategy_address, deposit_tokens, el_chain_writer).await?; - // let tx_hash = avs_registry_writer - // .register_operator_in_operator_set_with_avs_registry_coordinator( - // key_pair, - // vec![0], - // socket, - // ) - // .await?; - // debug!( - // "tx hash for registering operator in operator sets {:?} with avs registry coordinator {:?}", - // vec![0],tx_hash - // ); + let ts = deposit_into_strategy(erc20_strategy_address, deposit_tokens, el_chain_writer).await?; Ok(()) } @@ -794,14 +797,14 @@ pub async fn create_total_delegated_stake_quorum( let operator_set_param = eigen_utils::registrycoordinator::IRegistryCoordinator::OperatorSetParam { maxOperatorCount: 3, - kickBIPsOfOperatorStake: 0, - kickBIPsOfTotalStake: 0, + kickBIPsOfOperatorStake: 100, + kickBIPsOfTotalStake: 1000, }; let minimum_stake: U96 = U96::from(0); let strategy_params = vec![ eigen_utils::registrycoordinator::IStakeRegistry::StrategyParams { strategy: strategy_address, - multiplier: U96::from(10), + multiplier: U96::from(1), }, ]; @@ -844,41 +847,6 @@ pub async fn enable_operator_sets( .transaction_hash) } -pub async fn create_operator_sets( - service_manager_address: Address, - strategies: Vec
, - operator_set_ids: Vec, - operator_pvt_key: Option, - ecdsa_keystore_path: String, - ecdsa_keystore_password: String, - rpc_url: &str, -) -> eyre::Result> { - let signer; - if let Some(operator_key) = operator_pvt_key { - signer = PrivateKeySigner::from_str(&operator_key)?; - } else { - signer = LocalSigner::decrypt_keystore(ecdsa_keystore_path, ecdsa_keystore_password)?; - } - let s = signer.to_field_bytes(); - let pvt_key = hex::encode(s).to_string(); - - let service_manager = IncredibleSquaringServiceManager::new( - service_manager_address, - get_signer(&pvt_key, rpc_url), - ); - let params = vec![CreateSetParams { - operatorSetId: operator_set_ids[0], - strategies, - }]; - Ok(service_manager - .createOperatorSets(params) - .send() - .await? - .get_receipt() - .await? - .transaction_hash) -} - pub async fn modify_allocation_for_operator( allocation_manager: Address, operator_pvt_key: Option, @@ -997,8 +965,8 @@ pub async fn deposit_into_strategy( amount: U256, el_writer: ELChainWriter, ) -> Result<(), ElContractsError> { - let _ = el_writer + let s = el_writer .deposit_erc20_into_strategy(strategy_address, amount) - .await; + .await?; Ok(()) } diff --git a/contracts/script/IncredibleSquaringDeployer.s.sol b/contracts/script/IncredibleSquaringDeployer.s.sol index fe5b4bdd..9d1e8159 100644 --- a/contracts/script/IncredibleSquaringDeployer.s.sol +++ b/contracts/script/IncredibleSquaringDeployer.s.sol @@ -102,8 +102,8 @@ contract IncredibleSquaringDeployer is Script { configData = CoreDeploymentLib.readDeploymentJson("script/deployments/core/", block.chainid); erc20Mock = new MockERC20(); - FundOperator.fund_operator(address(erc20Mock), isConfig.operator_addr, 10e18); - FundOperator.fund_operator(address(erc20Mock), isConfig.operator_2_addr, 10e18); + FundOperator.fund_operator(address(erc20Mock), isConfig.operator_addr, 5000e18); + FundOperator.fund_operator(address(erc20Mock), isConfig.operator_2_addr, 7000e18); console.log(isConfig.operator_2_addr); (bool s,) = isConfig.operator_2_addr.call{value: 0.1 ether}(""); require(s); diff --git a/contracts/script/WriteToContractsRegistry.s.sol b/contracts/script/WriteToContractsRegistry.s.sol index c8fd0a04..2bea9146 100644 --- a/contracts/script/WriteToContractsRegistry.s.sol +++ b/contracts/script/WriteToContractsRegistry.s.sol @@ -35,6 +35,8 @@ contract WriteToContractsRegistry { contractsRegistry.registerContract("delegationManager", address(deploymentdata.delegationManager)); contractsRegistry.registerContract("strategyManager", address(deploymentdata.strategyManager)); contractsRegistry.registerContract("avsDirectory", address(deploymentdata.avsDirectory)); + contractsRegistry.registerContract("rewardsCoordinator",address(deploymentdata.rewardsCoordinator)); + } function _writeIncredibleSquaringContractsToRegistry( diff --git a/contracts/script/deployments/core/31337.json b/contracts/script/deployments/core/31337.json index f413fb39..65a0a8da 100644 --- a/contracts/script/deployments/core/31337.json +++ b/contracts/script/deployments/core/31337.json @@ -1 +1 @@ -{"lastUpdate":{"timestamp":"1734528023","block_number":"1"},"addresses":{"proxyAdmin":"0xe7f1725e7734ce288f8367e1bb143e90bb3f0512","delegation":"0xcf7ed3acca5a467e9e704c703e8d87f634fb0fc9","delegationManagerImpl":"0x322813fd9a801c5507c9de605d63cea4f2ce6c44","avsDirectory":"0xb7f8bc63bbcad18155201308c8f3540b07f84f5e","avsDirectoryImpl":"0x4a679253410272dd5232b3ff7cf5dbb88f295319","strategyManager":"0xa513e6e4b8f2a923d98304ec87f64353c4d5c853","strategyManagerImpl":"0x7a2088a1bfc9d81c55368ae168c2c02570cb814f","eigenPodManager":"0xc6e7df5e7b4f2a278906862b61205850344d4e7d","eigenPodManagerImpl":"0x67d269191c92caf3cd7723f116c85e6e9bf55933","strategyFactory":"0x68b1d87f95878fe05b998f19b66f4baba5de1aed","rewardsCoordinator":"0x0dcd1bf9a1b36ce34237eeafef220932846bcd82","pauserRegistry":"0x959922be3caee4b8cd9a407cc3ac1c251c2007b1","strategyBeacon":"0xa82ff9afd8f496c3d6ac40e2a0f282e47488cfc9","allocationManager":"0x8a791620dd6260079bf849dc5567adc3f2fdc318"}} \ No newline at end of file +{"lastUpdate":{"timestamp":"1735906869","block_number":"1"},"addresses":{"proxyAdmin":"0xe7f1725e7734ce288f8367e1bb143e90bb3f0512","delegation":"0xcf7ed3acca5a467e9e704c703e8d87f634fb0fc9","delegationManagerImpl":"0x322813fd9a801c5507c9de605d63cea4f2ce6c44","avsDirectory":"0xb7f8bc63bbcad18155201308c8f3540b07f84f5e","avsDirectoryImpl":"0x4a679253410272dd5232b3ff7cf5dbb88f295319","strategyManager":"0xa513e6e4b8f2a923d98304ec87f64353c4d5c853","strategyManagerImpl":"0x7a2088a1bfc9d81c55368ae168c2c02570cb814f","eigenPodManager":"0xc6e7df5e7b4f2a278906862b61205850344d4e7d","eigenPodManagerImpl":"0x67d269191c92caf3cd7723f116c85e6e9bf55933","strategyFactory":"0x68b1d87f95878fe05b998f19b66f4baba5de1aed","rewardsCoordinator":"0x0dcd1bf9a1b36ce34237eeafef220932846bcd82","pauserRegistry":"0x959922be3caee4b8cd9a407cc3ac1c251c2007b1","strategyBeacon":"0xa82ff9afd8f496c3d6ac40e2a0f282e47488cfc9","allocationManager":"0x8a791620dd6260079bf849dc5567adc3f2fdc318","permissionController":"0x4ed7c70f96b99c776995fb64377f0d4ab3b0e1c1"}} \ No newline at end of file diff --git a/contracts/script/deployments/incredible-squaring/31337.json b/contracts/script/deployments/incredible-squaring/31337.json index b1210845..b6248f5f 100644 --- a/contracts/script/deployments/incredible-squaring/31337.json +++ b/contracts/script/deployments/incredible-squaring/31337.json @@ -1 +1 @@ -{"lastUpdate":{"timestamp":"1734528024","block_number":"44"},"addresses":{"proxyAdmin":"0x1291be112d480055dafd8a610b7d1e203891c274","IncredibleSquaringServiceManager":"0xb7278a61aa25c888815afc32ad3cc52ff24fe575","incredibleSquaringServiceManagerImpl":"0x36b58f5c1969b7b6591d752ea6f5486d069010ab","IncredibleSquaringTaskManager":"0x7969c5ed335650692bc04293b07f5bf2e7a673c0","registryCoordinator":"0xc351628eb244ec633d5f21fbd6621e1a683b1181","blsapkRegistry":"0xcbeaf3bde82155f56486fb5a1072cb8baaf547cc","indexRegistry":"0xb0d4afd8879ed9f52b28595d31b441d079b2ca07","stakeRegistry":"0x82e01223d51eb87e16a03e24687edf0f294da6f1","operatorStateRetriever":"0x5081a39b8a5f0e35a8d959395a630b68b74dd30f","strategy":"0x5e3d0fde6f793b3115a9e7f5ebc195bbeed35d6c","pauserRegistry":"0x0000000000000000000000000000000000000000","token":"0x0000000000000000000000000000000000000000"}} \ No newline at end of file +{"lastUpdate":{"timestamp":"1735906870","block_number":"44"},"addresses":{"proxyAdmin":"0x1291be112d480055dafd8a610b7d1e203891c274","IncredibleSquaringServiceManager":"0xb7278a61aa25c888815afc32ad3cc52ff24fe575","incredibleSquaringServiceManagerImpl":"0x36b58f5c1969b7b6591d752ea6f5486d069010ab","IncredibleSquaringTaskManager":"0x7969c5ed335650692bc04293b07f5bf2e7a673c0","registryCoordinator":"0xc351628eb244ec633d5f21fbd6621e1a683b1181","blsapkRegistry":"0xcbeaf3bde82155f56486fb5a1072cb8baaf547cc","indexRegistry":"0xb0d4afd8879ed9f52b28595d31b441d079b2ca07","stakeRegistry":"0x82e01223d51eb87e16a03e24687edf0f294da6f1","operatorStateRetriever":"0x5081a39b8a5f0e35a8d959395a630b68b74dd30f","strategy":"0x5e3d0fde6f793b3115a9e7f5ebc195bbeed35d6c","pauserRegistry":"0x0000000000000000000000000000000000000000","token":"0x0000000000000000000000000000000000000000"}} \ No newline at end of file diff --git a/contracts/script/utils/CoreDeploymentLib.sol b/contracts/script/utils/CoreDeploymentLib.sol index 4b3c9af9..701735a0 100644 --- a/contracts/script/utils/CoreDeploymentLib.sol +++ b/contracts/script/utils/CoreDeploymentLib.sol @@ -480,6 +480,7 @@ library CoreDeploymentLib { data.allocationManager = json.readAddress( ".addresses.allocationManager" ); + data.permissionController = json.readAddress(".addresses.permissionController"); return data; } @@ -567,6 +568,8 @@ library CoreDeploymentLib { data.strategyBeacon.toHexString(), '","allocationManager":"', data.allocationManager.toHexString(), + '","permissionController":"', + data.permissionController.toHexString(), '"}' ); } diff --git a/contracts/script/utils/WriteToContractsRegistryLib.sol b/contracts/script/utils/WriteToContractsRegistryLib.sol index 1e9284de..867af9e4 100644 --- a/contracts/script/utils/WriteToContractsRegistryLib.sol +++ b/contracts/script/utils/WriteToContractsRegistryLib.sol @@ -16,6 +16,8 @@ library WriteToContractsRegistryLib { contractsRegistry.registerContract("strategyManager", address(deploymentdata.strategyManager)); contractsRegistry.registerContract("avsDirectory", address(deploymentdata.avsDirectory)); contractsRegistry.registerContract("allocationManager",address(deploymentdata.allocationManager)); + require(deploymentdata.permissionController != address(0)); + contractsRegistry.registerContract("permissionController",address(deploymentdata.permissionController)); } function writeIncredibleSquaringContractsToRegistry( diff --git a/crates/aggregator/Cargo.toml b/crates/aggregator/Cargo.toml index a9356451..a3b7be7a 100644 --- a/crates/aggregator/Cargo.toml +++ b/crates/aggregator/Cargo.toml @@ -13,6 +13,7 @@ workspace = true [dependencies] incredible-bindings.workspace = true ark-bn254.workspace = true +ark-ec.workspace = true alloy.workspace = true eigen-types.workspace = true serde.workspace = true diff --git a/crates/aggregator/src/error.rs b/crates/aggregator/src/error.rs index e074357b..f3f13d98 100644 --- a/crates/aggregator/src/error.rs +++ b/crates/aggregator/src/error.rs @@ -1,7 +1,7 @@ use alloy::transports::{RpcError, TransportErrorKind}; use eigen_client_avsregistry::error::AvsRegistryError; use eigen_crypto_bls::error::BlsError; -use eigen_services_blsaggregation::bls_agg::BlsAggregationServiceError; +use eigen_services_blsaggregation::bls_aggregation_service_error::BlsAggregationServiceError; use eigen_services_operatorsinfo::operatorsinfo_inmemory::OperatorInfoServiceError; use incredible_chainio::error::ChainIoError; use incredible_config::error::ConfigError; diff --git a/crates/aggregator/src/fake_aggregator.rs b/crates/aggregator/src/fake_aggregator.rs index f470fd1a..60b53c32 100644 --- a/crates/aggregator/src/fake_aggregator.rs +++ b/crates/aggregator/src/fake_aggregator.rs @@ -5,11 +5,11 @@ use alloy::rpc::types::Filter; use alloy::sol_types::SolEvent; use eigen_client_avsregistry::reader::AvsRegistryChainReader; use eigen_crypto_bls::{convert_to_g1_point, convert_to_g2_point}; -use eigen_logging::get_test_logger; +use eigen_logging::{get_logger, get_test_logger}; use eigen_services_avsregistry::chaincaller::AvsRegistryServiceChainCaller; -use eigen_services_blsaggregation::bls_agg::{ - BlsAggregationServiceError, BlsAggregationServiceResponse, BlsAggregatorService, -}; +use eigen_services_blsaggregation::bls_agg::BlsAggregatorService; +use eigen_services_blsaggregation::bls_aggregation_service_error::BlsAggregationServiceError; +use eigen_services_blsaggregation::bls_aggregation_service_response::BlsAggregationServiceResponse; use eigen_services_operatorsinfo::operatorsinfo_inmemory::OperatorInfoServiceInMemory; use eigen_types::avs::TaskResponseDigest; use eigen_utils::get_ws_provider; @@ -95,7 +95,8 @@ impl FakeAggregator { .await; }); - let bls_aggregation_service = BlsAggregatorService::new(avs_registry_service_chaincaller); + let bls_aggregation_service = + BlsAggregatorService::new(avs_registry_service_chaincaller, get_logger()); Self { port_address: config.aggregator_ip_addr(), diff --git a/crates/aggregator/src/lib.rs b/crates/aggregator/src/lib.rs index a96d5403..03ac2be8 100644 --- a/crates/aggregator/src/lib.rs +++ b/crates/aggregator/src/lib.rs @@ -11,12 +11,14 @@ use alloy::providers::Provider; use alloy::providers::{ProviderBuilder, WsConnect}; use alloy::rpc::types::Filter; use alloy::sol_types::SolEvent; +use ark_ec::AffineRepr; use eigen_client_avsregistry::reader::AvsRegistryChainReader; use eigen_crypto_bls::{convert_to_g1_point, convert_to_g2_point}; use eigen_logging::get_logger; use eigen_services_avsregistry::chaincaller::AvsRegistryServiceChainCaller; -use eigen_services_blsaggregation::bls_agg::{ - BlsAggregationServiceError, BlsAggregationServiceResponse, BlsAggregatorService, +use eigen_services_blsaggregation::bls_aggregation_service_error::BlsAggregationServiceError; +use eigen_services_blsaggregation::{ + bls_agg::BlsAggregatorService, bls_aggregation_service_response::BlsAggregationServiceResponse, }; use eigen_services_operatorsinfo::operatorsinfo_inmemory::OperatorInfoServiceInMemory; use eigen_types::avs::TaskResponseDigest; @@ -107,7 +109,8 @@ impl Aggregator { .await; }); - let bls_aggregation_service = BlsAggregatorService::new(avs_registry_service_chaincaller); + let bls_aggregation_service = + BlsAggregatorService::new(avs_registry_service_chaincaller, get_logger()); Ok(Self { port_address: config.aggregator_ip_addr(), @@ -237,6 +240,7 @@ impl Aggregator { } for val in task.quorumNumbers.iter() { + info!("qqq{:?}", val); quorum_nums.push(*val); } @@ -256,6 +260,7 @@ impl Aggregator { ) .await .map_err(|e: BlsAggregationServiceError| eyre::eyre!(e)); + info!("initialized new task with index{:?}", taskIndex); } Ok(()) @@ -284,6 +289,7 @@ impl Aggregator { check_double_mapping(&self.tasks_responses, task_index, task_response_digest); if response.is_none() { + info!("none_response"); let mut inner_map = HashMap::new(); inner_map.insert( task_response_digest, @@ -291,7 +297,10 @@ impl Aggregator { ); self.tasks_responses.insert(task_index, inner_map); } - + info!("task_index{:?}", task_index); + info!("task_response_digest{:?}", task_response_digest); + info!("signed_task_response{:?}", signed_task_response.signature()); + info!("operator_id{:?}", signed_task_response.operator_id()); self.bls_aggregation_service .process_new_signature( task_index, @@ -299,7 +308,8 @@ impl Aggregator { signed_task_response.signature(), signed_task_response.operator_id(), ) - .await?; + .await + .expect("PROCESS_SIGNATURE_ERROR"); info!("processed signature for index {:?}", task_index); let quorum_reached = { let entry = self.task_quorum.entry(task_index).or_insert(0); @@ -317,9 +327,10 @@ impl Aggregator { .recv() .await { - info!("sending aggregated response to contract"); - self.send_aggregated_response_to_contract(aggregated_response?) - .await?; + let response = aggregated_response + .map_err(|e| AggregatorError::BlsAggregationServiceError(e))?; + info!("sending aggregated response to contract {:?}", response); + self.send_aggregated_response_to_contract(response).await?; } } else { info!( @@ -345,13 +356,20 @@ impl Aggregator { ) -> Result<(), AggregatorError> { let mut non_signer_pub_keys = Vec::::new(); for pub_key in response.non_signers_pub_keys_g1.iter() { - let g1 = convert_to_g1_point(pub_key.g1())?; - non_signer_pub_keys.push(G1Point { X: g1.X, Y: g1.Y }) + if pub_key.g1().x().is_some() { + let g1 = convert_to_g1_point(pub_key.g1()).expect("111"); + non_signer_pub_keys.push(G1Point { X: g1.X, Y: g1.Y }) + } else { + info!( + "There are no non_signers for the task index :{:?}", + response.task_index + ); + } } let mut quorum_apks = Vec::::new(); for pub_key in response.quorum_apks_g1.iter() { - let g1 = convert_to_g1_point(pub_key.g1())?; + let g1 = convert_to_g1_point(pub_key.g1()).expect("222"); quorum_apks.push(G1Point { X: g1.X, Y: g1.Y }) } diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index 7e4c868f..5e935438 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -126,6 +126,10 @@ pub struct ELConfig { pub avs_directory_addr: String, pub strategy_manager_addr: String, + + pub rewards_coordinator_addr: String, + + pub permission_controller_addr: String, } #[derive(Debug, Default, Serialize, Deserialize, PartialEq, Eq, Clone)] @@ -318,6 +322,24 @@ impl IncredibleConfig { self.node_config.node_port_address = port; } + pub fn set_rewards_coordinator_address(&mut self, address: String) { + self.el_config.rewards_coordinator_addr = address; + } + + pub fn set_permission_controller_address(&mut self, address: String) { + self.el_config.permission_controller_addr = address; + } + + pub fn rewards_coordinator_address(&self) -> Result { + Address::from_hex(self.el_config.rewards_coordinator_addr.as_bytes()) + .map_err(ConfigError::HexParse) + } + + pub fn permission_controller_address(&self) -> Result { + Address::from_hex(self.el_config.permission_controller_addr.as_bytes()) + .map_err(ConfigError::HexParse) + } + pub fn node_api_port_address(&self) -> String { self.node_config.node_port_address.clone() } diff --git a/crates/operator/src/client.rs b/crates/operator/src/client.rs index 175f2004..780700a1 100644 --- a/crates/operator/src/client.rs +++ b/crates/operator/src/client.rs @@ -49,8 +49,8 @@ impl ClientAggregator { if let Some(request) = self.client.as_ref() { let s: bool = request .request("process_signed_task_response", params) - .await - .unwrap(); + .await?; + if s { incredible_metrics::inc_num_tasks_accepted_by_aggregator(); return Ok(()); diff --git a/crates/task_generator/src/lib.rs b/crates/task_generator/src/lib.rs index 43414b0a..b6a8c061 100644 --- a/crates/task_generator/src/lib.rs +++ b/crates/task_generator/src/lib.rs @@ -44,6 +44,7 @@ impl TaskManager { /// Creates new task every 10 seconds pub async fn start(&self) -> eyre::Result<()> { + sleep(Duration::from_secs(10)).await; // wait for 10 seconds first let url = Url::parse(&self.rpc_url).expect("Wrong rpc url"); let signer = PrivateKeySigner::from_str(&self.signer)?; let wallet = EthereumWallet::new(signer); @@ -58,7 +59,8 @@ impl TaskManager { loop { let number_to_be_squared = task_num; let quorum_threshold_percentage = 100; - let quorum_numbers = Bytes::from_str("0x00")?; + let quorum_numbers = Bytes::from_str("0x01")?; + let _ = task_manager_contract .createNewTask( number_to_be_squared, @@ -66,12 +68,11 @@ impl TaskManager { quorum_numbers.clone(), ) .send() - .await - .unwrap(); + .await?; - // Increment the task number for the next iteration + // // Increment the task number for the next iteration task_num += *TASK_NUMBER_INCREMENT_VALUE; - // Wait for 10 seconds before the next iteration + // // Wait for 10 seconds before the next iteration sleep(Duration::from_secs(10)).await; } }