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

feat: Operator methods missing, form Go SDK #280

Merged
merged 45 commits into from
Feb 20, 2025
Merged
Show file tree
Hide file tree
Changes from 40 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
0617506
operator/validate WIP
pablodeymo Feb 4, 2025
1c8f8a5
Merge branch 'dev' into operator_validate
pablodeymo Feb 6, 2025
7c79a44
Continued with operator functions present in Go SDK
pablodeymo Feb 6, 2025
db4434c
Merge branch 'dev' into operator_validate
pablodeymo Feb 14, 2025
8f14f84
progress in point conversion
pablodeymo Feb 14, 2025
c7cbc3a
refactor: remove vec from operator ID calculation
MegaRedHand Feb 14, 2025
6973d89
fix alloy feature used
pablodeymo Feb 17, 2025
ffc21a5
to_contract_public_keys
pablodeymo Feb 17, 2025
ce9541a
refactor in files
pablodeymo Feb 17, 2025
e0775a2
fix tests
pablodeymo Feb 17, 2025
8227557
feat: add error and comments
MegaRedHand Feb 17, 2025
3cd5d9a
feat: add checks for name and description
MegaRedHand Feb 17, 2025
5e64784
chore: update deps
MegaRedHand Feb 17, 2025
d734632
chore: fix clippy lints
MegaRedHand Feb 17, 2025
9efe146
feat: add website checks
MegaRedHand Feb 17, 2025
872de46
feat: add twitter validation
MegaRedHand Feb 17, 2025
a4dd4ae
test_operator_pub_keys
pablodeymo Feb 17, 2025
2a301c7
test: add tests for operator metadata
MegaRedHand Feb 17, 2025
ba39126
ark-bn254 as dev dependency
pablodeymo Feb 17, 2025
14ba3e3
is_valid_ethereum_address
pablodeymo Feb 17, 2025
a9a7a80
using OnceLock
pablodeymo Feb 17, 2025
a24a21b
test: move common data to function
MegaRedHand Feb 17, 2025
1607623
test: add tests for invalid cases
MegaRedHand Feb 17, 2025
7246aa8
refactor: change validate to be async
MegaRedHand Feb 17, 2025
945acf3
removed unused atribute in Operator
pablodeymo Feb 17, 2025
d46e438
comment in is_valid_ethereum_address, and check if address is Zero
pablodeymo Feb 17, 2025
46bfab0
operator.rs: new method and progress in validate
pablodeymo Feb 17, 2025
e57f883
Operator::validate implemented
pablodeymo Feb 17, 2025
a1c63e4
feat: check server returns a PNG image
MegaRedHand Feb 17, 2025
519113c
refactor: simplify Operator::validate a bit
MegaRedHand Feb 17, 2025
905acbe
test: add test for new check
MegaRedHand Feb 17, 2025
6d89a79
fix: build errors
MegaRedHand Feb 17, 2025
f937799
Merge branch 'dev' into operator_validate
MegaRedHand Feb 17, 2025
89c41d3
refactor: use nice type alias
MegaRedHand Feb 17, 2025
c048812
CHANGELOG modified
pablodeymo Feb 17, 2025
7825dcc
Merge branch 'dev' into operator_validate
MegaRedHand Feb 18, 2025
2e10dc3
refactor: replace array with OperatorId
MegaRedHand Feb 18, 2025
52038ba
revert: alloy feature change
MegaRedHand Feb 18, 2025
2269c63
chore: remove whitespace in error message
MegaRedHand Feb 18, 2025
28ac0db
chore: fix clippy lints
MegaRedHand Feb 18, 2025
d1b2bb2
refactor: make tests for regex initialization
MegaRedHand Feb 19, 2025
a7e9eff
docs: fix comments
MegaRedHand Feb 19, 2025
2a02994
fix: remove unwraps
MegaRedHand Feb 19, 2025
7b72435
Merge branch 'dev' into operator_validate
MegaRedHand Feb 19, 2025
9d57835
Merge branch 'dev' into operator_validate
supernovahs Feb 20, 2025
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
25 changes: 25 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,31 @@ Those changes in added, changed or breaking changes, should include usage exampl
.unwrap();
```

* Added functions `new()` and `validate()` to `Operator` struct in [#280](https://github.com/Layr-Labs/eigensdk-rs/pull/280).

```rust
let operator = Operator::new(
"f39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
"70997970C51812dc3A010C7d01b50e0d17dc79C8",
"http://www.example.com/eigensdk-rs.json",
3
);
operator.validate();
```

* Added `OperatorMetadata` struct in [#280](https://github.com/Layr-Labs/eigensdk-rs/pull/280).

```rust
let operator_metadata = OperatorMetadata {
name: "Ethereum Utopia".to_string(),
description: "Rust operator is good operator".to_string(),
logo: "https://goerli-operator-metadata.s3.amazonaws.com/eigenlayer.png".to_string(),
website: Some("https://test.com".to_string()),
twitter: Some("https://twitter.com/test".to_string()),
};
operator_metadata.validate();
```

* Added new method `update_avs_metadata_uri` in `avsregistry/writer` in [#344](https://github.com/Layr-Labs/eigensdk-rs/pull/344).

```rust
Expand Down
19 changes: 19 additions & 0 deletions Cargo.lock

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

5 changes: 2 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ 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-common = { version = "0.3.0", path = "crates/common/" }
eigen-common = { version = "0.3.0", path = "crates/common/" }
eigen-client-elcontracts = { version = "0.3.0", path = "crates/chainio/clients/elcontracts" }
eigen-client-eth = { version = "0.3.0", path = "crates/chainio/clients/eth" }
eigen-client-fireblocks = { version = "0.3.0", path = "crates/chainio/clients/fireblocks" }
Expand Down Expand Up @@ -127,7 +127,6 @@ uuid = { version = "1.11", features = ["v4"] }
parking_lot = "0.12"



# alloy
alloy = { version = "0.9", features = [
"sol-types",
Expand All @@ -136,4 +135,4 @@ alloy = { version = "0.9", features = [
"signer-aws",
"rlp",
"json-rpc",
] }
] }
6 changes: 2 additions & 4 deletions crates/chainio/clients/avsregistry/src/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,10 +295,8 @@ impl AvsRegistryChainWriter {
})
.collect();

let operator_id = FixedBytes::from(
operator_id_from_g1_pub_key(bls_key_pair.public_key())
.map_err(|_| AvsRegistryError::GetOperatorId)?,
);
let operator_id = operator_id_from_g1_pub_key(bls_key_pair.public_key())
.map_err(|_| AvsRegistryError::GetOperatorId)?;

let churn_wallet = PrivateKeySigner::from_str(&churn_signer_private_key)
.map_err(|_| AvsRegistryError::InvalidPrivateKey)?;
Expand Down
17 changes: 7 additions & 10 deletions crates/chainio/clients/elcontracts/src/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,15 @@ impl ELChainWriter {
///
/// # Returns
///
/// * `FixedBytes<32>` - The transaction hash if successful, otherwise an error
/// * `TxHash` - The transaction hash if successful, otherwise an error
///
/// # Errors
///
/// * `ElContractsError` - if the call to the contract fails
pub async fn register_as_operator(
&self,
operator: Operator,
) -> Result<FixedBytes<32>, ElContractsError> {
) -> Result<TxHash, ElContractsError> {
info!("registering operator {:?} to EigenLayer", operator.address);
let provider = get_signer(&self.signer.clone(), &self.provider);

Expand All @@ -99,7 +99,7 @@ impl ELChainWriter {
let contract_call = contract_delegation_manager.registerAsOperator(
operator.address,
operator.allocation_delay,
operator.metadata_url.unwrap_or_default(),
operator.metadata_url,
);
contract_call.gas(300000)
};
Expand Down Expand Up @@ -162,7 +162,7 @@ impl ELChainWriter {
info!(tx_hash = %modify_operator_tx.tx_hash(), operator = %operator.address, "updated operator details tx");

let contract_call_update_metadata_uri = contract_delegation_manager
.updateOperatorMetadataURI(operator.address, operator.metadata_url.unwrap_or_default());
.updateOperatorMetadataURI(operator.address, operator.metadata_url);

let metadata_tx = contract_call_update_metadata_uri.send().await?;

Expand Down Expand Up @@ -887,9 +887,8 @@ mod tests {

let operator = Operator {
address: FIRST_ADDRESS, // can only register the address corresponding to the signer used in the writer
staker_opt_out_window_blocks: 3,
delegation_approver_address: FIRST_ADDRESS,
metadata_url: Some("metadata_uri".to_string()),
metadata_url: "metadata_uri".to_string(),
allocation_delay: 1,
};
el_chain_writer
Expand Down Expand Up @@ -919,9 +918,8 @@ mod tests {

let operator = Operator {
address,
staker_opt_out_window_blocks: 3,
delegation_approver_address: Address::ZERO,
metadata_url: Some("eigensdk-rs".to_string()),
metadata_url: "eigensdk-rs".to_string(),
allocation_delay: 1,
};

Expand All @@ -936,9 +934,8 @@ mod tests {

let operator_modified = Operator {
address,
staker_opt_out_window_blocks: 3,
delegation_approver_address: Address::ZERO,
metadata_url: Some("new-metadata".to_string()),
metadata_url: "new-metadata".to_string(),
allocation_delay: 1,
};

Expand Down
6 changes: 5 additions & 1 deletion crates/crypto/bls/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@ use thiserror::Error;

#[derive(Debug, Error)]
pub enum BlsError {
/// Invalid Bls Public Key
#[error("Invalid bls public key")]
InvalidPublicKey,

/// Invalid Bls Private Key
#[error("Invalid bls private key ")]
#[error("Invalid bls private key")]
InvalidBlsPrivateKey,

/// Invalid G1Affine
Expand Down
12 changes: 6 additions & 6 deletions crates/services/avsregistry/src/chaincaller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ use async_trait::async_trait;
use eigen_client_avsregistry::{error::AvsRegistryError, reader::AvsRegistryReader};
use eigen_crypto_bls::{BlsG1Point, PublicKey};
use eigen_services_operatorsinfo::operator_info::OperatorInfoService;
use eigen_types::operator::{OperatorAvsState, OperatorInfo, OperatorPubKeys, QuorumAvsState};
use eigen_types::avs_state::{OperatorAvsState, QuorumAvsState};
use eigen_types::operator::{OperatorInfo, OperatorPubKeys};
use eigen_utils::slashing::middleware::operatorstateretriever::OperatorStateRetriever::CheckSignaturesIndices;
use std::collections::HashMap;

Expand Down Expand Up @@ -57,7 +58,7 @@ impl<R: AvsRegistryReader + Sync, S: OperatorInfoService + Sync> AvsRegistryServ
let avs_state = operators_avs_state
.entry(FixedBytes(*operator.operatorId))
.or_insert_with(|| OperatorAvsState {
operator_id: *operator.operatorId,
operator_id: operator.operatorId,
operator_info: OperatorInfo {
pub_keys: Some(info),
},
Expand Down Expand Up @@ -173,9 +174,8 @@ mod tests {
use eigen_crypto_bls::BlsKeyPair;
use eigen_services_operatorsinfo::fake_operator_info::FakeOperatorInfoService;
use eigen_testing_utils::test_data::TestData;
use eigen_types::operator::{
OperatorAvsState, OperatorInfo, OperatorPubKeys, QuorumAvsState, QuorumNum,
};
use eigen_types::avs_state::{OperatorAvsState, QuorumAvsState};
use eigen_types::operator::{OperatorInfo, OperatorPubKeys, QuorumNum};
use eigen_types::test::TestOperator;
use serde::Deserialize;

Expand Down Expand Up @@ -287,7 +287,7 @@ mod tests {
.unwrap();

let expected_operator_avs_state = OperatorAvsState {
operator_id: test_operator.operator_id.into(),
operator_id: test_operator.operator_id,
operator_info: OperatorInfo {
pub_keys: Some(OperatorPubKeys::from(test_operator.bls_keypair)),
},
Expand Down
5 changes: 3 additions & 2 deletions crates/services/avsregistry/src/fake_avs_registry_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ use ark_ec::{short_weierstrass::Affine, AffineRepr, CurveGroup};
use async_trait::async_trait;
use eigen_client_avsregistry::error::AvsRegistryError;
use eigen_crypto_bls::{BlsG1Point, OperatorId, PublicKey};
use eigen_types::avs_state::{OperatorAvsState, QuorumAvsState};
use eigen_types::{
operator::{OperatorAvsState, OperatorInfo, OperatorPubKeys, QuorumAvsState, QuorumNum},
operator::{OperatorInfo, OperatorPubKeys, QuorumNum},
test::TestOperator,
};
use eigen_utils::slashing::middleware::operatorstateretriever::OperatorStateRetriever::CheckSignaturesIndices;
Expand Down Expand Up @@ -37,7 +38,7 @@ impl FakeAvsRegistryService {
// populate the inner hashmap
for op in test_operators {
let state = OperatorAvsState {
operator_id: op.operator_id.into(),
operator_id: op.operator_id,
operator_info: OperatorInfo {
pub_keys: Some(OperatorPubKeys::from(op.bls_keypair)),
},
Expand Down
2 changes: 1 addition & 1 deletion crates/services/avsregistry/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use std::collections::HashMap;
use alloy::primitives::FixedBytes;
use async_trait::async_trait;
use eigen_client_avsregistry::error::AvsRegistryError;
use eigen_types::operator::{OperatorAvsState, QuorumAvsState};
use eigen_types::avs_state::{OperatorAvsState, QuorumAvsState};
use eigen_utils::slashing::middleware::operatorstateretriever::OperatorStateRetriever::CheckSignaturesIndices;

pub mod chaincaller;
Expand Down
5 changes: 3 additions & 2 deletions crates/services/bls_aggregation/src/bls_agg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ use eigen_crypto_bls::{BlsG1Point, BlsG2Point, Signature};
use eigen_crypto_bn254::utils::verify_message;
use eigen_logging::logger::SharedLogger;
use eigen_services_avsregistry::AvsRegistryService;
use eigen_types::avs_state::OperatorAvsState;
use eigen_types::{
avs::{SignatureVerificationError, SignedTaskResponseDigest, TaskIndex, TaskResponseDigest},
operator::{OperatorAvsState, QuorumThresholdPercentage, QuorumThresholdPercentages},
operator::{QuorumThresholdPercentage, QuorumThresholdPercentages},
};
use parking_lot::RwLock;
use std::collections::HashMap;
Expand Down Expand Up @@ -565,7 +566,7 @@ impl<A: AvsRegistryService + Send + Sync + Clone + 'static> BlsAggregatorService
signers_apk_g2,
signers_agg_sig_g1,
signers_operator_ids_set: HashMap::from([(
operator_state.operator_id.into(),
operator_state.operator_id,
true,
)]),
signers_total_stake_per_quorum: operator_state.stake_per_quorum.clone(),
Expand Down
27 changes: 9 additions & 18 deletions crates/services/bls_aggregation/src/bls_agg_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,7 @@ pub mod integration_test {
.to_string(),
)
.unwrap();
let operator_id =
FixedBytes::from(operator_id_from_g1_pub_key(bls_key_pair.public_key()).unwrap());
let operator_id = operator_id_from_g1_pub_key(bls_key_pair.public_key()).unwrap();
let el_chain_reader = ELChainReader::new(
get_test_logger(),
None,
Expand Down Expand Up @@ -501,8 +500,7 @@ pub mod integration_test {
.await
.unwrap()
._0;
let operator_id =
FixedBytes::from(operator_id_from_g1_pub_key(bls_key_pair.public_key()).unwrap());
let operator_id = operator_id_from_g1_pub_key(bls_key_pair.public_key()).unwrap();
assert_eq!(s, operator_id);
bls_agg_service
.process_new_signature(TaskSignature::new(
Expand Down Expand Up @@ -663,10 +661,8 @@ pub mod integration_test {
// Compute the signature and send it to the aggregation service
let task_response = 123;
let task_response_digest = hash(task_response);
let operator_id_1 =
FixedBytes::from(operator_id_from_g1_pub_key(bls_key_pair_1.public_key()).unwrap());
let operator_id_2 =
FixedBytes::from(operator_id_from_g1_pub_key(bls_key_pair_2.public_key()).unwrap());
let operator_id_1 = operator_id_from_g1_pub_key(bls_key_pair_1.public_key()).unwrap();
let operator_id_2 = operator_id_from_g1_pub_key(bls_key_pair_2.public_key()).unwrap();
let bls_signature_1 = bls_key_pair_1.sign_message(task_response_digest.as_ref());

bls_agg_service
Expand Down Expand Up @@ -739,10 +735,8 @@ pub mod integration_test {

let bls_key_pair_2 = BlsKeyPair::new(BLS_KEY_2.to_string()).unwrap();

let operator_id_1 =
FixedBytes::from(operator_id_from_g1_pub_key(bls_key_pair_1.public_key()).unwrap());
let operator_id_2 =
FixedBytes::from(operator_id_from_g1_pub_key(bls_key_pair_2.public_key()).unwrap());
let operator_id_1 = operator_id_from_g1_pub_key(bls_key_pair_1.public_key()).unwrap();
let operator_id_2 = operator_id_from_g1_pub_key(bls_key_pair_2.public_key()).unwrap();
let el_chain_reader = ELChainReader::new(
get_test_logger(),
None,
Expand Down Expand Up @@ -918,10 +912,8 @@ pub mod integration_test {
create_operator_set(http_endpoint.as_str(), avs_address).await;
create_operator_set(http_endpoint.as_str(), avs_address).await;

let operator_id_1 =
FixedBytes::from(operator_id_from_g1_pub_key(bls_key_pair_1.public_key()).unwrap());
let operator_id_2 =
FixedBytes::from(operator_id_from_g1_pub_key(bls_key_pair_2.public_key()).unwrap());
let operator_id_1 = operator_id_from_g1_pub_key(bls_key_pair_1.public_key()).unwrap();
let operator_id_2 = operator_id_from_g1_pub_key(bls_key_pair_2.public_key()).unwrap();
let el_chain_reader = ELChainReader::new(
get_test_logger(),
None,
Expand Down Expand Up @@ -1090,8 +1082,7 @@ pub mod integration_test {
let provider = get_provider(http_endpoint.as_str());

let bls_key_pair_1 = BlsKeyPair::new(BLS_KEY_1.to_string()).unwrap();
let operator_id_1 =
FixedBytes::from(operator_id_from_g1_pub_key(bls_key_pair_1.public_key()).unwrap());
let operator_id_1 = operator_id_from_g1_pub_key(bls_key_pair_1.public_key()).unwrap();
// Create quorums
let quorum_nums = Bytes::from([0u8, 1u8]);
let quorum_threshold_percentages: QuorumThresholdPercentages = vec![100, 100];
Expand Down
15 changes: 3 additions & 12 deletions crates/services/operatorsinfo/src/operatorsinfo_inmemory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,13 +182,7 @@ impl OperatorInfoServiceInMemory {
if *entry_src == StateSource::Event
&& state_src == StateSource::Historic => {}
_ => {
id_map.insert(
addr,
(
state_src.clone(),
alloy::primitives::FixedBytes(operator_id),
),
);
id_map.insert(addr, (state_src.clone(), operator_id));
}
}
}
Expand Down Expand Up @@ -490,9 +484,7 @@ async fn query_past_registered_operator_events_and_fill_db(
}

for (i, address) in operator_address.iter().enumerate() {
let operator_id = FixedBytes(operator_id_from_g1_pub_key(
operator_pub_keys[i].g1_pub_key.clone(),
)?);
let operator_id = operator_id_from_g1_pub_key(operator_pub_keys[i].g1_pub_key.clone())?;
if let Some(socket) = socket_map.get(&operator_id) {
let message = OperatorsInfoMessage::InsertOperatorInfo(
Some(*address),
Expand Down Expand Up @@ -772,8 +764,7 @@ mod tests {
let operator_details = Operator {
address: signer.address(),
delegation_approver_address: signer.address(),
staker_opt_out_window_blocks: 3,
metadata_url: Some("eigensdk-rs".to_string()),
metadata_url: "eigensdk-rs".to_string(),
allocation_delay: 0,
};

Expand Down
Loading
Loading