Skip to content

Commit 6908110

Browse files
authored
fix: sdk version for v060 (#944)
1 parent f2fac00 commit 6908110

File tree

5 files changed

+59
-7
lines changed

5 files changed

+59
-7
lines changed

batcher/aligned-sdk/abi/AlignedLayerServiceManager.json

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

batcher/aligned-sdk/src/communication/batch.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,17 @@ pub async fn await_batch_verification(
4444
aligned_verification_data: &AlignedVerificationData,
4545
rpc_url: &str,
4646
chain: Chain,
47+
payment_service_addr: &str,
4748
) -> Result<(), errors::SubmitError> {
4849
for _ in 0..RETRIES {
49-
if is_proof_verified(aligned_verification_data, chain.clone(), rpc_url)
50-
.await
51-
.is_ok_and(|r| r)
50+
if is_proof_verified(
51+
aligned_verification_data,
52+
chain.clone(),
53+
rpc_url,
54+
payment_service_addr,
55+
)
56+
.await
57+
.is_ok_and(|r| r)
5258
{
5359
return Ok(());
5460
}

batcher/aligned-sdk/src/sdk.rs

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ use futures_util::{
4040
/// * `verification_data` - An array of verification data of each proof.
4141
/// * `wallet` - The wallet used to sign the proof.
4242
/// * `nonce` - The nonce of the submitter address. See `get_next_nonce`.
43+
/// * `payment_service_addr` - The address of the payment service contract.
4344
/// # Returns
4445
/// * An array of aligned verification data obtained when submitting the proof.
4546
/// # Errors
@@ -66,13 +67,19 @@ pub async fn submit_multiple_and_wait_verification(
6667
verification_data: &[VerificationData],
6768
wallet: Wallet<SigningKey>,
6869
nonce: U256,
70+
payment_service_addr: &str,
6971
) -> Result<Vec<AlignedVerificationData>, errors::SubmitError> {
7072
let aligned_verification_data =
7173
submit_multiple(batcher_url, verification_data, wallet, nonce).await?;
7274

7375
for aligned_verification_data_item in aligned_verification_data.iter() {
74-
await_batch_verification(aligned_verification_data_item, eth_rpc_url, chain.clone())
75-
.await?;
76+
await_batch_verification(
77+
aligned_verification_data_item,
78+
eth_rpc_url,
79+
chain.clone(),
80+
payment_service_addr,
81+
)
82+
.await?;
7683
}
7784

7885
Ok(aligned_verification_data)
@@ -182,6 +189,7 @@ async fn _submit_multiple(
182189
/// * `verification_data` - The verification data of the proof.
183190
/// * `wallet` - The wallet used to sign the proof.
184191
/// * `nonce` - The nonce of the submitter address. See `get_next_nonce`.
192+
/// * `payment_service_addr` - The address of the payment service contract.
185193
/// # Returns
186194
/// * The aligned verification data obtained when submitting the proof.
187195
/// # Errors
@@ -208,6 +216,7 @@ pub async fn submit_and_wait_verification(
208216
verification_data: &VerificationData,
209217
wallet: Wallet<SigningKey>,
210218
nonce: U256,
219+
payment_service_addr: &str,
211220
) -> Result<AlignedVerificationData, errors::SubmitError> {
212221
let verification_data = vec![verification_data.clone()];
213222

@@ -218,6 +227,7 @@ pub async fn submit_and_wait_verification(
218227
&verification_data,
219228
wallet,
220229
nonce,
230+
payment_service_addr,
221231
)
222232
.await?;
223233

@@ -265,6 +275,7 @@ pub async fn submit(
265275
/// * `aligned_verification_data` - The aligned verification data obtained when submitting the proofs.
266276
/// * `chain` - The chain on which the verification will be done.
267277
/// * `eth_rpc_url` - The URL of the Ethereum RPC node.
278+
/// * `payment_service_addr` - The address of the payment service.
268279
/// # Returns
269280
/// * A boolean indicating whether the proof was verified on-chain and is included in the batch.
270281
/// # Errors
@@ -275,25 +286,38 @@ pub async fn is_proof_verified(
275286
aligned_verification_data: &AlignedVerificationData,
276287
chain: Chain,
277288
eth_rpc_url: &str,
289+
payment_service_addr: &str,
278290
) -> Result<bool, errors::VerificationError> {
279291
let eth_rpc_provider =
280292
Provider::<Http>::try_from(eth_rpc_url).map_err(|e: url::ParseError| {
281293
errors::VerificationError::EthereumProviderError(e.to_string())
282294
})?;
283-
_is_proof_verified(aligned_verification_data, chain, eth_rpc_provider).await
295+
296+
_is_proof_verified(
297+
aligned_verification_data,
298+
chain,
299+
eth_rpc_provider,
300+
payment_service_addr,
301+
)
302+
.await
284303
}
285304

286305
async fn _is_proof_verified(
287306
aligned_verification_data: &AlignedVerificationData,
288307
chain: Chain,
289308
eth_rpc_provider: Provider<Http>,
309+
payment_service_addr: &str,
290310
) -> Result<bool, errors::VerificationError> {
291311
let contract_address = match chain {
292312
Chain::Devnet => "0x1613beB3B2C4f22Ee086B2b38C1476A3cE7f78E8",
293313
Chain::Holesky => "0x58F280BeBE9B34c9939C3C39e0890C81f163B623",
294314
Chain::HoleskyStage => "0x9C5231FC88059C086Ea95712d105A2026048c39B",
295315
};
296316

317+
let payment_service_addr = payment_service_addr
318+
.parse::<Address>()
319+
.map_err(|e| errors::VerificationError::HexDecodingError(e.to_string()))?;
320+
297321
// All the elements from the merkle proof have to be concatenated
298322
let merkle_proof: Vec<u8> = aligned_verification_data
299323
.batch_inclusion_proof
@@ -317,6 +341,7 @@ async fn _is_proof_verified(
317341
aligned_verification_data.batch_merkle_root,
318342
merkle_proof.into(),
319343
aligned_verification_data.index_in_batch.into(),
344+
payment_service_addr,
320345
);
321346

322347
let result = call
@@ -405,6 +430,8 @@ mod test {
405430

406431
use ethers::signers::LocalWallet;
407432

433+
const BATCHER_PAYMENT_SERVICE_ADDR: &str = "0x7969c5eD335650692Bc04293B07F5BF2e7A673C0";
434+
408435
#[tokio::test]
409436
async fn test_submit_success() {
410437
let base_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
@@ -438,6 +465,7 @@ mod test {
438465
&verification_data,
439466
wallet,
440467
U256::zero(),
468+
BATCHER_PAYMENT_SERVICE_ADDR,
441469
)
442470
.await
443471
.unwrap();
@@ -471,6 +499,7 @@ mod test {
471499
&verification_data,
472500
wallet,
473501
U256::zero(),
502+
BATCHER_PAYMENT_SERVICE_ADDR,
474503
)
475504
.await;
476505

@@ -512,6 +541,7 @@ mod test {
512541
&verification_data,
513542
wallet,
514543
U256::zero(),
544+
BATCHER_PAYMENT_SERVICE_ADDR,
515545
)
516546
.await
517547
.unwrap();
@@ -522,6 +552,7 @@ mod test {
522552
&aligned_verification_data[0],
523553
Chain::Devnet,
524554
"http://localhost:8545",
555+
BATCHER_PAYMENT_SERVICE_ADDR,
525556
)
526557
.await
527558
.unwrap();
@@ -562,6 +593,7 @@ mod test {
562593
&verification_data,
563594
wallet,
564595
U256::zero(),
596+
BATCHER_PAYMENT_SERVICE_ADDR,
565597
)
566598
.await
567599
.unwrap();
@@ -577,6 +609,7 @@ mod test {
577609
&aligned_verification_data_modified,
578610
Chain::Devnet,
579611
"http://localhost:8545",
612+
BATCHER_PAYMENT_SERVICE_ADDR,
580613
)
581614
.await
582615
.unwrap();

batcher/aligned/src/main.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,12 @@ pub struct VerifyProofOnchainArgs {
162162
default_value = "devnet"
163163
)]
164164
chain: ChainArg,
165+
#[arg(
166+
name = "Batcher Payment Service Eth Address",
167+
long = "payment_service_addr",
168+
default_value = "0x7969c5eD335650692Bc04293B07F5BF2e7A673C0"
169+
)]
170+
payment_service_addr: String,
165171
}
166172

167173
#[derive(Parser, Debug)]
@@ -360,6 +366,7 @@ async fn main() -> Result<(), AlignedError> {
360366
&aligned_verification_data,
361367
chain,
362368
&verify_inclusion_args.eth_rpc_url,
369+
&verify_inclusion_args.payment_service_addr,
363370
)
364371
.await?;
365372

docs/guides/1_SDK.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ pub async fn submit_and_wait_verification(
114114
verification_data: &VerificationData,
115115
wallet: Wallet<SigningKey>,
116116
nonce: U256,
117+
payment_service_addr: &str,
117118
) -> Result<AlignedVerificationData, errors::SubmitError>
118119
```
119120

@@ -125,6 +126,7 @@ pub async fn submit_and_wait_verification(
125126
- `verification_data` - The verification data for the proof.
126127
- `wallet` - The wallet used to sign the proof. Should be using correct chain id. See `get_chain_id`.
127128
- `nonce` - The nonce of the submitter address. See `get_next_nonce`.
129+
- `payment_service_addr` - The address of the batcher payment service contract.
128130

129131
#### Returns
130132

@@ -162,6 +164,7 @@ pub async fn submit_multiple_and_wait_verification(
162164
verification_data: &[VerificationData],
163165
wallet: Wallet<SigningKey>,
164166
nonce: U256,
167+
payment_service_addr: &str,
165168
) -> Result<Vec<AlignedVerificationData>, errors::SubmitError>
166169
```
167170

@@ -173,6 +176,7 @@ pub async fn submit_multiple_and_wait_verification(
173176
- `verification_data` - A verification data array.
174177
- `wallet` - The wallet used to sign the proof. Should be using correct chain id. See `get_chain_id`.
175178
- `nonce` - The nonce of the submitter address. See `get_next_nonce`.
179+
- `payment_service_addr` - The address of the batcher payment service contract.
176180

177181
#### Returns
178182

@@ -206,6 +210,7 @@ pub async fn is_proof_verified(
206210
aligned_verification_data: AlignedVerificationData,
207211
chain: Chain,
208212
eth_rpc_url: &str,
213+
payment_service_addr: &str,
209214
) -> Result<bool, errors::VerificationError>
210215
```
211216

@@ -214,6 +219,7 @@ pub async fn is_proof_verified(
214219
- `aligned_verification_data` - The aligned verification data obtained when submitting the proofs.
215220
- `chain` - The chain on which the verification will be done.
216221
- `eth_rpc_url` - The URL of the Ethereum RPC node.
222+
- `payment_service_addr` - The address of the batcher payment service contract.
217223

218224
#### Returns
219225

0 commit comments

Comments
 (0)