diff --git a/Cargo.lock b/Cargo.lock
index 0cdfdd76..a4f195bf 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -467,6 +467,12 @@ dependencies = [
"ws_stream_wasm",
]
+[[package]]
+name = "anyhow"
+version = "1.0.83"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "25bdb32cbbdce2b519a9cd7df3a678443100e265d5e25ca763b7572a5104f5f3"
+
[[package]]
name = "ark-bn254"
version = "0.4.0"
@@ -1478,8 +1484,10 @@ dependencies = [
"alloy-contract",
"alloy-primitives",
"alloy-provider",
+ "alloy-rpc-types",
"alloy-sol-types",
"alloy-transport-ws",
+ "anyhow",
"eigensdk-client-avsregistry",
"eigensdk-contract-bindings",
"eigensdk-crypto-bls",
@@ -1491,6 +1499,7 @@ dependencies = [
"futures-util",
"thiserror",
"tokio",
+ "tracing",
]
[[package]]
@@ -2540,6 +2549,17 @@ dependencies = [
"hashbrown 0.14.3",
]
+[[package]]
+name = "info-operator-service"
+version = "0.0.1-alpha"
+dependencies = [
+ "alloy-primitives",
+ "eigensdk-client-avsregistry",
+ "eigensdk-services-operatorsinfo",
+ "tokio",
+ "tracing",
+]
+
[[package]]
name = "inout"
version = "0.1.3"
diff --git a/Cargo.toml b/Cargo.toml
index a448e105..cdfc07c6 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -15,7 +15,9 @@ members = [ "crates/chainio/clients/avsregistry/",
"crates/services/operatorsinfo/",
"crates/types/",
"crates/metrics/",
-"crates/types/"]
+"crates/types/",
+"examples/info-operator-service/"
+]
resolver = "2"
@@ -62,6 +64,7 @@ eigensdk-metrics-collectors-rpc-calls = {version = "0.0.1-alpha",path = "crates/
eigensdk-services-avsregistry = {path = "crates/services/avsregistry"}
eigensdk-services-bls_aggregation = {path = "crates/services/bls_aggregation"}
eigensdk-services-operatorsinfo = {path = "crates/services/operatorsinfo"}
+info-operator-service = {path = "examples/info-operator-service"}
tokio = {version = "1.37.0" , features = ["test-util", "full","sync"] }
futures-util = "0.3.30"
thiserror = "1.0"
diff --git a/crates/chainio/clients/avsregistry/src/reader.rs b/crates/chainio/clients/avsregistry/src/reader.rs
index 4963c0c0..bbb4932e 100644
--- a/crates/chainio/clients/avsregistry/src/reader.rs
+++ b/crates/chainio/clients/avsregistry/src/reader.rs
@@ -3,6 +3,7 @@ use alloy_primitives::{Address, Bytes, FixedBytes, B256, U256};
use alloy_provider::{Provider, ProviderBuilder};
use alloy_rpc_types::Filter;
use alloy_sol_types::sol;
+use ark_ff::Zero;
use eigensdk_types::operator::{bitmap_to_quorum_ids, BLSApkRegistry, OperatorPubKeys};
use num_bigint::BigInt;
use std::collections::HashMap;
@@ -36,7 +37,6 @@ sol!(
"../../../../crates/contracts/bindings/utils/json/OperatorStateRetriever.json"
);
-use BLSApkRegistry::{G1Point, G2Point};
/// Avs Registry chainreader
#[derive(Debug, Clone)]
pub struct AvsRegistryChainReader {
@@ -52,7 +52,7 @@ trait AvsRegistryReader {
}
impl AvsRegistryChainReader {
- fn new(
+ pub fn new(
registry_coordinator_addr: Address,
bls_apk_registry_addr: Address,
operator_state_retriever: Address,
@@ -415,44 +415,59 @@ impl AvsRegistryChainReader {
pub async fn query_existing_registered_operator_pub_keys(
&self,
start_block: u64,
- stop_block: u64,
+ mut stop_block: u64,
) -> Result<(Vec
, Vec), Box> {
let provider = ProviderBuilder::new()
.with_recommended_fillers()
.on_builtin(&self.provider)
.await?;
-
- let filter = Filter::new()
- .select(start_block..stop_block)
- .event("NewPubkeyRegistration(address,(uint256,uint256),(uint256[2],uint256[2]))")
- .address(self.bls_apk_registry_addr);
-
- let logs = provider.get_logs(&filter).await?;
-
- debug!(transactionLogs = ?logs, "avsRegistryChainReader.QueryExistingRegisteredOperatorPubKeys");
+ let query_block_range = 1024;
+ let current_block_number = provider.get_block_number().await?;
+ if stop_block.is_zero() {
+ stop_block = current_block_number;
+ }
+ println!("start block :{}", start_block);
+ println!("stop block {}", stop_block);
+ let mut i = start_block;
let mut operator_addresses: Vec = vec![];
let mut operator_pub_keys: Vec = vec![];
+ while i <= stop_block {
+ let mut to_block = i + (query_block_range - 1);
+ if to_block > stop_block {
+ to_block = stop_block;
+ }
+ println!("to block{}", to_block);
+ println!("bls apk address :{}", self.bls_apk_registry_addr);
+ let filter = Filter::new()
+ .select(i..to_block)
+ .event("NewPubkeyRegistration(address,(uint256,uint256),(uint256[2],uint256[2]))")
+ .address(self.bls_apk_registry_addr);
+
+ let logs = provider.get_logs(&filter).await?;
+ println!("logs length {:?}", logs.len());
+ debug!(transactionLogs = ?logs, "avsRegistryChainReader.QueryExistingRegisteredOperatorPubKeys");
- for (i, v_log) in logs.iter().enumerate() {
- let pub_key_reg_option = v_log
- .log_decode::()
- .ok();
- if let Some(pub_key_reg) = pub_key_reg_option {
- let data = pub_key_reg.data();
- let operator_addr = data.operator;
- operator_addresses.push(operator_addr);
- let g1_pub_key = data.pubkeyG1.clone();
- let g2_pub_key = data.pubkeyG2.clone();
-
- let operator_pub_key = OperatorPubKeys {
- g1_pub_key: g1_pub_key,
- g2_pub_key: g2_pub_key,
- };
-
- operator_pub_keys.push(operator_pub_key);
+ for (_, v_log) in logs.iter().enumerate() {
+ let pub_key_reg_option = v_log
+ .log_decode::()
+ .ok();
+ if let Some(pub_key_reg) = pub_key_reg_option {
+ let data = pub_key_reg.data();
+ let operator_addr = data.operator;
+ operator_addresses.push(operator_addr);
+ let g1_pub_key = data.pubkeyG1.clone();
+ let g2_pub_key = data.pubkeyG2.clone();
+
+ let operator_pub_key = OperatorPubKeys {
+ g1_pub_key: g1_pub_key,
+ g2_pub_key: g2_pub_key,
+ };
+
+ operator_pub_keys.push(operator_pub_key);
+ }
}
+ i += 1024;
}
-
Ok((operator_addresses, operator_pub_keys))
}
@@ -470,9 +485,6 @@ impl AvsRegistryChainReader {
let query_block_range = 10000;
- let contract_registry_coordinator =
- RegistryCoordinator::new(self.registry_coordinator_addr, &provider);
-
let mut i = start_block;
while i <= stop_block {
diff --git a/crates/chainio/clients/avsregistry/src/subscriber.rs b/crates/chainio/clients/avsregistry/src/subscriber.rs
index 72870929..f3349f7d 100644
--- a/crates/chainio/clients/avsregistry/src/subscriber.rs
+++ b/crates/chainio/clients/avsregistry/src/subscriber.rs
@@ -20,22 +20,17 @@ use BLSApkRegistry::{BLSApkRegistryEvents, BLSApkRegistryInstance, NewPubkeyRegi
/// AvsRegistry Chain Subscriber struct
#[derive(Debug)]
pub struct AvsRegistryChainSubscriber {
- bls_apk_registry: BLSApkRegistryEvents,
provider: String,
}
impl AvsRegistryChainSubscriber {
- fn new(bls_apk_registry: BLSApkRegistryEvents, provider: String) -> Self {
- return AvsRegistryChainSubscriber {
- bls_apk_registry: bls_apk_registry,
- provider,
- };
+ pub fn new(provider: String) -> Self {
+ return AvsRegistryChainSubscriber { provider };
}
- async fn build_avs_registry_chain_reader(
+ pub async fn build(
&self,
bls_apk_registry_addr: Address,
- provider: String,
) -> Result<
BLSApkRegistryInstance<
BoxTransport,
@@ -60,6 +55,7 @@ impl AvsRegistryChainSubscriber {
return Ok(bls_apk_reg);
}
+ /// Utility function that returns new pubkey registration filter
pub async fn get_new_pub_key_registration_filter<'a>(
&self,
) -> Result> {
diff --git a/crates/services/operatorsinfo/Cargo.toml b/crates/services/operatorsinfo/Cargo.toml
index d4e9e34e..8719d7d9 100644
--- a/crates/services/operatorsinfo/Cargo.toml
+++ b/crates/services/operatorsinfo/Cargo.toml
@@ -24,4 +24,7 @@ alloy-primitives.workspace = true
alloy-provider.workspace = true
alloy-transport-ws.workspace = true
futures-util.workspace = true
-tokio = { workspace = true, features = ["rt-multi-thread", "macros"] }
\ No newline at end of file
+tokio = { workspace = true, features = ["rt-multi-thread", "macros"] }
+tracing.workspace = true
+anyhow = "1.0.83"
+alloy-rpc-types.workspace = true
\ No newline at end of file
diff --git a/crates/services/operatorsinfo/src/operatorsinfo_inmemory.rs b/crates/services/operatorsinfo/src/operatorsinfo_inmemory.rs
index 5c886458..2ccbddbe 100644
--- a/crates/services/operatorsinfo/src/operatorsinfo_inmemory.rs
+++ b/crates/services/operatorsinfo/src/operatorsinfo_inmemory.rs
@@ -1,17 +1,16 @@
-use alloy_sol_types::sol;
-use eigensdk_client_avsregistry::{
- reader::AvsRegistryChainReader, subscriber::AvsRegistryChainSubscriber,
-};
-
-// use eigensdk_types::{G1Point,G2Point};
use alloy_primitives::Address;
use alloy_provider::{Provider, ProviderBuilder};
+use alloy_rpc_types::Filter;
use alloy_transport_ws::WsConnect;
+use anyhow::Result;
+use eigensdk_client_avsregistry::{
+ reader::AvsRegistryChainReader, subscriber::AvsRegistryChainSubscriber,
+};
use eigensdk_types::operator::BLSApkRegistry::{self, G1Point, G2Point};
use eigensdk_types::operator::{operator_id_from_g1_pub_key, OperatorPubKeys};
-use eyre::Result;
-use futures_util::{stream, StreamExt};
+use futures_util::StreamExt;
use std::collections::HashMap;
+use std::error::Error as StdError;
use tokio::sync::{
mpsc,
mpsc::UnboundedSender,
@@ -32,6 +31,8 @@ enum OperatorsInfoMessage {
Get(Address, Sender