Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Slashing #171

Draft
wants to merge 207 commits into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
207 commits
Select commit Hold shift + click to select a range
e64e5de
add get staker shares method
TomasArrachea Nov 14, 2024
7f4378f
add get_delegated_operator method
TomasArrachea Nov 14, 2024
caca28e
change eigen middleware submodule to slashing branch
TomasArrachea Nov 19, 2024
f4afa71
upload updated bindings
TomasArrachea Nov 20, 2024
eb006a0
update middleware rev
Nov 21, 2024
e513be2
working bindings
TomasArrachea Nov 21, 2024
d4c0a26
restore deleted bindings
TomasArrachea Nov 21, 2024
37696a4
update get_staker_shares method
TomasArrachea Nov 21, 2024
fb4babf
remove deprecated methods and update ElChainReader attributes
TomasArrachea Nov 21, 2024
8b348dc
add mockavsservicemanager binding
TomasArrachea Nov 21, 2024
cac51e8
update ElContract Reader tests
TomasArrachea Nov 21, 2024
c9ef2a4
wip scripts
Nov 22, 2024
177ed4c
port scripts from incredible squaring
Nov 22, 2024
349b40d
update elcontracts writer
TomasArrachea Nov 22, 2024
277d61d
add elcontracts reader build method
TomasArrachea Nov 22, 2024
29afec5
add bindings
TomasArrachea Nov 22, 2024
1903878
add missing bindings
TomasArrachea Nov 22, 2024
7fc3b85
fix examples
TomasArrachea Nov 22, 2024
6f1c5ba
cargo fmt
TomasArrachea Nov 22, 2024
75ccd80
remove added bindings
TomasArrachea Nov 22, 2024
4fae355
fix bindings lib
TomasArrachea Nov 22, 2024
70e1e05
remove more bindings
TomasArrachea Nov 22, 2024
403f027
wip : scripts
Nov 25, 2024
651460e
ignore failing tests due to anvil state not updated
TomasArrachea Nov 25, 2024
bbd91dc
Merge branch 'main' into slashing_methods
TomasArrachea Nov 25, 2024
b48ecce
ignore tests
TomasArrachea Nov 25, 2024
b490ed0
add get_operators_for_operator_set method
TomasArrachea Nov 25, 2024
65db644
add updated bindings
TomasArrachea Nov 25, 2024
ceb82ef
wip : state load issue
Nov 26, 2024
cccec71
remove extra bindings
TomasArrachea Nov 22, 2024
21d812c
Merge branch 'slashing_methods' into add_slashing_methods
TomasArrachea Nov 26, 2024
ba83e54
fix getAllocatedSets return type
TomasArrachea Nov 26, 2024
f12f366
add get_strategies_for_operator_set method
TomasArrachea Nov 26, 2024
72f9650
pin anvil version
TomasArrachea Nov 26, 2024
7ab4a89
add get_operators_sets_for_operator method
TomasArrachea Nov 26, 2024
7d5a3f0
add get_delegated_and_slashable_shares_for_operator_sets_before method
TomasArrachea Nov 26, 2024
90947bf
add get_registered_sets method
TomasArrachea Nov 26, 2024
562413c
add get_allocation_delay method
TomasArrachea Nov 26, 2024
e3ec1e9
add get_slashable_shares_for_operator_sets method
TomasArrachea Nov 26, 2024
10060f5
add get_num_operators_for_operator_set method
TomasArrachea Nov 26, 2024
d80b4c5
add is_operator_registered_with_operator_set method
TomasArrachea Nov 26, 2024
148257c
add get_num_operator_sets_for_operator method
TomasArrachea Nov 26, 2024
dc9c6d9
add get_operators_shares method
TomasArrachea Nov 26, 2024
1e8e4a2
add get_operator_shares method
TomasArrachea Nov 26, 2024
e43ef8c
add get_allocation_info method
TomasArrachea Nov 26, 2024
7334a26
add get_max_magnitudes method
TomasArrachea Nov 26, 2024
4115a47
add get_allocatable_magnitude method
TomasArrachea Nov 26, 2024
6524f07
cargo fmt
TomasArrachea Nov 26, 2024
2c18682
Merge branch 'slashing_methods' into add_slashing_methods
TomasArrachea Nov 26, 2024
ca80e80
fix anvil version
TomasArrachea Nov 26, 2024
864ca99
clippy
TomasArrachea Nov 26, 2024
186f517
Merge branch 'slashing_methods' into add_slashing_methods
TomasArrachea Nov 26, 2024
d988583
restore anvil version to latest
TomasArrachea Nov 27, 2024
ef89f17
add updated anvil state
TomasArrachea Nov 27, 2024
7c0fc7b
update solc version of foyndry.toml
TomasArrachea Nov 27, 2024
ed1eba3
format solidity scripts
TomasArrachea Nov 27, 2024
a334e80
get_cumulative_claimed_for_root
pablodeymo Nov 27, 2024
2fbf75a
udpated CoreDeploymentLib.sol for slashing contracts
TomasArrachea Nov 27, 2024
e3272b4
add test_is_operator_registered
TomasArrachea Nov 27, 2024
cbb22f4
add test_get_staker_shares
TomasArrachea Nov 27, 2024
2379dd5
add test_get_delegated_operator
TomasArrachea Nov 27, 2024
bbe92d2
fix deploy eigenlayer
TomasArrachea Nov 28, 2024
09ae574
add forge script broadcast flag
TomasArrachea Nov 28, 2024
ffe9ed4
fix deploy avs
TomasArrachea Nov 28, 2024
e1eaa73
update anvil state
TomasArrachea Nov 28, 2024
876b862
test_get_registered_sets
pablodeymo Nov 28, 2024
ff30d78
update anvil state
TomasArrachea Nov 28, 2024
d4fa852
remove ignore on tests
TomasArrachea Nov 28, 2024
c439589
Add slashing bindings (#163)
TomasArrachea Nov 29, 2024
09e2b37
Merge branch 'anvil_state_for_slashing' into slashing
TomasArrachea Nov 29, 2024
9d127cb
Merge branch 'add_slashing_methods' into slashing
TomasArrachea Nov 29, 2024
e337eb5
clippy
TomasArrachea Nov 29, 2024
8d59985
changes from the PR with rewards methods
pablodeymo Nov 29, 2024
0d90bb9
fix test strategy and token addresses
TomasArrachea Dec 2, 2024
08e0603
add allocation manager to deployment json
TomasArrachea Dec 2, 2024
aeefb8f
upgrade allocation manager contract in deployment scripts
TomasArrachea Dec 2, 2024
1675c35
set anvil base fee to 0
TomasArrachea Dec 2, 2024
2ace59e
register operator with allocation delay not zero
TomasArrachea Dec 2, 2024
f47692d
add testing util get_allocation_manager_address
TomasArrachea Dec 3, 2024
4264833
register AllocationManager in ContractsRegistry
TomasArrachea Dec 3, 2024
21029af
register RewardsCoordinator in ContractsRegistry
TomasArrachea Dec 3, 2024
edb4a37
fix env vars error on deploy scripts
TomasArrachea Dec 3, 2024
b6bdd1b
small fixes on register rewardsCoordinator and allocationManager
TomasArrachea Dec 3, 2024
22b4c6d
update anvil state json
TomasArrachea Dec 3, 2024
4764345
remove old make deploy target
TomasArrachea Dec 3, 2024
dc958ed
remove mining blocks on anvil init
TomasArrachea Dec 3, 2024
b43dbb0
format deploy json files
TomasArrachea Dec 3, 2024
b7dca0e
fix ElContracts Writer register operator test
TomasArrachea Dec 3, 2024
7c02923
update register operator to EL testing util
TomasArrachea Dec 3, 2024
0201e5e
changes on register operator AvsRegistry Writer
TomasArrachea Dec 3, 2024
58626ae
fix operator registered tests in ElContracts Reader
TomasArrachea Dec 3, 2024
415bf0c
comment get_registered_sets method
TomasArrachea Dec 3, 2024
c3da346
clippy
TomasArrachea Dec 3, 2024
5d01570
fix instrumented client tests
TomasArrachea Dec 3, 2024
2eef1df
fix elcontracts writer register operator test
TomasArrachea Dec 3, 2024
94bdbe6
fix get_strategy_and_underlying_erc20_token method
TomasArrachea Dec 4, 2024
6221c14
remove debug prints
TomasArrachea Dec 4, 2024
4030e92
fix writer deposit erc20 test
TomasArrachea Dec 4, 2024
4a917b5
fix egn_addrs tests
TomasArrachea Dec 4, 2024
f2b8c9a
clean avsRegistry writer tests
TomasArrachea Dec 4, 2024
a332630
fix instrumented client tests
TomasArrachea Dec 4, 2024
c8ba87a
fix tx manager tests
TomasArrachea Dec 4, 2024
2772242
map_to_curve receiving a 32 bits array
pablodeymo Dec 4, 2024
475ef13
refactor bls agg test to register operators
TomasArrachea Dec 4, 2024
f08392b
json serialization in test
pablodeymo Dec 4, 2024
8e51708
Merge branch 'main' into slashing
TomasArrachea Dec 4, 2024
bc8875a
add rewards documentation
TomasArrachea Dec 5, 2024
b84668a
add rewards test
TomasArrachea Dec 5, 2024
49226eb
add deploy target
TomasArrachea Dec 5, 2024
90a47b3
Fix map_to_curve in utils bn254 (in the deserialization it was used t…
pablodeymo Dec 5, 2024
c9c9fa8
finish test test_compliance for signature
pablodeymo Dec 5, 2024
ab2b652
add test check claim and process claim with no root submitted
TomasArrachea Dec 6, 2024
c2f9f31
Merge branch 'fix_signature' into slashing
TomasArrachea Dec 6, 2024
4b0b527
restore elcontracts writer imports
TomasArrachea Dec 6, 2024
0501cac
update map_to_curve and sign_message tests
TomasArrachea Dec 6, 2024
5779918
write token addres to json on deployement
TomasArrachea Dec 6, 2024
1b955a1
replace token address with harcoded one
TomasArrachea Dec 6, 2024
fcddb6d
test_compliance_bls_signature with the same data as Go SDK
pablodeymo Dec 6, 2024
42cca06
test with hardcoded merkle root and claim
TomasArrachea Dec 6, 2024
105db21
use 0.8 for alloy-primitives (#175)
supernovahs Dec 8, 2024
db1978e
update anvil state json
TomasArrachea Dec 9, 2024
891c5de
add submit rewards root for tests
TomasArrachea Dec 9, 2024
35c3365
test name changed to test_bls_signature
pablodeymo Dec 9, 2024
a334a2c
fix deposit erc20 test
TomasArrachea Dec 9, 2024
b4c15b0
Merge branch 'fix_signature' into slashing
TomasArrachea Dec 9, 2024
b69d961
restore middleware rev
TomasArrachea Dec 10, 2024
ac48e08
Merge branch 'main' into slashing
pablodeymo Dec 11, 2024
3f9f370
update anvil state
TomasArrachea Dec 10, 2024
70a2356
wip add test register bls key
TomasArrachea Dec 10, 2024
3ebad16
remove logs
TomasArrachea Dec 12, 2024
c2f7eca
add allocation manager address to mockAvs deploy
TomasArrachea Dec 12, 2024
bb799d5
setSlashableStakeLookahead when deploying avs
TomasArrachea Dec 12, 2024
a8e296d
remove debug prints
TomasArrachea Dec 12, 2024
b86f00e
fix test register operator
TomasArrachea Dec 13, 2024
f9b50b2
update anvil state
TomasArrachea Dec 13, 2024
787360d
update middleware submodule to feat/slashing-release-branch
TomasArrachea Dec 13, 2024
e0b46a7
update deployment scripts
TomasArrachea Dec 13, 2024
3a9ab71
updated bindings
TomasArrachea Dec 13, 2024
7fa5c2a
fix bindings OperatorSet imports
TomasArrachea Dec 13, 2024
ceead5c
fix register operator and json keys
TomasArrachea Dec 16, 2024
40ad141
add pauserRegistry to deploy json
TomasArrachea Dec 16, 2024
ce647a4
update anvil dump state
TomasArrachea Dec 16, 2024
e4611f7
slashing fixes (#181)
supernovahs Dec 17, 2024
535670c
Add retries with exponential backoff to send transactions (#158)
TomasArrachea Dec 17, 2024
070d76d
query_registration_detail method (#162)
pablodeymo Dec 17, 2024
5a68213
remove deprecated get_operator_details method
TomasArrachea Dec 17, 2024
4f8a82d
nits
TomasArrachea Dec 17, 2024
7e1e9db
add slashing methods docs and tests
TomasArrachea Dec 17, 2024
ef5b9c2
fix slashing tests
TomasArrachea Dec 17, 2024
194a4a0
fix update operator test
TomasArrachea Dec 18, 2024
beae356
add get_slashable_shares method
TomasArrachea Dec 18, 2024
cb2a517
add can_call method and permission controller to ElContracts Reader
TomasArrachea Dec 18, 2024
8072e46
add list_appointees method
TomasArrachea Dec 18, 2024
f167d26
add list_appointee_permissions method
TomasArrachea Dec 18, 2024
0a91eea
add list_admins method
TomasArrachea Dec 18, 2024
7793c0b
add is_pending_admin method
TomasArrachea Dec 18, 2024
3824693
add is_admin method
TomasArrachea Dec 18, 2024
7e1f26b
add tests
TomasArrachea Dec 18, 2024
c0b65df
add debug
TomasArrachea Dec 18, 2024
382d69f
fix aggregator info test
TomasArrachea Dec 18, 2024
61ff3f2
remove_permission skeleton
pablodeymo Dec 18, 2024
6e8a150
add add_pending_admin and remove_pending_admin methods
TomasArrachea Dec 19, 2024
7556ad9
add accept_admin method
TomasArrachea Dec 19, 2024
6a31b45
add remove_admin method
TomasArrachea Dec 19, 2024
23c376c
add register_for_operator_sets method
TomasArrachea Dec 19, 2024
1cf06d7
add deregister_from_operator_sets method
TomasArrachea Dec 19, 2024
0635537
add set_allocation_delay method
TomasArrachea Dec 19, 2024
5e486a2
add modify_allocations method
TomasArrachea Dec 19, 2024
bde4a19
add set_permission method
TomasArrachea Dec 19, 2024
305a7ad
Fix Holesky RPC provider url (#184)
TomasArrachea Dec 19, 2024
7c4c5fa
lines in comments
pablodeymo Dec 19, 2024
f1bca11
remove_permission function in writer and lines in comments
pablodeymo Dec 19, 2024
f4b6b6f
Add clippy lints in Cargo.toml (#159)
pablodeymo Dec 19, 2024
7ceea9c
Fix operatorsinfo_inmemory tests
pablodeymo Dec 19, 2024
832d9bf
Blsagg logger (#154)
pablodeymo Dec 19, 2024
722a156
fix write/examples/register_operator_in_quorum_with_avs_registry_coor…
pablodeymo Dec 19, 2024
fadbe67
Remove logs in operatorsinfo test (#185)
TomasArrachea Dec 19, 2024
e5b362e
fix get_operator_info example
pablodeymo Dec 19, 2024
a24d2c5
Merge branch 'main' into slashing
TomasArrachea Dec 19, 2024
c89e96e
add slashing branch to CI
TomasArrachea Dec 19, 2024
aeeae03
remove test
TomasArrachea Dec 19, 2024
07dc094
restore bls tests expected values
TomasArrachea Dec 20, 2024
cfdd436
Test remove_permission
pablodeymo Dec 20, 2024
eb7b716
WIP test_register_for_operator_sets
pablodeymo Dec 20, 2024
1b977c1
refactor bls agg tests
TomasArrachea Dec 20, 2024
7576e99
refactoring bls agg tests
TomasArrachea Dec 20, 2024
cf48b48
add deposit into strategy on deployment
TomasArrachea Dec 23, 2024
c878a6b
fix test remove permission
TomasArrachea Dec 23, 2024
4b976ac
update anvil state
TomasArrachea Dec 23, 2024
135f28d
fmt
TomasArrachea Dec 23, 2024
56ab931
test_register_for_operator_sets
pablodeymo Dec 23, 2024
836496a
update deployment scripts to fund and register operators
TomasArrachea Dec 26, 2024
1eef053
refactor bls agg tests
TomasArrachea Dec 26, 2024
e035d12
remove register_operator_to_el_if_not_registered util
TomasArrachea Dec 26, 2024
c2f0434
clippy
TomasArrachea Dec 26, 2024
1433038
fix nonce on tx tests
TomasArrachea Dec 26, 2024
c54b510
update slashing tests expected values
TomasArrachea Dec 26, 2024
8e776e2
fix instrumented client test
TomasArrachea Dec 26, 2024
5882608
clippy
TomasArrachea Dec 26, 2024
584cbec
wip fixing register_for_operator_set
TomasArrachea Dec 27, 2024
988cd35
add modify allocations test
TomasArrachea Dec 30, 2024
ff2e06a
add pubkey registration params when register operator
TomasArrachea Dec 30, 2024
813ef2e
fix encoding for registration params
TomasArrachea Dec 30, 2024
206fb0f
update register_for_operator_sets and modify_allocation tests
TomasArrachea Dec 30, 2024
7f6705b
update operators info test
TomasArrachea Dec 30, 2024
a543ae9
update examples
TomasArrachea Dec 30, 2024
6ae5733
clippy
TomasArrachea Dec 30, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,14 @@ name: Tests

on:
push:
branches: [main]
branches:
- main
- dev
pull_request:
branches: [main]
branches:
- main
- dev
- slashing

jobs:
build:
Expand Down
4 changes: 0 additions & 4 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
[submodule "crates/contracts/bindings/utils/middleware"]
path = crates/contracts/bindings/utils/middleware
url = https://github.com/Layr-Labs/eigenlayer-middleware
branch = m2-mainnet
[submodule "crates/contracts/lib/forge-std"]
path = crates/contracts/lib/forge-std
url = https://github.com/foundry-rs/forge-std
Expand Down
19 changes: 18 additions & 1 deletion Cargo.lock

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

30 changes: 24 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,14 @@ rust.rust_2018_idioms = { level = "deny", priority = -1 }
rustdoc.all = "warn"
clippy.unwrap_used = "warn"
clippy.expect_used = "warn"
clippy.panic = "warn"
clippy.todo = "warn"
clippy.indexing_slicing = "warn"
clippy.string_slice = "warn"
clippy.panic_in_result_fn = "warn"
clippy.panicking_overflow_checks = "warn"
clippy.question_mark = "warn"
clippy.implicit_return = "allow"

[workspace.dependencies]
ark-bn254 = "0.5.0"
Expand All @@ -56,6 +63,7 @@ ark-serialize = "0.5.0"
async-trait = "0.1.83"
aws-config = "1.5.9"
aws-sdk-kms = "1.49.0"
backoff = { version = "0.4.0", features = ["futures", "tokio"] }
clap = { version = "4.5.20", features = ["derive"] }
eigen-chainio-txmanager = { path = "crates/chainio/txmanager/" }
eigen-client-avsregistry = { path = "crates/chainio/clients/avsregistry" }
Expand Down Expand Up @@ -102,26 +110,35 @@ serde_json = "1.0"
serial_test = "3.1"
syn = "2.0"
tempfile = "3.13"
testcontainers = "0.23"
testcontainers = "0.23.1"
thiserror = "1.0"
tokio = { version = "1.41", features = ["test-util", "full", "sync"] }
tracing = "0.1"
tracing-subscriber = { version = "0.3", features = ["json"] }
url = "2.5"

#misc
rust-bls-bn254 = { version = "0.2.1" , features = ["std"] }
rust-bls-bn254 = { version = "0.2.1", features = ["std"] }
uuid = { version = "1.11", features = ["v4"] }


#misc
parking_lot = "0.12"


anvil-utils = { path = "examples/anvil-utils" }

#alloy
alloy = { version = "0.7.0", features = [
"sol-types",
"contract",
"full",
"signer-aws",
] }
alloy-json-rpc = { version = "0.7", default-features = false }
alloy-network = { version = "0.7", default-features = false }
alloy-node-bindings = { version = "0.7", default-features = false }
alloy-primitives = "0.8.14"
alloy-primitives = "0.8"
alloy-provider = { version = "0.7", default-features = false, features = [
"reqwest",
"ws",
Expand All @@ -138,10 +155,11 @@ alloy-signer-aws = "0.7"
alloy-signer-local = { version = "0.7", default-features = false }
alloy-sol-types = "0.8"
alloy-transport = { version = "0.7" }
alloy-transport-http = { version = "0.7", features = ["reqwest-rustls-tls"], default-features = false }
alloy-transport-http = { version = "0.7", features = [
"reqwest-rustls-tls",
], default-features = false }
alloy-transport-ipc = { version = "0.7.0", default-features = false }
alloy-transport-ws = { version = "0.7.0", default-features = false }
alloy = { version = "0.7.0", features = ["sol-types", "contract","full","signer-aws"] }
anvil-utils = { path = "examples/anvil-utils" }

avsregistry-read = { path = "examples/avsregistry-read" }
avsregistry-write = { path = "examples/avsregistry-write" }
14 changes: 12 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,18 @@ __CONTRACTS__: ##
start-anvil-chain-with-contracts-deployed: ##
./crates/contracts/anvil/start-anvil-chain-with-el-and-avs-deployed.sh

deploy-contracts-to-anvil-and-save-state: ##
./crates/contracts/anvil/deploy-contracts-save-anvil-state.sh
deploy-eigenlayer:
./crates/contracts/anvil/deploy-eigenlayer.sh

deploy-avs:
chmod +x ./crates/contracts/anvil/deploy-avs.sh
./crates/contracts/anvil/deploy-avs.sh

deploy: deploy-eigenlayer deploy-avs ##

dump-state:
chmod +x ./crates/contracts/anvil/dump-state.sh
./crates/contracts/anvil/dump-state.sh

__TESTING__: ##

Expand Down
98 changes: 84 additions & 14 deletions crates/chainio/clients/avsregistry/src/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,6 @@ impl AvsRegistryChainReader {
/// - a vector of the quorum numbers the operator was registered for at `block_number`.
/// - for each of the quorums mentioned above, a vector of the operators registered for
/// that quorum at `block_number`, containing each operator's `operatorId` and `stake`.

pub async fn get_operators_stake_in_quorums_of_operator_at_block(
&self,
operator_id: B256,
Expand Down Expand Up @@ -399,6 +398,44 @@ impl AvsRegistryChainReader {
Ok(quorum_stakes)
}

/// Query registration detail
///
/// # Arguments
///
/// * `operator_address` - The operator address.
///
/// # Returns
///
/// A vector of booleans, where each boolean represents if the operator
/// is registered for a quorum.
///
/// # Errors
///
/// Returns an error if the operator id cannot be fetched or if the quorum bitmap
pub async fn query_registration_detail(
&self,
operator_address: Address,
) -> Result<[bool; 64], AvsRegistryError> {
let operator_id = self.get_operator_id(operator_address).await?;

let provider = get_provider(&self.provider);
let registry_coordinator =
RegistryCoordinator::new(self.registry_coordinator_addr, &provider);
let quorum_bitmap = registry_coordinator
.getCurrentQuorumBitmap(operator_id)
.call()
.await?;

let inner_value = quorum_bitmap._0.into_limbs()[0];
let mut quorums: [bool; 64] = [false; 64];
for i in 0..64_u64 {
if let Some(value) = quorums.get_mut(i as usize) {
*value = inner_value & (1 << i) != 0;
}
}
Ok(quorums)
}

/// Get operator id
///
/// # Arguments
Expand Down Expand Up @@ -597,23 +634,18 @@ impl AvsRegistryChainReader {
mod tests {
use super::*;
use eigen_logging::get_test_logger;
use eigen_testing_utils::m2_holesky_constants::{
HOLESKY_RPC_PROVIDER, OPERATOR_STATE_RETRIEVER, REGISTRY_COORDINATOR,
};
use hex::FromHex;
use std::str::FromStr;
const HOLESKY_REGISTRY_COORDINATOR: &str = "0x53012C69A189cfA2D9d29eb6F19B32e0A2EA3490";
const HOLESKY_OPERATOR_STATE_RETRIEVER: &str = "0xB4baAfee917fb4449f5ec64804217bccE9f46C67";

async fn build_avs_registry_chain_reader() -> AvsRegistryChainReader {
let holesky_registry_coordinator =
Address::from_str(HOLESKY_REGISTRY_COORDINATOR).expect("failed to parse address");
let holesky_operator_state_retriever =
Address::from_str(HOLESKY_OPERATOR_STATE_RETRIEVER).expect("failed to parse address");

let holesky_provider = "https://ethereum-holesky.blockpi.network/v1/rpc/public";
AvsRegistryChainReader::new(
get_test_logger(),
holesky_registry_coordinator,
holesky_operator_state_retriever,
holesky_provider.to_string(),
REGISTRY_COORDINATOR,
OPERATOR_STATE_RETRIEVER,
HOLESKY_RPC_PROVIDER.to_string(),
)
.await
.unwrap()
Expand Down Expand Up @@ -697,9 +729,11 @@ mod tests {
#[tokio::test]
async fn test_is_operator_registered() {
let avs_reader = build_avs_registry_chain_reader().await;
let address = Address::from_str(HOLESKY_REGISTRY_COORDINATOR).unwrap();

let is_registered = avs_reader.is_operator_registered(address).await.unwrap();
let is_registered = avs_reader
.is_operator_registered(REGISTRY_COORDINATOR)
.await
.unwrap();
assert!(!is_registered);
}

Expand Down Expand Up @@ -727,4 +761,40 @@ mod tests {
.await
.unwrap();
}

#[tokio::test]
async fn test_query_registration_detail() {
let avs_reader = build_avs_registry_chain_reader().await;

let operator_id = U256::from_str(
"35344093966194310405039483339636912150346494903629410125452342281826147822033",
)
.unwrap();

let operator_id_b256: B256 = operator_id.into();

let operator_address = avs_reader
.get_operator_from_id(operator_id_b256.into())
.await
.unwrap();

let ret_query_registration_detail = avs_reader
.query_registration_detail(operator_address)
.await
.unwrap();

println!("{:?}", ret_query_registration_detail);

// all the value are false
for ret_value in ret_query_registration_detail.iter() {
assert!(!ret_value);
}

// register an operator
let is_registered = avs_reader
.is_operator_registered(operator_address)
.await
.unwrap();
assert!(!is_registered);
}
}
Loading
Loading