Skip to content

Commit

Permalink
added strategy whitelister
Browse files Browse the repository at this point in the history
  • Loading branch information
Sidu28 committed Nov 6, 2024
1 parent ad8670d commit 1e9ea3f
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 30 deletions.
31 changes: 23 additions & 8 deletions contracts/script/IncredibleSquaringDeployer.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import "forge-std/console.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, Utils {
contract IncredibleSquaringDeployer is Script, Utils, Test {
// DEPLOYMENT CONSTANTS
uint256 public constant QUORUM_THRESHOLD_PERCENTAGE = 100;
uint32 public constant TASK_RESPONSE_WINDOW_BLOCK = 30;
Expand Down Expand Up @@ -77,6 +77,8 @@ contract IncredibleSquaringDeployer is Script, Utils {
IncredibleSquaringTaskManager public incredibleSquaringTaskManager;
IIncredibleSquaringTaskManager public incredibleSquaringTaskManagerImplementation;

address public operationsMultisig;

function run() external {
// Eigenlayer contracts
string memory eigenlayerDeployedContracts = readOutput("eigenlayer_deployment_output");
Expand Down Expand Up @@ -104,13 +106,27 @@ contract IncredibleSquaringDeployer is Script, Utils {
stdJson.readAddress(eigenlayerDeployedContracts, ".addresses.rewardsCoordinator")
);

operationsMultisig = stdJson.readAddress(eigenlayerDeployedContracts, ".parameters.operationsMultisig");

address incredibleSquaringCommunityMultisig = msg.sender;
address incredibleSquaringPauser = msg.sender;

vm.startBroadcast();
_deployErc20AndStrategyAndWhitelistStrategy(
StrategyBaseTVLLimits erc20MockStrategy = _deployErc20AndStrategyAndWhitelistStrategy(
eigenLayerProxyAdmin, eigenLayerPauserReg, baseStrategyImplementation, strategyManager
);
vm.stopBroadcast();

vm.startBroadcast(vm.envUint(("OPERATIONS_MULTISIG_PK")));
IStrategy[] memory strats = new IStrategy[](1);
strats[0] = erc20MockStrategy;
bool[] memory thirdPartyTransfersForbiddenValues = new bool[](1);
thirdPartyTransfersForbiddenValues[0] = false;
strategyManager.addStrategiesToDepositWhitelist(strats, thirdPartyTransfersForbiddenValues);
vm.stopBroadcast();


vm.startBroadcast();
_deployIncredibleSquaringContracts(
delegationManager,
avsDirectory,
Expand All @@ -127,10 +143,12 @@ contract IncredibleSquaringDeployer is Script, Utils {
PauserRegistry eigenLayerPauserReg,
StrategyBaseTVLLimits baseStrategyImplementation,
IStrategyManager strategyManager
) internal {
) internal returns (StrategyBaseTVLLimits) {
erc20Mock = new ERC20Mock();
// TODO(samlaf): any reason why we are using the strategybase with tvl limits instead of just using strategybase?
// the maxPerDeposit and maxDeposits below are just arbitrary values.
emit log_named_address("baseStrategyImplementation", address(baseStrategyImplementation));
emit log_named_bytes("baseStrategyImplementation code", address(baseStrategyImplementation).code);
erc20MockStrategy = StrategyBaseTVLLimits(
address(
new TransparentUpgradeableProxy(
Expand All @@ -146,11 +164,8 @@ contract IncredibleSquaringDeployer is Script, Utils {
)
)
);
IStrategy[] memory strats = new IStrategy[](1);
strats[0] = erc20MockStrategy;
bool[] memory thirdPartyTransfersForbiddenValues = new bool[](1);
thirdPartyTransfersForbiddenValues[0] = false;
strategyManager.addStrategiesToDepositWhitelist(strats, thirdPartyTransfersForbiddenValues);

return erc20MockStrategy;
}

function _deployIncredibleSquaringContracts(
Expand Down
19 changes: 9 additions & 10 deletions contracts/src/IncredibleSquaringTaskManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ contract IncredibleSquaringTaskManager is

// check the BLS signature
(QuorumStakeTotals memory quorumStakeTotals, bytes32 hashOfNonSigners) =
checkSignatures(message, quorumNumbers, taskCreatedBlock, nonSignerStakesAndSignature);
checkSignatures(keccak256(abi.encode(taskResponse)), quorumNumbers, taskCreatedBlock, nonSignerStakesAndSignature);

// check that signatories own at least a threshold percentage of each quorum
for (uint256 i = 0; i < quorumNumbers.length; i++) {
Expand Down Expand Up @@ -202,8 +202,7 @@ contract IncredibleSquaringTaskManager is
);

// logic for checking whether challenge is valid or not
uint256 actualSquaredOutput = numberToBeSquared * numberToBeSquared;
bool isResponseCorrect = (actualSquaredOutput == taskResponse.numberSquared);
bool isResponseCorrect = ((numberToBeSquared * numberToBeSquared) == taskResponse.numberSquared);

// if response was correct, no slashing happens so we return
if (isResponseCorrect == true) {
Expand All @@ -230,18 +229,18 @@ contract IncredibleSquaringTaskManager is
"The pubkeys of non-signing operators supplied by the challenger are not correct."
);

// get the address of operators who didn't sign
address[] memory addressesOfNonSigningOperators =
new address[](pubkeysOfNonSigningOperators.length);
for (uint256 i = 0; i < pubkeysOfNonSigningOperators.length; i++) {
addressesOfNonSigningOperators[i] = BLSApkRegistry(address(blsApkRegistry))
.pubkeyHashToOperator(hashesOfPubkeysOfNonSigningOperators[i]);
}

// @dev the below code is commented out for the upcoming M2 release
// in which there will be no slashing. The slasher is also being redesigned
// so its interface may very well change.
// ==========================================
// get the address of operators who didn't sign
// address[] memory addressesOfNonSigningOperators =
// new address[](pubkeysOfNonSigningOperators.length);
// for (uint256 i = 0; i < pubkeysOfNonSigningOperators.length; i++) {
// addressesOfNonSigningOperators[i] = BLSApkRegistry(address(blsApkRegistry))
// .pubkeyHashToOperator(hashesOfPubkeysOfNonSigningOperators[i]);
// }
// // get the list of all operators who were active when the task was initialized
// Operator[][] memory allOperatorInfo = getOperatorState(
// IRegistryCoordinator(address(registryCoordinator)),
Expand Down
16 changes: 4 additions & 12 deletions tests/anvil/start-anvil-chain-with-el-and-avs-deployed.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ source ./utils.sh
set +a


deploy_eigenlayer() {
deploy_eigenlayer_and_avs() {
forge script script/deploy/devnet/M2_Deploy_From_Scratch.s.sol --rpc-url http://localhost:8545 --private-key 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 --broadcast --sig "run(string memory configFile)" -- M2_deploy_from_scratch.anvil.config.json
echo "deployment done"
mv script/output/devnet/M2_from_scratch_deployment_data.json ../../../../script/output/31337/eigenlayer_deployment_output.json
Expand All @@ -27,25 +27,17 @@ deploy_eigenlayer() {
# echo "avs deployed"
}

# deploy_avs() {

# }

start_anvil() {
anvil
sleep 2
}



cd ../../contracts/lib/eigenlayer-middleware/lib/eigenlayer-contracts
pwd
# deployment overwrites this file, so we save it as backup, because we want that output in our local files, and not in the eigenlayer-contracts submodule files
mv script/output/devnet/M2_from_scratch_deployment_data.json script/output/devnet/M2_from_scratch_deployment_data.json.bak

# private key used for operations multisig which is the strategy whitelister
export OPERATIONS_MULTISIG_PK="0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80"

start_anvil &
deploy_eigenlayer
deploy_eigenlayer_and_avs


# # we need to restart the anvil chain at the correct block, otherwise the indexRegistry has a quorumUpdate at the block number
Expand Down

0 comments on commit 1e9ea3f

Please sign in to comment.