Skip to content

Commit 216825d

Browse files
committed
feat(cli): get_first_nonce_in_queue
1 parent 05443b3 commit 216825d

File tree

1 file changed

+16
-21
lines changed

1 file changed

+16
-21
lines changed

batcher/aligned/src/main.rs

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ use aligned_sdk::core::{
1111
types::{AlignedVerificationData, Network, ProvingSystemId, VerificationData},
1212
};
1313
use aligned_sdk::sdk::get_chain_id;
14+
use aligned_sdk::sdk::get_first_nonce_in_queue_from_batcher;
1415
use aligned_sdk::sdk::get_nonce_from_batcher;
15-
use aligned_sdk::sdk::get_nonce_from_ethereum;
1616
use aligned_sdk::sdk::{deposit_to_aligned, get_balance_in_aligned};
1717
use aligned_sdk::sdk::{get_vk_commitment, is_proof_verified, save_response, submit_multiple};
1818
use clap::Parser;
@@ -29,7 +29,7 @@ use transaction::eip2718::TypedTransaction;
2929

3030
use crate::AlignedCommands::DepositToBatcher;
3131
use crate::AlignedCommands::GetUserBalance;
32-
use crate::AlignedCommands::GetUserFirstNonce;
32+
use crate::AlignedCommands::GetUserFirstNonceInBatcherQueue;
3333
use crate::AlignedCommands::GetUserNonce;
3434
use crate::AlignedCommands::GetVkCommitment;
3535
use crate::AlignedCommands::Submit;
@@ -61,10 +61,10 @@ pub enum AlignedCommands {
6161
#[clap(about = "Get user nonce from the batcher", name = "get-user-nonce")]
6262
GetUserNonce(GetUserNonceArgs),
6363
#[clap(
64-
about = "Get the first user nonce from ethereum",
65-
name = "get-user-first-nonce"
64+
about = "Returns the nonce of the proof with the lowest nonce inside the batcher queue for a given address. Useful when your proofs are stuck in the batcher due to a low fee and you need to bump them.",
65+
name = "get-user-first-nonce-in-batcher-queue"
6666
)]
67-
GetUserFirstNonce(GetUserFirstNonceArgs),
67+
GetUserFirstNonceInBatcherQueue(GetUserFirstNonceInBatcherQueueArgs),
6868
}
6969

7070
#[derive(Parser, Debug)]
@@ -227,25 +227,19 @@ pub struct GetUserNonceArgs {
227227

228228
#[derive(Parser, Debug)]
229229
#[command(version, about, long_about = None)]
230-
pub struct GetUserFirstNonceArgs {
231-
#[arg(
232-
name = "Ethereum RPC provider address",
233-
long = "rpc_url",
234-
default_value = "http://localhost:8545"
235-
)]
236-
eth_rpc_url: String,
230+
pub struct GetUserFirstNonceInBatcherQueueArgs {
237231
#[arg(
238232
name = "The user's Ethereum address",
239233
long = "user_addr",
240234
required = true
241235
)]
242236
address: String,
243237
#[arg(
244-
name = "The working network's name",
245-
long = "network",
246-
default_value = "devnet"
238+
name = "Batcher connection address",
239+
long = "batcher_url",
240+
default_value = "ws://localhost:8080"
247241
)]
248-
network: NetworkArg,
242+
batcher_url: String,
249243
}
250244

251245
#[derive(Debug, Clone, ValueEnum, Copy)]
@@ -558,13 +552,14 @@ async fn main() -> Result<(), AlignedError> {
558552
}
559553
}
560554
}
561-
GetUserFirstNonce(args) => {
555+
GetUserFirstNonceInBatcherQueue(args) => {
562556
let address = H160::from_str(&args.address).unwrap();
563-
let network = args.network.into();
564-
match get_nonce_from_ethereum(&args.eth_rpc_url, address, network).await {
557+
match get_first_nonce_in_queue_from_batcher(&args.batcher_url, address).await {
565558
Ok(nonce) => {
566-
let first_nonce = nonce + 1;
567-
info!("Nonce for address {} is {}", address, first_nonce);
559+
info!(
560+
"First nonce in batcher queue for address {} is {}",
561+
address, nonce
562+
);
568563
}
569564
Err(e) => {
570565
error!("Error while getting nonce: {:?}", e);

0 commit comments

Comments
 (0)