Skip to content

Commit

Permalink
Merge branch 'refs/heads/staging' into 1761-featcontract-add-amount_o…
Browse files Browse the repository at this point in the history
…f_proofs-in-taskcreated-event
  • Loading branch information
JuArce committed Feb 10, 2025
2 parents 298d9ca + f009da5 commit 6d195f2
Show file tree
Hide file tree
Showing 22 changed files with 457 additions and 44 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/foundry-gas-diff.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
FOUNDRY_FUZZ_SEED: 0x${{ github.event.pull_request.base.sha || github.sha }}

- name: Compare gas reports
uses: Rubilmax/foundry-gas-diff@v3.16
uses: Rubilmax/foundry-gas-diff@v3.21
with:
summaryQuantile: 0.9 # only display the 10% most significant gas diffs in the summary (defaults to 20%)
sortCriteria: avg,max # sort diff rows by criteria
Expand Down
39 changes: 37 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ CONFIG_FILE?=config-files/config.yaml
export OPERATOR_ADDRESS ?= $(shell yq -r '.operator.address' $(CONFIG_FILE))
AGG_CONFIG_FILE?=config-files/config-aggregator.yaml

OPERATOR_VERSION=v0.13.0
OPERATOR_VERSION=v0.14.0
EIGEN_SDK_GO_VERSION_TESTNET=v0.2.0-beta.1
EIGEN_SDK_GO_VERSION_MAINNET=v0.1.13

ifeq ($(OS),Linux)
BUILD_ALL_FFI = $(MAKE) build_all_ffi_linux
Expand All @@ -30,6 +32,16 @@ ifeq ($(OS),Darwin)
BUILD_OPERATOR = $(MAKE) build_operator_macos
endif

ifeq ($(ENVIRONMENT), devnet)
GET_SDK_VERSION = $(MAKE) operator_set_eigen_sdk_go_version_devnet
else ifeq ($(ENVIRONMENT), testnet)
GET_SDK_VERSION = $(MAKE) operator_set_eigen_sdk_go_version_testnet
else ifeq ($(ENVIRONMENT), mainnet)
GET_SDK_VERSION = $(MAKE) operator_set_eigen_sdk_go_version_mainnet
else
GET_SDK_VERSION = $(MAKE) operator_set_eigen_sdk_go_version_error
endif


FFI_FOR_RELEASE ?= true

Expand Down Expand Up @@ -140,7 +152,13 @@ anvil_start_with_block_time_with_more_prefunded_accounts:

_AGGREGATOR_:

build_aggregator:
$(GET_SDK_VERSION)
@echo "Building aggregator"
@go build -o ./build/aligned-aggregator ./aggregator/cmd/main.go

aggregator_start:
$(GET_SDK_VERSION)
@echo "Starting Aggregator..."
@go run aggregator/cmd/main.go --config $(AGG_CONFIG_FILE) \
2>&1 | zap-pretty
Expand All @@ -156,15 +174,31 @@ test_go_retries:
__OPERATOR__:

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

operator_set_eigen_sdk_go_version_testnet:
@echo "Setting Eigen SDK version to: $(EIGEN_SDK_GO_VERSION_TESTNET)"
go get github.com/Layr-Labs/eigensdk-go@$(EIGEN_SDK_GO_VERSION_TESTNET)

operator_set_eigen_sdk_go_version_devnet: operator_set_eigen_sdk_go_version_mainnet

operator_set_eigen_sdk_go_version_mainnet:
@echo "Setting Eigen SDK version to: $(EIGEN_SDK_GO_VERSION_MAINNET)"
go get github.com/Layr-Labs/eigensdk-go@$(EIGEN_SDK_GO_VERSION_MAINNET)

operator_set_eigen_sdk_go_version_error:
@echo "Error setting Eigen SDK version, missing ENVIRONMENT. Possible values for ENVIRONMENT=<devnet|testnet|mainnet>"
exit 1

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

operator_register_and_start: operator_full_registration operator_start
operator_register_and_start: $(GET_SDK_VERSION) operator_full_registration operator_start

build_operator: deps
$(GET_SDK_VERSION)
$(BUILD_OPERATOR)

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

update_operator:
$(GET_SDK_VERSION)
@echo "Updating Operator..."
@./scripts/fetch_latest_release.sh
@make build_operator
Expand Down
12 changes: 12 additions & 0 deletions aggregator/pkg/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package pkg
import (
"context"
"encoding/hex"
"errors"
"fmt"
"net/http"
"net/rpc"
Expand Down Expand Up @@ -48,6 +49,17 @@ func (agg *Aggregator) ProcessOperatorSignedTaskResponseV2(signedTaskResponse *t
"SenderAddress", "0x"+hex.EncodeToString(signedTaskResponse.SenderAddress[:]),
"BatchIdentifierHash", "0x"+hex.EncodeToString(signedTaskResponse.BatchIdentifierHash[:]),
"operatorId", hex.EncodeToString(signedTaskResponse.OperatorId[:]))

if signedTaskResponse.BlsSignature.G1Point == nil {
agg.logger.Warn("invalid operator response with nil signature",
"BatchMerkleRoot", "0x"+hex.EncodeToString(signedTaskResponse.BatchMerkleRoot[:]),
"SenderAddress", "0x"+hex.EncodeToString(signedTaskResponse.SenderAddress[:]),
"BatchIdentifierHash", "0x"+hex.EncodeToString(signedTaskResponse.BatchIdentifierHash[:]),
"operatorId", hex.EncodeToString(signedTaskResponse.OperatorId[:]))
*reply = 1
return errors.New("invalid response: nil signature")
}

taskIndex := uint32(0)

// The Aggregator may receive the Task Identifier after the operators.
Expand Down
2 changes: 1 addition & 1 deletion alerts/balance_alerts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ do
fi
balance_alert=true
else
message="🟩 INFO: Wallet $WALLET_ADDRESS balance ($balance_eth ETH) is above $BALANCE_THRESHOLD ETH"
message="🟩 INFO: $WALLET_NAME ($NETWORK) Wallet $WALLET_ADDRESS balance ($balance_eth ETH) is above $BALANCE_THRESHOLD ETH"
printf "$message\n"
if [ "$balance_alert" = true ]; then
send_slack_message "$message"
Expand Down
12 changes: 8 additions & 4 deletions alerts/contract_alerts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ do
if [ -z "$new_batch_logs" ]; then
printf "No new batches logs found\n"
if [ "$no_new_batches_alert" = false ]; then
message="🚨 ALERT: No new batches in Service Manager since block $from_block"
message="🚨 $NETWORK ALERT: No new batches in Service Manager since block $from_block"
printf "$message\n"
send_slack_message "$message"
send_telegram_message "$message"
send_pagerduty_alert "$message"
Expand All @@ -50,7 +51,8 @@ do
else
printf "New batches logs found\n"
if [ "$no_new_batches_alert" = true ]; then
message="🟩 INFO: Batches creation resumed in Service Manager since block $from_block"
message="🟩 $NETWORK INFO: Batches creation resumed in Service Manager since block $from_block"
printf "$message\n"
send_slack_message "$message"
send_telegram_message "$message"
fi
Expand All @@ -61,7 +63,8 @@ do
if [ -z "$verified_batch_logs" ]; then
printf "No verified batches logs found\n"
if [ "$no_verified_batches_alert" = false ]; then
message="🚨 ALERT: No verified batches in Service Manager since block $from_block"
message="🚨 $NETWORK ALERT: No verified batches in Service Manager since block $from_block"
printf "$message\n"
send_slack_message "$message"
send_telegram_message "$message"
send_pagerduty_alert "$message"
Expand All @@ -70,7 +73,8 @@ do
else
printf "Verified batches logs found\n"
if [ "$no_verified_batches_alert" = true ]; then
message="🟩 INFO: Batches verification resumed in Service Manager since block $from_block"
message="🟩 $NETWORK INFO: Batches verification resumed in Service Manager since block $from_block"
printf "$message\n"
send_slack_message "$message"
send_telegram_message "$message"
fi
Expand Down
30 changes: 28 additions & 2 deletions alerts/sender_with_alert.sh
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,15 @@ do

## Generate Proof
nonce=$(aligned get-user-nonce --network $NETWORK --user_addr $SENDER_ADDRESS 2>&1 | awk '{print $9}')
echo $nonce
if ! [[ "$nonce" =~ ^[0-9]+$ ]]; then
echo "Failed getting user nonce, retrying in 10 seconds"
sleep 10
continue
fi

x=$((nonce + 1)) # So we don't have any issues with nonce = 0
echo "Generating proof $x != 0"
echo "Generating proof $x != 0, nonce: $nonce"
go run ./scripts/test_files/gnark_groth16_bn254_infinite_script/cmd/main.go $x

## Send Proof
Expand All @@ -112,7 +119,26 @@ do
2>&1)

echo "$submit"


submit_errors=$(echo "$submit" | grep -oE 'ERROR[^]]*]([^[]*)' | sed 's/^[^]]*]//;s/[[:space:]]*$//')

# Loop through each error found and print with the custom message
is_error=0
while IFS= read -r error; do
if [[ -n "$error" ]]; then
slack_error_message="Error submitting proof to $NETWORK: $error"
send_slack_message "$slack_error_message"
is_error=1
fi
done <<< "$submit_errors"

if [ $is_error -eq 1 ]; then
echo "Error submitting proofs to $NETWORK, retrying in 60 seconds"
send_slack_message "Error submitting proofs to $NETWORK, retrying in 60 seconds"
sleep 60
continue
fi

echo "Waiting $VERIFICATION_WAIT_TIME seconds for verification"
sleep $VERIFICATION_WAIT_TIME

Expand Down
2 changes: 1 addition & 1 deletion batcher/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 13 additions & 3 deletions batcher/aligned-batcher/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ use std::time::Duration;
use aligned_sdk::core::constants::{
ADDITIONAL_SUBMISSION_GAS_COST_PER_PROOF, BATCHER_SUBMISSION_BASE_GAS_COST,
BUMP_BACKOFF_FACTOR, BUMP_MAX_RETRIES, BUMP_MAX_RETRY_DELAY, BUMP_MIN_RETRY_DELAY,
CONNECTION_TIMEOUT, DEFAULT_MAX_FEE_PER_PROOF, ETHEREUM_CALL_BACKOFF_FACTOR,
ETHEREUM_CALL_MAX_RETRIES, ETHEREUM_CALL_MAX_RETRY_DELAY, ETHEREUM_CALL_MIN_RETRY_DELAY,
GAS_PRICE_PERCENTAGE_MULTIPLIER, PERCENTAGE_DIVIDER,
CBOR_ARRAY_MAX_OVERHEAD, CONNECTION_TIMEOUT, DEFAULT_MAX_FEE_PER_PROOF,
ETHEREUM_CALL_BACKOFF_FACTOR, ETHEREUM_CALL_MAX_RETRIES, ETHEREUM_CALL_MAX_RETRY_DELAY,
ETHEREUM_CALL_MIN_RETRY_DELAY, GAS_PRICE_PERCENTAGE_MULTIPLIER, PERCENTAGE_DIVIDER,
RESPOND_TO_TASK_FEE_LIMIT_PERCENTAGE_MULTIPLIER,
};
use aligned_sdk::core::types::{
Expand Down Expand Up @@ -115,6 +115,16 @@ impl Batcher {
let s3_client = s3::create_client(upload_endpoint).await;

let config = ConfigFromYaml::new(config_file);
// Ensure max_batch_bytes_size can at least hold one proof of max_proof_size,
// including the overhead introduced by serialization
assert!(
config.batcher.max_proof_size + CBOR_ARRAY_MAX_OVERHEAD
<= config.batcher.max_batch_byte_size,
"max_batch_bytes_size ({}) not big enough for one max_proof_size ({}) proof",
config.batcher.max_batch_byte_size,
config.batcher.max_proof_size
);

let deployment_output =
ContractDeploymentOutput::new(config.aligned_layer_deployment_config_file_path);

Expand Down
10 changes: 8 additions & 2 deletions batcher/aligned-batcher/src/types/batch_queue.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
use aligned_sdk::{
communication::serialization::cbor_serialize,
core::types::{NoncedVerificationData, VerificationDataCommitment},
core::{
constants::CBOR_ARRAY_MAX_OVERHEAD,
types::{NoncedVerificationData, VerificationDataCommitment},
},
};
use ethers::types::{Address, Signature, U256};
use priority_queue::PriorityQueue;
Expand Down Expand Up @@ -132,7 +135,10 @@ pub(crate) fn calculate_batch_size(batch_queue: &BatchQueue) -> Result<usize, Ba
});

if let ControlFlow::Continue(batch_size) = folded_result {
Ok(batch_size)
// We over-estimate the size of the batch by at most 8 bytes.
// This saves us from a scenario where we actually try to send more
// than the maximum allowed bytes and get rejected by operators.
Ok(CBOR_ARRAY_MAX_OVERHEAD + batch_size)
} else {
Err(BatcherError::SerializationError(String::from(
"Could not calculate size of batch",
Expand Down
9 changes: 9 additions & 0 deletions batcher/aligned-sdk/src/core/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@ pub const DEFAULT_MAX_FEE_PER_PROOF: u128 =
ADDITIONAL_SUBMISSION_GAS_COST_PER_PROOF * 100_000_000_000; // gas_price = 100 Gwei = 0.0000001 ether (high gas price)
pub const CONNECTION_TIMEOUT: u64 = 30; // 30 secs

// According to:
// - https://www.rfc-editor.org/rfc/rfc8949.html#section-3.1-2.10
// - https://www.rfc-editor.org/rfc/rfc8949.html#section-3-3.2
// - https://www.rfc-editor.org/rfc/rfc8949.html#section-3-3.4
// 9 bytes are the maximum overhead from aggregating data into an array in CBOR
// (it may be as little as just 1 byte, but it depends on the number of elements
// and serialization parameters).
pub const CBOR_ARRAY_MAX_OVERHEAD: usize = 9;

// % modifiers: (100% is x1, 10% is x0.1, 1000% is x10)
pub const RESPOND_TO_TASK_FEE_LIMIT_PERCENTAGE_MULTIPLIER: u128 = 250; // fee_for_aggregator -> respondToTaskFeeLimit modifier
pub const DEFAULT_AGGREGATOR_FEE_PERCENTAGE_MULTIPLIER: u128 = 125; // feeForAggregator modifier
Expand Down
2 changes: 1 addition & 1 deletion batcher/aligned/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "aligned"
version = "0.13.0"
version = "0.14.0"
edition = "2021"

[dependencies]
Expand Down
Loading

0 comments on commit 6d195f2

Please sign in to comment.