Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit f29d375

Browse files
authoredApr 30, 2025
refactor: use new version of aggregator (#10)
1 parent bf5eec9 commit f29d375

File tree

6 files changed

+14833
-356
lines changed

6 files changed

+14833
-356
lines changed
 

‎Cargo.lock

Lines changed: 2 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎examples/aggregator/Cargo.toml

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,9 @@ description = "aggregator example"
1010

1111
[dependencies]
1212
alloy.workspace = true
13-
eigen-client-avsregistry.workspace = true
14-
eigen-crypto-bls.workspace = true
15-
eigen-logging.workspace = true
16-
eigen-testing-utils.workspace = true
17-
eigen-types.workspace = true
18-
eigen-common.workspace = true
19-
tokio = { workspace = true, features = ["macros", "rt-multi-thread"] }
2013
eigen-aggregator.workspace = true
14+
eigen-crypto-bls.workspace = true
15+
eigen-task-processor.workspace = true
16+
eigen-utils.workspace = true
2117
serde.workspace = true
22-
tracing.workspace = true
23-
serde_json.workspace = true
24-
25-
tarpc = { version = "0.36", features = ["full"] }
18+
tokio.workspace = true

‎examples/aggregator/examples/aggregator.rs

Lines changed: 0 additions & 337 deletions
This file was deleted.

‎examples/aggregator/src/bindings/iincrediblesquaringtaskmanager.rs

Lines changed: 14686 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#![allow(unused_imports, clippy::all, rustdoc::all)]
2+
//! This module contains the sol! generated bindings for solidity contracts.
3+
//! This is autogenerated code.
4+
//! Do not manually edit these files.
5+
//! These files may be overwritten by the codegen system at any time.
6+
pub mod r#iincrediblesquaringtaskmanager;

‎examples/aggregator/src/main.rs

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
use alloy::network::EthereumWallet;
2+
use alloy::primitives::{Address, U256};
3+
use alloy::providers::ProviderBuilder;
4+
use alloy::signers::local::PrivateKeySigner;
5+
use alloy::transports::http::reqwest::Url;
6+
use alloy::{
7+
contract::private::{Provider, Transport},
8+
network::Network,
9+
};
10+
use bindings::iincrediblesquaringtaskmanager::IBLSSignatureCheckerTypes::NonSignerStakesAndSignature as ContractNonSignerStakesAndSignature;
11+
use bindings::iincrediblesquaringtaskmanager::IIncredibleSquaringTaskManager::{
12+
Task as ContractTask, TaskResponse as ContractTaskResponse,
13+
};
14+
use bindings::iincrediblesquaringtaskmanager::IncredibleSquaringTaskManager::IncredibleSquaringTaskManagerInstance;
15+
use bindings::iincrediblesquaringtaskmanager::IncredibleSquaringTaskManager::NewTaskCreated;
16+
use bindings::iincrediblesquaringtaskmanager::BN254::{G1Point, G2Point};
17+
use eigen_aggregator::{Aggregator, AggregatorConfig};
18+
use eigen_task_processor::task::Task;
19+
use eigen_task_processor::task_manager::{TaskManagerContract, TaskManagerError};
20+
use eigen_task_processor::task_response::TaskResponse;
21+
use eigen_task_processor::IndexingTaskProcessor;
22+
use eigen_utils::slashing::middleware::iblssignaturechecker::IBLSSignatureCheckerTypes::NonSignerStakesAndSignature;
23+
use std::str::FromStr;
24+
25+
pub mod bindings;
26+
27+
impl<T, P, N> TaskManagerContract<T, P, N> for IncredibleSquaringTaskManagerInstance<T, P, N>
28+
where
29+
T: Transport + Clone + Send + Sync,
30+
P: Provider<T, N>,
31+
N: Network,
32+
{
33+
type Input = U256;
34+
type Output = U256;
35+
type NewTaskEvent = NewTaskCreated;
36+
37+
async fn respond_to_task(
38+
&self,
39+
task: Task<Self::Input>,
40+
response: TaskResponse<Self::Output>,
41+
non_signer_stakes_and_signature: NonSignerStakesAndSignature,
42+
) -> Result<(), TaskManagerError> {
43+
let contract_task = ContractTask {
44+
numberToBeSquared: task.input,
45+
taskCreatedBlock: task.task_created_block,
46+
quorumNumbers: task.quorum_numbers,
47+
quorumThresholdPercentage: task.quorum_threshold_percentage,
48+
};
49+
50+
let contract_response = ContractTaskResponse {
51+
numberSquared: response.response,
52+
referenceTaskIndex: response.task_index,
53+
};
54+
55+
let apk_g2 = G2Point {
56+
X: non_signer_stakes_and_signature.apkG2.X,
57+
Y: non_signer_stakes_and_signature.apkG2.Y,
58+
};
59+
60+
let sigma = G1Point {
61+
X: non_signer_stakes_and_signature.sigma.X,
62+
Y: non_signer_stakes_and_signature.sigma.Y,
63+
};
64+
65+
let quorum_apks = non_signer_stakes_and_signature
66+
.quorumApks
67+
.iter()
68+
.map(|apk| G1Point { X: apk.X, Y: apk.Y })
69+
.collect();
70+
71+
let non_signer_pubkeys = non_signer_stakes_and_signature
72+
.nonSignerPubkeys
73+
.iter()
74+
.map(|pubkey| G1Point {
75+
X: pubkey.X,
76+
Y: pubkey.Y,
77+
})
78+
.collect();
79+
80+
let non_signer_stakes_and_signature = ContractNonSignerStakesAndSignature {
81+
nonSignerStakeIndices: non_signer_stakes_and_signature.nonSignerStakeIndices,
82+
nonSignerQuorumBitmapIndices: non_signer_stakes_and_signature
83+
.nonSignerQuorumBitmapIndices,
84+
quorumApkIndices: non_signer_stakes_and_signature.quorumApkIndices,
85+
totalStakeIndices: non_signer_stakes_and_signature.totalStakeIndices,
86+
apkG2: apk_g2,
87+
quorumApks: quorum_apks,
88+
nonSignerPubkeys: non_signer_pubkeys,
89+
sigma,
90+
};
91+
92+
self.respondToTask(
93+
contract_task,
94+
contract_response,
95+
non_signer_stakes_and_signature,
96+
)
97+
.send()
98+
.await
99+
.unwrap()
100+
.get_receipt()
101+
.await
102+
.unwrap();
103+
104+
Ok(())
105+
}
106+
}
107+
108+
#[tokio::main]
109+
async fn main() {
110+
let registry_coordinator =
111+
Address::from_str("0x7969c5ed335650692bc04293b07f5bf2e7a673c0").unwrap();
112+
let operator_state_retriever =
113+
Address::from_str("0x1429859428c0abc9c2c47c8ee9fbaf82cfa0f20f").unwrap();
114+
let http_rpc_url = "http://localhost:8545".to_string();
115+
let signer = "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80";
116+
let task_manager_address =
117+
Address::from_str("0x742d35cc6634c0532925a3b844f51254ab06f58e").unwrap();
118+
let url = Url::parse(&http_rpc_url).unwrap();
119+
let wallet = EthereumWallet::new(PrivateKeySigner::from_str(signer).unwrap());
120+
let provider = ProviderBuilder::new().wallet(wallet).on_http(url);
121+
122+
let contract = IncredibleSquaringTaskManagerInstance::new(task_manager_address, provider);
123+
let task_processor = IndexingTaskProcessor::new(contract);
124+
125+
let config = AggregatorConfig {
126+
server_address: "http://localhost:8080".to_string(),
127+
http_rpc_url: "http://localhost:8545".to_string(),
128+
ws_rpc_url: "ws://localhost:8545".to_string(),
129+
registry_coordinator,
130+
operator_state_retriever,
131+
};
132+
133+
let aggregator = Aggregator::new(config, task_processor).await.unwrap();
134+
aggregator.start().await.unwrap();
135+
}

0 commit comments

Comments
 (0)
Please sign in to comment.