Skip to content

Commit

Permalink
Merge branch 'staging' into 1759-fixcontract-remove-reinitializers-fr…
Browse files Browse the repository at this point in the history
…om-contracts
  • Loading branch information
uri-99 committed Jan 28, 2025
2 parents 84ae727 + eb0be8d commit 549b716
Show file tree
Hide file tree
Showing 14 changed files with 403 additions and 32 deletions.
37 changes: 36 additions & 1 deletion 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

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
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.

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
93 changes: 91 additions & 2 deletions batcher/aligned/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use aligned_sdk::core::{
use aligned_sdk::sdk::estimate_fee;
use aligned_sdk::sdk::get_chain_id;
use aligned_sdk::sdk::get_nonce_from_batcher;
use aligned_sdk::sdk::get_nonce_from_ethereum;
use aligned_sdk::sdk::{deposit_to_aligned, get_balance_in_aligned};
use aligned_sdk::sdk::{get_vk_commitment, is_proof_verified, save_response, submit_multiple};
use clap::Args;
Expand All @@ -25,13 +26,16 @@ use ethers::prelude::*;
use ethers::utils::format_ether;
use ethers::utils::hex;
use ethers::utils::parse_ether;
use futures_util::future;
use log::warn;
use log::{error, info};
use transaction::eip2718::TypedTransaction;

use crate::AlignedCommands::DepositToBatcher;
use crate::AlignedCommands::GetUserAmountOfQueuedProofs;
use crate::AlignedCommands::GetUserBalance;
use crate::AlignedCommands::GetUserNonce;
use crate::AlignedCommands::GetUserNonceFromEthereum;
use crate::AlignedCommands::GetVkCommitment;
use crate::AlignedCommands::Submit;
use crate::AlignedCommands::VerifyProofOnchain;
Expand Down Expand Up @@ -59,8 +63,21 @@ pub enum AlignedCommands {
DepositToBatcher(DepositToBatcherArgs),
#[clap(about = "Get user balance from the batcher", name = "get-user-balance")]
GetUserBalance(GetUserBalanceArgs),
#[clap(about = "Get user nonce from the batcher", name = "get-user-nonce")]
#[clap(
about = "Gets user current nonce from the batcher. This is the nonce you should send in your next proof.",
name = "get-user-nonce"
)]
GetUserNonce(GetUserNonceArgs),
#[clap(
about = "Gets the user nonce directly from the BatcherPaymentService contract. Useful for validating the on-chain state and check if your transactions are pending in the batcher.",
name = "get-user-nonce-from-ethereum"
)]
GetUserNonceFromEthereum(GetUserNonceFromEthereumArgs),
#[clap(
about = "Gets the number of proofs a user has queued in the Batcher.",
name = "get-user-amount-of-queued-proofs"
)]
GetUserAmountOfQueuedProofs(GetUserAmountOfQueuedProofsArgs),
}

#[derive(Parser, Debug)]
Expand Down Expand Up @@ -225,8 +242,46 @@ pub struct GetUserNonceArgs {
address: String,
}

#[derive(Parser, Debug)]
#[command(version, about, long_about = None)]
pub struct GetUserNonceFromEthereumArgs {
#[arg(
name = "Ethereum RPC provider address",
long = "rpc_url",
default_value = "http://localhost:8545"
)]
eth_rpc_url: String,
#[arg(
name = "The user's Ethereum address",
long = "user_addr",
required = true
)]
address: String,
#[clap(flatten)]
network: NetworkArg,
}

#[derive(Parser, Debug)]
#[command(version, about, long_about = None)]
pub struct GetUserAmountOfQueuedProofsArgs {
#[arg(
name = "Ethereum RPC provider address",
long = "rpc_url",
default_value = "http://localhost:8545"
)]
eth_rpc_url: String,
#[arg(
name = "The user's Ethereum address",
long = "user_addr",
required = true
)]
address: String,
#[clap(flatten)]
network: NetworkArg,
}

#[derive(Args, Debug)]
#[group(required = true, multiple = false)]
#[group(multiple = false)]
pub struct PrivateKeyType {
#[arg(name = "path_to_keystore", long = "keystore_path")]
keystore_path: Option<PathBuf>,
Expand Down Expand Up @@ -642,6 +697,40 @@ async fn main() -> Result<(), AlignedError> {
}
}
}
GetUserNonceFromEthereum(args) => {
let address = H160::from_str(&args.address).unwrap();
let network = args.network.into();
match get_nonce_from_ethereum(&args.eth_rpc_url, address, network).await {
Ok(nonce) => {
info!(
"Nonce for address {} in BatcherPaymentService contract is {}",
address, nonce
);
}
Err(e) => {
error!("Error while getting nonce: {:?}", e);
return Ok(());
}
}
}
GetUserAmountOfQueuedProofs(args) => {
let address = H160::from_str(&args.address).unwrap();
let network: Network = args.network.into();
let Ok((ethereum_nonce, batcher_nonce)) = future::try_join(
get_nonce_from_ethereum(&args.eth_rpc_url, address, network.clone()),
get_nonce_from_batcher(network, address),
)
.await
.map_err(|e| error!("Error while getting nonce: {:?}", e)) else {
return Ok(());
};
info!(
"User {} has {} proofs in the batcher queue",
address,
batcher_nonce - ethereum_nonce
);
return Ok(());
}
}

Ok(())
Expand Down
2 changes: 1 addition & 1 deletion docs/3_guides/1_SDK_how_to.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ To use this SDK in your Rust project, add the following to your `Cargo.toml`:

```toml
[dependencies]
aligned-sdk = { git = "https://github.com/yetanotherco/aligned_layer", tag="v0.13.0" }
aligned-sdk = { git = "https://github.com/yetanotherco/aligned_layer", tag="v0.14.0" }
```

To find the latest release tag go to [releases](https://github.com/yetanotherco/aligned_layer/releases) and copy the
Expand Down
10 changes: 5 additions & 5 deletions docs/3_guides/6_setup_aligned.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,27 +74,27 @@ make bindings
To start the [Aggregator](../2_architecture/components/5_aggregator.md):

```bash
make aggregator_start
make aggregator_start ENVIRONMENT=devnet
```

or with a custom config:

```bash
make aggregator_start CONFIG_FILE=<path_to_config_file>
make aggregator_start ENVIRONMENT=devnet CONFIG_FILE=<path_to_config_file>
```

## Operator

To setup an [Operator](../2_architecture/components/4_operator.md) run:

```bash
make operator_register_and_start
make operator_register_and_start ENVIRONMENT=devnet
```

or with a custom config:

```bash
make operator_register_and_start CONFIG_FILE=<path_to_config_file>
make operator_register_and_start ENVIRONMENT=devnet CONFIG_FILE=<path_to_config_file>
```

Different configs for operators can be found in `config-files/config-operator`.
Expand All @@ -111,7 +111,7 @@ make operator_full_registration CONFIG_FILE<path_to_config_file>
and to start it once it has been registered:

```bash
make operator_start CONFIG_FILE=<path_to_config_file>
make operator_start ENVIRONMENT=devnet CONFIG_FILE=<path_to_config_file>
```

</details>
Expand Down
Loading

0 comments on commit 549b716

Please sign in to comment.