From fb11393f4e0370c013b7a0140e3aa7a22132dc47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Paradelo?= Date: Wed, 26 Nov 2025 14:01:40 -0300 Subject: [PATCH 01/18] support fee token --- cli/src/cli.rs | 1 + cli/src/commands/l2.rs | 53 ++++++++++++++++++++++++++++++++++++++++-- sdk/src/l2/deposit.rs | 1 + sdk/src/sdk.rs | 14 ++--------- 4 files changed, 55 insertions(+), 14 deletions(-) diff --git a/cli/src/cli.rs b/cli/src/cli.rs index 434d564..7368be8 100644 --- a/cli/src/cli.rs +++ b/cli/src/cli.rs @@ -455,6 +455,7 @@ impl Command { args.amount, from, args.to, + TxType::EIP1559, &args.private_key, &client, Overrides::default(), diff --git a/cli/src/commands/l2.rs b/cli/src/commands/l2.rs index 2aed9d8..4b7dbae 100644 --- a/cli/src/commands/l2.rs +++ b/cli/src/commands/l2.rs @@ -4,10 +4,13 @@ use crate::{ utils::{parse_private_key, parse_u256}, }; use clap::Subcommand; +use ethrex_common::types::TxType; use ethrex_common::{Address, H256, U256}; use ethrex_l2_common::utils::get_address_from_secret_key; use ethrex_rpc::EthClient; +use ethrex_rpc::clients::Overrides; use ethrex_sdk::wait_for_message_proof; +use rex_sdk::transfer; use rex_sdk::{ l2::{ deposit::{deposit_erc20, deposit_through_contract_call}, @@ -210,6 +213,12 @@ pub(crate) enum Command { Transfer { #[clap(flatten)] args: TransferArgs, + #[arg( + long, + required = false, + help = "The L2 address of a Fee Token to pay the gas fees" + )] + fee_token: Option
, #[arg( default_value = "http://localhost:1729", env = "RPC_URL", @@ -471,8 +480,48 @@ impl Command { Command::Nonce { account, rpc_url } => { Box::pin(async { EthCommand::Nonce { account, rpc_url }.run().await }).await? } - Command::Transfer { args, rpc_url } => { - Box::pin(async { EthCommand::Transfer { args, rpc_url }.run().await }).await? + Command::Transfer { + args, + fee_token, + rpc_url, + } => { + if args.token_address.is_some() { + todo!("Handle ERC20 transfers") + } + + if args.explorer_url { + todo!("Display transaction URL in the explorer") + } + + let from = + get_address_from_secret_key(&args.private_key).map_err(|e| eyre::eyre!(e))?; + + let client = EthClient::new(rpc_url)?; + let tx_type = if fee_token.is_some() { + TxType::FeeToken + } else { + TxType::EIP1559 + }; + + let tx_hash = transfer( + args.amount, + from, + args.to, + tx_type, + &args.private_key, + &client, + Overrides { + fee_token, + ..Default::default() + }, + ) + .await?; + + println!("{tx_hash:#x}"); + + if !args.cast { + wait_for_transaction_receipt(tx_hash, &client, 100, args.silent).await?; + } } Command::Send { args, rpc_url } => { Box::pin(async { EthCommand::Send { args, rpc_url }.run().await }).await? diff --git a/sdk/src/l2/deposit.rs b/sdk/src/l2/deposit.rs index 569caa3..dac817c 100644 --- a/sdk/src/l2/deposit.rs +++ b/sdk/src/l2/deposit.rs @@ -24,6 +24,7 @@ pub async fn deposit_through_transfer( amount, from, bridge_address, + TxType::EIP1559, from_pk, eth_client, Overrides::default(), diff --git a/sdk/src/sdk.rs b/sdk/src/sdk.rs index b90e1b5..73fa5cc 100644 --- a/sdk/src/sdk.rs +++ b/sdk/src/sdk.rs @@ -38,23 +38,13 @@ pub async fn transfer( amount: U256, from: Address, to: Address, + tx_type: TxType, private_key: &SecretKey, client: &EthClient, mut overrides: Overrides, ) -> Result { overrides.value = Some(amount); - let tx = build_generic_tx( - client, - TxType::EIP1559, - to, - from, - Default::default(), - Overrides { - value: Some(amount), - ..Default::default() - }, - ) - .await?; + let tx = build_generic_tx(client, tx_type, to, from, Bytes::new(), overrides).await?; let signer = LocalSigner::new(*private_key).into(); send_generic_transaction(client, tx, &signer).await From 342290052726c14cf0586c013e39ca6c5932f6b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Paradelo?= Date: Wed, 26 Nov 2025 14:59:24 -0300 Subject: [PATCH 02/18] fix tests --- sdk/tests/tests.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sdk/tests/tests.rs b/sdk/tests/tests.rs index 131b50e..1261b9a 100644 --- a/sdk/tests/tests.rs +++ b/sdk/tests/tests.rs @@ -1,3 +1,4 @@ +use ethrex_common::types::TxType; use ethrex_common::{Address, Bytes, H160, H256, U256}; use ethrex_l2_common::{calldata::Value, utils::get_address_from_secret_key}; use ethrex_l2_rpc::signer::{LocalSigner, Signer}; @@ -722,6 +723,7 @@ async fn perform_transfer( transfer_value, transferer_address, transfer_recipient_address, + TxType::EIP1559, transferer_private_key, proposer_client, Overrides::default(), From 8a8bef0b1f6bb71f9e812bab7997ce0a06f60822 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Paradelo?= Date: Wed, 26 Nov 2025 15:16:17 -0300 Subject: [PATCH 03/18] fix again --- sdk/examples/keystore/main.rs | 1 + sdk/examples/simple_usage.rs | 2 ++ 2 files changed, 3 insertions(+) diff --git a/sdk/examples/keystore/main.rs b/sdk/examples/keystore/main.rs index 0dbd688..e84fc60 100644 --- a/sdk/examples/keystore/main.rs +++ b/sdk/examples/keystore/main.rs @@ -70,6 +70,7 @@ async fn main() -> Result<(), Box> { amount, rich_wallet_address, keystore_address, + TxType::EIP1559, &rich_wallet_pk, ð_client, Overrides::default(), diff --git a/sdk/examples/simple_usage.rs b/sdk/examples/simple_usage.rs index 468936b..425f81e 100644 --- a/sdk/examples/simple_usage.rs +++ b/sdk/examples/simple_usage.rs @@ -1,4 +1,5 @@ use clap::Parser; +use ethrex_common::types::TxType; use ethrex_common::{Address, Bytes, U256}; use ethrex_l2_common::utils::get_address_from_secret_key; use ethrex_rpc::{ @@ -63,6 +64,7 @@ async fn main() { amount, from, to, + TxType::EIP15529, &args.private_key, ð_client, Overrides::default(), From 07ffe15518e176b0e0860a576eef85ec44cb99ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Paradelo?= Date: Wed, 26 Nov 2025 15:34:30 -0300 Subject: [PATCH 04/18] fix wrong number --- sdk/examples/simple_usage.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/examples/simple_usage.rs b/sdk/examples/simple_usage.rs index 425f81e..93cfc41 100644 --- a/sdk/examples/simple_usage.rs +++ b/sdk/examples/simple_usage.rs @@ -64,7 +64,7 @@ async fn main() { amount, from, to, - TxType::EIP15529, + TxType::EIP1559, &args.private_key, ð_client, Overrides::default(), From af7c5f507159a06fed3fb9b6bdfe0c141e6207bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Paradelo?= Date: Wed, 26 Nov 2025 16:24:04 -0300 Subject: [PATCH 05/18] add fee l2 info --- cli/src/commands/l2.rs | 48 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/cli/src/commands/l2.rs b/cli/src/commands/l2.rs index 4b7dbae..5c4cd1c 100644 --- a/cli/src/commands/l2.rs +++ b/cli/src/commands/l2.rs @@ -7,8 +7,15 @@ use clap::Subcommand; use ethrex_common::types::TxType; use ethrex_common::{Address, H256, U256}; use ethrex_l2_common::utils::get_address_from_secret_key; -use ethrex_rpc::EthClient; +use ethrex_l2_rpc::clients::{ + get_base_fee_vault_address, get_l1_blob_base_fee_per_gas, get_l1_fee_vault_address, + get_operator_fee, get_operator_fee_vault_address, +}; use ethrex_rpc::clients::Overrides; +use ethrex_rpc::{ + EthClient, + types::block_identifier::{BlockIdentifier, BlockTag}, +}; use ethrex_sdk::wait_for_message_proof; use rex_sdk::transfer; use rex_sdk::{ @@ -285,6 +292,21 @@ pub(crate) enum Command { )] rpc_url: Url, }, + #[clap(about = "Get L2 fees info for a block")] + GetFeeInfo { + #[arg( + long, + required = false, + help = "Block number to query the fees info for" + )] + block: Option, + #[arg( + default_value = "http://localhost:1729", + env = "RPC_URL", + help = "L2 RPC URL" + )] + rpc_url: Url, + }, } impl Command { @@ -535,6 +557,30 @@ impl Command { Command::ChainId { hex, rpc_url } => { Box::pin(async { EthCommand::ChainId { hex, rpc_url }.run().await }).await? } + Command::GetFeeInfo { block, rpc_url } => { + let client: EthClient = EthClient::new(rpc_url)?; + let block_identifier = if let Some(block_number) = block { + BlockIdentifier::Number(block_number) + } else { + BlockIdentifier::Tag(BlockTag::Latest) + }; + + let base_fee_vault_address = + get_base_fee_vault_address(&client, block_identifier.clone()).await?; + let operator_fee_vault_address = + get_operator_fee_vault_address(&client, block_identifier.clone()).await?; + let l1_fee_vault_address = + get_l1_fee_vault_address(&client, block_identifier.clone()).await?; + + let operator_fee = get_operator_fee(&client, block_identifier.clone()).await?; + + let block_number = if let Some(block) = block { + block + } else { + client.get_block_number().await?.as_u64() + }; + let blob_base_fee = get_l1_blob_base_fee_per_gas(&client, block_number).await?; + } }; Ok(()) } From 330e2eec56c33ee4f158e5cb0bcd460c54d99bb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Paradelo?= Date: Wed, 26 Nov 2025 16:51:31 -0300 Subject: [PATCH 06/18] add fee config info cli --- cli/src/commands/l2.rs | 40 ++++++++++++++++++++++++++++++++-------- 1 file changed, 32 insertions(+), 8 deletions(-) diff --git a/cli/src/commands/l2.rs b/cli/src/commands/l2.rs index 5c4cd1c..ac488eb 100644 --- a/cli/src/commands/l2.rs +++ b/cli/src/commands/l2.rs @@ -559,10 +559,12 @@ impl Command { } Command::GetFeeInfo { block, rpc_url } => { let client: EthClient = EthClient::new(rpc_url)?; - let block_identifier = if let Some(block_number) = block { - BlockIdentifier::Number(block_number) - } else { - BlockIdentifier::Tag(BlockTag::Latest) + let (block_identifier, block_number) = match block { + Some(block_number) => (BlockIdentifier::Number(block_number), block_number), + None => { + let latest_block = client.get_block_number().await?.as_u64(); + (BlockIdentifier::Tag(BlockTag::Latest), latest_block) + } }; let base_fee_vault_address = @@ -573,13 +575,35 @@ impl Command { get_l1_fee_vault_address(&client, block_identifier.clone()).await?; let operator_fee = get_operator_fee(&client, block_identifier.clone()).await?; + let blob_base_fee = get_l1_blob_base_fee_per_gas(&client, block_number).await?; + + let base_fee_vault_address = base_fee_vault_address + .map(|addr| format!("{addr:#x}")) + .unwrap_or_else(String::new); + let operator_fee_vault_address = operator_fee_vault_address + .map(|addr| format!("{addr:#x}")) + .unwrap_or_else(String::new); + let l1_fee_vault_address = l1_fee_vault_address + .map(|addr| format!("{addr:#x}")) + .unwrap_or_else(String::new); - let block_number = if let Some(block) = block { - block + let operator_fee = if operator_fee.is_zero() { + String::new() } else { - client.get_block_number().await?.as_u64() + operator_fee.to_string() }; - let blob_base_fee = get_l1_blob_base_fee_per_gas(&client, block_number).await?; + let blob_base_fee = if blob_base_fee == 0 { + String::new() + } else { + blob_base_fee.to_string() + }; + + println!("L2 fee info for block {block_number}:"); + println!(" Base fee vault: {base_fee_vault_address}"); + println!(" Operator fee vault: {operator_fee_vault_address}"); + println!(" L1 fee vault: {l1_fee_vault_address}"); + println!(" Operator fee (wei/gas): {operator_fee}"); + println!(" L1 blob base fee (wei/blob-gas): {blob_base_fee}"); } }; Ok(()) From 9a80b908636b45eb6d86d6ba1f7723912fe5bb52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Paradelo?= Date: Wed, 26 Nov 2025 18:07:46 -0300 Subject: [PATCH 07/18] feat: add batch l2 options --- cli/src/commands/l2.rs | 65 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/cli/src/commands/l2.rs b/cli/src/commands/l2.rs index ac488eb..b259bf6 100644 --- a/cli/src/commands/l2.rs +++ b/cli/src/commands/l2.rs @@ -7,6 +7,7 @@ use clap::Subcommand; use ethrex_common::types::TxType; use ethrex_common::{Address, H256, U256}; use ethrex_l2_common::utils::get_address_from_secret_key; +use ethrex_l2_rpc::clients::get_batch_by_number; use ethrex_l2_rpc::clients::{ get_base_fee_vault_address, get_l1_blob_base_fee_per_gas, get_l1_fee_vault_address, get_operator_fee, get_operator_fee_vault_address, @@ -307,6 +308,31 @@ pub(crate) enum Command { )] rpc_url: Url, }, + #[clap(about = "Get the latest batch number")] + BatchNumber { + #[arg( + default_value = "http://localhost:1729", + env = "RPC_URL", + help = "L2 RPC URL" + )] + rpc_url: Url, + }, + #[clap(about = "Get the latest batch or a batch by its number")] + BatchByNumber { + #[arg( + long, + short = 'b', + required = false, + help = "Batch number to retrieve information" + )] + batch_number: Option, + #[arg( + default_value = "http://localhost:1729", + env = "RPC_URL", + help = "L2 RPC URL" + )] + rpc_url: Url, + }, } impl Command { @@ -605,6 +631,45 @@ impl Command { println!(" Operator fee (wei/gas): {operator_fee}"); println!(" L1 blob base fee (wei/blob-gas): {blob_base_fee}"); } + Command::BatchNumber { rpc_url } => { + let _client = EthClient::new(rpc_url)?; + } + Command::BatchByNumber { + batch_number, + rpc_url, + } => { + let batch_number = batch_number.unwrap(); // left this until i can get the latest batch + let client = EthClient::new(rpc_url)?; + + let batch = match get_batch_by_number(&client, batch_number).await { + Ok(batch) => batch.batch, + Err(err) => { + println!("Batch {batch_number} not available yet: {err}"); + return Ok(()); + } + }; + + let commit_tx = batch + .commit_tx + .map(|tx| format!("{tx:#x}")) + .unwrap_or_else(String::new); + let verify_tx = batch + .verify_tx + .map(|tx| format!("{tx:#x}")) + .unwrap_or_else(String::new); + + println!("Batch info for batch {}", batch.number); + println!(" Number: {}", batch.number); + println!(" First block: {}", batch.first_block); + println!(" Last block: {}", batch.last_block); + println!(" State root: {:#x}", batch.state_root); + println!( + " Privileged transactions hash: {:#x}", + batch.privileged_transactions_hash + ); + println!(" Commit tx: {commit_tx}"); + println!(" Verify tx: {verify_tx}"); + } }; Ok(()) } From 9a6061fc5dffbefb6dfa14f28e7c7bc1aa47841d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Paradelo?= Date: Thu, 27 Nov 2025 11:40:14 -0300 Subject: [PATCH 08/18] add auth command --- cli/src/cli.rs | 48 +++++++++++++++++++++++++++++++++++++++++- cli/src/commands/l2.rs | 17 ++++++++++++++- sdk/src/utils.rs | 42 ++++++++++++++++++++++++++++++++++-- 3 files changed, 103 insertions(+), 4 deletions(-) diff --git a/cli/src/cli.rs b/cli/src/cli.rs index 7368be8..32fd5da 100644 --- a/cli/src/cli.rs +++ b/cli/src/cli.rs @@ -11,6 +11,7 @@ use ethrex_common::{Address, Bytes, H256, H520}; use ethrex_l2_common::calldata::Value; use ethrex_l2_common::utils::get_address_from_secret_key; use ethrex_l2_rpc::signer::{LocalSigner, Signer}; +use ethrex_rlp::encode::RLPEncode; use ethrex_rpc::EthClient; use ethrex_rpc::clients::Overrides; use ethrex_rpc::types::block_identifier::{BlockIdentifier, BlockTag}; @@ -23,7 +24,7 @@ use rex_sdk::create::{ DETERMINISTIC_DEPLOYER, brute_force_create2, compute_create_address, compute_create2_address, }; use rex_sdk::sign::{get_address_from_message_and_signature, sign_hash}; -use rex_sdk::utils::to_checksum_address; +use rex_sdk::utils::{make_auth_tuple, to_checksum_address}; use rex_sdk::{balance_in_eth, deploy, transfer, wait_for_transaction_receipt}; use secp256k1::SecretKey; use std::io::{self, Write}; @@ -276,6 +277,19 @@ pub(crate) enum Command { #[arg(value_parser = parse_hex)] data: Bytes, }, + #[clap(about = "Authorize a delegated account")] + Auth { + #[arg(help = "Delegated address")] + delegated_address: Address, + #[arg(long, value_parser = parse_private_key, help = "Private key to sign the auth")] + private_key: SecretKey, + #[arg(long, required = false, help = "Nonce of the signer")] + nonce: Option, + #[arg(long, required = false, help = "Chain id of the network")] + chain_id: Option, + #[arg(long, default_value = "http://localhost:8545", env = "RPC_URL")] + rpc_url: Url, + }, } impl Command { @@ -662,6 +676,38 @@ impl Command { print_calldata(0, elem); } } + Command::Auth { + delegated_address, + private_key, + nonce, + chain_id, + rpc_url, + } => { + let client = EthClient::new(rpc_url)?; + + let chain_id = if let Some(chain_id) = chain_id { + chain_id + } else { + client.get_chain_id().await?.as_u64() + }; + + let nonce = if let Some(nonce) = nonce { + nonce + } else { + client + .get_nonce( + get_address_from_secret_key(&private_key) + .map_err(|e| eyre::eyre!(e))?, + BlockIdentifier::Tag(BlockTag::Latest), + ) + .await? + }; + + let auth_tuple = make_auth_tuple(&private_key, chain_id, delegated_address, nonce); + let mut buf = Vec::new(); + auth_tuple.encode(&mut buf); + println!("0x{:x}", Bytes::from(buf)); + } }; Ok(()) } diff --git a/cli/src/commands/l2.rs b/cli/src/commands/l2.rs index b259bf6..d23765d 100644 --- a/cli/src/commands/l2.rs +++ b/cli/src/commands/l2.rs @@ -302,6 +302,7 @@ pub(crate) enum Command { )] block: Option, #[arg( + long, default_value = "http://localhost:1729", env = "RPC_URL", help = "L2 RPC URL" @@ -311,6 +312,7 @@ pub(crate) enum Command { #[clap(about = "Get the latest batch number")] BatchNumber { #[arg( + long, default_value = "http://localhost:1729", env = "RPC_URL", help = "L2 RPC URL" @@ -327,12 +329,25 @@ pub(crate) enum Command { )] batch_number: Option, #[arg( + long, default_value = "http://localhost:1729", env = "RPC_URL", help = "L2 RPC URL" )] rpc_url: Url, }, + // #[clap(about = "Send an ethrex sponsored transaction")] + // SponsorTx { + // #[clap(flatten)] + // args: SendArgs, + // #[arg( + // long, + // default_value = "http://localhost:1729", + // env = "RPC_URL", + // help = "L2 RPC URL" + // )] + // rpc_url: Url, + // }, } impl Command { @@ -669,7 +684,7 @@ impl Command { ); println!(" Commit tx: {commit_tx}"); println!(" Verify tx: {verify_tx}"); - } + } // Command::SponsorTx { rpc_url } => {} }; Ok(()) } diff --git a/sdk/src/utils.rs b/sdk/src/utils.rs index 08bf912..9136e08 100644 --- a/sdk/src/utils.rs +++ b/sdk/src/utils.rs @@ -1,6 +1,9 @@ -use ethrex_common::H256; +use ethrex_common::types::AuthorizationTuple; +use ethrex_common::{Address, H256, U256}; +use ethrex_rlp::encode::RLPEncode; use keccak_hash::keccak; -use secp256k1::SecretKey; +use secp256k1::ecdsa::RecoverableSignature; +use secp256k1::{Message, Secp256k1, SecretKey}; use serde::{Deserialize, Deserializer, Serialize, Serializer}; pub fn secret_key_deserializer<'de, D>(deserializer: D) -> Result @@ -48,3 +51,38 @@ pub fn to_checksum_address(address: &str) -> String { checksummed } + +// MAGIC is 0x05 (crates/vm/levm/src/constants.rs) +const MAGIC: u8 = 0x05; + +pub fn make_auth_tuple( + signing_key: &SecretKey, + chain_id: u64, + delegated_code_addr: Address, + nonce: u64, +) -> AuthorizationTuple { + // keccak256(MAGIC || rlp([chain_id, address, nonce])) + let mut buf = Vec::with_capacity(1 + 128); + buf.push(MAGIC); + (U256::from(chain_id), delegated_code_addr, nonce).encode(&mut buf); + let digest = keccak(&buf); + let msg = Message::from_digest(digest.into()); + + let secp = Secp256k1::new(); + let sig: RecoverableSignature = secp.sign_ecdsa_recoverable(&msg, signing_key); + let (rec_id, sig_bytes) = sig.serialize_compact(); + + // Split r,s and y_parity + let r_signature = U256::from_big_endian(&sig_bytes[0..32]); + let s_signature = U256::from_big_endian(&sig_bytes[32..64]); + let y_parity = U256::from(Into::::into(rec_id)); + + AuthorizationTuple { + chain_id: U256::from(chain_id), + address: delegated_code_addr, + nonce, + y_parity, + r_signature, + s_signature, + } +} From 2adf6394fddfb48f979c28ad2b915493e95f0cf8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Paradelo?= Date: Thu, 27 Nov 2025 12:09:05 -0300 Subject: [PATCH 09/18] add batch number --- Cargo.lock | 325 +++++++++++++++++----------------- Cargo.toml | 14 +- cli/src/cli.rs | 14 +- cli/src/commands/l2.rs | 24 ++- cli/tests/tests.rs | 10 +- sdk/examples/keystore/main.rs | 4 +- sdk/examples/simple_usage.rs | 2 +- sdk/src/l2/deposit.rs | 4 +- sdk/src/l2/withdraw.rs | 3 +- sdk/tests/tests.rs | 27 +-- 10 files changed, 219 insertions(+), 208 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 64bce91..90111c8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -92,22 +92,22 @@ dependencies = [ [[package]] name = "anstyle-query" -version = "1.1.4" +version = "1.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e231f6134f61b71076a3eab506c379d4f36122f2af15a9ff04415ea4c3339e2" +checksum = "40c48f72fd53cd289104fc64099abca73db4166ad86ea0b4341abe65af83dadc" dependencies = [ - "windows-sys 0.60.2", + "windows-sys 0.61.2", ] [[package]] name = "anstyle-wincon" -version = "3.0.10" +version = "3.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e0633414522a32ffaac8ac6cc8f748e090c5717661fddeea04219e2344f5f2a" +checksum = "291e6a250ff86cd4a820112fb8898808a366d8f9f58ce16d1f538353ad55747d" dependencies = [ "anstyle", "once_cell_polyfill", - "windows-sys 0.60.2", + "windows-sys 0.61.2", ] [[package]] @@ -175,7 +175,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "62945a2f7e6de02a31fe400aa489f0e0f5b2502e69f95f853adb82a96c7a6b60" dependencies = [ "quote", - "syn 2.0.110", + "syn 2.0.111", ] [[package]] @@ -188,7 +188,7 @@ dependencies = [ "num-traits", "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.111", ] [[package]] @@ -227,7 +227,7 @@ checksum = "213888f660fddcca0d257e88e54ac05bca01885f258ccdf695bafd77031bb69d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.111", ] [[package]] @@ -260,7 +260,7 @@ checksum = "9035ad2d096bed7955a320ee7e2230574d28fd3c3a0f186cbea1ff3c7eed5dbb" dependencies = [ "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.111", ] [[package]] @@ -277,9 +277,9 @@ checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8" [[package]] name = "axum" -version = "0.8.6" +version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a18ed336352031311f4e0b4dd2ff392d4fbb370777c9d18d7fc9d7359f73871" +checksum = "5b098575ebe77cb6d14fc7f32749631a6e44edbef6b796f89b020e99ba20d425" dependencies = [ "axum-core", "base64", @@ -508,7 +508,7 @@ checksum = "89385e82b5d1821d2219e0b095efa2cc1f246cbf99080f3be46a1a85c0d392d9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.111", ] [[package]] @@ -525,9 +525,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.10.1" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d71b6127be86fdcfddb610f7182ac57211d4b18a3e9c82eb2d17662f2227ad6a" +checksum = "b35204fbdc0b3f4446b89fc1ac2cf84a8a68971995d0bf2e925ec7cd960f9cb3" dependencies = [ "serde", ] @@ -555,9 +555,9 @@ checksum = "276a59bf2b2c967788139340c9f0c5b12d7fd6630315c15c217e559de85d2609" [[package]] name = "cc" -version = "1.2.45" +version = "1.2.47" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35900b6c8d709fb1d854671ae27aeaa9eec2f8b01b364e1619a40da3e6fe2afe" +checksum = "cd405d82c84ff7f35739f175f67d8b9fb7687a0e84ccdc78bd3568839827cf07" dependencies = [ "find-msvc-tools", "shlex", @@ -584,7 +584,7 @@ dependencies = [ "iana-time-zone", "num-traits", "serde", - "windows-link 0.2.1", + "windows-link", ] [[package]] @@ -599,9 +599,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.51" +version = "4.5.53" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c26d721170e0295f191a69bd9a1f93efcdb0aff38684b61ab5750468972e5f5" +checksum = "c9e340e012a1bf4935f5282ed1436d1489548e8f72308207ea5df0e23d2d03f8" dependencies = [ "clap_builder", "clap_derive", @@ -609,9 +609,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.51" +version = "4.5.53" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75835f0c7bf681bfd05abe44e965760fea999a5286c6eb2d59883634fd02011a" +checksum = "d76b5d13eaa18c901fd2f7fca939fefe3a0727a953561fefdf3b2922b8569d00" dependencies = [ "anstream", "anstyle", @@ -621,9 +621,9 @@ dependencies = [ [[package]] name = "clap_complete" -version = "4.5.60" +version = "4.5.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e602857739c5a4291dfa33b5a298aeac9006185229a700e5810a3ef7272d971" +checksum = "39615915e2ece2550c0149addac32fb5bd312c657f43845bb9088cb9c8a7c992" dependencies = [ "clap", ] @@ -637,7 +637,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.111", ] [[package]] @@ -916,9 +916,9 @@ dependencies = [ [[package]] name = "crypto-common" -version = "0.1.6" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +checksum = "78c8292055d1c1df0cce5d180393dc8cce0abec0a7102adb6c7b1eef6016d60a" dependencies = [ "generic-array", "typenum", @@ -954,7 +954,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.110", + "syn 2.0.111", ] [[package]] @@ -965,7 +965,7 @@ checksum = "d38308df82d1080de0afee5d069fa14b0326a88c14f15c5ccda35b4a6c414c81" dependencies = [ "darling_core", "quote", - "syn 2.0.110", + "syn 2.0.111", ] [[package]] @@ -1025,7 +1025,7 @@ dependencies = [ "convert_case", "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.111", "unicode-xid", ] @@ -1083,7 +1083,7 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.111", ] [[package]] @@ -1115,7 +1115,7 @@ dependencies = [ "enum-ordinalize", "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.111", ] [[package]] @@ -1176,7 +1176,7 @@ checksum = "8ca9601fb2d62598ee17836250842873a413586e5d7ed88b356e38ddbb0ec631" dependencies = [ "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.111", ] [[package]] @@ -1262,7 +1262,7 @@ dependencies = [ [[package]] name = "ethrex-blockchain" version = "7.0.0" -source = "git+https://github.com/lambdaclass/ethrex?tag=v7.0.0#f7cae770c6a8d78f355cb2f0afdcadfd75b14eba" +source = "git+https://github.com/lambdaclass/ethrex?branch=batch_number_function#0562b2495dbc9d5153032a89a8bf307669afd599" dependencies = [ "bytes", "ethrex-common", @@ -1274,7 +1274,6 @@ dependencies = [ "ethrex-vm", "hex", "rustc-hash", - "secp256k1", "thiserror 2.0.17", "tokio", "tokio-util", @@ -1284,7 +1283,7 @@ dependencies = [ [[package]] name = "ethrex-common" version = "7.0.0" -source = "git+https://github.com/lambdaclass/ethrex?tag=v7.0.0#f7cae770c6a8d78f355cb2f0afdcadfd75b14eba" +source = "git+https://github.com/lambdaclass/ethrex?branch=batch_number_function#0562b2495dbc9d5153032a89a8bf307669afd599" dependencies = [ "bytes", "crc32fast", @@ -1293,6 +1292,7 @@ dependencies = [ "ethrex-rlp", "ethrex-trie", "hex", + "k256", "kzg-rs", "lazy_static", "libc", @@ -1304,6 +1304,7 @@ dependencies = [ "serde", "serde_json", "sha2", + "sha3", "thiserror 2.0.17", "tinyvec", "tracing", @@ -1313,7 +1314,7 @@ dependencies = [ [[package]] name = "ethrex-crypto" version = "7.0.0" -source = "git+https://github.com/lambdaclass/ethrex?tag=v7.0.0#f7cae770c6a8d78f355cb2f0afdcadfd75b14eba" +source = "git+https://github.com/lambdaclass/ethrex?branch=batch_number_function#0562b2495dbc9d5153032a89a8bf307669afd599" dependencies = [ "c-kzg", "kzg-rs", @@ -1324,7 +1325,7 @@ dependencies = [ [[package]] name = "ethrex-l2-common" version = "7.0.0" -source = "git+https://github.com/lambdaclass/ethrex?tag=v7.0.0#f7cae770c6a8d78f355cb2f0afdcadfd75b14eba" +source = "git+https://github.com/lambdaclass/ethrex?branch=batch_number_function#0562b2495dbc9d5153032a89a8bf307669afd599" dependencies = [ "bytes", "ethereum-types", @@ -1335,18 +1336,20 @@ dependencies = [ "ethrex-trie", "ethrex-vm", "hex", + "k256", "lambdaworks-crypto", "rkyv", "secp256k1", "serde", "serde_with", + "sha3", "thiserror 2.0.17", ] [[package]] name = "ethrex-l2-rpc" version = "7.0.0" -source = "git+https://github.com/lambdaclass/ethrex?tag=v7.0.0#f7cae770c6a8d78f355cb2f0afdcadfd75b14eba" +source = "git+https://github.com/lambdaclass/ethrex?branch=batch_number_function#0562b2495dbc9d5153032a89a8bf307669afd599" dependencies = [ "axum", "bytes", @@ -1376,7 +1379,7 @@ dependencies = [ [[package]] name = "ethrex-levm" version = "7.0.0" -source = "git+https://github.com/lambdaclass/ethrex?tag=v7.0.0#f7cae770c6a8d78f355cb2f0afdcadfd75b14eba" +source = "git+https://github.com/lambdaclass/ethrex?branch=batch_number_function#0562b2495dbc9d5153032a89a8bf307669afd599" dependencies = [ "ark-bn254", "ark-ec", @@ -1400,6 +1403,7 @@ dependencies = [ "serde", "serde_json", "sha2", + "sha3", "strum", "thiserror 2.0.17", "walkdir", @@ -1408,7 +1412,7 @@ dependencies = [ [[package]] name = "ethrex-metrics" version = "7.0.0" -source = "git+https://github.com/lambdaclass/ethrex?tag=v7.0.0#f7cae770c6a8d78f355cb2f0afdcadfd75b14eba" +source = "git+https://github.com/lambdaclass/ethrex?branch=batch_number_function#0562b2495dbc9d5153032a89a8bf307669afd599" dependencies = [ "axum", "ethrex-common", @@ -1424,7 +1428,7 @@ dependencies = [ [[package]] name = "ethrex-p2p" version = "7.0.0" -source = "git+https://github.com/lambdaclass/ethrex?tag=v7.0.0#f7cae770c6a8d78f355cb2f0afdcadfd75b14eba" +source = "git+https://github.com/lambdaclass/ethrex?branch=batch_number_function#0562b2495dbc9d5153032a89a8bf307669afd599" dependencies = [ "aes", "async-trait", @@ -1444,7 +1448,7 @@ dependencies = [ "futures", "hex", "hmac", - "indexmap 2.12.0", + "indexmap 2.12.1", "lazy_static", "prometheus 0.14.0", "rand 0.8.5", @@ -1466,7 +1470,7 @@ dependencies = [ [[package]] name = "ethrex-rlp" version = "7.0.0" -source = "git+https://github.com/lambdaclass/ethrex?tag=v7.0.0#f7cae770c6a8d78f355cb2f0afdcadfd75b14eba" +source = "git+https://github.com/lambdaclass/ethrex?branch=batch_number_function#0562b2495dbc9d5153032a89a8bf307669afd599" dependencies = [ "bytes", "ethereum-types", @@ -1480,7 +1484,7 @@ dependencies = [ [[package]] name = "ethrex-rpc" version = "7.0.0" -source = "git+https://github.com/lambdaclass/ethrex?tag=v7.0.0#f7cae770c6a8d78f355cb2f0afdcadfd75b14eba" +source = "git+https://github.com/lambdaclass/ethrex?branch=batch_number_function#0562b2495dbc9d5153032a89a8bf307669afd599" dependencies = [ "axum", "axum-extra", @@ -1519,7 +1523,7 @@ dependencies = [ [[package]] name = "ethrex-sdk" version = "7.0.0" -source = "git+https://github.com/lambdaclass/ethrex?tag=v7.0.0#f7cae770c6a8d78f355cb2f0afdcadfd75b14eba" +source = "git+https://github.com/lambdaclass/ethrex?branch=batch_number_function#0562b2495dbc9d5153032a89a8bf307669afd599" dependencies = [ "bytes", "ethereum-types", @@ -1545,7 +1549,7 @@ dependencies = [ [[package]] name = "ethrex-sdk-contract-utils" version = "7.0.0" -source = "git+https://github.com/lambdaclass/ethrex?tag=v7.0.0#f7cae770c6a8d78f355cb2f0afdcadfd75b14eba" +source = "git+https://github.com/lambdaclass/ethrex?branch=batch_number_function#0562b2495dbc9d5153032a89a8bf307669afd599" dependencies = [ "thiserror 2.0.17", "tracing", @@ -1554,7 +1558,7 @@ dependencies = [ [[package]] name = "ethrex-storage" version = "7.0.0" -source = "git+https://github.com/lambdaclass/ethrex?tag=v7.0.0#f7cae770c6a8d78f355cb2f0afdcadfd75b14eba" +source = "git+https://github.com/lambdaclass/ethrex?branch=batch_number_function#0562b2495dbc9d5153032a89a8bf307669afd599" dependencies = [ "anyhow", "async-trait", @@ -1566,6 +1570,7 @@ dependencies = [ "ethrex-rlp", "ethrex-trie", "hex", + "lru", "qfilter", "rayon", "rustc-hash", @@ -1578,7 +1583,7 @@ dependencies = [ [[package]] name = "ethrex-storage-rollup" version = "7.0.0" -source = "git+https://github.com/lambdaclass/ethrex?tag=v7.0.0#f7cae770c6a8d78f355cb2f0afdcadfd75b14eba" +source = "git+https://github.com/lambdaclass/ethrex?branch=batch_number_function#0562b2495dbc9d5153032a89a8bf307669afd599" dependencies = [ "anyhow", "async-trait", @@ -1598,7 +1603,7 @@ dependencies = [ [[package]] name = "ethrex-threadpool" version = "0.1.0" -source = "git+https://github.com/lambdaclass/ethrex?tag=v7.0.0#f7cae770c6a8d78f355cb2f0afdcadfd75b14eba" +source = "git+https://github.com/lambdaclass/ethrex?branch=batch_number_function#0562b2495dbc9d5153032a89a8bf307669afd599" dependencies = [ "crossbeam 0.8.4", ] @@ -1606,7 +1611,7 @@ dependencies = [ [[package]] name = "ethrex-trie" version = "7.0.0" -source = "git+https://github.com/lambdaclass/ethrex?tag=v7.0.0#f7cae770c6a8d78f355cb2f0afdcadfd75b14eba" +source = "git+https://github.com/lambdaclass/ethrex?branch=batch_number_function#0562b2495dbc9d5153032a89a8bf307669afd599" dependencies = [ "anyhow", "bytes", @@ -1618,6 +1623,7 @@ dependencies = [ "ethrex-threadpool", "hex", "lazy_static", + "rkyv", "rustc-hash", "serde", "serde_json", @@ -1629,7 +1635,7 @@ dependencies = [ [[package]] name = "ethrex-vm" version = "7.0.0" -source = "git+https://github.com/lambdaclass/ethrex?tag=v7.0.0#f7cae770c6a8d78f355cb2f0afdcadfd75b14eba" +source = "git+https://github.com/lambdaclass/ethrex?branch=batch_number_function#0562b2495dbc9d5153032a89a8bf307669afd599" dependencies = [ "bincode", "bytes", @@ -1705,9 +1711,9 @@ dependencies = [ [[package]] name = "find-msvc-tools" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52051878f80a721bb68ebfbc930e07b65ba72f2da88968ea5c06fd6ca3d3a127" +checksum = "3a3076410a55c90011c298b04d0cfa770b00fa04e1e3c97d3f6c9de105a03844" [[package]] name = "fixed-hash" @@ -1733,6 +1739,12 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" +[[package]] +name = "foldhash" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77ce24cb58228fbb8aa041425bb1050850ac19177686ea6e0f41a70416f56fdb" + [[package]] name = "foreign-types" version = "0.3.2" @@ -1819,7 +1831,7 @@ checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.111", ] [[package]] @@ -1860,9 +1872,9 @@ checksum = "1d758ba1b47b00caf47f24925c0074ecb20d6dfcffe7f6d53395c0465674841a" [[package]] name = "generic-array" -version = "0.14.9" +version = "0.14.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bb6743198531e02858aeaea5398fcc883e71851fcbcb5a2f773e2fb6cb1edf2" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" dependencies = [ "typenum", "version_check", @@ -1923,7 +1935,7 @@ dependencies = [ "futures-core", "futures-sink", "http", - "indexmap 2.12.0", + "indexmap 2.12.1", "slab", "tokio", "tokio-util", @@ -1943,14 +1955,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1" dependencies = [ "allocator-api2", - "foldhash", + "foldhash 0.1.5", ] [[package]] name = "hashbrown" -version = "0.16.0" +version = "0.16.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5419bdc4f6a9207fbeba6d11b604d481addf78ecd10c11ad51e76c2f6482748d" +checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100" +dependencies = [ + "allocator-api2", + "equivalent", + "foldhash 0.2.0", +] [[package]] name = "headers" @@ -1996,9 +2013,9 @@ checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" [[package]] name = "hex-conservative" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5313b072ce3c597065a808dbf612c4c8e8590bdbf8b579508bf7a762c5eae6cd" +checksum = "fda06d18ac606267c40c04e41b9947729bf8b9efe74bd4e82b61a5f26a510b9f" dependencies = [ "arrayvec", ] @@ -2020,12 +2037,11 @@ dependencies = [ [[package]] name = "http" -version = "1.3.1" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4a85d31aea989eead29a3aaf9e1115a180df8282431156e533de47660892565" +checksum = "e3ba2a386d7f85a81f119ad7498ebe444d2e22c2af0b86b069416ace48b3311a" dependencies = [ "bytes", - "fnv", "itoa", ] @@ -2066,9 +2082,9 @@ checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" [[package]] name = "hyper" -version = "1.7.0" +version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb3aa54a13a0dfe7fbe3a59e0c76093041720fdc77b110cc0fc260fafb4dc51e" +checksum = "2ab2d4f250c3d7b1c9fcdff1cece94ea4e2dfbec68614f7b87cb205f24ca9d11" dependencies = [ "atomic-waker", "bytes", @@ -2121,9 +2137,9 @@ dependencies = [ [[package]] name = "hyper-util" -version = "0.1.17" +version = "0.1.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c6995591a8f1380fcb4ba966a252a4b29188d51d2b89e3a252f5305be65aea8" +checksum = "52e9a2a24dc5c6821e71a7030e1e14b7b632acac55c40e9d2e082c621261bb56" dependencies = [ "base64", "bytes", @@ -2312,7 +2328,7 @@ checksum = "a0eb5a3343abf848c0984fe4604b2b105da9539376e24fc0a3b0007411ae4fd9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.111", ] [[package]] @@ -2334,12 +2350,12 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.12.0" +version = "2.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6717a8d2a5a929a1a2eb43a12812498ed141a0bcfb7e8f7844fbdbe4303bba9f" +checksum = "0ad4bb2b565bca0645f4d68c5c9af97fba094e9791da685bf83cb5f3ce74acf2" dependencies = [ "equivalent", - "hashbrown 0.16.0", + "hashbrown 0.16.1", "serde", "serde_core", ] @@ -2582,6 +2598,15 @@ version = "0.4.28" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "34080505efa8e45a4b816c349525ebe327ceaa8559756f0356cba97ef3bf7432" +[[package]] +name = "lru" +version = "0.16.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96051b46fc183dc9cd4a223960ef37b9af631b55191852a8274bfef064cda20f" +dependencies = [ + "hashbrown 0.16.1", +] + [[package]] name = "malachite" version = "0.6.1" @@ -2698,7 +2723,7 @@ checksum = "4568f25ccbd45ab5d5603dc34318c1ec56b117531781260002151b8530a9f931" dependencies = [ "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.111", ] [[package]] @@ -2817,7 +2842,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.111", ] [[package]] @@ -3002,7 +3027,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.111", ] [[package]] @@ -3025,7 +3050,7 @@ dependencies = [ "libc", "redox_syscall", "smallvec", - "windows-link 0.2.1", + "windows-link", ] [[package]] @@ -3258,7 +3283,7 @@ checksum = "7347867d0a7e1208d93b46767be83e2b8f978c3dad35f775ac8d8847551d6fe1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.111", ] [[package]] @@ -3416,7 +3441,7 @@ checksum = "b7186006dcb21920990093f30e3dea63b7d6e977bf1256be20c3563a5db070da" dependencies = [ "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.111", ] [[package]] @@ -3592,7 +3617,7 @@ dependencies = [ "bytecheck", "bytes", "hashbrown 0.15.5", - "indexmap 2.12.0", + "indexmap 2.12.1", "munge", "ptr_meta", "rancor", @@ -3610,7 +3635,7 @@ checksum = "bd83f5f173ff41e00337d97f6572e416d022ef8a19f371817259ae960324c482" dependencies = [ "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.111", ] [[package]] @@ -3645,7 +3670,7 @@ dependencies = [ "errno", "libc", "linux-raw-sys 0.4.15", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -3877,7 +3902,7 @@ checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" dependencies = [ "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.111", ] [[package]] @@ -3927,15 +3952,15 @@ dependencies = [ [[package]] name = "serde_with" -version = "3.15.1" +version = "3.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa66c845eee442168b2c8134fec70ac50dc20e760769c8ba0ad1319ca1959b04" +checksum = "10574371d41b0d9b2cff89418eda27da52bcaff2cc8741db26382a77c29131f1" dependencies = [ "base64", "chrono", "hex", "indexmap 1.9.3", - "indexmap 2.12.0", + "indexmap 2.12.1", "schemars 0.9.0", "schemars 1.1.0", "serde_core", @@ -3946,14 +3971,14 @@ dependencies = [ [[package]] name = "serde_with_macros" -version = "3.15.1" +version = "3.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b91a903660542fced4e99881aa481bdbaec1634568ee02e0b8bd57c64cb38955" +checksum = "08a72d8216842fdd57820dc78d840bef99248e35fb2554ff923319e60f2d686b" dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.111", ] [[package]] @@ -4011,9 +4036,9 @@ checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" [[package]] name = "signal-hook-registry" -version = "1.4.6" +version = "1.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2a4719bff48cee6b39d12c020eeb490953ad2443b7055bd0b21fca26bd8c28b" +checksum = "7664a098b8e616bdfcc2dc0e9ac44eb231eedf41db4e9fe95d8d32ec728dedad" dependencies = [ "libc", ] @@ -4076,9 +4101,9 @@ dependencies = [ [[package]] name = "sp1-lib" -version = "5.2.2" +version = "5.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fce8ad0f153443d09d398eccb650a0b2dcbf829470e394e4bf60ec4379c7af93" +checksum = "eb1a9935d58cb1dcd757a1b10d727090f5b718f1f03b512d48f0c1952e6ead00" dependencies = [ "bincode", "serde", @@ -4087,9 +4112,9 @@ dependencies = [ [[package]] name = "sp1-primitives" -version = "5.2.2" +version = "5.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0244dee3a7a0f88cf71c3edf518f4fc97794ae870a107cbe7c810ac3fbf879cb" +checksum = "a7d2a6187e394c30097ea7a975a4832f172918690dc89a979f0fad67422d3a8b" dependencies = [ "bincode", "blake3", @@ -4210,7 +4235,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.111", ] [[package]] @@ -4232,9 +4257,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.110" +version = "2.0.111" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a99801b5bd34ede4cf3fc688c5919368fea4e4814a4664359503e6015b280aea" +checksum = "390cc9a294ab71bdb1aa2e99d13be9c753cd2d7bd6560c77118597410c4d2e87" dependencies = [ "proc-macro2", "quote", @@ -4258,7 +4283,7 @@ checksum = "728a70f3dbaf5bab7f0c4b1ac8d7ae5ea60a4b5549c8a5914361c99147a709d2" dependencies = [ "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.111", ] [[package]] @@ -4327,7 +4352,7 @@ checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.111", ] [[package]] @@ -4338,7 +4363,7 @@ checksum = "3ff15c8ecd7de3849db632e14d18d2571fa09dfc5ed93479bc4485c7a517c913" dependencies = [ "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.111", ] [[package]] @@ -4449,7 +4474,7 @@ checksum = "af407857209536a95c8e56f8231ef2c2e2aff839b22e07a1ffcbc617e9db9fa5" dependencies = [ "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.111", ] [[package]] @@ -4546,7 +4571,7 @@ version = "0.22.27" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "41fe8c660ae4257887cf66394862d21dbca4a6ddd26f04a3560410406a2f819a" dependencies = [ - "indexmap 2.12.0", + "indexmap 2.12.1", "serde", "serde_spanned", "toml_datetime 0.6.11", @@ -4560,7 +4585,7 @@ version = "0.23.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6485ef6d0d9b5d0ec17244ff7eb05310113c3f316f2d14200d4de56b3cb98f8d" dependencies = [ - "indexmap 2.12.0", + "indexmap 2.12.1", "toml_datetime 0.7.3", "toml_parser", "winnow", @@ -4599,9 +4624,9 @@ dependencies = [ [[package]] name = "tower-http" -version = "0.6.6" +version = "0.6.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adc82fd73de2a9722ac5da747f12383d2bfdb93591ee6c58486e0097890f05f2" +checksum = "9cf146f99d442e8e68e585f5d798ccd3cad9a7835b917e09728880a862706456" dependencies = [ "bitflags", "bytes", @@ -4641,20 +4666,20 @@ dependencies = [ [[package]] name = "tracing-attributes" -version = "0.1.30" +version = "0.1.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81383ab64e72a7a8b8e13130c49e3dab29def6d0c7d76a03087b3cf71c5c6903" +checksum = "7490cfa5ec963746568740651ac6781f701c9c5ea257c58e057f3ba8cf69e8da" dependencies = [ "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.111", ] [[package]] name = "tracing-core" -version = "0.1.34" +version = "0.1.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9d12581f227e93f094d3af2ae690a574abb8a2b9b7a96e7cfe9647b2b617678" +checksum = "7a04e24fab5c89c6a36eb8558c9656f30d81de51dfa4d3b45f26b21d61fa0a6c" dependencies = [ "once_cell", "valuable", @@ -4908,7 +4933,7 @@ dependencies = [ "bumpalo", "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.111", "wasm-bindgen-shared", ] @@ -4958,9 +4983,9 @@ checksum = "b8e83a14d34d0623b51dce9581199302a221863196a1dde71a7663a4c2be9deb" dependencies = [ "windows-implement", "windows-interface", - "windows-link 0.2.1", - "windows-result 0.4.1", - "windows-strings 0.5.1", + "windows-link", + "windows-result", + "windows-strings", ] [[package]] @@ -4971,7 +4996,7 @@ checksum = "053e2e040ab57b9dc951b72c264860db7eb3b0200ba345b4e4c3b14f67855ddf" dependencies = [ "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.111", ] [[package]] @@ -4982,15 +5007,9 @@ checksum = "3f316c4a2570ba26bbec722032c4099d8c8bc095efccdc15688708623367e358" dependencies = [ "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.111", ] -[[package]] -name = "windows-link" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e6ad25900d524eaabdbbb96d20b4311e1e7ae1699af4fb28c17ae66c80d798a" - [[package]] name = "windows-link" version = "0.2.1" @@ -4999,22 +5018,13 @@ checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" [[package]] name = "windows-registry" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b8a9ed28765efc97bbc954883f4e6796c33a06546ebafacbabee9696967499e" -dependencies = [ - "windows-link 0.1.3", - "windows-result 0.3.4", - "windows-strings 0.4.2", -] - -[[package]] -name = "windows-result" -version = "0.3.4" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56f42bd332cc6c8eac5af113fc0c1fd6a8fd2aa08a0119358686e5160d0586c6" +checksum = "02752bf7fbdcce7f2a27a742f798510f3e5ad88dbe84871e5168e2120c3d5720" dependencies = [ - "windows-link 0.1.3", + "windows-link", + "windows-result", + "windows-strings", ] [[package]] @@ -5023,16 +5033,7 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7781fa89eaf60850ac3d2da7af8e5242a5ea78d1a11c49bf2910bb5a73853eb5" dependencies = [ - "windows-link 0.2.1", -] - -[[package]] -name = "windows-strings" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56e6c93f3a0c3b36176cb1327a4958a0353d5d166c2a35cb268ace15e91d3b57" -dependencies = [ - "windows-link 0.1.3", + "windows-link", ] [[package]] @@ -5041,7 +5042,7 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7837d08f69c77cf6b07689544538e017c1bfcf57e34b4c0ff58e6c2cd3b37091" dependencies = [ - "windows-link 0.2.1", + "windows-link", ] [[package]] @@ -5077,7 +5078,7 @@ version = "0.61.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" dependencies = [ - "windows-link 0.2.1", + "windows-link", ] [[package]] @@ -5102,7 +5103,7 @@ version = "0.53.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4945f9f551b88e0d65f3db0bc25c33b8acea4d9e41163edf90dcd0b19f9069f3" dependencies = [ - "windows-link 0.2.1", + "windows-link", "windows_aarch64_gnullvm 0.53.1", "windows_aarch64_msvc 0.53.1", "windows_i686_gnu 0.53.1", @@ -5211,9 +5212,9 @@ checksum = "d6bbff5f0aada427a1e5a6da5f1f98158182f26556f345ac9e04d36d0ebed650" [[package]] name = "winnow" -version = "0.7.13" +version = "0.7.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21a0236b59786fed61e2a80582dd500fe61f18b5dca67a4a067d0bc9039339cf" +checksum = "5a5364e9d77fcdeeaa6062ced926ee3381faa2ee02d3eb83a5c27a8825540829" dependencies = [ "memchr", ] @@ -5264,28 +5265,28 @@ checksum = "b659052874eb698efe5b9e8cf382204678a0086ebf46982b79d6ca3182927e5d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.111", "synstructure", ] [[package]] name = "zerocopy" -version = "0.8.27" +version = "0.8.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0894878a5fa3edfd6da3f88c4805f4c8558e2b996227a3d864f47fe11e38282c" +checksum = "4ea879c944afe8a2b25fef16bb4ba234f47c694565e97383b36f3a878219065c" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.8.27" +version = "0.8.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88d2b8d9c68ad2b9e4340d7832716a4d21a22a1154777ad56ea55c51a9cf3831" +checksum = "cf955aa904d6040f70dc8e9384444cb1030aed272ba3cb09bbc4ab9e7c1f34f5" dependencies = [ "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.111", ] [[package]] @@ -5305,7 +5306,7 @@ checksum = "d71e5d6e06ab090c67b5e44993ec16b72dcbaabc526db883a360057678b48502" dependencies = [ "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.111", "synstructure", ] @@ -5326,7 +5327,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.111", ] [[package]] @@ -5359,5 +5360,5 @@ checksum = "eadce39539ca5cb3985590102671f2567e659fca9666581ad3411d59207951f3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.111", ] diff --git a/Cargo.toml b/Cargo.toml index d8996ed..80c36b5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -29,13 +29,13 @@ manual_saturating_arithmetic = "warn" rex-cli = { path = "cli" } rex-sdk = { path = "sdk" } -ethrex-common = { git = "https://github.com/lambdaclass/ethrex", package = "ethrex-common", tag = "v7.0.0" } -ethrex-blockchain = { git = "https://github.com/lambdaclass/ethrex", package = "ethrex-blockchain", tag = "v7.0.0" } -ethrex-rlp = { git = "https://github.com/lambdaclass/ethrex", package = "ethrex-rlp", tag = "v7.0.0" } -ethrex-rpc = { git = "https://github.com/lambdaclass/ethrex", package = "ethrex-rpc", tag = "v7.0.0" } -ethrex-l2-rpc = { git = "https://github.com/lambdaclass/ethrex", package = "ethrex-l2-rpc", tag = "v7.0.0" } -ethrex-sdk = { git = "https://github.com/lambdaclass/ethrex", package = "ethrex-sdk", tag = "v7.0.0" } -ethrex-l2-common = { git = "https://github.com/lambdaclass/ethrex", package = "ethrex-l2-common", tag = "v7.0.0" } +ethrex-common = { git = "https://github.com/lambdaclass/ethrex", package = "ethrex-common", branch = "batch_number_function" } +ethrex-blockchain = { git = "https://github.com/lambdaclass/ethrex", package = "ethrex-blockchain", branch = "batch_number_function" } +ethrex-rlp = { git = "https://github.com/lambdaclass/ethrex", package = "ethrex-rlp", branch = "batch_number_function" } +ethrex-rpc = { git = "https://github.com/lambdaclass/ethrex", package = "ethrex-rpc", branch = "batch_number_function" } +ethrex-l2-rpc = { git = "https://github.com/lambdaclass/ethrex", package = "ethrex-l2-rpc", branch = "batch_number_function" } +ethrex-sdk = { git = "https://github.com/lambdaclass/ethrex", package = "ethrex-sdk", branch = "batch_number_function" } +ethrex-l2-common = { git = "https://github.com/lambdaclass/ethrex", package = "ethrex-l2-common", branch = "batch_number_function" } keccak-hash = "0.11.0" thiserror = "2.0.11" diff --git a/cli/src/cli.rs b/cli/src/cli.rs index 32fd5da..4c94787 100644 --- a/cli/src/cli.rs +++ b/cli/src/cli.rs @@ -415,7 +415,8 @@ impl Command { random, } => { let address = if let Some(private_key) = from_private_key { - get_address_from_secret_key(&private_key).map_err(|e| eyre::eyre!(e))? + get_address_from_secret_key(&private_key.secret_bytes()) + .map_err(|e| eyre::eyre!(e))? } else if zero { Address::zero() } else if random { @@ -460,8 +461,8 @@ impl Command { todo!("Display transaction URL in the explorer") } - let from = - get_address_from_secret_key(&args.private_key).map_err(|e| eyre::eyre!(e))?; + let from = get_address_from_secret_key(&args.private_key.secret_bytes()) + .map_err(|e| eyre::eyre!(e))?; let client = EthClient::new(rpc_url)?; @@ -487,8 +488,8 @@ impl Command { todo!("Display transaction URL in the explorer") } - let from = - get_address_from_secret_key(&args.private_key).map_err(|e| eyre::eyre!(e))?; + let from = get_address_from_secret_key(&args.private_key.secret_bytes()) + .map_err(|e| eyre::eyre!(e))?; let client = EthClient::new(rpc_url)?; @@ -696,7 +697,7 @@ impl Command { } else { client .get_nonce( - get_address_from_secret_key(&private_key) + get_address_from_secret_key(&private_key.secret_bytes()) .map_err(|e| eyre::eyre!(e))?, BlockIdentifier::Tag(BlockTag::Latest), ) @@ -817,6 +818,7 @@ async fn compile_contract_from_path(args: DeployArgs) -> eyre::Result { output_dir, contract_path, false, + false, // TODO: review this change Some(&solc_remappings_ref), &include_paths, ) diff --git a/cli/src/commands/l2.rs b/cli/src/commands/l2.rs index d23765d..335a819 100644 --- a/cli/src/commands/l2.rs +++ b/cli/src/commands/l2.rs @@ -7,11 +7,11 @@ use clap::Subcommand; use ethrex_common::types::TxType; use ethrex_common::{Address, H256, U256}; use ethrex_l2_common::utils::get_address_from_secret_key; -use ethrex_l2_rpc::clients::get_batch_by_number; use ethrex_l2_rpc::clients::{ get_base_fee_vault_address, get_l1_blob_base_fee_per_gas, get_l1_fee_vault_address, get_operator_fee, get_operator_fee_vault_address, }; +use ethrex_l2_rpc::clients::{get_batch_by_number, get_batch_number}; use ethrex_rpc::clients::Overrides; use ethrex_rpc::{ EthClient, @@ -367,7 +367,8 @@ impl Command { } => { let eth_client = EthClient::new(l1_rpc_url)?; let to = to.unwrap_or( - get_address_from_secret_key(&private_key).map_err(|e| eyre::eyre!(e))?, + get_address_from_secret_key(&private_key.secret_bytes()) + .map_err(|e| eyre::eyre!(e))?, ); if explorer_url { todo!("Display transaction URL in the explorer") @@ -378,8 +379,8 @@ impl Command { let token_l2 = token_l2.expect( "Token address on L2 is required if token address on L1 is specified", ); - let from = - get_address_from_secret_key(&private_key).map_err(|e| eyre::eyre!(e))?; + let from = get_address_from_secret_key(&private_key.secret_bytes()) + .map_err(|e| eyre::eyre!(e))?; println!( "Depositing {amount} from {from:#x} to L2 token {token_l2:#x} using L1 token {token_l1:#x}" ); @@ -423,7 +424,8 @@ impl Command { rpc_url, bridge_address, } => { - let from = get_address_from_secret_key(&private_key).map_err(|e| eyre::eyre!(e))?; + let from = get_address_from_secret_key(&private_key.secret_bytes()) + .map_err(|e| eyre::eyre!(e))?; let eth_client = EthClient::new(l1_rpc_url)?; @@ -479,7 +481,8 @@ impl Command { private_key, rpc_url, } => { - let from = get_address_from_secret_key(&private_key).map_err(|e| eyre::eyre!(e))?; + let from = get_address_from_secret_key(&private_key.secret_bytes()) + .map_err(|e| eyre::eyre!(e))?; let client = EthClient::new(rpc_url)?; @@ -556,8 +559,8 @@ impl Command { todo!("Display transaction URL in the explorer") } - let from = - get_address_from_secret_key(&args.private_key).map_err(|e| eyre::eyre!(e))?; + let from = get_address_from_secret_key(&args.private_key.secret_bytes()) + .map_err(|e| eyre::eyre!(e))?; let client = EthClient::new(rpc_url)?; let tx_type = if fee_token.is_some() { @@ -647,7 +650,10 @@ impl Command { println!(" L1 blob base fee (wei/blob-gas): {blob_base_fee}"); } Command::BatchNumber { rpc_url } => { - let _client = EthClient::new(rpc_url)?; + let client = EthClient::new(rpc_url)?; + + let batch_number = get_batch_number(&client).await?; + println!("{batch_number}"); } Command::BatchByNumber { batch_number, diff --git a/cli/tests/tests.rs b/cli/tests/tests.rs index 9667c65..43b5f3f 100644 --- a/cli/tests/tests.rs +++ b/cli/tests/tests.rs @@ -117,7 +117,7 @@ async fn test_deposit( .map(|value| U256::from_dec_str(&value).expect("Invalid deposit value")) .unwrap_or(U256::from(1000000000000000000000u128)); - let depositor_address = get_address_from_secret_key(depositor_private_key)?; + let depositor_address = get_address_from_secret_key(&depositor_private_key.secret_bytes())?; let depositor_l1_initial_balance = get_l1_balance(depositor_address)?; @@ -208,8 +208,8 @@ async fn test_transfer( let transfer_value = std::env::var("INTEGRATION_TEST_TRANSFER_VALUE") .map(|value| U256::from_dec_str(&value).expect("Invalid transfer value")) .unwrap_or(U256::from(100000000000000000000u128)); - let returner_address = get_address_from_secret_key(returnerer_private_key)?; - let transferer_address = get_address_from_secret_key(transferer_private_key)?; + let returner_address = get_address_from_secret_key(&returnerer_private_key.secret_bytes())?; + let transferer_address = get_address_from_secret_key(&transferer_private_key.secret_bytes())?; perform_transfer(transferer_private_key, returner_address, transfer_value).await?; @@ -226,7 +226,7 @@ async fn perform_transfer( transfer_recipient_address: Address, transfer_value: U256, ) -> Result<(), Box> { - let transferer_address = get_address_from_secret_key(transferer_private_key)?; + let transferer_address = get_address_from_secret_key(&transferer_private_key.secret_bytes())?; let transferer_initial_l2_balance = get_l2_balance(transferer_address)?; @@ -404,7 +404,7 @@ async fn test_withdraws( n: u64, ) -> Result<(), Box> { // Withdraw funds from L2 to L1 - let withdrawer_address = get_address_from_secret_key(withdrawer_private_key)?; + let withdrawer_address = get_address_from_secret_key(&withdrawer_private_key.secret_bytes())?; let withdraw_value = std::env::var("INTEGRATION_TEST_WITHDRAW_VALUE") .map(|value| U256::from_dec_str(&value).expect("Invalid withdraw value")) .unwrap_or(U256::from(100000000000000000000u128)); diff --git a/sdk/examples/keystore/main.rs b/sdk/examples/keystore/main.rs index e84fc60..82c2b1c 100644 --- a/sdk/examples/keystore/main.rs +++ b/sdk/examples/keystore/main.rs @@ -46,7 +46,7 @@ async fn main() -> Result<(), Box> { // 3. Load the keystore with the password. let keystore_secret_key = load_keystore_from_path(None, "RexTest", "LambdaClass")?; - let keystore_address = get_address_from_secret_key(&keystore_secret_key)?; + let keystore_address = get_address_from_secret_key(&keystore_secret_key.secret_bytes())?; println!("\nKeystore loaded successfully:"); println!( @@ -64,7 +64,7 @@ async fn main() -> Result<(), Box> { .strip_prefix("0x") .unwrap_or(&args.private_key); let rich_wallet_pk = SecretKey::from_str(pk)?; - let rich_wallet_address = get_address_from_secret_key(&rich_wallet_pk)?; + let rich_wallet_address = get_address_from_secret_key(&rich_wallet_pk.secret_bytes())?; let amount = U256::from_dec_str("1000000000000000000").expect("Failed to parse amount"); let transfer_tx_hash = transfer( amount, diff --git a/sdk/examples/simple_usage.rs b/sdk/examples/simple_usage.rs index 93cfc41..f77ae32 100644 --- a/sdk/examples/simple_usage.rs +++ b/sdk/examples/simple_usage.rs @@ -36,7 +36,7 @@ fn parse_hex(s: &str) -> eyre::Result { async fn main() { let args = SimpleUsageArgs::parse(); - let account = get_address_from_secret_key(&args.private_key).unwrap(); + let account = get_address_from_secret_key(&args.private_key.secret_bytes()).unwrap(); let eth_client = EthClient::new(args.rpc_url).unwrap(); diff --git a/sdk/src/l2/deposit.rs b/sdk/src/l2/deposit.rs index dac817c..61e5c77 100644 --- a/sdk/src/l2/deposit.rs +++ b/sdk/src/l2/deposit.rs @@ -39,8 +39,8 @@ pub async fn deposit_through_contract_call( bridge_address: Address, eth_client: &EthClient, ) -> Result { - let l1_from = - get_address_from_secret_key(depositor_private_key).map_err(EthClientError::Custom)?; + let l1_from = get_address_from_secret_key(&depositor_private_key.secret_bytes()) + .map_err(EthClientError::Custom)?; let calldata = encode_calldata(DEPOSIT_SIGNATURE, &[Value::Address(to)])?; let gas_price = eth_client .get_gas_price_with_extra(20) diff --git a/sdk/src/l2/withdraw.rs b/sdk/src/l2/withdraw.rs index a66c848..d19d7da 100644 --- a/sdk/src/l2/withdraw.rs +++ b/sdk/src/l2/withdraw.rs @@ -134,7 +134,8 @@ pub async fn claim_erc20withdraw( message_proof: &L1MessageProof, bridge_address: Address, ) -> Result { - let from = get_address_from_secret_key(&from_pk).map_err(EthClientError::Custom)?; + let from = + get_address_from_secret_key(&from_pk.secret_bytes()).map_err(EthClientError::Custom)?; let calldata_values = vec![ Value::Address(token_l1), Value::Address(token_l2), diff --git a/sdk/tests/tests.rs b/sdk/tests/tests.rs index 1261b9a..1f91049 100644 --- a/sdk/tests/tests.rs +++ b/sdk/tests/tests.rs @@ -70,8 +70,9 @@ async fn sdk_integration_test() -> Result<(), Box> { let rich_wallet_private_key = l1_rich_wallet_private_key(); let transfer_return_private_key = l2_return_transfer_private_key(); let bridge_address = common_bridge_address(); - let deposit_recipient_address = get_address_from_secret_key(&rich_wallet_private_key) - .expect("Failed to get address from l1 rich wallet pk"); + let deposit_recipient_address = + get_address_from_secret_key(&rich_wallet_private_key.secret_bytes()) + .expect("Failed to get address from l1 rich wallet pk"); test_deposit_through_transfer( &rich_wallet_private_key, @@ -223,7 +224,7 @@ async fn test_deposit_through_transfer( ) -> Result<(), Box> { println!("Fetching initial balances on L1 and L2"); - let depositor = get_address_from_secret_key(depositor_private_key)?; + let depositor = get_address_from_secret_key(&depositor_private_key.secret_bytes())?; let deposit_value = std::env::var("INTEGRATION_TEST_DEPOSIT_VALUE") .map(|value| U256::from_dec_str(&value).expect("Invalid deposit value")) .unwrap_or(U256::from(1000000000000000000000u128)); @@ -333,7 +334,7 @@ async fn test_deposit_through_contract_call( ) -> Result<(), Box> { println!("Fetching initial balances on L1 and L2"); - let depositor = get_address_from_secret_key(depositor_private_key)?; + let depositor = get_address_from_secret_key(&depositor_private_key.secret_bytes())?; let deposit_value = std::env::var("INTEGRATION_TEST_DEPOSIT_VALUE") .map(|value| U256::from_dec_str(&value).expect("Invalid deposit value")) .unwrap_or(U256::from(1000000000000000000000u128)); @@ -438,8 +439,8 @@ async fn test_transfer( let transfer_value = std::env::var("INTEGRATION_TEST_TRANSFER_VALUE") .map(|value| U256::from_dec_str(&value).expect("Invalid transfer value")) .unwrap_or(U256::from(100000000000000000000u128)); - let transferer_address = get_address_from_secret_key(transferer_private_key)?; - let returner_address = get_address_from_secret_key(returnerer_private_key)?; + let transferer_address = get_address_from_secret_key(&transferer_private_key.secret_bytes())?; + let returner_address = get_address_from_secret_key(&returnerer_private_key.secret_bytes())?; perform_transfer( proposer_client, @@ -475,8 +476,8 @@ async fn test_transfer_with_privileged_tx( let transfer_value = std::env::var("INTEGRATION_TEST_TRANSFER_VALUE") .map(|value| U256::from_dec_str(&value).expect("Invalid transfer value")) .unwrap_or(U256::from(100000000000000000000u128)); - let transferer_address = get_address_from_secret_key(transferer_private_key)?; - let receiver_address = get_address_from_secret_key(receiver_private_key)?; + let transferer_address = get_address_from_secret_key(&transferer_private_key.secret_bytes())?; + let receiver_address = get_address_from_secret_key(&receiver_private_key.secret_bytes())?; let receiver_balance_before = proposer_client .get_balance(receiver_address, BlockIdentifier::Tag(BlockTag::Latest)) @@ -519,7 +520,7 @@ async fn test_transfer_with_privileged_tx( async fn test_gas_burning(eth_client: &EthClient) -> Result<(), Box> { println!("Transferring funds on L2 through a deposit"); let rich_private_key = l1_rich_wallet_private_key(); - let rich_address = get_address_from_secret_key(&rich_private_key)?; + let rich_address = get_address_from_secret_key(&rich_private_key.secret_bytes())?; let l2_gas_limit = 2_000_000; let l1_extra_gas_limit = 400_000; @@ -697,7 +698,7 @@ async fn perform_transfer( transfer_recipient_address: Address, transfer_value: U256, ) -> Result<(), Box> { - let transferer_address = get_address_from_secret_key(transferer_private_key)?; + let transferer_address = get_address_from_secret_key(&transferer_private_key.secret_bytes())?; let transferer_initial_l2_balance = proposer_client .get_balance(transferer_address, BlockIdentifier::Tag(BlockTag::Latest)) @@ -888,8 +889,8 @@ async fn test_call_to_contract_with_deposit( proposer_client: &EthClient, eth_client: &EthClient, ) -> Result<(), Box> { - let caller_address = - get_address_from_secret_key(caller_private_key).expect("Failed to get address"); + let caller_address = get_address_from_secret_key(&caller_private_key.secret_bytes()) + .expect("Failed to get address"); println!("Checking balances before call"); @@ -981,7 +982,7 @@ async fn test_n_withdraws( n: u64, ) -> Result<(), Box> { // Withdraw funds from L2 to L1 - let withdrawer_address = get_address_from_secret_key(withdrawer_private_key)?; + let withdrawer_address = get_address_from_secret_key(&withdrawer_private_key.secret_bytes())?; let withdraw_value = std::env::var("INTEGRATION_TEST_WITHDRAW_VALUE") .map(|value| U256::from_dec_str(&value).expect("Invalid withdraw value")) .unwrap_or(U256::from(100000000000000000000u128)); From ddda2d2cf44b8296eb3ebfae5702b5f017cf3199 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Paradelo?= Date: Thu, 27 Nov 2025 12:38:31 -0300 Subject: [PATCH 10/18] sponsored txs compiling, not tested --- cli/src/commands/l2.rs | 61 ++++++++++++++++++++++++++++++------------ 1 file changed, 44 insertions(+), 17 deletions(-) diff --git a/cli/src/commands/l2.rs b/cli/src/commands/l2.rs index 335a819..05b4f89 100644 --- a/cli/src/commands/l2.rs +++ b/cli/src/commands/l2.rs @@ -1,17 +1,18 @@ use crate::{ cli::Command as EthCommand, common::{BalanceArgs, CallArgs, DeployArgs, SendArgs, TransferArgs}, - utils::{parse_private_key, parse_u256}, + utils::{parse_hex, parse_private_key, parse_u256}, }; use clap::Subcommand; -use ethrex_common::types::TxType; -use ethrex_common::{Address, H256, U256}; +use ethrex_common::{Address, H256, U256, types::AuthorizationTuple}; +use ethrex_common::{Bytes, types::TxType}; use ethrex_l2_common::utils::get_address_from_secret_key; use ethrex_l2_rpc::clients::{ get_base_fee_vault_address, get_l1_blob_base_fee_per_gas, get_l1_fee_vault_address, - get_operator_fee, get_operator_fee_vault_address, + get_operator_fee, get_operator_fee_vault_address, send_ethrex_transaction, }; use ethrex_l2_rpc::clients::{get_batch_by_number, get_batch_number}; +use ethrex_rlp::decode::RLPDecode; use ethrex_rpc::clients::Overrides; use ethrex_rpc::{ EthClient, @@ -336,18 +337,22 @@ pub(crate) enum Command { )] rpc_url: Url, }, - // #[clap(about = "Send an ethrex sponsored transaction")] - // SponsorTx { - // #[clap(flatten)] - // args: SendArgs, - // #[arg( - // long, - // default_value = "http://localhost:1729", - // env = "RPC_URL", - // help = "L2 RPC URL" - // )] - // rpc_url: Url, - // }, + #[clap(about = "Send an ethrex sponsored transaction")] + SponsorTx { + #[arg(help = "Destination address of the transaction")] + to: Address, + #[arg(long, value_parser = parse_hex, help = "Calldata of the transaction")] + calldata: Bytes, + #[arg(long, help = "Authorization list")] + auth_list: Vec, + #[arg( + long, + default_value = "http://localhost:1729", + env = "RPC_URL", + help = "L2 RPC URL" + )] + rpc_url: Url, + }, } impl Command { @@ -690,7 +695,29 @@ impl Command { ); println!(" Commit tx: {commit_tx}"); println!(" Verify tx: {verify_tx}"); - } // Command::SponsorTx { rpc_url } => {} + } + Command::SponsorTx { + rpc_url, + to, + calldata, + auth_list, + } => { + let client = EthClient::new(rpc_url)?; + + let mut auth_list_parsed = Vec::new(); + for auth_tuple_raw in &auth_list { + let auth_tuple = AuthorizationTuple::decode(auth_tuple_raw)?; + auth_list_parsed.push(auth_tuple); + } + + let auth_list = if auth_list_parsed.is_empty() { + None + } else { + Some(auth_list_parsed) + }; + + send_ethrex_transaction(&client, to, calldata, auth_list).await?; + } }; Ok(()) } From 95ee9599b64b56506ab7ae4ff50e66d46edb7753 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Paradelo?= Date: Thu, 27 Nov 2025 14:52:54 -0300 Subject: [PATCH 11/18] tested send ethrex tx --- Cargo.lock | 34 +++++++++++++++++----------------- cli/src/commands/l2.rs | 12 ++++++++---- 2 files changed, 25 insertions(+), 21 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 90111c8..9f3348a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1262,7 +1262,7 @@ dependencies = [ [[package]] name = "ethrex-blockchain" version = "7.0.0" -source = "git+https://github.com/lambdaclass/ethrex?branch=batch_number_function#0562b2495dbc9d5153032a89a8bf307669afd599" +source = "git+https://github.com/lambdaclass/ethrex?branch=batch_number_function#ea443366ce4506be868a45b0eee2361b7834ef0d" dependencies = [ "bytes", "ethrex-common", @@ -1283,7 +1283,7 @@ dependencies = [ [[package]] name = "ethrex-common" version = "7.0.0" -source = "git+https://github.com/lambdaclass/ethrex?branch=batch_number_function#0562b2495dbc9d5153032a89a8bf307669afd599" +source = "git+https://github.com/lambdaclass/ethrex?branch=batch_number_function#ea443366ce4506be868a45b0eee2361b7834ef0d" dependencies = [ "bytes", "crc32fast", @@ -1314,7 +1314,7 @@ dependencies = [ [[package]] name = "ethrex-crypto" version = "7.0.0" -source = "git+https://github.com/lambdaclass/ethrex?branch=batch_number_function#0562b2495dbc9d5153032a89a8bf307669afd599" +source = "git+https://github.com/lambdaclass/ethrex?branch=batch_number_function#ea443366ce4506be868a45b0eee2361b7834ef0d" dependencies = [ "c-kzg", "kzg-rs", @@ -1325,7 +1325,7 @@ dependencies = [ [[package]] name = "ethrex-l2-common" version = "7.0.0" -source = "git+https://github.com/lambdaclass/ethrex?branch=batch_number_function#0562b2495dbc9d5153032a89a8bf307669afd599" +source = "git+https://github.com/lambdaclass/ethrex?branch=batch_number_function#ea443366ce4506be868a45b0eee2361b7834ef0d" dependencies = [ "bytes", "ethereum-types", @@ -1349,7 +1349,7 @@ dependencies = [ [[package]] name = "ethrex-l2-rpc" version = "7.0.0" -source = "git+https://github.com/lambdaclass/ethrex?branch=batch_number_function#0562b2495dbc9d5153032a89a8bf307669afd599" +source = "git+https://github.com/lambdaclass/ethrex?branch=batch_number_function#ea443366ce4506be868a45b0eee2361b7834ef0d" dependencies = [ "axum", "bytes", @@ -1379,7 +1379,7 @@ dependencies = [ [[package]] name = "ethrex-levm" version = "7.0.0" -source = "git+https://github.com/lambdaclass/ethrex?branch=batch_number_function#0562b2495dbc9d5153032a89a8bf307669afd599" +source = "git+https://github.com/lambdaclass/ethrex?branch=batch_number_function#ea443366ce4506be868a45b0eee2361b7834ef0d" dependencies = [ "ark-bn254", "ark-ec", @@ -1412,7 +1412,7 @@ dependencies = [ [[package]] name = "ethrex-metrics" version = "7.0.0" -source = "git+https://github.com/lambdaclass/ethrex?branch=batch_number_function#0562b2495dbc9d5153032a89a8bf307669afd599" +source = "git+https://github.com/lambdaclass/ethrex?branch=batch_number_function#ea443366ce4506be868a45b0eee2361b7834ef0d" dependencies = [ "axum", "ethrex-common", @@ -1428,7 +1428,7 @@ dependencies = [ [[package]] name = "ethrex-p2p" version = "7.0.0" -source = "git+https://github.com/lambdaclass/ethrex?branch=batch_number_function#0562b2495dbc9d5153032a89a8bf307669afd599" +source = "git+https://github.com/lambdaclass/ethrex?branch=batch_number_function#ea443366ce4506be868a45b0eee2361b7834ef0d" dependencies = [ "aes", "async-trait", @@ -1470,7 +1470,7 @@ dependencies = [ [[package]] name = "ethrex-rlp" version = "7.0.0" -source = "git+https://github.com/lambdaclass/ethrex?branch=batch_number_function#0562b2495dbc9d5153032a89a8bf307669afd599" +source = "git+https://github.com/lambdaclass/ethrex?branch=batch_number_function#ea443366ce4506be868a45b0eee2361b7834ef0d" dependencies = [ "bytes", "ethereum-types", @@ -1484,7 +1484,7 @@ dependencies = [ [[package]] name = "ethrex-rpc" version = "7.0.0" -source = "git+https://github.com/lambdaclass/ethrex?branch=batch_number_function#0562b2495dbc9d5153032a89a8bf307669afd599" +source = "git+https://github.com/lambdaclass/ethrex?branch=batch_number_function#ea443366ce4506be868a45b0eee2361b7834ef0d" dependencies = [ "axum", "axum-extra", @@ -1523,7 +1523,7 @@ dependencies = [ [[package]] name = "ethrex-sdk" version = "7.0.0" -source = "git+https://github.com/lambdaclass/ethrex?branch=batch_number_function#0562b2495dbc9d5153032a89a8bf307669afd599" +source = "git+https://github.com/lambdaclass/ethrex?branch=batch_number_function#ea443366ce4506be868a45b0eee2361b7834ef0d" dependencies = [ "bytes", "ethereum-types", @@ -1549,7 +1549,7 @@ dependencies = [ [[package]] name = "ethrex-sdk-contract-utils" version = "7.0.0" -source = "git+https://github.com/lambdaclass/ethrex?branch=batch_number_function#0562b2495dbc9d5153032a89a8bf307669afd599" +source = "git+https://github.com/lambdaclass/ethrex?branch=batch_number_function#ea443366ce4506be868a45b0eee2361b7834ef0d" dependencies = [ "thiserror 2.0.17", "tracing", @@ -1558,7 +1558,7 @@ dependencies = [ [[package]] name = "ethrex-storage" version = "7.0.0" -source = "git+https://github.com/lambdaclass/ethrex?branch=batch_number_function#0562b2495dbc9d5153032a89a8bf307669afd599" +source = "git+https://github.com/lambdaclass/ethrex?branch=batch_number_function#ea443366ce4506be868a45b0eee2361b7834ef0d" dependencies = [ "anyhow", "async-trait", @@ -1583,7 +1583,7 @@ dependencies = [ [[package]] name = "ethrex-storage-rollup" version = "7.0.0" -source = "git+https://github.com/lambdaclass/ethrex?branch=batch_number_function#0562b2495dbc9d5153032a89a8bf307669afd599" +source = "git+https://github.com/lambdaclass/ethrex?branch=batch_number_function#ea443366ce4506be868a45b0eee2361b7834ef0d" dependencies = [ "anyhow", "async-trait", @@ -1603,7 +1603,7 @@ dependencies = [ [[package]] name = "ethrex-threadpool" version = "0.1.0" -source = "git+https://github.com/lambdaclass/ethrex?branch=batch_number_function#0562b2495dbc9d5153032a89a8bf307669afd599" +source = "git+https://github.com/lambdaclass/ethrex?branch=batch_number_function#ea443366ce4506be868a45b0eee2361b7834ef0d" dependencies = [ "crossbeam 0.8.4", ] @@ -1611,7 +1611,7 @@ dependencies = [ [[package]] name = "ethrex-trie" version = "7.0.0" -source = "git+https://github.com/lambdaclass/ethrex?branch=batch_number_function#0562b2495dbc9d5153032a89a8bf307669afd599" +source = "git+https://github.com/lambdaclass/ethrex?branch=batch_number_function#ea443366ce4506be868a45b0eee2361b7834ef0d" dependencies = [ "anyhow", "bytes", @@ -1635,7 +1635,7 @@ dependencies = [ [[package]] name = "ethrex-vm" version = "7.0.0" -source = "git+https://github.com/lambdaclass/ethrex?branch=batch_number_function#0562b2495dbc9d5153032a89a8bf307669afd599" +source = "git+https://github.com/lambdaclass/ethrex?branch=batch_number_function#ea443366ce4506be868a45b0eee2361b7834ef0d" dependencies = [ "bincode", "bytes", diff --git a/cli/src/commands/l2.rs b/cli/src/commands/l2.rs index 05b4f89..edf43fc 100644 --- a/cli/src/commands/l2.rs +++ b/cli/src/commands/l2.rs @@ -342,9 +342,9 @@ pub(crate) enum Command { #[arg(help = "Destination address of the transaction")] to: Address, #[arg(long, value_parser = parse_hex, help = "Calldata of the transaction")] - calldata: Bytes, + calldata: Option, #[arg(long, help = "Authorization list")] - auth_list: Vec, + auth_list: Vec, #[arg( long, default_value = "http://localhost:1729", @@ -706,7 +706,8 @@ impl Command { let mut auth_list_parsed = Vec::new(); for auth_tuple_raw in &auth_list { - let auth_tuple = AuthorizationTuple::decode(auth_tuple_raw)?; + let auth_tuple = parse_hex(auth_tuple_raw)?; + let auth_tuple = AuthorizationTuple::decode(&auth_tuple)?; auth_list_parsed.push(auth_tuple); } @@ -715,8 +716,11 @@ impl Command { } else { Some(auth_list_parsed) }; + let calldata = calldata.unwrap_or_else(Bytes::new); - send_ethrex_transaction(&client, to, calldata, auth_list).await?; + let tx_hash = send_ethrex_transaction(&client, to, calldata, auth_list).await?; + + println!("{tx_hash:#x}"); } }; Ok(()) From 7014aa81cf72d22d85f85eb23586879cddf86b1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Paradelo?= Date: Thu, 27 Nov 2025 15:14:35 -0300 Subject: [PATCH 12/18] refactor --- cli/src/cli.rs | 2 +- cli/src/commands/l2.rs | 5 ++++- sdk/src/utils.rs | 5 +---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cli/src/cli.rs b/cli/src/cli.rs index 4c94787..7c2f2af 100644 --- a/cli/src/cli.rs +++ b/cli/src/cli.rs @@ -818,7 +818,7 @@ async fn compile_contract_from_path(args: DeployArgs) -> eyre::Result { output_dir, contract_path, false, - false, // TODO: review this change + false, Some(&solc_remappings_ref), &include_paths, ) diff --git a/cli/src/commands/l2.rs b/cli/src/commands/l2.rs index edf43fc..a0c63a8 100644 --- a/cli/src/commands/l2.rs +++ b/cli/src/commands/l2.rs @@ -664,8 +664,11 @@ impl Command { batch_number, rpc_url, } => { - let batch_number = batch_number.unwrap(); // left this until i can get the latest batch let client = EthClient::new(rpc_url)?; + let batch_number = match batch_number { + Some(number) => number, + None => get_batch_number(&client).await?, + }; let batch = match get_batch_by_number(&client, batch_number).await { Ok(batch) => batch.batch, diff --git a/sdk/src/utils.rs b/sdk/src/utils.rs index 9136e08..b86f12d 100644 --- a/sdk/src/utils.rs +++ b/sdk/src/utils.rs @@ -5,6 +5,7 @@ use keccak_hash::keccak; use secp256k1::ecdsa::RecoverableSignature; use secp256k1::{Message, Secp256k1, SecretKey}; use serde::{Deserialize, Deserializer, Serialize, Serializer}; +const MAGIC: u8 = 0x05; pub fn secret_key_deserializer<'de, D>(deserializer: D) -> Result where @@ -52,9 +53,6 @@ pub fn to_checksum_address(address: &str) -> String { checksummed } -// MAGIC is 0x05 (crates/vm/levm/src/constants.rs) -const MAGIC: u8 = 0x05; - pub fn make_auth_tuple( signing_key: &SecretKey, chain_id: u64, @@ -72,7 +70,6 @@ pub fn make_auth_tuple( let sig: RecoverableSignature = secp.sign_ecdsa_recoverable(&msg, signing_key); let (rec_id, sig_bytes) = sig.serialize_compact(); - // Split r,s and y_parity let r_signature = U256::from_big_endian(&sig_bytes[0..32]); let s_signature = U256::from_big_endian(&sig_bytes[32..64]); let y_parity = U256::from(Into::::into(rec_id)); From b48161dfb4671c2dd5a971d6a944d2aa1db09b01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Paradelo?= Date: Thu, 27 Nov 2025 16:03:55 -0300 Subject: [PATCH 13/18] refactor for authorize command --- cli/src/cli.rs | 30 ++++++++++-------------------- cli/src/commands/l2.rs | 12 +++++++++++- cli/src/common.rs | 12 ++++++++++++ 3 files changed, 33 insertions(+), 21 deletions(-) diff --git a/cli/src/cli.rs b/cli/src/cli.rs index 7c2f2af..9c9df9a 100644 --- a/cli/src/cli.rs +++ b/cli/src/cli.rs @@ -1,4 +1,5 @@ use crate::commands::l2; +use crate::common::AuthorizeArgs; use crate::utils::{parse_contract_creation, parse_func_call, parse_hex, parse_hex_string}; use crate::{ commands::autocomplete, @@ -278,15 +279,9 @@ pub(crate) enum Command { data: Bytes, }, #[clap(about = "Authorize a delegated account")] - Auth { - #[arg(help = "Delegated address")] - delegated_address: Address, - #[arg(long, value_parser = parse_private_key, help = "Private key to sign the auth")] - private_key: SecretKey, - #[arg(long, required = false, help = "Nonce of the signer")] - nonce: Option, - #[arg(long, required = false, help = "Chain id of the network")] - chain_id: Option, + Authorize { + #[clap(flatten)] + args: AuthorizeArgs, #[arg(long, default_value = "http://localhost:8545", env = "RPC_URL")] rpc_url: Url, }, @@ -677,34 +672,29 @@ impl Command { print_calldata(0, elem); } } - Command::Auth { - delegated_address, - private_key, - nonce, - chain_id, - rpc_url, - } => { + Command::Authorize { args, rpc_url } => { let client = EthClient::new(rpc_url)?; - let chain_id = if let Some(chain_id) = chain_id { + let chain_id = if let Some(chain_id) = args.chain_id { chain_id } else { client.get_chain_id().await?.as_u64() }; - let nonce = if let Some(nonce) = nonce { + let nonce = if let Some(nonce) = args.nonce { nonce } else { client .get_nonce( - get_address_from_secret_key(&private_key.secret_bytes()) + get_address_from_secret_key(&args.private_key.secret_bytes()) .map_err(|e| eyre::eyre!(e))?, BlockIdentifier::Tag(BlockTag::Latest), ) .await? }; - let auth_tuple = make_auth_tuple(&private_key, chain_id, delegated_address, nonce); + let auth_tuple = + make_auth_tuple(&args.private_key, chain_id, args.delegated_address, nonce); let mut buf = Vec::new(); auth_tuple.encode(&mut buf); println!("0x{:x}", Bytes::from(buf)); diff --git a/cli/src/commands/l2.rs b/cli/src/commands/l2.rs index a0c63a8..e58b807 100644 --- a/cli/src/commands/l2.rs +++ b/cli/src/commands/l2.rs @@ -1,6 +1,6 @@ use crate::{ cli::Command as EthCommand, - common::{BalanceArgs, CallArgs, DeployArgs, SendArgs, TransferArgs}, + common::{AuthorizeArgs, BalanceArgs, CallArgs, DeployArgs, SendArgs, TransferArgs}, utils::{parse_hex, parse_private_key, parse_u256}, }; use clap::Subcommand; @@ -353,6 +353,13 @@ pub(crate) enum Command { )] rpc_url: Url, }, + #[clap(about = "Authorize a delegated account")] + Authorize { + #[clap(flatten)] + args: AuthorizeArgs, + #[arg(long, default_value = "http://localhost:1729", env = "RPC_URL")] + rpc_url: Url, + }, } impl Command { @@ -725,6 +732,9 @@ impl Command { println!("{tx_hash:#x}"); } + Command::Authorize { args, rpc_url } => { + Box::pin(async { EthCommand::Authorize { args, rpc_url }.run().await }).await? + } }; Ok(()) } diff --git a/cli/src/common.rs b/cli/src/common.rs index fa389f4..60da0dd 100644 --- a/cli/src/common.rs +++ b/cli/src/common.rs @@ -214,3 +214,15 @@ pub struct DeployArgs { #[arg(last = true, hide = true)] pub _args: Vec, } + +#[derive(Parser)] +pub struct AuthorizeArgs { + #[arg(help = "Delegated address")] + pub delegated_address: Address, + #[arg(long, value_parser = parse_private_key, help = "Private key to sign the auth")] + pub private_key: SecretKey, + #[arg(long, required = false, help = "Nonce of the signer")] + pub nonce: Option, + #[arg(long, required = false, help = "Chain id of the network")] + pub chain_id: Option, +} From 01043bbf18fb407c16bf2bc7670d2bf846f7c4cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Paradelo?= Date: Thu, 27 Nov 2025 18:14:09 -0300 Subject: [PATCH 14/18] refactor: move some logic to the sdk --- cli/src/commands/l2.rs | 67 +++++++++++------------------------------ sdk/src/l2/authorize.rs | 35 +++++++++++++++++++++ sdk/src/l2/fees.rs | 51 +++++++++++++++++++++++++++++++ sdk/src/l2/mod.rs | 2 ++ 4 files changed, 106 insertions(+), 49 deletions(-) create mode 100644 sdk/src/l2/authorize.rs create mode 100644 sdk/src/l2/fees.rs diff --git a/cli/src/commands/l2.rs b/cli/src/commands/l2.rs index e58b807..1b5cb84 100644 --- a/cli/src/commands/l2.rs +++ b/cli/src/commands/l2.rs @@ -4,23 +4,17 @@ use crate::{ utils::{parse_hex, parse_private_key, parse_u256}, }; use clap::Subcommand; -use ethrex_common::{Address, H256, U256, types::AuthorizationTuple}; +use ethrex_common::{Address, H256, U256}; use ethrex_common::{Bytes, types::TxType}; use ethrex_l2_common::utils::get_address_from_secret_key; -use ethrex_l2_rpc::clients::{ - get_base_fee_vault_address, get_l1_blob_base_fee_per_gas, get_l1_fee_vault_address, - get_operator_fee, get_operator_fee_vault_address, send_ethrex_transaction, -}; use ethrex_l2_rpc::clients::{get_batch_by_number, get_batch_number}; -use ethrex_rlp::decode::RLPDecode; +use ethrex_rpc::EthClient; use ethrex_rpc::clients::Overrides; -use ethrex_rpc::{ - EthClient, - types::block_identifier::{BlockIdentifier, BlockTag}, -}; use ethrex_sdk::wait_for_message_proof; use rex_sdk::transfer; use rex_sdk::{ + l2::authorize::send_authorized_transaction, + l2::fees::fetch_fee_info, l2::{ deposit::{deposit_erc20, deposit_through_contract_call}, withdraw::{claim_erc20withdraw, claim_withdraw, withdraw, withdraw_erc20}, @@ -615,46 +609,33 @@ impl Command { } Command::GetFeeInfo { block, rpc_url } => { let client: EthClient = EthClient::new(rpc_url)?; - let (block_identifier, block_number) = match block { - Some(block_number) => (BlockIdentifier::Number(block_number), block_number), - None => { - let latest_block = client.get_block_number().await?.as_u64(); - (BlockIdentifier::Tag(BlockTag::Latest), latest_block) - } - }; - - let base_fee_vault_address = - get_base_fee_vault_address(&client, block_identifier.clone()).await?; - let operator_fee_vault_address = - get_operator_fee_vault_address(&client, block_identifier.clone()).await?; - let l1_fee_vault_address = - get_l1_fee_vault_address(&client, block_identifier.clone()).await?; - - let operator_fee = get_operator_fee(&client, block_identifier.clone()).await?; - let blob_base_fee = get_l1_blob_base_fee_per_gas(&client, block_number).await?; + let fee_info = fetch_fee_info(&client, block).await?; - let base_fee_vault_address = base_fee_vault_address + let base_fee_vault_address = fee_info + .base_fee_vault_address .map(|addr| format!("{addr:#x}")) .unwrap_or_else(String::new); - let operator_fee_vault_address = operator_fee_vault_address + let operator_fee_vault_address = fee_info + .operator_fee_vault_address .map(|addr| format!("{addr:#x}")) .unwrap_or_else(String::new); - let l1_fee_vault_address = l1_fee_vault_address + let l1_fee_vault_address = fee_info + .l1_fee_vault_address .map(|addr| format!("{addr:#x}")) .unwrap_or_else(String::new); - let operator_fee = if operator_fee.is_zero() { + let operator_fee = if fee_info.operator_fee.is_zero() { String::new() } else { - operator_fee.to_string() + fee_info.operator_fee.to_string() }; - let blob_base_fee = if blob_base_fee == 0 { + let blob_base_fee = if fee_info.blob_base_fee == 0 { String::new() } else { - blob_base_fee.to_string() + fee_info.blob_base_fee.to_string() }; - println!("L2 fee info for block {block_number}:"); + println!("L2 fee info for block {}:", fee_info.block_number); println!(" Base fee vault: {base_fee_vault_address}"); println!(" Operator fee vault: {operator_fee_vault_address}"); println!(" L1 fee vault: {l1_fee_vault_address}"); @@ -713,22 +694,10 @@ impl Command { auth_list, } => { let client = EthClient::new(rpc_url)?; - - let mut auth_list_parsed = Vec::new(); - for auth_tuple_raw in &auth_list { - let auth_tuple = parse_hex(auth_tuple_raw)?; - let auth_tuple = AuthorizationTuple::decode(&auth_tuple)?; - auth_list_parsed.push(auth_tuple); - } - - let auth_list = if auth_list_parsed.is_empty() { - None - } else { - Some(auth_list_parsed) - }; let calldata = calldata.unwrap_or_else(Bytes::new); - let tx_hash = send_ethrex_transaction(&client, to, calldata, auth_list).await?; + let tx_hash = + send_authorized_transaction(&client, to, calldata, &auth_list).await?; println!("{tx_hash:#x}"); } diff --git a/sdk/src/l2/authorize.rs b/sdk/src/l2/authorize.rs new file mode 100644 index 0000000..72464fe --- /dev/null +++ b/sdk/src/l2/authorize.rs @@ -0,0 +1,35 @@ +use bytes::Bytes; +use ethrex_common::{Address, H256, types::AuthorizationTuple}; +use ethrex_l2_rpc::clients::send_ethrex_transaction; +use ethrex_rlp::decode::RLPDecode; +use ethrex_rpc::{EthClient, clients::EthClientError}; +use hex; + +pub fn parse_authorization_list( + auth_list: &[String], +) -> Result, eyre::Error> { + let mut parsed = Vec::new(); + for auth_tuple_raw in auth_list { + let bytes = hex::decode(auth_tuple_raw.trim_start_matches("0x"))?; + let auth_tuple = AuthorizationTuple::decode(&bytes)?; + parsed.push(auth_tuple); + } + Ok(parsed) +} + +pub async fn send_authorized_transaction( + client: &EthClient, + to: Address, + calldata: Bytes, + auth_list_hex: &[String], +) -> Result { + let auth_list = parse_authorization_list(auth_list_hex) + .map_err(|e| EthClientError::Custom(e.to_string()))?; + let auth_list = if auth_list.is_empty() { + None + } else { + Some(auth_list) + }; + + send_ethrex_transaction(client, to, calldata, auth_list).await +} diff --git a/sdk/src/l2/fees.rs b/sdk/src/l2/fees.rs new file mode 100644 index 0000000..a3fae0a --- /dev/null +++ b/sdk/src/l2/fees.rs @@ -0,0 +1,51 @@ +use ethrex_common::{Address, U256}; +use ethrex_l2_rpc::clients::{ + get_base_fee_vault_address, get_l1_blob_base_fee_per_gas, get_l1_fee_vault_address, + get_operator_fee, get_operator_fee_vault_address, +}; +use ethrex_rpc::{ + EthClient, + clients::EthClientError, + types::block_identifier::{BlockIdentifier, BlockTag}, +}; + +#[derive(Clone, Debug)] +pub struct FeeInfo { + pub block_number: u64, + pub base_fee_vault_address: Option
, + pub operator_fee_vault_address: Option
, + pub l1_fee_vault_address: Option
, + pub operator_fee: U256, + pub blob_base_fee: u64, +} + +pub async fn fetch_fee_info( + client: &EthClient, + block: Option, +) -> Result { + let (block_identifier, block_number) = match block { + Some(block_number) => (BlockIdentifier::Number(block_number), block_number), + None => { + let latest_block = client.get_block_number().await?.as_u64(); + (BlockIdentifier::Tag(BlockTag::Latest), latest_block) + } + }; + + let base_fee_vault_address = + get_base_fee_vault_address(client, block_identifier.clone()).await?; + let operator_fee_vault_address = + get_operator_fee_vault_address(client, block_identifier.clone()).await?; + let l1_fee_vault_address = get_l1_fee_vault_address(client, block_identifier.clone()).await?; + + let operator_fee = get_operator_fee(client, block_identifier.clone()).await?; + let blob_base_fee = get_l1_blob_base_fee_per_gas(client, block_number).await?; + + Ok(FeeInfo { + block_number, + base_fee_vault_address, + operator_fee_vault_address, + l1_fee_vault_address, + operator_fee, + blob_base_fee, + }) +} diff --git a/sdk/src/l2/mod.rs b/sdk/src/l2/mod.rs index 96c52b3..bd3f759 100644 --- a/sdk/src/l2/mod.rs +++ b/sdk/src/l2/mod.rs @@ -1,4 +1,6 @@ +pub mod authorize; pub mod constants; pub mod deposit; +pub mod fees; pub mod privileged_transaction_data; pub mod withdraw; From 81fcb2747ff29a6fa1e008ff3fe13a982004c13e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Paradelo?= Date: Thu, 27 Nov 2025 18:17:06 -0300 Subject: [PATCH 15/18] fix compile --- sdk/src/l2/authorize.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/sdk/src/l2/authorize.rs b/sdk/src/l2/authorize.rs index 72464fe..b68e97e 100644 --- a/sdk/src/l2/authorize.rs +++ b/sdk/src/l2/authorize.rs @@ -1,5 +1,4 @@ -use bytes::Bytes; -use ethrex_common::{Address, H256, types::AuthorizationTuple}; +use ethrex_common::{Address, Bytes, H256, types::AuthorizationTuple}; use ethrex_l2_rpc::clients::send_ethrex_transaction; use ethrex_rlp::decode::RLPDecode; use ethrex_rpc::{EthClient, clients::EthClientError}; From b772d58ccae3c9db1d69ea1105fe3eaa2ef9e174 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Paradelo?= Date: Fri, 28 Nov 2025 11:34:55 -0300 Subject: [PATCH 16/18] add rex send --auth-tuple --- Cargo.lock | 34 +++++++++++++++++----------------- Cargo.toml | 14 +++++++------- cli/src/cli.rs | 24 ++++++++++++++++++++++-- cli/src/common.rs | 6 ++++++ 4 files changed, 52 insertions(+), 26 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9f3348a..b8d18f3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1262,7 +1262,7 @@ dependencies = [ [[package]] name = "ethrex-blockchain" version = "7.0.0" -source = "git+https://github.com/lambdaclass/ethrex?branch=batch_number_function#ea443366ce4506be868a45b0eee2361b7834ef0d" +source = "git+https://github.com/lambdaclass/ethrex?branch=7702_on_generic_tx#583c2093e885c89e3256cba9618b5604c191c9dd" dependencies = [ "bytes", "ethrex-common", @@ -1283,7 +1283,7 @@ dependencies = [ [[package]] name = "ethrex-common" version = "7.0.0" -source = "git+https://github.com/lambdaclass/ethrex?branch=batch_number_function#ea443366ce4506be868a45b0eee2361b7834ef0d" +source = "git+https://github.com/lambdaclass/ethrex?branch=7702_on_generic_tx#583c2093e885c89e3256cba9618b5604c191c9dd" dependencies = [ "bytes", "crc32fast", @@ -1314,7 +1314,7 @@ dependencies = [ [[package]] name = "ethrex-crypto" version = "7.0.0" -source = "git+https://github.com/lambdaclass/ethrex?branch=batch_number_function#ea443366ce4506be868a45b0eee2361b7834ef0d" +source = "git+https://github.com/lambdaclass/ethrex?branch=7702_on_generic_tx#583c2093e885c89e3256cba9618b5604c191c9dd" dependencies = [ "c-kzg", "kzg-rs", @@ -1325,7 +1325,7 @@ dependencies = [ [[package]] name = "ethrex-l2-common" version = "7.0.0" -source = "git+https://github.com/lambdaclass/ethrex?branch=batch_number_function#ea443366ce4506be868a45b0eee2361b7834ef0d" +source = "git+https://github.com/lambdaclass/ethrex?branch=7702_on_generic_tx#583c2093e885c89e3256cba9618b5604c191c9dd" dependencies = [ "bytes", "ethereum-types", @@ -1349,7 +1349,7 @@ dependencies = [ [[package]] name = "ethrex-l2-rpc" version = "7.0.0" -source = "git+https://github.com/lambdaclass/ethrex?branch=batch_number_function#ea443366ce4506be868a45b0eee2361b7834ef0d" +source = "git+https://github.com/lambdaclass/ethrex?branch=7702_on_generic_tx#583c2093e885c89e3256cba9618b5604c191c9dd" dependencies = [ "axum", "bytes", @@ -1379,7 +1379,7 @@ dependencies = [ [[package]] name = "ethrex-levm" version = "7.0.0" -source = "git+https://github.com/lambdaclass/ethrex?branch=batch_number_function#ea443366ce4506be868a45b0eee2361b7834ef0d" +source = "git+https://github.com/lambdaclass/ethrex?branch=7702_on_generic_tx#583c2093e885c89e3256cba9618b5604c191c9dd" dependencies = [ "ark-bn254", "ark-ec", @@ -1412,7 +1412,7 @@ dependencies = [ [[package]] name = "ethrex-metrics" version = "7.0.0" -source = "git+https://github.com/lambdaclass/ethrex?branch=batch_number_function#ea443366ce4506be868a45b0eee2361b7834ef0d" +source = "git+https://github.com/lambdaclass/ethrex?branch=7702_on_generic_tx#583c2093e885c89e3256cba9618b5604c191c9dd" dependencies = [ "axum", "ethrex-common", @@ -1428,7 +1428,7 @@ dependencies = [ [[package]] name = "ethrex-p2p" version = "7.0.0" -source = "git+https://github.com/lambdaclass/ethrex?branch=batch_number_function#ea443366ce4506be868a45b0eee2361b7834ef0d" +source = "git+https://github.com/lambdaclass/ethrex?branch=7702_on_generic_tx#583c2093e885c89e3256cba9618b5604c191c9dd" dependencies = [ "aes", "async-trait", @@ -1470,7 +1470,7 @@ dependencies = [ [[package]] name = "ethrex-rlp" version = "7.0.0" -source = "git+https://github.com/lambdaclass/ethrex?branch=batch_number_function#ea443366ce4506be868a45b0eee2361b7834ef0d" +source = "git+https://github.com/lambdaclass/ethrex?branch=7702_on_generic_tx#583c2093e885c89e3256cba9618b5604c191c9dd" dependencies = [ "bytes", "ethereum-types", @@ -1484,7 +1484,7 @@ dependencies = [ [[package]] name = "ethrex-rpc" version = "7.0.0" -source = "git+https://github.com/lambdaclass/ethrex?branch=batch_number_function#ea443366ce4506be868a45b0eee2361b7834ef0d" +source = "git+https://github.com/lambdaclass/ethrex?branch=7702_on_generic_tx#583c2093e885c89e3256cba9618b5604c191c9dd" dependencies = [ "axum", "axum-extra", @@ -1523,7 +1523,7 @@ dependencies = [ [[package]] name = "ethrex-sdk" version = "7.0.0" -source = "git+https://github.com/lambdaclass/ethrex?branch=batch_number_function#ea443366ce4506be868a45b0eee2361b7834ef0d" +source = "git+https://github.com/lambdaclass/ethrex?branch=7702_on_generic_tx#583c2093e885c89e3256cba9618b5604c191c9dd" dependencies = [ "bytes", "ethereum-types", @@ -1549,7 +1549,7 @@ dependencies = [ [[package]] name = "ethrex-sdk-contract-utils" version = "7.0.0" -source = "git+https://github.com/lambdaclass/ethrex?branch=batch_number_function#ea443366ce4506be868a45b0eee2361b7834ef0d" +source = "git+https://github.com/lambdaclass/ethrex?branch=7702_on_generic_tx#583c2093e885c89e3256cba9618b5604c191c9dd" dependencies = [ "thiserror 2.0.17", "tracing", @@ -1558,7 +1558,7 @@ dependencies = [ [[package]] name = "ethrex-storage" version = "7.0.0" -source = "git+https://github.com/lambdaclass/ethrex?branch=batch_number_function#ea443366ce4506be868a45b0eee2361b7834ef0d" +source = "git+https://github.com/lambdaclass/ethrex?branch=7702_on_generic_tx#583c2093e885c89e3256cba9618b5604c191c9dd" dependencies = [ "anyhow", "async-trait", @@ -1583,7 +1583,7 @@ dependencies = [ [[package]] name = "ethrex-storage-rollup" version = "7.0.0" -source = "git+https://github.com/lambdaclass/ethrex?branch=batch_number_function#ea443366ce4506be868a45b0eee2361b7834ef0d" +source = "git+https://github.com/lambdaclass/ethrex?branch=7702_on_generic_tx#583c2093e885c89e3256cba9618b5604c191c9dd" dependencies = [ "anyhow", "async-trait", @@ -1603,7 +1603,7 @@ dependencies = [ [[package]] name = "ethrex-threadpool" version = "0.1.0" -source = "git+https://github.com/lambdaclass/ethrex?branch=batch_number_function#ea443366ce4506be868a45b0eee2361b7834ef0d" +source = "git+https://github.com/lambdaclass/ethrex?branch=7702_on_generic_tx#583c2093e885c89e3256cba9618b5604c191c9dd" dependencies = [ "crossbeam 0.8.4", ] @@ -1611,7 +1611,7 @@ dependencies = [ [[package]] name = "ethrex-trie" version = "7.0.0" -source = "git+https://github.com/lambdaclass/ethrex?branch=batch_number_function#ea443366ce4506be868a45b0eee2361b7834ef0d" +source = "git+https://github.com/lambdaclass/ethrex?branch=7702_on_generic_tx#583c2093e885c89e3256cba9618b5604c191c9dd" dependencies = [ "anyhow", "bytes", @@ -1635,7 +1635,7 @@ dependencies = [ [[package]] name = "ethrex-vm" version = "7.0.0" -source = "git+https://github.com/lambdaclass/ethrex?branch=batch_number_function#ea443366ce4506be868a45b0eee2361b7834ef0d" +source = "git+https://github.com/lambdaclass/ethrex?branch=7702_on_generic_tx#583c2093e885c89e3256cba9618b5604c191c9dd" dependencies = [ "bincode", "bytes", diff --git a/Cargo.toml b/Cargo.toml index 80c36b5..23df99f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -29,13 +29,13 @@ manual_saturating_arithmetic = "warn" rex-cli = { path = "cli" } rex-sdk = { path = "sdk" } -ethrex-common = { git = "https://github.com/lambdaclass/ethrex", package = "ethrex-common", branch = "batch_number_function" } -ethrex-blockchain = { git = "https://github.com/lambdaclass/ethrex", package = "ethrex-blockchain", branch = "batch_number_function" } -ethrex-rlp = { git = "https://github.com/lambdaclass/ethrex", package = "ethrex-rlp", branch = "batch_number_function" } -ethrex-rpc = { git = "https://github.com/lambdaclass/ethrex", package = "ethrex-rpc", branch = "batch_number_function" } -ethrex-l2-rpc = { git = "https://github.com/lambdaclass/ethrex", package = "ethrex-l2-rpc", branch = "batch_number_function" } -ethrex-sdk = { git = "https://github.com/lambdaclass/ethrex", package = "ethrex-sdk", branch = "batch_number_function" } -ethrex-l2-common = { git = "https://github.com/lambdaclass/ethrex", package = "ethrex-l2-common", branch = "batch_number_function" } +ethrex-common = { git = "https://github.com/lambdaclass/ethrex", package = "ethrex-common", branch = "7702_on_generic_tx" } +ethrex-blockchain = { git = "https://github.com/lambdaclass/ethrex", package = "ethrex-blockchain", branch = "7702_on_generic_tx" } +ethrex-rlp = { git = "https://github.com/lambdaclass/ethrex", package = "ethrex-rlp", branch = "7702_on_generic_tx" } +ethrex-rpc = { git = "https://github.com/lambdaclass/ethrex", package = "ethrex-rpc", branch = "7702_on_generic_tx" } +ethrex-l2-rpc = { git = "https://github.com/lambdaclass/ethrex", package = "ethrex-l2-rpc", branch = "7702_on_generic_tx" } +ethrex-sdk = { git = "https://github.com/lambdaclass/ethrex", package = "ethrex-sdk", branch = "7702_on_generic_tx" } +ethrex-l2-common = { git = "https://github.com/lambdaclass/ethrex", package = "ethrex-l2-common", branch = "7702_on_generic_tx" } keccak-hash = "0.11.0" thiserror = "2.0.11" diff --git a/cli/src/cli.rs b/cli/src/cli.rs index 9c9df9a..ad38c88 100644 --- a/cli/src/cli.rs +++ b/cli/src/cli.rs @@ -7,7 +7,7 @@ use crate::{ utils::parse_private_key, }; use clap::{ArgAction, Parser, Subcommand}; -use ethrex_common::types::TxType; +use ethrex_common::types::{AuthorizationTupleEntry, TxType}; use ethrex_common::{Address, Bytes, H256, H520}; use ethrex_l2_common::calldata::Value; use ethrex_l2_common::utils::get_address_from_secret_key; @@ -24,6 +24,7 @@ use rex_sdk::client::eth::get_token_balance; use rex_sdk::create::{ DETERMINISTIC_DEPLOYER, brute_force_create2, compute_create_address, compute_create2_address, }; +use rex_sdk::l2::authorize::parse_authorization_list; use rex_sdk::sign::{get_address_from_message_and_signature, sign_hash}; use rex_sdk::utils::{make_auth_tuple, to_checksum_address}; use rex_sdk::{balance_in_eth, deploy, transfer, wait_for_transaction_receipt}; @@ -494,9 +495,27 @@ impl Command { parse_func_call(args._args)? }; + let tx_type = if args.auth_tuple.is_empty() { + TxType::EIP1559 + } else { + TxType::EIP7702 + }; + + let auth_list = parse_authorization_list(&args.auth_tuple)?; + let auth_list = if auth_list.is_empty() { + None + } else { + Some( + auth_list + .iter() + .map(AuthorizationTupleEntry::from) + .collect(), + ) + }; + let tx = build_generic_tx( &client, - TxType::EIP1559, + tx_type, args.to, from, calldata, @@ -508,6 +527,7 @@ impl Command { max_fee_per_gas: args.max_fee_per_gas, max_priority_fee_per_gas: args.max_priority_fee_per_gas, from: Some(from), + authorization_list: auth_list, ..Default::default() }, ) diff --git a/cli/src/common.rs b/cli/src/common.rs index 60da0dd..1c36be7 100644 --- a/cli/src/common.rs +++ b/cli/src/common.rs @@ -99,6 +99,12 @@ pub struct SendArgs { help = "Display transaction URL in the explorer." )] pub explorer_url: bool, + #[clap( + long, + required = false, + help = "Hex endoded authorization tuple for EIP 7702 transactions" + )] + pub auth_tuple: Vec, #[clap( long = "private-key", short = 'k', From 535cf43ec98d0527360b11e8a3a5c0d1affb3934 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Paradelo?= Date: Fri, 28 Nov 2025 11:42:21 -0300 Subject: [PATCH 17/18] move some logix to the sdk --- cli/src/cli.rs | 31 ++++++++++--------------------- sdk/src/authorize.rs | 42 ++++++++++++++++++++++++++++++++++++++++++ sdk/src/sdk.rs | 1 + 3 files changed, 53 insertions(+), 21 deletions(-) create mode 100644 sdk/src/authorize.rs diff --git a/cli/src/cli.rs b/cli/src/cli.rs index ad38c88..4e37dab 100644 --- a/cli/src/cli.rs +++ b/cli/src/cli.rs @@ -20,13 +20,14 @@ use ethrex_sdk::calldata::decode_calldata; use ethrex_sdk::{build_generic_tx, create2_deploy_from_bytecode, send_generic_transaction}; use ethrex_sdk::{compile_contract, git_clone}; use keccak_hash::keccak; +use rex_sdk::authorize::build_authorization_tuple; use rex_sdk::client::eth::get_token_balance; use rex_sdk::create::{ DETERMINISTIC_DEPLOYER, brute_force_create2, compute_create_address, compute_create2_address, }; use rex_sdk::l2::authorize::parse_authorization_list; use rex_sdk::sign::{get_address_from_message_and_signature, sign_hash}; -use rex_sdk::utils::{make_auth_tuple, to_checksum_address}; +use rex_sdk::utils::to_checksum_address; use rex_sdk::{balance_in_eth, deploy, transfer, wait_for_transaction_receipt}; use secp256k1::SecretKey; use std::io::{self, Write}; @@ -695,26 +696,14 @@ impl Command { Command::Authorize { args, rpc_url } => { let client = EthClient::new(rpc_url)?; - let chain_id = if let Some(chain_id) = args.chain_id { - chain_id - } else { - client.get_chain_id().await?.as_u64() - }; - - let nonce = if let Some(nonce) = args.nonce { - nonce - } else { - client - .get_nonce( - get_address_from_secret_key(&args.private_key.secret_bytes()) - .map_err(|e| eyre::eyre!(e))?, - BlockIdentifier::Tag(BlockTag::Latest), - ) - .await? - }; - - let auth_tuple = - make_auth_tuple(&args.private_key, chain_id, args.delegated_address, nonce); + let auth_tuple = build_authorization_tuple( + &client, + args.delegated_address, + &args.private_key, + args.chain_id, + args.nonce, + ) + .await?; let mut buf = Vec::new(); auth_tuple.encode(&mut buf); println!("0x{:x}", Bytes::from(buf)); diff --git a/sdk/src/authorize.rs b/sdk/src/authorize.rs new file mode 100644 index 0000000..cd2b96c --- /dev/null +++ b/sdk/src/authorize.rs @@ -0,0 +1,42 @@ +use ethrex_common::{Address, types::AuthorizationTuple}; +use ethrex_l2_common::utils::get_address_from_secret_key; +use ethrex_rpc::{ + EthClient, + clients::EthClientError, + types::block_identifier::{BlockIdentifier, BlockTag}, +}; +use secp256k1::SecretKey; + +use crate::utils::make_auth_tuple; + +pub async fn build_authorization_tuple( + client: &EthClient, + delegated_address: Address, + private_key: &SecretKey, + chain_id: Option, + nonce: Option, +) -> Result { + let chain_id = match chain_id { + Some(id) => id, + None => client.get_chain_id().await?.as_u64(), + }; + + let from = get_address_from_secret_key(&private_key.secret_bytes()) + .map_err(|e| EthClientError::Custom(e.to_string()))?; + + let nonce = match nonce { + Some(nonce) => nonce, + None => { + client + .get_nonce(from, BlockIdentifier::Tag(BlockTag::Latest)) + .await? + } + }; + + Ok(make_auth_tuple( + private_key, + chain_id, + delegated_address, + nonce, + )) +} diff --git a/sdk/src/sdk.rs b/sdk/src/sdk.rs index 73fa5cc..c4f24b5 100644 --- a/sdk/src/sdk.rs +++ b/sdk/src/sdk.rs @@ -24,6 +24,7 @@ pub mod keystore; pub mod sign; pub mod utils; +pub mod authorize; pub mod l2; #[derive(Debug, thiserror::Error)] From 5377cd5b78f8ffb8b3996a67c4e5fac064eed3ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Paradelo?= Date: Fri, 28 Nov 2025 12:54:34 -0300 Subject: [PATCH 18/18] move logic to proper place --- sdk/src/authorize.rs | 41 ++++++++++++++++++++++++++++++++++++++--- sdk/src/utils.rs | 39 ++------------------------------------- 2 files changed, 40 insertions(+), 40 deletions(-) diff --git a/sdk/src/authorize.rs b/sdk/src/authorize.rs index cd2b96c..5295ca4 100644 --- a/sdk/src/authorize.rs +++ b/sdk/src/authorize.rs @@ -1,13 +1,48 @@ -use ethrex_common::{Address, types::AuthorizationTuple}; +use ethrex_common::{Address, U256, types::AuthorizationTuple}; use ethrex_l2_common::utils::get_address_from_secret_key; +use ethrex_rlp::encode::RLPEncode; use ethrex_rpc::{ EthClient, clients::EthClientError, types::block_identifier::{BlockIdentifier, BlockTag}, }; -use secp256k1::SecretKey; +use keccak_hash::keccak; +use secp256k1::ecdsa::RecoverableSignature; +use secp256k1::{Message, Secp256k1, SecretKey}; -use crate::utils::make_auth_tuple; +// MAGIC is 0x05 (crates/vm/levm/src/constants.rs) +const MAGIC: u8 = 0x05; + +pub fn make_auth_tuple( + signing_key: &SecretKey, + chain_id: u64, + delegated_code_addr: Address, + nonce: u64, +) -> AuthorizationTuple { + // keccak256(MAGIC || rlp([chain_id, address, nonce])) + let mut buf = Vec::with_capacity(1 + 128); + buf.push(MAGIC); + (U256::from(chain_id), delegated_code_addr, nonce).encode(&mut buf); + let digest = keccak(&buf); + let msg = Message::from_digest(digest.into()); + + let secp = Secp256k1::new(); + let sig: RecoverableSignature = secp.sign_ecdsa_recoverable(&msg, signing_key); + let (rec_id, sig_bytes) = sig.serialize_compact(); + + let r_signature = U256::from_big_endian(&sig_bytes[0..32]); + let s_signature = U256::from_big_endian(&sig_bytes[32..64]); + let y_parity = U256::from(Into::::into(rec_id)); + + AuthorizationTuple { + chain_id: U256::from(chain_id), + address: delegated_code_addr, + nonce, + y_parity, + r_signature, + s_signature, + } +} pub async fn build_authorization_tuple( client: &EthClient, diff --git a/sdk/src/utils.rs b/sdk/src/utils.rs index b86f12d..08bf912 100644 --- a/sdk/src/utils.rs +++ b/sdk/src/utils.rs @@ -1,11 +1,7 @@ -use ethrex_common::types::AuthorizationTuple; -use ethrex_common::{Address, H256, U256}; -use ethrex_rlp::encode::RLPEncode; +use ethrex_common::H256; use keccak_hash::keccak; -use secp256k1::ecdsa::RecoverableSignature; -use secp256k1::{Message, Secp256k1, SecretKey}; +use secp256k1::SecretKey; use serde::{Deserialize, Deserializer, Serialize, Serializer}; -const MAGIC: u8 = 0x05; pub fn secret_key_deserializer<'de, D>(deserializer: D) -> Result where @@ -52,34 +48,3 @@ pub fn to_checksum_address(address: &str) -> String { checksummed } - -pub fn make_auth_tuple( - signing_key: &SecretKey, - chain_id: u64, - delegated_code_addr: Address, - nonce: u64, -) -> AuthorizationTuple { - // keccak256(MAGIC || rlp([chain_id, address, nonce])) - let mut buf = Vec::with_capacity(1 + 128); - buf.push(MAGIC); - (U256::from(chain_id), delegated_code_addr, nonce).encode(&mut buf); - let digest = keccak(&buf); - let msg = Message::from_digest(digest.into()); - - let secp = Secp256k1::new(); - let sig: RecoverableSignature = secp.sign_ecdsa_recoverable(&msg, signing_key); - let (rec_id, sig_bytes) = sig.serialize_compact(); - - let r_signature = U256::from_big_endian(&sig_bytes[0..32]); - let s_signature = U256::from_big_endian(&sig_bytes[32..64]); - let y_parity = U256::from(Into::::into(rec_id)); - - AuthorizationTuple { - chain_id: U256::from(chain_id), - address: delegated_code_addr, - nonce, - y_parity, - r_signature, - s_signature, - } -}