Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove State Dump #97

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ DEPLOYMENT_FILES_DIR=contracts/script/output/${CHAINID}

___CONTRACTS___: ##

anvil: ## starts anvil
anvil

build-contracts: ## builds all contracts
cd contracts && forge build

Expand All @@ -28,8 +31,8 @@ deploy-incredible-squaring-contracts-to-anvil-and-save-state: ## Deploy avs

deploy-all-to-anvil-and-save-state: deploy-eigenlayer-contracts-to-anvil-and-save-state deploy-incredible-squaring-contracts-to-anvil-and-save-state ## deploy eigenlayer, shared avs contracts, and inc-sq contracts

start-anvil-chain-with-el-and-avs-deployed: ## starts anvil from a saved state file (with el and avs contracts deployed)
./tests/anvil/start-anvil-chain-with-el-and-avs-deployed.sh
deploy-eigenlayer-and-avs: ## starts anvil from a saved state file (with el and avs contracts deployed)
./tests/anvil/deploy-eigenlayer-and-avs.sh

bindings: ## generates contract bindings
cd contracts && ./generate-go-bindings.sh
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,11 @@ make bindings
This simple session illustrates the basic flow of the AVS. The makefile commands are hardcoded for a single operator, but it's however easy to create new operator config files, and start more operators manually (see the actual commands that the makefile calls).

Start anvil in a separate terminal:

```bash
make start-anvil-chain-with-el-and-avs-deployed
make anvil
```
```bash
make deploy-eigenlayer-and-avs
```

The above command starts a local anvil chain from a [saved state](./tests/anvil/avs-and-eigenlayer-deployed-anvil-state.json) with eigenlayer and incredible-squaring contracts already deployed (but no operator registered).
Expand Down
157 changes: 146 additions & 11 deletions contracts/bindings/ERC20Mock/binding.go

Large diffs are not rendered by default.

250 changes: 229 additions & 21 deletions contracts/bindings/IncredibleSquaringServiceManager/binding.go

Large diffs are not rendered by default.

440 changes: 425 additions & 15 deletions contracts/bindings/IncredibleSquaringTaskManager/binding.go

Large diffs are not rendered by default.

33 changes: 25 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,14 @@ 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 +166,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
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"addresses": {
"credibleSquaringServiceManager": "0x84eA74d481Ee0A5332c457a4d796187F6Ba67fEB",
"credibleSquaringServiceManagerImplementation": "0x36C02dA8a0983159322a80FFE9F24b1acfF8B570",
"credibleSquaringTaskManager": "0x9E545E3C0baAB3E08CdfD552C960A1050f373042",
"credibleSquaringTaskManagerImplementation": "0x4c5859f0F772848b2D91F1D83E2Fe57935348029",
"erc20Mock": "0x7a2088a1bFc9d81c55368AE168C2C02570cB814F",
"erc20MockStrategy": "0x09635F643e140090A9A8Dcd712eD6285858ceBef",
"operatorStateRetriever": "0x95401dc811bb5740090279Ba06cfA8fcF6113778",
"registryCoordinator": "0xa82fF9aFd8f496c3d6ac40E2a0F282E47488CFc9",
"registryCoordinatorImplementation": "0x9d4454B023096f34B160D6B654540c56A1F81688"
"credibleSquaringServiceManager": "0xd6e1afe5cA8D00A2EFC01B89997abE2De47fdfAf",
"credibleSquaringServiceManagerImplementation": "0x6C2d83262fF84cBaDb3e416D527403135D757892",
"credibleSquaringTaskManager": "0x99dBE4AEa58E518C50a1c04aE9b48C9F6354612f",
"credibleSquaringTaskManagerImplementation": "0xa6e99A4ED7498b3cdDCBB61a6A607a4925Faa1B7",
"erc20Mock": "0xB82008565FdC7e44609fA118A4a681E92581e680",
"erc20MockStrategy": "0x2a810409872AfC346F9B5b26571Fd6eC42EA4849",
"operatorStateRetriever": "0x976fcd02f7C4773dd89C309fBF55D5923B4c98a1",
"registryCoordinator": "0x6F6f570F45833E249e27022648a26F4076F48f78",
"registryCoordinatorImplementation": "0x02b0B4EFd909240FCB2Eb5FAe060dC60D112E3a4"
}
}
38 changes: 19 additions & 19 deletions contracts/script/output/31337/eigenlayer_deployment_output.json
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
{
"addresses": {
"avsDirectory": "0x5FC8d32690cc91D4c39d9d3abcBD16989F875707",
"avsDirectoryImplementation": "0x0DCd1Bf9A1b36cE34237eEaFef220932846BCD82",
"baseStrategyImplementation": "0x322813Fd9A801c5507c9de605d63CEA4f2CE6c44",
"delayedWithdrawalRouter": "0x2279B7A0a67DB372996a5FaB50D91eAA73d2eBe6",
"delayedWithdrawalRouterImplementation": "0x959922bE3CAee4b8Cd9a407cc3ac1C251C2007B1",
"delegation": "0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9",
"delegationImplementation": "0xB7f8BC63BbcaD18155201308C8f3540b07f84F5e",
"eigenLayerPauserReg": "0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512",
"eigenLayerProxyAdmin": "0x5FbDB2315678afecb367f032d93F642f64180aa3",
"eigenPodBeacon": "0x610178dA211FEF7D417bC0e6FeD39F05609AD788",
"eigenPodImplementation": "0x8A791620dd6260079BF849Dc5567aDC3F2FdC318",
"eigenPodManager": "0xa513E6E4b8f2a923D98304ec87F64353C4D5C853",
"eigenPodManagerImplementation": "0x0B306BF915C4d645ff596e518fAf3F9669b97016",
"emptyContract": "0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0",
"slasher": "0x0165878A594ca255338adfa4d48449f69242Eb8F",
"slasherImplementation": "0x9A676e781A523b5d0C0e43731313A708CB607508",
"avsDirectory": "0xc0F115A19107322cFBf1cDBC7ea011C19EbDB4F8",
"avsDirectoryImplementation": "0x276C216D241856199A83bf27b2286659e5b877D3",
"baseStrategyImplementation": "0x525C7063E7C20997BaaE9bDa922159152D0e8417",
"delegation": "0xD5ac451B0c50B9476107823Af206eD814a2e2580",
"delegationImplementation": "0xA7c59f010700930003b33aB25a7a0679C860f29c",
"eigenLayerPauserReg": "0x4b6aB5F819A515382B0dEB6935D793817bB4af28",
"eigenLayerProxyAdmin": "0x18E317A7D70d8fBf8e6E893616b52390EbBdb629",
"eigenPodBeacon": "0x22753E4264FDDc6181dc7cce468904A80a363E44",
"eigenPodImplementation": "0x07882Ae1ecB7429a84f1D53048d35c4bB2056877",
"eigenPodManager": "0x34B40BA116d5Dec75548a9e9A8f15411461E8c70",
"eigenPodManagerImplementation": "0x3155755b79aA083bd953911C92705B7aA82a18F9",
"emptyContract": "0xCace1b78160AE76398F486c8a18044da0d66d86D",
"rewardsCoordinator": "0xD0141E899a65C95a556fE2B27e5982A6DE7fDD7A",
"rewardsCoordinatorImplementation": "0x5bf5b11053e734690269C6B9D438F8C9d48F528A",
"slasher": "0xc96304e3c037f81dA488ed9dEa1D8F2a48278a75",
"slasherImplementation": "0x3347B4d90ebe72BeFb30444C9966B2B990aE9FcB",
"strategies": "",
"strategyManager": "0xDc64a140Aa3E981100a9becA4E685f962f0cF6C9",
"strategyManagerImplementation": "0xA51c1fc2f0D1a1b8494Ed1FE312d7C3a78Ed91C0"
"strategyManager": "0xF8e31cb472bc70500f08Cd84917E5A1912Ec8397",
"strategyManagerImplementation": "0xfaAddC93baf78e89DCf37bA67943E1bE8F37Bb8c"
},
"chainInfo": {
"chainId": 31337,
"deploymentBlock": 0
"deploymentBlock": 83
},
"parameters": {
"executorMultisig": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
Expand Down
27 changes: 15 additions & 12 deletions contracts/src/IncredibleSquaringTaskManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,12 @@ contract IncredibleSquaringTaskManager is
bytes32 message = keccak256(abi.encode(taskResponse));

// check the BLS signature
(QuorumStakeTotals memory quorumStakeTotals, bytes32 hashOfNonSigners) =
checkSignatures(message, quorumNumbers, taskCreatedBlock, nonSignerStakesAndSignature);
(QuorumStakeTotals memory quorumStakeTotals, bytes32 hashOfNonSigners) = 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 +206,8 @@ 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 +234,17 @@ 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
40 changes: 40 additions & 0 deletions tests/anvil/deploy-eigenlayer-and-avs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/bin/bash

RPC_URL=http://localhost:8545

# cd to the directory of this script so that this can be run from anywhere
parent_path=$(
cd "$(dirname "${BASH_SOURCE[0]}")"
pwd -P
)
cd "$parent_path"

set -a
source ./utils.sh
set +a


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
mv script/output/devnet/M2_from_scratch_deployment_data.json.bak script/output/devnet/M2_from_scratch_deployment_data.json
echo "deployment output moved"
echo "deploying avs"
cd ../../../../../contracts
forge script script/IncredibleSquaringDeployer.s.sol:IncredibleSquaringDeployer --rpc-url http://localhost:8545 --private-key 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 --broadcast -v
echo "avs deployed"
}



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"

deploy_eigenlayer_and_avs

42 changes: 0 additions & 42 deletions tests/anvil/start-anvil-chain-with-el-and-avs-deployed.sh

This file was deleted.

Loading