Skip to content

Commit 8885b02

Browse files
committed
feat: backend initialization
1 parent 4fa59f4 commit 8885b02

File tree

2 files changed

+19
-12
lines changed

2 files changed

+19
-12
lines changed

aggregation-mode/src/backend/mod.rs

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use std::time::Duration;
1+
use std::{str::FromStr, time::Duration};
22

33
use alloy::{
44
network::EthereumWallet,
@@ -43,11 +43,15 @@ pub struct ProofAggregator {
4343
proof_aggregation_service: AlignedProofAggregationServiceContract,
4444
}
4545

46+
pub struct Config {
47+
pub rpc_url: String,
48+
pub private_key: String,
49+
}
50+
4651
impl ProofAggregator {
47-
// TODO read .yaml config file
48-
pub fn new(rpc_url: &str) -> Self {
49-
let rpc_url = rpc_url.parse().expect("correct url");
50-
let signer = PrivateKeySigner::random();
52+
pub fn new(config: Config) -> Self {
53+
let rpc_url = config.rpc_url.parse().expect("correct url");
54+
let signer = PrivateKeySigner::from_str(&config.private_key).expect("valid string");
5155
let wallet = EthereumWallet::from(signer);
5256
let provider = ProviderBuilder::new().wallet(wallet).on_http(rpc_url);
5357
let proof_aggregation_service =
@@ -127,8 +131,8 @@ impl ProofAggregator {
127131
}
128132
};
129133

130-
let receipt = self.send_blob_transaction(leaves).await?;
131-
self.send_proof_to_verify_on_chain(&receipt.transaction_hash.0, output.proof)
134+
let blob_tx_hash = self.send_blob_transaction(leaves).await?;
135+
self.send_proof_to_verify_on_chain(&blob_tx_hash, output.proof)
132136
.await?;
133137

134138
Ok(())
@@ -166,8 +170,8 @@ impl ProofAggregator {
166170
async fn send_blob_transaction(
167171
&self,
168172
leaves: Vec<[u8; 32]>,
169-
) -> Result<TransactionReceipt, AggregatedProofSubmissionError> {
170-
Err(AggregatedProofSubmissionError::SendBlobTransaction)
173+
) -> Result<[u8; 32], AggregatedProofSubmissionError> {
174+
Ok([0u8; 32])
171175
}
172176

173177
async fn set_aggregated_proof_as_missed(&self) {}

aggregation-mode/src/main.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use proof_aggregator::backend::ProofAggregator;
1+
use proof_aggregator::backend::{Config, ProofAggregator};
22
use tracing_subscriber::FmtSubscriber;
33

44
#[tokio::main]
@@ -7,8 +7,11 @@ async fn main() {
77
tracing::subscriber::set_global_default(subscriber).expect("setting default subscriber failed");
88

99
// TODO read proof aggregator yaml config file
10-
11-
let mut proof_aggregator = ProofAggregator::new("http://localhost:8545");
10+
let config = Config {
11+
private_key: "0x2a871d0798f97d79848a013d4936a73bf4cc922c825d33c1cf7073dff6d409c6".into(),
12+
rpc_url: "http://localhost:8545".into(),
13+
};
14+
let mut proof_aggregator = ProofAggregator::new(config);
1215

1316
// TODO read proofs from fs
1417
// proof_aggregator.add_proof(proof)

0 commit comments

Comments
 (0)