Skip to content

Commit a630e1b

Browse files
committed
Merge branch 'feat/deprecate-batcher-url' into fix/partially-verified-batch-should-display-batches
2 parents 29635f6 + 5a5447c commit a630e1b

File tree

137 files changed

+30589
-1942
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

137 files changed

+30589
-1942
lines changed

Makefile

Lines changed: 98 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ CONFIG_FILE?=config-files/config.yaml
77
export OPERATOR_ADDRESS ?= $(shell yq -r '.operator.address' $(CONFIG_FILE))
88
AGG_CONFIG_FILE?=config-files/config-aggregator.yaml
99

10-
OPERATOR_VERSION=v0.12.2
10+
OPERATOR_VERSION=v0.13.0
1111

1212
ifeq ($(OS),Linux)
1313
BUILD_ALL_FFI = $(MAKE) build_all_ffi_linux
@@ -290,6 +290,24 @@ verifier_disable:
290290
@echo "Disabling verifier with ID: $(VERIFIER_ID)"
291291
@. contracts/scripts/.env && . contracts/scripts/disable_verifier.sh $(VERIFIER_ID)
292292

293+
strategies_get_weight:
294+
@echo "Getting weight of strategy: $(STRATEGY_INDEX)"
295+
@. contracts/scripts/.env.$(NETWORK) && . contracts/scripts/get_strategy_weight.sh $(STRATEGY_INDEX)
296+
297+
strategies_update_weight:
298+
@echo "Updating strategy weights: "
299+
@echo "STRATEGY_INDICES: $(STRATEGY_INDICES)"
300+
@echo "NEW_MULTIPLIERS: $(NEW_MULTIPLIERS)"
301+
@. contracts/scripts/.env.$(NETWORK) && . contracts/scripts/update_strategy_weight.sh $(STRATEGY_INDICES) $(NEW_MULTIPLIERS)
302+
303+
strategies_remove:
304+
@echo "Removing strategies: $(INDICES_TO_REMOVE)"
305+
@. contracts/scripts/.env.$(NETWORK) && . contracts/scripts/remove_strategy.sh $(INDICES_TO_REMOVE)
306+
307+
strategies_get_addresses:
308+
@echo "Getting strategy addresses"
309+
@. contracts/scripts/.env.$(NETWORK) && . contracts/scripts/get_restakeable_strategies.sh
310+
293311
__BATCHER__:
294312

295313
BURST_SIZE ?= 5
@@ -486,16 +504,15 @@ task_sender_send_infinite_proofs_devnet:
486504
cargo run --release -- send-infinite-proofs \
487505
--burst-size $(BURST_SIZE) --burst-time-secs $(BURST_TIME_SECS) \
488506
--eth-rpc-url http://localhost:8545 \
489-
--batcher-url ws://localhost:8080 \
490507
--network devnet \
491508
--proofs-dirpath $(CURDIR)/scripts/test_files/task_sender/proofs \
492509
--private-keys-filepath $(CURDIR)/batcher/aligned-task-sender/wallets/devnet
493510

494511
task_sender_test_connections_devnet:
495512
@cd batcher/aligned-task-sender && \
496513
cargo run --release -- test-connections \
497-
--batcher-url ws://localhost:8080 \
498-
--num-senders $(NUM_SENDERS)
514+
--num-senders $(NUM_SENDERS) \
515+
--network devnet
499516

500517
# ===== HOLESKY-STAGE =====
501518
task_sender_generate_and_fund_wallets_holesky_stage:
@@ -514,21 +531,21 @@ task_sender_send_infinite_proofs_holesky_stage:
514531
cargo run --release -- send-infinite-proofs \
515532
--burst-size $(BURST_SIZE) --burst-time-secs $(BURST_TIME_SECS) \
516533
--eth-rpc-url https://ethereum-holesky-rpc.publicnode.com \
517-
--batcher-url wss://stage.batcher.alignedlayer.com \
518534
--network holesky-stage \
519535
--proofs-dirpath $(CURDIR)/scripts/test_files/task_sender/proofs \
520536
--private-keys-filepath $(CURDIR)/batcher/aligned-task-sender/wallets/holesky-stage
521537

522538
task_sender_test_connections_holesky_stage:
523539
@cd batcher/aligned-task-sender && \
524540
cargo run --release -- test-connections \
525-
--batcher-url wss://stage.batcher.alignedlayer.com \
526-
--num-senders $(NUM_SENDERS)
541+
--num-senders $(NUM_SENDERS) \
542+
--network holesky-stage
527543

528544
__UTILS__:
529545
aligned_get_user_balance_devnet:
530546
@cd batcher/aligned/ && cargo run --release -- get-user-balance \
531-
--user_addr $(USER_ADDR)
547+
--user_addr $(USER_ADDR) \
548+
--network devnet
532549

533550
aligned_get_user_balance_holesky:
534551
@cd batcher/aligned/ && cargo run --release -- get-user-balance \
@@ -557,7 +574,13 @@ generate_groth16_ineq_proof: ## Run the gnark_plonk_bn254_script
557574
@go run scripts/test_files/gnark_groth16_bn254_infinite_script/cmd/main.go 1
558575

559576
__METRICS__:
560-
# Prometheus and graphana
577+
# Prometheus and Grafana
578+
metrics_remove_containers:
579+
@docker stop prometheus grafana
580+
@docker rm prometheus grafana
581+
metrics_clean_db: metrics_remove_containers
582+
@docker volume rm aligned_layer_grafana_data aligned_layer_prometheus_data
583+
561584
run_metrics: ## Run metrics using metrics-docker-compose.yaml
562585
@echo "Running metrics..."
563586
@docker compose -f metrics-docker-compose.yaml up
@@ -1040,11 +1063,18 @@ docker_verify_proof_submission_success:
10401063
verification=$$(aligned verify-proof-onchain \
10411064
--aligned-verification-data $${proof} \
10421065
--rpc_url $$(echo $(DOCKER_RPC_URL)) 2>&1); \
1066+
cat $${proof%.cbor}.json; \
1067+
echo "$$verification"; \
10431068
if echo "$$verification" | grep -q not; then \
10441069
echo "ERROR: Proof verification failed for $${proof}"; \
10451070
exit 1; \
10461071
elif echo "$$verification" | grep -q verified; then \
10471072
echo "Proof verification succeeded for $${proof}"; \
1073+
else \
1074+
echo "WARNING: Unexpected verification result for $${proof}"; \
1075+
echo "Output:"; \
1076+
echo "$$verification"; \
1077+
exit 1; \
10481078
fi; \
10491079
echo "---------------------------------------------------------------------------------------------------"; \
10501080
done; \
@@ -1202,3 +1232,62 @@ ansible_operator_deploy: ## Deploy the Operator. Parameters: INVENTORY
12021232
-i $(INVENTORY) \
12031233
-e "ecdsa_keystore_path=$(ECDSA_KEYSTORE)" \
12041234
-e "bls_keystore_path=$(BLS_KEYSTORE)"
1235+
1236+
__ETHEREUM_PACKAGE__: ## ____
1237+
1238+
ethereum_package_start: ## Starts the ethereum_package environment
1239+
kurtosis run --enclave aligned github.com/ethpandaops/ethereum-package --args-file network_params.yaml
1240+
1241+
ethereum_package_inspect: ## Prints detailed information about the net
1242+
kurtosis enclave inspect aligned
1243+
1244+
ethereum_package_rm: ## Stops and removes the ethereum_package environment and used resources
1245+
kurtosis enclave rm aligned -f
1246+
1247+
batcher_start_ethereum_package: user_fund_payment_service
1248+
@echo "Starting Batcher..."
1249+
@$(MAKE) run_storage &
1250+
@cargo run --manifest-path ./batcher/aligned-batcher/Cargo.toml --release -- --config ./config-files/config-batcher-ethereum-package.yaml --env-file ./batcher/aligned-batcher/.env.dev
1251+
1252+
aggregator_start_ethereum_package:
1253+
$(MAKE) aggregator_start AGG_CONFIG_FILE=config-files/config-aggregator-ethereum-package.yaml
1254+
1255+
operator_start_ethereum_package:
1256+
$(MAKE) operator_start OPERATOR_ADDRESS=0x70997970C51812dc3A010C7d01b50e0d17dc79C8 CONFIG_FILE=config-files/config-operator-1-ethereum-package.yaml
1257+
1258+
operator_register_start_ethereum_package:
1259+
$(MAKE) operator_full_registration OPERATOR_ADDRESS=0x70997970C51812dc3A010C7d01b50e0d17dc79C8 CONFIG_FILE=config-files/config-operator-1-ethereum-package.yaml \
1260+
$(MAKE) operator_start OPERATOR_ADDRESS=0x70997970C51812dc3A010C7d01b50e0d17dc79C8 CONFIG_FILE=config-files/config-operator-1-ethereum-package.yaml
1261+
1262+
1263+
install_spamoor: ## Instal spamoor to spam transactions
1264+
@echo "Installing spamoor..."
1265+
@git clone https://github.com/ethpandaops/spamoor.git
1266+
@cd spamoor && make
1267+
@mv spamoor/bin/spamoor $(HOME)/.local/bin
1268+
@rm -rf spamoor
1269+
@echo "======================================================================="
1270+
@echo "Installation complete! Run 'spamoor --help' to verify the installation."
1271+
@echo "If 'spamoor' is not recognized, make sure it's in your PATH by adding the following line to your shell configuration:"
1272+
@echo "export PATH=\$$PATH:\$$HOME/.local/bin"
1273+
@echo "======================================================================="
1274+
1275+
# Spamoor funding wallet
1276+
SPAMOOR_PRIVATE_KEY?=dbda1821b80551c9d65939329250298aa3472ba22feea921c0cf5d620ea67b97
1277+
NUM_WALLETS?=1000
1278+
TX_PER_BLOCK?=250
1279+
# Similar to a swap
1280+
TX_CONSUMES_GAS?=150000
1281+
1282+
spamoor_send_transactions: ## Sends normal transactions and also replacement transactions
1283+
spamoor gasburnertx -p $(SPAMOOR_PRIVATE_KEY) -c $(COUNT) \
1284+
--gas-units-to-burn $(TX_CONSUMES_GAS) \
1285+
--max-wallets $(NUM_WALLETS) --max-pending $(TX_PER_BLOCK) \
1286+
-t $(TX_PER_BLOCK) -h http://127.0.0.1:8545/ -h http://127.0.0.1:8550/ -h http://127.0.0.1:8555/ -h http://127.0.0.1:8565/ \
1287+
--refill-amount 5 --refill-balance 2 --tipfee $(TIP_FEE) --basefee 100 \
1288+
2>&1 | grep -v 'checked child wallets (no funding needed)'
1289+
1290+
__NODE_EXPORTER_: ##__
1291+
1292+
install_node_exporter:
1293+
@./scripts/install_node_exporter.sh

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: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,13 @@ EXPRESSION=<GREP_EXPRESSION>
1919
RPC_URL=<YOUR_RPC_URL>
2020
PAYMENT_CONTRACT_ADDRESS=<YOUR_PAYMENT_CONTRACT_ADDRESS>
2121
BALANCE_THRESHOLD=<YOUR_BALANCE_THRESHOLD_IN_ETH>
22+
WALLET_NAME=<YOUR_WALLET_NAME> # Example: "Task sender"
2223
WALLET_ADDRESS=<YOUR_WALLET_ADDRESS>
24+
NETWORK=<MAINNET|HOLESKY|STAGE>
2325

2426
# Variables for sender_with_alert.sh
2527
REPETITIONS=<REPETITIONS>
2628
SENDER_ADDRESS=<YOUR_SENDER_ADDRESS>
27-
BATCHER_URL=<BATCHER_URL>
2829
RPC_URL=<RPC_BASE_URL>
2930
EXPLORER_URL=<EXPLORER_BASE_URL>
3031
NETWORK=<NETWORK>

alerts/balance_alerts.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ balance_alert=false
2525

2626
while :
2727
do
28-
balance_wei=$(cast call --rpc-url $RPC_URL $PAYMENT_CONTRACT_ADDRESS "UserBalances(address)(uint256)" $WALLET_ADDRESS | cut -d' ' -f1)
28+
balance_wei=$(cast call --rpc-url $RPC_URL $PAYMENT_CONTRACT_ADDRESS "user_balances(address)(uint256)" $WALLET_ADDRESS | cut -d' ' -f1)
2929

3030
balance_eth=$(cast from-wei $balance_wei)
3131

3232
if [ 1 -eq "$(echo "$balance_eth < $BALANCE_THRESHOLD" | bc)" ]; then
33-
message="⚠️ WARNING: Wallet $WALLET_ADDRESS balance ($balance_eth ETH) is below $BALANCE_THRESHOLD ETH"
33+
message="⚠️ WARNING: $WALLET_NAME ($NETWORK) Wallet ($WALLET_ADDRESS) balance ($balance_eth ETH) is below $BALANCE_THRESHOLD ETH"
3434
printf "$message\n"
3535
if [ "$balance_alert" = false ]; then
3636
send_slack_message "$message"

alerts/sender_with_alert.sh

Lines changed: 25 additions & 6 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
@@ -53,6 +52,22 @@ function fetch_tx_cost() {
5352
fi
5453
}
5554

55+
# Function to get the tx cost from the tx hash
56+
# @param tx_hash
57+
function get_number_proofs_in_batch_from_create_task_tx() {
58+
if [[ -z "$1" ]]; then
59+
echo 0
60+
else
61+
# Get the tx receipt from the blockchain
62+
calldata=$(cast tx $1 --rpc-url $RPC_URL input)
63+
decoded_calldata=$(cast --calldata-decode --json "createNewTask(bytes32 batchMerkleRoot, string batchDataPointer, address[] proofSubmitters, uint256 feeForAggregator, uint256 feePerProof, uint256 respondToTaskFeeLimit)" $calldata)
64+
# We count the number of proofSubmitters within the tx which corresponds to the number of proofs sent in the last batch
65+
number_proofs_in_batch=$(echo $decoded_calldata | jq '.[2] | [ match(","; "g")] | length + 1')
66+
67+
echo $number_proofs_in_batch
68+
fi
69+
}
70+
5671
# Function to send PagerDuty alert
5772
# @param message
5873
function send_pagerduty_alert() {
@@ -76,7 +91,7 @@ do
7691
mkdir -p ./scripts/test_files/gnark_groth16_bn254_infinite_script/infinite_proofs
7792

7893
## Generate Proof
79-
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}')
8095
x=$((nonce + 1)) # So we don't have any issues with nonce = 0
8196
echo "Generating proof $x != 0"
8297
go run ./scripts/test_files/gnark_groth16_bn254_infinite_script/cmd/main.go $x
@@ -92,9 +107,8 @@ do
92107
--proof_generator_addr $SENDER_ADDRESS \
93108
--private_key $PRIVATE_KEY \
94109
--rpc_url $RPC_URL \
95-
--batcher_url $BATCHER_URL \
96110
--network $NETWORK \
97-
--max_fee 4000000000000000 \
111+
--max_fee 0.004ether \
98112
2>&1)
99113

100114
echo "$submit"
@@ -113,6 +127,7 @@ do
113127
fi
114128

115129
total_fee_in_wei=0
130+
total_number_proofs=0
116131
batch_explorer_urls=()
117132
for batch_merkle_root in $batch_merkle_roots
118133
do
@@ -127,12 +142,16 @@ do
127142
response_tx_hash=$(echo "$log" | grep -oE "transactionHash: 0x[[:alnum:]]{64}" | awk '{ print $2 }')
128143

129144
# Calculate fees for transactions
145+
number_proofs_in_batch=$(get_number_proofs_in_batch_from_create_task_tx $submission_tx_hash)
130146
submission_fee_in_wei=$(fetch_tx_cost $submission_tx_hash)
131147
response_fee_in_wei=$(fetch_tx_cost $response_tx_hash)
132148
batch_fee_in_wei=$((submission_fee_in_wei + response_fee_in_wei))
133149

134150
# Accumulate the fee
135151
total_fee_in_wei=$(($total_fee_in_wei + $batch_fee_in_wei))
152+
153+
# Accumulate proofs in batch
154+
total_number_proofs=$(($total_number_proofs + $number_proofs_in_batch))
136155
done
137156

138157
# Calculate the spent amount by converting the fee to ETH
@@ -168,9 +187,9 @@ do
168187
done
169188

170189
if [ $verified -eq 1 ]; then
171-
slack_message="$REPETITIONS Proofs submitted and verified. Spent amount: $spent_amount ETH ($ $spent_amount_usd) [ ${batch_explorer_urls[@]} ]"
190+
slack_message="$total_number_proofs proofs submitted and verified. We sent $REPETITIONS proofs. Spent amount: $spent_amount ETH ($ $spent_amount_usd) [ ${batch_explorer_urls[@]} ]"
172191
else
173-
slack_message="$REPETITIONS Proofs submitted but not verified. Spent amount: $spent_amount ETH ($ $spent_amount_usd) [ ${batch_explorer_urls[@]} ]"
192+
slack_message="$total_number_proofs proofs submitted but not verified. We sent $REPETITIONS proofs. Spent amount: $spent_amount ETH ($ $spent_amount_usd) [ ${batch_explorer_urls[@]} ]"
174193
fi
175194

176195
## Send Update to Slack
173 KB
Binary file not shown.

batcher/Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

batcher/aligned-batcher/src/config/mod.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ impl NonPayingConfig {
3737

3838
#[derive(Debug, Deserialize)]
3939
pub struct BatcherConfigFromYaml {
40+
#[serde(default = "default_aggregator_fee_percentage_multiplier")]
41+
pub aggregator_fee_percentage_multiplier: u128,
42+
#[serde(default = "default_aggregator_gas_cost")]
43+
pub aggregator_gas_cost: u128,
4044
pub block_interval: u64,
4145
pub transaction_wait_timeout: u64,
4246
pub max_proof_size: usize,
@@ -86,3 +90,11 @@ impl ContractDeploymentOutput {
8690
serde_json::from_str(&deployment_output).expect("Failed to parse deployment output file")
8791
}
8892
}
93+
94+
fn default_aggregator_fee_percentage_multiplier() -> u128 {
95+
aligned_sdk::core::constants::DEFAULT_AGGREGATOR_FEE_PERCENTAGE_MULTIPLIER
96+
}
97+
98+
fn default_aggregator_gas_cost() -> u128 {
99+
aligned_sdk::core::constants::DEFAULT_AGGREGATOR_GAS_COST
100+
}

batcher/aligned-batcher/src/connection.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ pub(crate) async fn send_batch_inclusion_data_responses(
2121
finalized_batch: Vec<BatchQueueEntry>,
2222
batch_merkle_tree: &MerkleTree<VerificationCommitmentBatch>,
2323
) -> Result<(), BatcherError> {
24-
for (vd_batch_idx, entry) in finalized_batch.iter().enumerate() {
24+
// Finalized_batch is ordered as the PriorityQueue, ordered by: ascending max_fee && if max_fee is equal, by descending nonce.
25+
// We iter it in reverse because each sender wants to receive responses in ascending nonce order
26+
for (vd_batch_idx, entry) in finalized_batch.iter().enumerate().rev() {
2527
let batch_inclusion_data = BatchInclusionData::new(
2628
vd_batch_idx,
2729
batch_merkle_tree,

0 commit comments

Comments
 (0)