Skip to content

Commit

Permalink
Cleanup and workflow testing
Browse files Browse the repository at this point in the history
  • Loading branch information
Tjemmmic committed Aug 22, 2024
1 parent e90771e commit 5db6f88
Show file tree
Hide file tree
Showing 15 changed files with 139 additions and 520 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/validate_pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ jobs:
steps:
- name: checkout code
uses: actions/checkout@v2
with:
submodules: recursive
fetch-depth: 0

- name: Install Foundry
run: |
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ Incredible Squaring AVS
cargo test -p test-utils test_incredible_squaring_full
```

These full test starts a local Anvil testnet, deploys all the required contracts to it, and then starts an operator.
These full tests start a local Anvil testnet, deploy all the required contracts to it, and then start an operator.

### Running the Testnets as binaries

Expand Down
34 changes: 0 additions & 34 deletions avs/incredible-squaring-avs/.github/workflows/test.yml

This file was deleted.

7 changes: 6 additions & 1 deletion avs/incredible-squaring-avs/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@ use std::process::Command;

fn main() {
// List of directories containing Solidity contracts
let contract_dirs = vec!["./contracts"];
let contract_dirs: Vec<&str> = vec![
"./../contracts/lib/eigenlayer-middleware/lib/eigenlayer-contracts",
"./../contracts/lib/eigenlayer-middleware",
"./../contracts",
"./contracts",
];

// Get the project root directory
let root = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap());
Expand Down
32 changes: 22 additions & 10 deletions avs/incredible-squaring-avs/src/operator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use crate::rpc_client::AggregatorRpcClient;
use alloy_contract::private::Ethereum;
use alloy_primitives::{Address, Bytes, ChainId, FixedBytes, Signature, B256, U256};
use alloy_provider::{Provider, RootProvider};
use alloy_pubsub::Subscription;
use alloy_rpc_types::Log;
use alloy_signer_local::PrivateKeySigner;
use alloy_sol_types::SolValue;
Expand Down Expand Up @@ -85,8 +86,8 @@ pub struct Operator<T: Config, I: OperatorInfoServiceTrait> {
operator_id: FixedBytes<32>,
operator_addr: Address,
aggregator_server_ip_port_addr: String,
aggregator_server: Aggregator<T, I>,
aggregator_rpc_client: AggregatorRpcClient,
pub aggregator_server: Aggregator<T, I>,
pub aggregator_rpc_client: AggregatorRpcClient,
}

#[derive(Clone)]
Expand Down Expand Up @@ -156,6 +157,7 @@ pub struct NodeConfig {
pub server_ip_port_address: String,
pub operator_address: String,
pub enable_metrics: bool,
pub metadata_url: String,
}

impl Config for NodeConfig {
Expand Down Expand Up @@ -283,7 +285,7 @@ impl<T: Config, I: OperatorInfoServiceTrait> Operator<T, I> {
earnings_receiver_address: operator_address,
delegation_approver_address: Address::from([0u8; 20]),
staker_opt_out_window_blocks: 50400u32, // About 7 days in blocks on Ethereum
metadata_url: "https://github.com/webb-tools/eigensdk-rs/blob/donovan/eigen/test-utils/metadata.json".to_string(),
metadata_url: config.metadata_url.clone(),
};
let eigenlayer_register_result = eigenlayer_contract_manager
.register_as_operator(register_operator)
Expand Down Expand Up @@ -360,11 +362,7 @@ impl<T: Config, I: OperatorInfoServiceTrait> Operator<T, I> {
return Err(OperatorError::NodeApiError(e.to_string()));
}
}
let mut sub = self
.incredible_squaring_contract_manager
.subscribe_to_new_tasks()
.await
.unwrap();
let mut sub = self.subscribe_to_new_tasks().await?;

let server = self.aggregator_server.clone();
let aggregator_server = async move {
Expand Down Expand Up @@ -402,7 +400,7 @@ impl<T: Config, I: OperatorInfoServiceTrait> Operator<T, I> {
self.config.clone()
}

fn process_new_task_created_log(
pub fn process_new_task_created_log(
&self,
new_task_created_log: &Log<IncredibleSquaringTaskManager::NewTaskCreated>,
) -> IncredibleSquaringTaskManager::TaskResponse {
Expand All @@ -425,7 +423,7 @@ impl<T: Config, I: OperatorInfoServiceTrait> Operator<T, I> {
}
}

fn sign_task_response(
pub fn sign_task_response(
&self,
task_response: &IncredibleSquaringTaskManager::TaskResponse,
) -> Result<SignedTaskResponse, OperatorError> {
Expand All @@ -439,4 +437,18 @@ impl<T: Config, I: OperatorInfoServiceTrait> Operator<T, I> {
log::debug!("Signed task response: {:?}", signed_task_response);
Ok(signed_task_response)
}

pub async fn subscribe_to_new_tasks(&self) -> Result<Subscription<Log>, AvsError> {
self.incredible_squaring_contract_manager
.subscribe_to_new_tasks()
.await
}

pub async fn start_aggregator_server(&self) -> Result<(), AvsError> {
self.aggregator_server
.clone()
.start_server()
.await
.map_err(|e| AvsError::OperatorError(e.to_string()))
}
}
7 changes: 6 additions & 1 deletion avs/tangle-avs/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@ use std::process::Command;

fn main() {
// List of directories containing Solidity contracts
let contract_dirs = vec!["./contracts"];
let contract_dirs: Vec<&str> = vec![
"./../contracts/lib/eigenlayer-middleware/lib/eigenlayer-contracts",
"./../contracts/lib/eigenlayer-middleware",
"./../contracts",
"./contracts",
];

// Get the project root directory
let root = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap());
Expand Down
3 changes: 2 additions & 1 deletion avs/tangle-avs/src/operator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ pub struct NodeConfig {
pub operator_address: String,
pub enable_metrics: bool,
pub enable_node_api: bool,
pub metadata_url: String,
}

#[derive(Clone)]
Expand Down Expand Up @@ -241,7 +242,7 @@ impl<T: Config> Operator<T> {
earnings_receiver_address: operator_addr,
delegation_approver_address: Address::from([0u8; 20]),
staker_opt_out_window_blocks: 50400u32, // About 7 days in blocks on Ethereum
metadata_url: "https://github.com/webb-tools/eigensdk-rs/blob/donovan/eigen/test-utils/metadata.json".to_string(),
metadata_url: config.metadata_url.clone(),
};
let eigenlayer_register_result = eigenlayer_contract_manager
.register_as_operator(register_operator)
Expand Down
Loading

0 comments on commit 5db6f88

Please sign in to comment.