Skip to content

Commit

Permalink
fix:edge case in processing signature in aggregator
Browse files Browse the repository at this point in the history
  • Loading branch information
supernovahs committed Jan 8, 2025
1 parent 8c7d8c9 commit 9bad666
Show file tree
Hide file tree
Showing 9 changed files with 216 additions and 648 deletions.
742 changes: 167 additions & 575 deletions Cargo.lock

Large diffs are not rendered by default.

34 changes: 17 additions & 17 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -73,22 +73,22 @@ incredible-operator-2 = {path = "crates/operator_2/" , features = ["default"]}
incredible-slasher = {path = "crates/slasher/"}
# eigensdk-rs

eigen-client-avsregistry = { git = "https://github.com/Layr-Labs/eigensdk-rs", rev = "0986564"}
eigen-testing-utils ={ git = "https://github.com/Layr-Labs/eigensdk-rs", rev = "0986564"}
eigen-crypto-bls = { git = "https://github.com/Layr-Labs/eigensdk-rs", rev = "0986564"}
eigen-types = { git = "https://github.com/Layr-Labs/eigensdk-rs", rev = "0986564"}
eigen-metrics = { git = "https://github.com/Layr-Labs/eigensdk-rs", rev = "0986564"}
eigen-utils = { git = "https://github.com/Layr-Labs/eigensdk-rs", rev = "0986564"}
eigen-contract-bindings = { git = "https://github.com/Layr-Labs/eigensdk-rs", rev = "0986564"}
eigen-cli ={ git = "https://github.com/Layr-Labs/eigensdk-rs", rev = "0986564"}
eigen-logging ={ git = "https://github.com/Layr-Labs/eigensdk-rs", rev = "0986564"}
eigen-crypto-bn254 = { git = "https://github.com/Layr-Labs/eigensdk-rs", rev = "0986564"}
eigen-client-elcontracts = { git = "https://github.com/Layr-Labs/eigensdk-rs", rev = "0986564"}
eigen-services-operatorsinfo = { git = "https://github.com/Layr-Labs/eigensdk-rs", rev = "0986564"}
eigen-services-avsregistry = { git = "https://github.com/Layr-Labs/eigensdk-rs", rev = "0986564"}
eigen-services-blsaggregation = { git = "https://github.com/Layr-Labs/eigensdk-rs", rev = "0986564"}
eigen-metrics-collectors-rpc-calls = { git = "https://github.com/Layr-Labs/eigensdk-rs", rev = "0986564"}
eigen-client-eth = { git = "https://github.com/Layr-Labs/eigensdk-rs", rev = "0986564"}
eigen-nodeapi = { git = "https://github.com/Layr-Labs/eigensdk-rs", rev = "0986564"}
eigen-client-avsregistry = { git = "https://github.com/Layr-Labs/eigensdk-rs", rev = "8bc7d45"}
eigen-testing-utils ={ git = "https://github.com/Layr-Labs/eigensdk-rs", rev = "8bc7d45"}
eigen-crypto-bls = { git = "https://github.com/Layr-Labs/eigensdk-rs", rev = "8bc7d45"}
eigen-types = { git = "https://github.com/Layr-Labs/eigensdk-rs", rev = "8bc7d45"}
eigen-metrics = { git = "https://github.com/Layr-Labs/eigensdk-rs", rev = "8bc7d45"}
eigen-utils = { git = "https://github.com/Layr-Labs/eigensdk-rs", rev = "8bc7d45"}
eigen-contract-bindings = { git = "https://github.com/Layr-Labs/eigensdk-rs", rev = "8bc7d45"}
eigen-cli ={ git = "https://github.com/Layr-Labs/eigensdk-rs", rev = "8bc7d45"}
eigen-logging ={ git = "https://github.com/Layr-Labs/eigensdk-rs", rev = "8bc7d45"}
eigen-crypto-bn254 = { git = "https://github.com/Layr-Labs/eigensdk-rs", rev = "8bc7d45"}
eigen-client-elcontracts = { git = "https://github.com/Layr-Labs/eigensdk-rs", rev = "8bc7d45"}
eigen-services-operatorsinfo = { git = "https://github.com/Layr-Labs/eigensdk-rs", rev = "8bc7d45"}
eigen-services-avsregistry = { git = "https://github.com/Layr-Labs/eigensdk-rs", rev = "8bc7d45"}
eigen-services-blsaggregation = { git = "https://github.com/Layr-Labs/eigensdk-rs", rev = "8bc7d45"}
eigen-metrics-collectors-rpc-calls = { git = "https://github.com/Layr-Labs/eigensdk-rs", rev = "8bc7d45"}
eigen-client-eth = { git = "https://github.com/Layr-Labs/eigensdk-rs", rev = "8bc7d45"}
eigen-nodeapi = { git = "https://github.com/Layr-Labs/eigensdk-rs", rev = "8bc7d45"}


6 changes: 1 addition & 5 deletions bin/incredible-squaring-avs/src/commands/avs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ use eigen_utils::allocationmanager::IAllocationManagerTypes::{AllocateParams, Re
use eigen_utils::registrycoordinator::RegistryCoordinator;
use eigen_utils::{get_provider, get_signer};
use incredible_avs::builder::{AvsBuilder, DefaultAvsLauncher, LaunchAvs};
use incredible_bindings::incrediblesquaringtaskmanager::IncredibleSquaringTaskManager;
use incredible_config::IncredibleConfig;
use incredible_testing_utils::{
get_incredible_squaring_operator_state_retriever, get_incredible_squaring_registry_coordinator,
Expand Down Expand Up @@ -670,10 +669,6 @@ impl<Ext: clap::Args + fmt::Debug + Send + Sync + 'static> AvsCommand<Ext> {
mine_anvil_block(&rpc_url, current_block_number);
}

let task_manager = IncredibleSquaringTaskManager::new(
incredible_squaring_task_manager_address_anvil,
get_provider(ANVIL_HTTP_URL),
);
let avs_launcher = DefaultAvsLauncher::new();
let avs_builder = AvsBuilder::new(config);
let _ = avs_launcher.launch_avs(avs_builder).await;
Expand Down Expand Up @@ -713,6 +708,7 @@ pub async fn register_operator_with_el_and_deposit_tokens_in_strategy(
get_logger(),
allocation_manager,
delegation_manager_address,
rewards_coordinator,
avs_directory_address,
permission_controller_address,
rpc_url.clone(),
Expand Down
2 changes: 1 addition & 1 deletion contracts/script/deployments/core/31337.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"lastUpdate":{"timestamp":"1736266784","block_number":"1"},"addresses":{"proxyAdmin":"0xe7f1725e7734ce288f8367e1bb143e90bb3f0512","delegation":"0xcf7ed3acca5a467e9e704c703e8d87f634fb0fc9","delegationManagerImpl":"0x322813fd9a801c5507c9de605d63cea4f2ce6c44","avsDirectory":"0xb7f8bc63bbcad18155201308c8f3540b07f84f5e","avsDirectoryImpl":"0x4a679253410272dd5232b3ff7cf5dbb88f295319","strategyManager":"0xa513e6e4b8f2a923d98304ec87f64353c4d5c853","strategyManagerImpl":"0x7a2088a1bfc9d81c55368ae168c2c02570cb814f","eigenPodManager":"0xc6e7df5e7b4f2a278906862b61205850344d4e7d","eigenPodManagerImpl":"0x67d269191c92caf3cd7723f116c85e6e9bf55933","strategyFactory":"0x68b1d87f95878fe05b998f19b66f4baba5de1aed","rewardsCoordinator":"0x0dcd1bf9a1b36ce34237eeafef220932846bcd82","pauserRegistry":"0x959922be3caee4b8cd9a407cc3ac1c251c2007b1","strategyBeacon":"0xa82ff9afd8f496c3d6ac40e2a0f282e47488cfc9","allocationManager":"0x8a791620dd6260079bf849dc5567adc3f2fdc318","permissionController":"0x4ed7c70f96b99c776995fb64377f0d4ab3b0e1c1"}}
{"lastUpdate":{"timestamp":"1736327206","block_number":"1"},"addresses":{"proxyAdmin":"0xe7f1725e7734ce288f8367e1bb143e90bb3f0512","delegation":"0xcf7ed3acca5a467e9e704c703e8d87f634fb0fc9","delegationManagerImpl":"0x322813fd9a801c5507c9de605d63cea4f2ce6c44","avsDirectory":"0xb7f8bc63bbcad18155201308c8f3540b07f84f5e","avsDirectoryImpl":"0x4a679253410272dd5232b3ff7cf5dbb88f295319","strategyManager":"0xa513e6e4b8f2a923d98304ec87f64353c4d5c853","strategyManagerImpl":"0x7a2088a1bfc9d81c55368ae168c2c02570cb814f","eigenPodManager":"0xc6e7df5e7b4f2a278906862b61205850344d4e7d","eigenPodManagerImpl":"0x67d269191c92caf3cd7723f116c85e6e9bf55933","strategyFactory":"0x68b1d87f95878fe05b998f19b66f4baba5de1aed","rewardsCoordinator":"0x0dcd1bf9a1b36ce34237eeafef220932846bcd82","pauserRegistry":"0x959922be3caee4b8cd9a407cc3ac1c251c2007b1","strategyBeacon":"0xa82ff9afd8f496c3d6ac40e2a0f282e47488cfc9","allocationManager":"0x8a791620dd6260079bf849dc5567adc3f2fdc318","permissionController":"0x4ed7c70f96b99c776995fb64377f0d4ab3b0e1c1"}}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"lastUpdate":{"timestamp":"1736266785","block_number":"44"},"addresses":{"proxyAdmin":"0x1291be112d480055dafd8a610b7d1e203891c274","IncredibleSquaringServiceManager":"0xb7278a61aa25c888815afc32ad3cc52ff24fe575","incredibleSquaringServiceManagerImpl":"0x202cce504e04bed6fc0521238ddf04bc9e8e15ab","IncredibleSquaringTaskManager":"0x7969c5ed335650692bc04293b07f5bf2e7a673c0","registryCoordinator":"0xc351628eb244ec633d5f21fbd6621e1a683b1181","blsapkRegistry":"0xcbeaf3bde82155f56486fb5a1072cb8baaf547cc","indexRegistry":"0xb0d4afd8879ed9f52b28595d31b441d079b2ca07","stakeRegistry":"0x82e01223d51eb87e16a03e24687edf0f294da6f1","operatorStateRetriever":"0xdbc43ba45381e02825b14322cddd15ec4b3164e6","strategy":"0x5e3d0fde6f793b3115a9e7f5ebc195bbeed35d6c","pauserRegistry":"0x0000000000000000000000000000000000000000","token":"0x0000000000000000000000000000000000000000","instantSlasher":"0x1fa02b2d6a771842690194cf62d91bdd92bfe28d"}}
{"lastUpdate":{"timestamp":"1736327207","block_number":"44"},"addresses":{"proxyAdmin":"0x1291be112d480055dafd8a610b7d1e203891c274","IncredibleSquaringServiceManager":"0xb7278a61aa25c888815afc32ad3cc52ff24fe575","incredibleSquaringServiceManagerImpl":"0x202cce504e04bed6fc0521238ddf04bc9e8e15ab","IncredibleSquaringTaskManager":"0x7969c5ed335650692bc04293b07f5bf2e7a673c0","registryCoordinator":"0xc351628eb244ec633d5f21fbd6621e1a683b1181","blsapkRegistry":"0xcbeaf3bde82155f56486fb5a1072cb8baaf547cc","indexRegistry":"0xb0d4afd8879ed9f52b28595d31b441d079b2ca07","stakeRegistry":"0x82e01223d51eb87e16a03e24687edf0f294da6f1","operatorStateRetriever":"0xdbc43ba45381e02825b14322cddd15ec4b3164e6","strategy":"0x5e3d0fde6f793b3115a9e7f5ebc195bbeed35d6c","pauserRegistry":"0x0000000000000000000000000000000000000000","token":"0x0000000000000000000000000000000000000000","instantSlasher":"0x1fa02b2d6a771842690194cf62d91bdd92bfe28d"}}
36 changes: 27 additions & 9 deletions crates/aggregator/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ use jsonrpc_core::serde_json;
use jsonrpc_core::{Error, IoHandler, Params, Value};
use jsonrpc_http_server::{AccessControlAllowOrigin, DomainsValidation, ServerBuilder};
pub use rpc_server::SignedTaskResponse;
use serde::ser;
use std::collections::HashMap;
use std::net::SocketAddr;
use std::sync::Arc;
Expand Down Expand Up @@ -318,8 +317,9 @@ impl Aggregator {
self.tasks_responses.insert(task_index, inner_map);
}

let entry = self.task_quorum.entry(task_index).or_insert(U96::from(0));
let old_entry = entry.clone();
let quorum_reached = {
let entry = self.task_quorum.entry(task_index).or_insert(U96::from(0));
let registry_coordinator_instance = RegistryCoordinator::new(
registry_coordinator,
get_provider(&self.avs_writer.rpc_url),
Expand Down Expand Up @@ -351,7 +351,7 @@ impl Aggregator {
}
}
}
if *entry < U96::from(4000) {
if old_entry.is_zero() {
self.bls_aggregation_service
.process_new_signature(
task_index,
Expand All @@ -360,11 +360,22 @@ impl Aggregator {
signed_task_response.operator_id(),
)
.await?;
} else {
if old_entry < U96::from(4800) {
self.bls_aggregation_service
.process_new_signature(
task_index,
task_response_digest,
signed_task_response.signature(),
signed_task_response.operator_id(),
)
.await?;
}
}
*entry >= U96::from(4000) //todo change this
*entry >= U96::from(4800) // total stake is 12000. quorum threshold percentag in new task is 40% . hence 4800.
};

if quorum_reached {
if quorum_reached && (old_entry < U96::from(4800)) {
info!("quorum reached for task index: {:?}", task_index);
if let Some(aggregated_response) = self
.bls_aggregation_service
Expand All @@ -380,10 +391,17 @@ impl Aggregator {
.await?;
}
} else {
info!(
"quorum not reached yet for index:{:?}. waiting to receive more signatures ",
task_index
);
if old_entry >= U96::from(4800) {
info!(
"quorum already reached for index{:?}, ignoring more signatures",
task_index
);
} else {
info!(
"quorum not reached yet for index:{:?}. waiting to receive more signatures ",
task_index
);
}
}

Ok(())
Expand Down
1 change: 0 additions & 1 deletion crates/chainio/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,6 @@ impl AvsWriter {
) -> Result<(), ChainIoError> {
let pr = get_signer(&self.signer, &self.rpc_url);
let task_manager_contract = IncredibleSquaringTaskManager::new(self.task_manager_addr, pr);
info!("befofe responding to task");
let receipt = task_manager_contract
.respondToTask(task, task_response, non_signer_stakes_and_signature)
.send()
Expand Down
39 changes: 1 addition & 38 deletions crates/challenger/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,11 @@ impl Challenger {

let mut task_responded_stream = task_responded_sub.into_stream();

let task_responded_log = TaskResponded::SIGNATURE_HASH;

loop {
tokio::select! {
Some(log) = task_responded_stream.next() => {
info!("challenger: Picked a task response");
let task_index = self.process_task_response_log(log).await?;
if self.tasks.contains_key(&task_index) {
info!("calling challenge");
self.call_challenge(task_index).await?;
}
},
Expand All @@ -113,11 +109,8 @@ impl Challenger {
task: m.task.clone(),
};

let t_index = self.process_new_task_created_log(new_task_cr);
let _ = self.process_new_task_created_log(new_task_cr);

// if self.task_responses.contains_key(&t_index) {
// self.call_challenge(t_index).await?;
// }
}
},
else => {
Expand All @@ -126,36 +119,6 @@ impl Challenger {
break;
}
};

// let topic = log.topic0();

// if let Some(tp) = topic {
// if *tp == new_task_created_log {
// info!("challenger: picked up a new task ");
// let new_task_created_option = log.log_decode::<NewTaskCreated>().ok();

// if let Some(data) = new_task_created_option {
// let m = data.data();
// let new_task_cr = NewTaskCreated {
// taskIndex: m.taskIndex,
// task: m.task.clone(),
// };

// let t_index = self.process_new_task_created_log(new_task_cr);

// if self.task_responses.contains_key(&t_index) {
// self.call_challenge(t_index).await?;
// }
// }
// } else if *tp == task_responded_log {
// info!("challenger: received a task response log");

// let task_index = self.process_task_response_log(log).await?;
// if self.tasks.contains_key(&task_index) {
// self.call_challenge(task_index).await?;
// }
// }
// }
}

Ok(())
Expand Down
2 changes: 1 addition & 1 deletion crates/task_generator/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ impl TaskManager {

loop {
let number_to_be_squared = task_num;
let quorum_threshold_percentage = 10;
let quorum_threshold_percentage = 40;
let quorum_numbers = Bytes::from_str("0x01")?;

let _ = task_manager_contract
Expand Down

0 comments on commit 9bad666

Please sign in to comment.