Skip to content

Commit 549b716

Browse files
committed
Merge branch 'staging' into 1759-fixcontract-remove-reinitializers-from-contracts
2 parents 84ae727 + eb0be8d commit 549b716

File tree

14 files changed

+403
-32
lines changed

14 files changed

+403
-32
lines changed

Makefile

Lines changed: 36 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

alerts/sender_with_alert.sh

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,15 @@ do
9292

9393
## Generate Proof
9494
nonce=$(aligned get-user-nonce --network $NETWORK --user_addr $SENDER_ADDRESS 2>&1 | awk '{print $9}')
95+
echo $nonce
96+
if ! [[ "$nonce" =~ ^[0-9]+$ ]]; then
97+
echo "Failed getting user nonce, retrying in 10 seconds"
98+
sleep 10
99+
continue
100+
fi
101+
95102
x=$((nonce + 1)) # So we don't have any issues with nonce = 0
96-
echo "Generating proof $x != 0"
103+
echo "Generating proof $x != 0, nonce: $nonce"
97104
go run ./scripts/test_files/gnark_groth16_bn254_infinite_script/cmd/main.go $x
98105

99106
## Send Proof
@@ -112,7 +119,26 @@ do
112119
2>&1)
113120

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

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/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "aligned"
3-
version = "0.13.0"
3+
version = "0.14.0"
44
edition = "2021"
55

66
[dependencies]

batcher/aligned/src/main.rs

Lines changed: 91 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use aligned_sdk::core::{
1414
use aligned_sdk::sdk::estimate_fee;
1515
use aligned_sdk::sdk::get_chain_id;
1616
use aligned_sdk::sdk::get_nonce_from_batcher;
17+
use aligned_sdk::sdk::get_nonce_from_ethereum;
1718
use aligned_sdk::sdk::{deposit_to_aligned, get_balance_in_aligned};
1819
use aligned_sdk::sdk::{get_vk_commitment, is_proof_verified, save_response, submit_multiple};
1920
use clap::Args;
@@ -25,13 +26,16 @@ use ethers::prelude::*;
2526
use ethers::utils::format_ether;
2627
use ethers::utils::hex;
2728
use ethers::utils::parse_ether;
29+
use futures_util::future;
2830
use log::warn;
2931
use log::{error, info};
3032
use transaction::eip2718::TypedTransaction;
3133

3234
use crate::AlignedCommands::DepositToBatcher;
35+
use crate::AlignedCommands::GetUserAmountOfQueuedProofs;
3336
use crate::AlignedCommands::GetUserBalance;
3437
use crate::AlignedCommands::GetUserNonce;
38+
use crate::AlignedCommands::GetUserNonceFromEthereum;
3539
use crate::AlignedCommands::GetVkCommitment;
3640
use crate::AlignedCommands::Submit;
3741
use crate::AlignedCommands::VerifyProofOnchain;
@@ -59,8 +63,21 @@ pub enum AlignedCommands {
5963
DepositToBatcher(DepositToBatcherArgs),
6064
#[clap(about = "Get user balance from the batcher", name = "get-user-balance")]
6165
GetUserBalance(GetUserBalanceArgs),
62-
#[clap(about = "Get user nonce from the batcher", name = "get-user-nonce")]
66+
#[clap(
67+
about = "Gets user current nonce from the batcher. This is the nonce you should send in your next proof.",
68+
name = "get-user-nonce"
69+
)]
6370
GetUserNonce(GetUserNonceArgs),
71+
#[clap(
72+
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.",
73+
name = "get-user-nonce-from-ethereum"
74+
)]
75+
GetUserNonceFromEthereum(GetUserNonceFromEthereumArgs),
76+
#[clap(
77+
about = "Gets the number of proofs a user has queued in the Batcher.",
78+
name = "get-user-amount-of-queued-proofs"
79+
)]
80+
GetUserAmountOfQueuedProofs(GetUserAmountOfQueuedProofsArgs),
6481
}
6582

6683
#[derive(Parser, Debug)]
@@ -225,8 +242,46 @@ pub struct GetUserNonceArgs {
225242
address: String,
226243
}
227244

245+
#[derive(Parser, Debug)]
246+
#[command(version, about, long_about = None)]
247+
pub struct GetUserNonceFromEthereumArgs {
248+
#[arg(
249+
name = "Ethereum RPC provider address",
250+
long = "rpc_url",
251+
default_value = "http://localhost:8545"
252+
)]
253+
eth_rpc_url: String,
254+
#[arg(
255+
name = "The user's Ethereum address",
256+
long = "user_addr",
257+
required = true
258+
)]
259+
address: String,
260+
#[clap(flatten)]
261+
network: NetworkArg,
262+
}
263+
264+
#[derive(Parser, Debug)]
265+
#[command(version, about, long_about = None)]
266+
pub struct GetUserAmountOfQueuedProofsArgs {
267+
#[arg(
268+
name = "Ethereum RPC provider address",
269+
long = "rpc_url",
270+
default_value = "http://localhost:8545"
271+
)]
272+
eth_rpc_url: String,
273+
#[arg(
274+
name = "The user's Ethereum address",
275+
long = "user_addr",
276+
required = true
277+
)]
278+
address: String,
279+
#[clap(flatten)]
280+
network: NetworkArg,
281+
}
282+
228283
#[derive(Args, Debug)]
229-
#[group(required = true, multiple = false)]
284+
#[group(multiple = false)]
230285
pub struct PrivateKeyType {
231286
#[arg(name = "path_to_keystore", long = "keystore_path")]
232287
keystore_path: Option<PathBuf>,
@@ -642,6 +697,40 @@ async fn main() -> Result<(), AlignedError> {
642697
}
643698
}
644699
}
700+
GetUserNonceFromEthereum(args) => {
701+
let address = H160::from_str(&args.address).unwrap();
702+
let network = args.network.into();
703+
match get_nonce_from_ethereum(&args.eth_rpc_url, address, network).await {
704+
Ok(nonce) => {
705+
info!(
706+
"Nonce for address {} in BatcherPaymentService contract is {}",
707+
address, nonce
708+
);
709+
}
710+
Err(e) => {
711+
error!("Error while getting nonce: {:?}", e);
712+
return Ok(());
713+
}
714+
}
715+
}
716+
GetUserAmountOfQueuedProofs(args) => {
717+
let address = H160::from_str(&args.address).unwrap();
718+
let network: Network = args.network.into();
719+
let Ok((ethereum_nonce, batcher_nonce)) = future::try_join(
720+
get_nonce_from_ethereum(&args.eth_rpc_url, address, network.clone()),
721+
get_nonce_from_batcher(network, address),
722+
)
723+
.await
724+
.map_err(|e| error!("Error while getting nonce: {:?}", e)) else {
725+
return Ok(());
726+
};
727+
info!(
728+
"User {} has {} proofs in the batcher queue",
729+
address,
730+
batcher_nonce - ethereum_nonce
731+
);
732+
return Ok(());
733+
}
645734
}
646735

647736
Ok(())

docs/3_guides/1_SDK_how_to.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ To use this SDK in your Rust project, add the following to your `Cargo.toml`:
1212

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

1818
To find the latest release tag go to [releases](https://github.com/yetanotherco/aligned_layer/releases) and copy the

docs/3_guides/6_setup_aligned.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,27 +74,27 @@ make bindings
7474
To start the [Aggregator](../2_architecture/components/5_aggregator.md):
7575

7676
```bash
77-
make aggregator_start
77+
make aggregator_start ENVIRONMENT=devnet
7878
```
7979

8080
or with a custom config:
8181

8282
```bash
83-
make aggregator_start CONFIG_FILE=<path_to_config_file>
83+
make aggregator_start ENVIRONMENT=devnet CONFIG_FILE=<path_to_config_file>
8484
```
8585

8686
## Operator
8787

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

9090
```bash
91-
make operator_register_and_start
91+
make operator_register_and_start ENVIRONMENT=devnet
9292
```
9393

9494
or with a custom config:
9595

9696
```bash
97-
make operator_register_and_start CONFIG_FILE=<path_to_config_file>
97+
make operator_register_and_start ENVIRONMENT=devnet CONFIG_FILE=<path_to_config_file>
9898
```
9999

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

113113
```bash
114-
make operator_start CONFIG_FILE=<path_to_config_file>
114+
make operator_start ENVIRONMENT=devnet CONFIG_FILE=<path_to_config_file>
115115
```
116116

117117
</details>

0 commit comments

Comments
 (0)