Skip to content

Commit

Permalink
nits
Browse files Browse the repository at this point in the history
  • Loading branch information
supernovahs committed May 10, 2024
1 parent db45acc commit eb21bc2
Show file tree
Hide file tree
Showing 24 changed files with 69 additions and 297 deletions.
30 changes: 0 additions & 30 deletions Cargo.lock

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

8 changes: 1 addition & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ members = [ "crates/chainio/clients/avsregistry/",
"crates/chainio/clients/eth/",
"crates/chainio/clients/fireblocks/",
"crates/contracts/bindings/",
"crates/signerv2/",
"crates/chainio/utils/",
"crates/crypto/bn254/",
"crates/utils/",
Expand All @@ -16,8 +15,7 @@ members = [ "crates/chainio/clients/avsregistry/",
"crates/services/operatorsinfo/",
"crates/types/",
"crates/metrics/",
"crates/types/",
"crates/signer/"]
"crates/types/"]

resolver = "2"

Expand All @@ -43,8 +41,6 @@ rustdoc.all = "warn"
[workspace.dependencies]
ethers = "2.0.14"
ark-ff = "0.4.0"
ethers-providers ="2.0.14"
ethers-core = "2.0.14"
reth = {git = "https://github.com/paradigmxyz/reth"}
prometheus-client = "0.22.2"
bn254 = {git = "https://github.com/sedaprotocol/bn254"}
Expand All @@ -59,9 +55,7 @@ eigensdk-contract-bindings = {version = "0.0.1-alpha", path = "crates/contracts/
eigensdk-types = {version = "0.0.1-alpha",path = "crates/types/"}
eigensdk-crypto-bls = {path = "crates/crypto/bls/"}
eigensdk-crypto-bn254 = {version = "0.0.1-alpha",path = "crates/crypto/bn254/"}
eigensdk-signerv2 = {version = "0.0.1-alpha",path = "crates/signerv2/"}
eigensdk-utils = {version = "0.0.1-alpha" , path = "crates/utils/"}
ethers-signers = "2.0.14"
eigensdk-metrics-collectors-economic = {version = "0.0.1-alpha",path = "crates/metrics/collectors/economic"}
eigensdk-metrics-collectors-rpc-calls = {version = "0.0.1-alpha",path = "crates/metrics/collectors/rpc_calls"}
eigensdk-services-avsregistry = {path = "crates/services/avsregistry"}
Expand Down
22 changes: 11 additions & 11 deletions crates/chainio/clients/avsregistry/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! AvsRegistry methods for reading, writing and subscribing purposes.
use alloy_primitives::types::H256;
use alloy_primitives::B256;

#[allow(dead_code)]
/// Reader module
Expand All @@ -16,14 +16,14 @@ pub mod writer;
/// Avs registry error message
pub mod error;

/// cast sig-event "NewPubkeyRegistration(address,(uint256,uint256),(uint256[2],uint256[2]))"
pub const NEW_BLS_APK_REGISTRATION_EVENT_SIGNATURE: H256 = H256([
0xe3, 0xfb, 0x66, 0x13, 0xaf, 0x2e, 0x89, 0x30, 0xcf, 0x85, 0xd4, 0x7f, 0xcf, 0x6d, 0xb1, 0x01,
0x92, 0x22, 0x4a, 0x64, 0xc6, 0xcb, 0xe8, 0x02, 0x3e, 0x0e, 0xee, 0x1b, 0xa3, 0x82, 0x80, 0x41,
]);
// /// cast sig-event "NewPubkeyRegistration(address,(uint256,uint256),(uint256[2],uint256[2]))"
// pub const NEW_BLS_APK_REGISTRATION_EVENT_SIGNATURE: H256 = H256([
// 0xe3, 0xfb, 0x66, 0x13, 0xaf, 0x2e, 0x89, 0x30, 0xcf, 0x85, 0xd4, 0x7f, 0xcf, 0x6d, 0xb1, 0x01,
// 0x92, 0x22, 0x4a, 0x64, 0xc6, 0xcb, 0xe8, 0x02, 0x3e, 0x0e, 0xee, 0x1b, 0xa3, 0x82, 0x80, 0x41,
// ]);

/// cast sig-event "OperatorSocketUpdate(bytes32,string)"
pub const OPERATOR_SOCKET_UPDATE_EVENT_SIGNATURE: H256 = H256([
0xec, 0x29, 0x63, 0xab, 0x21, 0xc1, 0xe5, 0x0e, 0x1e, 0x58, 0x2a, 0xa5, 0x42, 0xaf, 0x2e, 0x4b,
0xf7, 0xbf, 0x38, 0xe6, 0xe1, 0x40, 0x3c, 0x27, 0xb4, 0x2e, 0x1c, 0x5d, 0x6e, 0x62, 0x1e, 0xaa,
]);
// /// cast sig-event "OperatorSocketUpdate(bytes32,string)"
// pub const OPERATOR_SOCKET_UPDATE_EVENT_SIGNATURE: H256 = H256([
// 0xec, 0x29, 0x63, 0xab, 0x21, 0xc1, 0xe5, 0x0e, 0x1e, 0x58, 0x2a, 0xa5, 0x42, 0xaf, 0x2e, 0x4b,
// 0xf7, 0xbf, 0x38, 0xe6, 0xe1, 0x40, 0x3c, 0x27, 0xb4, 0x2e, 0x1c, 0x5d, 0x6e, 0x62, 0x1e, 0xaa,
// ]);
4 changes: 2 additions & 2 deletions crates/chainio/clients/avsregistry/src/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -507,14 +507,14 @@ impl AvsRegistryChainReader {
to_block = stop_block;
}

let filter = Filter::new()
let mut filter = Filter::new()
.select(start_block..to_block)
.event("OperatorSocketUpdate(bytes32,string)")
.address(self.registry_coordinator_addr);
if stop_block == 0 {
let current_block_number = provider.get_block_number().await?;

filter.clone().select(start_block..current_block_number);
filter = filter.clone().select(start_block..current_block_number);
};

let logs = provider.get_logs(&filter).await?;
Expand Down
10 changes: 5 additions & 5 deletions crates/chainio/clients/avsregistry/src/subscriber.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use alloy_provider::{
use alloy_provider::{Provider, ProviderBuilder};
use alloy_rpc_types::Filter;
use alloy_transport::BoxTransport;
use BLSApkRegistry::{BLSApkRegistryEvents, BLSApkRegistryInstance,NewPubkeyRegistration};
use BLSApkRegistry::{BLSApkRegistryEvents, BLSApkRegistryInstance, NewPubkeyRegistration};

/// AvsRegistry Chain Subscriber struct
#[derive(Debug)]
Expand Down Expand Up @@ -60,17 +60,17 @@ impl AvsRegistryChainSubscriber {
return Ok(bls_apk_reg);
}

pub async fn get_new_pub_key_registration_filter<'a>(&self) -> Result<Filter, Box<dyn std::error::Error>> {
pub async fn get_new_pub_key_registration_filter<'a>(
&self,
) -> Result<Filter, Box<dyn std::error::Error>> {
let provider = ProviderBuilder::new()
.with_recommended_fillers()
.on_builtin(&self.provider)
.await?;
let current_block_number = provider.get_block_number().await.unwrap();

let filter = Filter::new()
.event(
"NewPubkeyRegistration(address,(uint256,uint256),(uint256[2],uint256[2]))"
)
.event("NewPubkeyRegistration(address,(uint256,uint256),(uint256[2],uint256[2]))")
.from_block(current_block_number);
Ok(filter)
}
Expand Down
50 changes: 30 additions & 20 deletions crates/chainio/clients/avsregistry/src/writer.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use crate::error::AvsRegistryError;
use alloy_network::EthereumSigner;
use alloy_signer::SignerSync;
use alloy_signer_wallet::LocalWallet;
Expand All @@ -9,12 +8,14 @@ use eigensdk_chainio_utils::{
};
use eigensdk_client_elcontracts::reader::ELChainReader;
use reqwest::Url;
sol!(
#[allow(missing_docs)]
#[sol(rpc)]
RegistryCoordinator,
"../../../../crates/contracts/bindings/utils/json/RegistryCoordinator.json"
);

use eigensdk_chainio_utils::{
BLSApkRegistry::{G1Point, PubkeyRegistrationParams},
RegistryCoordinator::{
self, G1Point as RegistryG1Point, G2Point as RegistryG2Point,
PubkeyRegistrationParams as RegistryPubkeyRegistrationParams,
},
};
sol!(
#[allow(missing_docs)]
#[sol(rpc)]
Expand All @@ -29,21 +30,13 @@ sol!(
"StakeRegistry.json"
);

sol!(
#[allow(missing_docs)]
#[derive(Debug)]
#[sol(rpc)]
BLSApkRegistry,
"../../../../crates/contracts/bindings/utils/json/BLSApkRegistry.json"
);

use alloy_primitives::{Address, Bytes, FixedBytes, TxHash, U256};
use alloy_provider::{Provider, ProviderBuilder};
use eigensdk_crypto_bls::attestation::KeyPair;
use std::sync::Arc;
use tracing::info;
use BLSApkRegistry::PubkeyRegistrationParams;
use RegistryCoordinator::SignatureWithSaltAndExpiry;

#[derive(Debug)]
pub struct AvsRegistryChainWriter {
service_manager_addr: Address,
registry_coordinator_addr: Address,
Expand Down Expand Up @@ -164,7 +157,11 @@ impl AvsRegistryChainWriter {
let signed_msg = convert_to_bn254_g1_point(
bls_key_pair
.sign_hashes_to_curve_message(G1Projective::from(
convert_bn254_to_ark(g1_hashes_msg_to_sign).point,
convert_bn254_to_ark(G1Point {
X: g1_hashes_msg_to_sign.X,
Y: g1_hashes_msg_to_sign.Y,
})
.point,
))
.sig(),
);
Expand Down Expand Up @@ -206,7 +203,20 @@ impl AvsRegistryChainWriter {
let contract_call = contract_registry_coordinator.registerOperator(
quorum_numbers.clone(),
socket,
pub_key_reg_params,
RegistryPubkeyRegistrationParams {
pubkeyRegistrationSignature: RegistryG1Point {
X: pub_key_reg_params.pubkeyRegistrationSignature.X,
Y: pub_key_reg_params.pubkeyRegistrationSignature.Y,
},
pubkeyG1: RegistryG1Point {
X: pub_key_reg_params.pubkeyG1.X,
Y: pub_key_reg_params.pubkeyG1.Y,
},
pubkeyG2: RegistryG2Point {
X: pub_key_reg_params.pubkeyG2.X,
Y: pub_key_reg_params.pubkeyG2.Y,
},
},
operator_signature_with_salt_and_expiry,
);

Expand Down Expand Up @@ -282,6 +292,6 @@ impl AvsRegistryChainWriter {
let tx = contract_call.send().await?;

info!(tx_hash = ?tx,"succesfully deregistered operator with the AVS's registry coordinator" );
return Ok(tx.tx_hash());
return Ok(*tx.tx_hash());
}
}
1 change: 1 addition & 0 deletions crates/chainio/clients/elcontracts/src/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ use std::sync::Arc;

use crate::error::ElContractsError;

#[derive(Debug)]
pub struct ELChainReader {
slasher: Address,
delegation_manager: Address,
Expand Down
1 change: 0 additions & 1 deletion crates/chainio/utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ repository.workspace = true
license-file.workspace = true

[dependencies]
ethers.workspace = true
ark-bn254 = "0.4.0"
ark-ff.workspace = true
eigensdk-contract-bindings.workspace = true
Expand Down
23 changes: 15 additions & 8 deletions crates/chainio/utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,33 +8,40 @@ sol!(
RegistryCoordinator,
"../../../crates/contracts/bindings/utils/json/RegistryCoordinator.json"
);
sol!(
#[allow(missing_docs)]
#[derive(Debug)]
#[sol(rpc)]
BLSApkRegistry,
"../../../crates/contracts/bindings/utils/json/BLSApkRegistry.json"
);

use eigensdk_crypto_bls::attestation::G1Point;
use eigensdk_crypto_bls::attestation::G1Point as AttestationG1Point;
use eigensdk_crypto_bn254::utils::biginteger256_to_u256;
use eigensdk_crypto_bn254::utils::u256_to_bigint256;
use RegistryCoordinator::{G1Point as RegistryG1Point, G2Point as RegistryG2Point};
pub use BLSApkRegistry::{G1Point, G2Point};

pub fn convert_bn254_to_ark(g1_point: RegistryCoordinator::G1Point) -> G1Point {
G1Point::new(u256_to_bigint256(g1_point.X), u256_to_bigint256(g1_point.Y))
pub fn convert_bn254_to_ark(g1_point: G1Point) -> AttestationG1Point {
AttestationG1Point::new(u256_to_bigint256(g1_point.X), u256_to_bigint256(g1_point.Y))
}

pub fn convert_to_bn254_g1_point(g1: G1Projective) -> RegistryG1Point {
pub fn convert_to_bn254_g1_point(g1: G1Projective) -> G1Point {
let x: BigInteger256 = g1.x.into();
let y: BigInteger256 = g1.y.into();

RegistryG1Point {
G1Point {
X: biginteger256_to_u256(x),
Y: biginteger256_to_u256(y),
}
}

pub fn convert_to_bn254_g2_point(g2: G2Projective) -> RegistryG2Point {
pub fn convert_to_bn254_g2_point(g2: G2Projective) -> G2Point {
let x_0: BigInteger256 = g2.x.c0.into();
let x_1: BigInteger256 = g2.x.c1.into();
let y_0: BigInteger256 = g2.y.c0.into();
let y_1: BigInteger256 = g2.y.c1.into();

RegistryG2Point {
G2Point {
X: [biginteger256_to_u256(x_0), biginteger256_to_u256(x_1)],
Y: [biginteger256_to_u256(y_0), biginteger256_to_u256(y_1)],
}
Expand Down
5 changes: 1 addition & 4 deletions crates/contracts/bindings/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
//! This module is a helper module to generate ethers bindings, if required
//!
//!
//! If you are using alloy, you don't need to take any action.


1 change: 0 additions & 1 deletion crates/crypto/bls/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,5 @@ ark-bn254 = "0.4.0"
ark-ff.workspace = true
eigensdk-crypto-bn254.workspace = true
thiserror.workspace = true
ethers-core.workspace = true
ark-ec = "0.4.2"
alloy-primitives.workspace = true
Loading

0 comments on commit eb21bc2

Please sign in to comment.