Skip to content

Commit f25a0f1

Browse files
authored
Merge branch 'testnet' into simplify_readme
2 parents d474229 + ceb0517 commit f25a0f1

54 files changed

Lines changed: 564 additions & 204 deletions

Some content is hidden

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

.github/workflows/foundry-gas-diff.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
FOUNDRY_FUZZ_SEED: 0x${{ github.event.pull_request.base.sha || github.sha }}
3636

3737
- name: Compare gas reports
38-
uses: Rubilmax/foundry-gas-diff@v3.16
38+
uses: Rubilmax/foundry-gas-diff@v3.21
3939
with:
4040
summaryQuantile: 0.9 # only display the 10% most significant gas diffs in the summary (defaults to 20%)
4141
sortCriteria: avg,max # sort diff rows by criteria

.github/workflows/send-proofs-docker.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ on:
1010
- '**.md'
1111

1212
concurrency:
13-
group: pull_request-${{ github.event.pull_request.number }}
13+
group: ${{ github.event_name == 'merge_group' && format('merge_group-{0}', github.event.merge_group.head_sha) || format('pull_request-{0}', github.event.pull_request.number) }}
1414
cancel-in-progress: true
1515

1616
jobs:

Makefile

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ 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.13.0
10+
OPERATOR_VERSION=v0.14.0
11+
EIGEN_SDK_GO_VERSION_TESTNET=v0.2.0-beta.1
12+
EIGEN_SDK_GO_VERSION_MAINNET=v0.1.13
1113

1214
ifeq ($(OS),Linux)
1315
BUILD_ALL_FFI = $(MAKE) build_all_ffi_linux
@@ -30,6 +32,16 @@ ifeq ($(OS),Darwin)
3032
BUILD_OPERATOR = $(MAKE) build_operator_macos
3133
endif
3234

35+
ifeq ($(ENVIRONMENT), devnet)
36+
GET_SDK_VERSION = $(MAKE) operator_set_eigen_sdk_go_version_devnet
37+
else ifeq ($(ENVIRONMENT), testnet)
38+
GET_SDK_VERSION = $(MAKE) operator_set_eigen_sdk_go_version_testnet
39+
else ifeq ($(ENVIRONMENT), mainnet)
40+
GET_SDK_VERSION = $(MAKE) operator_set_eigen_sdk_go_version_mainnet
41+
else
42+
GET_SDK_VERSION = $(MAKE) operator_set_eigen_sdk_go_version_error
43+
endif
44+
3345

3446
FFI_FOR_RELEASE ?= true
3547

@@ -140,7 +152,13 @@ anvil_start_with_block_time_with_more_prefunded_accounts:
140152

141153
_AGGREGATOR_:
142154

155+
build_aggregator:
156+
$(GET_SDK_VERSION)
157+
@echo "Building aggregator"
158+
@go build -o ./build/aligned-aggregator ./aggregator/cmd/main.go
159+
143160
aggregator_start:
161+
$(GET_SDK_VERSION)
144162
@echo "Starting Aggregator..."
145163
@go run aggregator/cmd/main.go --config $(AGG_CONFIG_FILE) \
146164
2>&1 | zap-pretty
@@ -156,15 +174,31 @@ test_go_retries:
156174
__OPERATOR__:
157175

158176
operator_start:
177+
$(GET_SDK_VERSION)
159178
@echo "Starting Operator..."
160179
go run operator/cmd/main.go start --config $(CONFIG_FILE) \
161180
2>&1 | zap-pretty
162181

182+
operator_set_eigen_sdk_go_version_testnet:
183+
@echo "Setting Eigen SDK version to: $(EIGEN_SDK_GO_VERSION_TESTNET)"
184+
go get github.com/Layr-Labs/eigensdk-go@$(EIGEN_SDK_GO_VERSION_TESTNET)
185+
186+
operator_set_eigen_sdk_go_version_devnet: operator_set_eigen_sdk_go_version_mainnet
187+
188+
operator_set_eigen_sdk_go_version_mainnet:
189+
@echo "Setting Eigen SDK version to: $(EIGEN_SDK_GO_VERSION_MAINNET)"
190+
go get github.com/Layr-Labs/eigensdk-go@$(EIGEN_SDK_GO_VERSION_MAINNET)
191+
192+
operator_set_eigen_sdk_go_version_error:
193+
@echo "Error setting Eigen SDK version, missing ENVIRONMENT. Possible values for ENVIRONMENT=<devnet|testnet|mainnet>"
194+
exit 1
195+
163196
operator_full_registration: operator_get_eth operator_register_with_eigen_layer operator_mint_mock_tokens operator_deposit_into_mock_strategy operator_whitelist_devnet operator_register_with_aligned_layer
164197

165198
operator_register_and_start: operator_full_registration operator_start
166199

167200
build_operator: deps
201+
$(GET_SDK_VERSION)
168202
$(BUILD_OPERATOR)
169203

170204
build_operator_macos:
@@ -178,6 +212,7 @@ build_operator_linux:
178212
@echo "Operator built into /operator/build/aligned-operator"
179213

180214
update_operator:
215+
$(GET_SDK_VERSION)
181216
@echo "Updating Operator..."
182217
@./scripts/fetch_latest_release.sh
183218
@make build_operator
@@ -1046,11 +1081,18 @@ docker_verify_proof_submission_success:
10461081
verification=$$(aligned verify-proof-onchain \
10471082
--aligned-verification-data $${proof} \
10481083
--rpc_url $$(echo $(DOCKER_RPC_URL)) 2>&1); \
1084+
cat $${proof%.cbor}.json; \
1085+
echo "$$verification"; \
10491086
if echo "$$verification" | grep -q not; then \
10501087
echo "ERROR: Proof verification failed for $${proof}"; \
10511088
exit 1; \
10521089
elif echo "$$verification" | grep -q verified; then \
10531090
echo "Proof verification succeeded for $${proof}"; \
1091+
else \
1092+
echo "WARNING: Unexpected verification result for $${proof}"; \
1093+
echo "Output:"; \
1094+
echo "$$verification"; \
1095+
exit 1; \
10541096
fi; \
10551097
echo "---------------------------------------------------------------------------------------------------"; \
10561098
done; \

aggregator/pkg/server.go

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package pkg
33
import (
44
"context"
55
"encoding/hex"
6+
"errors"
67
"fmt"
78
"net/http"
89
"net/rpc"
@@ -48,6 +49,17 @@ func (agg *Aggregator) ProcessOperatorSignedTaskResponseV2(signedTaskResponse *t
4849
"SenderAddress", "0x"+hex.EncodeToString(signedTaskResponse.SenderAddress[:]),
4950
"BatchIdentifierHash", "0x"+hex.EncodeToString(signedTaskResponse.BatchIdentifierHash[:]),
5051
"operatorId", hex.EncodeToString(signedTaskResponse.OperatorId[:]))
52+
53+
if signedTaskResponse.BlsSignature.G1Point == nil {
54+
agg.logger.Warn("invalid operator response with nil signature",
55+
"BatchMerkleRoot", "0x"+hex.EncodeToString(signedTaskResponse.BatchMerkleRoot[:]),
56+
"SenderAddress", "0x"+hex.EncodeToString(signedTaskResponse.SenderAddress[:]),
57+
"BatchIdentifierHash", "0x"+hex.EncodeToString(signedTaskResponse.BatchIdentifierHash[:]),
58+
"operatorId", hex.EncodeToString(signedTaskResponse.OperatorId[:]))
59+
*reply = 1
60+
return errors.New("invalid response: nil signature")
61+
}
62+
5163
taskIndex := uint32(0)
5264

5365
// The Aggregator may receive the Task Identifier after the operators.
@@ -69,7 +81,7 @@ func (agg *Aggregator) ProcessOperatorSignedTaskResponseV2(signedTaskResponse *t
6981
defer cancel() // Ensure the cancel function is called to release resources
7082

7183
// Create a channel to signal when the task is done
72-
done := make(chan struct{})
84+
done := make(chan uint8)
7385

7486
agg.logger.Info("Starting bls signature process")
7587
go func() {
@@ -80,9 +92,11 @@ func (agg *Aggregator) ProcessOperatorSignedTaskResponseV2(signedTaskResponse *t
8092

8193
if err != nil {
8294
agg.logger.Warnf("BLS aggregation service error: %s", err)
95+
done<- 1
8396
// todo shouldn't we here close the channel with a reply = 1?
8497
} else {
8598
agg.logger.Info("BLS process succeeded")
99+
done<- 0
86100
}
87101

88102
close(done)
@@ -94,10 +108,10 @@ func (agg *Aggregator) ProcessOperatorSignedTaskResponseV2(signedTaskResponse *t
94108
case <-ctx.Done():
95109
// The context's deadline was exceeded or it was canceled
96110
agg.logger.Info("Bls process timed out, operator signature will be lost. Batch may not reach quorum")
97-
case <-done:
111+
case res := <-done:
98112
// The task completed successfully
99-
agg.logger.Info("Bls context finished correctly")
100-
*reply = 0
113+
agg.logger.Info("Bls context finished on time")
114+
*reply = res
101115
}
102116

103117
return nil

alerts/balance_alerts.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ do
3838
fi
3939
balance_alert=true
4040
else
41-
message="🟩 INFO: Wallet $WALLET_ADDRESS balance ($balance_eth ETH) is above $BALANCE_THRESHOLD ETH"
41+
message="🟩 INFO: $WALLET_NAME ($NETWORK) Wallet $WALLET_ADDRESS balance ($balance_eth ETH) is above $BALANCE_THRESHOLD ETH"
4242
printf "$message\n"
4343
if [ "$balance_alert" = true ]; then
4444
send_slack_message "$message"

alerts/contract_alerts.sh

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ do
4141
if [ -z "$new_batch_logs" ]; then
4242
printf "No new batches logs found\n"
4343
if [ "$no_new_batches_alert" = false ]; then
44-
message="🚨 ALERT: No new batches in Service Manager since block $from_block"
44+
message="🚨 $NETWORK ALERT: No new batches in Service Manager since block $from_block"
45+
printf "$message\n"
4546
send_slack_message "$message"
4647
send_telegram_message "$message"
4748
send_pagerduty_alert "$message"
@@ -50,7 +51,8 @@ do
5051
else
5152
printf "New batches logs found\n"
5253
if [ "$no_new_batches_alert" = true ]; then
53-
message="🟩 INFO: Batches creation resumed in Service Manager since block $from_block"
54+
message="🟩 $NETWORK INFO: Batches creation resumed in Service Manager since block $from_block"
55+
printf "$message\n"
5456
send_slack_message "$message"
5557
send_telegram_message "$message"
5658
fi
@@ -61,7 +63,8 @@ do
6163
if [ -z "$verified_batch_logs" ]; then
6264
printf "No verified batches logs found\n"
6365
if [ "$no_verified_batches_alert" = false ]; then
64-
message="🚨 ALERT: No verified batches in Service Manager since block $from_block"
66+
message="🚨 $NETWORK ALERT: No verified batches in Service Manager since block $from_block"
67+
printf "$message\n"
6568
send_slack_message "$message"
6669
send_telegram_message "$message"
6770
send_pagerduty_alert "$message"
@@ -70,7 +73,8 @@ do
7073
else
7174
printf "Verified batches logs found\n"
7275
if [ "$no_verified_batches_alert" = true ]; then
73-
message="🟩 INFO: Batches verification resumed in Service Manager since block $from_block"
76+
message="🟩 $NETWORK INFO: Batches verification resumed in Service Manager since block $from_block"
77+
printf "$message\n"
7478
send_slack_message "$message"
7579
send_telegram_message "$message"
7680
fi

alerts/sender_with_alert.sh

Lines changed: 51 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,22 @@ function fetch_tx_cost() {
5353
fi
5454
}
5555

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

7894
## Generate Proof
7995
nonce=$(aligned get-user-nonce --batcher_url $BATCHER_URL --user_addr $SENDER_ADDRESS 2>&1 | awk '{print $9}')
96+
echo $nonce
97+
if ! [[ "$nonce" =~ ^[0-9]+$ ]]; then
98+
echo "Failed getting user nonce, retrying in 10 seconds"
99+
sleep 10
100+
continue
101+
fi
102+
80103
x=$((nonce + 1)) # So we don't have any issues with nonce = 0
81-
echo "Generating proof $x != 0"
104+
echo "Generating proof $x != 0, nonce: $nonce"
82105
go run ./scripts/test_files/gnark_groth16_bn254_infinite_script/cmd/main.go $x
83106

84107
## Send Proof
@@ -94,10 +117,29 @@ do
94117
--rpc_url $RPC_URL \
95118
--batcher_url $BATCHER_URL \
96119
--network $NETWORK \
97-
--max_fee 4000000000000000 \
120+
--max_fee 0.004ether \
98121
2>&1)
99122

100123
echo "$submit"
124+
125+
submit_errors=$(echo "$submit" | grep -oE 'ERROR[^]]*]([^[]*)' | sed 's/^[^]]*]//;s/[[:space:]]*$//')
126+
127+
# Loop through each error found and print with the custom message
128+
is_error=0
129+
while IFS= read -r error; do
130+
if [[ -n "$error" ]]; then
131+
slack_error_message="Error submitting proof to $NETWORK: $error"
132+
send_slack_message "$slack_error_message"
133+
is_error=1
134+
fi
135+
done <<< "$submit_errors"
136+
137+
if [ $is_error -eq 1 ]; then
138+
echo "Error submitting proofs to $NETWORK, retrying in 60 seconds"
139+
send_slack_message "Error submitting proofs to $NETWORK, retrying in 60 seconds"
140+
sleep 60
141+
continue
142+
fi
101143

102144
echo "Waiting $VERIFICATION_WAIT_TIME seconds for verification"
103145
sleep $VERIFICATION_WAIT_TIME
@@ -113,6 +155,7 @@ do
113155
fi
114156

115157
total_fee_in_wei=0
158+
total_number_proofs=0
116159
batch_explorer_urls=()
117160
for batch_merkle_root in $batch_merkle_roots
118161
do
@@ -127,12 +170,16 @@ do
127170
response_tx_hash=$(echo "$log" | grep -oE "transactionHash: 0x[[:alnum:]]{64}" | awk '{ print $2 }')
128171

129172
# Calculate fees for transactions
173+
number_proofs_in_batch=$(get_number_proofs_in_batch_from_create_task_tx $submission_tx_hash)
130174
submission_fee_in_wei=$(fetch_tx_cost $submission_tx_hash)
131175
response_fee_in_wei=$(fetch_tx_cost $response_tx_hash)
132176
batch_fee_in_wei=$((submission_fee_in_wei + response_fee_in_wei))
133177

134178
# Accumulate the fee
135179
total_fee_in_wei=$(($total_fee_in_wei + $batch_fee_in_wei))
180+
181+
# Accumulate proofs in batch
182+
total_number_proofs=$(($total_number_proofs + $number_proofs_in_batch))
136183
done
137184

138185
# Calculate the spent amount by converting the fee to ETH
@@ -168,9 +215,9 @@ do
168215
done
169216

170217
if [ $verified -eq 1 ]; then
171-
slack_message="$REPETITIONS Proofs submitted and verified. Spent amount: $spent_amount ETH ($ $spent_amount_usd) [ ${batch_explorer_urls[@]} ]"
218+
slack_message="$total_number_proofs proofs submitted and verified. We sent $REPETITIONS proofs. Spent amount: $spent_amount ETH ($ $spent_amount_usd) [ ${batch_explorer_urls[@]} ]"
172219
else
173-
slack_message="$REPETITIONS Proofs submitted but not verified. Spent amount: $spent_amount ETH ($ $spent_amount_usd) [ ${batch_explorer_urls[@]} ]"
220+
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[@]} ]"
174221
fi
175222

176223
## Send Update to Slack

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+
}

0 commit comments

Comments
 (0)