Skip to content

Commit

Permalink
operator2 slash simulate response
Browse files Browse the repository at this point in the history
  • Loading branch information
supernovahs committed Jan 6, 2025
1 parent d0292ed commit d4fdf5e
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 deletions.
3 changes: 2 additions & 1 deletion bin/incredible-squaring-avs/src/commands/avs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -412,14 +412,15 @@ impl<Ext: clap::Args + fmt::Debug + Send + Sync + 'static> AvsCommand<Ext> {
operator_2_token_amount,
allocation_delay,
metadata_uri,
slash_simulate,
..
} = *self;
if let Some(config_path) = config_path {
config = IncredibleConfig::load(&config_path)?;
} 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
Expand Down
1 change: 0 additions & 1 deletion contracts/script/IncredibleSquaringDeployer.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
10 changes: 10 additions & 0 deletions crates/config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down Expand Up @@ -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, ConfigError> {
u32::from_str(&self.operator_config.allocation_delay).map_err(ConfigError::ParseIntError)
}
Expand Down
11 changes: 10 additions & 1 deletion crates/operator_2/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ pub struct OperatorBuilder {
registry_coordinator: Address,

operator_state_retriever: Address,

slash_simulate: bool,
}

impl OperatorBuilder {
Expand All @@ -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(),
Expand All @@ -74,6 +77,7 @@ impl OperatorBuilder {
client,
registry_coordinator: registry_coordinator_addr,
operator_state_retriever: operator_statr_retriever_addr,
slash_simulate: slash,
})
}

Expand All @@ -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,
Expand Down

0 comments on commit d4fdf5e

Please sign in to comment.