Skip to content

Commit

Permalink
Updates for Gadget Eigen Blueprints (#24)
Browse files Browse the repository at this point in the history
* Fixes for Gadget Blueprint Testing

* Small changes for gadget
  • Loading branch information
Tjemmmic authored Sep 30, 2024
1 parent f9a9932 commit 8262b74
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 29 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ The full test starts a local Anvil testnet, deploys all the required contracts t

1. Build
```bash
cargo build --release
cargo build --release -p test-utils
```

2. Run
Expand Down
25 changes: 13 additions & 12 deletions avs/incredible-squaring-avs/src/operator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ use std::pin::Pin;
use std::str::FromStr;
use thiserror::Error;

const AVS_NAME: &str = "incredible-squaring";
const SEM_VER: &str = "0.0.1";
pub const AVS_NAME: &str = "incredible-squaring";
pub const SEM_VER: &str = "0.0.1";

/// Error type specific to the Operator for the Incredible Squaring AVS
#[derive(Debug, Error)]
Expand Down Expand Up @@ -86,21 +86,22 @@ pub enum OperatorError {
}

/// Incredible Squaring AVS Operator Struct
#[derive(Clone)]
pub struct Operator<T: Config, I: OperatorInfoServiceTrait> {
config: NodeConfig,
node_api: NodeApi,
avs_registry_contract_manager: AvsRegistryContractManager<T>,
incredible_squaring_contract_manager: IncredibleSquaringContractManager<T>,
eigenlayer_contract_manager: ElChainContractManager<T>,
bls_keypair: KeyPair,
operator_id: FixedBytes<32>,
operator_addr: Address,
aggregator_server_ip_port_addr: String,
pub config: NodeConfig,
pub node_api: NodeApi,
pub avs_registry_contract_manager: AvsRegistryContractManager<T>,
pub incredible_squaring_contract_manager: IncredibleSquaringContractManager<T>,
pub eigenlayer_contract_manager: ElChainContractManager<T>,
pub bls_keypair: KeyPair,
pub operator_id: FixedBytes<32>,
pub operator_addr: Address,
pub aggregator_server_ip_port_addr: String,
pub aggregator_server: Aggregator<T, I>,
pub aggregator_rpc_client: AggregatorRpcClient,
}

#[derive(Clone)]
#[derive(Clone, Debug)]
pub struct EigenGadgetProvider {
pub provider: RootProvider<BoxTransport, Ethereum>,
}
Expand Down
21 changes: 21 additions & 0 deletions test-utils/src/anvil/testnet/incredible_squaring.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,27 @@ pub struct ContractAddresses {
pub operator: Address,
}

impl std::fmt::Display for ContractAddresses {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
writeln!(f, "Contract Addresses:")?;
writeln!(f, " Service Manager: {}", self.service_manager)?;
writeln!(
f,
" Registry Coordinator: {}",
self.registry_coordinator
)?;
writeln!(
f,
" Operator State Retriever: {}",
self.operator_state_retriever
)?;
writeln!(f, " Delegation Manager: {}", self.delegation_manager)?;
writeln!(f, " AVS Directory: {}", self.avs_directory)?;
writeln!(f, " Operator: {}", self.operator)?;
Ok(())
}
}

/// Spawns and runs an Anvil Node, deploying the Smart Contracts that are relevant to
/// the Incredible Squaring AVS to it.
///
Expand Down
26 changes: 16 additions & 10 deletions test-utils/src/bin/incredible_squaring.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,27 @@ use eigen_utils::types::{operator_id_from_key_pair, OperatorInfo, OperatorPubkey
use incredible_squaring_avs::operator::*;
use k256::ecdsa::SigningKey;
use k256::elliptic_curve::SecretKey;
use std::env;
use test_utils::anvil::testnet::incredible_squaring::*;

#[tokio::main]
async fn main() {
let _ = env_logger::try_init();
run_incredible_squaring_testnet().await;
let contract_addresses = run_incredible_squaring_testnet().await;
println!("Contract Addresses: {contract_addresses}");
println!("The Incredible Squaring Testnet is now running. Press Ctrl-C to exit...");
tokio::signal::ctrl_c()
.await
.expect("Failed to listen for Ctrl-C");
}

pub fn env_init() {
if env::var("RUST_LOG").is_err() {
env::set_var("RUST_LOG", "info");
}
env::set_var("BLS_PASSWORD", "BLS_PASSWORD");
env::set_var("ECDSA_PASSWORD", "ECDSA_PASSWORD");
let _ = env_logger::try_init();
}

/// Sets up an Operator, given the [ContractAddresses] for the running Testnet you would like utilize
Expand Down Expand Up @@ -133,15 +148,6 @@ mod tests {
use incredible_squaring_avs::avs::IncredibleSquaringTaskManager;
use std::env;

fn env_init() {
if env::var("RUST_LOG").is_err() {
env::set_var("RUST_LOG", "info");
}
env::set_var("BLS_PASSWORD", "BLS_PASSWORD");
env::set_var("ECDSA_PASSWORD", "ECDSA_PASSWORD");
let _ = env_logger::try_init();
}

#[tokio::test]
async fn test_incredible_squaring_deployment() {
env_init();
Expand Down
8 changes: 2 additions & 6 deletions utils/src/avs_registry/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ use eigen_contracts::{
Bn254, PubkeyRegistrationParams, RegistryCoordinator, SignatureWithSaltAndExpiry,
};
use k256::ecdsa::VerifyingKey;
use rand::Rng;

pub trait AvsRegistryChainWriterTrait {
async fn register_operator(
Expand Down Expand Up @@ -100,11 +99,8 @@ impl<T: Config> AvsRegistryChainWriterTrait for AvsRegistryContractManager<T> {
};

// Generate a random salt and 1 hour expiry for the signature
let mut rng = rand::thread_rng();
let mut operator_to_avs_registration_sig_salt = [0u8; 32];
rng.fill(&mut operator_to_avs_registration_sig_salt);
let operator_to_avs_registration_sig_salt =
FixedBytes::from(operator_to_avs_registration_sig_salt);
let rng: [u8; 32] = rand::random();
let operator_to_avs_registration_sig_salt = FixedBytes::from(rng);

let cur_block_num = self.eth_client_http.get_block_number().await?;
let cur_block = self
Expand Down

0 comments on commit 8262b74

Please sign in to comment.