Skip to content

Commit

Permalink
Utilities for Testing, Contracts, and Operators
Browse files Browse the repository at this point in the history
  • Loading branch information
Tjemmmic committed Aug 14, 2024
1 parent c71a1ea commit 3c7f124
Show file tree
Hide file tree
Showing 17 changed files with 846 additions and 453 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

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

5 changes: 1 addition & 4 deletions avs/incredible-squaring-avs/src/operator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -336,10 +336,7 @@ impl<T: Config, I: OperatorInfoServiceTrait> Operator<T, I> {
let operator_is_registered = self
.avs_registry_contract_manager
.is_operator_registered(self.operator_addr)
.await; //?;
// if !operator_is_registered {
// return Err(OperatorError::OperatorNotRegistered);
// }
.await;
log::info!("Operator registration status: {:?}", operator_is_registered);

if self.config.enable_node_api {
Expand Down
6 changes: 3 additions & 3 deletions avs/tangle-avs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,21 @@ sol!(
#[derive(Debug)]
#[sol(rpc)]
TangleValidatorTaskManager,
"./contracts/out/TangleValidatorTaskManager.sol/TangleValidatorTaskManager.json"
"contracts/out/TangleValidatorTaskManager.sol/TangleValidatorTaskManager.json"
);

sol!(
#[allow(missing_docs)]
#[derive(Debug)]
#[sol(rpc)]
TangleValidatorServiceManager,
"./contracts/out/TangleValidatorServiceManager.sol/TangleValidatorServiceManager.json"
"contracts/out/TangleValidatorServiceManager.sol/TangleValidatorServiceManager.json"
);

sol!(
#[allow(missing_docs)]
#[derive(Debug)]
#[sol(rpc)]
ITangleValidatorTaskManager,
"./contracts/out/ITangleValidatorTaskManager.sol/ITangleValidatorTaskManager.json"
"contracts/out/ITangleValidatorTaskManager.sol/ITangleValidatorTaskManager.json"
);
20 changes: 2 additions & 18 deletions avs/tangle-avs/src/operator.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use alloy_contract::private::Ethereum;
use alloy_primitives::{ruint, Address, ChainId, FixedBytes, Signature, B256};
use alloy_primitives::{Address, ChainId, Signature, B256};
use alloy_provider::{Provider, RootProvider};
use alloy_signer_local::PrivateKeySigner;
use alloy_transport::BoxTransport;
Expand All @@ -10,15 +10,11 @@ use eigen_utils::crypto::bls::KeyPair;
use eigen_utils::node_api::NodeApi;
use eigen_utils::types::AvsError;
use eigen_utils::Config;
use gadget_common::subxt_signer::bip39::rand;
use gadget_common::subxt_signer::bip39::rand::Rng;
use k256::ecdsa::SigningKey;
use log::error;
use ruint::aliases;
use std::future::Future;
use std::pin::Pin;
use std::str::FromStr;
use std::time::{SystemTime, UNIX_EPOCH};
use thiserror::Error;

const AVS_NAME: &str = "incredible-squaring";
Expand Down Expand Up @@ -247,21 +243,9 @@ impl<T: Config> Operator<T> {
// );
// }

let mut salt = [0u8; 32];
rand::thread_rng().fill(&mut salt);
let sig_salt = FixedBytes::from_slice(&salt);
let expiry = aliases::U256::from(
SystemTime::now()
.duration_since(UNIX_EPOCH)
.unwrap()
.as_secs()
+ 3600,
);
let _register_result = avs_registry_contract_manager
.register_operator_in_quorum_with_avs_registry_coordinator(
.register_operator(
&ecdsa_signing_key,
sig_salt,
expiry,
&bls_keypair,
alloy_primitives::Bytes::from(vec![0]),
"127.0.0.1:8545".to_string(),
Expand Down
2 changes: 1 addition & 1 deletion test-utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ aws-sdk-kms.workspace = true
eigen-contracts.workspace = true
eigen-utils.workspace = true
incredible-squaring-avs.workspace = true
#tangle-avs.workspace = true
tangle-avs.workspace = true
aws-kms.workspace = true
gadget-common = { workspace = true, default-features = false, features = ["default"] }
# gadget-common = { workspace = true, features = ["tangle-testnet"] }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ impl AnvilInstance {

/// Returns the chain of the anvil instance
pub fn chain_id(&self) -> u64 {
self.chain_id.unwrap_or_else(|| 0u64)
self.chain_id.unwrap_or(0u64)
}

/// Returns the HTTP endpoint of this instance
Expand Down
9 changes: 4 additions & 5 deletions test-utils/src/anvil/local_chain.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::anvil::anvil::{Anvil, AnvilInstance};
use crate::anvil::anvil_node::{Anvil, AnvilInstance};
use crate::anvil::random_port;
use ethers::signers::Signer;
use std::sync::Arc;
Expand Down Expand Up @@ -94,10 +94,9 @@ impl LocalEvmChain {
state_dir: Option<&std::path::Path>,
port: Option<u16>,
) -> AnvilInstance {
let port = if port.is_some() {
port.unwrap()
} else {
random_port::random_port()
let port = match port {
None => random_port::random_port(),
Some(port) => port,
};
let mut anvil = Anvil::new()
.port(port)
Expand Down
2 changes: 1 addition & 1 deletion test-utils/src/anvil/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pub mod abi;
pub mod anvil;
pub mod anvil_node;
pub mod local_chain;
mod random_port;
pub mod testnet;
Loading

0 comments on commit 3c7f124

Please sign in to comment.