Skip to content

Commit 0525847

Browse files
PatStilesuri-99JuArce
authored
feat: Remove batcher_url parameter + better network parameter (#1730)
Co-authored-by: Urix <[email protected]> Co-authored-by: JuArce <[email protected]>
1 parent 75ae277 commit 0525847

File tree

17 files changed

+356
-247
lines changed

17 files changed

+356
-247
lines changed

Makefile

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -504,16 +504,15 @@ task_sender_send_infinite_proofs_devnet:
504504
cargo run --release -- send-infinite-proofs \
505505
--burst-size $(BURST_SIZE) --burst-time-secs $(BURST_TIME_SECS) \
506506
--eth-rpc-url http://localhost:8545 \
507-
--batcher-url ws://localhost:8080 \
508507
--network devnet \
509508
--proofs-dirpath $(CURDIR)/scripts/test_files/task_sender/proofs \
510509
--private-keys-filepath $(CURDIR)/batcher/aligned-task-sender/wallets/devnet
511510

512511
task_sender_test_connections_devnet:
513512
@cd batcher/aligned-task-sender && \
514513
cargo run --release -- test-connections \
515-
--batcher-url ws://localhost:8080 \
516-
--num-senders $(NUM_SENDERS)
514+
--num-senders $(NUM_SENDERS) \
515+
--network devnet
517516

518517
# ===== HOLESKY-STAGE =====
519518
task_sender_generate_and_fund_wallets_holesky_stage:
@@ -532,21 +531,21 @@ task_sender_send_infinite_proofs_holesky_stage:
532531
cargo run --release -- send-infinite-proofs \
533532
--burst-size $(BURST_SIZE) --burst-time-secs $(BURST_TIME_SECS) \
534533
--eth-rpc-url https://ethereum-holesky-rpc.publicnode.com \
535-
--batcher-url wss://stage.batcher.alignedlayer.com \
536534
--network holesky-stage \
537535
--proofs-dirpath $(CURDIR)/scripts/test_files/task_sender/proofs \
538536
--private-keys-filepath $(CURDIR)/batcher/aligned-task-sender/wallets/holesky-stage
539537

540538
task_sender_test_connections_holesky_stage:
541539
@cd batcher/aligned-task-sender && \
542540
cargo run --release -- test-connections \
543-
--batcher-url wss://stage.batcher.alignedlayer.com \
544-
--num-senders $(NUM_SENDERS)
541+
--num-senders $(NUM_SENDERS) \
542+
--network holesky-stage
545543

546544
__UTILS__:
547545
aligned_get_user_balance_devnet:
548546
@cd batcher/aligned/ && cargo run --release -- get-user-balance \
549-
--user_addr $(USER_ADDR)
547+
--user_addr $(USER_ADDR) \
548+
--network devnet
550549

551550
aligned_get_user_balance_holesky:
552551
@cd batcher/aligned/ && cargo run --release -- get-user-balance \

alerts/.env.devnet

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
# Variables for sender_with_alert.sh
2525
REPETITIONS=8
2626
SENDER_ADDRESS=0x14dC79964da2C08b23698B3D3cc7Ca32193d9955
27-
BATCHER_URL=ws://localhost:8080
2827
RPC_URL=http://localhost:8545
2928
EXPLORER_URL=http://localhost:3000
3029
NETWORK=devnet

alerts/.env.example

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ NETWORK=<MAINNET|HOLESKY|STAGE>
2626
# Variables for sender_with_alert.sh
2727
REPETITIONS=<REPETITIONS>
2828
SENDER_ADDRESS=<YOUR_SENDER_ADDRESS>
29-
BATCHER_URL=<BATCHER_URL>
3029
RPC_URL=<RPC_BASE_URL>
3130
EXPLORER_URL=<EXPLORER_BASE_URL>
3231
NETWORK=<NETWORK>

alerts/sender_with_alert.sh

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
# - REPETITIONS
55
# - EXPLORER_URL
66
# - SENDER_ADDRESS
7-
# - BATCHER_URL
87
# - RPC_URL
98
# - EXPLORER_URL
109
# - NETWORK
@@ -92,7 +91,7 @@ do
9291
mkdir -p ./scripts/test_files/gnark_groth16_bn254_infinite_script/infinite_proofs
9392

9493
## Generate Proof
95-
nonce=$(aligned get-user-nonce --batcher_url $BATCHER_URL --user_addr $SENDER_ADDRESS 2>&1 | awk '{print $9}')
94+
nonce=$(aligned get-user-nonce --network $NETWORK --user_addr $SENDER_ADDRESS 2>&1 | awk '{print $9}')
9695
x=$((nonce + 1)) # So we don't have any issues with nonce = 0
9796
echo "Generating proof $x != 0"
9897
go run ./scripts/test_files/gnark_groth16_bn254_infinite_script/cmd/main.go $x
@@ -108,7 +107,6 @@ do
108107
--proof_generator_addr $SENDER_ADDRESS \
109108
--private_key $PRIVATE_KEY \
110109
--rpc_url $RPC_URL \
111-
--batcher_url $BATCHER_URL \
112110
--network $NETWORK \
113111
--max_fee 0.004ether \
114112
2>&1)

batcher/aligned-batcher/src/lib.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1522,10 +1522,7 @@ impl Batcher {
15221522
Ok(())
15231523
}
15241524
Err(e) => {
1525-
error!(
1526-
"Failed to send batch to contract, batch will be lost: {:?}",
1527-
e
1528-
);
1525+
error!("Failed to send batch to contract: {:?}", e);
15291526

15301527
self.metrics.reverted_batches.inc();
15311528
Err(e)

batcher/aligned-sdk/src/communication/batch.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ pub async fn await_batch_verification(
4141
network: Network,
4242
) -> Result<(), errors::SubmitError> {
4343
for _ in 0..RETRIES {
44-
if is_proof_verified(aligned_verification_data, network, rpc_url)
44+
if is_proof_verified(aligned_verification_data, network.clone(), rpc_url)
4545
.await
4646
.is_ok_and(|r| r)
4747
{

batcher/aligned-sdk/src/core/constants.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,25 @@ pub const BUMP_MIN_RETRY_DELAY: u64 = 500; // milliseconds
3838
pub const BUMP_MAX_RETRIES: usize = 33; // ~ 1 day
3939
pub const BUMP_BACKOFF_FACTOR: f32 = 2.0;
4040
pub const BUMP_MAX_RETRY_DELAY: u64 = 3600; // seconds
41+
42+
/// NETWORK ADDRESSES ///
43+
/// BatcherPaymentService
44+
pub const BATCHER_PAYMENT_SERVICE_ADDRESS_DEVNET: &str =
45+
"0x7bc06c482DEAd17c0e297aFbC32f6e63d3846650";
46+
pub const BATCHER_PAYMENT_SERVICE_ADDRESS_HOLESKY: &str =
47+
"0x815aeCA64a974297942D2Bbf034ABEe22a38A003";
48+
pub const BATCHER_PAYMENT_SERVICE_ADDRESS_HOLESKY_STAGE: &str =
49+
"0x7577Ec4ccC1E6C529162ec8019A49C13F6DAd98b";
50+
pub const BATCHER_PAYMENT_SERVICE_ADDRESS_MAINNET: &str =
51+
"0xb0567184A52cB40956df6333510d6eF35B89C8de";
52+
/// AlignedServiceManager
53+
pub const ALIGNED_SERVICE_MANAGER_DEVNET: &str = "0x851356ae760d987E095750cCeb3bC6014560891C";
54+
pub const ALIGNED_SERVICE_MANAGER_HOLESKY: &str = "0x58F280BeBE9B34c9939C3C39e0890C81f163B623";
55+
pub const ALIGNED_SERVICE_MANAGER_HOLESKY_STAGE: &str =
56+
"0x9C5231FC88059C086Ea95712d105A2026048c39B";
57+
pub const ALIGNED_SERVICE_MANAGER_MAINNET: &str = "0xeF2A435e5EE44B2041100EF8cbC8ae035166606c";
58+
/// Batcher URL's
59+
pub const BATCHER_URL_DEVNET: &str = "ws://localhost:8080";
60+
pub const BATCHER_URL_HOLESKY: &str = "wss://batcher.alignedlayer.com";
61+
pub const BATCHER_URL_HOLESKY_STAGE: &str = "wss://stage.batcher.alignedlayer.com";
62+
pub const BATCHER_URL_MAINNET: &str = "wss://mainnet.batcher.alignedlayer.com";

batcher/aligned-sdk/src/core/types.rs

Lines changed: 40 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,21 @@ use ethers::types::transaction::eip712::Eip712;
1111
use ethers::types::transaction::eip712::Eip712Error;
1212
use ethers::types::Address;
1313
use ethers::types::Signature;
14+
use ethers::types::H160;
1415
use ethers::types::U256;
1516
use lambdaworks_crypto::merkle_tree::{
1617
merkle::MerkleTree, proof::Proof, traits::IsMerkleTreeBackend,
1718
};
1819
use serde::{Deserialize, Serialize};
1920
use sha3::{Digest, Keccak256};
2021

22+
use super::constants::{
23+
ALIGNED_SERVICE_MANAGER_DEVNET, ALIGNED_SERVICE_MANAGER_HOLESKY,
24+
ALIGNED_SERVICE_MANAGER_HOLESKY_STAGE, ALIGNED_SERVICE_MANAGER_MAINNET,
25+
BATCHER_PAYMENT_SERVICE_ADDRESS_DEVNET, BATCHER_PAYMENT_SERVICE_ADDRESS_HOLESKY,
26+
BATCHER_PAYMENT_SERVICE_ADDRESS_HOLESKY_STAGE, BATCHER_PAYMENT_SERVICE_ADDRESS_MAINNET,
27+
BATCHER_URL_DEVNET, BATCHER_URL_HOLESKY, BATCHER_URL_HOLESKY_STAGE, BATCHER_URL_MAINNET,
28+
};
2129
use super::errors::VerifySignatureError;
2230

2331
// VerificationData is a bytes32 instead of a VerificationData struct because in the BatcherPaymentService contract
@@ -396,27 +404,45 @@ pub enum GetNonceResponseMessage {
396404
InvalidRequest(String),
397405
}
398406

399-
#[derive(Debug, Clone, Copy)]
407+
#[derive(Debug, Clone)]
400408
pub enum Network {
401409
Devnet,
402410
Holesky,
403411
HoleskyStage,
404412
Mainnet,
413+
Custom(String, String, String),
405414
}
406415

407-
impl FromStr for Network {
408-
type Err = String;
409-
410-
fn from_str(s: &str) -> Result<Self, Self::Err> {
411-
match s.to_lowercase().as_str() {
412-
"holesky" => Ok(Network::Holesky),
413-
"holesky-stage" => Ok(Network::HoleskyStage),
414-
"devnet" => Ok(Network::Devnet),
415-
"mainnet" => Ok(Network::Mainnet),
416-
_ => Err(
417-
"Invalid network, possible values are: \"holesky\", \"holesky-stage\", \"devnet\", \"mainnet\""
418-
.to_string(),
419-
),
416+
impl Network {
417+
pub fn get_aligned_service_manager_address(&self) -> ethers::types::H160 {
418+
match self {
419+
Self::Devnet => H160::from_str(ALIGNED_SERVICE_MANAGER_DEVNET).unwrap(),
420+
Self::Holesky => H160::from_str(ALIGNED_SERVICE_MANAGER_HOLESKY).unwrap(),
421+
Self::HoleskyStage => H160::from_str(ALIGNED_SERVICE_MANAGER_HOLESKY_STAGE).unwrap(),
422+
Self::Mainnet => H160::from_str(ALIGNED_SERVICE_MANAGER_MAINNET).unwrap(),
423+
Self::Custom(s, _, _) => H160::from_str(s.as_str()).unwrap(),
424+
}
425+
}
426+
427+
pub fn get_batcher_payment_service_address(&self) -> ethers::types::H160 {
428+
match self {
429+
Self::Devnet => H160::from_str(BATCHER_PAYMENT_SERVICE_ADDRESS_DEVNET).unwrap(),
430+
Self::Holesky => H160::from_str(BATCHER_PAYMENT_SERVICE_ADDRESS_HOLESKY).unwrap(),
431+
Self::HoleskyStage => {
432+
H160::from_str(BATCHER_PAYMENT_SERVICE_ADDRESS_HOLESKY_STAGE).unwrap()
433+
}
434+
Self::Mainnet => H160::from_str(BATCHER_PAYMENT_SERVICE_ADDRESS_MAINNET).unwrap(),
435+
Self::Custom(_, s, _) => H160::from_str(s.as_str()).unwrap(),
436+
}
437+
}
438+
439+
pub fn get_batcher_url(&self) -> &str {
440+
match self {
441+
Self::Devnet => BATCHER_URL_DEVNET,
442+
Self::Holesky => BATCHER_URL_HOLESKY,
443+
Self::HoleskyStage => BATCHER_URL_HOLESKY_STAGE,
444+
Self::Mainnet => BATCHER_URL_MAINNET,
445+
Self::Custom(_, _, s) => s.as_str(),
420446
}
421447
}
422448
}

0 commit comments

Comments
 (0)