Skip to content

Commit 1c0845c

Browse files
Avoid modifying the SDK functions, restore it to the previous version
1 parent 9fdf3fe commit 1c0845c

File tree

4 files changed

+28
-28
lines changed

4 files changed

+28
-28
lines changed

crates/cli/src/main.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,7 @@ async fn main() -> Result<(), AlignedError> {
542542

543543
let nonce = match &submit_args.nonce {
544544
Some(nonce) => U256::from_dec_str(nonce).map_err(|_| SubmitError::InvalidNonce)?,
545-
None => get_nonce_from_batcher(&used_network, wallet.address())
545+
None => get_nonce_from_batcher(used_network.clone(), wallet.address())
546546
.await
547547
.map_err(|e| match e {
548548
aligned_sdk::common::errors::GetNonceError::EthRpcError(e) => {
@@ -584,7 +584,7 @@ async fn main() -> Result<(), AlignedError> {
584584
info!("Submitting proofs to the Aligned batcher...");
585585

586586
let aligned_verification_data_vec = submit_multiple(
587-
&used_network,
587+
used_network.clone(),
588588
&verification_data_arr,
589589
max_fee_wei,
590590
wallet,
@@ -650,7 +650,7 @@ async fn main() -> Result<(), AlignedError> {
650650
info!("Verifying response data matches sent proof data...");
651651
let response = verification_layer::is_proof_verified(
652652
&aligned_verification_data,
653-
&(verify_inclusion_args.network.into()),
653+
verify_inclusion_args.network.into(),
654654
&verify_inclusion_args.eth_rpc_url,
655655
)
656656
.await?;
@@ -718,7 +718,7 @@ async fn main() -> Result<(), AlignedError> {
718718
let chain_id = get_chain_id(eth_rpc_url.as_str()).await?;
719719
wallet = wallet.with_chain_id(chain_id);
720720

721-
let client = SignerMiddleware::new(eth_rpc_provider, wallet.clone());
721+
let client = SignerMiddleware::new(eth_rpc_provider, wallet);
722722

723723
match deposit_to_aligned(amount_wei, client, deposit_to_batcher_args.network.into())
724724
.await
@@ -758,7 +758,7 @@ async fn main() -> Result<(), AlignedError> {
758758
}
759759
GetUserNonce(args) => {
760760
let address = H160::from_str(&args.address).unwrap();
761-
match get_nonce_from_batcher(&args.network.into(), address).await {
761+
match get_nonce_from_batcher(args.network.into(), address).await {
762762
Ok(nonce) => {
763763
info!("Nonce for address {} is {}", address, nonce);
764764
}
@@ -770,8 +770,7 @@ async fn main() -> Result<(), AlignedError> {
770770
}
771771
GetUserNonceFromEthereum(args) => {
772772
let address = H160::from_str(&args.address).unwrap();
773-
let network = args.network.into();
774-
match get_nonce_from_ethereum(&args.eth_rpc_url, address, &network).await {
773+
match get_nonce_from_ethereum(&args.eth_rpc_url, address, args.network.into()).await {
775774
Ok(nonce) => {
776775
info!(
777776
"Nonce for address {} in BatcherPaymentService contract is {}",
@@ -788,8 +787,8 @@ async fn main() -> Result<(), AlignedError> {
788787
let address = H160::from_str(&args.address).unwrap();
789788
let network: Network = args.network.into();
790789
let Ok((ethereum_nonce, batcher_nonce)) = future::try_join(
791-
get_nonce_from_ethereum(&args.eth_rpc_url, address, &network),
792-
get_nonce_from_batcher(&network, address),
790+
get_nonce_from_ethereum(&args.eth_rpc_url, address, network.clone()),
791+
get_nonce_from_batcher(network, address),
793792
)
794793
.await
795794
.map_err(|e| error!("Error while getting nonce: {:?}", e)) else {

crates/sdk/src/communication/batch.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ pub fn process_batcher_response(
3838
pub async fn await_batch_verification(
3939
aligned_verification_data: &AlignedVerificationData,
4040
rpc_url: &str,
41-
network: &Network,
41+
network: Network,
4242
) -> Result<(), errors::SubmitError> {
4343
for _ in 0..RETRIES {
44-
if is_proof_verified(aligned_verification_data, network, rpc_url)
44+
if is_proof_verified(aligned_verification_data, network.clone(), rpc_url)
4545
.await
4646
.is_ok_and(|r| r)
4747
{

crates/sdk/src/verification_layer/mod.rs

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -82,21 +82,22 @@ use std::path::PathBuf;
8282
#[allow(clippy::too_many_arguments)] // TODO: Refactor this function, use NoncedVerificationData
8383
pub async fn submit_multiple_and_wait_verification(
8484
eth_rpc_url: &str,
85-
network: &Network,
85+
network: Network,
8686
verification_data: &[VerificationData],
8787
max_fee: U256,
8888
wallet: Wallet<SigningKey>,
8989
nonce: U256,
9090
) -> Vec<Result<AlignedVerificationData, errors::SubmitError>> {
9191
let mut aligned_verification_data =
92-
submit_multiple(network, verification_data, max_fee, wallet, nonce).await;
92+
submit_multiple(network.clone(), verification_data, max_fee, wallet, nonce).await;
9393

9494
// TODO: open issue: use a join to .await all at the same time, avoiding the loop
9595
// And await only once per batch, no need to await multiple proofs if they are in the same batch.
9696
let mut error_awaiting_batch_verification: Option<errors::SubmitError> = None;
9797
for aligned_verification_data_item in aligned_verification_data.iter().flatten() {
9898
if let Err(e) =
99-
await_batch_verification(aligned_verification_data_item, eth_rpc_url, network).await
99+
await_batch_verification(aligned_verification_data_item, eth_rpc_url, network.clone())
100+
.await
100101
{
101102
error_awaiting_batch_verification = Some(e);
102103
break;
@@ -229,13 +230,13 @@ async fn fetch_gas_price(
229230
/// * `ProofQueueFlushed` if there is an error in the batcher and the proof queue is flushed.
230231
/// * `GenericError` if the error doesn't match any of the previous ones.
231232
pub async fn submit_multiple(
232-
network: &Network,
233+
network: Network,
233234
verification_data: &[VerificationData],
234235
max_fee: U256,
235236
wallet: Wallet<SigningKey>,
236237
nonce: U256,
237238
) -> Vec<Result<AlignedVerificationData, errors::SubmitError>> {
238-
let (ws_stream, _) = match connect_async(network.get_batcher_url()).await {
239+
let (ws_stream, _) = match connect_async(network.clone().get_batcher_url()).await {
239240
Ok((ws_stream, response)) => (ws_stream, response),
240241
Err(e) => return vec![Err(errors::SubmitError::WebSocketConnectionError(e))],
241242
};
@@ -262,7 +263,7 @@ pub async fn submit_multiple(
262263
async fn _submit_multiple(
263264
ws_write: Arc<Mutex<SplitSink<WebSocketStream<MaybeTlsStream<TcpStream>>, Message>>>,
264265
mut ws_read: SplitStream<WebSocketStream<MaybeTlsStream<TcpStream>>>,
265-
network: &Network,
266+
network: Network,
266267
verification_data: &[VerificationData],
267268
max_fee: U256,
268269
wallet: Wallet<SigningKey>,
@@ -350,7 +351,7 @@ async fn _submit_multiple(
350351
#[allow(clippy::too_many_arguments)] // TODO: Refactor this function, use NoncedVerificationData
351352
pub async fn submit_and_wait_verification(
352353
eth_rpc_url: &str,
353-
network: &Network,
354+
network: Network,
354355
verification_data: &VerificationData,
355356
max_fee: U256,
356357
wallet: Wallet<SigningKey>,
@@ -405,7 +406,7 @@ pub async fn submit_and_wait_verification(
405406
/// * `ProofQueueFlushed` if there is an error in the batcher and the proof queue is flushed.
406407
/// * `GenericError` if the error doesn't match any of the previous ones.
407408
pub async fn submit(
408-
network: &Network,
409+
network: Network,
409410
verification_data: &VerificationData,
410411
max_fee: U256,
411412
wallet: Wallet<SigningKey>,
@@ -441,7 +442,7 @@ pub async fn submit(
441442
/// * `HexDecodingError` if there is an error decoding the Aligned service manager contract address.
442443
pub async fn is_proof_verified(
443444
aligned_verification_data: &AlignedVerificationData,
444-
network: &Network,
445+
network: Network,
445446
eth_rpc_url: &str,
446447
) -> Result<bool, errors::VerificationError> {
447448
let eth_rpc_provider =
@@ -454,10 +455,10 @@ pub async fn is_proof_verified(
454455

455456
async fn _is_proof_verified(
456457
aligned_verification_data: &AlignedVerificationData,
457-
network: &Network,
458+
network: Network,
458459
eth_rpc_provider: Provider<Http>,
459460
) -> Result<bool, errors::VerificationError> {
460-
let contract_address = network.get_aligned_service_manager_address();
461+
let contract_address = network.clone().get_aligned_service_manager_address();
461462
let payment_service_addr = network.get_batcher_payment_service_address();
462463

463464
// All the elements from the merkle proof have to be concatenated
@@ -529,7 +530,7 @@ pub fn get_vk_commitment(
529530
/// # Errors
530531
/// * `EthRpcError` if the batcher has an error in the Ethereum call when retrieving the nonce if not already cached.
531532
pub async fn get_nonce_from_batcher(
532-
network: &Network,
533+
network: Network,
533534
address: Address,
534535
) -> Result<U256, GetNonceError> {
535536
let (ws_stream, _) = connect_async(network.get_batcher_url())
@@ -605,7 +606,7 @@ pub async fn get_nonce_from_batcher(
605606
pub async fn get_nonce_from_ethereum(
606607
eth_rpc_url: &str,
607608
submitter_addr: Address,
608-
network: &Network,
609+
network: Network,
609610
) -> Result<U256, GetNonceError> {
610611
let eth_rpc_provider = Provider::<Http>::try_from(eth_rpc_url)
611612
.map_err(|e| GetNonceError::EthRpcError(e.to_string()))?;

crates/task-sender/src/commands.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -318,17 +318,17 @@ pub async fn send_infinite_proofs(args: SendInfiniteProofsArgs) {
318318
let network: Network = args.network.into();
319319
info!("Starting senders!");
320320
for (i, sender) in senders.iter().enumerate() {
321+
// this clones are necessary because of the move
321322
let wallet = sender.wallet.clone();
322323
let verification_data = verification_data.clone();
323-
// this is necessary because of the move
324324
let network_clone = network.clone();
325325

326326
// a thread to send tasks from each loaded wallet:
327327
let handle = tokio::spawn(async move {
328328
loop {
329329
let n = network_clone.clone();
330330
let mut result = Vec::with_capacity(args.burst_size);
331-
let nonce = get_nonce_from_batcher(&n, wallet.address())
331+
let nonce = get_nonce_from_batcher(n.clone(), wallet.address())
332332
.await
333333
.inspect_err(|e| {
334334
error!(
@@ -347,11 +347,11 @@ pub async fn send_infinite_proofs(args: SendInfiniteProofsArgs) {
347347

348348
info!(
349349
"Sending {:?} Proofs to Aligned Batcher on {:?} from sender {}, nonce: {}, address: {:?}",
350-
args.burst_size, n.clone(), i, nonce, wallet.address(),
350+
args.burst_size, n, i, nonce, wallet.address(),
351351
);
352352

353353
let aligned_verification_data = submit_multiple(
354-
&n,
354+
n,
355355
&verification_data_to_send.clone(),
356356
max_fee,
357357
wallet.clone(),

0 commit comments

Comments
 (0)