From 8b520f9c0bc3298d76369c66f261cdff6bf64461 Mon Sep 17 00:00:00 2001 From: PatStiles Date: Tue, 3 Dec 2024 19:11:39 -0300 Subject: [PATCH 01/16] derive batcher_url from network command if not provided --- batcher/aligned-sdk/src/core/constants.rs | 6 ++++++ batcher/aligned-sdk/src/core/types.rs | 14 +++++++++++++ batcher/aligned/src/main.rs | 24 +++++++++++++++++------ 3 files changed, 38 insertions(+), 6 deletions(-) diff --git a/batcher/aligned-sdk/src/core/constants.rs b/batcher/aligned-sdk/src/core/constants.rs index d45189000..43f92a2a8 100644 --- a/batcher/aligned-sdk/src/core/constants.rs +++ b/batcher/aligned-sdk/src/core/constants.rs @@ -37,3 +37,9 @@ pub const BUMP_MIN_RETRY_DELAY: u64 = 500; // milliseconds pub const BUMP_MAX_RETRIES: usize = 33; // ~ 1 day pub const BUMP_BACKOFF_FACTOR: f32 = 2.0; pub const BUMP_MAX_RETRY_DELAY: u64 = 3600; // seconds + +/// Batcher URL's +pub const BATCHER_URL_DEVNET: &str = "ws://localhost:8080"; +pub const BATCHER_URL_HOLESKY: &str = "wss://holesky.batcher.alignedlayer.com"; +pub const BATCHER_URL_HOLESKY_STAGE: &str = "wss://stage.batcher.alignedlayer.com"; +pub const BATCHER_URL_MAINNET: &str = "wss://batcher.alignedlayer.com"; diff --git a/batcher/aligned-sdk/src/core/types.rs b/batcher/aligned-sdk/src/core/types.rs index ab392df51..d344981b3 100644 --- a/batcher/aligned-sdk/src/core/types.rs +++ b/batcher/aligned-sdk/src/core/types.rs @@ -18,6 +18,8 @@ use lambdaworks_crypto::merkle_tree::{ use serde::{Deserialize, Serialize}; use sha3::{Digest, Keccak256}; +use super::constants::{BATCHER_URL_HOLESKY, BATCHER_URL_HOLESKY_STAGE, BATCHER_URL_DEVNET}; + use super::errors::VerifySignatureError; // VerificationData is a bytes32 instead of a VerificationData struct because in the BatcherPaymentService contract @@ -419,6 +421,18 @@ impl FromStr for Network { } } +impl Network { + + pub fn get_batcher_url(&self) -> &str { + match self { + Self::Devnet => BATCHER_URL_DEVNET, + Self::Holesky => BATCHER_URL_HOLESKY, + Self::HoleskyStage => BATCHER_URL_HOLESKY_STAGE, + } + } +} + + #[cfg(test)] mod tests { use ethers::signers::LocalWallet; diff --git a/batcher/aligned/src/main.rs b/batcher/aligned/src/main.rs index e8df5118b..fce5d5db4 100644 --- a/batcher/aligned/src/main.rs +++ b/batcher/aligned/src/main.rs @@ -66,9 +66,10 @@ pub struct SubmitArgs { #[arg( name = "Batcher connection address", long = "batcher_url", + required = false, default_value = "ws://localhost:8080" )] - batcher_url: String, + batcher_url: Option, #[arg( name = "Ethereum RPC provider connection address", long = "rpc_url", @@ -207,15 +208,23 @@ pub struct GetUserNonceArgs { #[arg( name = "Batcher connection address", long = "batcher_url", + required = false, default_value = "ws://localhost:8080" )] - batcher_url: String, + batcher_url: Option, #[arg( name = "The user's Ethereum address", long = "user_addr", required = true )] address: String, + #[arg( + name = "The working network's name", + long = "network", + required = true, + default_value = "devnet" + )] + network: NetworkArg, } #[derive(Debug, Clone, ValueEnum, Copy)] @@ -279,9 +288,10 @@ async fn main() -> Result<(), AlignedError> { let max_fee = U256::from_dec_str(&submit_args.max_fee).map_err(|_| SubmitError::InvalidMaxFee)?; + let network: Network = submit_args.network.into(); let repetitions = submit_args.repetitions; - let connect_addr = submit_args.batcher_url.clone(); + let batcher_url = submit_args.batcher_url.clone().unwrap_or(network.get_batcher_url().into()); let keystore_path = &submit_args.keystore_path; let private_key = &submit_args.private_key; @@ -321,7 +331,7 @@ async fn main() -> Result<(), AlignedError> { let nonce = match &submit_args.nonce { Some(nonce) => U256::from_dec_str(nonce).map_err(|_| SubmitError::InvalidNonce)?, - None => get_nonce_from_batcher(&connect_addr, wallet.address()) + None => get_nonce_from_batcher(&batcher_url, wallet.address()) .await .map_err(|e| match e { aligned_sdk::core::errors::GetNonceError::EthRpcError(e) => { @@ -355,7 +365,7 @@ async fn main() -> Result<(), AlignedError> { info!("Submitting proofs to the Aligned batcher..."); let aligned_verification_data_vec = submit_multiple( - &connect_addr, + &batcher_url, submit_args.network.into(), &verification_data_arr, max_fee, @@ -518,7 +528,9 @@ async fn main() -> Result<(), AlignedError> { } GetUserNonce(args) => { let address = H160::from_str(&args.address).unwrap(); - match get_nonce_from_batcher(&args.batcher_url, address).await { + let network: Network = args.network.into(); + let batcher_url = args.batcher_url.unwrap_or(network.get_batcher_url().into()); + match get_nonce_from_batcher(&batcher_url, address).await { Ok(nonce) => { info!("Nonce for address {} is {}", address, nonce); } From b5ea60327f7a3653328b92e0c9a5e8b242ab6025 Mon Sep 17 00:00:00 2001 From: PatStiles Date: Tue, 3 Dec 2024 19:13:41 -0300 Subject: [PATCH 02/16] add private key to DepositToBatcher --- batcher/aligned/src/main.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/batcher/aligned/src/main.rs b/batcher/aligned/src/main.rs index fce5d5db4..02351b7da 100644 --- a/batcher/aligned/src/main.rs +++ b/batcher/aligned/src/main.rs @@ -147,6 +147,8 @@ pub struct DepositToBatcherArgs { network: NetworkArg, #[arg(name = "Amount to deposit", long = "amount", required = true)] amount: String, + #[arg(name = "Private key", long = "private_key")] + private_key: Option, } #[derive(Parser, Debug)] @@ -480,6 +482,10 @@ async fn main() -> Result<(), AlignedError> { .map_err(|e| SubmitError::GenericError(e.to_string()))?; Wallet::decrypt_keystore(keystore_path, password) .map_err(|e| SubmitError::GenericError(e.to_string()))? + } else if let Some(private_key) = private_key { + private_key + .parse::() + .map_err(|e| SubmitError::GenericError(e.to_string()))? } else { warn!("Missing keystore used for payment."); return Ok(()); From e3bad09334cfe116951cda5d4ed137dec766ecca Mon Sep 17 00:00:00 2001 From: PatStiles Date: Wed, 4 Dec 2024 10:56:09 -0300 Subject: [PATCH 03/16] add "Funds have not been spent declaration" to error messages. --- .../src/communication/messaging.rs | 36 +++++++++---------- batcher/aligned/src/main.rs | 2 +- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/batcher/aligned-sdk/src/communication/messaging.rs b/batcher/aligned-sdk/src/communication/messaging.rs index 7f3ad921c..426a3ea34 100644 --- a/batcher/aligned-sdk/src/communication/messaging.rs +++ b/batcher/aligned-sdk/src/communication/messaging.rs @@ -175,41 +175,41 @@ async fn handle_batcher_response(msg: Message) -> Result { - error!("Batcher responded with invalid nonce"); + error!("Batcher responded with invalid nonce. Funds have not been spent."); Err(SubmitError::InvalidNonce) } Ok(SubmitProofResponseMessage::InvalidSignature) => { - error!("Batcher responded with invalid signature"); + error!("Batcher responded with invalid signature. Funds have not been spent."); Err(SubmitError::InvalidSignature) } Ok(SubmitProofResponseMessage::ProofTooLarge) => { - error!("Batcher responded with proof too large"); + error!("Batcher responded with proof too large. Funds have not been spent."); Err(SubmitError::ProofTooLarge) } Ok(SubmitProofResponseMessage::InvalidMaxFee) => { - error!("Batcher responded with invalid max fee"); + error!("Batcher responded with invalid max fee. Funds have not been spent."); Err(SubmitError::InvalidMaxFee) } Ok(SubmitProofResponseMessage::InsufficientBalance(addr)) => { - error!("Batcher responded with insufficient balance"); + error!("Batcher responded with insufficient balance. Funds have not been spent."); Err(SubmitError::InsufficientBalance(addr)) } Ok(SubmitProofResponseMessage::InvalidChainId) => { - error!("Batcher responded with invalid chain id"); + error!("Batcher responded with invalid chain id. Funds have not been spent."); Err(SubmitError::InvalidChainId) } Ok(SubmitProofResponseMessage::InvalidReplacementMessage) => { - error!("Batcher responded with invalid replacement message"); + error!("Batcher responded with invalid replacement message. Funds have not been spent."); Err(SubmitError::InvalidReplacementMessage) } Ok(SubmitProofResponseMessage::AddToBatchError) => { - error!("Batcher responded with add to batch error"); + error!("Batcher responded with add to batch error. Funds have not been spent."); Err(SubmitError::AddToBatchError) } Ok(SubmitProofResponseMessage::EthRpcError) => { - error!("Batcher experienced Eth RPC connection error"); + error!("Batcher experienced Eth RPC connection error. Funds have not been spent."); Err(SubmitError::EthereumProviderError( - "Batcher experienced Eth RPC connection error".to_string(), + "Batcher experienced Eth RPC connection error. Funds have not been spent.".to_string(), )) } Ok(SubmitProofResponseMessage::InvalidPaymentServiceAddress( @@ -217,7 +217,7 @@ async fn handle_batcher_response(msg: Message) -> Result { error!( - "Batcher responded with invalid payment service address: {:?}, expected: {:?}", + "Batcher responded with invalid payment service address: {:?}, expected: {:?}. Funds have not been spent.", received_addr, expected_addr ); Err(SubmitError::InvalidPaymentServiceAddress( @@ -226,11 +226,11 @@ async fn handle_batcher_response(msg: Message) -> Result { - error!("Batcher responded with invalid proof: {}", reason); + error!("Batcher responded with invalid proof: {}. Funds have not been spent.", reason); Err(SubmitError::InvalidProof(reason)) } Ok(SubmitProofResponseMessage::CreateNewTaskError(merkle_root, error)) => { - error!("Batcher responded with create new task error: {}", error); + error!("Batcher responded with create new task error: {}. Funds have not been spent.", error); Err(SubmitError::BatchSubmissionFailed( "Could not create task with merkle root ".to_owned() + &merkle_root @@ -239,22 +239,22 @@ async fn handle_batcher_response(msg: Message) -> Result { - error!("Batcher responded with protocol version instead of batch inclusion data"); + error!("Batcher responded with protocol version instead of batch inclusion data. Funds have not been spent."); Err(SubmitError::UnexpectedBatcherResponse( - "Batcher responded with protocol version instead of batch inclusion data" + "Batcher responded with protocol version instead of batch inclusion data. Funds have not been spent." .to_string(), )) } Ok(SubmitProofResponseMessage::BatchReset) => { - error!("Batcher responded with batch reset"); + error!("Batcher responded with batch reset. Funds have not been spent."); Err(SubmitError::ProofQueueFlushed) } Ok(SubmitProofResponseMessage::Error(e)) => { - error!("Batcher responded with error: {}", e); + error!("Batcher responded with error: {}. Funds have not been spent.", e); Err(SubmitError::GenericError(e)) } Err(e) => { - error!("Error while deserializing batch inclusion data: {}", e); + error!("Error while deserializing batch inclusion data: {}. Funds have not been spent.", e); Err(SubmitError::SerializationError(e)) } } diff --git a/batcher/aligned/src/main.rs b/batcher/aligned/src/main.rs index 02351b7da..7050abc1d 100644 --- a/batcher/aligned/src/main.rs +++ b/batcher/aligned/src/main.rs @@ -615,7 +615,7 @@ async fn handle_submit_err(err: SubmitError) { error!("Invalid nonce. try again"); } SubmitError::ProofQueueFlushed => { - error!("Batch was reset. try resubmitting the proof"); + error!("Batch was reset, user funds have not been spent, try resubmitting the proof"); } SubmitError::InvalidProof(reason) => error!("Submitted proof is invalid: {}", reason), SubmitError::InsufficientBalance(sender_address) => { From bca6e3c036aeafac2ec75e0b2a3b4775a615ee9a Mon Sep 17 00:00:00 2001 From: PatStiles Date: Wed, 4 Dec 2024 11:44:31 -0300 Subject: [PATCH 04/16] fmt + clippy --- .../src/communication/messaging.rs | 27 ++++++++++++++----- batcher/aligned-sdk/src/core/types.rs | 4 +-- batcher/aligned/src/main.rs | 6 ++++- 3 files changed, 27 insertions(+), 10 deletions(-) diff --git a/batcher/aligned-sdk/src/communication/messaging.rs b/batcher/aligned-sdk/src/communication/messaging.rs index 426a3ea34..f71486c46 100644 --- a/batcher/aligned-sdk/src/communication/messaging.rs +++ b/batcher/aligned-sdk/src/communication/messaging.rs @@ -199,7 +199,9 @@ async fn handle_batcher_response(msg: Message) -> Result { - error!("Batcher responded with invalid replacement message. Funds have not been spent."); + error!( + "Batcher responded with invalid replacement message. Funds have not been spent." + ); Err(SubmitError::InvalidReplacementMessage) } Ok(SubmitProofResponseMessage::AddToBatchError) => { @@ -209,7 +211,8 @@ async fn handle_batcher_response(msg: Message) -> Result { error!("Batcher experienced Eth RPC connection error. Funds have not been spent."); Err(SubmitError::EthereumProviderError( - "Batcher experienced Eth RPC connection error. Funds have not been spent.".to_string(), + "Batcher experienced Eth RPC connection error. Funds have not been spent." + .to_string(), )) } Ok(SubmitProofResponseMessage::InvalidPaymentServiceAddress( @@ -226,11 +229,17 @@ async fn handle_batcher_response(msg: Message) -> Result { - error!("Batcher responded with invalid proof: {}. Funds have not been spent.", reason); + error!( + "Batcher responded with invalid proof: {}. Funds have not been spent.", + reason + ); Err(SubmitError::InvalidProof(reason)) } Ok(SubmitProofResponseMessage::CreateNewTaskError(merkle_root, error)) => { - error!("Batcher responded with create new task error: {}. Funds have not been spent.", error); + error!( + "Batcher responded with create new task error: {}. Funds have not been spent.", + error + ); Err(SubmitError::BatchSubmissionFailed( "Could not create task with merkle root ".to_owned() + &merkle_root @@ -250,11 +259,17 @@ async fn handle_batcher_response(msg: Message) -> Result { - error!("Batcher responded with error: {}. Funds have not been spent.", e); + error!( + "Batcher responded with error: {}. Funds have not been spent.", + e + ); Err(SubmitError::GenericError(e)) } Err(e) => { - error!("Error while deserializing batch inclusion data: {}. Funds have not been spent.", e); + error!( + "Error while deserializing batch inclusion data: {}. Funds have not been spent.", + e + ); Err(SubmitError::SerializationError(e)) } } diff --git a/batcher/aligned-sdk/src/core/types.rs b/batcher/aligned-sdk/src/core/types.rs index d344981b3..322d0267d 100644 --- a/batcher/aligned-sdk/src/core/types.rs +++ b/batcher/aligned-sdk/src/core/types.rs @@ -18,7 +18,7 @@ use lambdaworks_crypto::merkle_tree::{ use serde::{Deserialize, Serialize}; use sha3::{Digest, Keccak256}; -use super::constants::{BATCHER_URL_HOLESKY, BATCHER_URL_HOLESKY_STAGE, BATCHER_URL_DEVNET}; +use super::constants::{BATCHER_URL_DEVNET, BATCHER_URL_HOLESKY, BATCHER_URL_HOLESKY_STAGE}; use super::errors::VerifySignatureError; @@ -422,7 +422,6 @@ impl FromStr for Network { } impl Network { - pub fn get_batcher_url(&self) -> &str { match self { Self::Devnet => BATCHER_URL_DEVNET, @@ -432,7 +431,6 @@ impl Network { } } - #[cfg(test)] mod tests { use ethers::signers::LocalWallet; diff --git a/batcher/aligned/src/main.rs b/batcher/aligned/src/main.rs index 7050abc1d..38bb46cb4 100644 --- a/batcher/aligned/src/main.rs +++ b/batcher/aligned/src/main.rs @@ -293,7 +293,10 @@ async fn main() -> Result<(), AlignedError> { let network: Network = submit_args.network.into(); let repetitions = submit_args.repetitions; - let batcher_url = submit_args.batcher_url.clone().unwrap_or(network.get_batcher_url().into()); + let batcher_url = submit_args + .batcher_url + .clone() + .unwrap_or(network.get_batcher_url().into()); let keystore_path = &submit_args.keystore_path; let private_key = &submit_args.private_key; @@ -476,6 +479,7 @@ async fn main() -> Result<(), AlignedError> { })?; let keystore_path = &deposit_to_batcher_args.keystore_path; + let private_key = &deposit_to_batcher_args.private_key; let mut wallet = if let Some(keystore_path) = keystore_path { let password = rpassword::prompt_password("Please enter your keystore password:") From 2e8465ca4791c7022d4356fe8f61f97bd7ee43d3 Mon Sep 17 00:00:00 2001 From: Marcos Nicolau Date: Wed, 4 Dec 2024 17:37:40 -0300 Subject: [PATCH 05/16] refactor(cli): remove batcher url option --- batcher/aligned/src/main.rs | 33 ++++++++------------------------- 1 file changed, 8 insertions(+), 25 deletions(-) diff --git a/batcher/aligned/src/main.rs b/batcher/aligned/src/main.rs index 38bb46cb4..455945360 100644 --- a/batcher/aligned/src/main.rs +++ b/batcher/aligned/src/main.rs @@ -63,13 +63,6 @@ pub enum AlignedCommands { #[derive(Parser, Debug)] #[command(version, about, long_about = None)] pub struct SubmitArgs { - #[arg( - name = "Batcher connection address", - long = "batcher_url", - required = false, - default_value = "ws://localhost:8080" - )] - batcher_url: Option, #[arg( name = "Ethereum RPC provider connection address", long = "rpc_url", @@ -127,11 +120,7 @@ pub struct SubmitArgs { #[derive(Parser, Debug)] #[command(version, about, long_about = None)] pub struct DepositToBatcherArgs { - #[arg( - name = "Path to local keystore", - long = "keystore_path", - required = true - )] + #[arg(name = "Path to local keystore", long = "keystore_path")] keystore_path: Option, #[arg( name = "Ethereum RPC provider address", @@ -207,13 +196,6 @@ pub struct GetUserBalanceArgs { #[derive(Parser, Debug)] #[command(version, about, long_about = None)] pub struct GetUserNonceArgs { - #[arg( - name = "Batcher connection address", - long = "batcher_url", - required = false, - default_value = "ws://localhost:8080" - )] - batcher_url: Option, #[arg( name = "The user's Ethereum address", long = "user_addr", @@ -293,10 +275,7 @@ async fn main() -> Result<(), AlignedError> { let network: Network = submit_args.network.into(); let repetitions = submit_args.repetitions; - let batcher_url = submit_args - .batcher_url - .clone() - .unwrap_or(network.get_batcher_url().into()); + let batcher_url = network.get_batcher_url(); let keystore_path = &submit_args.keystore_path; let private_key = &submit_args.private_key; @@ -482,6 +461,10 @@ async fn main() -> Result<(), AlignedError> { let private_key = &deposit_to_batcher_args.private_key; let mut wallet = if let Some(keystore_path) = keystore_path { + if private_key.is_some() { + error!("Conflicting inputs detected: Both a keystore and a private key were provided. Provide only one option to proceed."); + return Ok(()); + } let password = rpassword::prompt_password("Please enter your keystore password:") .map_err(|e| SubmitError::GenericError(e.to_string()))?; Wallet::decrypt_keystore(keystore_path, password) @@ -491,7 +474,7 @@ async fn main() -> Result<(), AlignedError> { .parse::() .map_err(|e| SubmitError::GenericError(e.to_string()))? } else { - warn!("Missing keystore used for payment."); + warn!("Missing keystore or private key used for payment."); return Ok(()); }; @@ -539,7 +522,7 @@ async fn main() -> Result<(), AlignedError> { GetUserNonce(args) => { let address = H160::from_str(&args.address).unwrap(); let network: Network = args.network.into(); - let batcher_url = args.batcher_url.unwrap_or(network.get_batcher_url().into()); + let batcher_url = network.get_batcher_url(); match get_nonce_from_batcher(&batcher_url, address).await { Ok(nonce) => { info!("Nonce for address {} is {}", address, nonce); From 889c6bdfecfed34a90d4e8ab7ab85502c61be4d1 Mon Sep 17 00:00:00 2001 From: Marcos Nicolau Date: Wed, 4 Dec 2024 17:40:18 -0300 Subject: [PATCH 06/16] chore: address clippy warnings --- batcher/aligned/src/main.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/batcher/aligned/src/main.rs b/batcher/aligned/src/main.rs index 455945360..5750fca91 100644 --- a/batcher/aligned/src/main.rs +++ b/batcher/aligned/src/main.rs @@ -315,7 +315,7 @@ async fn main() -> Result<(), AlignedError> { let nonce = match &submit_args.nonce { Some(nonce) => U256::from_dec_str(nonce).map_err(|_| SubmitError::InvalidNonce)?, - None => get_nonce_from_batcher(&batcher_url, wallet.address()) + None => get_nonce_from_batcher(batcher_url, wallet.address()) .await .map_err(|e| match e { aligned_sdk::core::errors::GetNonceError::EthRpcError(e) => { @@ -349,7 +349,7 @@ async fn main() -> Result<(), AlignedError> { info!("Submitting proofs to the Aligned batcher..."); let aligned_verification_data_vec = submit_multiple( - &batcher_url, + batcher_url, submit_args.network.into(), &verification_data_arr, max_fee, @@ -523,7 +523,7 @@ async fn main() -> Result<(), AlignedError> { let address = H160::from_str(&args.address).unwrap(); let network: Network = args.network.into(); let batcher_url = network.get_batcher_url(); - match get_nonce_from_batcher(&batcher_url, address).await { + match get_nonce_from_batcher(batcher_url, address).await { Ok(nonce) => { info!("Nonce for address {} is {}", address, nonce); } From 475dc546a471582c04f1a7e06ac123b63cbec848 Mon Sep 17 00:00:00 2001 From: Marcos Nicolau Date: Wed, 4 Dec 2024 17:46:26 -0300 Subject: [PATCH 07/16] refactor(sdk): remove batcher_url --- batcher/aligned-sdk/src/sdk.rs | 45 +++++++++------------------------- batcher/aligned/src/main.rs | 7 ++---- 2 files changed, 14 insertions(+), 38 deletions(-) diff --git a/batcher/aligned-sdk/src/sdk.rs b/batcher/aligned-sdk/src/sdk.rs index a9a0ad5a0..eac93ab48 100644 --- a/batcher/aligned-sdk/src/sdk.rs +++ b/batcher/aligned-sdk/src/sdk.rs @@ -49,7 +49,6 @@ use std::path::PathBuf; /// Submits multiple proofs to the batcher to be verified in Aligned and waits for the verification on-chain. /// # Arguments -/// * `batcher_url` - The url of the batcher to which the proof will be submitted. /// * `eth_rpc_url` - The URL of the Ethereum RPC node. /// * `chain` - The chain on which the verification will be done. /// * `verification_data` - An array of verification data of each proof. @@ -79,7 +78,6 @@ use std::path::PathBuf; /// * `GenericError` if the error doesn't match any of the previous ones. #[allow(clippy::too_many_arguments)] // TODO: Refactor this function, use NoncedVerificationData pub async fn submit_multiple_and_wait_verification( - batcher_url: &str, eth_rpc_url: &str, network: Network, verification_data: &[VerificationData], @@ -87,15 +85,8 @@ pub async fn submit_multiple_and_wait_verification( wallet: Wallet, nonce: U256, ) -> Vec> { - let mut aligned_verification_data = submit_multiple( - batcher_url, - network, - verification_data, - max_fee, - wallet, - nonce, - ) - .await; + let mut aligned_verification_data = + submit_multiple(network, verification_data, max_fee, wallet, nonce).await; // TODO: open issue: use a join to .await all at the same time, avoiding the loop // And await only once per batch, no need to await multiple proofs if they are in the same batch. @@ -218,7 +209,6 @@ async fn fetch_gas_price( /// Submits multiple proofs to the batcher to be verified in Aligned. /// # Arguments -/// * `batcher_url` - The url of the batcher to which the proof will be submitted. /// * `network` - The netork on which the verification will be done. /// * `verification_data` - An array of verification data of each proof. /// * `max_fees` - An array of the maximum fee that the submitter is willing to pay for each proof verification. @@ -242,14 +232,13 @@ async fn fetch_gas_price( /// * `ProofQueueFlushed` if there is an error in the batcher and the proof queue is flushed. /// * `GenericError` if the error doesn't match any of the previous ones. pub async fn submit_multiple( - batcher_url: &str, network: Network, verification_data: &[VerificationData], max_fee: U256, wallet: Wallet, nonce: U256, ) -> Vec> { - let (ws_stream, _) = match connect_async(batcher_url).await { + let (ws_stream, _) = match connect_async(network.get_batcher_url()).await { Ok((ws_stream, response)) => (ws_stream, response), Err(e) => return vec![Err(errors::SubmitError::WebSocketConnectionError(e))], }; @@ -352,7 +341,6 @@ async fn _submit_multiple( /// Submits a proof to the batcher to be verified in Aligned and waits for the verification on-chain. /// # Arguments -/// * `batcher_url` - The url of the batcher to which the proof will be submitted. /// * `eth_rpc_url` - The URL of the Ethereum RPC node. /// * `chain` - The chain on which the verification will be done. /// * `verification_data` - The verification data of the proof. @@ -382,7 +370,6 @@ async fn _submit_multiple( /// * `GenericError` if the error doesn't match any of the previous ones. #[allow(clippy::too_many_arguments)] // TODO: Refactor this function, use NoncedVerificationData pub async fn submit_and_wait_verification( - batcher_url: &str, eth_rpc_url: &str, network: Network, verification_data: &VerificationData, @@ -393,7 +380,6 @@ pub async fn submit_and_wait_verification( let verification_data = vec![verification_data.clone()]; let aligned_verification_data = submit_multiple_and_wait_verification( - batcher_url, eth_rpc_url, network, &verification_data, @@ -414,7 +400,6 @@ pub async fn submit_and_wait_verification( /// Submits a proof to the batcher to be verified in Aligned. /// # Arguments -/// * `batcher_url` - The url of the batcher to which the proof will be submitted. /// * `chain` - The chain on which the verification will be done. /// * `verification_data` - The verification data of the proof. /// * `max_fee` - The maximum fee that the submitter is willing to pay for the verification. @@ -438,7 +423,6 @@ pub async fn submit_and_wait_verification( /// * `ProofQueueFlushed` if there is an error in the batcher and the proof queue is flushed. /// * `GenericError` if the error doesn't match any of the previous ones. pub async fn submit( - batcher_url: &str, network: Network, verification_data: &VerificationData, max_fee: U256, @@ -447,15 +431,8 @@ pub async fn submit( ) -> Result { let verification_data = vec![verification_data.clone()]; - let aligned_verification_data = submit_multiple( - batcher_url, - network, - &verification_data, - max_fee, - wallet, - nonce, - ) - .await; + let aligned_verification_data = + submit_multiple(network, &verification_data, max_fee, wallet, nonce).await; match aligned_verification_data.first() { Some(Ok(aligned_verification_data)) => Ok(aligned_verification_data.clone()), @@ -556,19 +533,21 @@ pub fn get_vk_commitment( /// as the batcher proofs might not yet be on ethereum, /// producing an out-of-sync nonce with the payment service contract on ethereum /// # Arguments -/// * `batcher_url` - The batcher websocket url. /// * `address` - The user address for which the nonce will be retrieved. +/// * `network` - The network from which the nonce will be retrieved. /// # Returns /// * The next nonce of the proof submitter account. /// # Errors /// * `EthRpcError` if the batcher has an error in the Ethereum call when retrieving the nonce if not already cached. pub async fn get_nonce_from_batcher( - batcher_ws_url: &str, address: Address, + network: Network, ) -> Result { - let (ws_stream, _) = connect_async(batcher_ws_url).await.map_err(|_| { - GetNonceError::ConnectionFailed("Ws connection to batcher failed".to_string()) - })?; + let (ws_stream, _) = connect_async(network.get_batcher_url()) + .await + .map_err(|_| { + GetNonceError::ConnectionFailed("Ws connection to batcher failed".to_string()) + })?; debug!("WebSocket handshake has been successfully completed"); let (mut ws_write, mut ws_read) = ws_stream.split(); diff --git a/batcher/aligned/src/main.rs b/batcher/aligned/src/main.rs index 5750fca91..5298c2ac3 100644 --- a/batcher/aligned/src/main.rs +++ b/batcher/aligned/src/main.rs @@ -275,7 +275,6 @@ async fn main() -> Result<(), AlignedError> { let network: Network = submit_args.network.into(); let repetitions = submit_args.repetitions; - let batcher_url = network.get_batcher_url(); let keystore_path = &submit_args.keystore_path; let private_key = &submit_args.private_key; @@ -315,7 +314,7 @@ async fn main() -> Result<(), AlignedError> { let nonce = match &submit_args.nonce { Some(nonce) => U256::from_dec_str(nonce).map_err(|_| SubmitError::InvalidNonce)?, - None => get_nonce_from_batcher(batcher_url, wallet.address()) + None => get_nonce_from_batcher(wallet.address(), network) .await .map_err(|e| match e { aligned_sdk::core::errors::GetNonceError::EthRpcError(e) => { @@ -349,7 +348,6 @@ async fn main() -> Result<(), AlignedError> { info!("Submitting proofs to the Aligned batcher..."); let aligned_verification_data_vec = submit_multiple( - batcher_url, submit_args.network.into(), &verification_data_arr, max_fee, @@ -522,8 +520,7 @@ async fn main() -> Result<(), AlignedError> { GetUserNonce(args) => { let address = H160::from_str(&args.address).unwrap(); let network: Network = args.network.into(); - let batcher_url = network.get_batcher_url(); - match get_nonce_from_batcher(batcher_url, address).await { + match get_nonce_from_batcher(address, network).await { Ok(nonce) => { info!("Nonce for address {} is {}", address, nonce); } From c54efd1398e2c1e60a22b9f14a0e5ee4b2b07241 Mon Sep 17 00:00:00 2001 From: Marcos Nicolau Date: Wed, 4 Dec 2024 17:49:59 -0300 Subject: [PATCH 08/16] refactor(task-sender): remove batcher_url --- batcher/aligned-task-sender/src/commands.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/batcher/aligned-task-sender/src/commands.rs b/batcher/aligned-task-sender/src/commands.rs index f074b9156..15a5e06dd 100644 --- a/batcher/aligned-task-sender/src/commands.rs +++ b/batcher/aligned-task-sender/src/commands.rs @@ -317,7 +317,7 @@ pub async fn send_infinite_proofs(args: SendInfiniteProofsArgs) { info!("Starting senders!"); for (i, sender) in senders.iter().enumerate() { // this is necessary because of the move - let batcher_url = args.batcher_url.clone(); + let network = args.network.into(); let wallet = sender.wallet.clone(); let verification_data = verification_data.clone(); @@ -325,7 +325,7 @@ pub async fn send_infinite_proofs(args: SendInfiniteProofsArgs) { let handle = tokio::spawn(async move { loop { let mut result = Vec::with_capacity(args.burst_size); - let nonce = get_nonce_from_batcher(&batcher_url, wallet.address()) + let nonce = get_nonce_from_batcher(wallet.address(), network) .await .inspect_err(|e| { error!( @@ -346,11 +346,9 @@ pub async fn send_infinite_proofs(args: SendInfiniteProofsArgs) { "Sending {:?} Proofs to Aligned Batcher on {:?} from sender {}, nonce: {}, address: {:?}", args.burst_size, args.network, i, nonce, wallet.address(), ); - let batcher_url = batcher_url.clone(); let aligned_verification_data = submit_multiple( - &batcher_url.clone(), - args.network.into(), + network, &verification_data_to_send.clone(), max_fee, wallet.clone(), From af712afd51b33edbc002a5a6a3601fc7b483a9ad Mon Sep 17 00:00:00 2001 From: Marcos Nicolau Date: Wed, 4 Dec 2024 18:13:01 -0300 Subject: [PATCH 09/16] refactor(task-sender): remove batcher_url --- batcher/aligned-task-sender/src/commands.rs | 7 ++----- batcher/aligned-task-sender/src/structs.rs | 14 ++++---------- 2 files changed, 6 insertions(+), 15 deletions(-) diff --git a/batcher/aligned-task-sender/src/commands.rs b/batcher/aligned-task-sender/src/commands.rs index 15a5e06dd..b26323afd 100644 --- a/batcher/aligned-task-sender/src/commands.rs +++ b/batcher/aligned-task-sender/src/commands.rs @@ -211,16 +211,13 @@ pub async fn generate_and_fund_wallets(args: GenerateAndFundWalletsArgs) { /// infinitely hangs connections pub async fn test_connection(args: TestConnectionsArgs) { - if args.batcher_url == "wss://batcher.alignedlayer.com" { - error!("Network not supported by the connection tester"); - return; - } info!("Going to only open a connection"); let mut handlers = vec![]; for i in 0..args.num_senders { - let ws_url = args.batcher_url.clone(); + let network: Network = args.network.into(); let handle = tokio::spawn(async move { + let ws_url = network.get_batcher_url(); let conn = connect_async(ws_url).await; if let Ok((mut ws_stream, _)) = conn { info!("Opened connection for {}", i); diff --git a/batcher/aligned-task-sender/src/structs.rs b/batcher/aligned-task-sender/src/structs.rs index a1c449f72..fcd34142c 100644 --- a/batcher/aligned-task-sender/src/structs.rs +++ b/batcher/aligned-task-sender/src/structs.rs @@ -89,11 +89,11 @@ pub struct GenerateAndFundWalletsArgs { #[command(version, about, long_about = None)] pub struct TestConnectionsArgs { #[arg( - name = "Batcher connection address", - long = "batcher-url", - default_value = "ws://localhost:8080" + name = "The Ethereum network's name", + long = "network", + default_value = "devnet" )] - pub batcher_url: String, + pub network: NetworkArg, #[arg( name = "Number of spawned sockets", long = "num-senders", @@ -111,12 +111,6 @@ pub struct SendInfiniteProofsArgs { default_value = "http://localhost:8545" )] pub eth_rpc_url: String, - #[arg( - name = "Batcher connection address", - long = "batcher-url", - default_value = "ws://localhost:8080" - )] - pub batcher_url: String, #[arg( name = "Number of proofs per burst", long = "burst-size", From 4b62c298b37fdd3bb9a0e32aceb78c7c5418cb28 Mon Sep 17 00:00:00 2001 From: Marcos Nicolau Date: Wed, 4 Dec 2024 18:17:49 -0300 Subject: [PATCH 10/16] docs: remove batcher_url references --- batcher/aligned-task-sender/README.md | 2 -- docs/1_introduction/1_try_aligned.md | 1 - docs/3_guides/0_submitting_proofs.md | 9 --------- docs/3_guides/1.2_SDK_api_reference.md | 14 +++----------- docs/3_guides/1_SDK_how_to.md | 3 --- .../2_build_your_first_aligned_application.md | 1 - docs/3_guides/4_generating_proofs.md | 3 --- docs/3_guides/6_setup_aligned.md | 1 - 8 files changed, 3 insertions(+), 31 deletions(-) diff --git a/batcher/aligned-task-sender/README.md b/batcher/aligned-task-sender/README.md index 73b1df868..fdf49195d 100644 --- a/batcher/aligned-task-sender/README.md +++ b/batcher/aligned-task-sender/README.md @@ -61,7 +61,6 @@ To run it, you can: cargo run --release -- send-infinite-proofs \ --burst-size --burst-time-secs \ --eth-rpc-url \ - --batcher-url \ --network holesky-stage \ --proofs-dirpath $(PWD)/scripts/test_files/task_sender/proofs \ --private-keys-filepath @@ -82,7 +81,6 @@ This command enables and hangs N connections with the Batcher. To run it, you can: ``` cargo run --release -- test-connections \ - --batcher-url \ --num-senders ``` diff --git a/docs/1_introduction/1_try_aligned.md b/docs/1_introduction/1_try_aligned.md index 6a317ed89..520d8766b 100644 --- a/docs/1_introduction/1_try_aligned.md +++ b/docs/1_introduction/1_try_aligned.md @@ -29,7 +29,6 @@ aligned submit \ --proof ~/.aligned/test_files/sp1_fibonacci.proof \ --vm_program ~/.aligned/test_files/sp1_fibonacci.elf \ --aligned_verification_data_path ~/.aligned/aligned_verification_data \ ---batcher_url wss://batcher.alignedlayer.com \ --network holesky \ --rpc_url https://ethereum-holesky-rpc.publicnode.com ``` diff --git a/docs/3_guides/0_submitting_proofs.md b/docs/3_guides/0_submitting_proofs.md index 26bb58555..40fe63889 100644 --- a/docs/3_guides/0_submitting_proofs.md +++ b/docs/3_guides/0_submitting_proofs.md @@ -107,7 +107,6 @@ Proof submission is done via the `submit` command of the Aligned CLI. The argume * `proof`: The path of the proof associated to the computation to be verified. * `vm_program`: When the proving system involves the execution of a program in a zkVM, this argument is associated with the compiled program or some other identifier of the program. * `pub_input`: The path to the file with the public input associated with the proof. -* `batcher_url`: The batcher websocket URL. * `network` to specify the netowrk to be used. Can be `devnet`, `holesky-stage` or `holesky`. * `rpc_url`: The RPC Ethereum node URL. * `proof_generator_addr`: An optional parameter that can be used in some applications to avoid front-running. @@ -125,7 +124,6 @@ aligned submit \ --proving_system SP1 \ --proof \ --vm_program \ ---batcher_url wss://batcher.alignedlayer.com \ --proof_generator_addr [proof_generator_addr] \ --batch_inclusion_data_directory_path [batch_inclusion_data_directory_path] \ --keystore_path \ @@ -141,7 +139,6 @@ aligned submit \ --proving_system SP1 \ --proof ./scripts/test_files/sp1/sp1_fibonacci.proof \ --vm_program ./scripts/test_files/sp1/sp1_fibonacci.elf \ ---batcher_url wss://batcher.alignedlayer.com \ --keystore_path ~/.aligned_keystore/keystore0 \ --network holesky \ --rpc_url https://ethereum-holesky-rpc.publicnode.com @@ -160,7 +157,6 @@ aligned submit \ --proof \ --vm_program \ --pub_input \ ---batcher_url wss://batcher.alignedlayer.com \ --proof_generator_addr [proof_generator_addr] \ --batch_inclusion_data_directory_path [batch_inclusion_data_directory_path] \ --keystore_path \ @@ -188,7 +184,6 @@ aligned submit \ --proof ./scripts/test_files/risc_zero/fibonacci_proof_generator/risc_zero_fibonacci.proof \ --vm_program ./scripts/test_files/risc_zero/fibonacci_proof_generator/fibonacci_id.bin \ --public_input ./scripts/test_files/risc_zero/fibonacci_proof_generator/risc_zero_fibonacci.pub \ ---batcher_url wss://batcher.alignedlayer.com \ --aligned_verification_data_path ~/.aligned/aligned_verification_data \ --keystore_path ~/.aligned_keystore/keystore0 \ --network holesky \ @@ -206,7 +201,6 @@ aligned submit \ --proof \ --public_input \ --vk \ ---batcher_url wss://batcher.alignedlayer.com \ --proof_generator_addr [proof_generator_addr] \ --batch_inclusion_data_directory_path [batch_inclusion_data_directory_path] \ --keystore_path \ @@ -223,7 +217,6 @@ aligned submit \ --proof ./scripts/test_files/gnark_plonk_bn254_script/plonk.proof \ --public_input ./scripts/test_files/gnark_plonk_bn254_script/plonk_pub_input.pub \ --vk ./scripts/test_files/gnark_plonk_bn254_script/plonk.vk \ ---batcher_url wss://batcher.alignedlayer.com \ --keystore_path ~/.aligned_keystore/keystore0 \ --network holesky \ --rpc_url https://ethereum-holesky-rpc.publicnode.com @@ -236,7 +229,6 @@ aligned submit \ --proof ./scripts/test_files/gnark_plonk_bls12_381_script/plonk.proof \ --public_input ./scripts/test_files/gnark_plonk_bls12_381_script/plonk_pub_input.pub \ --vk ./scripts/test_files/gnark_plonk_bls12_381_script/plonk.vk \ ---batcher_url wss://batcher.alignedlayer.com \ --keystore_path ~/.aligned_keystore/keystore0 \ --network holesky \ --rpc_url https://ethereum-holesky-rpc.publicnode.com @@ -249,7 +241,6 @@ aligned submit \ --proof ./scripts/test_files/gnark_groth16_bn254_infinite_script/infinite_proofs/ineq_1_groth16.proof \ --public_input ./scripts/test_files/gnark_groth16_bn254_infinite_script/infinite_proofs/ineq_1_groth16.pub \ --vk ./scripts/test_files/gnark_groth16_bn254_infinite_script/infinite_proofs/ineq_1_groth16.vk \ ---batcher_url wss://batcher.alignedlayer.com \ --keystore_path ~/.aligned_keystore/keystore0 \ --network holesky \ --rpc_url https://ethereum-holesky-rpc.publicnode.com diff --git a/docs/3_guides/1.2_SDK_api_reference.md b/docs/3_guides/1.2_SDK_api_reference.md index 8bc3ca4df..5580ff3bf 100644 --- a/docs/3_guides/1.2_SDK_api_reference.md +++ b/docs/3_guides/1.2_SDK_api_reference.md @@ -8,7 +8,6 @@ Submits a proof to the batcher to be verified and returns an aligned verificatio ```rust pub async fn submit( - batcher_url: &str, network: Network, verification_data: &VerificationData, max_fee; U256, @@ -19,7 +18,6 @@ pub async fn submit( #### Arguments -- `batcher_url` - The url of the batcher to which the proof will be submitted. - `network` - The network on which the proof will be submitted (`devnet | holesky-stage | holesky`) - `verification_data` - The verification data for the proof. - `max_fee` - The maximum fee that the submitter is willing to pay for the proof verification. @@ -54,7 +52,6 @@ Submits multiple proofs to the batcher to be verified and returns an aligned ver ```rust pub async fn submit_multiple( - batcher_url: &str, network: Network, verification_data: &[VerificationData], max_fees: &[U256], @@ -65,7 +62,6 @@ pub async fn submit_multiple( #### Arguments -- `batcher_url` - The url of the batcher to which the proof will be submitted. - `network` - The network on which the proof will be submitted (`devnet | holesky-stage | holesky`) - `verification_data` - A verification data array. - `max_fees` - A max fee array. @@ -102,7 +98,6 @@ verification data struct. ```rust pub async fn submit_and_wait_verification( - batcher_url: &str, eth_rpc_url: &str, network: Network, verification_data: &VerificationData, @@ -114,7 +109,6 @@ pub async fn submit_and_wait_verification( #### Arguments -- `batcher_url` - The url of the batcher to which the proof will be submitted. - `eth_rpc_url` - The URL of the Ethereum RPC node. - `network` - The network on which the verification will be done (`devnet | holesky-stage | holesky`) - `verification_data` - The verification data for the proof. @@ -155,7 +149,6 @@ Submits multiple proofs to the batcher for verification, waits for verification ```rust pub async fn submit_multiple_and_wait_verification( - batcher_url: &str, eth_rpc_url: &str, network: Network, verification_data: &[VerificationData], @@ -167,7 +160,6 @@ pub async fn submit_multiple_and_wait_verification( #### Arguments -- `batcher_url` - The url of the batcher to which the proof will be submitted. - `eth_rpc_url` - The URL of the Ethereum RPC node. - `network` - The network on which the verification will be done (`devnet | holesky-stage | holesky`) - `verification_data` - A verification data array. @@ -289,15 +281,15 @@ as the batcher proofs might not yet be on ethereum, producing an out-of-sync non ```rust pub async fn get_nonce_from_batcher( - batcher_ws_url: &str, address: Address, -) -> Result { + network: Network +) -> Result ``` #### Arguments -- `batcher_url` - The batcher websocket url. - `address` - The user address for which the nonce will be retrieved. +- `network` - The network from which the nonce will be retrieved. #### Returns diff --git a/docs/3_guides/1_SDK_how_to.md b/docs/3_guides/1_SDK_how_to.md index e6f52e4e9..d5d7f04fd 100644 --- a/docs/3_guides/1_SDK_how_to.md +++ b/docs/3_guides/1_SDK_how_to.md @@ -51,8 +51,6 @@ Or you can make a more complex call to submit a proof: (code extract from [ZKQuiz example](../3_guides/2_build_your_first_aligned_application.md#app)) ```rust -const BATCHER_URL: &str = "wss://batcher.alignedlayer.com"; - fn main() { let rpc_url = args.rpc_url.clone(); let verification_data = VerificationData { @@ -74,7 +72,6 @@ fn main() { // Call to SDK: match submit_and_wait_verification( - BATCHER_URL, &rpc_url, Network::Holesky, &verification_data, diff --git a/docs/3_guides/2_build_your_first_aligned_application.md b/docs/3_guides/2_build_your_first_aligned_application.md index a1182a201..8e1fdb03d 100644 --- a/docs/3_guides/2_build_your_first_aligned_application.md +++ b/docs/3_guides/2_build_your_first_aligned_application.md @@ -273,7 +273,6 @@ let nonce = get_nonce_from_ethereum(&rpc_url, wallet.address(), NETWORK) // Submit to Aligned. let aligned_verification_data = submit_and_wait_verification( - BATCHER_URL, &rpc_url, NETWORK, &verification_data, diff --git a/docs/3_guides/4_generating_proofs.md b/docs/3_guides/4_generating_proofs.md index c71f88380..c5e541e9f 100644 --- a/docs/3_guides/4_generating_proofs.md +++ b/docs/3_guides/4_generating_proofs.md @@ -39,7 +39,6 @@ aligned submit \ --proving_system SP1 \ --proof \ --vm_program \ ---batcher_url wss://batcher.alignedlayer.com \ --proof_generator_addr \ --rpc_url https://ethereum-holesky-rpc.publicnode.com ``` @@ -88,7 +87,6 @@ aligned submit \ --proof \ --public_input --vk \ ---batcher_url wss://batcher.alignedlayer.com \ --proof_generator_addr \ --rpc_url https://ethereum-holesky-rpc.publicnode.com ``` @@ -166,7 +164,6 @@ aligned submit \ --proof \ --vm_program \ --public_input \ - --batcher_url wss://batcher.alignedlayer.com \ --proof_generator_addr \ --rpc_url https://ethereum-holesky-rpc.publicnode.com \ --payment_service_addr 0x815aeCA64a974297942D2Bbf034ABEe22a38A003 diff --git a/docs/3_guides/6_setup_aligned.md b/docs/3_guides/6_setup_aligned.md index d0f210fd0..5259fb229 100644 --- a/docs/3_guides/6_setup_aligned.md +++ b/docs/3_guides/6_setup_aligned.md @@ -505,7 +505,6 @@ aligned submit \ --proof_generator_addr [proof_generator_addr] \ --batch_inclusion_data_directory_path [batch_inclusion_data_directory_path] \ --keystore_path [path_to_ecdsa_keystore] \ ---batcher_url wss://batcher.alignedlayer.com \ --rpc_url https://ethereum-holesky-rpc.publicnode.com ``` From 5798257449bad72b8ed61dfe150b031f22dd5e7d Mon Sep 17 00:00:00 2001 From: Marcos Nicolau Date: Wed, 4 Dec 2024 18:18:30 -0300 Subject: [PATCH 11/16] refactor(examples): remove batcher_url --- .../validating-public-input/aligned-integration/src/main.rs | 3 --- examples/zkquiz/quiz/script/src/main.rs | 3 --- 2 files changed, 6 deletions(-) diff --git a/examples/validating-public-input/aligned-integration/src/main.rs b/examples/validating-public-input/aligned-integration/src/main.rs index c3ed79b42..d399b4bc4 100644 --- a/examples/validating-public-input/aligned-integration/src/main.rs +++ b/examples/validating-public-input/aligned-integration/src/main.rs @@ -43,8 +43,6 @@ pub enum ProvingSystemArg { #[derive(Parser, Debug)] #[command(version, about, long_about = None)] struct Args { - #[arg(short, long, default_value = "wss://batcher.alignedlayer.com")] - batcher_url: String, #[arg(short, long, default_value = "holesky")] network: Network, #[arg(short, long)] @@ -134,7 +132,6 @@ async fn main() -> Result<(), SubmitError> { info!("Submitting Fibonacci proof to Aligned and waiting for verification..."); let aligned_verification_data = submit_and_wait_verification( - &args.batcher_url, &args.rpc_url, network, &verification_data, diff --git a/examples/zkquiz/quiz/script/src/main.rs b/examples/zkquiz/quiz/script/src/main.rs index 5a895023d..d6e714a8a 100644 --- a/examples/zkquiz/quiz/script/src/main.rs +++ b/examples/zkquiz/quiz/script/src/main.rs @@ -29,8 +29,6 @@ struct Args { default_value = "https://ethereum-holesky-rpc.publicnode.com" )] rpc_url: String, - #[arg(short, long, default_value = "wss://batcher.alignedlayer.com")] - batcher_url: String, #[arg(short, long, default_value = "holesky")] network: Network, #[arg(short, long)] @@ -139,7 +137,6 @@ async fn main() { println!("Submitting your proof..."); let aligned_verification_data = submit_and_wait_verification( - &args.batcher_url, &rpc_url, args.network, &verification_data, From 0e502c0cfb0bbd98b0640bb035fcfdfdb9e9d9c8 Mon Sep 17 00:00:00 2001 From: Marcos Nicolau Date: Wed, 4 Dec 2024 18:20:03 -0300 Subject: [PATCH 12/16] refactor(scripts): remove batcher_url --- batcher/aligned/generate_proof_and_send.sh | 2 -- .../aligned/send_infinite_sp1_tasks/send_infinite_sp1_tasks.sh | 1 - batcher/aligned/send_infinite_tasks.sh | 1 - 3 files changed, 4 deletions(-) diff --git a/batcher/aligned/generate_proof_and_send.sh b/batcher/aligned/generate_proof_and_send.sh index bcfa68454..42d01b8fb 100755 --- a/batcher/aligned/generate_proof_and_send.sh +++ b/batcher/aligned/generate_proof_and_send.sh @@ -26,7 +26,6 @@ go run scripts/test_files/gnark_groth16_bn254_infinite_script/cmd/main.go $x # Set default values for RPC and BATCHER if they are not set RPC=${RPC:-http://localhost:8545} -BATCHER_CONN=${BATCHER_CONN:-ws://localhost:8080} if [ -z "$NETWORK" ]; then echo "NETWORK is not set. Setting it to devnet" NETWORK="devnet" @@ -42,7 +41,6 @@ cmd=( --vk "scripts/test_files/gnark_groth16_bn254_infinite_script/infinite_proofs/ineq_${x}_groth16.vk" --proof_generator_addr 0x66f9664f97F2b50F62D13eA064982f936dE76657 --rpc_url "$RPC" - --batcher_url "$BATCHER_CONN" --network "$NETWORK" ) diff --git a/batcher/aligned/send_infinite_sp1_tasks/send_infinite_sp1_tasks.sh b/batcher/aligned/send_infinite_sp1_tasks/send_infinite_sp1_tasks.sh index 079a8dcc5..92742acd3 100755 --- a/batcher/aligned/send_infinite_sp1_tasks/send_infinite_sp1_tasks.sh +++ b/batcher/aligned/send_infinite_sp1_tasks/send_infinite_sp1_tasks.sh @@ -33,7 +33,6 @@ do --vm_program ../../scripts/test_files/sp1/sp1_fibonacci.elf \ --proof_generator_addr "$random_address" \ --network "$NETWORK" \ - --batcher_url "$BATCHER_CONN" \ --repetitions "2" \ --rpc_url "$RPC" diff --git a/batcher/aligned/send_infinite_tasks.sh b/batcher/aligned/send_infinite_tasks.sh index d79ff8ab3..b189be82d 100755 --- a/batcher/aligned/send_infinite_tasks.sh +++ b/batcher/aligned/send_infinite_tasks.sh @@ -35,7 +35,6 @@ do --proof_generator_addr 0x66f9664f97F2b50F62D13eA064982f936dE76657 \ --repetitions "2" \ --rpc_url "$RPC" \ - --batcher_url "$BATCHER_CONN" \ --network "$NETWORK" cd ../.. From aa019e92f80d165e0875b10df74a276ac010d69c Mon Sep 17 00:00:00 2001 From: Urix <43704209+uri-99@users.noreply.github.com> Date: Thu, 5 Dec 2024 16:10:24 -0300 Subject: [PATCH 13/16] fix: add mainnet batcher url --- batcher/aligned-sdk/src/core/types.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/batcher/aligned-sdk/src/core/types.rs b/batcher/aligned-sdk/src/core/types.rs index 83698599b..f253f35db 100644 --- a/batcher/aligned-sdk/src/core/types.rs +++ b/batcher/aligned-sdk/src/core/types.rs @@ -18,7 +18,7 @@ use lambdaworks_crypto::merkle_tree::{ use serde::{Deserialize, Serialize}; use sha3::{Digest, Keccak256}; -use super::constants::{BATCHER_URL_DEVNET, BATCHER_URL_HOLESKY, BATCHER_URL_HOLESKY_STAGE}; +use super::constants::{BATCHER_URL_DEVNET, BATCHER_URL_HOLESKY, BATCHER_URL_HOLESKY_STAGE, BATCHER_URL_MAINNET}; use super::errors::VerifySignatureError; @@ -429,6 +429,7 @@ impl Network { Self::Devnet => BATCHER_URL_DEVNET, Self::Holesky => BATCHER_URL_HOLESKY, Self::HoleskyStage => BATCHER_URL_HOLESKY_STAGE, + Self::Mainnet => BATCHER_URL_MAINNET, } } } From 89af410775fd4b8dd1c907600b7e9455d68d24c3 Mon Sep 17 00:00:00 2001 From: Marcos Nicolau Date: Thu, 5 Dec 2024 16:31:43 -0300 Subject: [PATCH 14/16] chore: cargo fmt --- batcher/aligned-sdk/src/core/types.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/batcher/aligned-sdk/src/core/types.rs b/batcher/aligned-sdk/src/core/types.rs index f253f35db..8446e5f96 100644 --- a/batcher/aligned-sdk/src/core/types.rs +++ b/batcher/aligned-sdk/src/core/types.rs @@ -18,7 +18,9 @@ use lambdaworks_crypto::merkle_tree::{ use serde::{Deserialize, Serialize}; use sha3::{Digest, Keccak256}; -use super::constants::{BATCHER_URL_DEVNET, BATCHER_URL_HOLESKY, BATCHER_URL_HOLESKY_STAGE, BATCHER_URL_MAINNET}; +use super::constants::{ + BATCHER_URL_DEVNET, BATCHER_URL_HOLESKY, BATCHER_URL_HOLESKY_STAGE, BATCHER_URL_MAINNET, +}; use super::errors::VerifySignatureError; From 22540b26289a89992a6f2df9e0623ae5c831296e Mon Sep 17 00:00:00 2001 From: Marcos Nicolau Date: Thu, 5 Dec 2024 17:58:15 -0300 Subject: [PATCH 15/16] chore: remove batcher_url from makefiles --- Makefile | 6 ++---- examples/validating-public-input/Makefile | 4 ++-- examples/zkquiz/Makefile | 1 - 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index beb5b2a22..04a8fe8dd 100644 --- a/Makefile +++ b/Makefile @@ -486,7 +486,6 @@ task_sender_send_infinite_proofs_devnet: cargo run --release -- send-infinite-proofs \ --burst-size $(BURST_SIZE) --burst-time-secs $(BURST_TIME_SECS) \ --eth-rpc-url http://localhost:8545 \ - --batcher-url ws://localhost:8080 \ --network devnet \ --proofs-dirpath $(CURDIR)/scripts/test_files/task_sender/proofs \ --private-keys-filepath $(CURDIR)/batcher/aligned-task-sender/wallets/devnet @@ -494,7 +493,7 @@ task_sender_send_infinite_proofs_devnet: task_sender_test_connections_devnet: @cd batcher/aligned-task-sender && \ cargo run --release -- test-connections \ - --batcher-url ws://localhost:8080 \ + --network devnet --num-senders $(NUM_SENDERS) # ===== HOLESKY-STAGE ===== @@ -514,7 +513,6 @@ task_sender_send_infinite_proofs_holesky_stage: cargo run --release -- send-infinite-proofs \ --burst-size $(BURST_SIZE) --burst-time-secs $(BURST_TIME_SECS) \ --eth-rpc-url https://ethereum-holesky-rpc.publicnode.com \ - --batcher-url wss://stage.batcher.alignedlayer.com \ --network holesky-stage \ --proofs-dirpath $(CURDIR)/scripts/test_files/task_sender/proofs \ --private-keys-filepath $(CURDIR)/batcher/aligned-task-sender/wallets/holesky-stage @@ -522,7 +520,7 @@ task_sender_send_infinite_proofs_holesky_stage: task_sender_test_connections_holesky_stage: @cd batcher/aligned-task-sender && \ cargo run --release -- test-connections \ - --batcher-url wss://stage.batcher.alignedlayer.com \ + --network holesky-stage --num-senders $(NUM_SENDERS) __UTILS__: diff --git a/examples/validating-public-input/Makefile b/examples/validating-public-input/Makefile index 0749991bc..b4e59106e 100644 --- a/examples/validating-public-input/Makefile +++ b/examples/validating-public-input/Makefile @@ -13,7 +13,7 @@ generate_sp1_fibonacci_proof: submit_fibonacci_sp1_proof_devnet: @cd aligned-integration && \ - RUST_LOG=info cargo run --release -- --proving-system "SP1" --network "devnet" --batcher-url "ws://localhost:8080" --rpc-url "http://localhost:8545" + RUST_LOG=info cargo run --release -- --proving-system "SP1" --network "devnet" --rpc-url "http://localhost:8545" submit_fibonacci_sp1_proof: @cd aligned-integration && \ @@ -21,7 +21,7 @@ submit_fibonacci_sp1_proof: submit_fibonacci_risc0_proof_devnet: @cd aligned-integration && \ - RUST_LOG=info cargo run --release -- --proving-system "Risc0" --network "devnet" --batcher-url "ws://localhost:8080" --rpc-url "http://localhost:8545" + RUST_LOG=info cargo run --release -- --proving-system "Risc0" --network "devnet --rpc-url "http://localhost:8545" submit_fibonacci_risc0_proof: @cd aligned-integration && \ diff --git a/examples/zkquiz/Makefile b/examples/zkquiz/Makefile index 679705861..7cde352a5 100644 --- a/examples/zkquiz/Makefile +++ b/examples/zkquiz/Makefile @@ -17,7 +17,6 @@ answer_quiz_local: @cd quiz/script && cargo run -r -- \ --keystore-path ../../../../config-files/devnet/keys/operator-3.ecdsa.key.json \ --rpc-url http://localhost:8545 \ - --batcher-url ws://localhost:8080 \ --network devnet \ --verifier-contract-address $(CONTRACT_ADDRESS) From 75d38225f5f04ba10a2f2e28aff65dfb908cb9bd Mon Sep 17 00:00:00 2001 From: PatStiles Date: Fri, 6 Dec 2024 09:37:46 -0300 Subject: [PATCH 16/16] fix merge error --- batcher/aligned/src/main.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/batcher/aligned/src/main.rs b/batcher/aligned/src/main.rs index ac9df289a..02cf14d33 100644 --- a/batcher/aligned/src/main.rs +++ b/batcher/aligned/src/main.rs @@ -287,6 +287,7 @@ async fn main() -> Result<(), AlignedError> { let keystore_path = &submit_args.keystore_path; let private_key = &submit_args.private_key; + let network = submit_args.network.into(); if keystore_path.is_some() && private_key.is_some() { warn!("Can't have a keystore path and a private key as input. Please use only one");