From c857a56b1bcc682e200946a9711ea30dbe675cd4 Mon Sep 17 00:00:00 2001 From: PatStiles Date: Wed, 4 Dec 2024 17:39:22 -0300 Subject: [PATCH 01/74] add price estimate as submission fee mechanism --- batcher/aligned-sdk/src/core/constants.rs | 4 +- batcher/aligned-sdk/src/core/errors.rs | 22 +++-- batcher/aligned-sdk/src/core/types.rs | 27 +++++- batcher/aligned-sdk/src/sdk.rs | 107 ++++------------------ batcher/aligned/src/main.rs | 52 ++++++++--- 5 files changed, 102 insertions(+), 110 deletions(-) diff --git a/batcher/aligned-sdk/src/core/constants.rs b/batcher/aligned-sdk/src/core/constants.rs index d45189000b..2190f6ae49 100644 --- a/batcher/aligned-sdk/src/core/constants.rs +++ b/batcher/aligned-sdk/src/core/constants.rs @@ -21,10 +21,10 @@ pub const PERCENTAGE_DIVIDER: u128 = 100; /// Number of proofs we a batch for estimation. /// This is the number of proofs in a batch of size n, where we set n = 32. /// i.e. the user pays for the entire batch and his proof is instantly submitted. -pub const MAX_FEE_BATCH_PROOF_NUMBER: usize = 32; +pub const INSTANT_MAX_FEE_PROOF_NUMBER: usize = 1; /// Estimated number of proofs for batch submission. /// This corresponds to the number of proofs to compute for a default max_fee. -pub const MAX_FEE_DEFAULT_PROOF_NUMBER: usize = 10; +pub const DEFAULT_MAX_FEE_PROOF_NUMBER: usize = 10; /// Ethereum calls retry constants pub const ETHEREUM_CALL_MIN_RETRY_DELAY: u64 = 500; // milliseconds diff --git a/batcher/aligned-sdk/src/core/errors.rs b/batcher/aligned-sdk/src/core/errors.rs index 8712009c65..52485a7086 100644 --- a/batcher/aligned-sdk/src/core/errors.rs +++ b/batcher/aligned-sdk/src/core/errors.rs @@ -17,7 +17,7 @@ pub enum AlignedError { SubmitError(SubmitError), VerificationError(VerificationError), ChainIdError(ChainIdError), - MaxFeeEstimateError(MaxFeeEstimateError), + FeeEstimateError(FeeEstimateError), FileError(FileError), } @@ -39,9 +39,9 @@ impl From for AlignedError { } } -impl From for AlignedError { - fn from(e: MaxFeeEstimateError) -> Self { - AlignedError::MaxFeeEstimateError(e) +impl From for AlignedError { + fn from(e: FeeEstimateError) -> Self { + AlignedError::FeeEstimateError(e) } } @@ -57,7 +57,7 @@ impl fmt::Display for AlignedError { AlignedError::SubmitError(e) => write!(f, "Submit error: {}", e), AlignedError::VerificationError(e) => write!(f, "Verification error: {}", e), AlignedError::ChainIdError(e) => write!(f, "Chain ID error: {}", e), - AlignedError::MaxFeeEstimateError(e) => write!(f, "Max fee estimate error: {}", e), + AlignedError::FeeEstimateError(e) => write!(f, "Max fee estimate error: {}", e), AlignedError::FileError(e) => write!(f, "File error: {}", e), } } @@ -266,20 +266,24 @@ impl fmt::Display for ChainIdError { } #[derive(Debug)] -pub enum MaxFeeEstimateError { +pub enum FeeEstimateError { EthereumProviderError(String), EthereumGasPriceError(String), + PriceEstimateParseError(String), } -impl fmt::Display for MaxFeeEstimateError { +impl fmt::Display for FeeEstimateError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match self { - MaxFeeEstimateError::EthereumProviderError(e) => { + FeeEstimateError::EthereumProviderError(e) => { write!(f, "Ethereum provider error: {}", e) } - MaxFeeEstimateError::EthereumGasPriceError(e) => { + FeeEstimateError::EthereumGasPriceError(e) => { write!(f, "Failed to retreive the current gas price: {}", e) } + FeeEstimateError::PriceEstimateParseError(e) => { + write!(f, "Error parsing PriceEstimate: {}", e) + } } } } diff --git a/batcher/aligned-sdk/src/core/types.rs b/batcher/aligned-sdk/src/core/types.rs index ab392df51c..cc5a9867eb 100644 --- a/batcher/aligned-sdk/src/core/types.rs +++ b/batcher/aligned-sdk/src/core/types.rs @@ -89,9 +89,34 @@ impl NoncedVerificationData { // Defines an estimate price preference for the user. #[derive(Debug, Serialize, Deserialize, Clone)] pub enum PriceEstimate { - Min, Default, Instant, + Custom(usize), +} + +impl TryFrom for PriceEstimate { + type Error = String; + + fn try_from(value: String) -> Result { + let val = match value.as_str() { + // TODO remove the InvalidMaxFee error... + "default" => Self::Default, + "instant" => Self::Instant, + s if s.starts_with("custom") => { + println!("{s}"); + let n = s.split_whitespace() + .nth(1) + .ok_or("Failed to Parse: `number_proofs_per_batch` not supplied")? + .parse() + .map_err(|_| "Failed to Parse: Value of `number_proofs_per_batch` invalid")?; + PriceEstimate::Custom(n) + }, + _ => + return Err("Invalid network, possible values are: \"default\", \"instant\", \"custom\"" + .to_string()), + }; + Ok(val) + } } #[derive(Debug, Serialize, Deserialize, Clone, Default)] diff --git a/batcher/aligned-sdk/src/sdk.rs b/batcher/aligned-sdk/src/sdk.rs index a9a0ad5a03..d6a13ee59e 100644 --- a/batcher/aligned-sdk/src/sdk.rs +++ b/batcher/aligned-sdk/src/sdk.rs @@ -8,7 +8,7 @@ use crate::{ core::{ constants::{ ADDITIONAL_SUBMISSION_GAS_COST_PER_PROOF, CONSTANT_GAS_COST, - MAX_FEE_BATCH_PROOF_NUMBER, MAX_FEE_DEFAULT_PROOF_NUMBER, + DEFAULT_MAX_FEE_PROOF_NUMBER, INSTANT_MAX_FEE_PROOF_NUMBER, }, errors::{self, GetNonceError}, types::{ @@ -136,37 +136,17 @@ pub async fn submit_multiple_and_wait_verification( pub async fn estimate_fee( eth_rpc_url: &str, estimate: PriceEstimate, -) -> Result { +) -> Result { // Price of 1 proof in 32 proof batch - let fee_per_proof = fee_per_proof(eth_rpc_url, MAX_FEE_BATCH_PROOF_NUMBER).await?; - - let proof_price = match estimate { - PriceEstimate::Min => fee_per_proof, - PriceEstimate::Default => U256::from(MAX_FEE_DEFAULT_PROOF_NUMBER) * fee_per_proof, - PriceEstimate::Instant => U256::from(MAX_FEE_BATCH_PROOF_NUMBER) * fee_per_proof, - }; - Ok(proof_price) -} - -/// Returns the computed `max_fee` for a proof based on the number of proofs in a batch (`num_proofs_per_batch`) and -/// number of proofs (`num_proofs`) in that batch the user would pay for i.e (`num_proofs` / `num_proofs_per_batch`). -/// NOTE: The `max_fee` is computed from an rpc nodes max priority gas price. -/// # Arguments -/// * `eth_rpc_url` - The URL of the users Ethereum RPC node. -/// * `num_proofs` - number of proofs in a batch the user would pay for. -/// * `num_proofs_per_batch` - number of proofs within a batch. -/// # Returns -/// * The calculated `max_fee` as a `U256`. -/// # Errors -/// * `EthereumProviderError` if there is an error in the connection with the RPC provider. -/// * `EthereumGasPriceError` if there is an error retrieving the Ethereum gas price. -pub async fn compute_max_fee( - eth_rpc_url: &str, - num_proofs: usize, - num_proofs_per_batch: usize, -) -> Result { - let fee_per_proof = fee_per_proof(eth_rpc_url, num_proofs_per_batch).await?; - Ok(fee_per_proof * num_proofs) + match estimate { + PriceEstimate::Default => { + max_fee_per_proof_in_batch(eth_rpc_url, DEFAULT_MAX_FEE_PROOF_NUMBER).await + } + PriceEstimate::Instant => { + max_fee_per_proof_in_batch(eth_rpc_url, INSTANT_MAX_FEE_PROOF_NUMBER).await + } + PriceEstimate::Custom(n) => max_fee_per_proof_in_batch(eth_rpc_url, n).await, + } } /// Returns the `fee_per_proof` based on the current gas price for a batch compromised of `num_proofs_per_batch` @@ -180,22 +160,22 @@ pub async fn compute_max_fee( /// # Errors /// * `EthereumProviderError` if there is an error in the connection with the RPC provider. /// * `EthereumGasPriceError` if there is an error retrieving the Ethereum gas price. -pub async fn fee_per_proof( +pub async fn max_fee_per_proof_in_batch( eth_rpc_url: &str, - num_proofs_per_batch: usize, -) -> Result { + num_proofs_in_batch: usize, +) -> Result { let eth_rpc_provider = Provider::::try_from(eth_rpc_url).map_err(|e: url::ParseError| { - errors::MaxFeeEstimateError::EthereumProviderError(e.to_string()) + errors::FeeEstimateError::EthereumProviderError(e.to_string()) })?; let gas_price = fetch_gas_price(ð_rpc_provider).await?; // Cost for estimate `num_proofs_per_batch` proofs let estimated_gas_per_proof = (CONSTANT_GAS_COST - + ADDITIONAL_SUBMISSION_GAS_COST_PER_PROOF * num_proofs_per_batch as u128) - / num_proofs_per_batch as u128; + + ADDITIONAL_SUBMISSION_GAS_COST_PER_PROOF * num_proofs_in_batch as u128) + / num_proofs_in_batch as u128; - // Price of 1 proof in 32 proof batch + // Price of 1 / `num_proofs_in_batch` proof batch let fee_per_proof = U256::from(estimated_gas_per_proof) * gas_price; Ok(fee_per_proof) @@ -203,11 +183,11 @@ pub async fn fee_per_proof( async fn fetch_gas_price( eth_rpc_provider: &Provider, -) -> Result { +) -> Result { let gas_price = match eth_rpc_provider.get_gas_price().await { Ok(price) => price, Err(e) => { - return Err(errors::MaxFeeEstimateError::EthereumGasPriceError( + return Err(errors::FeeEstimateError::EthereumGasPriceError( e.to_string(), )) } @@ -823,50 +803,3 @@ fn save_response_json( Ok(()) } - -#[cfg(test)] -mod test { - //Public constants for convenience - pub const HOLESKY_PUBLIC_RPC_URL: &str = "https://ethereum-holesky-rpc.publicnode.com"; - use super::*; - - #[tokio::test] - async fn computed_max_fee_for_larger_batch_is_smaller() { - let small_fee = compute_max_fee(HOLESKY_PUBLIC_RPC_URL, 2, 10) - .await - .unwrap(); - let large_fee = compute_max_fee(HOLESKY_PUBLIC_RPC_URL, 5, 10) - .await - .unwrap(); - - assert!(small_fee < large_fee); - } - - #[tokio::test] - async fn computed_max_fee_for_more_proofs_larger_than_for_less_proofs() { - let small_fee = compute_max_fee(HOLESKY_PUBLIC_RPC_URL, 5, 20) - .await - .unwrap(); - let large_fee = compute_max_fee(HOLESKY_PUBLIC_RPC_URL, 5, 10) - .await - .unwrap(); - - assert!(small_fee < large_fee); - } - - #[tokio::test] - async fn estimate_fee_are_larger_than_one_another() { - let min_fee = estimate_fee(HOLESKY_PUBLIC_RPC_URL, PriceEstimate::Min) - .await - .unwrap(); - let default_fee = estimate_fee(HOLESKY_PUBLIC_RPC_URL, PriceEstimate::Default) - .await - .unwrap(); - let instant_fee = estimate_fee(HOLESKY_PUBLIC_RPC_URL, PriceEstimate::Instant) - .await - .unwrap(); - - assert!(min_fee < default_fee); - assert!(default_fee < instant_fee); - } -} diff --git a/batcher/aligned/src/main.rs b/batcher/aligned/src/main.rs index e8df5118ba..ef814a7871 100644 --- a/batcher/aligned/src/main.rs +++ b/batcher/aligned/src/main.rs @@ -6,10 +6,12 @@ use std::path::PathBuf; use std::str::FromStr; use aligned_sdk::communication::serialization::cbor_deserialize; +use aligned_sdk::core::types::PriceEstimate; use aligned_sdk::core::{ errors::{AlignedError, SubmitError}, types::{AlignedVerificationData, Network, ProvingSystemId, VerificationData}, }; +use aligned_sdk::sdk::estimate_fee; use aligned_sdk::sdk::get_chain_id; use aligned_sdk::sdk::get_nonce_from_batcher; use aligned_sdk::sdk::{deposit_to_aligned, get_balance_in_aligned}; @@ -107,12 +109,15 @@ pub struct SubmitArgs { keystore_path: Option, #[arg(name = "Private key", long = "private_key")] private_key: Option, + #[arg(name = "Max Fee", long = "max_fee")] + max_fee: Option, // String because U256 expects hex #[arg( - name = "Max Fee", - long = "max_fee", - default_value = "1300000000000000" // 13_000 gas per proof * 100 gwei gas price (upper bound) + name = "Price Estimate", + long = "price_estimate", + default_value = "default", + allow_hyphen_values = true )] - max_fee: String, // String because U256 expects hex + price_estimate: Option, #[arg(name = "Nonce", long = "nonce")] nonce: Option, // String because U256 expects hex #[arg( @@ -120,7 +125,34 @@ pub struct SubmitArgs { long = "network", default_value = "devnet" )] - network: NetworkArg, + network: Network, +} + +impl SubmitArgs { + async fn get_max_fee(&self) -> Result { + // If max_fee is explicitly provided it is used first + if let Some(max_fee) = &self.max_fee { + // We explicitly tell the user that using both is invalid + if self.price_estimate.is_some() { + warn!("`max_fee` and `price_estimate` are both present using `max_fee`"); + } + return Ok( + U256::from_str(max_fee).map_err(|e| SubmitError::GenericError(e.to_string()))? + ); + } + + if let Some(price_est) = &self.price_estimate { + let estimate = PriceEstimate::try_from(price_est.clone()) + .map_err(|e| SubmitError::GenericError(e.to_string()))?; + return estimate_fee(&self.eth_rpc_url, estimate) + .await + .map_err(AlignedError::FeeEstimateError); + } + + // Fallback to default value + Ok(U256::from_str("1300000000000000") + .map_err(|e| SubmitError::GenericError(e.to_string()))?) + } } #[derive(Parser, Debug)] @@ -277,9 +309,9 @@ async fn main() -> Result<(), AlignedError> { SubmitError::IoError(batch_inclusion_data_directory_path.clone(), e) })?; - let max_fee = - U256::from_dec_str(&submit_args.max_fee).map_err(|_| SubmitError::InvalidMaxFee)?; - + let eth_rpc_url = submit_args.eth_rpc_url.clone(); + // `max_fee` is required unless `price_estimate` is present. + let max_fee = submit_args.get_max_fee().await?; let repetitions = submit_args.repetitions; let connect_addr = submit_args.batcher_url.clone(); @@ -314,8 +346,6 @@ async fn main() -> Result<(), AlignedError> { } }; - let eth_rpc_url = submit_args.eth_rpc_url.clone(); - let chain_id = get_chain_id(eth_rpc_url.as_str()).await?; wallet = wallet.with_chain_id(chain_id); @@ -356,7 +386,7 @@ async fn main() -> Result<(), AlignedError> { let aligned_verification_data_vec = submit_multiple( &connect_addr, - submit_args.network.into(), + submit_args.network, &verification_data_arr, max_fee, wallet.clone(), From 6040beb0064580fffedf09636a609d2d6f2e9891 Mon Sep 17 00:00:00 2001 From: PatStiles Date: Wed, 4 Dec 2024 17:45:34 -0300 Subject: [PATCH 02/74] rm error --- batcher/aligned-sdk/src/core/types.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/batcher/aligned-sdk/src/core/types.rs b/batcher/aligned-sdk/src/core/types.rs index cc5a9867eb..6a38386148 100644 --- a/batcher/aligned-sdk/src/core/types.rs +++ b/batcher/aligned-sdk/src/core/types.rs @@ -99,7 +99,6 @@ impl TryFrom for PriceEstimate { fn try_from(value: String) -> Result { let val = match value.as_str() { - // TODO remove the InvalidMaxFee error... "default" => Self::Default, "instant" => Self::Instant, s if s.starts_with("custom") => { From 2e17db3db66cf0468788d3676895f8810cde1738 Mon Sep 17 00:00:00 2001 From: PatStiles Date: Wed, 4 Dec 2024 17:51:19 -0300 Subject: [PATCH 03/74] fmt --- batcher/aligned-sdk/src/core/types.rs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/batcher/aligned-sdk/src/core/types.rs b/batcher/aligned-sdk/src/core/types.rs index 6a38386148..fd4235423c 100644 --- a/batcher/aligned-sdk/src/core/types.rs +++ b/batcher/aligned-sdk/src/core/types.rs @@ -96,23 +96,27 @@ pub enum PriceEstimate { impl TryFrom for PriceEstimate { type Error = String; - + fn try_from(value: String) -> Result { let val = match value.as_str() { "default" => Self::Default, "instant" => Self::Instant, s if s.starts_with("custom") => { println!("{s}"); - let n = s.split_whitespace() + let n = s + .split_whitespace() .nth(1) .ok_or("Failed to Parse: `number_proofs_per_batch` not supplied")? .parse() .map_err(|_| "Failed to Parse: Value of `number_proofs_per_batch` invalid")?; PriceEstimate::Custom(n) - }, - _ => - return Err("Invalid network, possible values are: \"default\", \"instant\", \"custom\"" - .to_string()), + } + _ => { + return Err( + "Invalid network, possible values are: \"default\", \"instant\", \"custom\"" + .to_string(), + ) + } }; Ok(val) } From 4811db34b44fbb682416593957c66eb441168128 Mon Sep 17 00:00:00 2001 From: PatStiles Date: Wed, 4 Dec 2024 17:54:14 -0300 Subject: [PATCH 04/74] change name per cmts in #1558 --- batcher/aligned-sdk/src/sdk.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/batcher/aligned-sdk/src/sdk.rs b/batcher/aligned-sdk/src/sdk.rs index d6a13ee59e..84f2a6045b 100644 --- a/batcher/aligned-sdk/src/sdk.rs +++ b/batcher/aligned-sdk/src/sdk.rs @@ -140,12 +140,12 @@ pub async fn estimate_fee( // Price of 1 proof in 32 proof batch match estimate { PriceEstimate::Default => { - max_fee_per_proof_in_batch(eth_rpc_url, DEFAULT_MAX_FEE_PROOF_NUMBER).await + suggest_fee_per_proof(eth_rpc_url, DEFAULT_MAX_FEE_PROOF_NUMBER).await } PriceEstimate::Instant => { - max_fee_per_proof_in_batch(eth_rpc_url, INSTANT_MAX_FEE_PROOF_NUMBER).await + suggest_fee_per_proof(eth_rpc_url, INSTANT_MAX_FEE_PROOF_NUMBER).await } - PriceEstimate::Custom(n) => max_fee_per_proof_in_batch(eth_rpc_url, n).await, + PriceEstimate::Custom(n) => suggest_fee_per_proof(eth_rpc_url, n).await, } } @@ -160,7 +160,7 @@ pub async fn estimate_fee( /// # Errors /// * `EthereumProviderError` if there is an error in the connection with the RPC provider. /// * `EthereumGasPriceError` if there is an error retrieving the Ethereum gas price. -pub async fn max_fee_per_proof_in_batch( +pub async fn suggest_fee_per_proof( eth_rpc_url: &str, num_proofs_in_batch: usize, ) -> Result { From 9e19acb3e687a34be2a3bc67a986c895ad49d6db Mon Sep 17 00:00:00 2001 From: PatStiles Date: Thu, 5 Dec 2024 09:54:37 -0300 Subject: [PATCH 05/74] comment nit --- batcher/aligned/src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/batcher/aligned/src/main.rs b/batcher/aligned/src/main.rs index ef814a7871..6ae37534f7 100644 --- a/batcher/aligned/src/main.rs +++ b/batcher/aligned/src/main.rs @@ -132,7 +132,7 @@ impl SubmitArgs { async fn get_max_fee(&self) -> Result { // If max_fee is explicitly provided it is used first if let Some(max_fee) = &self.max_fee { - // We explicitly tell the user that using both is invalid + // Inform the user if both are declared that `max_fee` is used. if self.price_estimate.is_some() { warn!("`max_fee` and `price_estimate` are both present using `max_fee`"); } From 7c2d8f90cf295b0393449084f6caeee84237bf5f Mon Sep 17 00:00:00 2001 From: PatStiles Date: Thu, 5 Dec 2024 12:22:45 -0300 Subject: [PATCH 06/74] remove unneeded println --- batcher/aligned-sdk/src/core/types.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/batcher/aligned-sdk/src/core/types.rs b/batcher/aligned-sdk/src/core/types.rs index fd4235423c..879132a2be 100644 --- a/batcher/aligned-sdk/src/core/types.rs +++ b/batcher/aligned-sdk/src/core/types.rs @@ -102,7 +102,6 @@ impl TryFrom for PriceEstimate { "default" => Self::Default, "instant" => Self::Instant, s if s.starts_with("custom") => { - println!("{s}"); let n = s .split_whitespace() .nth(1) From d9c6b65657900a16860ada7f0e18604da24af930 Mon Sep 17 00:00:00 2001 From: PatStiles Date: Thu, 5 Dec 2024 12:35:20 -0300 Subject: [PATCH 07/74] help section for cli command + prompt correct usage in errors --- batcher/aligned-sdk/src/core/types.rs | 6 +++--- batcher/aligned/src/main.rs | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/batcher/aligned-sdk/src/core/types.rs b/batcher/aligned-sdk/src/core/types.rs index 879132a2be..fe6ea1c4a5 100644 --- a/batcher/aligned-sdk/src/core/types.rs +++ b/batcher/aligned-sdk/src/core/types.rs @@ -105,14 +105,14 @@ impl TryFrom for PriceEstimate { let n = s .split_whitespace() .nth(1) - .ok_or("Failed to Parse: `number_proofs_per_batch` not supplied")? + .ok_or("Failed to Parse: `number_proofs_per_batch` not supplied, correct usage \"custom \" (note quotations)")? .parse() - .map_err(|_| "Failed to Parse: Value of `number_proofs_per_batch` invalid")?; + .map_err(|_| "Failed to Parse: Value of `number_proofs_per_batch` invalid , correct usage \"custom \" (note quotations)")?; PriceEstimate::Custom(n) } _ => { return Err( - "Invalid network, possible values are: \"default\", \"instant\", \"custom\"" + "Invalid network, possible values are: \"default\", \"instant\", \"custom \"" .to_string(), ) } diff --git a/batcher/aligned/src/main.rs b/batcher/aligned/src/main.rs index 6ae37534f7..3a8e2feb78 100644 --- a/batcher/aligned/src/main.rs +++ b/batcher/aligned/src/main.rs @@ -115,6 +115,7 @@ pub struct SubmitArgs { name = "Price Estimate", long = "price_estimate", default_value = "default", + help = "`price_estimate` allows for a user to use the aligned_sdk `estimate_fee` function to compute there `max_fee`.\n Usage: `default,`, `instant`, \"custom \"", allow_hyphen_values = true )] price_estimate: Option, From b1c1f198476c1605ce1d3a1a9c76cda74321e91b Mon Sep 17 00:00:00 2001 From: PatStiles Date: Thu, 5 Dec 2024 15:18:42 -0300 Subject: [PATCH 08/74] update doc comment --- batcher/aligned-sdk/src/sdk.rs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/batcher/aligned-sdk/src/sdk.rs b/batcher/aligned-sdk/src/sdk.rs index 84f2a6045b..0fb8d8b295 100644 --- a/batcher/aligned-sdk/src/sdk.rs +++ b/batcher/aligned-sdk/src/sdk.rs @@ -115,16 +115,15 @@ pub async fn submit_multiple_and_wait_verification( aligned_verification_data } -/// Returns the estimated `max_fee` depending on the batch inclusion preference of the user, based on the max priority gas price. +/// Returns the estimated `max_fee` depending on the batch inclusion preference of the user, computed based on the current gas price, and the number of proofs in a batch. /// NOTE: The `max_fee` is computed from an rpc nodes max priority gas price. -/// To estimate the `max_fee` of a batch we use a compute the `max_fee` with respect to a batch of ~32 proofs present. +/// To estimate the `max_fee` of a batch we use a compute the `max_fee` with respect to a batch size of 1 (Instant), 10 (Default), or `number_proofs_in_batch` (Custom). /// The `max_fee` estimates therefore are: -/// * `Min`: Specifies a `max_fee` equivalent to the cost of 1 proof in a 32 proof batch. -/// This estimates the lowest possible `max_fee` the user should specify for there proof with lowest priority. -/// * `Default`: Specifies a `max_fee` equivalent to the cost of 10 proofs in a 32 proof batch. -/// This estimates the `max_fee` the user should specify for inclusion within the batch. -/// * `Instant`: specifies a `max_fee` equivalent to the cost of all proofs within in a 32 proof batch. -/// This estimates the `max_fee` the user should specify to pay for the entire batch of proofs and have there proof included instantly. +/// * `Default`: Specifies a `max_fee` equivalent to the cost of paying for one proof within a batch of 10 proofs ie. 1 / 10 proofs. +/// This estimates a default `max_fee` the user should specify for including there proof within the batch. +/// * `Instant`: Specifies a `max_fee` equivalent to the cost of paying for an entire batch ensuring the user's proof is included instantly. +/// * `Custom (number_proofs_in_batch)`: Specifies a `max_fee` equivalent to the cost of paying 1 proof / `num_proofs_in_batch` allowing the user a user to estimate there `max_fee` precisely based on the `number_proofs_in_batch`. +/// /// # Arguments /// * `eth_rpc_url` - The URL of the Ethereum RPC node. /// * `estimate` - Enum specifying the type of price estimate: MIN, DEFAULT, INSTANT. From ad91ac66f15050978f9c0e0d01b1d014932edc28 Mon Sep 17 00:00:00 2001 From: PatStiles Date: Thu, 5 Dec 2024 15:24:09 -0300 Subject: [PATCH 09/74] return error if user specifies both fee arguments are specified --- batcher/aligned/src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/batcher/aligned/src/main.rs b/batcher/aligned/src/main.rs index 3a8e2feb78..7bfe834500 100644 --- a/batcher/aligned/src/main.rs +++ b/batcher/aligned/src/main.rs @@ -135,7 +135,7 @@ impl SubmitArgs { if let Some(max_fee) = &self.max_fee { // Inform the user if both are declared that `max_fee` is used. if self.price_estimate.is_some() { - warn!("`max_fee` and `price_estimate` are both present using `max_fee`"); + return Err(SubmitError::GenericError("`max_fee` and `price_estimate` are both present please specify one or the other".to_string()))? } return Ok( U256::from_str(max_fee).map_err(|e| SubmitError::GenericError(e.to_string()))? From 5f9d3442798228c92fa0851e2196df97bf77a0fd Mon Sep 17 00:00:00 2001 From: PatStiles Date: Thu, 5 Dec 2024 15:35:14 -0300 Subject: [PATCH 10/74] print max_fee in ethers --- batcher/aligned/src/main.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/batcher/aligned/src/main.rs b/batcher/aligned/src/main.rs index 7bfe834500..5bd47ae98c 100644 --- a/batcher/aligned/src/main.rs +++ b/batcher/aligned/src/main.rs @@ -109,13 +109,13 @@ pub struct SubmitArgs { keystore_path: Option, #[arg(name = "Private key", long = "private_key")] private_key: Option, - #[arg(name = "Max Fee", long = "max_fee")] + #[arg(name = "Max Fee", help = "Specifies the `max_fee` the user of the submitted proof in ether" , long = "max_fee")] max_fee: Option, // String because U256 expects hex #[arg( name = "Price Estimate", long = "price_estimate", default_value = "default", - help = "`price_estimate` allows for a user to use the aligned_sdk `estimate_fee` function to compute there `max_fee`.\n Usage: `default,`, `instant`, \"custom \"", + help = "Specifies the aligned_sdk `estimate_fee` function should be used to compute the `max_fee` of the submitted proof based on the number of proofs in a batch and the current gas price from the node specified by `eth_rpc_url`.\n Usage: `default,`, `instant`, \"custom \"", allow_hyphen_values = true )] price_estimate: Option, @@ -313,6 +313,7 @@ async fn main() -> Result<(), AlignedError> { let eth_rpc_url = submit_args.eth_rpc_url.clone(); // `max_fee` is required unless `price_estimate` is present. let max_fee = submit_args.get_max_fee().await?; + info!("max_fee: {} ether", format_ether(max_fee)); let repetitions = submit_args.repetitions; let connect_addr = submit_args.batcher_url.clone(); From c2742ffb223e3c04a86037a3a0242da707b69563 Mon Sep 17 00:00:00 2001 From: PatStiles Date: Thu, 5 Dec 2024 15:43:15 -0300 Subject: [PATCH 11/74] doc changes --- batcher/aligned/src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/batcher/aligned/src/main.rs b/batcher/aligned/src/main.rs index 5bd47ae98c..98c28bbf75 100644 --- a/batcher/aligned/src/main.rs +++ b/batcher/aligned/src/main.rs @@ -109,7 +109,7 @@ pub struct SubmitArgs { keystore_path: Option, #[arg(name = "Private key", long = "private_key")] private_key: Option, - #[arg(name = "Max Fee", help = "Specifies the `max_fee` the user of the submitted proof in ether" , long = "max_fee")] + #[arg(name = "Max Fee", help = "Specifies the `max_fee` the user of the submitted proof in `ether`" , long = "max_fee")] max_fee: Option, // String because U256 expects hex #[arg( name = "Price Estimate", From 233004fc750b0f2103dfa9ffafbbff7bde4977b8 Mon Sep 17 00:00:00 2001 From: PatStiles Date: Thu, 5 Dec 2024 15:50:55 -0300 Subject: [PATCH 12/74] adjust fee estime with respect to gas percentage bump in batcher + fmt --- batcher/aligned-sdk/src/sdk.rs | 8 ++++++-- batcher/aligned/src/main.rs | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/batcher/aligned-sdk/src/sdk.rs b/batcher/aligned-sdk/src/sdk.rs index 0fb8d8b295..c1a8090fc7 100644 --- a/batcher/aligned-sdk/src/sdk.rs +++ b/batcher/aligned-sdk/src/sdk.rs @@ -8,7 +8,8 @@ use crate::{ core::{ constants::{ ADDITIONAL_SUBMISSION_GAS_COST_PER_PROOF, CONSTANT_GAS_COST, - DEFAULT_MAX_FEE_PROOF_NUMBER, INSTANT_MAX_FEE_PROOF_NUMBER, + DEFAULT_MAX_FEE_PROOF_NUMBER, GAS_PRICE_PERCENTAGE_MULTIPLIER, + INSTANT_MAX_FEE_PROOF_NUMBER, PERCENTAGE_DIVIDER, }, errors::{self, GetNonceError}, types::{ @@ -175,7 +176,10 @@ pub async fn suggest_fee_per_proof( / num_proofs_in_batch as u128; // Price of 1 / `num_proofs_in_batch` proof batch - let fee_per_proof = U256::from(estimated_gas_per_proof) * gas_price; + let fee_per_proof = (U256::from(estimated_gas_per_proof) + * gas_price + * U256::from(GAS_PRICE_PERCENTAGE_MULTIPLIER)) + / U256::from(PERCENTAGE_DIVIDER); Ok(fee_per_proof) } diff --git a/batcher/aligned/src/main.rs b/batcher/aligned/src/main.rs index 98c28bbf75..d4a5deaef6 100644 --- a/batcher/aligned/src/main.rs +++ b/batcher/aligned/src/main.rs @@ -109,7 +109,11 @@ pub struct SubmitArgs { keystore_path: Option, #[arg(name = "Private key", long = "private_key")] private_key: Option, - #[arg(name = "Max Fee", help = "Specifies the `max_fee` the user of the submitted proof in `ether`" , long = "max_fee")] + #[arg( + name = "Max Fee", + help = "Specifies the `max_fee` the user of the submitted proof in `ether`", + long = "max_fee" + )] max_fee: Option, // String because U256 expects hex #[arg( name = "Price Estimate", @@ -135,7 +139,7 @@ impl SubmitArgs { if let Some(max_fee) = &self.max_fee { // Inform the user if both are declared that `max_fee` is used. if self.price_estimate.is_some() { - return Err(SubmitError::GenericError("`max_fee` and `price_estimate` are both present please specify one or the other".to_string()))? + return Err(SubmitError::GenericError("`max_fee` and `price_estimate` are both present please specify one or the other".to_string()))?; } return Ok( U256::from_str(max_fee).map_err(|e| SubmitError::GenericError(e.to_string()))? From dccfbbf3feecb4fbda377dc52f83fb5381787476 Mon Sep 17 00:00:00 2001 From: PatStiles Date: Thu, 5 Dec 2024 16:10:12 -0300 Subject: [PATCH 13/74] max_fee => max_fee_wei --- 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 d4a5deaef6..d047d576cd 100644 --- a/batcher/aligned/src/main.rs +++ b/batcher/aligned/src/main.rs @@ -316,8 +316,8 @@ async fn main() -> Result<(), AlignedError> { let eth_rpc_url = submit_args.eth_rpc_url.clone(); // `max_fee` is required unless `price_estimate` is present. - let max_fee = submit_args.get_max_fee().await?; - info!("max_fee: {} ether", format_ether(max_fee)); + let max_fee_wei = submit_args.get_max_fee().await?; + info!("max_fee: {} ether", format_ether(max_fee_wei)); let repetitions = submit_args.repetitions; let connect_addr = submit_args.batcher_url.clone(); @@ -394,7 +394,7 @@ async fn main() -> Result<(), AlignedError> { &connect_addr, submit_args.network, &verification_data_arr, - max_fee, + max_fee_wei, wallet.clone(), nonce, ) From 196056b90c04a472b2d8c31c594db548091b5efd Mon Sep 17 00:00:00 2001 From: PatStiles Date: Thu, 5 Dec 2024 16:16:58 -0300 Subject: [PATCH 14/74] nit: types.rs network -> price estimate --- batcher/aligned-sdk/src/core/types.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/batcher/aligned-sdk/src/core/types.rs b/batcher/aligned-sdk/src/core/types.rs index fe6ea1c4a5..e1d927a896 100644 --- a/batcher/aligned-sdk/src/core/types.rs +++ b/batcher/aligned-sdk/src/core/types.rs @@ -112,7 +112,7 @@ impl TryFrom for PriceEstimate { } _ => { return Err( - "Invalid network, possible values are: \"default\", \"instant\", \"custom \"" + "Invalid price estimate, possible values are: \"default\", \"instant\", \"custom \"" .to_string(), ) } From d0a99e0bffad0b152ea92e314098d634ad00adda Mon Sep 17 00:00:00 2001 From: PatStiles Date: Thu, 5 Dec 2024 20:12:30 -0300 Subject: [PATCH 15/74] use mutual exclusive args + fmting + fmt --- batcher/Cargo.lock | 663 +++++++++++++++++++----------------- batcher/aligned/src/main.rs | 106 ++++-- 2 files changed, 424 insertions(+), 345 deletions(-) diff --git a/batcher/Cargo.lock b/batcher/Cargo.lock index 02ce4b2175..ce3fed7944 100644 --- a/batcher/Cargo.lock +++ b/batcher/Cargo.lock @@ -147,9 +147,9 @@ dependencies = [ [[package]] name = "allocator-api2" -version = "0.2.20" +version = "0.2.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45862d1c77f2228b9e10bc609d5bc203d86ebc9b87ad8d5d5167a6c9abf739d9" +checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" [[package]] name = "alloy-primitives" @@ -194,7 +194,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.90", ] [[package]] @@ -210,7 +210,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.90", "syn-solidity", "tiny-keccak", ] @@ -226,7 +226,7 @@ dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.90", "syn-solidity", ] @@ -302,9 +302,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.93" +version = "1.0.94" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c95c10ba0b00a02636238b814946408b1322d5ac4760326e6fb8ec956d85775" +checksum = "c1fd03a028ef38ba2276dce7e33fcd6369c158a1bca17946c4b1b701891c1ff7" [[package]] name = "ark-bn254" @@ -569,7 +569,7 @@ checksum = "721cae7de5c34fbb2acd27e21e6d2cf7b886dce0c27388d46c4e6c47ea4318dd" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.90", ] [[package]] @@ -597,7 +597,7 @@ checksum = "3c87f3f15e7794432337fc718554eaa4dc8f04c9677a950ffe366f20a162ae42" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.90", ] [[package]] @@ -619,7 +619,7 @@ dependencies = [ "aws-sdk-sts", "aws-smithy-async", "aws-smithy-http", - "aws-smithy-json", + "aws-smithy-json 0.60.7", "aws-smithy-runtime", "aws-smithy-runtime-api", "aws-smithy-types", @@ -650,9 +650,9 @@ dependencies = [ [[package]] name = "aws-runtime" -version = "1.4.3" +version = "1.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a10d5c055aa540164d9561a0e2e74ad30f0dcf7393c3a92f6733ddf9c5762468" +checksum = "b5ac934720fbb46206292d2c75b57e67acfc56fe7dfd34fb9a02334af08409ea" dependencies = [ "aws-credential-types", "aws-sigv4", @@ -676,9 +676,9 @@ dependencies = [ [[package]] name = "aws-sdk-s3" -version = "1.60.0" +version = "1.65.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0506cc60e392e33712d47717d5ae5760a3b134bf8ee7aea7e43df3d7e2669ae0" +checksum = "d3ba2c5c0f2618937ce3d4a5ad574b86775576fa24006bcb3128c6e2cbf3c34e" dependencies = [ "aws-credential-types", "aws-runtime", @@ -687,7 +687,7 @@ dependencies = [ "aws-smithy-checksums", "aws-smithy-eventstream", "aws-smithy-http", - "aws-smithy-json", + "aws-smithy-json 0.61.1", "aws-smithy-runtime", "aws-smithy-runtime-api", "aws-smithy-types", @@ -710,15 +710,15 @@ dependencies = [ [[package]] name = "aws-sdk-sso" -version = "1.49.0" +version = "1.50.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09677244a9da92172c8dc60109b4a9658597d4d298b188dd0018b6a66b410ca4" +checksum = "05ca43a4ef210894f93096039ef1d6fa4ad3edfabb3be92b80908b9f2e4b4eab" dependencies = [ "aws-credential-types", "aws-runtime", "aws-smithy-async", "aws-smithy-http", - "aws-smithy-json", + "aws-smithy-json 0.61.1", "aws-smithy-runtime", "aws-smithy-runtime-api", "aws-smithy-types", @@ -732,15 +732,15 @@ dependencies = [ [[package]] name = "aws-sdk-ssooidc" -version = "1.50.0" +version = "1.51.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81fea2f3a8bb3bd10932ae7ad59cc59f65f270fc9183a7e91f501dc5efbef7ee" +checksum = "abaf490c2e48eed0bb8e2da2fb08405647bd7f253996e0f93b981958ea0f73b0" dependencies = [ "aws-credential-types", "aws-runtime", "aws-smithy-async", "aws-smithy-http", - "aws-smithy-json", + "aws-smithy-json 0.61.1", "aws-smithy-runtime", "aws-smithy-runtime-api", "aws-smithy-types", @@ -754,15 +754,15 @@ dependencies = [ [[package]] name = "aws-sdk-sts" -version = "1.49.0" +version = "1.51.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53dcf5e7d9bd1517b8b998e170e650047cea8a2b85fe1835abe3210713e541b7" +checksum = "b68fde0d69c8bfdc1060ea7da21df3e39f6014da316783336deff0a9ec28f4bf" dependencies = [ "aws-credential-types", "aws-runtime", "aws-smithy-async", "aws-smithy-http", - "aws-smithy-json", + "aws-smithy-json 0.61.1", "aws-smithy-query", "aws-smithy-runtime", "aws-smithy-runtime-api", @@ -777,9 +777,9 @@ dependencies = [ [[package]] name = "aws-sigv4" -version = "1.2.5" +version = "1.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5619742a0d8f253be760bfbb8e8e8368c69e3587e4637af5754e488a611499b1" +checksum = "7d3820e0c08d0737872ff3c7c1f21ebbb6693d832312d6152bf18ef50a5471c2" dependencies = [ "aws-credential-types", "aws-smithy-eventstream", @@ -792,7 +792,7 @@ dependencies = [ "hex", "hmac", "http 0.2.12", - "http 1.1.0", + "http 1.2.0", "once_cell", "p256", "percent-encoding", @@ -877,6 +877,15 @@ dependencies = [ "aws-smithy-types", ] +[[package]] +name = "aws-smithy-json" +version = "0.61.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee4e69cc50921eb913c6b662f8d909131bb3e6ad6cb6090d3a39b66fc5c52095" +dependencies = [ + "aws-smithy-types", +] + [[package]] name = "aws-smithy-query" version = "0.60.7" @@ -889,9 +898,9 @@ dependencies = [ [[package]] name = "aws-smithy-runtime" -version = "1.7.3" +version = "1.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be28bd063fa91fd871d131fc8b68d7cd4c5fa0869bea68daca50dcb1cbd76be2" +checksum = "9f20685047ca9d6f17b994a07f629c813f08b5bce65523e47124879e60103d45" dependencies = [ "aws-smithy-async", "aws-smithy-http", @@ -924,7 +933,7 @@ dependencies = [ "aws-smithy-types", "bytes", "http 0.2.12", - "http 1.1.0", + "http 1.2.0", "pin-project-lite", "tokio", "tracing", @@ -942,7 +951,7 @@ dependencies = [ "bytes-utils", "futures-core", "http 0.2.12", - "http 1.1.0", + "http 1.2.0", "http-body 0.4.6", "http-body 1.0.1", "http-body-util", @@ -982,18 +991,18 @@ dependencies = [ [[package]] name = "axum" -version = "0.7.7" +version = "0.7.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "504e3947307ac8326a5437504c517c4b56716c9d98fac0028c2acc7ca47d70ae" +checksum = "edca88bc138befd0323b20752846e6587272d3b03b0343c8ea28a6f819e6e71f" dependencies = [ "async-trait", "axum-core", "bytes", "futures-util", - "http 1.1.0", + "http 1.2.0", "http-body 1.0.1", "http-body-util", - "hyper 1.5.0", + "hyper 1.5.1", "hyper-util", "itoa", "matchit", @@ -1006,7 +1015,7 @@ dependencies = [ "serde_json", "serde_path_to_error", "serde_urlencoded", - "sync_wrapper 1.0.1", + "sync_wrapper 1.0.2", "tokio", "tower", "tower-layer", @@ -1023,13 +1032,13 @@ dependencies = [ "async-trait", "bytes", "futures-util", - "http 1.1.0", + "http 1.2.0", "http-body 1.0.1", "http-body-util", "mime", "pin-project-lite", "rustversion", - "sync_wrapper 1.0.1", + "sync_wrapper 1.0.2", "tower-layer", "tower-service", "tracing", @@ -1037,9 +1046,9 @@ dependencies = [ [[package]] name = "backon" -version = "1.2.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4fa97bb310c33c811334143cf64c5bb2b7b3c06e453db6b095d7061eff8f113" +checksum = "ba5289ec98f68f28dd809fd601059e6aa908bb8f6108620930828283d4ee23d7" dependencies = [ "fastrand", "gloo-timers 0.3.0", @@ -1140,7 +1149,7 @@ dependencies = [ "regex", "rustc-hash 1.1.0", "shlex", - "syn 2.0.87", + "syn 2.0.90", ] [[package]] @@ -1204,9 +1213,9 @@ dependencies = [ [[package]] name = "blake3" -version = "1.5.4" +version = "1.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d82033247fd8e890df8f740e407ad4d038debb9eb1f40533fffb32e7d17dc6f7" +checksum = "b8ee0c1824c4dea5b5f81736aff91bae041d2c07ee1192bec91054e10e3e601e" dependencies = [ "arrayref", "arrayvec", @@ -1252,14 +1261,14 @@ dependencies = [ "maybe-async", "reqwest 0.12.9", "serde", - "thiserror", + "thiserror 1.0.69", ] [[package]] name = "borsh" -version = "1.5.2" +version = "1.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5327f6c99920069d1fe374aa743be1af0031dea9f250852cdf1ae6a0861ee24" +checksum = "2506947f73ad44e344215ccd6403ac2ae18cd8e046e581a441bf8d199f257f03" dependencies = [ "borsh-derive", "cfg_aliases", @@ -1267,15 +1276,15 @@ dependencies = [ [[package]] name = "borsh-derive" -version = "1.5.2" +version = "1.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10aedd8f1a81a8aafbfde924b0e3061cd6fedd6f6bbcfc6a76e6fd426d7bfe26" +checksum = "c2593a3b8b938bd68373196c9832f516be11fa487ef4ae745eb282e6a56a7244" dependencies = [ "once_cell", "proc-macro-crate 3.2.0", "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.90", ] [[package]] @@ -1302,9 +1311,9 @@ checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c" [[package]] name = "bytemuck" -version = "1.19.0" +version = "1.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8334215b81e418a0a7bdb8ef0849474f40bb10c8b71f1c4ed315cff49f32494d" +checksum = "8b37c88a63ffd85d15b406896cc343916d7cf57838a847b3a6f2ca5d39a5695a" dependencies = [ "bytemuck_derive", ] @@ -1317,7 +1326,7 @@ checksum = "bcfcc3cd946cb52f0bbfdbbcfa2f4e24f75ebb6c0e1002f7c25904fada18b9ec" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.90", ] [[package]] @@ -1328,9 +1337,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.8.0" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ac0150caa2ae65ca5bd83f25c7de183dea78d4d366469f148435e2acfbad0da" +checksum = "325918d6fe32f23b19878fe4b34794ae41fc19ddbe53b10571a4874d44ffd39b" dependencies = [ "serde", ] @@ -1377,9 +1386,9 @@ dependencies = [ [[package]] name = "cargo-platform" -version = "0.1.8" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24b1f0365a6c6bb4020cd05806fd0d33c44d38046b8bd7f0e40814b9763cabfc" +checksum = "e35af189006b9c0f00a064685c727031e3ed2d8020f7ba284d78cc2671bd36ea" dependencies = [ "serde", ] @@ -1395,14 +1404,14 @@ dependencies = [ "semver 1.0.23", "serde", "serde_json", - "thiserror", + "thiserror 1.0.69", ] [[package]] name = "cc" -version = "1.1.37" +version = "1.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40545c26d092346d8a8dab71ee48e7685a7a9cba76e634790c215b41a4a7b4cf" +checksum = "f34d93e62b03caf570cccc334cbc6c2fceca82f39211051345108adcba3eebdc" dependencies = [ "jobserver", "libc", @@ -1489,9 +1498,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.20" +version = "4.5.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b97f376d85a664d5837dbae44bf546e6477a679ff6610010f17276f686d867e8" +checksum = "3135e7ec2ef7b10c6ed8950f0f792ed96ee093fa088608f1c76e569722700c84" dependencies = [ "clap_builder", "clap_derive", @@ -1499,9 +1508,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.20" +version = "4.5.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19bc80abd44e4bed93ca373a0704ccbd1b710dc5749406201bb018272808dc54" +checksum = "30582fc632330df2bd26877bde0c1f4470d57c582bbc070376afcd04d8cb4838" dependencies = [ "anstream", "anstyle", @@ -1518,14 +1527,14 @@ dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.90", ] [[package]] name = "clap_lex" -version = "0.7.2" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1462739cb27611015575c0c11df5df7601141071f07518d56fcc1be504cbec97" +checksum = "f46ad14479a25103f283c0f10005961cf086d8dc42205bb44c46ac563475dca6" [[package]] name = "coins-bip32" @@ -1540,7 +1549,7 @@ dependencies = [ "k256", "serde", "sha2", - "thiserror", + "thiserror 1.0.69", ] [[package]] @@ -1556,7 +1565,7 @@ dependencies = [ "pbkdf2 0.12.2", "rand", "sha2", - "thiserror", + "thiserror 1.0.69", ] [[package]] @@ -1576,7 +1585,7 @@ dependencies = [ "serde_derive", "sha2", "sha3", - "thiserror", + "thiserror 1.0.69", ] [[package]] @@ -1594,15 +1603,15 @@ dependencies = [ "encode_unicode", "lazy_static", "libc", - "unicode-width", + "unicode-width 0.1.14", "windows-sys 0.52.0", ] [[package]] name = "const-hex" -version = "1.13.1" +version = "1.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0121754e84117e65f9d90648ee6aa4882a6e63110307ab73967a4c5e7e69e586" +checksum = "4b0485bab839b018a8f1723fc5391819fea5f8f0f32288ef8a735fd096b6160c" dependencies = [ "cfg-if", "cpufeatures", @@ -1664,9 +1673,9 @@ dependencies = [ [[package]] name = "cpufeatures" -version = "0.2.15" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ca741a962e1b0bff6d724a1a0958b686406e853bb14061f218562e1896f95e6" +checksum = "16b80225097f2e5ae4e7179dd2266824648f3e2f49d9134d584b76389d31c4c3" dependencies = [ "libc", ] @@ -1786,7 +1795,7 @@ checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.90", ] [[package]] @@ -1923,7 +1932,7 @@ dependencies = [ "proc-macro2", "quote", "rustc_version 0.4.1", - "syn 2.0.87", + "syn 2.0.90", ] [[package]] @@ -1943,7 +1952,7 @@ checksum = "cb7330aeadfbe296029522e6c40f315320aba36fc43a5b3632f3795348f3bd22" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.90", ] [[package]] @@ -1955,7 +1964,7 @@ dependencies = [ "console", "shell-words", "tempfile", - "thiserror", + "thiserror 1.0.69", "zeroize", ] @@ -2030,7 +2039,7 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.90", ] [[package]] @@ -2204,7 +2213,7 @@ checksum = "f282cfdfe92516eb26c2af8589c274c7c17681f5ecc03c18255fe741c6aa64eb" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.90", ] [[package]] @@ -2238,12 +2247,12 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "errno" -version = "0.3.9" +version = "0.3.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" +checksum = "33d852cb9b869c2a9b3df2f71a3074817f01e1844f839a144f5fcef059a4eb5d" dependencies = [ "libc", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -2264,7 +2273,7 @@ dependencies = [ "serde_json", "sha2", "sha3", - "thiserror", + "thiserror 1.0.69", "uuid 0.8.2", ] @@ -2281,7 +2290,7 @@ dependencies = [ "serde", "serde_json", "sha3", - "thiserror", + "thiserror 1.0.69", "uint", ] @@ -2360,7 +2369,7 @@ dependencies = [ "pin-project", "serde", "serde_json", - "thiserror", + "thiserror 1.0.69", ] [[package]] @@ -2382,7 +2391,7 @@ dependencies = [ "reqwest 0.11.27", "serde", "serde_json", - "syn 2.0.87", + "syn 2.0.90", "toml", "walkdir", ] @@ -2400,7 +2409,7 @@ dependencies = [ "proc-macro2", "quote", "serde_json", - "syn 2.0.87", + "syn 2.0.90", ] [[package]] @@ -2426,9 +2435,9 @@ dependencies = [ "serde", "serde_json", "strum", - "syn 2.0.87", + "syn 2.0.90", "tempfile", - "thiserror", + "thiserror 1.0.69", "tiny-keccak", "unicode-xid", ] @@ -2445,7 +2454,7 @@ dependencies = [ "semver 1.0.23", "serde", "serde_json", - "thiserror", + "thiserror 1.0.69", "tracing", ] @@ -2469,7 +2478,7 @@ dependencies = [ "reqwest 0.11.27", "serde", "serde_json", - "thiserror", + "thiserror 1.0.69", "tokio", "tracing", "tracing-futures", @@ -2502,7 +2511,7 @@ dependencies = [ "reqwest 0.11.27", "serde", "serde_json", - "thiserror", + "thiserror 1.0.69", "tokio", "tokio-tungstenite 0.20.1", "tracing", @@ -2529,7 +2538,7 @@ dependencies = [ "ethers-core", "rand", "sha2", - "thiserror", + "thiserror 1.0.69", "tracing", ] @@ -2557,7 +2566,7 @@ dependencies = [ "serde_json", "solang-parser", "svm-rs", - "thiserror", + "thiserror 1.0.69", "tiny-keccak", "tokio", "tracing", @@ -2658,9 +2667,9 @@ checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" [[package]] name = "flate2" -version = "1.0.34" +version = "1.0.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1b589b4dc103969ad3cf85c950899926ec64300a1a46d76c03a6072957036f0" +checksum = "c936bfdafb507ebbf50b8074c54fa31c5be9a1e7e5f467dd659697041407d07c" dependencies = [ "crc32fast", "miniz_oxide", @@ -2705,7 +2714,7 @@ checksum = "1a5c6c585bc94aaf2c7b51dd4c2ba22680844aba4c687be581871a6f518c5742" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.90", ] [[package]] @@ -2811,7 +2820,7 @@ checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.90", ] [[package]] @@ -2882,9 +2891,9 @@ dependencies = [ [[package]] name = "generic-array" -version = "1.1.0" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96512db27971c2c3eece70a1e106fbe6c87760234e31e8f7e5634912fe52794a" +checksum = "2cb8bc4c28d15ade99c7e90b219f30da4be5c88e586277e8cbe886beeb868ab2" dependencies = [ "serde", "typenum", @@ -2897,8 +2906,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" dependencies = [ "cfg-if", + "js-sys", "libc", "wasi", + "wasm-bindgen", ] [[package]] @@ -2994,16 +3005,16 @@ dependencies = [ [[package]] name = "h2" -version = "0.4.6" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "524e8ac6999421f49a846c2d4411f337e53497d8ec55d67753beffa43c5d9205" +checksum = "ccae279728d634d083c00f6099cb58f01cc99c145b84b8be2f6c74618d79922e" dependencies = [ "atomic-waker", "bytes", "fnv", "futures-core", "futures-sink", - "http 1.1.0", + "http 1.2.0", "indexmap", "slab", "tokio", @@ -3066,9 +3077,9 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.15.1" +version = "0.15.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a9bfc1af68b1726ea47d3d5109de126281def866b33970e10fbab11b5dafab3" +checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289" dependencies = [ "allocator-api2", "equivalent", @@ -3169,9 +3180,9 @@ dependencies = [ [[package]] name = "http" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21b9ddb458710bc376481b842f5da65cdf31522de232c1ca8146abce2a358258" +checksum = "f16ca2af56261c99fba8bac40a10251ce8188205a4c448fbb745a2e4daa76fea" dependencies = [ "bytes", "fnv", @@ -3196,7 +3207,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184" dependencies = [ "bytes", - "http 1.1.0", + "http 1.2.0", ] [[package]] @@ -3207,7 +3218,7 @@ checksum = "793429d76616a256bcb62c2a2ec2bed781c8307e797e2598c50010f2bee2544f" dependencies = [ "bytes", "futures-util", - "http 1.1.0", + "http 1.2.0", "http-body 1.0.1", "pin-project-lite", ] @@ -3256,15 +3267,15 @@ dependencies = [ [[package]] name = "hyper" -version = "1.5.0" +version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbbff0a806a4728c99295b254c8838933b5b082d75e3cb70c8dab21fdfbcfa9a" +checksum = "97818827ef4f364230e16705d4706e2897df2bb60617d6ca15d598025a3c481f" dependencies = [ "bytes", "futures-channel", "futures-util", - "h2 0.4.6", - "http 1.1.0", + "h2 0.4.7", + "http 1.2.0", "http-body 1.0.1", "httparse", "httpdate", @@ -3298,15 +3309,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08afdbb5c31130e3034af566421053ab03787c640246a446327f550d11bcb333" dependencies = [ "futures-util", - "http 1.1.0", - "hyper 1.5.0", + "http 1.2.0", + "hyper 1.5.1", "hyper-util", - "rustls 0.23.16", + "rustls 0.23.19", "rustls-pki-types", "tokio", - "tokio-rustls 0.26.0", + "tokio-rustls 0.26.1", "tower-service", - "webpki-roots 0.26.6", + "webpki-roots 0.26.7", ] [[package]] @@ -3330,7 +3341,7 @@ checksum = "70206fc6890eaca9fde8a0bf71caa2ddfc9fe045ac9e5c70df101a7dbde866e0" dependencies = [ "bytes", "http-body-util", - "hyper 1.5.0", + "hyper 1.5.1", "hyper-util", "native-tls", "tokio", @@ -3347,9 +3358,9 @@ dependencies = [ "bytes", "futures-channel", "futures-util", - "http 1.1.0", + "http 1.2.0", "http-body 1.0.1", - "hyper 1.5.0", + "hyper 1.5.1", "pin-project-lite", "socket2", "tokio", @@ -3472,7 +3483,7 @@ checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.90", ] [[package]] @@ -3525,13 +3536,13 @@ dependencies = [ [[package]] name = "impl-trait-for-tuples" -version = "0.2.2" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11d7a9f6330b71fea57921c9b61c47ee6e84f72d394754eff6163ae67e7395eb" +checksum = "a0eb5a3343abf848c0984fe4604b2b105da9539376e24fc0a3b0007411ae4fd9" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.90", ] [[package]] @@ -3542,25 +3553,25 @@ checksum = "ce23b50ad8242c51a442f3ff322d56b02f08852c77e4c0b4d3fd684abc89c683" [[package]] name = "indexmap" -version = "2.6.0" +version = "2.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "707907fe3c25f5424cce2cb7e1cbcafee6bdbe735ca90ef77c29e84591e5b9da" +checksum = "62f822373a4fe84d4bb149bf54e584a7f4abec90e072ed49cda0edea5b95471f" dependencies = [ "equivalent", - "hashbrown 0.15.1", + "hashbrown 0.15.2", ] [[package]] name = "indicatif" -version = "0.17.8" +version = "0.17.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "763a5a8f45087d6bcea4222e7b72c291a054edf80e4ef6efd2a4979878c7bea3" +checksum = "cbf675b85ed934d3c67b5c5469701eec7db22689d0a2139d856e0925fa28b281" dependencies = [ "console", - "instant", "number_prefix", "portable-atomic", - "unicode-width", + "unicode-width 0.2.0", + "web-time", ] [[package]] @@ -3631,9 +3642,9 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.11" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" +checksum = "d75a2a4b1b190afb6f5425f10f6a8f959d2ea0b9c2b1d79553551850539e4674" [[package]] name = "jobserver" @@ -3646,10 +3657,11 @@ dependencies = [ [[package]] name = "js-sys" -version = "0.3.72" +version = "0.3.74" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a88f1bda2bd75b0452a14784937d796722fdebfe50df998aeb3f0b7603019a9" +checksum = "a865e038f7f6ed956f788f0d7d60c541fff74c7bd74272c5d4cf15c63743e705" dependencies = [ + "once_cell", "wasm-bindgen", ] @@ -3784,7 +3796,7 @@ dependencies = [ "proc-macro2", "quote", "regex", - "syn 2.0.87", + "syn 2.0.90", ] [[package]] @@ -3798,9 +3810,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.162" +version = "0.2.167" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18d287de67fe55fd7e1581fe933d965a5a9477b38e949cfa9f8574ef01506398" +checksum = "09d6582e104315a817dff97f75133544b2e094ee22447d2acf4a74e189ba06fc" [[package]] name = "libgit2-sys" @@ -3816,9 +3828,9 @@ dependencies = [ [[package]] name = "libloading" -version = "0.8.5" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4979f22fdb869068da03c9f7528f8297c6fd2606bc3a4affe42e6a823fdb8da4" +checksum = "fc2f4eb4bc735547cfed7c0a4922cbd04a4655978c09b54f1f7b228750664c34" dependencies = [ "cfg-if", "windows-targets 0.52.6", @@ -3860,9 +3872,9 @@ checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" [[package]] name = "litemap" -version = "0.7.3" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "643cb0b8d4fcc284004d5fd0d67ccf61dfffadb7f75e1e71bc420f4688a3a704" +checksum = "4ee93343901ab17bd981295f2cf0026d4ad018c7c31ba84549a4ddbb47a45104" [[package]] name = "lock_api" @@ -3886,7 +3898,7 @@ version = "0.12.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "234cf4f4a04dc1f57e24b96cc0cd600cf2af460d4161ac5ecdd0af8e1f3b2a38" dependencies = [ - "hashbrown 0.15.1", + "hashbrown 0.15.2", ] [[package]] @@ -3921,7 +3933,7 @@ checksum = "5cf92c10c7e361d6b99666ec1c6f9805b0bea2c3bd8c78dc6fe98ac5bd78db11" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.90", ] [[package]] @@ -3994,11 +4006,10 @@ dependencies = [ [[package]] name = "mio" -version = "1.0.2" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80e04d1dcff3aae0704555fe5fee3bcfaf3d1fdf8a7e521d5b9d2b42acb52cec" +checksum = "2886843bf800fba2e3377cff24abf6379b4c4d5c6681eaf9ea5b0d15090450bd" dependencies = [ - "hermit-abi", "libc", "wasi", "windows-sys 0.52.0", @@ -4235,7 +4246,7 @@ dependencies = [ "proc-macro-crate 3.2.0", "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.90", ] [[package]] @@ -4325,7 +4336,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.90", ] [[package]] @@ -4789,7 +4800,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "879952a81a83930934cbf1786752d6dedc3b1f29e8f8fb2ad1d0a36f377cf442" dependencies = [ "memchr", - "thiserror", + "thiserror 1.0.69", "ucd-trie", ] @@ -4843,7 +4854,7 @@ dependencies = [ "phf_shared 0.11.2", "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.90", ] [[package]] @@ -4881,7 +4892,7 @@ checksum = "3c0f5fad0874fc7abcd4d750e76917eaebbecaa2c20bde22e1dbeeba8beb758c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.90", ] [[package]] @@ -4924,9 +4935,9 @@ checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2" [[package]] name = "portable-atomic" -version = "1.9.0" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc9c68a3f6da06753e9335d63e27f6b9754dd1920d941135b7ea8224f141adb2" +checksum = "280dc24453071f1b63954171985a0b0d30058d287960968b9b2aca264c8d4ee6" [[package]] name = "powerfmt" @@ -4956,7 +4967,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "64d1ec885c64d0457d564db4ec299b2dae3f9c02808b8ad9c3a089c591b18033" dependencies = [ "proc-macro2", - "syn 2.0.87", + "syn 2.0.90", ] [[package]] @@ -5029,9 +5040,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.89" +version = "1.0.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f139b0662de085916d1fb67d2b4169d1addddda1919e696f3252b740b629986e" +checksum = "37d3544b3f2748c54e147655edb5025752e2303145b5aefb3c3ea2c78b973bb0" dependencies = [ "unicode-ident", ] @@ -5073,7 +5084,7 @@ dependencies = [ "parking_lot", "procfs", "protobuf", - "thiserror", + "thiserror 1.0.69", ] [[package]] @@ -5116,7 +5127,7 @@ dependencies = [ "itertools 0.13.0", "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.90", ] [[package]] @@ -5133,37 +5144,40 @@ checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" [[package]] name = "quinn" -version = "0.11.5" +version = "0.11.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c7c5fdde3cdae7203427dc4f0a68fe0ed09833edc525a03456b153b79828684" +checksum = "62e96808277ec6f97351a2380e6c25114bc9e67037775464979f3037c92d05ef" dependencies = [ "bytes", "pin-project-lite", "quinn-proto", "quinn-udp", - "rustc-hash 2.0.0", - "rustls 0.23.16", + "rustc-hash 2.1.0", + "rustls 0.23.19", "socket2", - "thiserror", + "thiserror 2.0.4", "tokio", "tracing", ] [[package]] name = "quinn-proto" -version = "0.11.8" +version = "0.11.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fadfaed2cd7f389d0161bb73eeb07b7b78f8691047a6f3e73caaeae55310a4a6" +checksum = "a2fe5ef3495d7d2e377ff17b1a8ce2ee2ec2a18cde8b6ad6619d65d0701c135d" dependencies = [ "bytes", + "getrandom", "rand", "ring 0.17.8", - "rustc-hash 2.0.0", - "rustls 0.23.16", + "rustc-hash 2.1.0", + "rustls 0.23.19", + "rustls-pki-types", "slab", - "thiserror", + "thiserror 2.0.4", "tinyvec", "tracing", + "web-time", ] [[package]] @@ -5280,7 +5294,7 @@ checksum = "ba009ff324d1fc1b900bd1fdb31564febe58a8ccc8a6fdbb93b543d33b13ca43" dependencies = [ "getrandom", "libredox", - "thiserror", + "thiserror 1.0.69", ] [[package]] @@ -5389,11 +5403,11 @@ dependencies = [ "futures-channel", "futures-core", "futures-util", - "h2 0.4.6", - "http 1.1.0", + "h2 0.4.7", + "http 1.2.0", "http-body 1.0.1", "http-body-util", - "hyper 1.5.0", + "hyper 1.5.1", "hyper-rustls 0.27.3", "hyper-tls 0.6.0", "hyper-util", @@ -5406,17 +5420,17 @@ dependencies = [ "percent-encoding", "pin-project-lite", "quinn", - "rustls 0.23.16", + "rustls 0.23.19", "rustls-pemfile 2.2.0", "rustls-pki-types", "serde", "serde_json", "serde_urlencoded", - "sync_wrapper 1.0.1", + "sync_wrapper 1.0.2", "system-configuration 0.6.1", "tokio", "tokio-native-tls", - "tokio-rustls 0.26.0", + "tokio-rustls 0.26.1", "tokio-util", "tower-service", "url", @@ -5424,7 +5438,7 @@ dependencies = [ "wasm-bindgen-futures", "wasm-streams", "web-sys", - "webpki-roots 0.26.6", + "webpki-roots 0.26.7", "windows-registry", ] @@ -5436,10 +5450,10 @@ checksum = "562ceb5a604d3f7c885a792d42c199fd8af239d0a51b2fa6a78aafa092452b04" dependencies = [ "anyhow", "async-trait", - "http 1.1.0", + "http 1.2.0", "reqwest 0.12.9", "serde", - "thiserror", + "thiserror 1.0.69", "tower-service", ] @@ -5766,9 +5780,9 @@ checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" [[package]] name = "rustc-hash" -version = "2.0.0" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "583034fd73374156e66797ed8e5b0d5690409c9226b22d87cb7f19821c05d152" +checksum = "c7fb8039b3032c191086b10f11f319a6e99e1e82889c5cc6046f515c9db1d497" [[package]] name = "rustc-hex" @@ -5796,9 +5810,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.40" +version = "0.38.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99e4ea3e1cdc4b559b8e5650f9c8e5998e3e5c1343b4eaf034565f32318d63c0" +checksum = "d7f649912bc1495e167a6edee79151c84b1bad49748cb4f1f1167f459f6224f6" dependencies = [ "bitflags 2.6.0", "errno", @@ -5821,9 +5835,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.23.16" +version = "0.23.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eee87ff5d9b36712a58574e12e9f0ea80f915a5b0ac518d322b24a465617925e" +checksum = "934b404430bb06b3fae2cba809eb45a1ab1aecd64491213d7c3301b88393f8d1" dependencies = [ "once_cell", "ring 0.17.8", @@ -5868,6 +5882,9 @@ name = "rustls-pki-types" version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "16f1201b3c9a7ee8039bcadc17b7e605e2945b27eee7631788c1bd2b0643674b" +dependencies = [ + "web-time", +] [[package]] name = "rustls-webpki" @@ -5934,9 +5951,9 @@ dependencies = [ [[package]] name = "scale-info" -version = "2.11.5" +version = "2.11.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1aa7ffc1c0ef49b0452c6e2986abf2b07743320641ffd5fc63d552458e3b779b" +checksum = "346a3b32eba2640d17a9cb5927056b08f3de90f65b72fe09402c2ad07d684d0b" dependencies = [ "cfg-if", "derive_more 1.0.0", @@ -5946,30 +5963,30 @@ dependencies = [ [[package]] name = "scale-info-derive" -version = "2.11.5" +version = "2.11.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46385cc24172cf615450267463f937c10072516359b3ff1cb24228a4a08bf951" +checksum = "c6630024bf739e2179b91fb424b28898baf819414262c5d376677dbff1fe7ebf" dependencies = [ "proc-macro-crate 3.2.0", "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.90", ] [[package]] name = "scc" -version = "2.2.4" +version = "2.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8d25269dd3a12467afe2e510f69fb0b46b698e5afb296b59f2145259deaf8e8" +checksum = "66b202022bb57c049555430e11fc22fea12909276a80a4c3d368da36ac1d88ed" dependencies = [ "sdd", ] [[package]] name = "schannel" -version = "0.1.26" +version = "0.1.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01227be5826fa0690321a2ba6c5cd57a19cf3f6a09e76973b58e61de6ab9d1c1" +checksum = "1f29ebaa345f945cec9fbbc532eb307f0fdad8161f281b6369539c8d84876b3d" dependencies = [ "windows-sys 0.59.0", ] @@ -6085,9 +6102,9 @@ dependencies = [ [[package]] name = "semver-parser" -version = "0.10.2" +version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00b0bef5b7f9e0df16536d3961cfb6e84331c065b4066afb39768d0e319411f7" +checksum = "9900206b54a3527fdc7b8a938bffd94a568bac4f4aa8113b209df75a09c0dec2" dependencies = [ "pest", ] @@ -6106,29 +6123,29 @@ checksum = "cd0b0ec5f1c1ca621c432a25813d8d60c88abe6d3e08a3eb9cf37d97a0fe3d73" [[package]] name = "serde" -version = "1.0.214" +version = "1.0.215" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f55c3193aca71c12ad7890f1785d2b73e1b9f63a0bbc353c08ef26fe03fc56b5" +checksum = "6513c1ad0b11a9376da888e3e0baa0077f1aed55c17f50e7b2397136129fb88f" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.214" +version = "1.0.215" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de523f781f095e28fa605cdce0f8307e451cc0fd14e2eb4cd2e98a355b147766" +checksum = "ad1e866f866923f252f05c889987993144fb74e722403468a4ebd70c3cd756c0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.90", ] [[package]] name = "serde_json" -version = "1.0.132" +version = "1.0.133" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d726bfaff4b320266d395898905d0eba0345aae23b54aee3a737e260fd46db03" +checksum = "c7fceb2473b9166b2294ef05efcb65a3db80803f0b03ef86a5fc88a2b85ee377" dependencies = [ "itoa", "memchr", @@ -6154,7 +6171,7 @@ checksum = "6c64451ba24fc7a6a2d60fc75dd9c83c90903b19028d4eff35e88fc1e86564e9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.90", ] [[package]] @@ -6213,7 +6230,7 @@ checksum = "5d69265a08751de7844521fd15003ae0a888e035773ba05695c5c759a6f89eef" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.90", ] [[package]] @@ -6316,7 +6333,7 @@ checksum = "adc4e5204eb1910f40f9cfa375f6f05b68c3abac4b6fd879c8ff5e7ae8a0a085" dependencies = [ "num-bigint 0.4.6", "num-traits", - "thiserror", + "thiserror 1.0.69", "time", ] @@ -6359,9 +6376,9 @@ dependencies = [ [[package]] name = "socket2" -version = "0.5.7" +version = "0.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce305eb0b4296696835b71df73eb912e0f1ffd2556a501fcede6e0c50349191c" +checksum = "c970269d99b64e60ec3bd6ad27270092a5394c4e309314b18ae3fe575695fbe8" dependencies = [ "libc", "windows-sys 0.52.0", @@ -6377,7 +6394,7 @@ dependencies = [ "lalrpop", "lalrpop-util", "phf", - "thiserror", + "thiserror 1.0.69", "unicode-xid", ] @@ -6407,7 +6424,7 @@ dependencies = [ "sp1-stark", "strum", "strum_macros", - "thiserror", + "thiserror 1.0.69", "tiny-keccak", "tracing", "typenum", @@ -6422,7 +6439,7 @@ dependencies = [ "bincode", "cfg-if", "elliptic-curve 0.13.8", - "generic-array 1.1.0", + "generic-array 1.1.1", "hashbrown 0.14.5", "hex", "itertools 0.13.0", @@ -6453,10 +6470,10 @@ dependencies = [ "strum", "strum_macros", "tempfile", - "thiserror", + "thiserror 1.0.69", "tracing", "tracing-forest", - "tracing-subscriber 0.3.18", + "tracing-subscriber 0.3.19", "typenum", "web-time", ] @@ -6470,7 +6487,7 @@ dependencies = [ "curve25519-dalek", "dashu", "elliptic-curve 0.13.8", - "generic-array 1.1.0", + "generic-array 1.1.1", "itertools 0.13.0", "k256", "num", @@ -6544,9 +6561,9 @@ dependencies = [ "sp1-stark", "subtle-encoding", "tempfile", - "thiserror", + "thiserror 1.0.69", "tracing", - "tracing-subscriber 0.3.18", + "tracing-subscriber 0.3.19", ] [[package]] @@ -6632,7 +6649,7 @@ dependencies = [ "sp1-primitives", "sp1-stark", "static_assertions", - "thiserror", + "thiserror 1.0.69", "tracing", "vec_map", "zkhash", @@ -6705,7 +6722,7 @@ dependencies = [ "strum", "strum_macros", "tempfile", - "thiserror", + "thiserror 1.0.69", "tokio", "tracing", "twirp-rs", @@ -6743,7 +6760,7 @@ dependencies = [ "strum", "strum_macros", "sysinfo", - "thiserror", + "thiserror 1.0.69", "tracing", ] @@ -6786,7 +6803,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d904e7009df136af5297832a3ace3370cd14ff1546a232f4f185036c2736fcac" dependencies = [ "quote", - "syn 2.0.87", + "syn 2.0.90", ] [[package]] @@ -6839,7 +6856,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.87", + "syn 2.0.90", ] [[package]] @@ -6872,7 +6889,7 @@ dependencies = [ "serde", "serde_json", "sha2", - "thiserror", + "thiserror 1.0.69", "url", "zip", ] @@ -6890,9 +6907,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.87" +version = "2.0.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25aa4ce346d03a6dcd68dd8b4010bcb74e54e62c90c573f394c46eae99aba32d" +checksum = "919d3b74a5dd0ccd15aeb8f93e7006bd9e14c295087c9896a110f490752bcf31" dependencies = [ "proc-macro2", "quote", @@ -6908,7 +6925,7 @@ dependencies = [ "paste", "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.90", ] [[package]] @@ -6919,9 +6936,9 @@ checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" [[package]] name = "sync_wrapper" -version = "1.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7065abeca94b6a8a577f9bd45aa0867a2238b74e8eb67cf10d492bc39351394" +checksum = "0bf256ce5efdfa370213c1dabab5935a12e49f2c58d15e9eac2870d3b4f27263" dependencies = [ "futures-core", ] @@ -6934,7 +6951,7 @@ checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.90", ] [[package]] @@ -7049,7 +7066,16 @@ version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" dependencies = [ - "thiserror-impl", + "thiserror-impl 1.0.69", +] + +[[package]] +name = "thiserror" +version = "2.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f49a1853cf82743e3b7950f77e0f4d622ca36cf4317cba00c767838bac8d490" +dependencies = [ + "thiserror-impl 2.0.4", ] [[package]] @@ -7060,7 +7086,18 @@ checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.90", +] + +[[package]] +name = "thiserror-impl" +version = "2.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8381894bb3efe0c4acac3ded651301ceee58a15d47c2e34885ed1908ad667061" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.90", ] [[package]] @@ -7075,9 +7112,9 @@ dependencies = [ [[package]] name = "time" -version = "0.3.36" +version = "0.3.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5dfd88e563464686c916c7e46e623e520ddc6d79fa6641390f2e3fa86e83e885" +checksum = "35e7868883861bd0e56d9ac6efcaaca0d6d5d82a2a7ec8209ff492c07cf37b21" dependencies = [ "deranged", "itoa", @@ -7098,9 +7135,9 @@ checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" [[package]] name = "time-macros" -version = "0.2.18" +version = "0.2.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f252a68540fde3a3877aeea552b832b40ab9a69e318efd078774a01ddee1ccf" +checksum = "2834e6017e3e5e4b9834939793b282bc03b37a3336245fa820e35e233e2a85de" dependencies = [ "num-conv", "time-core", @@ -7142,9 +7179,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.41.1" +version = "1.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22cfb5bee7a6a52939ca9224d6ac897bb669134078daa8735560897f69de4d33" +checksum = "5cec9b21b0450273377fc97bd4c33a8acffc8c996c987a7c5b319a0083707551" dependencies = [ "backtrace", "bytes", @@ -7166,7 +7203,7 @@ checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.90", ] [[package]] @@ -7191,12 +7228,11 @@ dependencies = [ [[package]] name = "tokio-rustls" -version = "0.26.0" +version = "0.26.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c7bc40d0e5a97695bb96e27995cd3a08538541b0a846f65bba7a359f36700d4" +checksum = "5f6d0975eaace0cf0fcadee4e4aaa5da15b5c079146f2cffb67c113be122bf37" dependencies = [ - "rustls 0.23.16", - "rustls-pki-types", + "rustls 0.23.19", "tokio", ] @@ -7236,13 +7272,13 @@ dependencies = [ "futures-util", "log", "native-tls", - "rustls 0.23.16", + "rustls 0.23.19", "rustls-pki-types", "tokio", "tokio-native-tls", - "tokio-rustls 0.26.0", + "tokio-rustls 0.26.1", "tungstenite 0.23.0", - "webpki-roots 0.26.6", + "webpki-roots 0.26.7", ] [[package]] @@ -7254,20 +7290,20 @@ dependencies = [ "futures-util", "log", "native-tls", - "rustls 0.23.16", + "rustls 0.23.19", "rustls-pki-types", "tokio", "tokio-native-tls", - "tokio-rustls 0.26.0", + "tokio-rustls 0.26.1", "tungstenite 0.24.0", - "webpki-roots 0.26.6", + "webpki-roots 0.26.7", ] [[package]] name = "tokio-util" -version = "0.7.12" +version = "0.7.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61e7c3654c13bcd040d4a03abee2c75b1d14a37b423cf5a813ceae1cc903ec6a" +checksum = "d7fcaa8d55a2bdd6b83ace262b016eca0d79ee02818c5c1bcdf0305114081078" dependencies = [ "bytes", "futures-core", @@ -7351,9 +7387,9 @@ checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" [[package]] name = "tracing" -version = "0.1.40" +version = "0.1.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" +checksum = "784e0ac535deb450455cbfa28a6f0df145ea1bb7ae51b821cf5e7927fdcfbdd0" dependencies = [ "log", "pin-project-lite", @@ -7363,20 +7399,20 @@ dependencies = [ [[package]] name = "tracing-attributes" -version = "0.1.27" +version = "0.1.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" +checksum = "395ae124c09f9e6918a2310af6038fba074bcf474ac352496d5910dd59a2226d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.90", ] [[package]] name = "tracing-core" -version = "0.1.32" +version = "0.1.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" +checksum = "e672c95779cf947c5311f83787af4fa8fffd12fb27e4993211a84bdfd9610f9c" dependencies = [ "once_cell", "valuable", @@ -7390,9 +7426,9 @@ checksum = "ee40835db14ddd1e3ba414292272eddde9dad04d3d4b65509656414d1c42592f" dependencies = [ "ansi_term", "smallvec", - "thiserror", + "thiserror 1.0.69", "tracing", - "tracing-subscriber 0.3.18", + "tracing-subscriber 0.3.19", ] [[package]] @@ -7427,9 +7463,9 @@ dependencies = [ [[package]] name = "tracing-subscriber" -version = "0.3.18" +version = "0.3.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad0f048c97dbd9faa9b7df56362b8ebcaa52adb06b498c050d2f4e32f90a7a8b" +checksum = "e8189decb5ac0fa7bc8b96b7cb9b2701d60d48805aca84a238004d665fcc4008" dependencies = [ "matchers", "nu-ansi-term", @@ -7464,7 +7500,7 @@ dependencies = [ "rand", "rustls 0.21.12", "sha1", - "thiserror", + "thiserror 1.0.69", "url", "utf-8", ] @@ -7478,12 +7514,12 @@ dependencies = [ "byteorder", "bytes", "data-encoding", - "http 1.1.0", + "http 1.2.0", "httparse", "log", "rand", "sha1", - "thiserror", + "thiserror 1.0.69", "url", "utf-8", ] @@ -7497,15 +7533,15 @@ dependencies = [ "byteorder", "bytes", "data-encoding", - "http 1.1.0", + "http 1.2.0", "httparse", "log", "native-tls", "rand", - "rustls 0.23.16", + "rustls 0.23.19", "rustls-pki-types", "sha1", - "thiserror", + "thiserror 1.0.69", "utf-8", ] @@ -7518,15 +7554,15 @@ dependencies = [ "byteorder", "bytes", "data-encoding", - "http 1.1.0", + "http 1.2.0", "httparse", "log", "native-tls", "rand", - "rustls 0.23.16", + "rustls 0.23.19", "rustls-pki-types", "sha1", - "thiserror", + "thiserror 1.0.69", "utf-8", ] @@ -7539,14 +7575,14 @@ dependencies = [ "async-trait", "axum", "futures", - "http 1.1.0", + "http 1.2.0", "http-body-util", - "hyper 1.5.0", + "hyper 1.5.1", "prost", "reqwest 0.12.9", "serde", "serde_json", - "thiserror", + "thiserror 1.0.69", "tokio", "tower", "url", @@ -7590,9 +7626,9 @@ checksum = "7e51b68083f157f853b6379db119d1c1be0e6e4dec98101079dec41f6f5cf6df" [[package]] name = "unicode-ident" -version = "1.0.13" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" +checksum = "adb9e6ca4f869e1180728b7950e35922a7fc6397f7b641499e8f3ef06e50dc83" [[package]] name = "unicode-width" @@ -7600,6 +7636,12 @@ version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af" +[[package]] +name = "unicode-width" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fc81956842c57dac11422a97c3b8195a1ff727f06e85c84ed2e8aa277c9a0fd" + [[package]] name = "unicode-xid" version = "0.2.6" @@ -7626,9 +7668,9 @@ checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" [[package]] name = "url" -version = "2.5.3" +version = "2.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d157f1b96d14500ffdc1f10ba712e780825526c03d9a49b4d0324b0d9113ada" +checksum = "32f8b686cadd1473f4bd0117a5d28d36b1ade384ea9b5069a1c40aefed7fda60" dependencies = [ "form_urlencoded", "idna", @@ -7792,9 +7834,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.95" +version = "0.2.97" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "128d1e363af62632b8eb57219c8fd7877144af57558fb2ef0368d0087bddeb2e" +checksum = "d15e63b4482863c109d70a7b8706c1e364eb6ea449b201a76c5b89cedcec2d5c" dependencies = [ "cfg-if", "once_cell", @@ -7803,36 +7845,37 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.95" +version = "0.2.97" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb6dd4d3ca0ddffd1dd1c9c04f94b868c37ff5fac97c30b97cff2d74fce3a358" +checksum = "8d36ef12e3aaca16ddd3f67922bc63e48e953f126de60bd33ccc0101ef9998cd" dependencies = [ "bumpalo", "log", "once_cell", "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.90", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-futures" -version = "0.4.45" +version = "0.4.47" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc7ec4f8827a71586374db3e87abdb5a2bb3a15afed140221307c3ec06b1f63b" +checksum = "9dfaf8f50e5f293737ee323940c7d8b08a66a95a419223d9f41610ca08b0833d" dependencies = [ "cfg-if", "js-sys", + "once_cell", "wasm-bindgen", "web-sys", ] [[package]] name = "wasm-bindgen-macro" -version = "0.2.95" +version = "0.2.97" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e79384be7f8f5a9dd5d7167216f022090cf1f9ec128e6e6a482a2cb5c5422c56" +checksum = "705440e08b42d3e4b36de7d66c944be628d579796b8090bfa3471478a2260051" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -7840,22 +7883,22 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.95" +version = "0.2.97" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26c6ab57572f7a24a4985830b120de1594465e5d500f24afe89e16b4e833ef68" +checksum = "98c9ae5a76e46f4deecd0f0255cc223cfa18dc9b261213b8aa0c7b36f61b3f1d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.90", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.95" +version = "0.2.97" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65fc09f10666a9f147042251e0dda9c18f166ff7de300607007e96bdebc1068d" +checksum = "6ee99da9c5ba11bd675621338ef6fa52296b76b83305e9b6e5c77d4c286d6d49" [[package]] name = "wasm-streams" @@ -7872,9 +7915,9 @@ dependencies = [ [[package]] name = "web-sys" -version = "0.3.72" +version = "0.3.74" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6488b90108c040df0fe62fa815cbdee25124641df01814dd7282749234c6112" +checksum = "a98bc3c33f0fe7e59ad7cd041b89034fa82a7c2d4365ca538dda6cdaf513863c" dependencies = [ "js-sys", "wasm-bindgen", @@ -7898,9 +7941,9 @@ checksum = "5f20c57d8d7db6d3b86154206ae5d8fba62dd39573114de97c2cb0578251f8e1" [[package]] name = "webpki-roots" -version = "0.26.6" +version = "0.26.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "841c67bff177718f1d4dfefde8d8f0e78f9b6589319ba88312f567fc5841a958" +checksum = "5d642ff16b7e79272ae451b7322067cdc17cadf68c23264be9d94a32319efe7e" dependencies = [ "rustls-pki-types", ] @@ -8186,7 +8229,7 @@ dependencies = [ "pharos", "rustc_version 0.4.1", "send_wrapper 0.6.0", - "thiserror", + "thiserror 1.0.69", "wasm-bindgen", "wasm-bindgen-futures", "web-sys", @@ -8215,9 +8258,9 @@ checksum = "09041cd90cf85f7f8b2df60c646f853b7f535ce68f85244eb6731cf89fa498ec" [[package]] name = "yoke" -version = "0.7.4" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c5b1314b079b0930c31e3af543d8ee1757b1951ae1e1565ec704403a7240ca5" +checksum = "120e6aef9aa629e3d4f52dc8cc43a015c7724194c97dfaf45180d2daf2b77f40" dependencies = [ "serde", "stable_deref_trait", @@ -8227,13 +8270,13 @@ dependencies = [ [[package]] name = "yoke-derive" -version = "0.7.4" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28cc31741b18cb6f1d5ff12f5b7523e3d6eb0852bbbad19d73905511d9849b95" +checksum = "2380878cad4ac9aac1e2435f3eb4020e8374b5f13c296cb75b4620ff8e229154" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.90", "synstructure", ] @@ -8255,27 +8298,27 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.90", ] [[package]] name = "zerofrom" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91ec111ce797d0e0784a1116d0ddcdbea84322cd79e5d5ad173daeba4f93ab55" +checksum = "cff3ee08c995dee1859d998dea82f7374f2826091dd9cd47def953cae446cd2e" dependencies = [ "zerofrom-derive", ] [[package]] name = "zerofrom-derive" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ea7b4a3637ea8669cedf0f1fd5c286a17f3de97b8dd5a70a6c167a1730e63a5" +checksum = "595eed982f7d355beb85837f651fa22e90b3c044842dc7f2c2842c086f295808" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.90", "synstructure", ] @@ -8296,7 +8339,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.90", ] [[package]] @@ -8318,7 +8361,7 @@ checksum = "6eafa6dfb17584ea3e2bd6e76e0cc15ad7af12b09abdd1ca55961bed9b1063c6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.90", ] [[package]] diff --git a/batcher/aligned/src/main.rs b/batcher/aligned/src/main.rs index d047d576cd..b7af0a007d 100644 --- a/batcher/aligned/src/main.rs +++ b/batcher/aligned/src/main.rs @@ -16,6 +16,7 @@ use aligned_sdk::sdk::get_chain_id; use aligned_sdk::sdk::get_nonce_from_batcher; use aligned_sdk::sdk::{deposit_to_aligned, get_balance_in_aligned}; use aligned_sdk::sdk::{get_vk_commitment, is_proof_verified, save_response, submit_multiple}; +use clap::Args; use clap::Parser; use clap::Subcommand; use clap::ValueEnum; @@ -63,7 +64,6 @@ pub enum AlignedCommands { } #[derive(Parser, Debug)] -#[command(version, about, long_about = None)] pub struct SubmitArgs { #[arg( name = "Batcher connection address", @@ -109,20 +109,8 @@ pub struct SubmitArgs { keystore_path: Option, #[arg(name = "Private key", long = "private_key")] private_key: Option, - #[arg( - name = "Max Fee", - help = "Specifies the `max_fee` the user of the submitted proof in `ether`", - long = "max_fee" - )] - max_fee: Option, // String because U256 expects hex - #[arg( - name = "Price Estimate", - long = "price_estimate", - default_value = "default", - help = "Specifies the aligned_sdk `estimate_fee` function should be used to compute the `max_fee` of the submitted proof based on the number of proofs in a batch and the current gas price from the node specified by `eth_rpc_url`.\n Usage: `default,`, `instant`, \"custom \"", - allow_hyphen_values = true - )] - price_estimate: Option, + #[command(flatten)] + price_estimate: PriceEstimateArgs, #[arg(name = "Nonce", long = "nonce")] nonce: Option, // String because U256 expects hex #[arg( @@ -133,30 +121,78 @@ pub struct SubmitArgs { network: Network, } +#[derive(Args, Debug)] +#[group(required = false, multiple = false)] +pub struct PriceEstimateArgs { + #[arg( + name = "Max Fee", + long = "max_fee", + help = "Specifies the `max_fee` the user of the submitted proof in `ether`." + )] + max_fee: Option, // String because U256 expects hex + #[arg( + name = "Price Estimate: Custom", + long = "custom_fee_estimate", + help = "Specifies a `max_fee` equivalent to the cost of paying 1 proof / `num_proofs_in_batch` allowing the user a user to estimate there `max_fee` precisely based on the `number_proofs_in_batch`." + )] + custom_fee_estimate: Option, + #[arg( + name = "Price Estimate: Instant", + long = "instant_fee_estimate", + help = "Specifies a `max_fee` equivalent to the cost of paying for an entire batch ensuring the user's proof is included instantly." + )] + instant_fee_estimate: bool, + #[arg( + name = "Price Estimate: Default", + long = "default_fee_estimate", + help = "Specifies a `max_fee` equivalent to the cost of paying for one proof within a batch of 10 proofs ie. 1 / 10 proofs. This estimates a default `max_fee` the user should specify for including there proof within the batch." + )] + default_fee_estimate: bool, +} + impl SubmitArgs { async fn get_max_fee(&self) -> Result { - // If max_fee is explicitly provided it is used first - if let Some(max_fee) = &self.max_fee { - // Inform the user if both are declared that `max_fee` is used. - if self.price_estimate.is_some() { - return Err(SubmitError::GenericError("`max_fee` and `price_estimate` are both present please specify one or the other".to_string()))?; - } - return Ok( - U256::from_str(max_fee).map_err(|e| SubmitError::GenericError(e.to_string()))? - ); - } + // The fee types are present as a ArgGroup in clap that in which declaring multiple arguments is not allowed. + // Therefore we can switch over the returned values of each with a guarantee that only one or none are set. + // In the case of none being set we return a default `max_fee`. + let estimate = match ( + &self.price_estimate.max_fee, + &self.price_estimate.custom_fee_estimate, + self.price_estimate.instant_fee_estimate, + self.price_estimate.default_fee_estimate, + ) { + (Some(max_fee), None, false, false) => { + if !max_fee.ends_with("ether") { + error!("`max_fee` should be in the format XX.XXether"); + Err(SubmitError::EthereumProviderError( + "Error while parsing `max_fee`".to_string(), + ))? + } - if let Some(price_est) = &self.price_estimate { - let estimate = PriceEstimate::try_from(price_est.clone()) - .map_err(|e| SubmitError::GenericError(e.to_string()))?; - return estimate_fee(&self.eth_rpc_url, estimate) + let max_fee_ether = max_fee.replace("ether", ""); + parse_ether(&max_fee_ether).map_err(|e| { + SubmitError::EthereumProviderError(format!( + "Error while parsing `max_fee`: {}", + e + )) + })? + } + (None, Some(number_proofs_in_batch), false, false) => estimate_fee( + &self.eth_rpc_url, + PriceEstimate::Custom(*number_proofs_in_batch), + ) + .await + .map_err(AlignedError::FeeEstimateError)?, + (None, None, true, false) => estimate_fee(&self.eth_rpc_url, PriceEstimate::Instant) .await - .map_err(AlignedError::FeeEstimateError); - } - - // Fallback to default value - Ok(U256::from_str("1300000000000000") - .map_err(|e| SubmitError::GenericError(e.to_string()))?) + .map_err(AlignedError::FeeEstimateError)?, + (None, None, false, true) => estimate_fee(&self.eth_rpc_url, PriceEstimate::Default) + .await + .map_err(AlignedError::FeeEstimateError)?, + _ => U256::from_dec_str("13000000000000") + .map_err(|e| SubmitError::GenericError(e.to_string()))?, + }; + Ok(estimate) } } From 33b1044e075b0bd53de308d9c7b5dfaca98cfb06 Mon Sep 17 00:00:00 2001 From: PatStiles Date: Thu, 5 Dec 2024 20:33:49 -0300 Subject: [PATCH 16/74] remove unneeded TryFrom --- batcher/aligned-sdk/src/core/types.rs | 27 --------------------------- 1 file changed, 27 deletions(-) diff --git a/batcher/aligned-sdk/src/core/types.rs b/batcher/aligned-sdk/src/core/types.rs index e1d927a896..eb95e06347 100644 --- a/batcher/aligned-sdk/src/core/types.rs +++ b/batcher/aligned-sdk/src/core/types.rs @@ -94,33 +94,6 @@ pub enum PriceEstimate { Custom(usize), } -impl TryFrom for PriceEstimate { - type Error = String; - - fn try_from(value: String) -> Result { - let val = match value.as_str() { - "default" => Self::Default, - "instant" => Self::Instant, - s if s.starts_with("custom") => { - let n = s - .split_whitespace() - .nth(1) - .ok_or("Failed to Parse: `number_proofs_per_batch` not supplied, correct usage \"custom \" (note quotations)")? - .parse() - .map_err(|_| "Failed to Parse: Value of `number_proofs_per_batch` invalid , correct usage \"custom \" (note quotations)")?; - PriceEstimate::Custom(n) - } - _ => { - return Err( - "Invalid price estimate, possible values are: \"default\", \"instant\", \"custom \"" - .to_string(), - ) - } - }; - Ok(val) - } -} - #[derive(Debug, Serialize, Deserialize, Clone, Default)] pub struct VerificationDataCommitment { pub proof_commitment: [u8; 32], From 8cae2c98a16e1a1b77e78b1cec0b7c3e09e1f7d3 Mon Sep 17 00:00:00 2001 From: PatStiles Date: Thu, 5 Dec 2024 20:36:46 -0300 Subject: [PATCH 17/74] cmt nits --- 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 b7af0a007d..5e4bb74eb3 100644 --- a/batcher/aligned/src/main.rs +++ b/batcher/aligned/src/main.rs @@ -152,9 +152,9 @@ pub struct PriceEstimateArgs { impl SubmitArgs { async fn get_max_fee(&self) -> Result { - // The fee types are present as a ArgGroup in clap that in which declaring multiple arguments is not allowed. - // Therefore we can switch over the returned values of each with a guarantee that only one or none are set. - // In the case of none being set we return a default `max_fee`. + // The fee types are present as a ArgGroup in clap in which declaring multiple arguments is not allowed. + // Therefore we switch over the returned values of each argument with as we assume that only one or none are set. + // In the case of none are set we return a default `max_fee`. let estimate = match ( &self.price_estimate.max_fee, &self.price_estimate.custom_fee_estimate, From 4e23678b390cbf872bf436caf16c98510c213c98 Mon Sep 17 00:00:00 2001 From: PatStiles Date: Thu, 5 Dec 2024 23:33:36 -0300 Subject: [PATCH 18/74] make cases explicit instead of fun --- batcher/aligned/src/main.rs | 71 ++++++++++++++++++------------------- 1 file changed, 35 insertions(+), 36 deletions(-) diff --git a/batcher/aligned/src/main.rs b/batcher/aligned/src/main.rs index 5e4bb74eb3..9095860ebf 100644 --- a/batcher/aligned/src/main.rs +++ b/batcher/aligned/src/main.rs @@ -152,47 +152,46 @@ pub struct PriceEstimateArgs { impl SubmitArgs { async fn get_max_fee(&self) -> Result { - // The fee types are present as a ArgGroup in clap in which declaring multiple arguments is not allowed. - // Therefore we switch over the returned values of each argument with as we assume that only one or none are set. - // In the case of none are set we return a default `max_fee`. - let estimate = match ( - &self.price_estimate.max_fee, - &self.price_estimate.custom_fee_estimate, - self.price_estimate.instant_fee_estimate, - self.price_estimate.default_fee_estimate, - ) { - (Some(max_fee), None, false, false) => { - if !max_fee.ends_with("ether") { - error!("`max_fee` should be in the format XX.XXether"); - Err(SubmitError::EthereumProviderError( - "Error while parsing `max_fee`".to_string(), - ))? - } - - let max_fee_ether = max_fee.replace("ether", ""); - parse_ether(&max_fee_ether).map_err(|e| { - SubmitError::EthereumProviderError(format!( - "Error while parsing `max_fee`: {}", - e - )) - })? + if let Some(max_fee) = &self.price_estimate.max_fee { + if !max_fee.ends_with("ether") { + error!("`max_fee` should be in the format XX.XXether"); + Err(SubmitError::EthereumProviderError( + "Error while parsing `max_fee`".to_string(), + ))? } - (None, Some(number_proofs_in_batch), false, false) => estimate_fee( + + let max_fee_ether = max_fee.replace("ether", ""); + return Ok(parse_ether(&max_fee_ether).map_err(|e| { + SubmitError::EthereumProviderError(format!( + "Error while parsing `max_fee`: {}", + e + )) + })?) + } + + if let Some(number_proofs_in_batch) = &self.price_estimate.custom_fee_estimate { + return Ok(estimate_fee( &self.eth_rpc_url, PriceEstimate::Custom(*number_proofs_in_batch), ) .await - .map_err(AlignedError::FeeEstimateError)?, - (None, None, true, false) => estimate_fee(&self.eth_rpc_url, PriceEstimate::Instant) - .await - .map_err(AlignedError::FeeEstimateError)?, - (None, None, false, true) => estimate_fee(&self.eth_rpc_url, PriceEstimate::Default) - .await - .map_err(AlignedError::FeeEstimateError)?, - _ => U256::from_dec_str("13000000000000") - .map_err(|e| SubmitError::GenericError(e.to_string()))?, - }; - Ok(estimate) + .map_err(AlignedError::FeeEstimateError)?) + } + + if self.price_estimate.instant_fee_estimate { + return Ok(estimate_fee(&self.eth_rpc_url, PriceEstimate::Instant) + .await + .map_err(AlignedError::FeeEstimateError)?) + } + + if self.price_estimate.default_fee_estimate { + return Ok(estimate_fee(&self.eth_rpc_url, PriceEstimate::Instant) + .await + .map_err(AlignedError::FeeEstimateError)?) + } + + Ok(U256::from_dec_str("13000000000000") + .map_err(|e| SubmitError::GenericError(e.to_string()))?) } } From ac8e5b3ade1dd03446ba54051695949798d3b324 Mon Sep 17 00:00:00 2001 From: PatStiles Date: Fri, 6 Dec 2024 04:28:56 -0300 Subject: [PATCH 19/74] clippy --- batcher/aligned/src/main.rs | 37 ++++++++++++++++--------------------- 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/batcher/aligned/src/main.rs b/batcher/aligned/src/main.rs index 4fdca5c7c2..9f6e28b563 100644 --- a/batcher/aligned/src/main.rs +++ b/batcher/aligned/src/main.rs @@ -152,7 +152,7 @@ pub struct PriceEstimateArgs { impl SubmitArgs { async fn get_max_fee(&self) -> Result { - if let Some(max_fee) = &self.price_estimate.max_fee { + if let Some(max_fee) = &self.price_estimate.max_fee { if !max_fee.ends_with("ether") { error!("`max_fee` should be in the format XX.XXether"); Err(SubmitError::EthereumProviderError( @@ -162,36 +162,33 @@ impl SubmitArgs { let max_fee_ether = max_fee.replace("ether", ""); return Ok(parse_ether(&max_fee_ether).map_err(|e| { - SubmitError::EthereumProviderError(format!( - "Error while parsing `max_fee`: {}", - e - )) - })?) + SubmitError::EthereumProviderError(format!("Error while parsing `max_fee`: {}", e)) + })?); } if let Some(number_proofs_in_batch) = &self.price_estimate.custom_fee_estimate { - return Ok(estimate_fee( + return estimate_fee( &self.eth_rpc_url, PriceEstimate::Custom(*number_proofs_in_batch), ) .await - .map_err(AlignedError::FeeEstimateError)?) + .map_err(AlignedError::FeeEstimateError); } if self.price_estimate.instant_fee_estimate { - return Ok(estimate_fee(&self.eth_rpc_url, PriceEstimate::Instant) - .await - .map_err(AlignedError::FeeEstimateError)?) + return estimate_fee(&self.eth_rpc_url, PriceEstimate::Instant) + .await + .map_err(AlignedError::FeeEstimateError); } if self.price_estimate.default_fee_estimate { - return Ok(estimate_fee(&self.eth_rpc_url, PriceEstimate::Instant) - .await - .map_err(AlignedError::FeeEstimateError)?) + return estimate_fee(&self.eth_rpc_url, PriceEstimate::Instant) + .await + .map_err(AlignedError::FeeEstimateError); } Ok(U256::from_dec_str("13000000000000") - .map_err(|e| SubmitError::GenericError(e.to_string()))?) + .map_err(|e| SubmitError::GenericError(e.to_string()))?) } } @@ -295,7 +292,6 @@ enum NetworkArg { Devnet, Holesky, HoleskyStage, - Mainnet, } impl From for Network { @@ -304,7 +300,6 @@ impl From for Network { NetworkArg::Devnet => Network::Devnet, NetworkArg::Holesky => Network::Holesky, NetworkArg::HoleskyStage => Network::HoleskyStage, - NetworkArg::Mainnet => Network::Mainnet, } } } @@ -516,13 +511,13 @@ async fn main() -> Result<(), AlignedError> { } DepositToBatcher(deposit_to_batcher_args) => { if !deposit_to_batcher_args.amount.ends_with("ether") { - error!("`amount` should be in the format XX.XXether"); + error!("Amount should be in the format XX.XXether"); return Ok(()); } - let amount_ether = deposit_to_batcher_args.amount.replace("ether", ""); + let amount = deposit_to_batcher_args.amount.replace("ether", ""); - let amount_wei = parse_ether(&amount_ether).map_err(|e| { + let amount_ether = parse_ether(&amount).map_err(|e| { SubmitError::EthereumProviderError(format!("Error while parsing amount: {}", e)) })?; @@ -553,7 +548,7 @@ async fn main() -> Result<(), AlignedError> { let client = SignerMiddleware::new(eth_rpc_provider.clone(), wallet.clone()); - match deposit_to_aligned(amount_wei, client, deposit_to_batcher_args.network.into()) + match deposit_to_aligned(amount_ether, client, deposit_to_batcher_args.network.into()) .await { Ok(receipt) => { From 620384bf6ae416ebebb8b869258acdc950d6e982 Mon Sep 17 00:00:00 2001 From: PatStiles Date: Fri, 6 Dec 2024 09:57:00 -0300 Subject: [PATCH 20/74] docs + cmts + made function name more specific --- batcher/aligned-sdk/src/sdk.rs | 13 ++++++++----- batcher/aligned/src/main.rs | 6 +++--- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/batcher/aligned-sdk/src/sdk.rs b/batcher/aligned-sdk/src/sdk.rs index f478bfa4d2..5d14d1350b 100644 --- a/batcher/aligned-sdk/src/sdk.rs +++ b/batcher/aligned-sdk/src/sdk.rs @@ -140,12 +140,12 @@ pub async fn estimate_fee( // Price of 1 proof in 32 proof batch match estimate { PriceEstimate::Default => { - suggest_fee_per_proof(eth_rpc_url, DEFAULT_MAX_FEE_PROOF_NUMBER).await + fee_per_proof_in_batch(eth_rpc_url, DEFAULT_MAX_FEE_PROOF_NUMBER).await } PriceEstimate::Instant => { - suggest_fee_per_proof(eth_rpc_url, INSTANT_MAX_FEE_PROOF_NUMBER).await + fee_per_proof_in_batch(eth_rpc_url, INSTANT_MAX_FEE_PROOF_NUMBER).await } - PriceEstimate::Custom(n) => suggest_fee_per_proof(eth_rpc_url, n).await, + PriceEstimate::Custom(n) => fee_per_proof_in_batch(eth_rpc_url, n).await, } } @@ -160,7 +160,7 @@ pub async fn estimate_fee( /// # Errors /// * `EthereumProviderError` if there is an error in the connection with the RPC provider. /// * `EthereumGasPriceError` if there is an error retrieving the Ethereum gas price. -pub async fn suggest_fee_per_proof( +pub async fn fee_per_proof_in_batch( eth_rpc_url: &str, num_proofs_in_batch: usize, ) -> Result { @@ -175,7 +175,10 @@ pub async fn suggest_fee_per_proof( + ADDITIONAL_SUBMISSION_GAS_COST_PER_PROOF * num_proofs_in_batch as u128) / num_proofs_in_batch as u128; - // Price of 1 / `num_proofs_in_batch` proof batch + + // Price of 1 proof in a batch of size `num_proofs_in_batch` (i.e. 1 / `num_proofs_in_batch`). + // The computed price is adjusted with respect to the percentage multiplier from: + // https://github.com/yetanotherco/aligned_layer/blob/staging/batcher/aligned-batcher/src/lib.rs#L1401 let fee_per_proof = (U256::from(estimated_gas_per_proof) * gas_price * U256::from(GAS_PRICE_PERCENTAGE_MULTIPLIER)) diff --git a/batcher/aligned/src/main.rs b/batcher/aligned/src/main.rs index 9f6e28b563..d8547385d9 100644 --- a/batcher/aligned/src/main.rs +++ b/batcher/aligned/src/main.rs @@ -125,13 +125,13 @@ pub struct SubmitArgs { #[group(required = false, multiple = false)] pub struct PriceEstimateArgs { #[arg( - name = "Max Fee", + name = "Max Fee (ether)", long = "max_fee", help = "Specifies the `max_fee` the user of the submitted proof in `ether`." )] max_fee: Option, // String because U256 expects hex #[arg( - name = "Price Estimate: Custom", + name = "NUMBER_PROOFS_IN_BATCH", long = "custom_fee_estimate", help = "Specifies a `max_fee` equivalent to the cost of paying 1 proof / `num_proofs_in_batch` allowing the user a user to estimate there `max_fee` precisely based on the `number_proofs_in_batch`." )] @@ -188,7 +188,7 @@ impl SubmitArgs { } Ok(U256::from_dec_str("13000000000000") - .map_err(|e| SubmitError::GenericError(e.to_string()))?) + .map_err(|e| SubmitError::GenericError(e.to_string()))?) // 13_000 gas per proof * 100 gwei gas price (upper bound) } } From dcd00a13022ccf0bd777d0c166ffca1d5b0c664c Mon Sep 17 00:00:00 2001 From: PatStiles Date: Fri, 6 Dec 2024 10:07:12 -0300 Subject: [PATCH 21/74] clippy --- batcher/aligned-sdk/src/sdk.rs | 3 +-- batcher/aligned/src/main.rs | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/batcher/aligned-sdk/src/sdk.rs b/batcher/aligned-sdk/src/sdk.rs index 5d14d1350b..6ef58edfeb 100644 --- a/batcher/aligned-sdk/src/sdk.rs +++ b/batcher/aligned-sdk/src/sdk.rs @@ -175,8 +175,7 @@ pub async fn fee_per_proof_in_batch( + ADDITIONAL_SUBMISSION_GAS_COST_PER_PROOF * num_proofs_in_batch as u128) / num_proofs_in_batch as u128; - - // Price of 1 proof in a batch of size `num_proofs_in_batch` (i.e. 1 / `num_proofs_in_batch`). + // Price of 1 proof in a batch of size `num_proofs_in_batch` i.e. (1 / `num_proofs_in_batch`). // The computed price is adjusted with respect to the percentage multiplier from: // https://github.com/yetanotherco/aligned_layer/blob/staging/batcher/aligned-batcher/src/lib.rs#L1401 let fee_per_proof = (U256::from(estimated_gas_per_proof) diff --git a/batcher/aligned/src/main.rs b/batcher/aligned/src/main.rs index d8547385d9..03397fb99c 100644 --- a/batcher/aligned/src/main.rs +++ b/batcher/aligned/src/main.rs @@ -188,7 +188,7 @@ impl SubmitArgs { } Ok(U256::from_dec_str("13000000000000") - .map_err(|e| SubmitError::GenericError(e.to_string()))?) // 13_000 gas per proof * 100 gwei gas price (upper bound) + .map_err(|e| SubmitError::GenericError(e.to_string()))?) // 13_000 gas per proof * 100 gwei gas price (upper bound) } } From 4482459f7858403a1ad68c7cf89a35404acd94a1 Mon Sep 17 00:00:00 2001 From: PatStiles Date: Fri, 6 Dec 2024 12:19:03 -0300 Subject: [PATCH 22/74] marcos comments --- batcher/aligned-sdk/src/core/errors.rs | 2 +- batcher/aligned/src/main.rs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/batcher/aligned-sdk/src/core/errors.rs b/batcher/aligned-sdk/src/core/errors.rs index 52485a7086..6b51ab2f74 100644 --- a/batcher/aligned-sdk/src/core/errors.rs +++ b/batcher/aligned-sdk/src/core/errors.rs @@ -57,7 +57,7 @@ impl fmt::Display for AlignedError { AlignedError::SubmitError(e) => write!(f, "Submit error: {}", e), AlignedError::VerificationError(e) => write!(f, "Verification error: {}", e), AlignedError::ChainIdError(e) => write!(f, "Chain ID error: {}", e), - AlignedError::FeeEstimateError(e) => write!(f, "Max fee estimate error: {}", e), + AlignedError::FeeEstimateError(e) => write!(f, "Fee estimate error: {}", e), AlignedError::FileError(e) => write!(f, "File error: {}", e), } } diff --git a/batcher/aligned/src/main.rs b/batcher/aligned/src/main.rs index 03397fb99c..99265521d6 100644 --- a/batcher/aligned/src/main.rs +++ b/batcher/aligned/src/main.rs @@ -127,7 +127,7 @@ pub struct PriceEstimateArgs { #[arg( name = "Max Fee (ether)", long = "max_fee", - help = "Specifies the `max_fee` the user of the submitted proof in `ether`." + help = "Specifies the maximum fee (`max_fee`) the user is willing to pay for the submitted proof, in Ether." )] max_fee: Option, // String because U256 expects hex #[arg( @@ -139,13 +139,13 @@ pub struct PriceEstimateArgs { #[arg( name = "Price Estimate: Instant", long = "instant_fee_estimate", - help = "Specifies a `max_fee` equivalent to the cost of paying for an entire batch ensuring the user's proof is included instantly." + help = "Specifies a `max_fee` that covers the cost of paying for the entire batch, ensuring the proof is included instantly." )] instant_fee_estimate: bool, #[arg( name = "Price Estimate: Default", long = "default_fee_estimate", - help = "Specifies a `max_fee` equivalent to the cost of paying for one proof within a batch of 10 proofs ie. 1 / 10 proofs. This estimates a default `max_fee` the user should specify for including there proof within the batch." + help = "Specifies a default `max_fee` based on the cost of one proof within a batch of 10 proofs, providing a standard fee for batch inclusion." )] default_fee_estimate: bool, } From 4ffab999ad5e6bc17ccf64e398bf9f9852e59137 Mon Sep 17 00:00:00 2001 From: PatStiles Date: Fri, 6 Dec 2024 13:19:13 -0300 Subject: [PATCH 23/74] marcos comments --- batcher/aligned/src/main.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/batcher/aligned/src/main.rs b/batcher/aligned/src/main.rs index 99265521d6..d127714813 100644 --- a/batcher/aligned/src/main.rs +++ b/batcher/aligned/src/main.rs @@ -182,7 +182,7 @@ impl SubmitArgs { } if self.price_estimate.default_fee_estimate { - return estimate_fee(&self.eth_rpc_url, PriceEstimate::Instant) + return estimate_fee(&self.eth_rpc_url, PriceEstimate::Default) .await .map_err(AlignedError::FeeEstimateError); } @@ -292,6 +292,7 @@ enum NetworkArg { Devnet, Holesky, HoleskyStage, + Mainnet } impl From for Network { @@ -300,6 +301,7 @@ impl From for Network { NetworkArg::Devnet => Network::Devnet, NetworkArg::Holesky => Network::Holesky, NetworkArg::HoleskyStage => Network::HoleskyStage, + NetworkArg::Mainnet => Network::Mainnet, } } } @@ -347,9 +349,8 @@ async fn main() -> Result<(), AlignedError> { })?; let eth_rpc_url = submit_args.eth_rpc_url.clone(); - // `max_fee` is required unless `price_estimate` is present. let max_fee_wei = submit_args.get_max_fee().await?; - info!("max_fee: {} ether", format_ether(max_fee_wei)); + info!("Will send proof with an estimated max_fee of: {}ether", format_ether(max_fee_wei)); let repetitions = submit_args.repetitions; let connect_addr = submit_args.batcher_url.clone(); From ff5ff80bd7f39d5ee1e2b88f21f8f1c21b6d4a68 Mon Sep 17 00:00:00 2001 From: PatStiles Date: Fri, 6 Dec 2024 13:21:45 -0300 Subject: [PATCH 24/74] fmt --- batcher/aligned/src/main.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/batcher/aligned/src/main.rs b/batcher/aligned/src/main.rs index d127714813..872702800d 100644 --- a/batcher/aligned/src/main.rs +++ b/batcher/aligned/src/main.rs @@ -292,7 +292,7 @@ enum NetworkArg { Devnet, Holesky, HoleskyStage, - Mainnet + Mainnet, } impl From for Network { @@ -350,7 +350,10 @@ async fn main() -> Result<(), AlignedError> { let eth_rpc_url = submit_args.eth_rpc_url.clone(); let max_fee_wei = submit_args.get_max_fee().await?; - info!("Will send proof with an estimated max_fee of: {}ether", format_ether(max_fee_wei)); + info!( + "Will send proof with an estimated max_fee of: {}ether", + format_ether(max_fee_wei) + ); let repetitions = submit_args.repetitions; let connect_addr = submit_args.batcher_url.clone(); From 430b989b4d2954fc727c48a4b2cc31d26a65ccb9 Mon Sep 17 00:00:00 2001 From: PatStiles Date: Fri, 6 Dec 2024 19:44:41 -0300 Subject: [PATCH 25/74] address Uri's comments + clippy + fmt --- batcher/aligned-sdk/src/core/constants.rs | 6 +++--- batcher/aligned-sdk/src/core/types.rs | 2 +- batcher/aligned-sdk/src/sdk.rs | 24 +++++++++++------------ batcher/aligned/src/main.rs | 24 +++++++++++------------ 4 files changed, 27 insertions(+), 29 deletions(-) diff --git a/batcher/aligned-sdk/src/core/constants.rs b/batcher/aligned-sdk/src/core/constants.rs index 2190f6ae49..e0564946d0 100644 --- a/batcher/aligned-sdk/src/core/constants.rs +++ b/batcher/aligned-sdk/src/core/constants.rs @@ -19,12 +19,12 @@ pub const PERCENTAGE_DIVIDER: u128 = 100; /// SDK /// /// Number of proofs we a batch for estimation. -/// This is the number of proofs in a batch of size n, where we set n = 32. +/// This is the number of proofs in a batch of size 1. /// i.e. the user pays for the entire batch and his proof is instantly submitted. -pub const INSTANT_MAX_FEE_PROOF_NUMBER: usize = 1; +pub const INSTANT_MAX_FEE_BATCH_SIZE: usize = 1; /// Estimated number of proofs for batch submission. /// This corresponds to the number of proofs to compute for a default max_fee. -pub const DEFAULT_MAX_FEE_PROOF_NUMBER: usize = 10; +pub const DEFAULT_MAX_FEE_BATCH_SIZE: usize = 16; /// Ethereum calls retry constants pub const ETHEREUM_CALL_MIN_RETRY_DELAY: u64 = 500; // milliseconds diff --git a/batcher/aligned-sdk/src/core/types.rs b/batcher/aligned-sdk/src/core/types.rs index 4ab115cce5..afa0e7108d 100644 --- a/batcher/aligned-sdk/src/core/types.rs +++ b/batcher/aligned-sdk/src/core/types.rs @@ -88,7 +88,7 @@ impl NoncedVerificationData { // Defines an estimate price preference for the user. #[derive(Debug, Serialize, Deserialize, Clone)] -pub enum PriceEstimate { +pub enum FeeEstimateType { Default, Instant, Custom(usize), diff --git a/batcher/aligned-sdk/src/sdk.rs b/batcher/aligned-sdk/src/sdk.rs index 6ef58edfeb..183476758b 100644 --- a/batcher/aligned-sdk/src/sdk.rs +++ b/batcher/aligned-sdk/src/sdk.rs @@ -8,13 +8,13 @@ use crate::{ core::{ constants::{ ADDITIONAL_SUBMISSION_GAS_COST_PER_PROOF, CONSTANT_GAS_COST, - DEFAULT_MAX_FEE_PROOF_NUMBER, GAS_PRICE_PERCENTAGE_MULTIPLIER, - INSTANT_MAX_FEE_PROOF_NUMBER, PERCENTAGE_DIVIDER, + DEFAULT_MAX_FEE_BATCH_SIZE, GAS_PRICE_PERCENTAGE_MULTIPLIER, + INSTANT_MAX_FEE_BATCH_SIZE, PERCENTAGE_DIVIDER, }, errors::{self, GetNonceError}, types::{ - AlignedVerificationData, ClientMessage, GetNonceResponseMessage, Network, - PriceEstimate, ProvingSystemId, VerificationData, + AlignedVerificationData, ClientMessage, FeeEstimateType, GetNonceResponseMessage, + Network, ProvingSystemId, VerificationData, }, }, eth::{ @@ -118,7 +118,7 @@ pub async fn submit_multiple_and_wait_verification( /// Returns the estimated `max_fee` depending on the batch inclusion preference of the user, computed based on the current gas price, and the number of proofs in a batch. /// NOTE: The `max_fee` is computed from an rpc nodes max priority gas price. -/// To estimate the `max_fee` of a batch we use a compute the `max_fee` with respect to a batch size of 1 (Instant), 10 (Default), or `number_proofs_in_batch` (Custom). +/// To estimate the `max_fee` of a batch we compute it based on a batch size of 1 (Instant), 10 (Default), or `number_proofs_in_batch` (Custom). /// The `max_fee` estimates therefore are: /// * `Default`: Specifies a `max_fee` equivalent to the cost of paying for one proof within a batch of 10 proofs ie. 1 / 10 proofs. /// This estimates a default `max_fee` the user should specify for including there proof within the batch. @@ -135,17 +135,17 @@ pub async fn submit_multiple_and_wait_verification( /// * `EthereumGasPriceError` if there is an error retrieving the Ethereum gas price. pub async fn estimate_fee( eth_rpc_url: &str, - estimate: PriceEstimate, + estimate: FeeEstimateType, ) -> Result { // Price of 1 proof in 32 proof batch match estimate { - PriceEstimate::Default => { - fee_per_proof_in_batch(eth_rpc_url, DEFAULT_MAX_FEE_PROOF_NUMBER).await + FeeEstimateType::Default => { + calculate_fee_per_proof_in_batch(eth_rpc_url, DEFAULT_MAX_FEE_BATCH_SIZE).await } - PriceEstimate::Instant => { - fee_per_proof_in_batch(eth_rpc_url, INSTANT_MAX_FEE_PROOF_NUMBER).await + FeeEstimateType::Instant => { + calculate_fee_per_proof_in_batch(eth_rpc_url, INSTANT_MAX_FEE_BATCH_SIZE).await } - PriceEstimate::Custom(n) => fee_per_proof_in_batch(eth_rpc_url, n).await, + FeeEstimateType::Custom(n) => calculate_fee_per_proof_in_batch(eth_rpc_url, n).await, } } @@ -160,7 +160,7 @@ pub async fn estimate_fee( /// # Errors /// * `EthereumProviderError` if there is an error in the connection with the RPC provider. /// * `EthereumGasPriceError` if there is an error retrieving the Ethereum gas price. -pub async fn fee_per_proof_in_batch( +pub async fn calculate_fee_per_proof_in_batch( eth_rpc_url: &str, num_proofs_in_batch: usize, ) -> Result { diff --git a/batcher/aligned/src/main.rs b/batcher/aligned/src/main.rs index 872702800d..1abff9e7ba 100644 --- a/batcher/aligned/src/main.rs +++ b/batcher/aligned/src/main.rs @@ -6,7 +6,7 @@ use std::path::PathBuf; use std::str::FromStr; use aligned_sdk::communication::serialization::cbor_deserialize; -use aligned_sdk::core::types::PriceEstimate; +use aligned_sdk::core::types::FeeEstimateType; use aligned_sdk::core::{ errors::{AlignedError, SubmitError}, types::{AlignedVerificationData, Network, ProvingSystemId, VerificationData}, @@ -110,7 +110,7 @@ pub struct SubmitArgs { #[arg(name = "Private key", long = "private_key")] private_key: Option, #[command(flatten)] - price_estimate: PriceEstimateArgs, + fee_type: FeeType, #[arg(name = "Nonce", long = "nonce")] nonce: Option, // String because U256 expects hex #[arg( @@ -123,7 +123,7 @@ pub struct SubmitArgs { #[derive(Args, Debug)] #[group(required = false, multiple = false)] -pub struct PriceEstimateArgs { +pub struct FeeType { #[arg( name = "Max Fee (ether)", long = "max_fee", @@ -137,13 +137,11 @@ pub struct PriceEstimateArgs { )] custom_fee_estimate: Option, #[arg( - name = "Price Estimate: Instant", long = "instant_fee_estimate", help = "Specifies a `max_fee` that covers the cost of paying for the entire batch, ensuring the proof is included instantly." )] instant_fee_estimate: bool, #[arg( - name = "Price Estimate: Default", long = "default_fee_estimate", help = "Specifies a default `max_fee` based on the cost of one proof within a batch of 10 proofs, providing a standard fee for batch inclusion." )] @@ -152,7 +150,7 @@ pub struct PriceEstimateArgs { impl SubmitArgs { async fn get_max_fee(&self) -> Result { - if let Some(max_fee) = &self.price_estimate.max_fee { + if let Some(max_fee) = &self.fee_type.max_fee { if !max_fee.ends_with("ether") { error!("`max_fee` should be in the format XX.XXether"); Err(SubmitError::EthereumProviderError( @@ -161,28 +159,28 @@ impl SubmitArgs { } let max_fee_ether = max_fee.replace("ether", ""); - return Ok(parse_ether(&max_fee_ether).map_err(|e| { + return Ok(parse_ether(max_fee_ether).map_err(|e| { SubmitError::EthereumProviderError(format!("Error while parsing `max_fee`: {}", e)) })?); } - if let Some(number_proofs_in_batch) = &self.price_estimate.custom_fee_estimate { + if let Some(number_proofs_in_batch) = &self.fee_type.custom_fee_estimate { return estimate_fee( &self.eth_rpc_url, - PriceEstimate::Custom(*number_proofs_in_batch), + FeeEstimateType::Custom(*number_proofs_in_batch), ) .await .map_err(AlignedError::FeeEstimateError); } - if self.price_estimate.instant_fee_estimate { - return estimate_fee(&self.eth_rpc_url, PriceEstimate::Instant) + if self.fee_type.instant_fee_estimate { + return estimate_fee(&self.eth_rpc_url, FeeEstimateType::Instant) .await .map_err(AlignedError::FeeEstimateError); } - if self.price_estimate.default_fee_estimate { - return estimate_fee(&self.eth_rpc_url, PriceEstimate::Default) + if self.fee_type.default_fee_estimate { + return estimate_fee(&self.eth_rpc_url, FeeEstimateType::Default) .await .map_err(AlignedError::FeeEstimateError); } From 61ab98c32e9963ef159fb09895ca82d92140dc90 Mon Sep 17 00:00:00 2001 From: PatStiles Date: Fri, 6 Dec 2024 20:03:19 -0300 Subject: [PATCH 26/74] nit --- batcher/aligned-sdk/src/sdk.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/batcher/aligned-sdk/src/sdk.rs b/batcher/aligned-sdk/src/sdk.rs index 183476758b..5a3aca8673 100644 --- a/batcher/aligned-sdk/src/sdk.rs +++ b/batcher/aligned-sdk/src/sdk.rs @@ -135,7 +135,7 @@ pub async fn submit_multiple_and_wait_verification( /// * `EthereumGasPriceError` if there is an error retrieving the Ethereum gas price. pub async fn estimate_fee( eth_rpc_url: &str, - estimate: FeeEstimateType, + estimate_type: FeeEstimateType, ) -> Result { // Price of 1 proof in 32 proof batch match estimate { From e03f75a4d362473bcecde96f947d19e27ac2a33c Mon Sep 17 00:00:00 2001 From: PatStiles Date: Fri, 6 Dec 2024 20:06:27 -0300 Subject: [PATCH 27/74] missing name change --- batcher/aligned-sdk/src/sdk.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/batcher/aligned-sdk/src/sdk.rs b/batcher/aligned-sdk/src/sdk.rs index 5a3aca8673..0b1ef213e2 100644 --- a/batcher/aligned-sdk/src/sdk.rs +++ b/batcher/aligned-sdk/src/sdk.rs @@ -138,7 +138,7 @@ pub async fn estimate_fee( estimate_type: FeeEstimateType, ) -> Result { // Price of 1 proof in 32 proof batch - match estimate { + match estimate_type { FeeEstimateType::Default => { calculate_fee_per_proof_in_batch(eth_rpc_url, DEFAULT_MAX_FEE_BATCH_SIZE).await } From 170f3a3d81b7c1f33eded9c53ebe8447defdc059 Mon Sep 17 00:00:00 2001 From: PatStiles Date: Fri, 6 Dec 2024 20:34:15 -0300 Subject: [PATCH 28/74] gaston's comments --- batcher/aligned-sdk/src/core/constants.rs | 9 ++++----- batcher/aligned-sdk/src/sdk.rs | 13 ++++++------- batcher/aligned/src/main.rs | 2 +- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/batcher/aligned-sdk/src/core/constants.rs b/batcher/aligned-sdk/src/core/constants.rs index e0564946d0..f554b7734a 100644 --- a/batcher/aligned-sdk/src/core/constants.rs +++ b/batcher/aligned-sdk/src/core/constants.rs @@ -18,12 +18,11 @@ pub const OVERRIDE_GAS_PRICE_PERCENTAGE_MULTIPLIER: u128 = 120; // gasPrice modi pub const PERCENTAGE_DIVIDER: u128 = 100; /// SDK /// -/// Number of proofs we a batch for estimation. -/// This is the number of proofs in a batch of size 1. -/// i.e. the user pays for the entire batch and his proof is instantly submitted. +/// Constants used for `max_fee` estimation in the sdk `estimate_fee()` function. +/// The number of proofs in a batch to compute the `Instant` fee estimate for proof submission to Aligned. +/// i.e. the user pays for the entire batch and his proof is instantly submitted, therefore a batch of one proof. pub const INSTANT_MAX_FEE_BATCH_SIZE: usize = 1; -/// Estimated number of proofs for batch submission. -/// This corresponds to the number of proofs to compute for a default max_fee. +/// The number of proofs in a batch to compute the `Default` fee estimate for proof submission to Aligned. pub const DEFAULT_MAX_FEE_BATCH_SIZE: usize = 16; /// Ethereum calls retry constants diff --git a/batcher/aligned-sdk/src/sdk.rs b/batcher/aligned-sdk/src/sdk.rs index 0b1ef213e2..cca6689b81 100644 --- a/batcher/aligned-sdk/src/sdk.rs +++ b/batcher/aligned-sdk/src/sdk.rs @@ -118,18 +118,18 @@ pub async fn submit_multiple_and_wait_verification( /// Returns the estimated `max_fee` depending on the batch inclusion preference of the user, computed based on the current gas price, and the number of proofs in a batch. /// NOTE: The `max_fee` is computed from an rpc nodes max priority gas price. -/// To estimate the `max_fee` of a batch we compute it based on a batch size of 1 (Instant), 10 (Default), or `number_proofs_in_batch` (Custom). +/// To estimate the `max_fee` of a batch we compute it based on a batch size of 1 (Instant), 16 (Default), or a user supplied `number_proofs_in_batch` (Custom). /// The `max_fee` estimates therefore are: -/// * `Default`: Specifies a `max_fee` equivalent to the cost of paying for one proof within a batch of 10 proofs ie. 1 / 10 proofs. +/// * `Default`: Specifies a `max_fee` equivalent to the cost of paying for one proof within a batch of 16 proofs ie. 1 / 16 proofs. /// This estimates a default `max_fee` the user should specify for including there proof within the batch. /// * `Instant`: Specifies a `max_fee` equivalent to the cost of paying for an entire batch ensuring the user's proof is included instantly. -/// * `Custom (number_proofs_in_batch)`: Specifies a `max_fee` equivalent to the cost of paying 1 proof / `num_proofs_in_batch` allowing the user a user to estimate there `max_fee` precisely based on the `number_proofs_in_batch`. +/// * `Custom (number_proofs_in_batch)`: Specifies a `max_fee` equivalent to the cost of paying 1 proof / `num_proofs_in_batch` allowing the user a user to estimate the `max_fee` precisely based on the `number_proofs_in_batch`. /// /// # Arguments /// * `eth_rpc_url` - The URL of the Ethereum RPC node. -/// * `estimate` - Enum specifying the type of price estimate: MIN, DEFAULT, INSTANT. +/// * `estimate_type` - Enum specifying the type of price estimate: Default, Instant. Custom(usize) /// # Returns -/// The estimated `max_fee` in gas for a proof based on the users `PriceEstimate` as a `U256`. +/// The estimated `max_fee` in gas for a proof based on the users `FeeEstimateType` as a `U256`. /// # Errors /// * `EthereumProviderError` if there is an error in the connection with the RPC provider. /// * `EthereumGasPriceError` if there is an error retrieving the Ethereum gas price. @@ -137,7 +137,6 @@ pub async fn estimate_fee( eth_rpc_url: &str, estimate_type: FeeEstimateType, ) -> Result { - // Price of 1 proof in 32 proof batch match estimate_type { FeeEstimateType::Default => { calculate_fee_per_proof_in_batch(eth_rpc_url, DEFAULT_MAX_FEE_BATCH_SIZE).await @@ -170,7 +169,7 @@ pub async fn calculate_fee_per_proof_in_batch( })?; let gas_price = fetch_gas_price(ð_rpc_provider).await?; - // Cost for estimate `num_proofs_per_batch` proofs + // Cost for estimate `num_proofs_in_batch` proofs let estimated_gas_per_proof = (CONSTANT_GAS_COST + ADDITIONAL_SUBMISSION_GAS_COST_PER_PROOF * num_proofs_in_batch as u128) / num_proofs_in_batch as u128; diff --git a/batcher/aligned/src/main.rs b/batcher/aligned/src/main.rs index 1abff9e7ba..1682b9b5c3 100644 --- a/batcher/aligned/src/main.rs +++ b/batcher/aligned/src/main.rs @@ -133,7 +133,7 @@ pub struct FeeType { #[arg( name = "NUMBER_PROOFS_IN_BATCH", long = "custom_fee_estimate", - help = "Specifies a `max_fee` equivalent to the cost of paying 1 proof / `num_proofs_in_batch` allowing the user a user to estimate there `max_fee` precisely based on the `number_proofs_in_batch`." + help = "Specifies a `max_fee` equivalent to the cost of paying 1 proof / `num_proofs_in_batch` allowing the user a user to estimate a `max_fee` precisely based on the `number_proofs_in_batch`." )] custom_fee_estimate: Option, #[arg( From f8d83082cca7fc929f6a5769c506d0c8eb66e63c Mon Sep 17 00:00:00 2001 From: PatStiles Date: Fri, 6 Dec 2024 20:36:06 -0300 Subject: [PATCH 29/74] naming nit --- batcher/aligned-sdk/src/core/errors.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/batcher/aligned-sdk/src/core/errors.rs b/batcher/aligned-sdk/src/core/errors.rs index 6b51ab2f74..f0a358e549 100644 --- a/batcher/aligned-sdk/src/core/errors.rs +++ b/batcher/aligned-sdk/src/core/errors.rs @@ -269,7 +269,7 @@ impl fmt::Display for ChainIdError { pub enum FeeEstimateError { EthereumProviderError(String), EthereumGasPriceError(String), - PriceEstimateParseError(String), + FeeEstimateParseError(String), } impl fmt::Display for FeeEstimateError { From ad111db7a8f18772004e1cb228a8b8517b818eea Mon Sep 17 00:00:00 2001 From: PatStiles Date: Fri, 6 Dec 2024 20:41:51 -0300 Subject: [PATCH 30/74] can variable names for price in DepositToBatcher that got mixed in merge + doc nits --- batcher/aligned-sdk/src/core/errors.rs | 2 +- batcher/aligned-sdk/src/sdk.rs | 2 +- batcher/aligned/src/main.rs | 10 +++++----- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/batcher/aligned-sdk/src/core/errors.rs b/batcher/aligned-sdk/src/core/errors.rs index f0a358e549..31fc3ee54a 100644 --- a/batcher/aligned-sdk/src/core/errors.rs +++ b/batcher/aligned-sdk/src/core/errors.rs @@ -281,7 +281,7 @@ impl fmt::Display for FeeEstimateError { FeeEstimateError::EthereumGasPriceError(e) => { write!(f, "Failed to retreive the current gas price: {}", e) } - FeeEstimateError::PriceEstimateParseError(e) => { + FeeEstimateError::FeeEstimateParseError(e) => { write!(f, "Error parsing PriceEstimate: {}", e) } } diff --git a/batcher/aligned-sdk/src/sdk.rs b/batcher/aligned-sdk/src/sdk.rs index cca6689b81..4c43eedac4 100644 --- a/batcher/aligned-sdk/src/sdk.rs +++ b/batcher/aligned-sdk/src/sdk.rs @@ -123,7 +123,7 @@ pub async fn submit_multiple_and_wait_verification( /// * `Default`: Specifies a `max_fee` equivalent to the cost of paying for one proof within a batch of 16 proofs ie. 1 / 16 proofs. /// This estimates a default `max_fee` the user should specify for including there proof within the batch. /// * `Instant`: Specifies a `max_fee` equivalent to the cost of paying for an entire batch ensuring the user's proof is included instantly. -/// * `Custom (number_proofs_in_batch)`: Specifies a `max_fee` equivalent to the cost of paying 1 proof / `num_proofs_in_batch` allowing the user a user to estimate the `max_fee` precisely based on the `number_proofs_in_batch`. +/// * `Custom (number_proofs_in_batch)`: Specifies a `max_fee` equivalent to the cost of paying 1 proof / `number_proofs_in_batch` allowing the user a user to estimate the `max_fee` precisely based on the `number_proofs_in_batch`. /// /// # Arguments /// * `eth_rpc_url` - The URL of the Ethereum RPC node. diff --git a/batcher/aligned/src/main.rs b/batcher/aligned/src/main.rs index 1682b9b5c3..4256cd53d7 100644 --- a/batcher/aligned/src/main.rs +++ b/batcher/aligned/src/main.rs @@ -133,7 +133,7 @@ pub struct FeeType { #[arg( name = "NUMBER_PROOFS_IN_BATCH", long = "custom_fee_estimate", - help = "Specifies a `max_fee` equivalent to the cost of paying 1 proof / `num_proofs_in_batch` allowing the user a user to estimate a `max_fee` precisely based on the `number_proofs_in_batch`." + help = "Specifies a `max_fee` equivalent to the cost of paying (1 proof / `num_proofs_in_batch`) allowing the user to estimate a `max_fee` precisely based on the `number_proofs_in_batch`." )] custom_fee_estimate: Option, #[arg( @@ -143,7 +143,7 @@ pub struct FeeType { instant_fee_estimate: bool, #[arg( long = "default_fee_estimate", - help = "Specifies a default `max_fee` based on the cost of one proof within a batch of 10 proofs, providing a standard fee for batch inclusion." + help = "Specifies a default `max_fee` based on the cost of one proof within a batch of 16 proofs, providing a standard fee for batch inclusion." )] default_fee_estimate: bool, } @@ -517,9 +517,9 @@ async fn main() -> Result<(), AlignedError> { return Ok(()); } - let amount = deposit_to_batcher_args.amount.replace("ether", ""); + let amount_ether = deposit_to_batcher_args.amount.replace("ether", ""); - let amount_ether = parse_ether(&amount).map_err(|e| { + let amount_wei = parse_ether(&amount_ether).map_err(|e| { SubmitError::EthereumProviderError(format!("Error while parsing amount: {}", e)) })?; @@ -550,7 +550,7 @@ async fn main() -> Result<(), AlignedError> { let client = SignerMiddleware::new(eth_rpc_provider.clone(), wallet.clone()); - match deposit_to_aligned(amount_ether, client, deposit_to_batcher_args.network.into()) + match deposit_to_aligned(amount_wei, client, deposit_to_batcher_args.network.into()) .await { Ok(receipt) => { From 13efe4df07ff93e195dc8bf494f1eccacef55a8b Mon Sep 17 00:00:00 2001 From: PatStiles Date: Mon, 9 Dec 2024 10:28:29 -0300 Subject: [PATCH 31/74] change to 10 --- batcher/aligned-sdk/src/core/constants.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/batcher/aligned-sdk/src/core/constants.rs b/batcher/aligned-sdk/src/core/constants.rs index f554b7734a..d88829613d 100644 --- a/batcher/aligned-sdk/src/core/constants.rs +++ b/batcher/aligned-sdk/src/core/constants.rs @@ -23,7 +23,7 @@ pub const PERCENTAGE_DIVIDER: u128 = 100; /// i.e. the user pays for the entire batch and his proof is instantly submitted, therefore a batch of one proof. pub const INSTANT_MAX_FEE_BATCH_SIZE: usize = 1; /// The number of proofs in a batch to compute the `Default` fee estimate for proof submission to Aligned. -pub const DEFAULT_MAX_FEE_BATCH_SIZE: usize = 16; +pub const DEFAULT_MAX_FEE_BATCH_SIZE: usize = 10; /// Ethereum calls retry constants pub const ETHEREUM_CALL_MIN_RETRY_DELAY: u64 = 500; // milliseconds From d1e4c9e295d88a0c5690fd03fba2bbaa307299a7 Mon Sep 17 00:00:00 2001 From: PatStiles Date: Mon, 9 Dec 2024 16:11:33 -0300 Subject: [PATCH 32/74] uri's comments + nits + naming changes --- batcher/aligned-sdk/src/core/constants.rs | 3 ++- batcher/aligned-sdk/src/core/types.rs | 4 ++-- batcher/aligned-sdk/src/sdk.rs | 20 +++++++++++--------- batcher/aligned/src/main.rs | 16 ++++++---------- 4 files changed, 21 insertions(+), 22 deletions(-) diff --git a/batcher/aligned-sdk/src/core/constants.rs b/batcher/aligned-sdk/src/core/constants.rs index d88829613d..0dd055ae72 100644 --- a/batcher/aligned-sdk/src/core/constants.rs +++ b/batcher/aligned-sdk/src/core/constants.rs @@ -23,7 +23,8 @@ pub const PERCENTAGE_DIVIDER: u128 = 100; /// i.e. the user pays for the entire batch and his proof is instantly submitted, therefore a batch of one proof. pub const INSTANT_MAX_FEE_BATCH_SIZE: usize = 1; /// The number of proofs in a batch to compute the `Default` fee estimate for proof submission to Aligned. -pub const DEFAULT_MAX_FEE_BATCH_SIZE: usize = 10; +/// We define `16` as the `Default` setting as every 24 hours the batcher receives a batch of `16` proofs sent from Aligned to confirm the network is live. +pub const DEFAULT_MAX_FEE_BATCH_SIZE: usize = 16; /// Ethereum calls retry constants pub const ETHEREUM_CALL_MIN_RETRY_DELAY: u64 = 500; // milliseconds diff --git a/batcher/aligned-sdk/src/core/types.rs b/batcher/aligned-sdk/src/core/types.rs index afa0e7108d..17006c5500 100644 --- a/batcher/aligned-sdk/src/core/types.rs +++ b/batcher/aligned-sdk/src/core/types.rs @@ -86,9 +86,9 @@ impl NoncedVerificationData { } } -// Defines an estimate price preference for the user. +// Defines an price estimate type for the user. #[derive(Debug, Serialize, Deserialize, Clone)] -pub enum FeeEstimateType { +pub enum FeeEstimationType { Default, Instant, Custom(usize), diff --git a/batcher/aligned-sdk/src/sdk.rs b/batcher/aligned-sdk/src/sdk.rs index 4c43eedac4..8470b8f2db 100644 --- a/batcher/aligned-sdk/src/sdk.rs +++ b/batcher/aligned-sdk/src/sdk.rs @@ -13,7 +13,7 @@ use crate::{ }, errors::{self, GetNonceError}, types::{ - AlignedVerificationData, ClientMessage, FeeEstimateType, GetNonceResponseMessage, + AlignedVerificationData, ClientMessage, FeeEstimationType, GetNonceResponseMessage, Network, ProvingSystemId, VerificationData, }, }, @@ -135,16 +135,18 @@ pub async fn submit_multiple_and_wait_verification( /// * `EthereumGasPriceError` if there is an error retrieving the Ethereum gas price. pub async fn estimate_fee( eth_rpc_url: &str, - estimate_type: FeeEstimateType, + fee_estimation_type: FeeEstimationType, ) -> Result { - match estimate_type { - FeeEstimateType::Default => { - calculate_fee_per_proof_in_batch(eth_rpc_url, DEFAULT_MAX_FEE_BATCH_SIZE).await + match fee_estimation_type { + FeeEstimationType::Default => { + calculate_fee_per_proof_for_batch_of_size(eth_rpc_url, DEFAULT_MAX_FEE_BATCH_SIZE).await } - FeeEstimateType::Instant => { - calculate_fee_per_proof_in_batch(eth_rpc_url, INSTANT_MAX_FEE_BATCH_SIZE).await + FeeEstimationType::Instant => { + calculate_fee_per_proof_for_batch_of_size(eth_rpc_url, INSTANT_MAX_FEE_BATCH_SIZE).await + } + FeeEstimationType::Custom(n) => { + calculate_fee_per_proof_for_batch_of_size(eth_rpc_url, n).await } - FeeEstimateType::Custom(n) => calculate_fee_per_proof_in_batch(eth_rpc_url, n).await, } } @@ -159,7 +161,7 @@ pub async fn estimate_fee( /// # Errors /// * `EthereumProviderError` if there is an error in the connection with the RPC provider. /// * `EthereumGasPriceError` if there is an error retrieving the Ethereum gas price. -pub async fn calculate_fee_per_proof_in_batch( +pub async fn calculate_fee_per_proof_for_batch_of_size( eth_rpc_url: &str, num_proofs_in_batch: usize, ) -> Result { diff --git a/batcher/aligned/src/main.rs b/batcher/aligned/src/main.rs index 4256cd53d7..2a9968cc45 100644 --- a/batcher/aligned/src/main.rs +++ b/batcher/aligned/src/main.rs @@ -6,7 +6,7 @@ use std::path::PathBuf; use std::str::FromStr; use aligned_sdk::communication::serialization::cbor_deserialize; -use aligned_sdk::core::types::FeeEstimateType; +use aligned_sdk::core::types::FeeEstimationType; use aligned_sdk::core::{ errors::{AlignedError, SubmitError}, types::{AlignedVerificationData, Network, ProvingSystemId, VerificationData}, @@ -143,7 +143,7 @@ pub struct FeeType { instant_fee_estimate: bool, #[arg( long = "default_fee_estimate", - help = "Specifies a default `max_fee` based on the cost of one proof within a batch of 16 proofs, providing a standard fee for batch inclusion." + help = "Specifies a `max_fee`, based on the cost of one proof within a batch of 16 proofs, providing a `default` fee for batch inclusion." )] default_fee_estimate: bool, } @@ -167,26 +167,22 @@ impl SubmitArgs { if let Some(number_proofs_in_batch) = &self.fee_type.custom_fee_estimate { return estimate_fee( &self.eth_rpc_url, - FeeEstimateType::Custom(*number_proofs_in_batch), + FeeEstimationType::Custom(*number_proofs_in_batch), ) .await .map_err(AlignedError::FeeEstimateError); } if self.fee_type.instant_fee_estimate { - return estimate_fee(&self.eth_rpc_url, FeeEstimateType::Instant) + return estimate_fee(&self.eth_rpc_url, FeeEstimationType::Instant) .await .map_err(AlignedError::FeeEstimateError); - } - - if self.fee_type.default_fee_estimate { - return estimate_fee(&self.eth_rpc_url, FeeEstimateType::Default) + } else { + return estimate_fee(&self.eth_rpc_url, FeeEstimationType::Default) .await .map_err(AlignedError::FeeEstimateError); } - Ok(U256::from_dec_str("13000000000000") - .map_err(|e| SubmitError::GenericError(e.to_string()))?) // 13_000 gas per proof * 100 gwei gas price (upper bound) } } From 590c7d5ccdf1ae87eb4801bbead06634ca54df66 Mon Sep 17 00:00:00 2001 From: PatStiles Date: Mon, 9 Dec 2024 16:29:20 -0300 Subject: [PATCH 33/74] add back tests --- batcher/aligned-sdk/src/sdk.rs | 47 ++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/batcher/aligned-sdk/src/sdk.rs b/batcher/aligned-sdk/src/sdk.rs index 8470b8f2db..f0a92ed14f 100644 --- a/batcher/aligned-sdk/src/sdk.rs +++ b/batcher/aligned-sdk/src/sdk.rs @@ -811,3 +811,50 @@ fn save_response_json( Ok(()) } + +#[cfg(test)] +mod test { + //Public constants for convenience + pub const HOLESKY_PUBLIC_RPC_URL: &str = "https://ethereum-holesky-rpc.publicnode.com"; + use super::*; + + #[tokio::test] + async fn computed_max_fee_for_larger_batch_is_smaller() { + let small_fee = calculate_fee_per_proof_for_batch_of_size(HOLESKY_PUBLIC_RPC_URL, 2) + .await + .unwrap(); + let large_fee = calculate_fee_per_proof_for_batch_of_size(HOLESKY_PUBLIC_RPC_URL, 5) + .await + .unwrap(); + + assert!(small_fee < large_fee); + } + + #[tokio::test] + async fn computed_max_fee_for_more_proofs_larger_than_for_less_proofs() { + let small_fee = calculate_fee_per_proof_for_batch_of_size(HOLESKY_PUBLIC_RPC_URL, 20) + .await + .unwrap(); + let large_fee = calculate_fee_per_proof_for_batch_of_size(HOLESKY_PUBLIC_RPC_URL, 10) + .await + .unwrap(); + + assert!(small_fee < large_fee); + } + + #[tokio::test] + async fn estimate_fee_are_larger_than_one_another() { + let min_fee = estimate_fee(HOLESKY_PUBLIC_RPC_URL, FeeEstimationType::Custom(100)) + .await + .unwrap(); + let default_fee = estimate_fee(HOLESKY_PUBLIC_RPC_URL, FeeEstimationType::Default) + .await + .unwrap(); + let instant_fee = estimate_fee(HOLESKY_PUBLIC_RPC_URL, FeeEstimationType::Instant) + .await + .unwrap(); + + assert!(min_fee < default_fee); + assert!(default_fee < instant_fee); + } +} \ No newline at end of file From 543c0556fecfcd67bfd2760ea8a1ec135e019671 Mon Sep 17 00:00:00 2001 From: PatStiles Date: Mon, 9 Dec 2024 16:35:08 -0300 Subject: [PATCH 34/74] clippy --- batcher/aligned/src/main.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/batcher/aligned/src/main.rs b/batcher/aligned/src/main.rs index 2a9968cc45..b746118116 100644 --- a/batcher/aligned/src/main.rs +++ b/batcher/aligned/src/main.rs @@ -174,15 +174,14 @@ impl SubmitArgs { } if self.fee_type.instant_fee_estimate { - return estimate_fee(&self.eth_rpc_url, FeeEstimationType::Instant) + estimate_fee(&self.eth_rpc_url, FeeEstimationType::Instant) .await - .map_err(AlignedError::FeeEstimateError); + .map_err(AlignedError::FeeEstimateError) } else { - return estimate_fee(&self.eth_rpc_url, FeeEstimationType::Default) + estimate_fee(&self.eth_rpc_url, FeeEstimationType::Default) .await - .map_err(AlignedError::FeeEstimateError); + .map_err(AlignedError::FeeEstimateError) } - } } From 5471636157ade527953b5fb07c096ad5e6d80661 Mon Sep 17 00:00:00 2001 From: PatStiles Date: Mon, 9 Dec 2024 16:36:20 -0300 Subject: [PATCH 35/74] fmt --- batcher/aligned-sdk/src/sdk.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/batcher/aligned-sdk/src/sdk.rs b/batcher/aligned-sdk/src/sdk.rs index f0a92ed14f..89f3979fd6 100644 --- a/batcher/aligned-sdk/src/sdk.rs +++ b/batcher/aligned-sdk/src/sdk.rs @@ -857,4 +857,4 @@ mod test { assert!(min_fee < default_fee); assert!(default_fee < instant_fee); } -} \ No newline at end of file +} From 495787a27bb398419892cac07f26a05202787fac Mon Sep 17 00:00:00 2001 From: PatStiles Date: Tue, 10 Dec 2024 11:45:57 -0300 Subject: [PATCH 36/74] fix tests --- batcher/aligned-sdk/src/sdk.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/batcher/aligned-sdk/src/sdk.rs b/batcher/aligned-sdk/src/sdk.rs index 89f3979fd6..d42ce4cdfb 100644 --- a/batcher/aligned-sdk/src/sdk.rs +++ b/batcher/aligned-sdk/src/sdk.rs @@ -820,10 +820,10 @@ mod test { #[tokio::test] async fn computed_max_fee_for_larger_batch_is_smaller() { - let small_fee = calculate_fee_per_proof_for_batch_of_size(HOLESKY_PUBLIC_RPC_URL, 2) + let small_fee = calculate_fee_per_proof_for_batch_of_size(HOLESKY_PUBLIC_RPC_URL, 5) .await .unwrap(); - let large_fee = calculate_fee_per_proof_for_batch_of_size(HOLESKY_PUBLIC_RPC_URL, 5) + let large_fee = calculate_fee_per_proof_for_batch_of_size(HOLESKY_PUBLIC_RPC_URL, 2) .await .unwrap(); From 17c3ba8ef78d488970f006ab35234a4d89ae5ce6 Mon Sep 17 00:00:00 2001 From: Urix <43704209+uri-99@users.noreply.github.com> Date: Tue, 10 Dec 2024 15:19:58 -0300 Subject: [PATCH 37/74] feat: better msg --- batcher/aligned/src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/batcher/aligned/src/main.rs b/batcher/aligned/src/main.rs index b746118116..67d0790127 100644 --- a/batcher/aligned/src/main.rs +++ b/batcher/aligned/src/main.rs @@ -344,7 +344,7 @@ async fn main() -> Result<(), AlignedError> { let eth_rpc_url = submit_args.eth_rpc_url.clone(); let max_fee_wei = submit_args.get_max_fee().await?; info!( - "Will send proof with an estimated max_fee of: {}ether", + "Will send each proof with an estimated max_fee of: {}ether", format_ether(max_fee_wei) ); let repetitions = submit_args.repetitions; From 252f8a6dec5222cf2d7bce17b0be25f6e36b902a Mon Sep 17 00:00:00 2001 From: PatStiles Date: Tue, 7 Jan 2025 09:59:36 -0300 Subject: [PATCH 38/74] revert constant as per Mauro's request --- batcher/aligned-sdk/src/core/constants.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/batcher/aligned-sdk/src/core/constants.rs b/batcher/aligned-sdk/src/core/constants.rs index 0dd055ae72..2c3a1e5a17 100644 --- a/batcher/aligned-sdk/src/core/constants.rs +++ b/batcher/aligned-sdk/src/core/constants.rs @@ -23,8 +23,9 @@ pub const PERCENTAGE_DIVIDER: u128 = 100; /// i.e. the user pays for the entire batch and his proof is instantly submitted, therefore a batch of one proof. pub const INSTANT_MAX_FEE_BATCH_SIZE: usize = 1; /// The number of proofs in a batch to compute the `Default` fee estimate for proof submission to Aligned. -/// We define `16` as the `Default` setting as every 24 hours the batcher receives a batch of `16` proofs sent from Aligned to confirm the network is live. -pub const DEFAULT_MAX_FEE_BATCH_SIZE: usize = 16; +/// We define `10` as the `Default` setting as every 24 hours the batcher receives a batch of `16` proofs +/// sent from Aligned to confirm the network is live and estimating with a batch size of `10` proofs provides a buffer in case of a network fee increase. +pub const DEFAULT_MAX_FEE_BATCH_SIZE: usize = 10; /// Ethereum calls retry constants pub const ETHEREUM_CALL_MIN_RETRY_DELAY: u64 = 500; // milliseconds From caf344b8e6cad3405ed4457495761caf032926a5 Mon Sep 17 00:00:00 2001 From: Urix <43704209+uri-99@users.noreply.github.com> Date: Tue, 7 Jan 2025 11:45:07 -0300 Subject: [PATCH 39/74] chore: cargo fmt --- batcher/aligned-sdk/src/core/constants.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/batcher/aligned-sdk/src/core/constants.rs b/batcher/aligned-sdk/src/core/constants.rs index 2c3a1e5a17..a7c85edc87 100644 --- a/batcher/aligned-sdk/src/core/constants.rs +++ b/batcher/aligned-sdk/src/core/constants.rs @@ -23,7 +23,7 @@ pub const PERCENTAGE_DIVIDER: u128 = 100; /// i.e. the user pays for the entire batch and his proof is instantly submitted, therefore a batch of one proof. pub const INSTANT_MAX_FEE_BATCH_SIZE: usize = 1; /// The number of proofs in a batch to compute the `Default` fee estimate for proof submission to Aligned. -/// We define `10` as the `Default` setting as every 24 hours the batcher receives a batch of `16` proofs +/// We define `10` as the `Default` setting as every 24 hours the batcher receives a batch of `16` proofs /// sent from Aligned to confirm the network is live and estimating with a batch size of `10` proofs provides a buffer in case of a network fee increase. pub const DEFAULT_MAX_FEE_BATCH_SIZE: usize = 10; From bf8bdb1213833fb215e9ecca4f5d10afbd712b14 Mon Sep 17 00:00:00 2001 From: PatStiles Date: Wed, 8 Jan 2025 18:39:14 -0300 Subject: [PATCH 40/74] gaston's comments --- batcher/aligned-sdk/src/core/types.rs | 2 +- batcher/aligned-sdk/src/sdk.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/batcher/aligned-sdk/src/core/types.rs b/batcher/aligned-sdk/src/core/types.rs index 17006c5500..027201fc4c 100644 --- a/batcher/aligned-sdk/src/core/types.rs +++ b/batcher/aligned-sdk/src/core/types.rs @@ -86,7 +86,7 @@ impl NoncedVerificationData { } } -// Defines an price estimate type for the user. +// Defines a price estimate type for the user. #[derive(Debug, Serialize, Deserialize, Clone)] pub enum FeeEstimationType { Default, diff --git a/batcher/aligned-sdk/src/sdk.rs b/batcher/aligned-sdk/src/sdk.rs index d42ce4cdfb..9b309b2c75 100644 --- a/batcher/aligned-sdk/src/sdk.rs +++ b/batcher/aligned-sdk/src/sdk.rs @@ -120,9 +120,9 @@ pub async fn submit_multiple_and_wait_verification( /// NOTE: The `max_fee` is computed from an rpc nodes max priority gas price. /// To estimate the `max_fee` of a batch we compute it based on a batch size of 1 (Instant), 16 (Default), or a user supplied `number_proofs_in_batch` (Custom). /// The `max_fee` estimates therefore are: -/// * `Default`: Specifies a `max_fee` equivalent to the cost of paying for one proof within a batch of 16 proofs ie. 1 / 16 proofs. +/// * `Default`: Specifies a `max_fee` equivalent to the cost of paying for one proof within a batch of 10 proofs ie. 1 / 10 proofs. /// This estimates a default `max_fee` the user should specify for including there proof within the batch. -/// * `Instant`: Specifies a `max_fee` equivalent to the cost of paying for an entire batch ensuring the user's proof is included instantly. +/// * `Instant`: Specifies a `max_fee` equivalent to the cost of paying for an entire batch ensuring the user's proof is included instantly assuming the proof is not competing with others for inclusion. /// * `Custom (number_proofs_in_batch)`: Specifies a `max_fee` equivalent to the cost of paying 1 proof / `number_proofs_in_batch` allowing the user a user to estimate the `max_fee` precisely based on the `number_proofs_in_batch`. /// /// # Arguments From 23ec4beca5eaab98e51913e180941823b7d7d769 Mon Sep 17 00:00:00 2001 From: Urix <43704209+uri-99@users.noreply.github.com> Date: Thu, 9 Jan 2025 13:42:02 -0300 Subject: [PATCH 41/74] fix: error types and comment --- batcher/aligned-sdk/src/sdk.rs | 2 +- batcher/aligned/src/main.rs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/batcher/aligned-sdk/src/sdk.rs b/batcher/aligned-sdk/src/sdk.rs index 9b309b2c75..e3d8eb6dc0 100644 --- a/batcher/aligned-sdk/src/sdk.rs +++ b/batcher/aligned-sdk/src/sdk.rs @@ -118,7 +118,7 @@ pub async fn submit_multiple_and_wait_verification( /// Returns the estimated `max_fee` depending on the batch inclusion preference of the user, computed based on the current gas price, and the number of proofs in a batch. /// NOTE: The `max_fee` is computed from an rpc nodes max priority gas price. -/// To estimate the `max_fee` of a batch we compute it based on a batch size of 1 (Instant), 16 (Default), or a user supplied `number_proofs_in_batch` (Custom). +/// To estimate the `max_fee` of a batch we compute it based on a batch size of 1 (Instant), 10 (Default), or a user supplied `number_proofs_in_batch` (Custom). /// The `max_fee` estimates therefore are: /// * `Default`: Specifies a `max_fee` equivalent to the cost of paying for one proof within a batch of 10 proofs ie. 1 / 10 proofs. /// This estimates a default `max_fee` the user should specify for including there proof within the batch. diff --git a/batcher/aligned/src/main.rs b/batcher/aligned/src/main.rs index 67d0790127..56284854da 100644 --- a/batcher/aligned/src/main.rs +++ b/batcher/aligned/src/main.rs @@ -8,7 +8,7 @@ use std::str::FromStr; use aligned_sdk::communication::serialization::cbor_deserialize; use aligned_sdk::core::types::FeeEstimationType; use aligned_sdk::core::{ - errors::{AlignedError, SubmitError}, + errors::{AlignedError, SubmitError, FeeEstimateError}, types::{AlignedVerificationData, Network, ProvingSystemId, VerificationData}, }; use aligned_sdk::sdk::estimate_fee; @@ -153,14 +153,14 @@ impl SubmitArgs { if let Some(max_fee) = &self.fee_type.max_fee { if !max_fee.ends_with("ether") { error!("`max_fee` should be in the format XX.XXether"); - Err(SubmitError::EthereumProviderError( + Err(FeeEstimateError::FeeEstimateParseError( "Error while parsing `max_fee`".to_string(), ))? } let max_fee_ether = max_fee.replace("ether", ""); return Ok(parse_ether(max_fee_ether).map_err(|e| { - SubmitError::EthereumProviderError(format!("Error while parsing `max_fee`: {}", e)) + FeeEstimateError::FeeEstimateParseError(format!("Error while parsing `max_fee`: {}", e)) })?); } From cdadb7090ac7e1fc390eeff4c9b1cebb54a925e0 Mon Sep 17 00:00:00 2001 From: Urix <43704209+uri-99@users.noreply.github.com> Date: Thu, 9 Jan 2025 15:14:10 -0300 Subject: [PATCH 42/74] docs: add to CLI docs, and better --help info --- batcher/aligned/src/main.rs | 8 ++++---- docs/3_guides/9_aligned_cli.md | 10 +++++++--- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/batcher/aligned/src/main.rs b/batcher/aligned/src/main.rs index 56284854da..1761465bee 100644 --- a/batcher/aligned/src/main.rs +++ b/batcher/aligned/src/main.rs @@ -131,19 +131,19 @@ pub struct FeeType { )] max_fee: Option, // String because U256 expects hex #[arg( - name = "NUMBER_PROOFS_IN_BATCH", + name = "amount_of_proofs_in_batch", long = "custom_fee_estimate", - help = "Specifies a `max_fee` equivalent to the cost of paying (1 proof / `num_proofs_in_batch`) allowing the user to estimate a `max_fee` precisely based on the `number_proofs_in_batch`." + help = "Specifies a `max_fee` equivalent to the cost of 1 proof in a batch of size `num_proofs_in_batch`." )] custom_fee_estimate: Option, #[arg( long = "instant_fee_estimate", - help = "Specifies a `max_fee` that covers the cost of paying for the entire batch, ensuring the proof is included instantly." + help = "Specifies a `max_fee` that ensures the proof is included instantly, equivalent to the cost of 1 proof in a batch of size 1." )] instant_fee_estimate: bool, #[arg( long = "default_fee_estimate", - help = "Specifies a `max_fee`, based on the cost of one proof within a batch of 16 proofs, providing a `default` fee for batch inclusion." + help = "Specifies a `max_fee`, based on the cost of one proof in a batch of 10 proofs." )] default_fee_estimate: bool, } diff --git a/docs/3_guides/9_aligned_cli.md b/docs/3_guides/9_aligned_cli.md index fb4cbaa436..65ed1771b1 100644 --- a/docs/3_guides/9_aligned_cli.md +++ b/docs/3_guides/9_aligned_cli.md @@ -67,13 +67,17 @@ Submit a proof to the Aligned Layer batcher. - Default: `./aligned_verification_data/` - `--keystore_path `: Path to the local keystore. - `--private_key `: User's wallet private key. -- `--max_fee `: Maximum fee in Ether to deposit into the contract. - - Default: `0.0013ether` - `--nonce `: Proof nonce. - By default, the nonce is set automatically. By setting the nonce manually, you can perform a proof replacement. - `--network `: Network name to interact with. - Default: `devnet` - Possible values: `devnet`, `holesky`, `mainnet` +- Max Fee allowed to be spent for each proof verification, use one of the following: + - `--max_fee `: Specifies a `max_fee` in Ether. + - `--default_fee_estimate`: Specifies a `max_fee` equivalent to the cost of 1 proof in a batch of size 10. + - `--instant_fee_estimate`: Specifies a `max_fee` that ensures the proof is included instantly, equivalent to the cost of a proof in a batch of size 1. + - `--custom_fee_estimate `: Specifies a `max_fee` equivalent to the cost of 1 proof in a batch of size `num_proofs_in_batch`. + #### Example: ```bash @@ -140,7 +144,7 @@ Computes the verification data commitment from the verification data file. --- -### deposit-to-batcher +### **deposit-to-batcher** #### Description: From 6921c5e4b5bd4584628e72869003cfaf3859f788 Mon Sep 17 00:00:00 2001 From: Urix <43704209+uri-99@users.noreply.github.com> Date: Thu, 9 Jan 2025 15:18:17 -0300 Subject: [PATCH 43/74] chore: cargo fmt --- batcher/aligned/src/main.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/batcher/aligned/src/main.rs b/batcher/aligned/src/main.rs index 1761465bee..bf37247e3c 100644 --- a/batcher/aligned/src/main.rs +++ b/batcher/aligned/src/main.rs @@ -8,7 +8,7 @@ use std::str::FromStr; use aligned_sdk::communication::serialization::cbor_deserialize; use aligned_sdk::core::types::FeeEstimationType; use aligned_sdk::core::{ - errors::{AlignedError, SubmitError, FeeEstimateError}, + errors::{AlignedError, FeeEstimateError, SubmitError}, types::{AlignedVerificationData, Network, ProvingSystemId, VerificationData}, }; use aligned_sdk::sdk::estimate_fee; @@ -160,7 +160,10 @@ impl SubmitArgs { let max_fee_ether = max_fee.replace("ether", ""); return Ok(parse_ether(max_fee_ether).map_err(|e| { - FeeEstimateError::FeeEstimateParseError(format!("Error while parsing `max_fee`: {}", e)) + FeeEstimateError::FeeEstimateParseError(format!( + "Error while parsing `max_fee`: {}", + e + )) })?); } From d55f58ed78f8745c7a6588c45aa9fa7d41658eab Mon Sep 17 00:00:00 2001 From: PatStiles Date: Tue, 10 Dec 2024 10:39:33 -0300 Subject: [PATCH 44/74] remove NetworkArg type --- batcher/aligned-sdk/Cargo.toml | 1 + batcher/aligned-sdk/src/core/types.rs | 28 +++++++++++++++++++- batcher/aligned-sdk/src/sdk.rs | 38 ++++++--------------------- batcher/aligned/src/main.rs | 37 ++++++-------------------- 4 files changed, 44 insertions(+), 60 deletions(-) diff --git a/batcher/aligned-sdk/Cargo.toml b/batcher/aligned-sdk/Cargo.toml index 019a659842..9b1bcedd0e 100644 --- a/batcher/aligned-sdk/Cargo.toml +++ b/batcher/aligned-sdk/Cargo.toml @@ -25,3 +25,4 @@ hex = "0.4.3" ciborium = "=0.2.2" serde_repr = "0.1.19" dialoguer = "0.11.0" +clap = { version = "4.5.4", features = ["derive"] } diff --git a/batcher/aligned-sdk/src/core/types.rs b/batcher/aligned-sdk/src/core/types.rs index ba59b5d6b5..3c5a07a189 100644 --- a/batcher/aligned-sdk/src/core/types.rs +++ b/batcher/aligned-sdk/src/core/types.rs @@ -3,6 +3,7 @@ use std::fmt::Display; use std::fmt::Formatter; use std::str::FromStr; +use clap::ValueEnum; use ethers::core::k256::ecdsa::SigningKey; use ethers::signers::Signer; use ethers::signers::Wallet; @@ -11,6 +12,7 @@ use ethers::types::transaction::eip712::Eip712; use ethers::types::transaction::eip712::Eip712Error; use ethers::types::Address; use ethers::types::Signature; +use ethers::types::H160; use ethers::types::U256; use lambdaworks_crypto::merkle_tree::{ merkle::MerkleTree, proof::Proof, traits::IsMerkleTreeBackend, @@ -396,7 +398,7 @@ pub enum GetNonceResponseMessage { InvalidRequest(String), } -#[derive(Debug, Clone, Copy)] +#[derive(Debug, Clone, Copy, ValueEnum)] pub enum Network { Devnet, Holesky, @@ -404,6 +406,30 @@ pub enum Network { Mainnet, } +impl Network { + pub fn get_batcher_payment_service_address(&self) -> ethers::types::H160 { + match self { + Self::Devnet => H160::from_str("0x7bc06c482DEAd17c0e297aFbC32f6e63d3846650").unwrap(), + Self::Holesky => H160::from_str("0x815aeCA64a974297942D2Bbf034ABEe22a38A003").unwrap(), + Self::HoleskyStage => { + H160::from_str("0x7577Ec4ccC1E6C529162ec8019A49C13F6DAd98b").unwrap() + } + Self::Mainnet => H160::from_str("0xb0567184A52cB40956df6333510d6eF35B89C8de").unwrap(), + } + } + + pub fn get_aligned_service_manager_address(&self) -> ethers::types::H160 { + match self { + Self::Devnet => H160::from_str("0x1613beB3B2C4f22Ee086B2b38C1476A3cE7f78E8").unwrap(), + Self::Holesky => H160::from_str("0x58F280BeBE9B34c9939C3C39e0890C81f163B623").unwrap(), + Self::HoleskyStage => { + H160::from_str("0x9C5231FC88059C086Ea95712d105A2026048c39B").unwrap() + } + Self::Mainnet => H160::from_str("0xeF2A435e5EE44B2041100EF8cbC8ae035166606c").unwrap(), + } + } +} + impl FromStr for Network { type Err = String; diff --git a/batcher/aligned-sdk/src/sdk.rs b/batcher/aligned-sdk/src/sdk.rs index 6045d84116..c3cb2a7a88 100644 --- a/batcher/aligned-sdk/src/sdk.rs +++ b/batcher/aligned-sdk/src/sdk.rs @@ -28,10 +28,10 @@ use ethers::{ prelude::k256::ecdsa::SigningKey, providers::{Http, Middleware, Provider}, signers::{LocalWallet, Wallet}, - types::{Address, H160, U256}, + types::{Address, U256}, }; use sha3::{Digest, Keccak256}; -use std::{str::FromStr, sync::Arc}; +use std::sync::Arc; use tokio::{net::TcpStream, sync::Mutex}; use tokio_tungstenite::{connect_async, tungstenite::Message, MaybeTlsStream, WebSocketStream}; @@ -271,28 +271,6 @@ pub async fn submit_multiple( .await } -pub fn get_payment_service_address(network: Network) -> ethers::types::H160 { - match network { - Network::Devnet => H160::from_str("0x7bc06c482DEAd17c0e297aFbC32f6e63d3846650").unwrap(), - Network::Holesky => H160::from_str("0x815aeCA64a974297942D2Bbf034ABEe22a38A003").unwrap(), - Network::HoleskyStage => { - H160::from_str("0x7577Ec4ccC1E6C529162ec8019A49C13F6DAd98b").unwrap() - } - Network::Mainnet => H160::from_str("0xb0567184A52cB40956df6333510d6eF35B89C8de").unwrap(), - } -} - -pub fn get_aligned_service_manager_address(network: Network) -> ethers::types::H160 { - match network { - Network::Devnet => H160::from_str("0x1613beB3B2C4f22Ee086B2b38C1476A3cE7f78E8").unwrap(), - Network::Holesky => H160::from_str("0x58F280BeBE9B34c9939C3C39e0890C81f163B623").unwrap(), - Network::HoleskyStage => { - H160::from_str("0x9C5231FC88059C086Ea95712d105A2026048c39B").unwrap() - } - Network::Mainnet => H160::from_str("0xeF2A435e5EE44B2041100EF8cbC8ae035166606c").unwrap(), - } -} - // Will submit the proofs to the batcher and wait for their responses // Will return once all proofs are responded, or up to a proof that is responded with an error async fn _submit_multiple( @@ -328,7 +306,7 @@ async fn _submit_multiple( let response_stream = Arc::new(Mutex::new(response_stream)); - let payment_service_addr = get_payment_service_address(network); + let payment_service_addr = network.get_batcher_payment_service_address(); let result = async { let sent_verification_data_rev = send_messages( @@ -498,8 +476,8 @@ async fn _is_proof_verified( network: Network, eth_rpc_provider: Provider, ) -> Result { - let contract_address = get_aligned_service_manager_address(network); - let payment_service_addr = get_payment_service_address(network); + let contract_address = network.get_aligned_service_manager_address(); + let payment_service_addr = network.get_batcher_payment_service_address(); // All the elements from the merkle proof have to be concatenated let merkle_proof: Vec = aligned_verification_data @@ -640,7 +618,7 @@ pub async fn get_nonce_from_ethereum( let eth_rpc_provider = Provider::::try_from(eth_rpc_url) .map_err(|e| GetNonceError::EthRpcError(e.to_string()))?; - let payment_service_address = get_payment_service_address(network); + let payment_service_address = network.get_batcher_payment_service_address(); match batcher_payment_service(eth_rpc_provider, payment_service_address).await { Ok(contract) => { @@ -691,7 +669,7 @@ pub async fn deposit_to_aligned( signer: SignerMiddleware, LocalWallet>, network: Network, ) -> Result { - let payment_service_address = get_payment_service_address(network); + let payment_service_address = network.get_batcher_payment_service_address(); let from = signer.address(); let tx = TransactionRequest::new() @@ -729,7 +707,7 @@ pub async fn get_balance_in_aligned( let eth_rpc_provider = Provider::::try_from(eth_rpc_url) .map_err(|e| errors::BalanceError::EthereumProviderError(e.to_string()))?; - let payment_service_address = get_payment_service_address(network); + let payment_service_address = network.get_batcher_payment_service_address(); match batcher_payment_service(eth_rpc_provider, payment_service_address).await { Ok(batcher_payment_service) => { diff --git a/batcher/aligned/src/main.rs b/batcher/aligned/src/main.rs index 1153cacbda..fe51bbba47 100644 --- a/batcher/aligned/src/main.rs +++ b/batcher/aligned/src/main.rs @@ -120,7 +120,7 @@ pub struct SubmitArgs { long = "network", default_value = "devnet" )] - network: NetworkArg, + network: Network, } #[derive(Parser, Debug)] @@ -143,7 +143,7 @@ pub struct DepositToBatcherArgs { long = "network", default_value = "devnet" )] - network: NetworkArg, + network: Network, #[arg(name = "Amount to deposit", long = "amount", required = true)] amount: String, } @@ -164,7 +164,7 @@ pub struct VerifyProofOnchainArgs { long = "network", default_value = "devnet" )] - network: NetworkArg, + network: Network, } #[derive(Parser, Debug)] @@ -186,7 +186,7 @@ pub struct GetUserBalanceArgs { long = "network", default_value = "devnet" )] - network: NetworkArg, + network: Network, #[arg( name = "Ethereum RPC provider address", long = "rpc_url", @@ -218,25 +218,6 @@ pub struct GetUserNonceArgs { address: String, } -#[derive(Debug, Clone, ValueEnum, Copy)] -enum NetworkArg { - Devnet, - Holesky, - HoleskyStage, - Mainnet, -} - -impl From for Network { - fn from(env_arg: NetworkArg) -> Self { - match env_arg { - NetworkArg::Devnet => Network::Devnet, - NetworkArg::Holesky => Network::Holesky, - NetworkArg::HoleskyStage => Network::HoleskyStage, - NetworkArg::Mainnet => Network::Mainnet, - } - } -} - #[derive(Debug, Clone, ValueEnum)] pub enum ProvingSystemArg { #[clap(name = "GnarkPlonkBls12_381")] @@ -366,7 +347,7 @@ async fn main() -> Result<(), AlignedError> { let aligned_verification_data_vec = submit_multiple( &connect_addr, - submit_args.network.into(), + submit_args.network, &verification_data_arr, max_fee_wei, wallet.clone(), @@ -425,7 +406,7 @@ async fn main() -> Result<(), AlignedError> { info!("Verifying response data matches sent proof data..."); let response = is_proof_verified( &aligned_verification_data, - verify_inclusion_args.network.into(), + verify_inclusion_args.network, &verify_inclusion_args.eth_rpc_url, ) .await?; @@ -490,9 +471,7 @@ async fn main() -> Result<(), AlignedError> { let client = SignerMiddleware::new(eth_rpc_provider.clone(), wallet.clone()); - match deposit_to_aligned(amount_wei, client, deposit_to_batcher_args.network.into()) - .await - { + match deposit_to_aligned(amount_wei, client, deposit_to_batcher_args.network).await { Ok(receipt) => { info!( "Payment sent to the batcher successfully. Tx: 0x{:x}", @@ -509,7 +488,7 @@ async fn main() -> Result<(), AlignedError> { match get_balance_in_aligned( user_address, &get_user_balance_args.eth_rpc_url, - get_user_balance_args.network.into(), + get_user_balance_args.network, ) .await { From bd1139b0857d20ee45a498013499a2590ea2bb82 Mon Sep 17 00:00:00 2001 From: PatStiles Date: Tue, 10 Dec 2024 15:05:56 -0300 Subject: [PATCH 45/74] add lock --- batcher/Cargo.lock | 1 + 1 file changed, 1 insertion(+) diff --git a/batcher/Cargo.lock b/batcher/Cargo.lock index f04cb8c63c..8183b16738 100644 --- a/batcher/Cargo.lock +++ b/batcher/Cargo.lock @@ -130,6 +130,7 @@ name = "aligned-sdk" version = "0.1.0" dependencies = [ "ciborium", + "clap", "dialoguer", "ethers", "futures-util", From bab051aea8c466844d9d758faf61b96774ede272 Mon Sep 17 00:00:00 2001 From: PatStiles Date: Thu, 2 Jan 2025 16:29:25 -0300 Subject: [PATCH 46/74] pass by copy --- batcher/aligned-sdk/src/core/types.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/batcher/aligned-sdk/src/core/types.rs b/batcher/aligned-sdk/src/core/types.rs index 3c5a07a189..a041fe26d1 100644 --- a/batcher/aligned-sdk/src/core/types.rs +++ b/batcher/aligned-sdk/src/core/types.rs @@ -407,7 +407,7 @@ pub enum Network { } impl Network { - pub fn get_batcher_payment_service_address(&self) -> ethers::types::H160 { + pub fn get_batcher_payment_service_address(self) -> ethers::types::H160 { match self { Self::Devnet => H160::from_str("0x7bc06c482DEAd17c0e297aFbC32f6e63d3846650").unwrap(), Self::Holesky => H160::from_str("0x815aeCA64a974297942D2Bbf034ABEe22a38A003").unwrap(), @@ -418,7 +418,7 @@ impl Network { } } - pub fn get_aligned_service_manager_address(&self) -> ethers::types::H160 { + pub fn get_aligned_service_manager_address(self) -> ethers::types::H160 { match self { Self::Devnet => H160::from_str("0x1613beB3B2C4f22Ee086B2b38C1476A3cE7f78E8").unwrap(), Self::Holesky => H160::from_str("0x58F280BeBE9B34c9939C3C39e0890C81f163B623").unwrap(), From 8c4049afbc5fef7a5c556f3000ab788669b6c491 Mon Sep 17 00:00:00 2001 From: PatStiles Date: Tue, 7 Jan 2025 12:04:28 -0300 Subject: [PATCH 47/74] remove need for ValueEnum --- .../aligned-sdk/src/communication/batch.rs | 2 +- batcher/aligned-sdk/src/core/types.rs | 7 +++---- batcher/aligned-sdk/src/sdk.rs | 6 +++--- batcher/aligned/src/main.rs | 19 ++++++++++++------- 4 files changed, 19 insertions(+), 15 deletions(-) diff --git a/batcher/aligned-sdk/src/communication/batch.rs b/batcher/aligned-sdk/src/communication/batch.rs index d3935593f1..56c0b2ad11 100644 --- a/batcher/aligned-sdk/src/communication/batch.rs +++ b/batcher/aligned-sdk/src/communication/batch.rs @@ -41,7 +41,7 @@ pub async fn await_batch_verification( network: Network, ) -> Result<(), errors::SubmitError> { for _ in 0..RETRIES { - if is_proof_verified(aligned_verification_data, network, rpc_url) + if is_proof_verified(aligned_verification_data, network.clone(), rpc_url) .await .is_ok_and(|r| r) { diff --git a/batcher/aligned-sdk/src/core/types.rs b/batcher/aligned-sdk/src/core/types.rs index a041fe26d1..b716e811e1 100644 --- a/batcher/aligned-sdk/src/core/types.rs +++ b/batcher/aligned-sdk/src/core/types.rs @@ -3,7 +3,6 @@ use std::fmt::Display; use std::fmt::Formatter; use std::str::FromStr; -use clap::ValueEnum; use ethers::core::k256::ecdsa::SigningKey; use ethers::signers::Signer; use ethers::signers::Wallet; @@ -398,7 +397,7 @@ pub enum GetNonceResponseMessage { InvalidRequest(String), } -#[derive(Debug, Clone, Copy, ValueEnum)] +#[derive(Debug, Clone)] pub enum Network { Devnet, Holesky, @@ -407,7 +406,7 @@ pub enum Network { } impl Network { - pub fn get_batcher_payment_service_address(self) -> ethers::types::H160 { + pub fn get_batcher_payment_service_address(&self) -> ethers::types::H160 { match self { Self::Devnet => H160::from_str("0x7bc06c482DEAd17c0e297aFbC32f6e63d3846650").unwrap(), Self::Holesky => H160::from_str("0x815aeCA64a974297942D2Bbf034ABEe22a38A003").unwrap(), @@ -418,7 +417,7 @@ impl Network { } } - pub fn get_aligned_service_manager_address(self) -> ethers::types::H160 { + pub fn get_aligned_service_manager_address(&self) -> ethers::types::H160 { match self { Self::Devnet => H160::from_str("0x1613beB3B2C4f22Ee086B2b38C1476A3cE7f78E8").unwrap(), Self::Holesky => H160::from_str("0x58F280BeBE9B34c9939C3C39e0890C81f163B623").unwrap(), diff --git a/batcher/aligned-sdk/src/sdk.rs b/batcher/aligned-sdk/src/sdk.rs index c3cb2a7a88..27cd4cb166 100644 --- a/batcher/aligned-sdk/src/sdk.rs +++ b/batcher/aligned-sdk/src/sdk.rs @@ -89,7 +89,7 @@ pub async fn submit_multiple_and_wait_verification( ) -> Vec> { let mut aligned_verification_data = submit_multiple( batcher_url, - network, + network.clone(), verification_data, max_fee, wallet, @@ -102,7 +102,7 @@ pub async fn submit_multiple_and_wait_verification( let mut error_awaiting_batch_verification: Option = None; for aligned_verification_data_item in aligned_verification_data.iter().flatten() { if let Err(e) = - await_batch_verification(aligned_verification_data_item, eth_rpc_url, network).await + await_batch_verification(aligned_verification_data_item, eth_rpc_url, network.clone()).await { error_awaiting_batch_verification = Some(e); break; @@ -476,7 +476,7 @@ async fn _is_proof_verified( network: Network, eth_rpc_provider: Provider, ) -> Result { - let contract_address = network.get_aligned_service_manager_address(); + let contract_address = network.clone().get_aligned_service_manager_address(); let payment_service_addr = network.get_batcher_payment_service_address(); // All the elements from the merkle proof have to be concatenated diff --git a/batcher/aligned/src/main.rs b/batcher/aligned/src/main.rs index fe51bbba47..fbc62abe11 100644 --- a/batcher/aligned/src/main.rs +++ b/batcher/aligned/src/main.rs @@ -14,6 +14,7 @@ use aligned_sdk::sdk::get_chain_id; use aligned_sdk::sdk::get_nonce_from_batcher; use aligned_sdk::sdk::{deposit_to_aligned, get_balance_in_aligned}; use aligned_sdk::sdk::{get_vk_commitment, is_proof_verified, save_response, submit_multiple}; +use clap::value_parser; use clap::Parser; use clap::Subcommand; use clap::ValueEnum; @@ -118,7 +119,8 @@ pub struct SubmitArgs { #[arg( name = "The working network's name", long = "network", - default_value = "devnet" + default_value = "devnet", + value_parser = value_parser!(Network) )] network: Network, } @@ -141,7 +143,8 @@ pub struct DepositToBatcherArgs { #[arg( name = "The working network's name", long = "network", - default_value = "devnet" + default_value = "devnet", + value_parser = value_parser!(Network) )] network: Network, #[arg(name = "Amount to deposit", long = "amount", required = true)] @@ -162,7 +165,8 @@ pub struct VerifyProofOnchainArgs { #[arg( name = "The working network's name", long = "network", - default_value = "devnet" + default_value = "devnet", + value_parser = value_parser!(Network) )] network: Network, } @@ -184,7 +188,8 @@ pub struct GetUserBalanceArgs { #[arg( name = "The working network's name", long = "network", - default_value = "devnet" + default_value = "devnet", + value_parser = value_parser!(Network) )] network: Network, #[arg( @@ -347,7 +352,7 @@ async fn main() -> Result<(), AlignedError> { let aligned_verification_data_vec = submit_multiple( &connect_addr, - submit_args.network, + submit_args.network.into(), &verification_data_arr, max_fee_wei, wallet.clone(), @@ -406,7 +411,7 @@ async fn main() -> Result<(), AlignedError> { info!("Verifying response data matches sent proof data..."); let response = is_proof_verified( &aligned_verification_data, - verify_inclusion_args.network, + verify_inclusion_args.network.into(), &verify_inclusion_args.eth_rpc_url, ) .await?; @@ -471,7 +476,7 @@ async fn main() -> Result<(), AlignedError> { let client = SignerMiddleware::new(eth_rpc_provider.clone(), wallet.clone()); - match deposit_to_aligned(amount_wei, client, deposit_to_batcher_args.network).await { + match deposit_to_aligned(amount_wei, client, deposit_to_batcher_args.network.into()).await { Ok(receipt) => { info!( "Payment sent to the batcher successfully. Tx: 0x{:x}", From a289328a88c46fa725ee63225a5b9deb07f4e5d8 Mon Sep 17 00:00:00 2001 From: PatStiles Date: Tue, 7 Jan 2025 12:12:46 -0300 Subject: [PATCH 48/74] fmt + clippy --- batcher/aligned-sdk/src/sdk.rs | 3 ++- batcher/aligned/src/main.rs | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/batcher/aligned-sdk/src/sdk.rs b/batcher/aligned-sdk/src/sdk.rs index 27cd4cb166..2e698ad99f 100644 --- a/batcher/aligned-sdk/src/sdk.rs +++ b/batcher/aligned-sdk/src/sdk.rs @@ -102,7 +102,8 @@ pub async fn submit_multiple_and_wait_verification( let mut error_awaiting_batch_verification: Option = None; for aligned_verification_data_item in aligned_verification_data.iter().flatten() { if let Err(e) = - await_batch_verification(aligned_verification_data_item, eth_rpc_url, network.clone()).await + await_batch_verification(aligned_verification_data_item, eth_rpc_url, network.clone()) + .await { error_awaiting_batch_verification = Some(e); break; diff --git a/batcher/aligned/src/main.rs b/batcher/aligned/src/main.rs index fbc62abe11..9601238a68 100644 --- a/batcher/aligned/src/main.rs +++ b/batcher/aligned/src/main.rs @@ -352,7 +352,7 @@ async fn main() -> Result<(), AlignedError> { let aligned_verification_data_vec = submit_multiple( &connect_addr, - submit_args.network.into(), + submit_args.network, &verification_data_arr, max_fee_wei, wallet.clone(), @@ -411,7 +411,7 @@ async fn main() -> Result<(), AlignedError> { info!("Verifying response data matches sent proof data..."); let response = is_proof_verified( &aligned_verification_data, - verify_inclusion_args.network.into(), + verify_inclusion_args.network, &verify_inclusion_args.eth_rpc_url, ) .await?; @@ -476,7 +476,7 @@ async fn main() -> Result<(), AlignedError> { let client = SignerMiddleware::new(eth_rpc_provider.clone(), wallet.clone()); - match deposit_to_aligned(amount_wei, client, deposit_to_batcher_args.network.into()).await { + match deposit_to_aligned(amount_wei, client, deposit_to_batcher_args.network).await { Ok(receipt) => { info!( "Payment sent to the batcher successfully. Tx: 0x{:x}", From 82fa72172df3383d6a999cc21f748b3293b5a235 Mon Sep 17 00:00:00 2001 From: PatStiles Date: Wed, 8 Jan 2025 13:33:59 -0300 Subject: [PATCH 49/74] move values to constants --- batcher/aligned-sdk/src/core/constants.rs | 18 +++++++++++++++++ batcher/aligned-sdk/src/core/types.rs | 24 +++++++++++++---------- 2 files changed, 32 insertions(+), 10 deletions(-) diff --git a/batcher/aligned-sdk/src/core/constants.rs b/batcher/aligned-sdk/src/core/constants.rs index b7a253f7a4..e71e48bf44 100644 --- a/batcher/aligned-sdk/src/core/constants.rs +++ b/batcher/aligned-sdk/src/core/constants.rs @@ -37,3 +37,21 @@ 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 + +/// NETWORK ADDRESSES /// +/// BatcherPaymentService +pub const BATCHER_PAYMENT_SERVICE_ADDRESS_DEVNET: &str = + "0x7bc06c482DEAd17c0e297aFbC32f6e63d3846650"; +pub const BATCHER_PAYMENT_SERVICE_ADDRESS_HOLESKY: &str = + "0x815aeCA64a974297942D2Bbf034ABEe22a38A003"; +pub const BATCHER_PAYMENT_SERVICE_ADDRESS_HOLESKY_STAGE: &str = + "0x7577Ec4ccC1E6C529162ec8019A49C13F6DAd98b"; +pub const BATCHER_PAYMENT_SERVICE_ADDRESS_MAINNET: &str = + "0xb0567184A52cB40956df6333510d6eF35B89C8de"; +/// AlignedServiceManager +pub const ALIGNED_SERVICE_MANAGER_DEVNET: &str = "0x1613beB3B2C4f22Ee086B2b38C1476A3cE7f78E8"; +pub const ALIGNED_SERVICE_MANAGER_HOLESKY: &str = "0x58F280BeBE9B34c9939C3C39e0890C81f163B623"; +pub const ALIGNED_SERVICE_MANAGER_HOLESKY_STAGE: &str = + "0x9C5231FC88059C086Ea95712d105A2026048c39B"; +pub const ALIGNED_SERVICE_MANAGER_HOLESKY_MAINNET: &str = + "0xeF2A435e5EE44B2041100EF8cbC8ae035166606c"; diff --git a/batcher/aligned-sdk/src/core/types.rs b/batcher/aligned-sdk/src/core/types.rs index b716e811e1..6222ee302c 100644 --- a/batcher/aligned-sdk/src/core/types.rs +++ b/batcher/aligned-sdk/src/core/types.rs @@ -19,6 +19,12 @@ use lambdaworks_crypto::merkle_tree::{ use serde::{Deserialize, Serialize}; use sha3::{Digest, Keccak256}; +use super::constants::{ + ALIGNED_SERVICE_MANAGER_DEVNET, ALIGNED_SERVICE_MANAGER_HOLESKY, + ALIGNED_SERVICE_MANAGER_HOLESKY_MAINNET, ALIGNED_SERVICE_MANAGER_HOLESKY_STAGE, + BATCHER_PAYMENT_SERVICE_ADDRESS_DEVNET, BATCHER_PAYMENT_SERVICE_ADDRESS_HOLESKY, + BATCHER_PAYMENT_SERVICE_ADDRESS_HOLESKY_STAGE, BATCHER_PAYMENT_SERVICE_ADDRESS_MAINNET, +}; use super::errors::VerifySignatureError; // VerificationData is a bytes32 instead of a VerificationData struct because in the BatcherPaymentService contract @@ -408,23 +414,21 @@ pub enum Network { impl Network { pub fn get_batcher_payment_service_address(&self) -> ethers::types::H160 { match self { - Self::Devnet => H160::from_str("0x7bc06c482DEAd17c0e297aFbC32f6e63d3846650").unwrap(), - Self::Holesky => H160::from_str("0x815aeCA64a974297942D2Bbf034ABEe22a38A003").unwrap(), + Self::Devnet => H160::from_str(BATCHER_PAYMENT_SERVICE_ADDRESS_DEVNET).unwrap(), + Self::Holesky => H160::from_str(BATCHER_PAYMENT_SERVICE_ADDRESS_HOLESKY).unwrap(), Self::HoleskyStage => { - H160::from_str("0x7577Ec4ccC1E6C529162ec8019A49C13F6DAd98b").unwrap() + H160::from_str(BATCHER_PAYMENT_SERVICE_ADDRESS_HOLESKY_STAGE).unwrap() } - Self::Mainnet => H160::from_str("0xb0567184A52cB40956df6333510d6eF35B89C8de").unwrap(), + Self::Mainnet => H160::from_str(BATCHER_PAYMENT_SERVICE_ADDRESS_MAINNET).unwrap(), } } pub fn get_aligned_service_manager_address(&self) -> ethers::types::H160 { match self { - Self::Devnet => H160::from_str("0x1613beB3B2C4f22Ee086B2b38C1476A3cE7f78E8").unwrap(), - Self::Holesky => H160::from_str("0x58F280BeBE9B34c9939C3C39e0890C81f163B623").unwrap(), - Self::HoleskyStage => { - H160::from_str("0x9C5231FC88059C086Ea95712d105A2026048c39B").unwrap() - } - Self::Mainnet => H160::from_str("0xeF2A435e5EE44B2041100EF8cbC8ae035166606c").unwrap(), + Self::Devnet => H160::from_str(ALIGNED_SERVICE_MANAGER_DEVNET).unwrap(), + Self::Holesky => H160::from_str(ALIGNED_SERVICE_MANAGER_HOLESKY).unwrap(), + Self::HoleskyStage => H160::from_str(ALIGNED_SERVICE_MANAGER_HOLESKY_STAGE).unwrap(), + Self::Mainnet => H160::from_str(ALIGNED_SERVICE_MANAGER_HOLESKY_MAINNET).unwrap(), } } } From 510f6e29366c9769466fe2fc70b095478134483d Mon Sep 17 00:00:00 2001 From: PatStiles Date: Wed, 8 Jan 2025 14:18:09 -0300 Subject: [PATCH 50/74] add custom network arg --- batcher/aligned-sdk/src/core/types.rs | 30 +++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/batcher/aligned-sdk/src/core/types.rs b/batcher/aligned-sdk/src/core/types.rs index 6222ee302c..20f80eec0c 100644 --- a/batcher/aligned-sdk/src/core/types.rs +++ b/batcher/aligned-sdk/src/core/types.rs @@ -409,6 +409,7 @@ pub enum Network { Holesky, HoleskyStage, Mainnet, + Custom(String, String) } impl Network { @@ -420,6 +421,7 @@ impl Network { H160::from_str(BATCHER_PAYMENT_SERVICE_ADDRESS_HOLESKY_STAGE).unwrap() } Self::Mainnet => H160::from_str(BATCHER_PAYMENT_SERVICE_ADDRESS_MAINNET).unwrap(), + Self::Custom(s, _) => H160::from_str(s.as_str()).unwrap(), } } @@ -429,6 +431,7 @@ impl Network { Self::Holesky => H160::from_str(ALIGNED_SERVICE_MANAGER_HOLESKY).unwrap(), Self::HoleskyStage => H160::from_str(ALIGNED_SERVICE_MANAGER_HOLESKY_STAGE).unwrap(), Self::Mainnet => H160::from_str(ALIGNED_SERVICE_MANAGER_HOLESKY_MAINNET).unwrap(), + Self::Custom(_, s) => H160::from_str(s.as_str()).unwrap(), } } } @@ -442,10 +445,29 @@ impl FromStr for Network { "holesky-stage" => Ok(Network::HoleskyStage), "devnet" => Ok(Network::Devnet), "mainnet" => Ok(Network::Mainnet), - _ => Err( - "Invalid network, possible values are: \"holesky\", \"holesky-stage\", \"devnet\", \"mainnet\"" - .to_string(), - ), + s => { + if !s.contains("custom") { + return Err( + "Invalid network, possible values are: \"holesky\", \"holesky-stage\", \"devnet\", \"mainnet\", \"'custom '\"" + .to_string(), + ) + } + let parts: Vec<&str> = s.split_whitespace().collect(); + + if parts.len() == 3 { + Ok(Network::Custom( + parts[1].to_string(), + parts[2].to_string() + )) + } else { + Err( + "Invalid network, possible values are: \"holesky\", \"holesky-stage\", \"devnet\", \"mainnet\", \"'custom '\"" + .to_string() + ) + } + + + } } } } From 9b2d37b44d0c1cb1241015e5f508559203221984 Mon Sep 17 00:00:00 2001 From: PatStiles Date: Wed, 8 Jan 2025 14:18:49 -0300 Subject: [PATCH 51/74] fmt --- batcher/aligned-sdk/src/core/types.rs | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/batcher/aligned-sdk/src/core/types.rs b/batcher/aligned-sdk/src/core/types.rs index 20f80eec0c..93fe3d5475 100644 --- a/batcher/aligned-sdk/src/core/types.rs +++ b/batcher/aligned-sdk/src/core/types.rs @@ -409,7 +409,7 @@ pub enum Network { Holesky, HoleskyStage, Mainnet, - Custom(String, String) + Custom(String, String), } impl Network { @@ -450,23 +450,18 @@ impl FromStr for Network { return Err( "Invalid network, possible values are: \"holesky\", \"holesky-stage\", \"devnet\", \"mainnet\", \"'custom '\"" .to_string(), - ) + ); } let parts: Vec<&str> = s.split_whitespace().collect(); if parts.len() == 3 { - Ok(Network::Custom( - parts[1].to_string(), - parts[2].to_string() - )) + Ok(Network::Custom(parts[1].to_string(), parts[2].to_string())) } else { Err( "Invalid network, possible values are: \"holesky\", \"holesky-stage\", \"devnet\", \"mainnet\", \"'custom '\"" .to_string() ) } - - } } } From a320ab07e465e9727b950aa89935aca422bed278 Mon Sep 17 00:00:00 2001 From: PatStiles Date: Wed, 8 Jan 2025 14:50:34 -0300 Subject: [PATCH 52/74] change error messages --- batcher/aligned-sdk/src/core/types.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/batcher/aligned-sdk/src/core/types.rs b/batcher/aligned-sdk/src/core/types.rs index 93fe3d5475..9aa769e478 100644 --- a/batcher/aligned-sdk/src/core/types.rs +++ b/batcher/aligned-sdk/src/core/types.rs @@ -448,7 +448,7 @@ impl FromStr for Network { s => { if !s.contains("custom") { return Err( - "Invalid network, possible values are: \"holesky\", \"holesky-stage\", \"devnet\", \"mainnet\", \"'custom '\"" + "Invalid network, possible values are: \"holesky\", \"holesky-stage\", \"devnet\", \"mainnet\", \"custom \"" .to_string(), ); } @@ -458,7 +458,7 @@ impl FromStr for Network { Ok(Network::Custom(parts[1].to_string(), parts[2].to_string())) } else { Err( - "Invalid network, possible values are: \"holesky\", \"holesky-stage\", \"devnet\", \"mainnet\", \"'custom '\"" + "Invalid custom network, \"custom \"" .to_string() ) } From 587a5fad988ad2fd3cf114c67ee58a1cd412f466 Mon Sep 17 00:00:00 2001 From: PatStiles Date: Fri, 10 Jan 2025 11:32:39 -0300 Subject: [PATCH 53/74] enforce custom in right place + fix --- batcher/aligned-sdk/src/core/constants.rs | 4 ++-- batcher/aligned-sdk/src/core/types.rs | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/batcher/aligned-sdk/src/core/constants.rs b/batcher/aligned-sdk/src/core/constants.rs index e71e48bf44..6bc0858683 100644 --- a/batcher/aligned-sdk/src/core/constants.rs +++ b/batcher/aligned-sdk/src/core/constants.rs @@ -49,9 +49,9 @@ pub const BATCHER_PAYMENT_SERVICE_ADDRESS_HOLESKY_STAGE: &str = pub const BATCHER_PAYMENT_SERVICE_ADDRESS_MAINNET: &str = "0xb0567184A52cB40956df6333510d6eF35B89C8de"; /// AlignedServiceManager -pub const ALIGNED_SERVICE_MANAGER_DEVNET: &str = "0x1613beB3B2C4f22Ee086B2b38C1476A3cE7f78E8"; +pub const ALIGNED_SERVICE_MANAGER_DEVNET: &str = "0x851356ae760d987E095750cCeb3bC6014560891C"; pub const ALIGNED_SERVICE_MANAGER_HOLESKY: &str = "0x58F280BeBE9B34c9939C3C39e0890C81f163B623"; pub const ALIGNED_SERVICE_MANAGER_HOLESKY_STAGE: &str = "0x9C5231FC88059C086Ea95712d105A2026048c39B"; -pub const ALIGNED_SERVICE_MANAGER_HOLESKY_MAINNET: &str = +pub const ALIGNED_SERVICE_MANAGER_MAINNET: &str = "0xeF2A435e5EE44B2041100EF8cbC8ae035166606c"; diff --git a/batcher/aligned-sdk/src/core/types.rs b/batcher/aligned-sdk/src/core/types.rs index 9aa769e478..03b0db973a 100644 --- a/batcher/aligned-sdk/src/core/types.rs +++ b/batcher/aligned-sdk/src/core/types.rs @@ -21,7 +21,7 @@ use sha3::{Digest, Keccak256}; use super::constants::{ ALIGNED_SERVICE_MANAGER_DEVNET, ALIGNED_SERVICE_MANAGER_HOLESKY, - ALIGNED_SERVICE_MANAGER_HOLESKY_MAINNET, ALIGNED_SERVICE_MANAGER_HOLESKY_STAGE, + ALIGNED_SERVICE_MANAGER_MAINNET, ALIGNED_SERVICE_MANAGER_HOLESKY_STAGE, BATCHER_PAYMENT_SERVICE_ADDRESS_DEVNET, BATCHER_PAYMENT_SERVICE_ADDRESS_HOLESKY, BATCHER_PAYMENT_SERVICE_ADDRESS_HOLESKY_STAGE, BATCHER_PAYMENT_SERVICE_ADDRESS_MAINNET, }; @@ -430,7 +430,7 @@ impl Network { Self::Devnet => H160::from_str(ALIGNED_SERVICE_MANAGER_DEVNET).unwrap(), Self::Holesky => H160::from_str(ALIGNED_SERVICE_MANAGER_HOLESKY).unwrap(), Self::HoleskyStage => H160::from_str(ALIGNED_SERVICE_MANAGER_HOLESKY_STAGE).unwrap(), - Self::Mainnet => H160::from_str(ALIGNED_SERVICE_MANAGER_HOLESKY_MAINNET).unwrap(), + Self::Mainnet => H160::from_str(ALIGNED_SERVICE_MANAGER_MAINNET).unwrap(), Self::Custom(_, s) => H160::from_str(s.as_str()).unwrap(), } } @@ -454,7 +454,7 @@ impl FromStr for Network { } let parts: Vec<&str> = s.split_whitespace().collect(); - if parts.len() == 3 { + if parts.len() == 3 && parts[0].contains("custom") { Ok(Network::Custom(parts[1].to_string(), parts[2].to_string())) } else { Err( From 1a4ef2914137bac57ee578090c67049957cea979 Mon Sep 17 00:00:00 2001 From: PatStiles Date: Thu, 9 Jan 2025 16:37:23 -0300 Subject: [PATCH 54/74] remove clap from cargo.toml --- batcher/aligned-sdk/Cargo.toml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/batcher/aligned-sdk/Cargo.toml b/batcher/aligned-sdk/Cargo.toml index 9b1bcedd0e..90b828ba3e 100644 --- a/batcher/aligned-sdk/Cargo.toml +++ b/batcher/aligned-sdk/Cargo.toml @@ -24,5 +24,4 @@ url = "2.5.0" hex = "0.4.3" ciborium = "=0.2.2" serde_repr = "0.1.19" -dialoguer = "0.11.0" -clap = { version = "4.5.4", features = ["derive"] } +dialoguer = "0.11.0" \ No newline at end of file From 0ac4db3b077c23b733aafafb16876b7d6c4770f5 Mon Sep 17 00:00:00 2001 From: PatStiles Date: Fri, 10 Jan 2025 15:02:18 -0300 Subject: [PATCH 55/74] deprecate batcher_url --- alerts/.env.devnet | 1 - alerts/.env.example | 1 - alerts/sender_with_alert.sh | 4 +- batcher/aligned-sdk/src/core/constants.rs | 5 +++ batcher/aligned-sdk/src/core/types.rs | 25 ++++++++--- batcher/aligned-sdk/src/sdk.rs | 21 +++------ batcher/aligned-task-sender/README.md | 2 - batcher/aligned-task-sender/src/commands.rs | 7 +-- batcher/aligned-task-sender/src/structs.rs | 44 ++++++------------- batcher/aligned/generate_proof_and_send.sh | 2 - .../send_infinite_sp1_tasks.sh | 2 - batcher/aligned/send_infinite_tasks.sh | 2 - batcher/aligned/src/main.rs | 20 +++------ 13 files changed, 51 insertions(+), 85 deletions(-) diff --git a/alerts/.env.devnet b/alerts/.env.devnet index cf967dba1f..55bfc07bab 100644 --- a/alerts/.env.devnet +++ b/alerts/.env.devnet @@ -24,7 +24,6 @@ # Variables for sender_with_alert.sh REPETITIONS=8 SENDER_ADDRESS=0x14dC79964da2C08b23698B3D3cc7Ca32193d9955 -BATCHER_URL=ws://localhost:8080 RPC_URL=http://localhost:8545 EXPLORER_URL=http://localhost:3000 NETWORK=devnet diff --git a/alerts/.env.example b/alerts/.env.example index 2c0fe8a843..d210912a5e 100644 --- a/alerts/.env.example +++ b/alerts/.env.example @@ -26,7 +26,6 @@ NETWORK= # Variables for sender_with_alert.sh REPETITIONS= SENDER_ADDRESS= -BATCHER_URL= RPC_URL= EXPLORER_URL= NETWORK= diff --git a/alerts/sender_with_alert.sh b/alerts/sender_with_alert.sh index 3b70d57d7c..124a675e73 100755 --- a/alerts/sender_with_alert.sh +++ b/alerts/sender_with_alert.sh @@ -4,7 +4,6 @@ # - REPETITIONS # - EXPLORER_URL # - SENDER_ADDRESS -# - BATCHER_URL # - RPC_URL # - EXPLORER_URL # - NETWORK @@ -76,7 +75,7 @@ do mkdir -p ./scripts/test_files/gnark_groth16_bn254_infinite_script/infinite_proofs ## Generate Proof - nonce=$(aligned get-user-nonce --batcher_url $BATCHER_URL --user_addr $SENDER_ADDRESS 2>&1 | awk '{print $9}') + nonce=$(aligned get-user-nonce --network $NETWORK --user_addr $SENDER_ADDRESS 2>&1 | awk '{print $9}') x=$((nonce + 1)) # So we don't have any issues with nonce = 0 echo "Generating proof $x != 0" go run ./scripts/test_files/gnark_groth16_bn254_infinite_script/cmd/main.go $x @@ -92,7 +91,6 @@ do --proof_generator_addr $SENDER_ADDRESS \ --private_key $PRIVATE_KEY \ --rpc_url $RPC_URL \ - --batcher_url $BATCHER_URL \ --network $NETWORK \ --max_fee 4000000000000000 \ 2>&1) diff --git a/batcher/aligned-sdk/src/core/constants.rs b/batcher/aligned-sdk/src/core/constants.rs index 6bc0858683..900800b837 100644 --- a/batcher/aligned-sdk/src/core/constants.rs +++ b/batcher/aligned-sdk/src/core/constants.rs @@ -55,3 +55,8 @@ pub const ALIGNED_SERVICE_MANAGER_HOLESKY_STAGE: &str = "0x9C5231FC88059C086Ea95712d105A2026048c39B"; pub const ALIGNED_SERVICE_MANAGER_MAINNET: &str = "0xeF2A435e5EE44B2041100EF8cbC8ae035166606c"; +/// 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"; \ No newline at end of file diff --git a/batcher/aligned-sdk/src/core/types.rs b/batcher/aligned-sdk/src/core/types.rs index 03b0db973a..b440415f6c 100644 --- a/batcher/aligned-sdk/src/core/types.rs +++ b/batcher/aligned-sdk/src/core/types.rs @@ -24,6 +24,7 @@ use super::constants::{ ALIGNED_SERVICE_MANAGER_MAINNET, ALIGNED_SERVICE_MANAGER_HOLESKY_STAGE, BATCHER_PAYMENT_SERVICE_ADDRESS_DEVNET, BATCHER_PAYMENT_SERVICE_ADDRESS_HOLESKY, BATCHER_PAYMENT_SERVICE_ADDRESS_HOLESKY_STAGE, BATCHER_PAYMENT_SERVICE_ADDRESS_MAINNET, + BATCHER_URL_DEVNET, BATCHER_URL_HOLESKY, BATCHER_URL_HOLESKY_STAGE, BATCHER_URL_MAINNET, }; use super::errors::VerifySignatureError; @@ -409,7 +410,7 @@ pub enum Network { Holesky, HoleskyStage, Mainnet, - Custom(String, String), + Custom(String, String, String), } impl Network { @@ -421,7 +422,7 @@ impl Network { H160::from_str(BATCHER_PAYMENT_SERVICE_ADDRESS_HOLESKY_STAGE).unwrap() } Self::Mainnet => H160::from_str(BATCHER_PAYMENT_SERVICE_ADDRESS_MAINNET).unwrap(), - Self::Custom(s, _) => H160::from_str(s.as_str()).unwrap(), + Self::Custom(s, _, _) => H160::from_str(s.as_str()).unwrap(), } } @@ -431,7 +432,17 @@ impl Network { Self::Holesky => H160::from_str(ALIGNED_SERVICE_MANAGER_HOLESKY).unwrap(), Self::HoleskyStage => H160::from_str(ALIGNED_SERVICE_MANAGER_HOLESKY_STAGE).unwrap(), Self::Mainnet => H160::from_str(ALIGNED_SERVICE_MANAGER_MAINNET).unwrap(), - Self::Custom(_, s) => H160::from_str(s.as_str()).unwrap(), + Self::Custom(_, s, _) => H160::from_str(s.as_str()).unwrap(), + } + } + + 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, + Self::Mainnet => BATCHER_URL_MAINNET, + Self::Custom(_, _, s) => s.as_str(), } } } @@ -448,17 +459,17 @@ impl FromStr for Network { s => { if !s.contains("custom") { return Err( - "Invalid network, possible values are: \"holesky\", \"holesky-stage\", \"devnet\", \"mainnet\", \"custom \"" + "Invalid network, possible values are: \"holesky\", \"holesky-stage\", \"devnet\", \"mainnet\", \"custom \"" .to_string(), ); } let parts: Vec<&str> = s.split_whitespace().collect(); - if parts.len() == 3 && parts[0].contains("custom") { - Ok(Network::Custom(parts[1].to_string(), parts[2].to_string())) + if parts.len() == 4 && parts[0].contains("custom") { + Ok(Network::Custom(parts[1].to_string(), parts[2].to_string(), parts[3].to_string())) } else { Err( - "Invalid custom network, \"custom \"" + "Invalid custom network, \"custom \"" .to_string() ) } diff --git a/batcher/aligned-sdk/src/sdk.rs b/batcher/aligned-sdk/src/sdk.rs index 2e698ad99f..13de4b62dd 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], @@ -88,8 +86,7 @@ pub async fn submit_multiple_and_wait_verification( nonce: U256, ) -> Vec> { let mut aligned_verification_data = submit_multiple( - batcher_url, - network.clone(), + network, verification_data, max_fee, wallet, @@ -219,7 +216,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. @@ -243,14 +239,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))], }; @@ -333,7 +328,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. @@ -363,7 +357,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, @@ -374,7 +367,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, @@ -395,7 +387,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. @@ -419,7 +410,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, @@ -429,7 +419,6 @@ pub async fn submit( let verification_data = vec![verification_data.clone()]; let aligned_verification_data = submit_multiple( - batcher_url, network, &verification_data, max_fee, @@ -537,17 +526,17 @@ 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, + network: Network, address: Address, ) -> Result { - let (ws_stream, _) = connect_async(batcher_ws_url).await.map_err(|_| { + let (ws_stream, _) = connect_async(network.get_batcher_url()).await.map_err(|_| { GetNonceError::ConnectionFailed("Ws connection to batcher failed".to_string()) })?; diff --git a/batcher/aligned-task-sender/README.md b/batcher/aligned-task-sender/README.md index 73b1df8686..fdf49195df 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/batcher/aligned-task-sender/src/commands.rs b/batcher/aligned-task-sender/src/commands.rs index f074b91563..233e5cb79d 100644 --- a/batcher/aligned-task-sender/src/commands.rs +++ b/batcher/aligned-task-sender/src/commands.rs @@ -211,15 +211,11 @@ 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 ws_url = args.network.get_batcher_url().clone(); let handle = tokio::spawn(async move { let conn = connect_async(ws_url).await; if let Ok((mut ws_stream, _)) = conn { @@ -349,7 +345,6 @@ pub async fn send_infinite_proofs(args: SendInfiniteProofsArgs) { let batcher_url = batcher_url.clone(); let aligned_verification_data = submit_multiple( - &batcher_url.clone(), args.network.into(), &verification_data_to_send.clone(), max_fee, diff --git a/batcher/aligned-task-sender/src/structs.rs b/batcher/aligned-task-sender/src/structs.rs index 7c5d36f6bb..d2ea2b4ec2 100644 --- a/batcher/aligned-task-sender/src/structs.rs +++ b/batcher/aligned-task-sender/src/structs.rs @@ -78,22 +78,24 @@ pub struct GenerateAndFundWalletsArgs { )] pub private_keys_filepath: String, #[arg( - name = "The Ethereum network's name", + name = "The working network's name", long = "network", - default_value = "devnet" + default_value = "devnet", + value_parser = value_parser!(Network) )] - pub network: NetworkArg, + pub network: Network, } #[derive(Parser, Debug)] #[command(version, about, long_about = None)] pub struct TestConnectionsArgs { #[arg( - name = "Batcher connection address", - long = "batcher-url", - default_value = "ws://localhost:8080" + name = "The working network's name", + long = "network", + default_value = "devnet", + value_parser = value_parser!(Network) )] - pub batcher_url: String, + pub network: Network, #[arg( name = "Number of spawned sockets", long = "num-senders", @@ -132,11 +134,12 @@ pub struct SendInfiniteProofsArgs { #[arg(name = "Max Fee", long = "max-fee", default_value = "1300000000000000")] pub max_fee: String, #[arg( - name = "The Ethereum network's name", + name = "The working network's name", long = "network", - default_value = "devnet" + default_value = "devnet", + value_parser = value_parser!(Network) )] - pub network: NetworkArg, + pub network: Network, #[arg( name = "Private keys filepath for the senders", long = "private-keys-filepath" @@ -148,23 +151,4 @@ pub struct SendInfiniteProofsArgs { default_value = "devnet" )] pub proofs_dir: String, -} - -#[derive(Debug, Clone, Copy, ValueEnum)] -pub enum NetworkArg { - Devnet, - Holesky, - HoleskyStage, - Mainnet, -} - -impl From for Network { - fn from(chain_arg: NetworkArg) -> Self { - match chain_arg { - NetworkArg::Devnet => Network::Devnet, - NetworkArg::Holesky => Network::Holesky, - NetworkArg::HoleskyStage => Network::HoleskyStage, - NetworkArg::Mainnet => Network::Mainnet, - } - } -} +} \ No newline at end of file diff --git a/batcher/aligned/generate_proof_and_send.sh b/batcher/aligned/generate_proof_and_send.sh index bcfa684544..42d01b8fbd 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 079a8dcc57..620a465719 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 @@ -13,7 +13,6 @@ else fi 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" @@ -33,7 +32,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 d79ff8ab3b..90e24a4013 100755 --- a/batcher/aligned/send_infinite_tasks.sh +++ b/batcher/aligned/send_infinite_tasks.sh @@ -14,7 +14,6 @@ fi # 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" @@ -35,7 +34,6 @@ do --proof_generator_addr 0x66f9664f97F2b50F62D13eA064982f936dE76657 \ --repetitions "2" \ --rpc_url "$RPC" \ - --batcher_url "$BATCHER_CONN" \ --network "$NETWORK" cd ../.. diff --git a/batcher/aligned/src/main.rs b/batcher/aligned/src/main.rs index 9601238a68..bed698fb15 100644 --- a/batcher/aligned/src/main.rs +++ b/batcher/aligned/src/main.rs @@ -64,12 +64,6 @@ pub enum AlignedCommands { #[derive(Parser, Debug)] #[command(version, about, long_about = None)] pub struct SubmitArgs { - #[arg( - name = "Batcher connection address", - long = "batcher_url", - default_value = "ws://localhost:8080" - )] - batcher_url: String, #[arg( name = "Ethereum RPC provider connection address", long = "rpc_url", @@ -210,11 +204,12 @@ pub struct GetUserBalanceArgs { #[command(version, about, long_about = None)] pub struct GetUserNonceArgs { #[arg( - name = "Batcher connection address", - long = "batcher_url", - default_value = "ws://localhost:8080" + name = "The working network's name", + long = "network", + default_value = "devnet", + value_parser = value_parser!(Network) )] - batcher_url: String, + network: Network, #[arg( name = "The user's Ethereum address", long = "user_addr", @@ -317,7 +312,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(&submit_args.network, wallet.address()) .await .map_err(|e| match e { aligned_sdk::core::errors::GetNonceError::EthRpcError(e) => { @@ -351,7 +346,6 @@ async fn main() -> Result<(), AlignedError> { info!("Submitting proofs to the Aligned batcher..."); let aligned_verification_data_vec = submit_multiple( - &connect_addr, submit_args.network, &verification_data_arr, max_fee_wei, @@ -512,7 +506,7 @@ 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 { + match get_nonce_from_batcher(&args.network, address).await { Ok(nonce) => { info!("Nonce for address {} is {}", address, nonce); } From c765ecff00bc391d1dea7288abcc67d91772fa35 Mon Sep 17 00:00:00 2001 From: PatStiles Date: Fri, 10 Jan 2025 15:02:31 -0300 Subject: [PATCH 56/74] deprecate more --- batcher/Cargo.lock | 1 - batcher/aligned-sdk/src/sdk.rs | 2 +- batcher/aligned-task-sender/src/commands.rs | 6 +++--- batcher/aligned-task-sender/src/structs.rs | 1 + batcher/aligned/src/main.rs | 7 +++---- 5 files changed, 8 insertions(+), 9 deletions(-) diff --git a/batcher/Cargo.lock b/batcher/Cargo.lock index 8183b16738..f04cb8c63c 100644 --- a/batcher/Cargo.lock +++ b/batcher/Cargo.lock @@ -130,7 +130,6 @@ name = "aligned-sdk" version = "0.1.0" dependencies = [ "ciborium", - "clap", "dialoguer", "ethers", "futures-util", diff --git a/batcher/aligned-sdk/src/sdk.rs b/batcher/aligned-sdk/src/sdk.rs index 13de4b62dd..7bdd13458c 100644 --- a/batcher/aligned-sdk/src/sdk.rs +++ b/batcher/aligned-sdk/src/sdk.rs @@ -86,7 +86,7 @@ pub async fn submit_multiple_and_wait_verification( nonce: U256, ) -> Vec> { let mut aligned_verification_data = submit_multiple( - network, + network.clone(), verification_data, max_fee, wallet, diff --git a/batcher/aligned-task-sender/src/commands.rs b/batcher/aligned-task-sender/src/commands.rs index 233e5cb79d..395b57dfa4 100644 --- a/batcher/aligned-task-sender/src/commands.rs +++ b/batcher/aligned-task-sender/src/commands.rs @@ -2,7 +2,6 @@ use aligned_sdk::core::types::{Network, ProvingSystemId, VerificationData}; use aligned_sdk::sdk::{deposit_to_aligned, get_nonce_from_batcher, submit_multiple}; use ethers::prelude::*; use ethers::utils::parse_ether; -use futures_util::StreamExt; use k256::ecdsa::SigningKey; use log::{debug, error, info}; use rand::seq::SliceRandom; @@ -189,7 +188,7 @@ pub async fn generate_and_fund_wallets(args: GenerateAndFundWalletsArgs) { ); let signer = SignerMiddleware::new(eth_rpc_provider.clone(), wallet.clone()); if let Err(err) = - deposit_to_aligned(amount_to_deposit_to_aligned, signer, args.network.into()).await + deposit_to_aligned(amount_to_deposit_to_aligned, signer, args.network.clone()).await { error!("Could not deposit to aligned, err: {:?}", err); return; @@ -213,9 +212,10 @@ pub async fn generate_and_fund_wallets(args: GenerateAndFundWalletsArgs) { pub async fn test_connection(args: TestConnectionsArgs) { info!("Going to only open a connection"); let mut handlers = vec![]; + let network = network.clone(); for i in 0..args.num_senders { - let ws_url = args.network.get_batcher_url().clone(); + let ws_url = network.get_batcher_url().clone(); let handle = tokio::spawn(async move { let conn = connect_async(ws_url).await; if let Ok((mut ws_stream, _)) = conn { diff --git a/batcher/aligned-task-sender/src/structs.rs b/batcher/aligned-task-sender/src/structs.rs index d2ea2b4ec2..3456047a4e 100644 --- a/batcher/aligned-task-sender/src/structs.rs +++ b/batcher/aligned-task-sender/src/structs.rs @@ -1,4 +1,5 @@ use aligned_sdk::core::types::Network; +use clap::value_parser; use clap::Parser; use clap::Subcommand; use clap::ValueEnum; diff --git a/batcher/aligned/src/main.rs b/batcher/aligned/src/main.rs index bed698fb15..9ae9919418 100644 --- a/batcher/aligned/src/main.rs +++ b/batcher/aligned/src/main.rs @@ -272,7 +272,6 @@ async fn main() -> Result<(), AlignedError> { })?; let repetitions = submit_args.repetitions; - let connect_addr = submit_args.batcher_url.clone(); let keystore_path = &submit_args.keystore_path; let private_key = &submit_args.private_key; @@ -312,7 +311,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(&submit_args.network, wallet.address()) + None => get_nonce_from_batcher(submit_args.network, wallet.address()) .await .map_err(|e| match e { aligned_sdk::core::errors::GetNonceError::EthRpcError(e) => { @@ -346,7 +345,7 @@ async fn main() -> Result<(), AlignedError> { info!("Submitting proofs to the Aligned batcher..."); let aligned_verification_data_vec = submit_multiple( - submit_args.network, + submit_args.network.clone(), &verification_data_arr, max_fee_wei, wallet.clone(), @@ -506,7 +505,7 @@ async fn main() -> Result<(), AlignedError> { } GetUserNonce(args) => { let address = H160::from_str(&args.address).unwrap(); - match get_nonce_from_batcher(&args.network, address).await { + match get_nonce_from_batcher(args.network, address).await { Ok(nonce) => { info!("Nonce for address {} is {}", address, nonce); } From 2f6da7c711ae198f1dbf92818edccf5d9c7e477d Mon Sep 17 00:00:00 2001 From: Urix <43704209+uri-99@users.noreply.github.com> Date: Wed, 15 Jan 2025 18:38:17 -0300 Subject: [PATCH 57/74] feat: better implementation of this pr --- batcher/aligned-sdk/src/core/types.rs | 50 ++------- batcher/aligned/src/main.rs | 141 ++++++++++++++++++-------- docs/3_guides/9_aligned_cli.md | 55 +++++++--- 3 files changed, 148 insertions(+), 98 deletions(-) diff --git a/batcher/aligned-sdk/src/core/types.rs b/batcher/aligned-sdk/src/core/types.rs index b440415f6c..596cd9bc13 100644 --- a/batcher/aligned-sdk/src/core/types.rs +++ b/batcher/aligned-sdk/src/core/types.rs @@ -414,6 +414,16 @@ pub enum Network { } impl Network { + pub fn get_aligned_service_manager_address(&self) -> ethers::types::H160 { + match self { + Self::Devnet => H160::from_str(ALIGNED_SERVICE_MANAGER_DEVNET).unwrap(), + Self::Holesky => H160::from_str(ALIGNED_SERVICE_MANAGER_HOLESKY).unwrap(), + Self::HoleskyStage => H160::from_str(ALIGNED_SERVICE_MANAGER_HOLESKY_STAGE).unwrap(), + Self::Mainnet => H160::from_str(ALIGNED_SERVICE_MANAGER_MAINNET).unwrap(), + Self::Custom(s, _, _) => H160::from_str(s.as_str()).unwrap(), + } + } + pub fn get_batcher_payment_service_address(&self) -> ethers::types::H160 { match self { Self::Devnet => H160::from_str(BATCHER_PAYMENT_SERVICE_ADDRESS_DEVNET).unwrap(), @@ -422,16 +432,6 @@ impl Network { H160::from_str(BATCHER_PAYMENT_SERVICE_ADDRESS_HOLESKY_STAGE).unwrap() } Self::Mainnet => H160::from_str(BATCHER_PAYMENT_SERVICE_ADDRESS_MAINNET).unwrap(), - Self::Custom(s, _, _) => H160::from_str(s.as_str()).unwrap(), - } - } - - pub fn get_aligned_service_manager_address(&self) -> ethers::types::H160 { - match self { - Self::Devnet => H160::from_str(ALIGNED_SERVICE_MANAGER_DEVNET).unwrap(), - Self::Holesky => H160::from_str(ALIGNED_SERVICE_MANAGER_HOLESKY).unwrap(), - Self::HoleskyStage => H160::from_str(ALIGNED_SERVICE_MANAGER_HOLESKY_STAGE).unwrap(), - Self::Mainnet => H160::from_str(ALIGNED_SERVICE_MANAGER_MAINNET).unwrap(), Self::Custom(_, s, _) => H160::from_str(s.as_str()).unwrap(), } } @@ -447,36 +447,6 @@ impl Network { } } -impl FromStr for Network { - type Err = String; - - fn from_str(s: &str) -> Result { - match s.to_lowercase().as_str() { - "holesky" => Ok(Network::Holesky), - "holesky-stage" => Ok(Network::HoleskyStage), - "devnet" => Ok(Network::Devnet), - "mainnet" => Ok(Network::Mainnet), - s => { - if !s.contains("custom") { - return Err( - "Invalid network, possible values are: \"holesky\", \"holesky-stage\", \"devnet\", \"mainnet\", \"custom \"" - .to_string(), - ); - } - let parts: Vec<&str> = s.split_whitespace().collect(); - - if parts.len() == 4 && parts[0].contains("custom") { - Ok(Network::Custom(parts[1].to_string(), parts[2].to_string(), parts[3].to_string())) - } else { - Err( - "Invalid custom network, \"custom \"" - .to_string() - ) - } - } - } - } -} #[cfg(test)] mod tests { diff --git a/batcher/aligned/src/main.rs b/batcher/aligned/src/main.rs index 9ae9919418..748c33888e 100644 --- a/batcher/aligned/src/main.rs +++ b/batcher/aligned/src/main.rs @@ -14,7 +14,6 @@ use aligned_sdk::sdk::get_chain_id; use aligned_sdk::sdk::get_nonce_from_batcher; use aligned_sdk::sdk::{deposit_to_aligned, get_balance_in_aligned}; use aligned_sdk::sdk::{get_vk_commitment, is_proof_verified, save_response, submit_multiple}; -use clap::value_parser; use clap::Parser; use clap::Subcommand; use clap::ValueEnum; @@ -110,13 +109,8 @@ pub struct SubmitArgs { max_fee: String, // String because U256 expects hex #[arg(name = "Nonce", long = "nonce")] nonce: Option, // String because U256 expects hex - #[arg( - name = "The working network's name", - long = "network", - default_value = "devnet", - value_parser = value_parser!(Network) - )] - network: Network, + #[clap(flatten)] + network: NetworkArg, } #[derive(Parser, Debug)] @@ -134,13 +128,9 @@ pub struct DepositToBatcherArgs { default_value = "http://localhost:8545" )] eth_rpc_url: String, - #[arg( - name = "The working network's name", - long = "network", - default_value = "devnet", - value_parser = value_parser!(Network) - )] - network: Network, + + #[clap(flatten)] + network: NetworkArg, #[arg(name = "Amount to deposit", long = "amount", required = true)] amount: String, } @@ -156,13 +146,9 @@ pub struct VerifyProofOnchainArgs { default_value = "http://localhost:8545" )] eth_rpc_url: String, - #[arg( - name = "The working network's name", - long = "network", - default_value = "devnet", - value_parser = value_parser!(Network) - )] - network: Network, + + #[clap(flatten)] + network: NetworkArg, } #[derive(Parser, Debug)] @@ -179,13 +165,8 @@ pub struct GetVkCommitmentArgs { #[derive(Parser, Debug)] #[command(version, about, long_about = None)] pub struct GetUserBalanceArgs { - #[arg( - name = "The working network's name", - long = "network", - default_value = "devnet", - value_parser = value_parser!(Network) - )] - network: Network, + #[clap(flatten)] + network: NetworkArg, #[arg( name = "Ethereum RPC provider address", long = "rpc_url", @@ -203,13 +184,8 @@ pub struct GetUserBalanceArgs { #[derive(Parser, Debug)] #[command(version, about, long_about = None)] pub struct GetUserNonceArgs { - #[arg( - name = "The working network's name", - long = "network", - default_value = "devnet", - value_parser = value_parser!(Network) - )] - network: Network, + #[clap(flatten)] + network: NetworkArg, #[arg( name = "The user's Ethereum address", long = "user_addr", @@ -246,6 +222,87 @@ impl From for ProvingSystemId { } } +#[derive(Debug, Clone, Copy)] +enum NetworkNameArg { + Devnet, + Holesky, + HoleskyStage, + Mainnet, +} + +impl FromStr for NetworkNameArg { + type Err = String; + + fn from_str(s: &str) -> Result { + match s { + "devnet" => Ok(NetworkNameArg::Devnet), + "holesky" => Ok(NetworkNameArg::Holesky), + "holesky-stage" => Ok(NetworkNameArg::HoleskyStage), + "mainnet" => Ok(NetworkNameArg::Mainnet), + _ => Err("Unknown network. Possible values: devnet, holesky, holesky-stage, mainnet".to_string()), + } + } +} + +#[derive(Debug, clap::Args, Clone)] +struct NetworkArg { + #[arg( + name = "The working network's name", + long = "network", + default_value = "devnet", + help = "[possible values: devnet, holesky, holesky-stage, mainnet]" + )] + network: Option, + #[arg( + name = "Aligned Service Manager Contract Address", + long = "aligned_service_manager", + conflicts_with("The working network's name"), + requires("Batcher Payment Service Contract Address"), + requires("Batcher URL"), + )] + aligned_service_manager_address: Option, + + #[arg( + name = "Batcher Payment Service Contract Address", + long = "batcher_payment_service", + conflicts_with("The working network's name"), + requires("Aligned Service Manager Contract Address"), + requires("Batcher URL"), + )] + batcher_payment_service_address: Option, + + #[arg( + name = "Batcher URL", + long = "batcher_url", + conflicts_with("The working network's name"), + requires("Aligned Service Manager Contract Address"), + requires("Batcher Payment Service Contract Address"), + )] + batcher_url: Option, +} + +impl From for Network { + fn from(network_arg: NetworkArg) -> Self { + let mut processed_network_argument = network_arg.clone(); + + if network_arg.batcher_url.is_some() || network_arg.aligned_service_manager_address.is_some() || network_arg.batcher_payment_service_address.is_some() { + processed_network_argument.network = None; // We need this because network is Devnet as default, which is not true for a Custom network + } + + match processed_network_argument.network { + None => Network::Custom( + network_arg.aligned_service_manager_address.unwrap(), + network_arg.batcher_payment_service_address.unwrap(), + network_arg.batcher_url.unwrap(), + ), + Some(NetworkNameArg::Devnet) => Network::Devnet, + Some(NetworkNameArg::Holesky) => Network::Holesky, + Some(NetworkNameArg::HoleskyStage) => Network::HoleskyStage, + Some(NetworkNameArg::Mainnet) => Network::Mainnet, + } + } +} + #[tokio::main] async fn main() -> Result<(), AlignedError> { env_logger::Builder::from_env(Env::default().default_filter_or("info")).init(); @@ -311,7 +368,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(submit_args.network, wallet.address()) + None => get_nonce_from_batcher(submit_args.network.clone().into(), wallet.address()) .await .map_err(|e| match e { aligned_sdk::core::errors::GetNonceError::EthRpcError(e) => { @@ -345,7 +402,7 @@ async fn main() -> Result<(), AlignedError> { info!("Submitting proofs to the Aligned batcher..."); let aligned_verification_data_vec = submit_multiple( - submit_args.network.clone(), + submit_args.network.into(), &verification_data_arr, max_fee_wei, wallet.clone(), @@ -404,7 +461,7 @@ async fn main() -> Result<(), AlignedError> { info!("Verifying response data matches sent proof data..."); let response = is_proof_verified( &aligned_verification_data, - verify_inclusion_args.network, + verify_inclusion_args.network.into(), &verify_inclusion_args.eth_rpc_url, ) .await?; @@ -469,7 +526,7 @@ async fn main() -> Result<(), AlignedError> { let client = SignerMiddleware::new(eth_rpc_provider.clone(), wallet.clone()); - match deposit_to_aligned(amount_wei, client, deposit_to_batcher_args.network).await { + match deposit_to_aligned(amount_wei, client, deposit_to_batcher_args.network.into()).await { Ok(receipt) => { info!( "Payment sent to the batcher successfully. Tx: 0x{:x}", @@ -486,7 +543,7 @@ async fn main() -> Result<(), AlignedError> { match get_balance_in_aligned( user_address, &get_user_balance_args.eth_rpc_url, - get_user_balance_args.network, + get_user_balance_args.network.into(), ) .await { @@ -505,7 +562,7 @@ async fn main() -> Result<(), AlignedError> { } GetUserNonce(args) => { let address = H160::from_str(&args.address).unwrap(); - match get_nonce_from_batcher(args.network, address).await { + match get_nonce_from_batcher(args.network.into(), address).await { Ok(nonce) => { info!("Nonce for address {} is {}", address, nonce); } diff --git a/docs/3_guides/9_aligned_cli.md b/docs/3_guides/9_aligned_cli.md index fb4cbaa436..d4f1003087 100644 --- a/docs/3_guides/9_aligned_cli.md +++ b/docs/3_guides/9_aligned_cli.md @@ -71,9 +71,15 @@ Submit a proof to the Aligned Layer batcher. - Default: `0.0013ether` - `--nonce `: Proof nonce. - By default, the nonce is set automatically. By setting the nonce manually, you can perform a proof replacement. -- `--network `: Network name to interact with. - - Default: `devnet` - - Possible values: `devnet`, `holesky`, `mainnet` +- One of the following, to specify which Network to interact with: + - `--network `: Network name to interact with. + - Default: `devnet` + - Possible values: `devnet`, `holesky`, `mainnet` + - For a custom Network, you must specify the following parameters: + - `--aligned_service_manager ` + - `--batcher_payment_service ` + - `--batcher_url ` + #### Example: ```bash @@ -108,9 +114,14 @@ Check if a proof was verified by Aligned on Ethereum. - Mainnet: `https://ethereum-rpc.publicnode.com` - Holesky: `https://ethereum-holesky-rpc.publicnode.com` - Also, you can use your own Ethereum RPC providers. -- `--network `: Network name to interact with. - - Default: `devnet` - - Possible values: `devnet`, `holesky`, `mainnet` +- One of the following, to specify which Network to interact with: + - `--network `: Network name to interact with. + - Default: `devnet` + - Possible values: `devnet`, `holesky`, `mainnet` + - For a custom Network, you must specify the following parameters: + - `--aligned_service_manager ` + - `--batcher_payment_service ` + - `--batcher_url ` #### Example: ```bash @@ -157,10 +168,15 @@ Deposits Ethereum into the Aligned Layer's `BatcherPaymentService.sol` contract. - Mainnet: `https://ethereum-rpc.publicnode.com` - Holesky: `https://ethereum-holesky-rpc.publicnode.com` - Also, you can use your own Ethereum RPC providers. -- `--network `: Network name to interact with. - - Default: `devnet` - - Possible values: `devnet`, `holesky`, `mainnet` - `--amount `: Amount of Ether to deposit. +- One of the following, to specify which Network to interact with: + - `--network `: Network name to interact with. + - Default: `devnet` + - Possible values: `devnet`, `holesky`, `mainnet` + - For a custom Network, you must specify the following parameters: + - `--aligned_service_manager ` + - `--batcher_payment_service ` + - `--batcher_url ` #### Example: ```bash @@ -185,9 +201,14 @@ Retrieves the user's balance in the Aligned Layer's contract. #### Options: -- `--network `: Network name to interact with. - - Default: `devnet` - - Possible values: `devnet`, `holesky`, `mainnet` +- One of the following, to specify which Network to interact with: + - `--network `: Network name to interact with. + - Default: `devnet` + - Possible values: `devnet`, `holesky`, `mainnet` + - For a custom Network, you must specify the following parameters: + - `--aligned_service_manager ` + - `--batcher_payment_service ` + - `--batcher_url ` - `--rpc_url `: User's Ethereum RPC provider connection address. - Default: `http://localhost:8545` - Mainnet: `https://ethereum-rpc.publicnode.com` @@ -217,11 +238,13 @@ Retrieves the user's current nonce from the batcher. `get-user-nonce [OPTIONS] --user_addr ` #### Options: -- **`--batcher_url`**: Websocket URL for the Aligned Layer batcher. - - Default: `ws://localhost:8080` - - Mainnet: `wss://mainnet.batcher.alignedlayer.com` - - Holesky: `wss://batcher.alignedlayer.com` - `--user_addr `: User's Ethereum address. +- One of the following, to specify which Network to interact with: + - `--network `: Network name to interact with. + - Default: `devnet` + - Possible values: `devnet`, `holesky`, `mainnet` + - For a custom Network, you must specify the following parameter: + - `--batcher_url ` #### Example: ```bash From ec9685ddd402e7a4538b14d5c8c5c76e9040dea1 Mon Sep 17 00:00:00 2001 From: Urix <43704209+uri-99@users.noreply.github.com> Date: Thu, 16 Jan 2025 14:45:49 -0300 Subject: [PATCH 58/74] chore: cargo fmt --- batcher/aligned-sdk/src/core/constants.rs | 5 +- batcher/aligned-sdk/src/core/types.rs | 5 +- batcher/aligned-sdk/src/sdk.rs | 28 +++------ batcher/aligned-task-sender/src/structs.rs | 2 +- batcher/aligned/src/main.rs | 72 ++++++++++++---------- 5 files changed, 55 insertions(+), 57 deletions(-) diff --git a/batcher/aligned-sdk/src/core/constants.rs b/batcher/aligned-sdk/src/core/constants.rs index 900800b837..7554d9624a 100644 --- a/batcher/aligned-sdk/src/core/constants.rs +++ b/batcher/aligned-sdk/src/core/constants.rs @@ -53,10 +53,9 @@ pub const ALIGNED_SERVICE_MANAGER_DEVNET: &str = "0x851356ae760d987E095750cCeb3b pub const ALIGNED_SERVICE_MANAGER_HOLESKY: &str = "0x58F280BeBE9B34c9939C3C39e0890C81f163B623"; pub const ALIGNED_SERVICE_MANAGER_HOLESKY_STAGE: &str = "0x9C5231FC88059C086Ea95712d105A2026048c39B"; -pub const ALIGNED_SERVICE_MANAGER_MAINNET: &str = - "0xeF2A435e5EE44B2041100EF8cbC8ae035166606c"; +pub const ALIGNED_SERVICE_MANAGER_MAINNET: &str = "0xeF2A435e5EE44B2041100EF8cbC8ae035166606c"; /// 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"; \ No newline at end of file +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 596cd9bc13..2acf6a6810 100644 --- a/batcher/aligned-sdk/src/core/types.rs +++ b/batcher/aligned-sdk/src/core/types.rs @@ -21,7 +21,7 @@ use sha3::{Digest, Keccak256}; use super::constants::{ ALIGNED_SERVICE_MANAGER_DEVNET, ALIGNED_SERVICE_MANAGER_HOLESKY, - ALIGNED_SERVICE_MANAGER_MAINNET, ALIGNED_SERVICE_MANAGER_HOLESKY_STAGE, + ALIGNED_SERVICE_MANAGER_HOLESKY_STAGE, ALIGNED_SERVICE_MANAGER_MAINNET, BATCHER_PAYMENT_SERVICE_ADDRESS_DEVNET, BATCHER_PAYMENT_SERVICE_ADDRESS_HOLESKY, BATCHER_PAYMENT_SERVICE_ADDRESS_HOLESKY_STAGE, BATCHER_PAYMENT_SERVICE_ADDRESS_MAINNET, BATCHER_URL_DEVNET, BATCHER_URL_HOLESKY, BATCHER_URL_HOLESKY_STAGE, BATCHER_URL_MAINNET, @@ -423,7 +423,7 @@ impl Network { Self::Custom(s, _, _) => H160::from_str(s.as_str()).unwrap(), } } - + pub fn get_batcher_payment_service_address(&self) -> ethers::types::H160 { match self { Self::Devnet => H160::from_str(BATCHER_PAYMENT_SERVICE_ADDRESS_DEVNET).unwrap(), @@ -447,7 +447,6 @@ impl Network { } } - #[cfg(test)] mod tests { use ethers::signers::LocalWallet; diff --git a/batcher/aligned-sdk/src/sdk.rs b/batcher/aligned-sdk/src/sdk.rs index 7bdd13458c..910ad4ac07 100644 --- a/batcher/aligned-sdk/src/sdk.rs +++ b/batcher/aligned-sdk/src/sdk.rs @@ -85,14 +85,8 @@ pub async fn submit_multiple_and_wait_verification( wallet: Wallet, nonce: U256, ) -> Vec> { - let mut aligned_verification_data = submit_multiple( - network.clone(), - verification_data, - max_fee, - wallet, - nonce, - ) - .await; + let mut aligned_verification_data = + submit_multiple(network.clone(), 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. @@ -418,14 +412,8 @@ pub async fn submit( ) -> Result { let verification_data = vec![verification_data.clone()]; - let aligned_verification_data = submit_multiple( - 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()), @@ -536,9 +524,11 @@ pub async fn get_nonce_from_batcher( network: Network, address: Address, ) -> Result { - let (ws_stream, _) = connect_async(network.get_batcher_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-task-sender/src/structs.rs b/batcher/aligned-task-sender/src/structs.rs index 3456047a4e..c42b293683 100644 --- a/batcher/aligned-task-sender/src/structs.rs +++ b/batcher/aligned-task-sender/src/structs.rs @@ -152,4 +152,4 @@ pub struct SendInfiniteProofsArgs { default_value = "devnet" )] pub proofs_dir: String, -} \ No newline at end of file +} diff --git a/batcher/aligned/src/main.rs b/batcher/aligned/src/main.rs index 4da2d544b0..b058ade14d 100644 --- a/batcher/aligned/src/main.rs +++ b/batcher/aligned/src/main.rs @@ -235,14 +235,17 @@ enum NetworkNameArg { impl FromStr for NetworkNameArg { type Err = String; - + fn from_str(s: &str) -> Result { match s { "devnet" => Ok(NetworkNameArg::Devnet), "holesky" => Ok(NetworkNameArg::Holesky), "holesky-stage" => Ok(NetworkNameArg::HoleskyStage), "mainnet" => Ok(NetworkNameArg::Mainnet), - _ => Err("Unknown network. Possible values: devnet, holesky, holesky-stage, mainnet".to_string()), + _ => Err( + "Unknown network. Possible values: devnet, holesky, holesky-stage, mainnet" + .to_string(), + ), } } } @@ -261,7 +264,7 @@ struct NetworkArg { long = "aligned_service_manager", conflicts_with("The working network's name"), requires("Batcher Payment Service Contract Address"), - requires("Batcher URL"), + requires("Batcher URL") )] aligned_service_manager_address: Option, @@ -270,7 +273,7 @@ struct NetworkArg { long = "batcher_payment_service", conflicts_with("The working network's name"), requires("Aligned Service Manager Contract Address"), - requires("Batcher URL"), + requires("Batcher URL") )] batcher_payment_service_address: Option, @@ -279,7 +282,7 @@ struct NetworkArg { long = "batcher_url", conflicts_with("The working network's name"), requires("Aligned Service Manager Contract Address"), - requires("Batcher Payment Service Contract Address"), + requires("Batcher Payment Service Contract Address") )] batcher_url: Option, } @@ -288,7 +291,10 @@ impl From for Network { fn from(network_arg: NetworkArg) -> Self { let mut processed_network_argument = network_arg.clone(); - if network_arg.batcher_url.is_some() || network_arg.aligned_service_manager_address.is_some() || network_arg.batcher_payment_service_address.is_some() { + if network_arg.batcher_url.is_some() + || network_arg.aligned_service_manager_address.is_some() + || network_arg.batcher_payment_service_address.is_some() + { processed_network_argument.network = None; // We need this because network is Devnet as default, which is not true for a Custom network } @@ -302,7 +308,7 @@ impl From for Network { Some(NetworkNameArg::Holesky) => Network::Holesky, Some(NetworkNameArg::HoleskyStage) => Network::HoleskyStage, Some(NetworkNameArg::Mainnet) => Network::Mainnet, - } + } } } @@ -366,29 +372,31 @@ 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(submit_args.network.clone().into(), wallet.address()) - .await - .map_err(|e| match e { - aligned_sdk::core::errors::GetNonceError::EthRpcError(e) => { - SubmitError::GetNonceError(e) - } - aligned_sdk::core::errors::GetNonceError::ConnectionFailed(e) => { - SubmitError::GenericError(e) - } - aligned_sdk::core::errors::GetNonceError::InvalidRequest(e) => { - SubmitError::GenericError(e) - } - aligned_sdk::core::errors::GetNonceError::SerializationError(e) => { - SubmitError::GenericError(e) - } - aligned_sdk::core::errors::GetNonceError::ProtocolMismatch { - current, - expected, - } => SubmitError::ProtocolVersionMismatch { current, expected }, - aligned_sdk::core::errors::GetNonceError::UnexpectedResponse(e) => { - SubmitError::UnexpectedBatcherResponse(e) - } - })?, + None => { + get_nonce_from_batcher(submit_args.network.clone().into(), wallet.address()) + .await + .map_err(|e| match e { + aligned_sdk::core::errors::GetNonceError::EthRpcError(e) => { + SubmitError::GetNonceError(e) + } + aligned_sdk::core::errors::GetNonceError::ConnectionFailed(e) => { + SubmitError::GenericError(e) + } + aligned_sdk::core::errors::GetNonceError::InvalidRequest(e) => { + SubmitError::GenericError(e) + } + aligned_sdk::core::errors::GetNonceError::SerializationError(e) => { + SubmitError::GenericError(e) + } + aligned_sdk::core::errors::GetNonceError::ProtocolMismatch { + current, + expected, + } => SubmitError::ProtocolVersionMismatch { current, expected }, + aligned_sdk::core::errors::GetNonceError::UnexpectedResponse(e) => { + SubmitError::UnexpectedBatcherResponse(e) + } + })? + } }; warn!("Nonce: {nonce}"); @@ -529,7 +537,9 @@ async fn main() -> Result<(), AlignedError> { let client = SignerMiddleware::new(eth_rpc_provider.clone(), wallet.clone()); - match deposit_to_aligned(amount_wei, client, deposit_to_batcher_args.network.into()).await { + match deposit_to_aligned(amount_wei, client, deposit_to_batcher_args.network.into()) + .await + { Ok(receipt) => { info!( "Payment sent to the batcher successfully. Tx: 0x{:x}", From 9da8dcc1a45ff86b14d44fa624c41b427b2da555 Mon Sep 17 00:00:00 2001 From: Urix <43704209+uri-99@users.noreply.github.com> Date: Thu, 16 Jan 2025 16:28:06 -0300 Subject: [PATCH 59/74] feat: migrate rust task sender --- Makefile | 13 +-- batcher/aligned-task-sender/src/commands.rs | 27 +++-- batcher/aligned-task-sender/src/structs.rs | 121 +++++++++++++++----- 3 files changed, 114 insertions(+), 47 deletions(-) diff --git a/Makefile b/Makefile index c102b55cf6..b1f6abfb7e 100644 --- a/Makefile +++ b/Makefile @@ -504,7 +504,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 @@ -512,8 +511,8 @@ 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 \ - --num-senders $(NUM_SENDERS) + --num-senders $(NUM_SENDERS) \ + --network devnet # ===== HOLESKY-STAGE ===== task_sender_generate_and_fund_wallets_holesky_stage: @@ -532,7 +531,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 @@ -540,13 +538,14 @@ 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 \ - --num-senders $(NUM_SENDERS) + --num-senders $(NUM_SENDERS) \ + --network holesky-stage __UTILS__: aligned_get_user_balance_devnet: @cd batcher/aligned/ && cargo run --release -- get-user-balance \ - --user_addr $(USER_ADDR) + --user_addr $(USER_ADDR) \ + --network devnet aligned_get_user_balance_holesky: @cd batcher/aligned/ && cargo run --release -- get-user-balance \ diff --git a/batcher/aligned-task-sender/src/commands.rs b/batcher/aligned-task-sender/src/commands.rs index 395b57dfa4..82c45c6b90 100644 --- a/batcher/aligned-task-sender/src/commands.rs +++ b/batcher/aligned-task-sender/src/commands.rs @@ -63,7 +63,7 @@ pub async fn generate_proofs(args: GenerateProofsArgs) { } pub async fn generate_and_fund_wallets(args: GenerateAndFundWalletsArgs) { - if matches!(args.network.into(), Network::Devnet) { + if matches!(args.network.clone().into(), Network::Devnet) { let Ok(eth_rpc_provider) = Provider::::try_from(args.eth_rpc_url.clone()) else { error!("Could not connect to eth rpc"); return; @@ -96,11 +96,12 @@ pub async fn generate_and_fund_wallets(args: GenerateAndFundWalletsArgs) { let funded_wallet_signer = SignerMiddleware::new(eth_rpc_provider.clone(), wallet.clone()); tokio::time::sleep(Duration::from_millis(50)).await; // To avoid overloading the RPC + let network = args.network.clone(); let handle = tokio::spawn(async move { if let Err(err) = deposit_to_aligned( amount_to_deposit_to_aligned, funded_wallet_signer.clone(), - args.network.into(), + network.into(), ) .await { @@ -188,7 +189,7 @@ pub async fn generate_and_fund_wallets(args: GenerateAndFundWalletsArgs) { ); let signer = SignerMiddleware::new(eth_rpc_provider.clone(), wallet.clone()); if let Err(err) = - deposit_to_aligned(amount_to_deposit_to_aligned, signer, args.network.clone()).await + deposit_to_aligned(amount_to_deposit_to_aligned, signer, args.network.clone().into()).await { error!("Could not deposit to aligned, err: {:?}", err); return; @@ -212,10 +213,11 @@ pub async fn generate_and_fund_wallets(args: GenerateAndFundWalletsArgs) { pub async fn test_connection(args: TestConnectionsArgs) { info!("Going to only open a connection"); let mut handlers = vec![]; - let network = network.clone(); + let network: Network = args.network.into(); + let ws_url_string = network.get_batcher_url().to_string(); for i in 0..args.num_senders { - let ws_url = network.get_batcher_url().clone(); + let ws_url = ws_url_string.clone(); let handle = tokio::spawn(async move { let conn = connect_async(ws_url).await; if let Ok((mut ws_stream, _)) = conn { @@ -246,7 +248,7 @@ struct Sender { } pub async fn send_infinite_proofs(args: SendInfiniteProofsArgs) { - if matches!(args.network.into(), Network::Holesky) { + if matches!(args.network.clone().into(), Network::Holesky) { error!("Network not supported this infinite proof sender"); return; } @@ -310,18 +312,20 @@ pub async fn send_infinite_proofs(args: SendInfiniteProofsArgs) { let max_fee = U256::from_dec_str(&args.max_fee).expect("Invalid max fee"); let mut handles = vec![]; + let network: Network = args.network.into(); 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 wallet = sender.wallet.clone(); let verification_data = verification_data.clone(); + // this is necessary because of the move + let network_clone = network.clone(); // a thread to send tasks from each loaded wallet: let handle = tokio::spawn(async move { loop { + let n = network_clone.clone(); 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(n.clone(), wallet.address()) .await .inspect_err(|e| { error!( @@ -340,12 +344,11 @@ pub async fn send_infinite_proofs(args: SendInfiniteProofsArgs) { info!( "Sending {:?} Proofs to Aligned Batcher on {:?} from sender {}, nonce: {}, address: {:?}", - args.burst_size, args.network, i, nonce, wallet.address(), + args.burst_size, n.clone(), i, nonce, wallet.address(), ); - let batcher_url = batcher_url.clone(); let aligned_verification_data = submit_multiple( - args.network.into(), + n.clone().into(), &verification_data_to_send.clone(), max_fee, wallet.clone(), diff --git a/batcher/aligned-task-sender/src/structs.rs b/batcher/aligned-task-sender/src/structs.rs index c42b293683..f5f5db1d53 100644 --- a/batcher/aligned-task-sender/src/structs.rs +++ b/batcher/aligned-task-sender/src/structs.rs @@ -1,8 +1,8 @@ use aligned_sdk::core::types::Network; -use clap::value_parser; use clap::Parser; use clap::Subcommand; use clap::ValueEnum; +use std::str::FromStr; #[derive(Parser, Debug)] #[command(version, about, long_about = None)] @@ -78,25 +78,15 @@ pub struct GenerateAndFundWalletsArgs { long = "private-keys-filepath" )] pub private_keys_filepath: String, - #[arg( - name = "The working network's name", - long = "network", - default_value = "devnet", - value_parser = value_parser!(Network) - )] - pub network: Network, + #[clap(flatten)] + pub network: NetworkArg, } #[derive(Parser, Debug)] #[command(version, about, long_about = None)] pub struct TestConnectionsArgs { - #[arg( - name = "The working network's name", - long = "network", - default_value = "devnet", - value_parser = value_parser!(Network) - )] - pub network: Network, + #[clap(flatten)] + pub network: NetworkArg, #[arg( name = "Number of spawned sockets", long = "num-senders", @@ -114,12 +104,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", @@ -134,13 +118,8 @@ pub struct SendInfiniteProofsArgs { pub burst_time_secs: u64, #[arg(name = "Max Fee", long = "max-fee", default_value = "1300000000000000")] pub max_fee: String, - #[arg( - name = "The working network's name", - long = "network", - default_value = "devnet", - value_parser = value_parser!(Network) - )] - pub network: Network, + #[clap(flatten)] + pub network: NetworkArg, #[arg( name = "Private keys filepath for the senders", long = "private-keys-filepath" @@ -153,3 +132,89 @@ pub struct SendInfiniteProofsArgs { )] pub proofs_dir: String, } + + +#[derive(Debug, Clone, Copy)] +enum NetworkNameArg { + Devnet, + Holesky, + HoleskyStage, + Mainnet, +} + +impl FromStr for NetworkNameArg { + type Err = String; + + fn from_str(s: &str) -> Result { + match s { + "devnet" => Ok(NetworkNameArg::Devnet), + "holesky" => Ok(NetworkNameArg::Holesky), + "holesky-stage" => Ok(NetworkNameArg::HoleskyStage), + "mainnet" => Ok(NetworkNameArg::Mainnet), + _ => Err( + "Unknown network. Possible values: devnet, holesky, holesky-stage, mainnet" + .to_string(), + ), + } + } +} + +#[derive(Debug, clap::Args, Clone)] +pub struct NetworkArg { + #[arg( + name = "The working network's name", + long = "network", + default_value = "devnet", + help = "[possible values: devnet, holesky, holesky-stage, mainnet]" + )] + network: Option, + #[arg( + name = "Aligned Service Manager Contract Address", + long = "aligned_service_manager", + conflicts_with("The working network's name"), + requires("Batcher Payment Service Contract Address"), + requires("Batcher URL") + )] + aligned_service_manager_address: Option, + #[arg( + name = "Batcher Payment Service Contract Address", + long = "batcher_payment_service", + conflicts_with("The working network's name"), + requires("Aligned Service Manager Contract Address"), + requires("Batcher URL") + )] + batcher_payment_service_address: Option, + #[arg( + name = "Batcher URL", + long = "batcher_url", + conflicts_with("The working network's name"), + requires("Aligned Service Manager Contract Address"), + requires("Batcher Payment Service Contract Address") + )] + batcher_url: Option, +} + +impl From for Network { + fn from(network_arg: NetworkArg) -> Self { + let mut processed_network_argument = network_arg.clone(); + + if network_arg.batcher_url.is_some() + || network_arg.aligned_service_manager_address.is_some() + || network_arg.batcher_payment_service_address.is_some() + { + processed_network_argument.network = None; // We need this because network is Devnet as default, which is not true for a Custom network + } + + match processed_network_argument.network { + None => Network::Custom( + network_arg.aligned_service_manager_address.unwrap(), + network_arg.batcher_payment_service_address.unwrap(), + network_arg.batcher_url.unwrap(), + ), + Some(NetworkNameArg::Devnet) => Network::Devnet, + Some(NetworkNameArg::Holesky) => Network::Holesky, + Some(NetworkNameArg::HoleskyStage) => Network::HoleskyStage, + Some(NetworkNameArg::Mainnet) => Network::Mainnet, + } + } +} From 5873fa41e7317fb48d080c258d1dfa63f4e767d1 Mon Sep 17 00:00:00 2001 From: Urix <43704209+uri-99@users.noreply.github.com> Date: Thu, 16 Jan 2025 16:29:40 -0300 Subject: [PATCH 60/74] chore: docs --- batcher/aligned-task-sender/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/batcher/aligned-task-sender/README.md b/batcher/aligned-task-sender/README.md index fdf49195df..c73d454b1e 100644 --- a/batcher/aligned-task-sender/README.md +++ b/batcher/aligned-task-sender/README.md @@ -61,7 +61,7 @@ To run it, you can: cargo run --release -- send-infinite-proofs \ --burst-size --burst-time-secs \ --eth-rpc-url \ - --network holesky-stage \ + --network \ --proofs-dirpath $(PWD)/scripts/test_files/task_sender/proofs \ --private-keys-filepath ``` From ceafba515440e3f0fda8e8d045ed8744b81c0484 Mon Sep 17 00:00:00 2001 From: Urix <43704209+uri-99@users.noreply.github.com> Date: Thu, 16 Jan 2025 16:31:24 -0300 Subject: [PATCH 61/74] chore: cargo fmt --- batcher/aligned-task-sender/src/commands.rs | 8 ++++++-- batcher/aligned-task-sender/src/structs.rs | 1 - 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/batcher/aligned-task-sender/src/commands.rs b/batcher/aligned-task-sender/src/commands.rs index 82c45c6b90..dadcd9d756 100644 --- a/batcher/aligned-task-sender/src/commands.rs +++ b/batcher/aligned-task-sender/src/commands.rs @@ -188,8 +188,12 @@ pub async fn generate_and_fund_wallets(args: GenerateAndFundWalletsArgs) { amount_to_deposit_to_aligned, i ); let signer = SignerMiddleware::new(eth_rpc_provider.clone(), wallet.clone()); - if let Err(err) = - deposit_to_aligned(amount_to_deposit_to_aligned, signer, args.network.clone().into()).await + if let Err(err) = deposit_to_aligned( + amount_to_deposit_to_aligned, + signer, + args.network.clone().into(), + ) + .await { error!("Could not deposit to aligned, err: {:?}", err); return; diff --git a/batcher/aligned-task-sender/src/structs.rs b/batcher/aligned-task-sender/src/structs.rs index f5f5db1d53..fdeba460d0 100644 --- a/batcher/aligned-task-sender/src/structs.rs +++ b/batcher/aligned-task-sender/src/structs.rs @@ -133,7 +133,6 @@ pub struct SendInfiniteProofsArgs { pub proofs_dir: String, } - #[derive(Debug, Clone, Copy)] enum NetworkNameArg { Devnet, From ab8708670084ed9b1d80f125ca99271708aa2f92 Mon Sep 17 00:00:00 2001 From: Urix <43704209+uri-99@users.noreply.github.com> Date: Thu, 16 Jan 2025 16:37:57 -0300 Subject: [PATCH 62/74] chore: cargo clippy --- batcher/aligned-task-sender/src/commands.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/batcher/aligned-task-sender/src/commands.rs b/batcher/aligned-task-sender/src/commands.rs index dadcd9d756..6a163c1910 100644 --- a/batcher/aligned-task-sender/src/commands.rs +++ b/batcher/aligned-task-sender/src/commands.rs @@ -352,7 +352,7 @@ pub async fn send_infinite_proofs(args: SendInfiniteProofsArgs) { ); let aligned_verification_data = submit_multiple( - n.clone().into(), + n.clone(), &verification_data_to_send.clone(), max_fee, wallet.clone(), From 51f576ade08ae99343e2c72218b376771f45b03b Mon Sep 17 00:00:00 2001 From: Urix <43704209+uri-99@users.noreply.github.com> Date: Fri, 17 Jan 2025 12:56:02 -0300 Subject: [PATCH 63/74] chore: add error failure on CI --- Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile b/Makefile index b1f6abfb7e..4afa46c0c6 100644 --- a/Makefile +++ b/Makefile @@ -1065,6 +1065,7 @@ docker_verify_proof_submission_success: --rpc_url $$(echo $(DOCKER_RPC_URL)) 2>&1); \ if echo "$$verification" | grep -q not; then \ echo "ERROR: Proof verification failed for $${proof}"; \ + echo "With error: $$verification"; \ exit 1; \ elif echo "$$verification" | grep -q verified; then \ echo "Proof verification succeeded for $${proof}"; \ From 79a3b8a37570a1f7ae7b9a18879c0758854eff8c Mon Sep 17 00:00:00 2001 From: Urix <43704209+uri-99@users.noreply.github.com> Date: Fri, 17 Jan 2025 13:07:01 -0300 Subject: [PATCH 64/74] chore: fix comment --- batcher/aligned-batcher/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/batcher/aligned-batcher/src/lib.rs b/batcher/aligned-batcher/src/lib.rs index 420b435e1f..304e68dff8 100644 --- a/batcher/aligned-batcher/src/lib.rs +++ b/batcher/aligned-batcher/src/lib.rs @@ -1516,7 +1516,7 @@ impl Batcher { } Err(e) => { error!( - "Failed to send batch to contract, batch will be lost: {:?}", + "Failed to send batch to contract: {:?}", e ); From d7dc1c1aa12fca0b9621055717eb08a99772949f Mon Sep 17 00:00:00 2001 From: Urix <43704209+uri-99@users.noreply.github.com> Date: Fri, 17 Jan 2025 14:21:44 -0300 Subject: [PATCH 65/74] fix: debugging error in CI --- Makefile | 4 +++- batcher/aligned-sdk/src/sdk.rs | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 4afa46c0c6..bac5a4afbd 100644 --- a/Makefile +++ b/Makefile @@ -1060,12 +1060,14 @@ docker_verify_proof_submission_success: sleep $(DOCKER_PROOFS_WAIT_TIME); \ for proof in ./aligned_verification_data/*.cbor; do \ echo "Verifying proof $${proof} \n"; \ + cat $${proof}; verification=$$(aligned verify-proof-onchain \ --aligned-verification-data $${proof} \ --rpc_url $$(echo $(DOCKER_RPC_URL)) 2>&1); \ if echo "$$verification" | grep -q not; then \ echo "ERROR: Proof verification failed for $${proof}"; \ - echo "With error: $$verification"; \ + echo "With error:"; \ + echo "$$verification"; \ exit 1; \ elif echo "$$verification" | grep -q verified; then \ echo "Proof verification succeeded for $${proof}"; \ diff --git a/batcher/aligned-sdk/src/sdk.rs b/batcher/aligned-sdk/src/sdk.rs index 910ad4ac07..0ac06024bc 100644 --- a/batcher/aligned-sdk/src/sdk.rs +++ b/batcher/aligned-sdk/src/sdk.rs @@ -457,6 +457,9 @@ async fn _is_proof_verified( let contract_address = network.clone().get_aligned_service_manager_address(); let payment_service_addr = network.get_batcher_payment_service_address(); + info!("contract_address: {}", contract_address); + info!("payment_service_addr: {}", payment_service_addr); + // All the elements from the merkle proof have to be concatenated let merkle_proof: Vec = aligned_verification_data .batch_inclusion_proof From ce35d416b074175ac85174492c1cc82485467c3c Mon Sep 17 00:00:00 2001 From: Urix <43704209+uri-99@users.noreply.github.com> Date: Fri, 17 Jan 2025 15:05:23 -0300 Subject: [PATCH 66/74] fix(wip): print .json contents --- Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile b/Makefile index bac5a4afbd..fe1a004a9d 100644 --- a/Makefile +++ b/Makefile @@ -1061,6 +1061,7 @@ docker_verify_proof_submission_success: for proof in ./aligned_verification_data/*.cbor; do \ echo "Verifying proof $${proof} \n"; \ cat $${proof}; + cat $${proof%.cbor}.json verification=$$(aligned verify-proof-onchain \ --aligned-verification-data $${proof} \ --rpc_url $$(echo $(DOCKER_RPC_URL)) 2>&1); \ From f05869ed6fdb216e46fb3071b55efa8c7a593f79 Mon Sep 17 00:00:00 2001 From: Urix <43704209+uri-99@users.noreply.github.com> Date: Fri, 17 Jan 2025 15:06:15 -0300 Subject: [PATCH 67/74] fix: prints --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index fe1a004a9d..a3218fa005 100644 --- a/Makefile +++ b/Makefile @@ -1060,8 +1060,8 @@ docker_verify_proof_submission_success: sleep $(DOCKER_PROOFS_WAIT_TIME); \ for proof in ./aligned_verification_data/*.cbor; do \ echo "Verifying proof $${proof} \n"; \ - cat $${proof}; - cat $${proof%.cbor}.json + cat $${proof}; \ + cat $${proof%.cbor}.json; \ verification=$$(aligned verify-proof-onchain \ --aligned-verification-data $${proof} \ --rpc_url $$(echo $(DOCKER_RPC_URL)) 2>&1); \ From 1c3b24527c3b5a3aefb1f1ff4e52d9b11230dd1e Mon Sep 17 00:00:00 2001 From: Urix <43704209+uri-99@users.noreply.github.com> Date: Fri, 17 Jan 2025 16:27:57 -0300 Subject: [PATCH 68/74] fix: revert CI changes, they are in another pr --- Makefile | 4 ---- batcher/aligned-sdk/src/sdk.rs | 3 --- 2 files changed, 7 deletions(-) diff --git a/Makefile b/Makefile index a3218fa005..b1f6abfb7e 100644 --- a/Makefile +++ b/Makefile @@ -1060,15 +1060,11 @@ docker_verify_proof_submission_success: sleep $(DOCKER_PROOFS_WAIT_TIME); \ for proof in ./aligned_verification_data/*.cbor; do \ echo "Verifying proof $${proof} \n"; \ - cat $${proof}; \ - cat $${proof%.cbor}.json; \ verification=$$(aligned verify-proof-onchain \ --aligned-verification-data $${proof} \ --rpc_url $$(echo $(DOCKER_RPC_URL)) 2>&1); \ if echo "$$verification" | grep -q not; then \ echo "ERROR: Proof verification failed for $${proof}"; \ - echo "With error:"; \ - echo "$$verification"; \ exit 1; \ elif echo "$$verification" | grep -q verified; then \ echo "Proof verification succeeded for $${proof}"; \ diff --git a/batcher/aligned-sdk/src/sdk.rs b/batcher/aligned-sdk/src/sdk.rs index 0ac06024bc..910ad4ac07 100644 --- a/batcher/aligned-sdk/src/sdk.rs +++ b/batcher/aligned-sdk/src/sdk.rs @@ -457,9 +457,6 @@ async fn _is_proof_verified( let contract_address = network.clone().get_aligned_service_manager_address(); let payment_service_addr = network.get_batcher_payment_service_address(); - info!("contract_address: {}", contract_address); - info!("payment_service_addr: {}", payment_service_addr); - // All the elements from the merkle proof have to be concatenated let merkle_proof: Vec = aligned_verification_data .batch_inclusion_proof From 5d32849279ec3f7fa5eba4b9afd2292617f084e7 Mon Sep 17 00:00:00 2001 From: Urix <43704209+uri-99@users.noreply.github.com> Date: Fri, 17 Jan 2025 17:26:56 -0300 Subject: [PATCH 69/74] fix: docs --- docs/3_guides/9_aligned_cli.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/3_guides/9_aligned_cli.md b/docs/3_guides/9_aligned_cli.md index 30bbaa0b7f..42bcbb7af5 100644 --- a/docs/3_guides/9_aligned_cli.md +++ b/docs/3_guides/9_aligned_cli.md @@ -244,7 +244,9 @@ Retrieves the user's current nonce from the batcher. - `--network `: Network name to interact with. - Default: `devnet` - Possible values: `devnet`, `holesky`, `mainnet` - - For a custom Network, you must specify the following parameter: + - For a custom Network, you must specify the following parameters: + - `--aligned_service_manager ` + - `--batcher_payment_service ` - `--batcher_url ` #### Example: From 544723738158e3d5ba5fad72304eb64c3ff3c657 Mon Sep 17 00:00:00 2001 From: Urix <43704209+uri-99@users.noreply.github.com> Date: Fri, 17 Jan 2025 17:35:04 -0300 Subject: [PATCH 70/74] chore: cargo fmt --- batcher/aligned-batcher/src/lib.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/batcher/aligned-batcher/src/lib.rs b/batcher/aligned-batcher/src/lib.rs index bda2af87a6..7fa09d539a 100644 --- a/batcher/aligned-batcher/src/lib.rs +++ b/batcher/aligned-batcher/src/lib.rs @@ -1522,10 +1522,7 @@ impl Batcher { Ok(()) } Err(e) => { - error!( - "Failed to send batch to contract: {:?}", - e - ); + error!("Failed to send batch to contract: {:?}", e); self.metrics.reverted_batches.inc(); Err(e) From 00a252cc051d5ae7c05f16b99e5dbf1b1f98f11b Mon Sep 17 00:00:00 2001 From: JuArce <52429267+JuArce@users.noreply.github.com> Date: Fri, 17 Jan 2025 18:23:43 -0300 Subject: [PATCH 71/74] fix: batcher urls --- batcher/aligned-sdk/src/core/constants.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/batcher/aligned-sdk/src/core/constants.rs b/batcher/aligned-sdk/src/core/constants.rs index e573dcbfd7..ee6dd7b366 100644 --- a/batcher/aligned-sdk/src/core/constants.rs +++ b/batcher/aligned-sdk/src/core/constants.rs @@ -57,6 +57,6 @@ pub const ALIGNED_SERVICE_MANAGER_HOLESKY_STAGE: &str = pub const ALIGNED_SERVICE_MANAGER_MAINNET: &str = "0xeF2A435e5EE44B2041100EF8cbC8ae035166606c"; /// 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: &str = "wss://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"; +pub const BATCHER_URL_MAINNET: &str = "wss://mainnet.batcher.alignedlayer.com"; From cc84f6e14291f9b241ea5d6b758bbd02384c3ec1 Mon Sep 17 00:00:00 2001 From: JuArce <52429267+JuArce@users.noreply.github.com> Date: Fri, 17 Jan 2025 18:24:42 -0300 Subject: [PATCH 72/74] fix: missing new line --- batcher/aligned-sdk/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/batcher/aligned-sdk/Cargo.toml b/batcher/aligned-sdk/Cargo.toml index 90b828ba3e..019a659842 100644 --- a/batcher/aligned-sdk/Cargo.toml +++ b/batcher/aligned-sdk/Cargo.toml @@ -24,4 +24,4 @@ url = "2.5.0" hex = "0.4.3" ciborium = "=0.2.2" serde_repr = "0.1.19" -dialoguer = "0.11.0" \ No newline at end of file +dialoguer = "0.11.0" From beef3cfc171a10368b9f53d28c15c0aca1922c18 Mon Sep 17 00:00:00 2001 From: Urix <43704209+uri-99@users.noreply.github.com> Date: Fri, 17 Jan 2025 18:43:44 -0300 Subject: [PATCH 73/74] chore: cargo fmt --- batcher/aligned-sdk/src/sdk.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/batcher/aligned-sdk/src/sdk.rs b/batcher/aligned-sdk/src/sdk.rs index 57758e4755..b2623d03d0 100644 --- a/batcher/aligned-sdk/src/sdk.rs +++ b/batcher/aligned-sdk/src/sdk.rs @@ -7,7 +7,9 @@ use crate::{ }, core::{ constants::{ - ADDITIONAL_SUBMISSION_GAS_COST_PER_PROOF, DEFAULT_CONSTANT_GAS_COST, INSTANT_MAX_FEE_BATCH_SIZE, DEFAULT_MAX_FEE_BATCH_SIZE, GAS_PRICE_PERCENTAGE_MULTIPLIER, PERCENTAGE_DIVIDER + ADDITIONAL_SUBMISSION_GAS_COST_PER_PROOF, DEFAULT_CONSTANT_GAS_COST, + DEFAULT_MAX_FEE_BATCH_SIZE, GAS_PRICE_PERCENTAGE_MULTIPLIER, + INSTANT_MAX_FEE_BATCH_SIZE, PERCENTAGE_DIVIDER, }, errors::{self, GetNonceError}, types::{ From aca5e7df54dc884ccb8253a6a0e493927904ac28 Mon Sep 17 00:00:00 2001 From: JuArce <52429267+JuArce@users.noreply.github.com> Date: Mon, 20 Jan 2025 12:23:42 -0300 Subject: [PATCH 74/74] fix: comment fix: remove mix.lock changes from explorer --- batcher/aligned-sdk/src/core/constants.rs | 2 +- explorer/mix.lock | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/batcher/aligned-sdk/src/core/constants.rs b/batcher/aligned-sdk/src/core/constants.rs index c13db2d2d4..3d963732aa 100644 --- a/batcher/aligned-sdk/src/core/constants.rs +++ b/batcher/aligned-sdk/src/core/constants.rs @@ -24,7 +24,7 @@ pub const PERCENTAGE_DIVIDER: u128 = 100; /// i.e. the user pays for the entire batch and his proof is instantly submitted, therefore a batch of one proof. pub const INSTANT_MAX_FEE_BATCH_SIZE: usize = 1; /// The number of proofs in a batch to compute the `Default` fee estimate for proof submission to Aligned. -/// We define `10` as the `Default` setting as every 24 hours the batcher receives a batch of `16` proofs +/// We define `10` as the `Default` setting as every 6 hours the batcher receives a batch of `16` proofs /// sent from Aligned to confirm the network is live and estimating with a batch size of `10` proofs provides a buffer in case of a network fee increase. pub const DEFAULT_MAX_FEE_BATCH_SIZE: usize = 10; diff --git a/explorer/mix.lock b/explorer/mix.lock index 336bebe7ee..17f684b6a1 100644 --- a/explorer/mix.lock +++ b/explorer/mix.lock @@ -23,7 +23,7 @@ "floki": {:hex, :floki, "0.36.2", "a7da0193538c93f937714a6704369711998a51a6164a222d710ebd54020aa7a3", [:mix], [], "hexpm", "a8766c0bc92f074e5cb36c4f9961982eda84c5d2b8e979ca67f5c268ec8ed580"}, "gettext": {:hex, :gettext, "0.24.0", "6f4d90ac5f3111673cbefc4ebee96fe5f37a114861ab8c7b7d5b30a1108ce6d8", [:mix], [{:expo, "~> 0.5.1", [hex: :expo, repo: "hexpm", optional: false]}], "hexpm", "bdf75cdfcbe9e4622dd18e034b227d77dd17f0f133853a1c73b97b3d6c770e8b"}, "hackney": {:hex, :hackney, "1.20.1", "8d97aec62ddddd757d128bfd1df6c5861093419f8f7a4223823537bad5d064e2", [:rebar3], [{:certifi, "~> 2.12.0", [hex: :certifi, repo: "hexpm", optional: false]}, {:idna, "~> 6.1.0", [hex: :idna, repo: "hexpm", optional: false]}, {:metrics, "~> 1.0.0", [hex: :metrics, repo: "hexpm", optional: false]}, {:mimerl, "~> 1.1", [hex: :mimerl, repo: "hexpm", optional: false]}, {:parse_trans, "3.4.1", [hex: :parse_trans, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "~> 1.1.0", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}, {:unicode_util_compat, "~> 0.7.0", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm", "fe9094e5f1a2a2c0a7d10918fee36bfec0ec2a979994cff8cfe8058cd9af38e3"}, - "heroicons": {:git, "https://github.com/tailwindlabs/heroicons.git", "88ab3a0d790e6a47404cba02800a6b25d2afae50", [tag: "v2.1.1", sparse: "optimized", depth: 1]}, + "heroicons": {:git, "https://github.com/tailwindlabs/heroicons.git", "88ab3a0d790e6a47404cba02800a6b25d2afae50", [tag: "v2.1.1", sparse: "optimized"]}, "hpax": {:hex, :hpax, "0.2.0", "5a58219adcb75977b2edce5eb22051de9362f08236220c9e859a47111c194ff5", [:mix], [], "hexpm", "bea06558cdae85bed075e6c036993d43cd54d447f76d8190a8db0dc5893fa2f1"}, "httpoison": {:hex, :httpoison, "2.2.1", "87b7ed6d95db0389f7df02779644171d7319d319178f6680438167d7b69b1f3d", [:mix], [{:hackney, "~> 1.17", [hex: :hackney, repo: "hexpm", optional: false]}], "hexpm", "51364e6d2f429d80e14fe4b5f8e39719cacd03eb3f9a9286e61e216feac2d2df"}, "idna": {:hex, :idna, "6.1.1", "8a63070e9f7d0c62eb9d9fcb360a7de382448200fbbd1b106cc96d3d8099df8d", [:rebar3], [{:unicode_util_compat, "~> 0.7.0", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm", "92376eb7894412ed19ac475e4a86f7b413c1b9fbb5bd16dccd57934157944cea"},