Skip to content

Commit

Permalink
chore: merge main changes (#190)
Browse files Browse the repository at this point in the history
Co-authored-by: Tomas <tomas.arrachea@lambdaclass.com>
Co-authored-by: Pablo Deymonnaz <deymonnaz@gmail.com>
Co-authored-by: supernovahs <supernovahs@proton.me>
  • Loading branch information
4 people authored Jan 3, 2025
1 parent d716fc0 commit 8a2652e
Show file tree
Hide file tree
Showing 17 changed files with 528 additions and 136 deletions.
15 changes: 15 additions & 0 deletions Cargo.lock

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

26 changes: 22 additions & 4 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 @@ -110,14 +118,23 @@ 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 }
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" }
21 changes: 20 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,26 @@ Example :
cargo run --example get_quorum_count
```

## Contract Bindings

The main branch of this repo is intended to be syncronized with mainnet version of core contracts.

To update the bindings of this repo:

- Inside the `crates/contracts` folder, run:

```bash
forge bind --alloy --bindings-path <path-eigensdk-rs>/crates/utils --overwrite -C src/contracts
```

where `path-eigensdk-rs` is the full path to the eigensdk-rs (this) repo.

This command will generate the bindings files in the folder: `<path-eigensdk-rs>/crates/utils`.

⚠️ It rewrites Cargo.toml file, this file must be restored to the current version.

- Fix all compilation warnings.

## Contributor Guidelines

We are actively looking for contributors. Thank you for your interest. We have strict ci checks in place. In case of any questions and support, feel free to raise an issue.
Expand Down Expand Up @@ -105,7 +125,6 @@ Rolling `MSRV` policy of 6 months. The current `MSRV` is 1.79

🚧 Eigensdk-rs is under active development and has not been audited. Eigensdk-rs is rapidly being upgraded, features may be added, removed or otherwise improved or modified and interfaces will have breaking changes. Eigensdk-rs should be used only for testing purposes and not in production. Eigensdk-rs is provided "as is" and Eigen Labs, Inc. does not guarantee its functionality or provide support for its use in production. 🚧


## Credits

- [eigensdk-go](https://github.com/Layr-Labs/eigensdk-go/tree/master)
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);
}
}
10 changes: 8 additions & 2 deletions crates/chainio/clients/fireblocks/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,13 @@ impl FireblocksWallet {

match contains_account {
true => {
if self.whitelisted_accounts.get(&address).unwrap().id().eq("") {
if self
.whitelisted_accounts
.get(&address)
.unwrap()
.id()
.is_empty()
{
Err(FireBlockError::AccountNotFoundError(address.to_string()))
} else {
Ok(self.whitelisted_accounts.get(&address).unwrap().clone())
Expand Down Expand Up @@ -146,7 +152,7 @@ impl FireblocksWallet {
.get(&address)
.unwrap()
.id()
.eq("")
.is_empty()
{
Err(FireBlockError::ContractNotFound(address.to_string()))
} else {
Expand Down
1 change: 1 addition & 0 deletions crates/chainio/txmanager/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ eigen-signer.workspace = true
reqwest.workspace = true
thiserror.workspace = true
tokio.workspace = true
backoff.workspace = true

[dev-dependencies]
eigen-testing-utils.workspace = true
Expand Down
Loading

0 comments on commit 8a2652e

Please sign in to comment.