Skip to content

Commit

Permalink
BLS Pairing Debugging and Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Tjemmmic committed Aug 20, 2024
1 parent 165c457 commit 9fd1a64
Show file tree
Hide file tree
Showing 6 changed files with 267 additions and 60 deletions.
15 changes: 13 additions & 2 deletions avs/incredible-squaring-avs/src/operator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,14 @@ impl<T: Config, I: OperatorInfoServiceTrait> Operator<T, I> {
.await
.unwrap();

let quorum_nums = Bytes::from(vec![0]);
let quorum_nums = Bytes::from([0x00]);
let bls_keypair = KeyPair::new(
eigen_utils::crypto::bls::PrivateKey::from_str(
"12248929636257230549931416853095037629726205319386239410403476017439825112537",
)
.unwrap(),
)
.unwrap();
let register_result = avs_registry_contract_manager
.register_operator(
&ecdsa_signing_key,
Expand Down Expand Up @@ -358,7 +365,7 @@ impl<T: Config, I: OperatorInfoServiceTrait> Operator<T, I> {
log::info!("Received new task: {:?}", value);

loop {
log::info!("About to wait for a new task submissions");
log::info!("Waiting for new task submissions");
tokio::select! {
Ok(new_task_created_log) = sub.recv() => {
log::info!("Received new task: {:?}", new_task_created_log);
Expand All @@ -376,6 +383,10 @@ impl<T: Config, I: OperatorInfoServiceTrait> Operator<T, I> {
}
}

pub fn config(&self) -> NodeConfig {
self.config.clone()
}

fn process_new_task_created_log(
&self,
new_task_created_log: &Log<IncredibleSquaringTaskManager::NewTaskCreated>,
Expand Down
74 changes: 41 additions & 33 deletions test-utils/src/anvil/testnet/incredible_squaring.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ pub async fn run_incredible_squaring_testnet() -> ContractAddresses {
let from = accounts[0].address();

let dev_account = accounts[0].address();
let task_account = address!("a0Ee7A142d267C1f36714E4a8F75612F20a79720"); // This is the last Dev Account `accounts[9]`

// Deploy initial contracts that don't depend on others

Expand Down Expand Up @@ -94,11 +95,17 @@ pub async fn run_incredible_squaring_testnet() -> ContractAddresses {

// Function with signature initialize(uint256,uint256,address,address) and selector 0x019e2729.
let function_signature = "initialize(uint256,uint256,address,address)";
let mut hasher = Keccak256::new();
hasher.update(function_signature);
let function_selector = &hasher.finalize()[..4];
// let mut hasher = Keccak256::new();
// hasher.update(function_signature);
// let function_selector = &hasher.finalize()[..4];

let encoded_data = encode_params!(function_selector, 1, 100, ierc20_addr, pauser_registry_addr);
let encoded_data = encode_params!(
function_signature,
1,
100,
ierc20_addr,
pauser_registry_addr
);

let strategy_proxy = TransparentUpgradeableProxy::deploy(
provider.clone(),
Expand Down Expand Up @@ -506,35 +513,36 @@ pub async fn run_incredible_squaring_testnet() -> ContractAddresses {
);
log::info!("DELEGATION MANAGER ADDRESS: {:?}", delegation_manager_addr);

// let spawner_task_manager_address = task_manager_addr.clone();
// // let spawner_provider = provider.clone();
// let spawner_provider = provider;
// let task_spawner = async move {
// let manager = IncredibleSquaringTaskManager::new(
// spawner_task_manager_address,
// spawner_provider.clone(),
// );
// loop {
// api.mine_one().await;
// log::info!("About to create new task");
// tokio::time::sleep(std::time::Duration::from_millis(5000)).await;
// let result = manager
// .createNewTask(U256::from(2), 100u32, Bytes::from("0"))
// .send()
// .await
// .unwrap()
// .watch()
// .await
// .unwrap();
// api.mine_one().await;
// log::info!("Created new task: {:?}", result);
// // let latest_task = manager.latestTaskNum().call().await.unwrap()._0;
// // log::info!("Latest task: {:?}", latest_task);
// // let task_hash = manager.allTaskHashes(latest_task).call().await.unwrap()._0;
// // log::info!("Task info: {:?}", task_hash);
// }
// };
// tokio::spawn(task_spawner);
let spawner_task_manager_address = incredible_squaring_task_manager_addr.clone();
// let spawner_provider = provider.clone();
let spawner_provider = provider.clone();
let task_spawner = async move {
let manager = IncredibleSquaringTaskManager::new(
spawner_task_manager_address,
spawner_provider.clone(),
);
loop {
api.mine_one().await;
log::info!("About to create new task");
tokio::time::sleep(std::time::Duration::from_millis(5000)).await;
let result = manager
.createNewTask(U256::from(2), 100u32, Bytes::from(vec![0]))
.from(task_account)
.send()
.await
.unwrap()
.watch()
.await
.unwrap();
api.mine_one().await;
log::info!("Created new task: {:?}", result);
// let latest_task = manager.latestTaskNum().call().await.unwrap()._0;
// log::info!("Latest task: {:?}", latest_task);
// let task_hash = manager.allTaskHashes(latest_task).call().await.unwrap()._0;
// log::info!("Task info: {:?}", task_hash);
}
};
tokio::spawn(task_spawner);

ContractAddresses {
service_manager: incredible_squaring_service_manager_addr,
Expand Down
5 changes: 4 additions & 1 deletion test-utils/src/bin/incredible_squaring.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ use alloy_provider::Provider;
use alloy_provider::ProviderBuilder;
use alloy_signer_local::PrivateKeySigner;
use alloy_transport_ws::WsConnect;
use ethers::prelude::contract;
use incredible_squaring_avs::aggregator::Aggregator;
use incredible_squaring_avs::avs::SetupConfig;
use incredible_squaring_avs::operator::*;
use k256::ecdsa::SigningKey;
use k256::elliptic_curve::SecretKey;
Expand Down Expand Up @@ -35,7 +38,7 @@ async fn operator_setup(
operator_address: contract_addresses.operator.to_string(),
enable_metrics: false,
enable_node_api: false,
server_ip_port_address: "".to_string(),
server_ip_port_address: "127.0.0.1:8673".to_string(),
};

let operator_info_service = OperatorInfoService {};
Expand Down
2 changes: 2 additions & 0 deletions utils/src/avs_registry/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ impl<T: Config> AvsRegistryChainWriterTrait for AvsRegistryContractManager<T> {
pubkeyG2: RegistryCoordinator::G2Point {
X: g2_pubkey_bn254.x,
Y: g2_pubkey_bn254.y,
//X: [g2_pubkey_bn254.x[1], g2_pubkey_bn254.x[0]],
//Y: [g2_pubkey_bn254.y[1], g2_pubkey_bn254.y[0]],
},
};

Expand Down
Loading

0 comments on commit 9fd1a64

Please sign in to comment.