|
1 | 1 | use aligned_sdk::{ |
| 2 | + aggregation_layer::ProofStatus, |
2 | 3 | common::types::{AlignedVerificationData, Signer, VerificationData, Wallet}, |
3 | 4 | verification_layer::{estimate_fee, get_chain_id}, |
4 | 5 | }; |
5 | | -use alloy::{ |
6 | | - eips::BlockNumberOrTag, |
7 | | - primitives::Address, |
8 | | - providers::{Provider, ProviderBuilder, WsConnect}, |
9 | | - rpc::types::Filter, |
10 | | -}; |
11 | | -use futures_util::StreamExt; |
12 | 6 | use sp1_sdk::{HashableKey, SP1VerifyingKey}; |
13 | 7 |
|
14 | 8 | use crate::config::Config; |
@@ -63,58 +57,45 @@ pub async fn send_proof_to_be_verified_on_aligned( |
63 | 57 | .expect("Proof to be sent") |
64 | 58 | } |
65 | 59 |
|
66 | | -pub async fn wait_until_proof_is_aggregated( |
| 60 | +pub async fn check_proof_proof_aggregation_status( |
67 | 61 | config: &Config, |
68 | 62 | proof: &sp1_sdk::SP1ProofWithPublicValues, |
69 | 63 | vk: &SP1VerifyingKey, |
70 | | -) -> Vec<[u8; 32]> { |
71 | | - let ws_rpc_url = &config.ws_eth_rpc_url; |
72 | | - let ws = WsConnect::new(ws_rpc_url); |
73 | | - let provider = ProviderBuilder::new().on_ws(ws).await.unwrap(); |
74 | | - |
75 | | - let aligned_proof_agg_address = |
76 | | - Address::from(config.network.get_aligned_proof_agg_service_address().0); |
77 | | - |
78 | | - let filter = Filter::new() |
79 | | - .address(aligned_proof_agg_address) |
80 | | - .event("AggregatedProofVerified(bytes32,bytes32)") |
81 | | - .from_block(BlockNumberOrTag::Latest); |
82 | | - |
83 | | - // Subscribe to logs. |
84 | | - let sub = provider.subscribe_logs(&filter).await.unwrap(); |
85 | | - let mut stream = sub.into_stream(); |
86 | | - |
| 64 | +) -> ProofStatus { |
87 | 65 | let verification_data = aligned_sdk::aggregation_layer::AggregationModeVerificationData::SP1 { |
88 | 66 | vk: vk.hash_bytes(), |
89 | 67 | public_inputs: proof.public_values.to_vec(), |
90 | 68 | }; |
91 | 69 |
|
92 | | - let mut merkle_path = vec![]; |
93 | | - |
94 | | - while stream.next().await.is_some() { |
95 | | - let proof_status = aligned_sdk::aggregation_layer::check_proof_verification( |
96 | | - &verification_data, |
97 | | - config.network.clone(), |
98 | | - config.eth_rpc_url.clone(), |
99 | | - config.beacon_client_url.clone(), |
100 | | - None, |
101 | | - ) |
102 | | - .await |
103 | | - .expect("Get merkle path for proof"); |
| 70 | + let proof_status = aligned_sdk::aggregation_layer::check_proof_verification( |
| 71 | + &verification_data, |
| 72 | + config.network.clone(), |
| 73 | + config.eth_rpc_url.clone(), |
| 74 | + config.beacon_client_url.clone(), |
| 75 | + // By default it looks back 24 hours |
| 76 | + None, |
| 77 | + ) |
| 78 | + .await |
| 79 | + .expect("Get merkle path for proof"); |
104 | 80 |
|
105 | | - match proof_status { |
106 | | - aligned_sdk::aggregation_layer::ProofStatus::Verified { |
107 | | - merkle_path: path, .. |
108 | | - } => { |
109 | | - merkle_path = path; |
110 | | - break; |
111 | | - } |
112 | | - aligned_sdk::aggregation_layer::ProofStatus::Invalid => { |
113 | | - panic!("Proof did pass merkle root verification") |
114 | | - } |
115 | | - aligned_sdk::aggregation_layer::ProofStatus::NotFound => continue, |
116 | | - } |
117 | | - } |
| 81 | + proof_status |
118 | 82 |
|
119 | | - merkle_path |
| 83 | + // match proof_status { |
| 84 | + // aligned_sdk::aggregation_layer::ProofStatus::Verified { |
| 85 | + // merkle_root, |
| 86 | + // merkle_path, |
| 87 | + // } => { |
| 88 | + // info!( |
| 89 | + // "Proof aggregated in aggregation with merkle root {:?}", |
| 90 | + // hex::encode(merkle_root) |
| 91 | + // ); |
| 92 | + // merkle_path |
| 93 | + // } |
| 94 | + // aligned_sdk::aggregation_layer::ProofStatus::Invalid => { |
| 95 | + // panic!("Proof did pass merkle root verification"); |
| 96 | + // } |
| 97 | + // aligned_sdk::aggregation_layer::ProofStatus::NotFound => { |
| 98 | + // panic!("Proof not found in the last 24 hours logs"); |
| 99 | + // } |
| 100 | + // } |
120 | 101 | } |
0 commit comments