From d4fdf5effd3ecf36e54045654f4f39ee304d9422 Mon Sep 17 00:00:00 2001 From: supernovahs Date: Mon, 6 Jan 2025 21:51:03 +0530 Subject: [PATCH] operator2 slash simulate response --- bin/incredible-squaring-avs/src/commands/avs/mod.rs | 3 ++- contracts/script/IncredibleSquaringDeployer.s.sol | 1 - crates/config/src/lib.rs | 10 ++++++++++ crates/operator_2/src/builder.rs | 11 ++++++++++- 4 files changed, 22 insertions(+), 3 deletions(-) diff --git a/bin/incredible-squaring-avs/src/commands/avs/mod.rs b/bin/incredible-squaring-avs/src/commands/avs/mod.rs index feae5f9..ff42441 100644 --- a/bin/incredible-squaring-avs/src/commands/avs/mod.rs +++ b/bin/incredible-squaring-avs/src/commands/avs/mod.rs @@ -412,6 +412,7 @@ impl AvsCommand { operator_2_token_amount, allocation_delay, metadata_uri, + slash_simulate, .. } = *self; if let Some(config_path) = config_path { @@ -419,7 +420,7 @@ impl AvsCommand { } else { config.set_node_api_port_address(node_api_address); config.set_metrics_port_address(metrics_address); - + config.set_slash_simulate(slash_simulate); // there's a default value ,so using unwrap is no issue config.set_task_manager_signer(task_manager_signer); config.set_signer(signer); // there's a default value ,so using unwrap is no issue diff --git a/contracts/script/IncredibleSquaringDeployer.s.sol b/contracts/script/IncredibleSquaringDeployer.s.sol index 76830b0..fb0e39c 100644 --- a/contracts/script/IncredibleSquaringDeployer.s.sol +++ b/contracts/script/IncredibleSquaringDeployer.s.sol @@ -37,7 +37,6 @@ import {UpgradeableProxyLib} from "./utils/UpgradeableProxyLib.sol"; import {FundOperator} from "./utils/FundOperator.sol"; // # To deploy and verify our contract // forge script script/IncredibleSquaringDeployer.s.sol:IncredibleSquaringDeployer --rpc-url $RPC_URL --private-key $PRIVATE_KEY --broadcast -vvvv - contract IncredibleSquaringDeployer is Script { // DEPLOYMENT CONSTANTS uint256 public constant QUORUM_THRESHOLD_PERCENTAGE = 100; diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index ad838df..6ba363d 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -121,6 +121,8 @@ pub struct OperatorConfig { pub operator_2_token_amount: String, pub allocation_delay: String, + + pub slash_simulate: bool, } #[derive(Debug, Default, Serialize, Deserialize, PartialEq, Eq, Clone)] @@ -354,6 +356,14 @@ impl IncredibleConfig { self.operator_config.allocation_delay = delay; } + pub fn set_slash_simulate(&mut self, slash: bool) { + self.operator_config.slash_simulate = slash; + } + + pub fn slash_simulate(&self) -> bool { + self.operator_config.slash_simulate + } + pub fn allocation_delay(&mut self) -> Result { u32::from_str(&self.operator_config.allocation_delay).map_err(ConfigError::ParseIntError) } diff --git a/crates/operator_2/src/builder.rs b/crates/operator_2/src/builder.rs index 7cdd958..491297a 100644 --- a/crates/operator_2/src/builder.rs +++ b/crates/operator_2/src/builder.rs @@ -45,6 +45,8 @@ pub struct OperatorBuilder { registry_coordinator: Address, operator_state_retriever: Address, + + slash_simulate: bool, } impl OperatorBuilder { @@ -65,6 +67,7 @@ impl OperatorBuilder { let registry_coordinator_addr = config.registry_coordinator_addr()?; let operator_statr_retriever_addr = config.operator_state_retriever_addr()?; let operator_address = config.operator_2_address()?; + let slash = config.slash_simulate(); Ok(Self { http_rpc_url: config.http_rpc_url(), ws_rpc_url: config.ws_rpc_url(), @@ -74,6 +77,7 @@ impl OperatorBuilder { client, registry_coordinator: registry_coordinator_addr, operator_state_retriever: operator_statr_retriever_addr, + slash_simulate: slash, }) } @@ -94,7 +98,12 @@ impl OperatorBuilder { info!("Challenger test: setting number to be squared to 9"); } - let num_squared = number_to_be_squared * number_to_be_squared; + let num_squared; + if self.slash_simulate { + num_squared = U256::from(24); // not a perfect square, so it can't be correct in any input + } else { + num_squared = number_to_be_squared * number_to_be_squared; + } TaskResponse { referenceTaskIndex: new_task_created.taskIndex,