Skip to content

Commit 0c57aa8

Browse files
committed
feat: verify aggreted proof on chain sdk
1 parent ed4cc71 commit 0c57aa8

File tree

2 files changed

+39
-1
lines changed

2 files changed

+39
-1
lines changed

batcher/aligned-sdk/abi/AlignedProofAggregationService.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

batcher/aligned-sdk/src/sdk/aggregation.rs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use crate::{
22
beacon::{BeaconClient, BeaconClientError},
33
core::types::Network,
4+
eth::aligned_proof_agg_service::aligned_proof_aggregation_service,
45
};
56
use ethers::{
67
providers::{Http, Middleware, Provider},
@@ -133,6 +134,43 @@ pub async fn is_proof_verified_in_aggregation_mode(
133134
Err(ProofVerificationAggModeError::ProofNotFoundInLogs)
134135
}
135136

137+
pub async fn verify_agg_proof_on_chain(
138+
network: Network,
139+
eth_rpc_url: String,
140+
beacon_client_url: String,
141+
from_block: Option<u64>,
142+
proof_commitment: [u8; 32],
143+
) -> Result<bool, ProofVerificationAggModeError> {
144+
let Some(merkle_path) = get_merkle_path_for_proof(
145+
network.clone(),
146+
eth_rpc_url.clone(),
147+
beacon_client_url,
148+
from_block,
149+
proof_commitment,
150+
)
151+
.await?
152+
else {
153+
return Ok(false);
154+
};
155+
156+
let eth_rpc_provider = Provider::<Http>::try_from(eth_rpc_url)
157+
.map_err(|e| ProofVerificationAggModeError::EthereumProviderError(e.to_string()))?;
158+
let contract_provider = aligned_proof_aggregation_service(
159+
eth_rpc_provider,
160+
network.get_aligned_proof_agg_service_address(),
161+
)
162+
.await
163+
.map_err(|e| ProofVerificationAggModeError::EthereumProviderError(e.to_string()))?;
164+
165+
let res: bool = contract_provider
166+
.verify_proof_inclusion(merkle_path, proof_commitment)
167+
.call()
168+
.await
169+
.expect("Message to be sent");
170+
171+
Ok(res)
172+
}
173+
136174
pub async fn get_merkle_path_for_proof(
137175
network: Network,
138176
eth_rpc_url: String,

0 commit comments

Comments
 (0)