diff --git a/mev-auction-avs/contracts/.gitignore b/mev-auction-avs/contracts/.gitignore index cd9278d..50ffcf3 100644 --- a/mev-auction-avs/contracts/.gitignore +++ b/mev-auction-avs/contracts/.gitignore @@ -13,3 +13,15 @@ docs/ # Not sure what this folder is for.. so removing for now data/ + +# Ignore everything in the contracts/lib/eigenlayer-middleware directory +contracts/lib/eigenlayer-middleware/* +!contracts/lib/eigenlayer-middleware/.gitkeep + +# Ignore everything in the contracts/lib/forge-std directory +contracts/lib/forge-std/* +!contracts/lib/forge-std/.gitkeep + +# Ignore everything in the contracts/lib/openzeppelin-contracts directory +contracts/lib/openzeppelin-contracts/* +!contracts/lib/openzeppelin-contracts/.gitkeep diff --git a/mev-auction-avs/contracts/script/IncredibleSquaringDeployer.s.sol b/mev-auction-avs/contracts/script/MevAuctionDeployer.s.sol similarity index 82% rename from mev-auction-avs/contracts/script/IncredibleSquaringDeployer.s.sol rename to mev-auction-avs/contracts/script/MevAuctionDeployer.s.sol index e455112..c549a65 100644 --- a/mev-auction-avs/contracts/script/IncredibleSquaringDeployer.s.sol +++ b/mev-auction-avs/contracts/script/MevAuctionDeployer.s.sol @@ -18,9 +18,9 @@ import {IndexRegistry} from "@eigenlayer-middleware/src/IndexRegistry.sol"; import {StakeRegistry} from "@eigenlayer-middleware/src/StakeRegistry.sol"; import "@eigenlayer-middleware/src/OperatorStateRetriever.sol"; -import {IncredibleSquaringServiceManager, IServiceManager} from "../src/IncredibleSquaringServiceManager.sol"; -import {IncredibleSquaringTaskManager} from "../src/IncredibleSquaringTaskManager.sol"; -import {IIncredibleSquaringTaskManager} from "../src/IIncredibleSquaringTaskManager.sol"; +import {MevAuctionServiceManager, IServiceManager} from "../src/MevAuctionServiceManager.sol"; +import {MevAuctionTaskManager} from "../src/MevAuctionTaskManager.sol"; +import {IMevAuctionTaskManager} from "../src/IMevAuctionTaskManager.sol"; import "../src/ERC20Mock.sol"; import {Utils} from "./utils/Utils.sol"; @@ -31,8 +31,8 @@ import "forge-std/StdJson.sol"; import "forge-std/console.sol"; // # To deploy and verify our contract -// forge script script/CredibleSquaringDeployer.s.sol:CredibleSquaringDeployer --rpc-url $RPC_URL --private-key $PRIVATE_KEY --broadcast -vvvv -contract IncredibleSquaringDeployer is Script, Utils { +// forge script script/MevAuctionDeployer.s.sol:MevAuctionDeployer --rpc-url $RPC_URL --private-key $PRIVATE_KEY --broadcast -vvvv +contract MevAuctionDeployer is Script, Utils { // DEPLOYMENT CONSTANTS uint256 public constant QUORUM_THRESHOLD_PERCENTAGE = 100; uint32 public constant TASK_RESPONSE_WINDOW_BLOCK = 30; @@ -49,8 +49,8 @@ contract IncredibleSquaringDeployer is Script, Utils { StrategyBaseTVLLimits public erc20MockStrategy; // Credible Squaring contracts - ProxyAdmin public incredibleSquaringProxyAdmin; - PauserRegistry public incredibleSquaringPauserReg; + ProxyAdmin public mevAuctionProxyAdmin; + PauserRegistry public mevAuctionPauserReg; regcoord.RegistryCoordinator public registryCoordinator; regcoord.IRegistryCoordinator public registryCoordinatorImplementation; @@ -66,12 +66,12 @@ contract IncredibleSquaringDeployer is Script, Utils { OperatorStateRetriever public operatorStateRetriever; - IncredibleSquaringServiceManager public incredibleSquaringServiceManager; - IServiceManager public incredibleSquaringServiceManagerImplementation; + MevAuctionServiceManager public mevAuctionServiceManager; + IServiceManager public mevAuctionServiceManagerImplementation; - IncredibleSquaringTaskManager public incredibleSquaringTaskManager; - IIncredibleSquaringTaskManager - public incredibleSquaringTaskManagerImplementation; + MevAuctionTaskManager public mevAuctionTaskManager; + IMevAuctionTaskManager + public mevAuctionTaskManagerImplementation; function run() external { // Eigenlayer contracts @@ -173,7 +173,7 @@ contract IncredibleSquaringDeployer is Script, Utils { IDelegationManager delegationManager, IAVSDirectory avsDirectory, IStrategy strat, - address incredibleSquaringCommunityMultisig, + address mevAuctionCommunityMultisig, address credibleSquaringPauser ) internal { // Adding this as a temporary fix to make the rest of the script work with a single strategy @@ -182,16 +182,16 @@ contract IncredibleSquaringDeployer is Script, Utils { uint numStrategies = deployedStrategyArray.length; // deploy proxy admin for ability to upgrade proxy contracts - incredibleSquaringProxyAdmin = new ProxyAdmin(); + mevAuctionProxyAdmin = new ProxyAdmin(); // deploy pauser registry { address[] memory pausers = new address[](2); pausers[0] = credibleSquaringPauser; - pausers[1] = incredibleSquaringCommunityMultisig; - incredibleSquaringPauserReg = new PauserRegistry( + pausers[1] = mevAuctionCommunityMultisig; + mevAuctionPauserReg = new PauserRegistry( pausers, - incredibleSquaringCommunityMultisig + mevAuctionCommunityMultisig ); } @@ -203,20 +203,20 @@ contract IncredibleSquaringDeployer is Script, Utils { * First, deploy upgradeable proxy contracts that **will point** to the implementations. Since the implementation contracts are * not yet deployed, we give these proxies an empty contract as the initial implementation, to act as if they have no code. */ - incredibleSquaringServiceManager = IncredibleSquaringServiceManager( + mevAuctionServiceManager = MevAuctionServiceManager( address( new TransparentUpgradeableProxy( address(emptyContract), - address(incredibleSquaringProxyAdmin), + address(mevAuctionProxyAdmin), "" ) ) ); - incredibleSquaringTaskManager = IncredibleSquaringTaskManager( + mevAuctionTaskManager = MevAuctionTaskManager( address( new TransparentUpgradeableProxy( address(emptyContract), - address(incredibleSquaringProxyAdmin), + address(mevAuctionProxyAdmin), "" ) ) @@ -225,7 +225,7 @@ contract IncredibleSquaringDeployer is Script, Utils { address( new TransparentUpgradeableProxy( address(emptyContract), - address(incredibleSquaringProxyAdmin), + address(mevAuctionProxyAdmin), "" ) ) @@ -234,7 +234,7 @@ contract IncredibleSquaringDeployer is Script, Utils { address( new TransparentUpgradeableProxy( address(emptyContract), - address(incredibleSquaringProxyAdmin), + address(mevAuctionProxyAdmin), "" ) ) @@ -243,7 +243,7 @@ contract IncredibleSquaringDeployer is Script, Utils { address( new TransparentUpgradeableProxy( address(emptyContract), - address(incredibleSquaringProxyAdmin), + address(mevAuctionProxyAdmin), "" ) ) @@ -252,7 +252,7 @@ contract IncredibleSquaringDeployer is Script, Utils { address( new TransparentUpgradeableProxy( address(emptyContract), - address(incredibleSquaringProxyAdmin), + address(mevAuctionProxyAdmin), "" ) ) @@ -267,7 +267,7 @@ contract IncredibleSquaringDeployer is Script, Utils { delegationManager ); - incredibleSquaringProxyAdmin.upgrade( + mevAuctionProxyAdmin.upgrade( TransparentUpgradeableProxy(payable(address(stakeRegistry))), address(stakeRegistryImplementation) ); @@ -276,7 +276,7 @@ contract IncredibleSquaringDeployer is Script, Utils { registryCoordinator ); - incredibleSquaringProxyAdmin.upgrade( + mevAuctionProxyAdmin.upgrade( TransparentUpgradeableProxy(payable(address(blsApkRegistry))), address(blsApkRegistryImplementation) ); @@ -285,14 +285,14 @@ contract IncredibleSquaringDeployer is Script, Utils { registryCoordinator ); - incredibleSquaringProxyAdmin.upgrade( + mevAuctionProxyAdmin.upgrade( TransparentUpgradeableProxy(payable(address(indexRegistry))), address(indexRegistryImplementation) ); } registryCoordinatorImplementation = new regcoord.RegistryCoordinator( - incredibleSquaringServiceManager, + mevAuctionServiceManager, regcoord.IStakeRegistry(address(stakeRegistry)), regcoord.IBLSApkRegistry(address(blsApkRegistry)), regcoord.IIndexRegistry(address(indexRegistry)) @@ -338,7 +338,7 @@ contract IncredibleSquaringDeployer is Script, Utils { }); } } - incredibleSquaringProxyAdmin.upgradeAndCall( + mevAuctionProxyAdmin.upgradeAndCall( TransparentUpgradeableProxy( payable(address(registryCoordinator)) ), @@ -346,10 +346,10 @@ contract IncredibleSquaringDeployer is Script, Utils { abi.encodeWithSelector( regcoord.RegistryCoordinator.initialize.selector, // we set churnApprover and ejector to communityMultisig because we don't need them - incredibleSquaringCommunityMultisig, - incredibleSquaringCommunityMultisig, - incredibleSquaringCommunityMultisig, - incredibleSquaringPauserReg, + mevAuctionCommunityMultisig, + mevAuctionCommunityMultisig, + mevAuctionCommunityMultisig, + mevAuctionPauserReg, 0, // 0 initialPausedStatus means everything unpaused quorumsOperatorSetParams, quorumsMinimumStake, @@ -358,35 +358,35 @@ contract IncredibleSquaringDeployer is Script, Utils { ); } - incredibleSquaringServiceManagerImplementation = new IncredibleSquaringServiceManager( + mevAuctionServiceManagerImplementation = new MevAuctionServiceManager( avsDirectory, registryCoordinator, stakeRegistry, - incredibleSquaringTaskManager + mevAuctionTaskManager ); // Third, upgrade the proxy contracts to use the correct implementation contracts and initialize them. - incredibleSquaringProxyAdmin.upgrade( + mevAuctionProxyAdmin.upgrade( TransparentUpgradeableProxy( - payable(address(incredibleSquaringServiceManager)) + payable(address(mevAuctionServiceManager)) ), - address(incredibleSquaringServiceManagerImplementation) + address(mevAuctionServiceManagerImplementation) ); - incredibleSquaringTaskManagerImplementation = new IncredibleSquaringTaskManager( + mevAuctionTaskManagerImplementation = new MevAuctionTaskManager( registryCoordinator, TASK_RESPONSE_WINDOW_BLOCK ); // Third, upgrade the proxy contracts to use the correct implementation contracts and initialize them. - incredibleSquaringProxyAdmin.upgradeAndCall( + mevAuctionProxyAdmin.upgradeAndCall( TransparentUpgradeableProxy( - payable(address(incredibleSquaringTaskManager)) + payable(address(mevAuctionTaskManager)) ), - address(incredibleSquaringTaskManagerImplementation), + address(mevAuctionTaskManagerImplementation), abi.encodeWithSelector( - incredibleSquaringTaskManager.initialize.selector, - incredibleSquaringPauserReg, - incredibleSquaringCommunityMultisig, + mevAuctionTaskManager.initialize.selector, + mevAuctionPauserReg, + mevAuctionCommunityMultisig, AGGREGATOR_ADDR, TASK_GENERATOR_ADDR ) @@ -409,22 +409,22 @@ contract IncredibleSquaringDeployer is Script, Utils { vm.serializeAddress( deployed_addresses, "credibleSquaringServiceManager", - address(incredibleSquaringServiceManager) + address(mevAuctionServiceManager) ); vm.serializeAddress( deployed_addresses, "credibleSquaringServiceManagerImplementation", - address(incredibleSquaringServiceManagerImplementation) + address(mevAuctionServiceManagerImplementation) ); vm.serializeAddress( deployed_addresses, "credibleSquaringTaskManager", - address(incredibleSquaringTaskManager) + address(mevAuctionTaskManager) ); vm.serializeAddress( deployed_addresses, "credibleSquaringTaskManagerImplementation", - address(incredibleSquaringTaskManagerImplementation) + address(mevAuctionTaskManagerImplementation) ); vm.serializeAddress( deployed_addresses, diff --git a/mev-auction-avs/contracts/src/MevAuctionTaskManager.sol b/mev-auction-avs/contracts/src/MevAuctionTaskManager.sol index fed43db..de92824 100644 --- a/mev-auction-avs/contracts/src/MevAuctionTaskManager.sol +++ b/mev-auction-avs/contracts/src/MevAuctionTaskManager.sol @@ -46,18 +46,7 @@ contract MevAuctionTaskManager is mapping(uint32 => bool) public taskSuccesfullyChallenged; mapping(uint32 => Auction) public auctions; - - event NewTaskCreated(uint32 taskId, Auction auction); - event NewBidSubmitted(uint32 taskId, address bidder, uint256 bidAmount); - event AuctionCompleted(uint32 taskId, address highestBidder, uint256 highestBid); - - struct Auction { - uint256 highestBid; - address highestBidder; - uint256 endTime; - bool completed; - } - + /* MODIFIERS */ modifier onlyAggregator() { require(msg.sender == aggregator, "Aggregator must be the caller"); @@ -232,7 +221,7 @@ contract MevAuctionTaskManager is BN254.G1Point[] memory pubkeysOfNonSigningOperators ) external { uint32 referenceTaskIndex = taskResponse.referenceTaskIndex; - uint256 numberToBeSquared = task.numberToBeSquared; + // some logical checks require( allTaskResponses[referenceTaskIndex] != bytes32(0), @@ -255,16 +244,16 @@ contract MevAuctionTaskManager is "The challenge period for this task has already expired." ); - // logic for checking whether challenge is valid or not - uint256 actualSquaredOutput = numberToBeSquared * numberToBeSquared; - bool isResponseCorrect = (actualSquaredOutput == - taskResponse.numberSquared); + // // logic for checking whether challenge is valid or not + // uint256 actualSquaredOutput = numberToBeSquared * numberToBeSquared; + // bool isResponseCorrect = (actualSquaredOutput == + // taskResponse.numberSquared); - // if response was correct, no slashing happens so we return - if (isResponseCorrect == true) { - emit TaskChallengedUnsuccessfully(referenceTaskIndex, msg.sender); - return; - } + // // if response was correct, no slashing happens so we return + // if (isResponseCorrect == true) { + // emit TaskChallengedUnsuccessfully(referenceTaskIndex, msg.sender); + // return; + // } // get the list of hash of pubkeys of operators who weren't part of the task response submitted by the aggregator bytes32[] memory hashesOfPubkeysOfNonSigningOperators = new bytes32[]( diff --git a/mev-auction-avs/contracts/test/MevAuctionTaskManager.t.sol b/mev-auction-avs/contracts/test/MevAuctionTaskManager.t.sol index 9b8c902..f0c1ddc 100644 --- a/mev-auction-avs/contracts/test/MevAuctionTaskManager.t.sol +++ b/mev-auction-avs/contracts/test/MevAuctionTaskManager.t.sol @@ -1,38 +1,53 @@ // SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.12; -import "../src/MevAuctionServiceManager.sol" as mevacsm; +import "../src/MevAuctionServiceManager.sol"; import {MevAuctionTaskManager} from "../src/MevAuctionTaskManager.sol"; import {BLSMockAVSDeployer} from "@eigenlayer-middleware/test/utils/BLSMockAVSDeployer.sol"; import {TransparentUpgradeableProxy} from "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol"; -import "forge-std/Test.sol"; +import {Test} from "forge-std/Test.sol"; -contract MevAuctionTaskManagerTest is BLSMockAVSDeployer, Test { - mevacsm.MevAuctionServiceManager sm; - mevacsm.MevAuctionServiceManager smImplementation; +contract MevAuctionTaskManagerTest is Test { + MevAuctionServiceManager sm; + MevAuctionServiceManager smImplementation; MevAuctionTaskManager tm; MevAuctionTaskManager tmImplementation; + BLSMockAVSDeployer avsDeployer; - uint32 public constant TASK_RESPONSE_WINDOW_BLOCK = 10; - address aggregator = - address(uint160(uint256(keccak256(abi.encodePacked("aggregator"))))); - address generator = - address(uint160(uint256(keccak256(abi.encodePacked("generator"))))); + uint32 public constant TASK_RESPONSE_WINDOW_BLOCK = 30; + address aggregator = address(uint160(uint256(keccak256(abi.encodePacked("aggregator"))))); + address generator = address(uint160(uint256(keccak256(abi.encodePacked("generator"))))); function setUp() public { - _setUpBLSMockAVSDeployer(); - + emit log("Setting up BLSMockAVSDeployer"); + avsDeployer = new BLSMockAVSDeployer(); + avsDeployer._setUpBLSMockAVSDeployer(); + emit log("BLSMockAVSDeployer set up"); + + address registryCoordinator = address(avsDeployer.registryCoordinator()); + address proxyAdmin = address(avsDeployer.proxyAdmin()); + address pauserRegistry = address(avsDeployer.pauserRegistry()); + address registryCoordinatorOwner = avsDeployer.registryCoordinatorOwner(); + + emit log_named_address("Registry Coordinator", registryCoordinator); + emit log_named_address("Proxy Admin", proxyAdmin); + emit log_named_address("Pauser Registry", pauserRegistry); + emit log_named_address("Registry Coordinator Owner", registryCoordinatorOwner); + + emit log("Deploying MevAuctionTaskManager implementation"); tmImplementation = new MevAuctionTaskManager( - mevacsm.IRegistryCoordinator(address(registryCoordinator)), + IRegistryCoordinator(registryCoordinator), TASK_RESPONSE_WINDOW_BLOCK ); + emit log("MevAuctionTaskManager implementation deployed"); // Third, upgrade the proxy contracts to use the correct implementation contracts and initialize them. + emit log("Deploying TransparentUpgradeableProxy for MevAuctionTaskManager"); tm = MevAuctionTaskManager( address( new TransparentUpgradeableProxy( address(tmImplementation), - address(proxyAdmin), + proxyAdmin, abi.encodeWithSelector( tm.initialize.selector, pauserRegistry, @@ -43,11 +58,11 @@ contract MevAuctionTaskManagerTest is BLSMockAVSDeployer, Test { ) ) ); + emit log("TransparentUpgradeableProxy for MevAuctionTaskManager deployed"); } function testCreateNewTask() public { bytes memory quorumNumbers = new bytes(0); - // cheats.prank(generator, generator); vm.prank(generator); tm.createNewTask(2, 100, quorumNumbers); assertEq(tm.latestTaskNum(), 1); @@ -61,9 +76,9 @@ contract MevAuctionTaskManagerTest is BLSMockAVSDeployer, Test { vm.prank(address(1)); tm.submitBid(0, 1 ether); - (uint256 highestBid, address highestBidder, , ) = tm.getAuctionDetails(0); - assertEq(highestBid, 1 ether); - assertEq(highestBidder, address(1)); + IMevAuctionTaskManager.Auction memory auction = tm.getAuctionDetails(0); + assertEq(auction.highestBid, 1 ether); + assertEq(auction.highestBidder, address(1)); } function testCompleteAuction() public { @@ -80,8 +95,8 @@ contract MevAuctionTaskManagerTest is BLSMockAVSDeployer, Test { vm.prank(address(2)); tm.completeAuction(0); - (, , , bool completed) = tm.getAuctionDetails(0); - assertTrue(completed); + IMevAuctionTaskManager.Auction memory auction = tm.getAuctionDetails(0); + assertTrue(auction.completed); } function testGetAuctionDetails() public { @@ -92,11 +107,11 @@ contract MevAuctionTaskManagerTest is BLSMockAVSDeployer, Test { vm.prank(address(1)); tm.submitBid(0, 1 ether); - (uint256 highestBid, address highestBidder, uint256 endTime, bool completed) = tm.getAuctionDetails(0); - assertEq(highestBid, 1 ether); - assertEq(highestBidder, address(1)); - assertEq(endTime, block.timestamp + 2); - assertFalse(completed); + IMevAuctionTaskManager.Auction memory auction = tm.getAuctionDetails(0); + assertEq(auction.highestBid, 1 ether); + assertEq(auction.highestBidder, address(1)); + assertEq(auction.endTime, block.timestamp + 2); + assertFalse(auction.completed); } function testMultipleBids() public { @@ -110,9 +125,9 @@ contract MevAuctionTaskManagerTest is BLSMockAVSDeployer, Test { vm.prank(address(2)); tm.submitBid(0, 2 ether); - (uint256 highestBid, address highestBidder, , ) = tm.getAuctionDetails(0); - assertEq(highestBid, 2 ether); - assertEq(highestBidder, address(2)); + IMevAuctionTaskManager.Auction memory auction = tm.getAuctionDetails(0); + assertEq(auction.highestBid, 2 ether); + assertEq(auction.highestBidder, address(2)); } function testAuctionFailsAfterEndTime() public {