From e4189058c9efe864b74150811700402d2ef83238 Mon Sep 17 00:00:00 2001 From: Mikelle Date: Fri, 3 May 2024 18:29:32 +0200 Subject: [PATCH] chore: increased dispatch window --- contracts/scripts/DeployScripts.s.sol | 113 ++++++++++++++++----- contracts/test/PreConfirmationConfTest.sol | 39 ------- 2 files changed, 89 insertions(+), 63 deletions(-) diff --git a/contracts/scripts/DeployScripts.s.sol b/contracts/scripts/DeployScripts.s.sol index 213e960a2..be191fd57 100644 --- a/contracts/scripts/DeployScripts.s.sol +++ b/contracts/scripts/DeployScripts.s.sol @@ -13,16 +13,23 @@ import "../contracts/BlockTracker.sol"; // Deploy scripts should inherit this contract if they deploy using create2 deterministic addrs. contract Create2Deployer { - address constant _CREATE2_PROXY = 0x4e59b44847b379578588920cA78FbF26c0B4956C; - address constant _EXPECTED_DEPLOYER = 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266; + address constant _CREATE2_PROXY = + 0x4e59b44847b379578588920cA78FbF26c0B4956C; + address constant _EXPECTED_DEPLOYER = + 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266; function _checkCreate2Deployed() internal view { - require(isContractDeployed(_CREATE2_PROXY), "Create2 proxy needs to be deployed. See https://github.com/primevprotocol/deterministic-deployment-proxy"); + require( + isContractDeployed(_CREATE2_PROXY), + "Create2 proxy needs to be deployed. See https://github.com/primevprotocol/deterministic-deployment-proxy" + ); } function _checkDeployer() internal view { if (msg.sender != _EXPECTED_DEPLOYER) { - console.log("Warning: deployer is not expected address of 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266. Contracts addresses will not match documentation"); + console.log( + "Warning: deployer is not expected address of 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266. Contracts addresses will not match documentation" + ); } } @@ -45,9 +52,11 @@ contract DeployScript is Script, Create2Deployer { // Replace these with your contract's constructor parameters uint256 minStake = 1 ether; - address feeRecipient = address(0x68bC10674b265f266b4b1F079Fa06eF4045c3ab9); + address feeRecipient = address( + 0x68bC10674b265f266b4b1F079Fa06eF4045c3ab9 + ); uint16 feePercent = 2; - uint64 commitmentDispatchWindow = 250; + uint64 commitmentDispatchWindow = 500; uint256 blocksPerWindow = 10; // Forge deploy with salt uses create2 proxy from https://github.com/primevprotocol/deterministic-deployment-proxy @@ -56,26 +65,66 @@ contract DeployScript is Script, Create2Deployer { BlockTracker blockTracker = new BlockTracker{salt: salt}(msg.sender); console.log("BlockTracker deployed to:", address(blockTracker)); - BidderRegistry bidderRegistry = new BidderRegistry{salt: salt}(minStake, feeRecipient, feePercent, msg.sender, address(blockTracker)); + BidderRegistry bidderRegistry = new BidderRegistry{salt: salt}( + minStake, + feeRecipient, + feePercent, + msg.sender, + address(blockTracker) + ); console.log("BidderRegistry deployed to:", address(bidderRegistry)); - ProviderRegistry providerRegistry = new ProviderRegistry{salt: salt}(minStake, feeRecipient, feePercent, msg.sender); + ProviderRegistry providerRegistry = new ProviderRegistry{salt: salt}( + minStake, + feeRecipient, + feePercent, + msg.sender + ); console.log("ProviderRegistry deployed to:", address(providerRegistry)); - PreConfCommitmentStore preConfCommitmentStore = new PreConfCommitmentStore{salt: salt}(address(providerRegistry), address(bidderRegistry), feeRecipient, msg.sender, address(blockTracker), commitmentDispatchWindow); - console.log("PreConfCommitmentStore deployed to:", address(preConfCommitmentStore)); + PreConfCommitmentStore preConfCommitmentStore = new PreConfCommitmentStore{ + salt: salt + }( + address(providerRegistry), + address(bidderRegistry), + feeRecipient, + msg.sender, + address(blockTracker), + commitmentDispatchWindow + ); + console.log( + "PreConfCommitmentStore deployed to:", + address(preConfCommitmentStore) + ); - providerRegistry.setPreconfirmationsContract(address(preConfCommitmentStore)); - console.log("ProviderRegistry updated with PreConfCommitmentStore address:", address(preConfCommitmentStore)); + providerRegistry.setPreconfirmationsContract( + address(preConfCommitmentStore) + ); + console.log( + "ProviderRegistry updated with PreConfCommitmentStore address:", + address(preConfCommitmentStore) + ); - bidderRegistry.setPreconfirmationsContract(address(preConfCommitmentStore)); - console.log("BidderRegistry updated with PreConfCommitmentStore address:", address(preConfCommitmentStore)); + bidderRegistry.setPreconfirmationsContract( + address(preConfCommitmentStore) + ); + console.log( + "BidderRegistry updated with PreConfCommitmentStore address:", + address(preConfCommitmentStore) + ); - Oracle oracle = new Oracle{salt: salt}(address(preConfCommitmentStore), address(blockTracker), msg.sender); + Oracle oracle = new Oracle{salt: salt}( + address(preConfCommitmentStore), + address(blockTracker), + msg.sender + ); console.log("Oracle deployed to:", address(oracle)); preConfCommitmentStore.updateOracle(address(oracle)); - console.log("PreConfCommitmentStore updated with Oracle address:", address(oracle)); + console.log( + "PreConfCommitmentStore updated with Oracle address:", + address(oracle) + ); vm.stopBroadcast(); } @@ -84,12 +133,16 @@ contract DeployScript is Script, Create2Deployer { // Deploys whitelist contract and adds HypERC20 to whitelist contract DeployWhitelist is Script, Create2Deployer { function run() external { - - console.log("Warning: DeployWhitelist is deprecated and only for backwards compatibility with hyperlane"); + console.log( + "Warning: DeployWhitelist is deprecated and only for backwards compatibility with hyperlane" + ); address expectedWhiteListAddr = 0x57508f0B0f3426758F1f3D63ad4935a7c9383620; if (isContractDeployed(expectedWhiteListAddr)) { - console.log("Whitelist already deployed to:", expectedWhiteListAddr); + console.log( + "Whitelist already deployed to:", + expectedWhiteListAddr + ); return; } @@ -99,7 +152,10 @@ contract DeployWhitelist is Script, Create2Deployer { _checkDeployer(); address hypERC20Addr = vm.envAddress("HYP_ERC20_ADDR"); - require(hypERC20Addr != address(0), "Address to whitelist not provided"); + require( + hypERC20Addr != address(0), + "Address to whitelist not provided" + ); // Forge deploy with salt uses create2 proxy from https://github.com/primevprotocol/deterministic-deployment-proxy bytes32 salt = 0x8989000000000000000000000000000000000000000000000000000000000000; @@ -108,7 +164,10 @@ contract DeployWhitelist is Script, Create2Deployer { console.log("Whitelist deployed to:", address(whitelist)); whitelist.addToWhitelist(address(hypERC20Addr)); - console.log("Whitelist updated with hypERC20 address:", address(hypERC20Addr)); + console.log( + "Whitelist updated with hypERC20 address:", + address(hypERC20Addr) + ); vm.stopBroadcast(); } @@ -119,16 +178,22 @@ contract DeployValidatorRegistry is Script { function run() external { vm.startBroadcast(); - // 7000 blocks @ 200ms per block = 23.3 min. This allows two L1 epochs (finalization time) + settlement buffer, + // 7000 blocks @ 200ms per block = 23.3 min. This allows two L1 epochs (finalization time) + settlement buffer, // to pass between validator unstake initiation and withdrawal. uint256 unstakePeriodBlocks = 7000; // Can later be upgraded with https://docs.openzeppelin.com/upgrades-plugins/1.x/api-foundry-upgrades#Upgrades-upgradeProxy-address-string-bytes- address proxy = Upgrades.deployUUPSProxy( "ValidatorRegistry.sol", - abi.encodeCall(ValidatorRegistry.initialize, (3 ether, unstakePeriodBlocks, msg.sender)) + abi.encodeCall( + ValidatorRegistry.initialize, + (3 ether, unstakePeriodBlocks, msg.sender) + ) + ); + console.log( + "ValidatorRegistry UUPS proxy deployed to:", + address(proxy) ); - console.log("ValidatorRegistry UUPS proxy deployed to:", address(proxy)); ValidatorRegistry validatorRegistry = ValidatorRegistry(proxy); console.log("ValidatorRegistry owner:", validatorRegistry.owner()); diff --git a/contracts/test/PreConfirmationConfTest.sol b/contracts/test/PreConfirmationConfTest.sol index 390bc12a4..ec9a102ab 100644 --- a/contracts/test/PreConfirmationConfTest.sol +++ b/contracts/test/PreConfirmationConfTest.sol @@ -135,45 +135,6 @@ contract TestPreConfCommitmentStore is Test { function test_StoreCommitmentFailureDueToTimestampValidation() public { - // bytes32 bidHash = preConfCommitmentStore.getBidHash( - // _testCommitmentAliceBob.txnHash, - // _testCommitmentAliceBob.bid, - // _testCommitmentAliceBob.blockNumber, - // _testCommitmentAliceBob.decayStartTimestamp, - // _testCommitmentAliceBob.decayEndTimestamp - // ); - // (address bidder, uint256 bidderPk) = makeAddrAndKey("alice"); - // // Wallet memory kartik = vm.createWallet('test wallet'); - // (uint8 v,bytes32 r, bytes32 s) = vm.sign(bidderPk, bidHash); - // bytes memory signature = abi.encodePacked(r, s, v); - - // vm.deal(bidder, 200000 ether); - // vm.prank(bidder); - // bidderRegistry.depositForSpecificWindow{value: 2 ether}(2); - - // (bytes32 digest, address recoveredAddress) = preConfCommitmentStore.verifyBid( - // _testCommitmentAliceBob.bid, - // _testCommitmentAliceBob.blockNumber, - // _testCommitmentAliceBob.decayStartTimestamp, - // _testCommitmentAliceBob.decayEndTimestamp, - // _testCommitmentAliceBob.txnHash, - // signature); - - // assertEq(bidder, recoveredAddress); - // assertEq(digest, bidHash); - // vm.warp(1000); - // vm.expectRevert("Invalid dispatch timestamp, block.timestamp - dispatchTimestamp < commitment_dispatch_window"); - // preConfCommitmentStore.storeCommitment( - // _testCommitmentAliceBob.bid, - // _testCommitmentAliceBob.blockNumber, - // _testCommitmentAliceBob.txnHash, - // _testCommitmentAliceBob.decayStartTimestamp, - // _testCommitmentAliceBob.decayEndTimestamp, - // signature, - // _testCommitmentAliceBob.commitmentSignature, - // _testCommitmentAliceBob.dispatchTimestamp - // ); - // Step 1: Prepare the commitment information and signature bytes32 commitmentDigest = keccak256( abi.encodePacked("commitment data") );