From 00d9a27f59dc25ed87bbe29d0cbb6931037288b6 Mon Sep 17 00:00:00 2001 From: Kirk Baird Date: Thu, 8 Feb 2024 18:29:13 +1100 Subject: [PATCH 1/3] test(protocol): add Sigma Prime tests (#15678) --- .../protocol/test/L1/gov/TaikoGovernor.t.sol | 206 ++++++++ .../protocol/test/common/AddressManager.t.sol | 57 +++ .../test/common/AddressResolver.t.sol | 74 +++ .../test/common/AuthorizableContract.t.sol | 87 ++++ .../protocol/test/mocks/MockPlonkVerifier.sol | 21 + .../test/thirdparty/LibFixedPointMath.t.sol | 32 ++ .../test/thirdparty/optimisim/Bytes.t.sol | 118 +++++ .../thirdparty/optimisim/rlp/RLPReader.t.sol | 117 +++++ .../optimisim/trie/SecureMerkleTrie.t.sol | 125 +++++ .../test/verifiers/GuardianVerifier.t.sol | 81 +++ .../test/verifiers/PseZkVerifier.t.sol | 475 ++++++++++++++++++ .../protocol/test/verifiers/SgxVerifier.t.sol | 371 +++++++++++++- 12 files changed, 1738 insertions(+), 26 deletions(-) create mode 100644 packages/protocol/test/L1/gov/TaikoGovernor.t.sol create mode 100644 packages/protocol/test/common/AddressManager.t.sol create mode 100644 packages/protocol/test/common/AddressResolver.t.sol create mode 100644 packages/protocol/test/common/AuthorizableContract.t.sol create mode 100644 packages/protocol/test/mocks/MockPlonkVerifier.sol create mode 100644 packages/protocol/test/thirdparty/LibFixedPointMath.t.sol create mode 100644 packages/protocol/test/thirdparty/optimisim/Bytes.t.sol create mode 100644 packages/protocol/test/thirdparty/optimisim/rlp/RLPReader.t.sol create mode 100644 packages/protocol/test/thirdparty/optimisim/trie/SecureMerkleTrie.t.sol create mode 100644 packages/protocol/test/verifiers/GuardianVerifier.t.sol create mode 100644 packages/protocol/test/verifiers/PseZkVerifier.t.sol diff --git a/packages/protocol/test/L1/gov/TaikoGovernor.t.sol b/packages/protocol/test/L1/gov/TaikoGovernor.t.sol new file mode 100644 index 00000000000..65a80f1c5fd --- /dev/null +++ b/packages/protocol/test/L1/gov/TaikoGovernor.t.sol @@ -0,0 +1,206 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity 0.8.24; + +import "../TaikoL1TestBase.sol"; +import "../../../contracts/L1/gov/TaikoGovernor.sol"; +import "../../../contracts/L1/gov/TaikoTimelockController.sol"; +import "lib/openzeppelin-contracts/contracts/governance/IGovernor.sol"; +import "lib/openzeppelin-contracts/contracts/governance/TimelockController.sol"; + +/// @author Kirk Baird +contract TestTaikoGovernor is TaikoL1TestBase { + TaikoGovernor public taikoGovernor; + TaikoTimelockController public taikoTimelockController; + + function deployTaikoL1() internal override returns (TaikoL1) { + return + TaikoL1(payable(deployProxy({ name: "taiko", impl: address(new TaikoL1()), data: "" }))); + } + + function setUp() public override { + // Call the TaikoL1TestBase setUp() + super.setUp(); + + // deploy TaikoTimelockController + taikoTimelockController = TaikoTimelockController( + payable( + LibDeploy.deployERC1967Proxy({ + impl: address(new TaikoTimelockController()), + owner: address(0), + data: "" + }) + ) + ); + + // init TaikoTimelockController + uint256 minDelay = 0.5 days; + taikoTimelockController.init(minDelay); + + // deploy TaikoGovernor + taikoGovernor = TaikoGovernor( + payable( + LibDeploy.deployERC1967Proxy({ + impl: address(new TaikoGovernor()), + owner: address(0), + data: "" + }) + ) + ); + + // init TaikoGovernor + taikoGovernor.init(tko, taikoTimelockController); // not sure if the token should be TaikoToken here + + + // Alice delegate voting power to self + vm.startPrank(Alice); + tko.delegate(Alice); + vm.stopPrank(); + + address owner = taikoTimelockController.owner(); + vm.startPrank(owner); + // Owner set access controls for timelock controller + taikoTimelockController.grantRole(taikoTimelockController.PROPOSER_ROLE(), address(taikoGovernor)); + taikoTimelockController.grantRole(taikoTimelockController.EXECUTOR_ROLE(), address(taikoGovernor)); + taikoTimelockController.grantRole(taikoTimelockController.CANCELLER_ROLE(), address(taikoGovernor)); + + // Owner delegate voting power to self + tko.delegate(owner); + + // Transfer Alice double the proposal threshold worth of tokens + uint256 proposalThreshold = taikoGovernor.proposalThreshold(); + tko.transfer(Alice, proposalThreshold * 2); + tko.transfer(Bob, proposalThreshold * 5); + vm.roll(block.number + 1); // increase block number to help facilitate snapshots in TaikoToken + + vm.stopPrank(); + } + + function test_init() public { + // GovernorVotesQuorumFractionUpgradeable + assertEq(taikoGovernor.quorumNumerator(), 4, 'Incorrect initial quorum numerator'); + assertEq(taikoGovernor.quorumNumerator(block.number), 4, 'Incorrect initial block quorum numerator'); + assertEq(taikoGovernor.quorumDenominator(), 100, 'Incorrect quorum denominator'); + + // GovernorUpgradeable + assertEq(taikoGovernor.name(), 'TaikoGovernor', 'Incorrect name'); + assertEq(taikoGovernor.version(), '1', 'Incorrect version'); + + // GovernorVotesUpgradeable + assertEq(address(taikoGovernor.token()), address(tko), 'Incorrect token'); + + // GovernorCompatibilityBravoUpgradeable + assertEq(taikoGovernor.COUNTING_MODE(), 'support=bravo&quorum=bravo', 'Incorrect counting mode'); + + // GovernorTimelockControlUpgradeable + assertEq(taikoGovernor.timelock(), address(taikoTimelockController), 'Incorrect timelock'); + + // Interfaces + assertEq(taikoGovernor.supportsInterface(type(IGovernorTimelockUpgradeable).interfaceId), true, 'Incorrect supports interface'); + assertEq(taikoGovernor.supportsInterface(type(IGovernorUpgradeable).interfaceId), true, 'Incorrect supports interface'); + assertEq(taikoGovernor.supportsInterface(type(IERC1155ReceiverUpgradeable).interfaceId), true, 'Incorrect supports interface'); + + // TaikoGovernor + assertEq(taikoGovernor.votingDelay(), 7200, 'Incorrect voting delay'); + assertEq(taikoGovernor.votingPeriod(), 50_400, 'Incorrect voting period'); + assertEq(taikoGovernor.proposalThreshold(), 100_000 ether, 'Incorrect proposal threshold'); + } + + + // Tests `propose()` + function test_propose() public { + // Parameters for `TaikoGovernor.propose()` + address[] memory targets = new address[](1); + targets[0] = Alice; + + uint256[] memory values = new uint256[](1); + values[0] = 1 ether; + + bytes[] memory calldatas = new bytes[](1); + + string memory description = 'Send alice an ether'; + + address proposer = Alice; + vm.startPrank(proposer); + + // Prepare for event emission + uint256 startBlock = block.number + taikoGovernor.votingDelay(); + uint256 endBlock = startBlock + taikoGovernor.votingPeriod(); + uint256 calculatedProposalId = taikoGovernor.hashProposal(targets, values, calldatas, keccak256(bytes(description))); + + vm.expectEmit(true, true, true, true); + emit IGovernor.ProposalCreated( + calculatedProposalId, + Alice, + targets, + values, + new string[](targets.length), + calldatas, + startBlock, + endBlock, + description + ); + + // `propose()` + uint256 proposalId = taikoGovernor.propose(targets, values, calldatas, description); + vm.stopPrank(); + + // Validate proposal + assertEq(proposalId, calculatedProposalId, 'Proposal does not have the correct ID'); + assertEq(taikoGovernor.state(proposalId) == IGovernorUpgradeable.ProposalState.Pending, true, 'Incorrect proposal state'); + assertEq(taikoGovernor.proposalSnapshot(proposalId), startBlock, 'Incorrect proposal snapshot'); + assertEq(taikoGovernor.proposalDeadline(proposalId), endBlock, 'Incorrect proposal deadline'); + } + + // Tests `castVote()`, `queue()` and `execute()` + function test_execute() public { + // Parameters for `propose()` + address proposer = Alice; + address[] memory targets = new address[](1); + targets[0] = Alice; + uint256[] memory values = new uint256[](1); + values[0] = 1 ether; + bytes[] memory calldatas = new bytes[](1); + string memory description = 'Send alice an ether'; + bytes32 descriptionHash = keccak256(bytes(description)); + + // Send the values to the timelock controller for execute + (bool success,) = address(taikoTimelockController).call{value: values[0]}(""); + + assertEq(success, true, "Transfer funds unsuccessful"); + + // `propose()` + vm.startPrank(proposer); + uint256 proposalId = taikoGovernor.propose(targets, values, calldatas, description); + vm.stopPrank(); + + // Skip to voting start + uint256 startBlock = taikoGovernor.proposalSnapshot(proposalId); + vm.roll(startBlock + 1); + + // `castVote()` + vm.startPrank(tko.owner()); + taikoGovernor.castVote(proposalId, 1); // 1 = for + + // Skip to voting end + uint256 endBlock = taikoGovernor.proposalDeadline(proposalId); + vm.roll(endBlock + 1); + + // `queue()` successful proposal + taikoGovernor.queue(proposalId); + + // Skip delay amount of time + uint256 eta = taikoGovernor.proposalEta(proposalId); + vm.warp(eta + 1); + + // Prepare execute event + bytes32 timelockId = taikoTimelockController.hashOperationBatch(targets, values, calldatas, 0, descriptionHash); + vm.expectEmit(true, true, true, true); + emit TimelockController.CallExecuted(timelockId, 0, targets[0], values[0], calldatas[0]); + + // `execute()` + // taikoGovernor.execute(targets, values, calldatas, descriptionHash); + taikoGovernor.execute(proposalId); + + vm.stopPrank(); + } +} \ No newline at end of file diff --git a/packages/protocol/test/common/AddressManager.t.sol b/packages/protocol/test/common/AddressManager.t.sol new file mode 100644 index 00000000000..d6636d4c266 --- /dev/null +++ b/packages/protocol/test/common/AddressManager.t.sol @@ -0,0 +1,57 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity 0.8.24; + +import "../L1/TaikoL1TestBase.sol"; + +/// @author Kirk Baird +contract TestAddressManager is TaikoL1TestBase { + function deployTaikoL1() internal override returns (TaikoL1) { + return + TaikoL1(payable(deployProxy({ name: "taiko", impl: address(new TaikoL1()), data: "" }))); + } + + function setUp() public override { + // Call the TaikoL1TestBase setUp() + super.setUp(); + } + + function test_setAddress() external { + uint64 chainid = 1; + bytes32 name = bytes32(bytes("Bob")); + address newAddress = Bob; + // logs + vm.expectEmit(address(addressManager)); + emit AddressManager.AddressSet(chainid, name, newAddress, address(0)); + + // call `setAddress()` + addressManager.setAddress(chainid, name, newAddress); + + // validation + assertEq( + addressManager.getAddress(chainid, name), + Bob, + "should return Bob address" + ); + } + + function test_setAddress_callerNotOwner() external { + vm.startPrank(Alice); + + uint64 chainid = 1; + bytes32 name = bytes32(bytes("Bob")); + address newAddress = Bob; + + // call `setAddress()` + vm.expectRevert("Ownable: caller is not the owner"); + addressManager.setAddress(chainid, name, newAddress); + } + + function test_getAddress() external { + assertEq( + addressManager.getAddress(uint64(block.chainid), bytes32(bytes("taiko"))), + address(L1), + "expected address should be TaikoL1" + ); + } + +} \ No newline at end of file diff --git a/packages/protocol/test/common/AddressResolver.t.sol b/packages/protocol/test/common/AddressResolver.t.sol new file mode 100644 index 00000000000..16a9683af03 --- /dev/null +++ b/packages/protocol/test/common/AddressResolver.t.sol @@ -0,0 +1,74 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity 0.8.24; + +import "../L1/TaikoL1TestBase.sol"; + +/// @author Kirk Baird +contract TestAddressResolver is TaikoL1TestBase { + function deployTaikoL1() internal override returns (TaikoL1) { + return + TaikoL1(payable(deployProxy({ name: "taiko", impl: address(new TaikoL1()), data: "" }))); + } + + function setUp() public override { + // Call the TaikoL1TestBase setUp() + super.setUp(); + } + + function test_resolve() external { + assertEq( + bridge.resolve( + uint64(block.chainid), + bytes32(bytes("tier_guardian")), + false + ), + address(gv), + "wrong guardianVerifier address" + ); + + assertEq( + bridge.resolve( + uint64(block.chainid), + bytes32(bytes("tier_sgx")), + false + ), + address(sv), + " wrong sgxVerifier address" + ); + + assertEq( + bridge.resolve( + uint64(block.chainid), + bytes32(bytes("tier_pse_zkevm")), + false + ), + address(pv), + "wrong pseZkVerifier address" + ); + } + + + // Tests `resolve()` revert on zero address + function test_resolve_revertZeroAddress() external { + bytes32 name = bytes32(bytes("signal_service")); + vm.expectRevert( + abi.encodeWithSelector( + AddressResolver.RESOLVER_ZERO_ADDR.selector, + 666, + name + ) + ); + + bridge.resolve(uint64(666), name, false); + } + + // Tests `resolve()` successfully return zero address + function test_resolve_returnZeroAddress() external { + assertEq( + bridge.resolve(uint64(123), bytes32(bytes("taiko")), true), + address(0), + " should return address(0)" + ); + } + +} \ No newline at end of file diff --git a/packages/protocol/test/common/AuthorizableContract.t.sol b/packages/protocol/test/common/AuthorizableContract.t.sol new file mode 100644 index 00000000000..d3f4368e5d6 --- /dev/null +++ b/packages/protocol/test/common/AuthorizableContract.t.sol @@ -0,0 +1,87 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity 0.8.24; + +import "../L1/TaikoL1TestBase.sol"; + +/// @author Kirk Baird +contract TestAuthorizableContract is TaikoL1TestBase { + function deployTaikoL1() internal override returns (TaikoL1) { + return + TaikoL1(payable(deployProxy({ name: "taiko", impl: address(new TaikoL1()), data: "" }))); + } + + function setUp() public override { + // Call the TaikoL1TestBase setUp() + super.setUp(); + } + + function test_authorize() external { + bytes32 bobLabel = keccak256("Bob"); + //logs + vm.expectEmit(address(ss)); + emit AuthorizableContract.Authorized(Bob, 0, bobLabel); + // call authorize + ss.authorize(Bob, bobLabel); + + // validation + assertEq( + ss.authorizedAddresses(Bob), + bobLabel, + "wrong Label" + ); + assertEq( + ss.isAuthorizedAs(Bob, bobLabel), + true, + "should return true" + ); + + //stop prank + vm.stopPrank(); + } + + function test_authorize_invalid_address() external { + bytes32 bobLabel = keccak256("Bob"); + + vm.expectRevert(AuthorizableContract.INVALID_ADDRESS.selector); + // call authorize + ss.authorize(address(0), bobLabel); + } + + function test_authorize_invalid_label() external { + bytes32 bobLabel = keccak256("Bob"); + + //logs + vm.expectEmit(address(ss)); + emit AuthorizableContract.Authorized(Bob, 0, bobLabel); + + // call authorize + ss.authorize(Bob, bobLabel); + + // call authorize + vm.expectRevert(AuthorizableContract.INVALID_LABEL.selector); + ss.authorize(Bob, bobLabel); + } + + function test_isAuthorizedAs() external { + bytes32 bobLabel = keccak256("Bob"); + + //logs + vm.expectEmit(address(ss)); + emit AuthorizableContract.Authorized(Bob, 0, bobLabel); + + // call authorize + ss.authorize(Bob, bobLabel); + + assertEq( + ss.isAuthorizedAs(Bob, bobLabel), + true, + "should return true" + ); + assertEq( + ss.isAuthorizedAs(Alice, 0), + false, + "should return false" + ); + } + +} \ No newline at end of file diff --git a/packages/protocol/test/mocks/MockPlonkVerifier.sol b/packages/protocol/test/mocks/MockPlonkVerifier.sol new file mode 100644 index 00000000000..11cb23de808 --- /dev/null +++ b/packages/protocol/test/mocks/MockPlonkVerifier.sol @@ -0,0 +1,21 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity 0.8.24; + +import "../../contracts/thirdparty/optimism/Bytes.sol"; + +/// @author Kirk Baird +contract MockPlonkVerifier { + bool public _shouldRevert; + + + // Mock verifier that just returns what is sent in the proof after the first 64 bytes + fallback(bytes calldata input) external returns (bytes memory) { + require(!_shouldRevert, "We're going to revert here for fun :)"); + + return Bytes.slice(input, 64, input.length - 64); + } + + function setShouldRevert(bool shouldRevert) public { + _shouldRevert = shouldRevert; + } +} \ No newline at end of file diff --git a/packages/protocol/test/thirdparty/LibFixedPointMath.t.sol b/packages/protocol/test/thirdparty/LibFixedPointMath.t.sol new file mode 100644 index 00000000000..8524239b8ce --- /dev/null +++ b/packages/protocol/test/thirdparty/LibFixedPointMath.t.sol @@ -0,0 +1,32 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity 0.8.24; + +import "../TaikoTest.sol"; + +/// @author Kirk Baird +contract TestLibFixedPointMath is TaikoTest { + function test_exp() external { + assertEq(LibFixedPointMath.exp(1e18), 2718281828459045235); // 2.718281828459045235 + assertEq(LibFixedPointMath.exp(2e18), 7389056098930650227); // 7.389056098930650227 + assertEq(LibFixedPointMath.exp(0), 1000000000000000000); // 1 + assertEq(LibFixedPointMath.exp(-1e18), 367879441171442321); // 0.3678794411714423216 + assertEq(LibFixedPointMath.exp(1), 1000000000000000001); //1.000000000000000001 + assertEq(LibFixedPointMath.exp(-1), 999999999999999999); //0.9999999999999999990 + + // accurate up to 1e-16% + assertApproxEqRel(LibFixedPointMath.exp(135e18), 42633899483147210448936866880765989356468745853255281087440011736227864297277, 1); // 42633899483147210448936866880765989356468745853255281087440.011736227864297277 + + // accurate up to 1e-16% + assertApproxEqRel(LibFixedPointMath.exp(135_305_999_368_893_231_588), 57896044618658097649816762928942336782129491980154662247847962410455084893091, 1); // 57896044618658097649816762928942336782129491980154662247847.962410455084893091 + + assertEq(LibFixedPointMath.exp(-40e18), 4); + + // returns 0 if result is <0.5 + assertEq(LibFixedPointMath.exp(-42_139_678_854_452_767_552), 0); + } + + function test_exp_overflow() external { + vm.expectRevert(LibFixedPointMath.Overflow.selector); + LibFixedPointMath.exp(135305999368893231589); // max input is 135305999368893231588 + } +} diff --git a/packages/protocol/test/thirdparty/optimisim/Bytes.t.sol b/packages/protocol/test/thirdparty/optimisim/Bytes.t.sol new file mode 100644 index 00000000000..371813e7004 --- /dev/null +++ b/packages/protocol/test/thirdparty/optimisim/Bytes.t.sol @@ -0,0 +1,118 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity 0.8.24; + +import "../../TaikoTest.sol"; + +/// @author Kirk Baird +contract TestBytes is TaikoTest { + + function test_toNibbles() external { + // 20 Bytes input + bytes memory someBytes = hex"0123456789012345678901234567890123456789"; + bytes memory nibbles = Bytes.toNibbles(someBytes); + assertEq(hex"00010203040506070809000102030405060708090001020304050607080900010203040506070809", nibbles); + + // Empty bytes input + bytes memory emptyBytes; + nibbles = Bytes.toNibbles(emptyBytes); + assertEq(nibbles, hex""); + } + + // We test slice using case division based on different input sizes, starts and lengths + function test_slice() external { + // 1. 20 bytes input + bytes memory someBytes = hex"0123456789012345678901234567890123456789"; + + // 1.A. 0 length + // 1.A.i. 0 start + assertEq(Bytes.slice(someBytes, 0, 0), hex""); + + // 1.A.ii. partial start + assertEq(Bytes.slice(someBytes, 7, 0), hex""); + + // 1.A.iii. end start + assertEq(Bytes.slice(someBytes, someBytes.length, 0), hex""); + + // 1.B. full length + // 1.B.i. 0 start + assertEq(Bytes.slice(someBytes, 0, someBytes.length), hex"0123456789012345678901234567890123456789"); + + // 1.B.ii. partial start + vm.expectRevert("slice_outOfBounds"); + Bytes.slice(someBytes, 7, someBytes.length); + + // 1.C. partial length + // 1.C.i. 0 start + assertEq(Bytes.slice(someBytes, 0, 9), hex"012345678901234567"); + + // 1.C.ii. partial start + assertEq(Bytes.slice(someBytes, 7, 9), hex"456789012345678901"); + + // 1.C.iii. partial start, until exact end of input + assertEq(Bytes.slice(someBytes, 11, 9), hex"234567890123456789"); + + // 1.C.iv. end start + vm.expectRevert("slice_outOfBounds"); + Bytes.slice(someBytes, someBytes.length, 9); + + // 2. 64 byte input + someBytes = hex"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"; + + // 2.A. 0 length + // 2.A.i. 0 start + assertEq(Bytes.slice(someBytes, 0, 0), hex""); + + // 2.A.ii. partial start + assertEq(Bytes.slice(someBytes, 7, 0), hex""); + + // 2.A.iii. end start + assertEq(Bytes.slice(someBytes, someBytes.length, 0), hex""); + + // 2.B. full length + // 2.B.i. 0 start + assertEq(Bytes.slice(someBytes, 0, someBytes.length), hex"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"); + + // 2.B.ii. partial start + vm.expectRevert("slice_outOfBounds"); + Bytes.slice(someBytes, 7, someBytes.length); // TODO Foundry bug + + // 2.C. partial length + // 2.C.i. 0 start + assertEq(Bytes.slice(someBytes, 0, 9), hex"0123456789abcdef01"); + + // 2.C.ii. partial start + assertEq(Bytes.slice(someBytes, 7, 9), hex"ef0123456789abcdef"); + + // 2.C.iii. partial start, until exact end of input + assertEq(Bytes.slice(someBytes, 55, 9), hex"ef0123456789abcdef"); + + // 2.C.iv. end start + vm.expectRevert("slice_outOfBounds"); + Bytes.slice(someBytes, someBytes.length, 9); + + // 3. 0 byte input + someBytes = hex""; + + // 3.A. 0 start + assertEq(Bytes.slice(someBytes, 0, 0), hex""); + + // 3.B. overflow start + vm.expectRevert("slice_outOfBounds"); + Bytes.slice(someBytes, 1, 0); + + // 3.C. overflow length + vm.expectRevert("slice_outOfBounds"); + Bytes.slice(someBytes, 0, 1); + } + + function test_slice2() external { + // 20 byte input + bytes memory someBytes = hex"0123456789012345678901234567890123456789"; + + assertEq(Bytes.slice(someBytes, 0), hex"0123456789012345678901234567890123456789"); + + assertEq(Bytes.slice(someBytes, 10), hex"01234567890123456789"); + + assertEq(Bytes.slice(someBytes, someBytes.length*1000), hex""); //Doesnt revert if start is out of bounds + } +} \ No newline at end of file diff --git a/packages/protocol/test/thirdparty/optimisim/rlp/RLPReader.t.sol b/packages/protocol/test/thirdparty/optimisim/rlp/RLPReader.t.sol new file mode 100644 index 00000000000..811aa0a861b --- /dev/null +++ b/packages/protocol/test/thirdparty/optimisim/rlp/RLPReader.t.sol @@ -0,0 +1,117 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity 0.8.24; + +import "../../../TaikoTest.sol"; + +/// @author Kirk Baird +contract TestRLPReader is TaikoTest { + function test_readList_correctList() external { + bytes memory encodedList = hex"c3010203"; // "[0x01, 0x02, 0x03]" + RLPReader.RLPItem[] memory decodedList = RLPReader.readList(encodedList); + assertEq(decodedList.length, 3); + assertEq(RLPReader.readBytes(decodedList[0]), hex"01"); + assertEq(RLPReader.readBytes(decodedList[1]), hex"02"); + assertEq(RLPReader.readBytes(decodedList[2]), hex"03"); + } + + function test_readList_emptyList() external { + bytes memory encodedList = hex"c0"; // "[]" + RLPReader.RLPItem[] memory decodedList = RLPReader.readList(encodedList); + assertEq(decodedList.length, 0); + } + + function test_readList_emptyListNull() external { + bytes memory encodedList = hex"c180"; // "[""]" + RLPReader.RLPItem[] memory decodedList = RLPReader.readList(encodedList); + assertEq(decodedList.length, 1); + assertEq(RLPReader.readBytes(decodedList[0]), hex""); + } + + function test_readList_nestedList() external { + bytes memory encodedList = hex"c3c10102"; // "[["0x01"],"0x02"]" + RLPReader.RLPItem[] memory decodedList = RLPReader.readList(encodedList); + assertEq(decodedList.length, 2); + assertEq(RLPReader.readBytes(decodedList[1]), hex"02"); + RLPReader.RLPItem[] memory nestedDecodedList = RLPReader.readList(decodedList[0]); + assertEq(nestedDecodedList.length, 1); + assertEq(RLPReader.readBytes(nestedDecodedList[0]), hex"01"); + } + + function test_readList_invalidLength() external { + bytes memory encodedList = hex"e1a00000000000000000000000000000000000000000000000000001"; + vm.expectRevert("RLPReader: length of content must be greater than list length (short list)"); + RLPReader.readList(encodedList); + } + + function test_readList_empty() external { + bytes memory empty = hex""; + vm.expectRevert("RLPReader: length of an RLP item must be greater than zero to be decodable"); + RLPReader.readList(empty); + } + + function test_readList_null() external { + bytes memory encodedNull = hex"80"; + vm.expectRevert("RLPReader: decoded item type for list is not a list item"); + RLPReader.readList(encodedNull); + } + + function test_readList_nonList() external { + bytes memory encodedNumber = hex"8204d2"; // "1234" + vm.expectRevert("RLPReader: decoded item type for list is not a list item"); + RLPReader.readList(encodedNumber); + } + + function test_readBytes_correctFourBytes() external { + bytes memory encodedBytes = hex"8412345678"; // "0x12345678" + bytes memory decodedBytes = RLPReader.readBytes(encodedBytes); + assertEq(decodedBytes.length, 4); + assertEq(decodedBytes, hex"12345678"); + } + + function test_readBytes_correctSixtyFourBytes() external { + bytes memory encodedBytes = hex"b8400123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"; + bytes memory decodedBytes = RLPReader.readBytes(encodedBytes); + assertEq(decodedBytes.length, 64); + assertEq(decodedBytes, hex"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"); + + } + + function test_readBytes_null() external { + bytes memory encodedBytes = hex"80"; + assertEq(RLPReader.readBytes(encodedBytes), hex""); + } + + function test_readBytes_empty() external { + bytes memory empty = hex""; + vm.expectRevert("RLPReader: length of an RLP item must be greater than zero to be decodable"); + RLPReader.readBytes(empty); + } + + function test_readBytes_list() external { + bytes memory encodedList = hex"c3010203"; // "[0x01, 0x02, 0x03]" + vm.expectRevert("RLPReader: decoded item type for bytes is not a data item"); + RLPReader.readBytes(encodedList); + } + + function test_readRawBytes_shortBytes() external { + bytes memory encodedBytes = hex"940123456789012345678901234567890123456789"; + assertEq(RLPReader.readRawBytes(RLPReader.toRLPItem(encodedBytes)), encodedBytes); + } + + function test_readRawBytes_longBytes() external { + bytes memory encodedBytes = hex"b8400123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"; + assertEq(RLPReader.readRawBytes(RLPReader.toRLPItem(encodedBytes)), encodedBytes); + } + + function test_readRawBytes_empty() external { + bytes memory encodedBytes = hex""; + vm.expectRevert("RLPReader: length of an RLP item must be greater than zero to be decodable"); + RLPReader.readRawBytes(RLPReader.toRLPItem(encodedBytes)); + } + + function test_readRawBytes_null() external { + bytes memory encodedBytes = hex"80"; + assertEq(RLPReader.readRawBytes(RLPReader.toRLPItem(encodedBytes)), encodedBytes); + } + +} \ No newline at end of file diff --git a/packages/protocol/test/thirdparty/optimisim/trie/SecureMerkleTrie.t.sol b/packages/protocol/test/thirdparty/optimisim/trie/SecureMerkleTrie.t.sol new file mode 100644 index 00000000000..83dedab3347 --- /dev/null +++ b/packages/protocol/test/thirdparty/optimisim/trie/SecureMerkleTrie.t.sol @@ -0,0 +1,125 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity 0.8.24; + +import "../../../TaikoTest.sol"; + +/// @author Kirk Baird +contract TestSecureMerkleTrie is TaikoTest { + function test_verifyInclusionProof_simple() external { + bytes memory slot = hex"0000000000000000000000000000000000000000000000000000000000000006"; // hash = 0xf652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d3f + bytes memory value = hex"01"; + // Leaf node (target): ["0x3652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d3f","0x01"] // hash = 4c020f5af4649ee703bbfa974846790d332abacef03c89036babb2238c01c337 + // Branch node (root): ["0x","0x","0x","0x","0x","0x","0x","0x","0x","0x","0x","0x","0x","0x","0x","0x4c020f5af4649ee703bbfa974846790d332abacef03c89036babb2238c01c337", "0x"] // hash = b21a635028fc2f2a4ba5b688497165f7096500771fd493e0695ef750c6c1845c + + bytes32 rootHash = hex"b21a635028fc2f2a4ba5b688497165f7096500771fd493e0695ef750c6c1845c"; + + bytes[] memory proof = new bytes[](2); + proof[0] = hex"f1808080808080808080808080808080a04c020f5af4649ee703bbfa974846790d332abacef03c89036babb2238c01c33780"; + proof[1] = hex"e2a03652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d3f01"; + + + assertTrue(SecureMerkleTrie.verifyInclusionProof( + slot, + value, + proof, + rootHash + )); + } + + // based on deployed contract 0xcD5e2bebd3DfE46e4BF96aE2ac7B89B22cc6a982 (SignalService Proxy) on Sepolia + function test_verifyInclusionProof_realProof() external { + bytes memory slot = hex"0000000000000000000000000000000000000000000000000000000000000000"; + bytes memory value = hex"01"; + bytes32 rootHash = hex"45e9f670f31850ee0771a6ce85f36721526bc413bd91d58b8b9002adacb418ca"; + + bytes[] memory proof = new bytes[](6); + proof[0] = hex"f90211a01bf8dc9db1d06b09a1593db05232aa42c2b417e20251d71e8f32086b57573e06a0f541e279cb44d7e034fd4a8fda716291d8bb5cc2fb67249197c373e4405333d9a09ac7f4d030a807bf868f0e9122a537e6ea6f029a3bbae5477f5bec9367477538a012795298d14f24c7876a15303f38c794fe4d22c385d6b15adf136a65287d64aca0db8ff50aeed396a753e2b582a2101807146b9abad224956c8c0b2914e8bc6308a050e2462dd19498a35aabf6a701e90756cd519129c04095fde7b35ced53548967a01d4d98eae2c34085bef8029256fbc79dfd08ce2413742e006c16057ee23d8415a05ee9d91e8763e4ab8bfddb682f1579d91189d77435e69e186788b1236c07b400a06e867457693097e1ac54bca407a9b7241740e64d110e661b71b708776bf951cea038440f0f7488fc76ba3f7a35b1789dd4658b9b206441ef824acb7fe2a3a76a20a0285e98d81740593ef5a9a529c4d733ebe64f15f40732b3a0d0623c1cb71f8ed0a0a80dd18c30ffd2792e4856b13097aad1e5afe7439b7f343cf9ae856d68af2ba7a0c2d74f432cab091d90bae5ec862089ae1272f39108f1cba4f57c7b5671e5c816a0aceebc0b41cf40fe8313c2b524f03e732b8385727de1abae876d9057b2d85e1fa00ee8b4f21e2f328d027884d9ffbac6fac35539a7d74b11d9f17e5a3a185b8386a0e52242d3cc5dd7773ec21fbfae2141144d02ce74ff601c375bda5fff96aef12b80"; + proof[1] = hex"f90211a09c081fac815d03d3ef97f0f6ec100c24a7057fff79a870a22756b374a67a67eaa008586c30da747166360003b1eed874a0b915ca98cbfa84964f7d88ab8da1989aa0449474ec27502c1a3a5d21050bbfd57cc514adae298412e23f132534ff932dfca08434310370976516d70c7b3b6b33a383e46a94563ec48da41ce3074141c29d37a0912079ec50d4499209c32b2f7dd8d12cb9c152136812df496876fae92d485335a0505627a88c1028e9ce54238f9f5d79e196b9fee338aa642afe511886ed53f04aa0e411917634b30a3767de43f4208ee6a7bef92e63e4afd83b9318da18b5664a6ea03f5bbccdf60e44fa45761b107f34166d4b511d0343af2464afed818dfdc57963a002920171377ba261586e2733d3d0f19696b44848abb95ad91b08484f7cbe74bea0815f25e6680089a62b7219ee2957b19e773d41545fe2140a4dbcd7e8cd3dffd7a0204c53730d2e8b4840012807a3ccfb3dab97a9abcbddea7b470e72c31ed47e64a0e37b499b1b6139944109adfffe5a303f26efc14627a85bdd06f5f67fa18d1f27a070660c887064df8b7d89a942b0553427dd18f06b8bbb39db5365786e780fc749a07b51a6dbe67bad62c92538c859a66937162cb61a000d7e5f21695e490199b18ba0b80c116ca1493c4a017f3189e519614295c4ec23edcaa199f16f64ad9b9527c7a09cea6ec2caee96a5cacbae86e88c15e0f2a5d26d4b75137179fd5666fbb5aa7480"; + proof[2] = hex"f90211a0edff33fe5c95b4fa868d66431769e22577932ee13b18b1da8ee5419aec59c5e7a09320d0ae25a44b54b44f69b435a3edb6503d0aab80052a4ba2d0069e840ffcf3a084d002a67ee8281c3681b11d948ab4d2a6440a2803f6025b54dcaa4a2bb86047a00104b82f9c6c5a0d3bc9f1af1ccde26293e680e26d525f9d542a9ebb5d623eada02b2522787d006e41d10c12bff567be8eb13ca23784a926eddeda28550bc50843a03d02c42758d7f7107850431572c6275b64a9da09107d588c732a45804ec8b650a0be4b44daa2d677c7163e0b6b8334c39ddb92ae0701b573196ed2e422d08d7f79a0c4c06e7eded093383c6c3e2460462a49d356a4fc3165ec0207490cf62b382653a0d54b62359a6a9c0541e660b151009cc42a48e3ba12b7059e7aa40ea55f7d627fa08ee6a1a4cc20035c4ac7aea9d80dfc1dd13d83b9c9941c180caf0496a261a525a02885741fff2f4e61c3cd76ea387978030d9d0a79d2accdaaa535e9fd69be9dc0a013f67d5965341a354b659eddf810ad1801ed6cdbc85922fbf4f1d5690d4dec5ea0014ce0d9af419fb75af5ebf396786cd3f415429d30e174c864c6f355e46e9e9fa04ad594c616d61e8b911359309131516d9e29d9a435cec91520d0831bcee6752fa06aeb091d8001bf97c0861ea1900e85edad54c00e7d368fae73a5d980a4479a2da07e2aa9f31c59e36b69154fbd34de81c6b1feed1a6ed868813e923d2f98d8c31480"; + proof[3] = hex"f90211a0d2c363378ebc8717d552d4137cba842e6d00f045121f885d88f1146121c299e5a09f6f5a03356b3033f75fba1956afe0242be8dc508ce83e356ea5f48b3c17b571a0ba32e8ef62fdfc524822241c471024cba2b1d4a6a9d049424e2ac3868435f2eaa0284ecc45af9d2cc173636750eef4fc9c3e8828a5469732571950259cd25b2ae5a0a4a384dba0939acbcc8b14ce2411df265cc91162debb84ffd94f9a5f185e6c04a02542ba4e13a2571665afb8a8d6b5e972e018d1d6f3ae57707d725254530f27aaa05b1f61c8dea59ac83181d4faa4d3c322970f5ecacd0bd07028bc87b6e3174baba02fa86ead02062c2671a3de5460efe03e179184e3602320ab8478aa51239ca5f1a0b0a1ed80fa8eef67af1193c2080d04976d2b28ed3a70ad64afc9d31864ddf0d3a0afd61230c619715051e37d73754063a58da86e17fa9f1f702038b88b762fda4ea0cdb772381aec1978ad17c8c0e13298b1f9ce4b937f45a7b5ade7bce5ec374665a0db07f3614888c57b8ccbddca9e1575e63b663acada279262261b43e8d328ba88a00de0759c749651d9b8960feed63fbeecaaa145f47927e7f2d2d3f56bb802d676a01c3384e31a91e9d39ee8c728c24cf49a2d1c27ed4d96075c760d470e0812731da07e7fc146b9cc0be8af894c7a6cd93b4857011483f299c5b68737de3f0eb53304a0466878f42b7f4b98bdf104bede4313aade1c2cf0186db3e5806b74935129d00e80"; + proof[4] = hex"f90171a031dde6777fd092b1b9769b2402355e81e3e03e5d5c336f5edc583836ed15cfa580a0bb779ade81cb7fa701d963b9c1ae32d7cf58d926d14217bf96e3b44cdc93426da08cfeef6342385fbb0b452adca5c2ae1c5c651839137c15ce646d2a2011358e0ba0354480a6556b60a6af02f5f138eac24b268af77d85b3a7e241b1c6ec30125e17a08b6d79c69add140fd1bdd694ded36b248961ce0a6c905aac15ae928b925d730f80a0665dd3eb57bd0fd5bf2476a2c7ce190bbe4cfe92862d2ca644ec2f24a5e1545980a0321c382b719c93b3d816c3876a5f36b265186988c4a7994bc5927357f64d82bfa0adbd467e4d446b07a0f755954da22d7480373fdb139e93ec52799aa4239571a980a0a3eed0a41205afb11767756e464a4b99b0cbec8ac9f0919f46b831118a6847f880a0954e8545cb42ac37f2ef0f79f745a03c660dd143a7b621132385060a8345e821a00fe18033d0e53a5d97855111b656f4aefc4b32538df7aba9a01592bb1337d15380"; + proof[5] = hex"e09e3cd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e56301"; + + assertTrue(SecureMerkleTrie.verifyInclusionProof( + slot, + value, + proof, + rootHash + )); + } + + function test_verifyInclusionProof_fakeValue() external { + bytes memory slot = hex"0000000000000000000000000000000000000000000000000000000000000006"; + bytes memory value = hex"ff"; + bytes32 rootHash = hex"b21a635028fc2f2a4ba5b688497165f7096500771fd493e0695ef750c6c1845c"; + + bytes[] memory proof = new bytes[](2); + proof[0] = hex"f1808080808080808080808080808080a04c020f5af4649ee703bbfa974846790d332abacef03c89036babb2238c01c33780"; + proof[1] = hex"e2a03652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d3f01"; + + assertFalse(SecureMerkleTrie.verifyInclusionProof( + slot, + value, + proof, + rootHash + )); + } + + function test_verifyInclusionProof_fakeRoot() external { + bytes memory slot = hex"0000000000000000000000000000000000000000000000000000000000000006"; // hash = 0xf652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d3f + bytes memory value = hex"01"; + // Leaf node (target): ["0x3652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d3f","0x01"] // hash = 4c020f5af4649ee703bbfa974846790d332abacef03c89036babb2238c01c337 + // Branch node (root): ["0x","0x","0x","0x","0x","0x","0x","0x","0x","0x","0x","0x","0x","0x","0x","0x4c020f5af4649ee703bbfa974846790d332abacef03c89036babb2238c01c337", "0x"] // hash = b21a635028fc2f2a4ba5b688497165f7096500771fd493e0695ef750c6c1845c + + bytes32 rootHash = hex"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"; + + bytes[] memory proof = new bytes[](2); + proof[0] = hex"f1808080808080808080808080808080a04c020f5af4649ee703bbfa974846790d332abacef03c89036babb2238c01c33780"; + proof[1] = hex"e2a03652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d3f01"; + + vm.expectRevert("MerkleTrie: invalid root hash"); + SecureMerkleTrie.verifyInclusionProof( + slot, + value, + proof, + rootHash + ); + } + + function test_verifyInclusionProof_fakeIntermediateNode() external { + bytes memory slot = hex"0000000000000000000000000000000000000000000000000000000000000006"; // hash = 0xf652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d3f + bytes memory value = hex"01"; + // Leaf node (target): ["0x3123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef","0x01"] // hash = 7b074e96d2dcd6ae7a05e7e35c748e067706d28e47bfecf0c0e642f4dff48d17 + // Branch node (root): ["0x","0x","0x","0x","0x","0x","0x","0x","0x","0x","0x","0x","0x","0x","0x","0x4c020f5af4649ee703bbfa974846790d332abacef03c89036babb2238c01c337", "0x"] // hash = b21a635028fc2f2a4ba5b688497165f7096500771fd493e0695ef750c6c1845c + + bytes32 rootHash = hex"b21a635028fc2f2a4ba5b688497165f7096500771fd493e0695ef750c6c1845c"; + + bytes[] memory proof = new bytes[](2); + proof[0] = hex"f1808080808080808080808080808080a04c020f5af4649ee703bbfa974846790d332abacef03c89036babb2238c01c33780"; + proof[1] = hex"e2a03123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef01"; + + vm.expectRevert("MerkleTrie: invalid large internal hash"); + SecureMerkleTrie.verifyInclusionProof( + slot, + value, + proof, + rootHash + ); + } + + function test_get() external { + bytes memory slot = hex"0000000000000000000000000000000000000000000000000000000000000006"; // hash = 0xf652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d3f + bytes memory value = hex"01"; + // Leaf node (target): ["0x3652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d3f","0x01"] // hash = 4c020f5af4649ee703bbfa974846790d332abacef03c89036babb2238c01c337 + // Branch node (root): ["0x","0x","0x","0x","0x","0x","0x","0x","0x","0x","0x","0x","0x","0x","0x","0x4c020f5af4649ee703bbfa974846790d332abacef03c89036babb2238c01c337", "0x"] // hash = b21a635028fc2f2a4ba5b688497165f7096500771fd493e0695ef750c6c1845c + + bytes32 rootHash = hex"b21a635028fc2f2a4ba5b688497165f7096500771fd493e0695ef750c6c1845c"; + + bytes[] memory proof = new bytes[](2); + proof[0] = hex"f1808080808080808080808080808080a04c020f5af4649ee703bbfa974846790d332abacef03c89036babb2238c01c33780"; + proof[1] = hex"e2a03652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d3f01"; + + bytes memory fetchedValue = SecureMerkleTrie.get(slot, proof, rootHash); + assertEq(fetchedValue, value); + } +} \ No newline at end of file diff --git a/packages/protocol/test/verifiers/GuardianVerifier.t.sol b/packages/protocol/test/verifiers/GuardianVerifier.t.sol new file mode 100644 index 00000000000..7c88ba04e59 --- /dev/null +++ b/packages/protocol/test/verifiers/GuardianVerifier.t.sol @@ -0,0 +1,81 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity 0.8.24; + +import "../L1/TaikoL1TestBase.sol"; + +/// @author Kirk Baird +contract TestGuardianVerifier is TaikoL1TestBase { + function deployTaikoL1() internal override returns (TaikoL1) { + return + TaikoL1(payable(deployProxy({ name: "taiko", impl: address(new TaikoL1()), data: "" }))); + } + + function setUp() public override { + // Call the TaikoL1TestBase setUp() + super.setUp(); + } + + + // Tests `verifyProof()` with the correct prover + function test_verifyProof() public { + // Context + IVerifier.Context memory ctx = IVerifier.Context({ + metaHash: bytes32(0), + blobHash: bytes32(0), + prover: address(gp), + blockId: 10, + isContesting: false, + blobUsed: false + }); + + // Transition + TaikoData.Transition memory transition = TaikoData.Transition({ + parentHash: bytes32(0), + blockHash: bytes32(0), + signalRoot: bytes32(0), + graffiti: bytes32(0) + }); + + // TierProof + TaikoData.TierProof memory proof = TaikoData.TierProof({ + tier: 0, + data: "" + }); + + // `verifyProof()` + gv.verifyProof(ctx, transition, proof); + } + + + // Tests `verifyProof()` with the wrong prover + function test_verifyProof_invalidProver() public { + // Context + IVerifier.Context memory ctx = IVerifier.Context({ + metaHash: bytes32(0), + blobHash: bytes32(0), + prover: Alice, // invalid + blockId: 10, + isContesting: false, + blobUsed: false + }); + + // Transition + TaikoData.Transition memory transition = TaikoData.Transition({ + parentHash: bytes32(0), + blockHash: bytes32(0), + signalRoot: bytes32(0), + graffiti: bytes32(0) + }); + + // TierProof + TaikoData.TierProof memory proof = TaikoData.TierProof({ + tier: 0, + data: "" + }); + + // `verifyProof()` with invalid ctx.prover + vm.expectRevert(GuardianVerifier.PERMISSION_DENIED.selector); + gv.verifyProof(ctx, transition, proof); + } +} + diff --git a/packages/protocol/test/verifiers/PseZkVerifier.t.sol b/packages/protocol/test/verifiers/PseZkVerifier.t.sol new file mode 100644 index 00000000000..645e0e78ce7 --- /dev/null +++ b/packages/protocol/test/verifiers/PseZkVerifier.t.sol @@ -0,0 +1,475 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity 0.8.24; + +import "../L1/TaikoL1TestBase.sol"; +import "lib/openzeppelin-contracts/contracts/utils/Strings.sol"; +import {IVerifier} from "../../contracts/verifiers/IVerifier.sol"; +import {TaikoData} from "../../contracts/L1/TaikoData.sol"; +import {MockPlonkVerifier} from "../mocks/MockPlonkVerifier.sol"; + +/// @author Kirk Baird +contract TestPseZkVerifier is TaikoL1TestBase { + uint16 mockPlonkVerifierId; + address mockPlonkVerifier; + + function deployTaikoL1() internal override returns (TaikoL1) { + return + TaikoL1(payable(deployProxy({ name: "taiko", impl: address(new TaikoL1()), data: "" }))); + } + + function setUp() public override { + // Call the TaikoL1TestBase setUp() + super.setUp(); + + // Create a mock PLONK Verifier + mockPlonkVerifierId = 12345; + mockPlonkVerifier = address(new MockPlonkVerifier()); + + // Add the mock PLONK verifier to the address resolver + bytes32 verifierName = pv.getVerifierName(mockPlonkVerifierId); + + addressManager.setAddress( + uint64(block.chainid), + bytes32(verifierName), + address(mockPlonkVerifier) + ); + } + + // Test `verifyProof()` when contesting + function test_verifyProof_isContesting() external { + // Context + IVerifier.Context memory ctx = IVerifier.Context({ + metaHash: bytes32("ab"), + blobHash: bytes32("cd"), + prover: Alice, + blockId: 10, + isContesting: true, // skips all verification when true + blobUsed: false + }); + + // Transition + TaikoData.Transition memory transition = TaikoData.Transition({ + parentHash: bytes32(0), + blockHash: bytes32(0), + signalRoot: bytes32(0), + graffiti: bytes32(0) + }); + + // TierProof + TaikoData.TierProof memory proof = TaikoData.TierProof({ + tier: 0, + data: "" + }); + + // `verifyProof()` + pv.verifyProof(ctx, transition, proof); + } + + // Test `verifyProof()` with `isBlobUsed = true` + function test_verifyProof_isBlobUsed() external { + // Context + IVerifier.Context memory ctx = IVerifier.Context({ + metaHash: bytes32("ab"), + blobHash: bytes32("cd"), + prover: Alice, + blockId: 10, + isContesting: false, + blobUsed: true + }); + + // Transition + TaikoData.Transition memory transition = TaikoData.Transition({ + parentHash: bytes32(0), + blockHash: bytes32(0), + signalRoot: bytes32(0), + graffiti: bytes32(0) + }); + + // TierProof + bytes1[48] memory point; + PseZkVerifier.PointProof memory pointProof = PseZkVerifier.PointProof({ + txListHash: bytes32(0), + pointValue: 10, + pointCommitment: point, + pointProof: point + }); + + bytes32 instance = pv.calcInstance(transition, ctx.prover, ctx.metaHash, pointProof.txListHash, pointProof.pointValue); + bytes memory instanceWords = abi.encodePacked(bytes16(0), bytes16(instance), bytes16(0), bytes16(uint128(uint256(instance)))); + bytes memory zkp = abi.encodePacked(instanceWords, abi.encode(keccak256("taiko"))); + + PseZkVerifier.ZkEvmProof memory zkProof = PseZkVerifier.ZkEvmProof({ + verifierId: mockPlonkVerifierId, + zkp: zkp, + pointProof: abi.encode(pointProof) + }); + + TaikoData.TierProof memory proof = TaikoData.TierProof({ + tier: 0, + data: abi.encode(zkProof) + }); + + // `verifyProof()` + vm.expectRevert(Lib4844.EVAL_FAILED_2.selector); + pv.verifyProof(ctx, transition, proof); + } + + // Test `verifyProof()` without blob, happy path + function test_verifyProof() external { + // Context + IVerifier.Context memory ctx = IVerifier.Context({ + metaHash: bytes32("ab"), + blobHash: bytes32("cd"), + prover: Alice, + blockId: 10, + isContesting: false, + blobUsed: false + }); + + // Transition + TaikoData.Transition memory transition = TaikoData.Transition({ + parentHash: bytes32("12"), + blockHash: bytes32("23"), + signalRoot: bytes32("34"), + graffiti: bytes32("1234") + }); + + // TierProof + bytes32 instance = pv.calcInstance(transition, ctx.prover, ctx.metaHash, ctx.blobHash, 0); + bytes memory instanceWords = abi.encodePacked(bytes16(0), bytes16(instance), bytes16(0), bytes16(uint128(uint256(instance)))); + bytes memory zkp = abi.encodePacked(instanceWords, abi.encode(keccak256("taiko"))); + + PseZkVerifier.ZkEvmProof memory zkProof = PseZkVerifier.ZkEvmProof({ + verifierId: mockPlonkVerifierId, + zkp: zkp, + pointProof: "" + }); + + TaikoData.TierProof memory proof = TaikoData.TierProof({ + tier: 0, + data: abi.encode(zkProof) + }); + + // `verifyProof()` + pv.verifyProof(ctx, transition, proof); + } + + // Test `verifyProof()` without blob, invalid encoding of ZkEvmProof + function test_verifyProof_invalidEncodingZkEvmProof() external { + // Context + IVerifier.Context memory ctx = IVerifier.Context({ + metaHash: bytes32("ab"), + blobHash: bytes32("cd"), + prover: Alice, + blockId: 10, + isContesting: false, + blobUsed: false + }); + + // Transition + TaikoData.Transition memory transition = TaikoData.Transition({ + parentHash: bytes32("12"), + blockHash: bytes32("23"), + signalRoot: bytes32("34"), + graffiti: bytes32("1234") + }); + + // TierProof + TaikoData.TierProof memory proof = TaikoData.TierProof({ + tier: 0, + data: abi.encode(uint256(0)) + }); + + // `verifyProof()` + vm.expectRevert(); + pv.verifyProof(ctx, transition, proof); + } + + // Test `verifyProof()` without blob, invalid instance first part + function test_verifyProof_invalidInstanceA() external { + // Context + IVerifier.Context memory ctx = IVerifier.Context({ + metaHash: bytes32("ab"), + blobHash: bytes32("cd"), + prover: Alice, + blockId: 10, + isContesting: false, + blobUsed: false + }); + + // Transition + TaikoData.Transition memory transition = TaikoData.Transition({ + parentHash: bytes32("12"), + blockHash: bytes32("23"), + signalRoot: bytes32("34"), + graffiti: bytes32("1234") + }); + + // TierProof + bytes32 instance = pv.calcInstance(transition, ctx.prover, ctx.metaHash, ctx.blobHash, 0); + bytes memory instanceWords = abi.encodePacked(bytes16(0), bytes16(0), bytes16(0), bytes16(uint128(uint256(instance)))); + bytes memory zkp = abi.encodePacked(instanceWords, abi.encode(keccak256("taiko"))); + + PseZkVerifier.ZkEvmProof memory zkProof = PseZkVerifier.ZkEvmProof({ + verifierId: mockPlonkVerifierId, + zkp: zkp, + pointProof: "" + }); + + TaikoData.TierProof memory proof = TaikoData.TierProof({ + tier: 0, + data: abi.encode(zkProof) + }); + + // `verifyProof()` + vm.expectRevert(PseZkVerifier.L1_INVALID_PROOF.selector); + pv.verifyProof(ctx, transition, proof); + } + + // Test `verifyProof()` without blob, invalid instance second part + function test_verifyProof_invalidInstanceB() external { + // Context + IVerifier.Context memory ctx = IVerifier.Context({ + metaHash: bytes32("ab"), + blobHash: bytes32("cd"), + prover: Alice, + blockId: 10, + isContesting: false, + blobUsed: false + }); + + // Transition + TaikoData.Transition memory transition = TaikoData.Transition({ + parentHash: bytes32("12"), + blockHash: bytes32("23"), + signalRoot: bytes32("34"), + graffiti: bytes32("1234") + }); + + // TierProof + bytes32 instance = pv.calcInstance(transition, ctx.prover, ctx.metaHash, ctx.blobHash, 0); + bytes memory instanceWords = abi.encodePacked(bytes16(0), bytes16(0), bytes16(instance), bytes16(0)); + bytes memory zkp = abi.encodePacked(instanceWords, abi.encode(keccak256("taiko"))); + + PseZkVerifier.ZkEvmProof memory zkProof = PseZkVerifier.ZkEvmProof({ + verifierId: mockPlonkVerifierId, + zkp: zkp, + pointProof: "" + }); + + TaikoData.TierProof memory proof = TaikoData.TierProof({ + tier: 0, + data: abi.encode(zkProof) + }); + + // `verifyProof()` + vm.expectRevert(PseZkVerifier.L1_INVALID_PROOF.selector); + pv.verifyProof(ctx, transition, proof); + } + + // Test `verifyProof()` without blob, zkp less than 64 bytes + function test_verifyProof_invalidZkpLength() external { + // Context + IVerifier.Context memory ctx = IVerifier.Context({ + metaHash: bytes32("ab"), + blobHash: bytes32("cd"), + prover: Alice, + blockId: 10, + isContesting: false, + blobUsed: false + }); + + // Transition + TaikoData.Transition memory transition = TaikoData.Transition({ + parentHash: bytes32("12"), + blockHash: bytes32("23"), + signalRoot: bytes32("34"), + graffiti: bytes32("1234") + }); + + // TierProof + bytes memory zkp = abi.encodePacked("invalid"); + + PseZkVerifier.ZkEvmProof memory zkProof = PseZkVerifier.ZkEvmProof({ + verifierId: mockPlonkVerifierId, + zkp: zkp, + pointProof: "" + }); + + TaikoData.TierProof memory proof = TaikoData.TierProof({ + tier: 0, + data: abi.encode(zkProof) + }); + + // `verifyProof()` + vm.expectRevert("slice_outOfBounds"); + pv.verifyProof(ctx, transition, proof); + } + + // Test `verifyProof()` without blob, invalid verifier ID + function test_verifyProof_invalidVerifierId() external { + // Context + IVerifier.Context memory ctx = IVerifier.Context({ + metaHash: bytes32("ab"), + blobHash: bytes32("cd"), + prover: Alice, + blockId: 10, + isContesting: false, + blobUsed: false + }); + + // Transition + TaikoData.Transition memory transition = TaikoData.Transition({ + parentHash: bytes32("12"), + blockHash: bytes32("23"), + signalRoot: bytes32("34"), + graffiti: bytes32("1234") + }); + + // TierProof + bytes32 instance = pv.calcInstance(transition, ctx.prover, ctx.metaHash, ctx.blobHash, 0); + bytes memory instanceWords = abi.encodePacked(bytes16(0), bytes16(instance), bytes16(0), bytes16(uint128(uint256(instance)))); + bytes memory zkp = abi.encodePacked(instanceWords, abi.encode(keccak256("taiko"))); + + PseZkVerifier.ZkEvmProof memory zkProof = PseZkVerifier.ZkEvmProof({ + verifierId: 999, // invalid + zkp: zkp, + pointProof: "" + }); + + TaikoData.TierProof memory proof = TaikoData.TierProof({ + tier: 0, + data: abi.encode(zkProof) + }); + + // `verifyProof()` + vm.expectRevert(); + pv.verifyProof(ctx, transition, proof); + } + + // Test `verifyProof()` without blob, PLONK verifier reverts + function test_verifyProof_plonkVerifierRevert() external { + // Context + IVerifier.Context memory ctx = IVerifier.Context({ + metaHash: bytes32("ab"), + blobHash: bytes32("cd"), + prover: Alice, + blockId: 10, + isContesting: false, + blobUsed: false + }); + + // Transition + TaikoData.Transition memory transition = TaikoData.Transition({ + parentHash: bytes32("12"), + blockHash: bytes32("23"), + signalRoot: bytes32("34"), + graffiti: bytes32("1234") + }); + + // TierProof + bytes32 instance = pv.calcInstance(transition, ctx.prover, ctx.metaHash, ctx.blobHash, 0); + bytes memory instanceWords = abi.encodePacked(bytes16(0), bytes16(instance), bytes16(0), bytes16(uint128(uint256(instance)))); + bytes memory zkp = abi.encodePacked(instanceWords, abi.encode(keccak256("taiko"))); + + PseZkVerifier.ZkEvmProof memory zkProof = PseZkVerifier.ZkEvmProof({ + verifierId: mockPlonkVerifierId, + zkp: zkp, + pointProof: "" + }); + + TaikoData.TierProof memory proof = TaikoData.TierProof({ + tier: 0, + data: abi.encode(zkProof) + }); + + // Tell verifier to revert + MockPlonkVerifier(mockPlonkVerifier).setShouldRevert(true); + + // `verifyProof()` + vm.expectRevert(PseZkVerifier.L1_INVALID_PROOF.selector); + pv.verifyProof(ctx, transition, proof); + } + + // Test `verifyProof()` without blob, PLONK verifier returns the wrong length + function test_verifyProof_plonkVerifierInvalidLength() external { + // Context + IVerifier.Context memory ctx = IVerifier.Context({ + metaHash: bytes32("ab"), + blobHash: bytes32("cd"), + prover: Alice, + blockId: 10, + isContesting: false, + blobUsed: false + }); + + // Transition + TaikoData.Transition memory transition = TaikoData.Transition({ + parentHash: bytes32("12"), + blockHash: bytes32("23"), + signalRoot: bytes32("34"), + graffiti: bytes32("1234") + }); + + // TierProof + bytes32 instance = pv.calcInstance(transition, ctx.prover, ctx.metaHash, ctx.blobHash, 0); + bytes memory instanceWords = abi.encodePacked(bytes16(0), bytes16(instance), bytes16(0), bytes16(uint128(uint256(instance)))); + bytes memory zkp = abi.encodePacked(instanceWords, "Hi"); + + PseZkVerifier.ZkEvmProof memory zkProof = PseZkVerifier.ZkEvmProof({ + verifierId: mockPlonkVerifierId, + zkp: zkp, + pointProof: "" + }); + + TaikoData.TierProof memory proof = TaikoData.TierProof({ + tier: 0, + data: abi.encode(zkProof) + }); + + // `verifyProof()` + vm.expectRevert(PseZkVerifier.L1_INVALID_PROOF.selector); + pv.verifyProof(ctx, transition, proof); + } + + // Test `verifyProof()` without blob, PLONK verifier returns the wrong 32 bytes + function test_verifyProof_plonkVerifierInvalidRetrun() external { + // Context + IVerifier.Context memory ctx = IVerifier.Context({ + metaHash: bytes32("ab"), + blobHash: bytes32("cd"), + prover: Alice, + blockId: 10, + isContesting: false, + blobUsed: false + }); + + // Transition + TaikoData.Transition memory transition = TaikoData.Transition({ + parentHash: bytes32("12"), + blockHash: bytes32("23"), + signalRoot: bytes32("34"), + graffiti: bytes32("1234") + }); + + // TierProof + bytes32 instance = pv.calcInstance(transition, ctx.prover, ctx.metaHash, ctx.blobHash, 0); + bytes memory instanceWords = abi.encodePacked(bytes16(0), bytes16(instance), bytes16(0), bytes16(uint128(uint256(instance)))); + bytes memory zkp = abi.encodePacked(instanceWords, bytes32("Hi")); + + PseZkVerifier.ZkEvmProof memory zkProof = PseZkVerifier.ZkEvmProof({ + verifierId: mockPlonkVerifierId, + zkp: zkp, + pointProof: "" + }); + + TaikoData.TierProof memory proof = TaikoData.TierProof({ + tier: 0, + data: abi.encode(zkProof) + }); + + // `verifyProof()` + vm.expectRevert(PseZkVerifier.L1_INVALID_PROOF.selector); + pv.verifyProof(ctx, transition, proof); + } +} diff --git a/packages/protocol/test/verifiers/SgxVerifier.t.sol b/packages/protocol/test/verifiers/SgxVerifier.t.sol index b903d1ac704..8081029ae68 100644 --- a/packages/protocol/test/verifiers/SgxVerifier.t.sol +++ b/packages/protocol/test/verifiers/SgxVerifier.t.sol @@ -9,6 +9,10 @@ contract TestSgxVerifier is TaikoL1TestBase, AttestationBase { vm.addr(0x9b1bb8cb3bdb539d0d1f03951d27f167f2d5443e7ef0d7ce745cd4ec619d3dd7); address internal SGX_Z = randAddress(); + address KNOWN_ADDRESS = address(0xAAAAAFE838B80D164535CD4d50058E456A4f9E16); + uint256 KNOWN_ADDRESS_PRIV_KEY = 0xde9b0c39e60bb0404347b588c6891947db2c873942b553d5d15c03ea30c04c63; + + function deployTaikoL1() internal override returns (TaikoL1) { return TaikoL1(payable(deployProxy({ name: "taiko", impl: address(new TaikoL1()), data: "" }))); @@ -24,14 +28,96 @@ contract TestSgxVerifier is TaikoL1TestBase, AttestationBase { registerAddress("automata_dcap_attestation", address(attestation)); } - function test_addInstancesByOwner() external { - address[] memory _instances = new address[](3); - _instances[0] = SGX_X_1; - _instances[1] = SGX_Y; - _instances[2] = SGX_Z; - sv.addInstances(_instances); + // Tests `addInstances()` from the owner + function test_addInstances() public { + uint256 startInstance = sv.nextInstanceId(); + + // Create instances to add + address[] memory instances = new address[](2); + instances[0] = Alice; + instances[1] = Bob; + + vm.expectEmit(true, true, true, true); + emit SgxVerifier.InstanceAdded(startInstance, instances[0], address(0), block.timestamp); + vm.expectEmit(true, true, true, true); + emit SgxVerifier.InstanceAdded(startInstance + 1, instances[1], address(0), block.timestamp); + + // `addInstances()` + uint256[] memory ids = sv.addInstances(instances); + + // Verification + assertEq(ids.length, 2, "Invalid IDs length"); + assertEq(ids[0], startInstance, "Invalid ID"); + assertEq(ids[1], startInstance + 1, "Invalid ID"); + + (address instanceAddr, uint64 instanceAddedAt) = sv.instances(startInstance); + assertEq(instanceAddr, instances[0], "Invalid instance address"); + assertEq(instanceAddedAt, block.timestamp, "Invalid instance addedAt"); + + (instanceAddr, instanceAddedAt) = sv.instances(startInstance + 1); + assertEq(instanceAddr, instances[1], "Invalid instance address"); + assertEq(instanceAddedAt, block.timestamp, "Invalid instance addedAt"); + + assertEq(sv.nextInstanceId(), startInstance + 2, "Invalid next instance ID"); + + // Setup for second `addInstances()` from the owner + address[] memory instances2 = new address[](2); + instances2[0] = Carol; + instances2[1] = David; + + vm.expectEmit(true, true, true, true); + emit SgxVerifier.InstanceAdded(startInstance + 2, instances2[0], address(0), block.timestamp); + vm.expectEmit(true, true, true, true); + emit SgxVerifier.InstanceAdded(startInstance + 3, instances2[1], address(0), block.timestamp); + + // `addInstances()` + ids = sv.addInstances(instances2); + + // Verification + assertEq(ids.length, 2, "Invalid IDs length"); + assertEq(ids[0], startInstance + 2, "Invalid ID"); + assertEq(ids[1], startInstance + 3, "Invalid ID"); + + (instanceAddr, instanceAddedAt) = sv.instances(startInstance + 2); + assertEq(instanceAddr, instances2[0], "Invalid instance address"); + assertEq(instanceAddedAt, block.timestamp, "Invalid instance addedAt"); + + (instanceAddr, instanceAddedAt) = sv.instances(startInstance + 3); + assertEq(instanceAddr, instances2[1], "Invalid instance address"); + assertEq(instanceAddedAt, block.timestamp, "Invalid instance addedAt"); + + assertEq(sv.nextInstanceId(), startInstance + 4, "Invalid next instance ID"); + + vm.stopPrank(); } + // Tests `addInstances()` from the owner when there is a zero address + function test_addInstances_zeroAddress() external { + // Create instances to add + address[] memory instances = new address[](2); + instances[0] = Alice; + instances[1] = address(0); + + // `addInstances()` + vm.expectRevert(SgxVerifier.SGX_INVALID_INSTANCE.selector); + sv.addInstances(instances); + + vm.stopPrank(); + } + + // Tests `addInstances()` from the owner with duplicates + function test_addInstances_duplicates() external { + // Create instances to add + address[] memory instances = new address[](2); + instances[0] = Alice; + instances[1] = Alice; // invalid as duplicate isntance + + // `addInstances()` + vm.expectRevert(SgxVerifier.SGX_ALREADY_ATTESTED.selector); + sv.addInstances(instances); + } + + function test_addInstancesByOwner_WithoutOwnerRole() external { address[] memory _instances = new address[](3); _instances[0] = SGX_X_0; @@ -77,25 +163,258 @@ contract TestSgxVerifier is TaikoL1TestBase, AttestationBase { sv.registerInstance(v3quote); } - function _getSignature( - address _newInstance, - address[] memory _instances, - uint256 privKey - ) - private - view - returns (bytes memory signature) - { - bytes32 digest = keccak256( - abi.encode( - "ADD_INSTANCES", - ITaikoL1(L1).getConfig().chainId, - address(sv), - _newInstance, - _instances - ) - ); - (uint8 v, bytes32 r, bytes32 s) = vm.sign(privKey, digest); - signature = abi.encodePacked(r, s, v); + + // Test `verifyProof()` happy path + function test_verifyProof() external { + uint32 id = uint32(sv.nextInstanceId()); + + // `addInstances()` add an alice instance + address[] memory instances = new address[](1); + instances[0] = KNOWN_ADDRESS; + sv.addInstances(instances); + + vm.stopPrank(); + + // Caller should be TaikoL1 contract + vm.startPrank(address(L1)); + + // Context + IVerifier.Context memory ctx = IVerifier.Context({ + metaHash: bytes32("ab"), + blobHash: bytes32("cd"), + prover: KNOWN_ADDRESS, + blockId: 10, + isContesting: false, + blobUsed: false + }); + + // Transition + TaikoData.Transition memory transition = TaikoData.Transition({ + parentHash: bytes32("12"), + blockHash: bytes32("34"), + signalRoot: bytes32("56"), + graffiti: bytes32("78") + }); + + // TierProof + address newInstance = address(0x33); + + bytes32 signedHash = sv.getSignedHash(transition, newInstance, ctx.prover, ctx.metaHash); + (uint8 v, bytes32 r, bytes32 s) = vm.sign(KNOWN_ADDRESS_PRIV_KEY, signedHash); + bytes memory signature = abi.encodePacked(r, s, v); + + bytes memory data = abi.encodePacked(id, newInstance, signature); + TaikoData.TierProof memory proof = TaikoData.TierProof({ + tier: 100, + data: data + }); + + vm.warp(block.timestamp + 5); + + vm.expectEmit(true, true, true, true); + emit SgxVerifier.InstanceAdded(id, newInstance, KNOWN_ADDRESS, block.timestamp); + + // `verifyProof()` + sv.verifyProof(ctx, transition, proof); + + // Verification + (address instanceAddr, uint64 instanceAddedAt) = sv.instances(id); + assertEq(instanceAddr, newInstance, 'Invalid instance address'); + assertEq(instanceAddedAt, block.timestamp, 'Invalid instance addedAt'); + + vm.stopPrank(); + } + + // Test `verifyProof()` when contesting + function test_verifyProof_isContesting() external { + vm.startPrank(address(L1)); + + // Context + IVerifier.Context memory ctx = IVerifier.Context({ + metaHash: bytes32("ab"), + blobHash: bytes32("cd"), + prover: Alice, + blockId: 10, + isContesting: true, // skips all verification when true + blobUsed: false + }); + + // Transition + TaikoData.Transition memory transition = TaikoData.Transition({ + parentHash: bytes32("12"), + blockHash: bytes32("34"), + signalRoot: bytes32("56"), + graffiti: bytes32("78") + }); + + // TierProof + TaikoData.TierProof memory proof = TaikoData.TierProof({ + tier: 0, + data: "" + }); + + // `verifyProof()` + sv.verifyProof(ctx, transition, proof); + + vm.stopPrank(); + } + + // Test `verifyProof()` invalid proof length + function test_verifyProof_invalidProofLength() external { + vm.startPrank(address(L1)); + + // Context + IVerifier.Context memory ctx = IVerifier.Context({ + metaHash: bytes32("ab"), + blobHash: bytes32("cd"), + prover: Alice, + blockId: 10, + isContesting: false, + blobUsed: false + }); + + // Transition + TaikoData.Transition memory transition = TaikoData.Transition({ + parentHash: bytes32("12"), + blockHash: bytes32("34"), + signalRoot: bytes32("56"), + graffiti: bytes32("78") + }); + + // TierProof + TaikoData.TierProof memory proof = TaikoData.TierProof({ + tier: 0, + data: new bytes(80) // invalid length + }); + + // `verifyProof()` + vm.expectRevert(SgxVerifier.SGX_INVALID_PROOF.selector); + sv.verifyProof(ctx, transition, proof); + } + + // Test `verifyProof()` invalid signature + function test_verifyProof_invalidSignature() public { + vm.startPrank(address(L1)); + + // Context + IVerifier.Context memory ctx = IVerifier.Context({ + metaHash: bytes32("ab"), + blobHash: bytes32("cd"), + prover: Alice, + blockId: 10, + isContesting: false, + blobUsed: false + }); + + // Transition + TaikoData.Transition memory transition = TaikoData.Transition({ + parentHash: bytes32("12"), + blockHash: bytes32("34"), + signalRoot: bytes32("56"), + graffiti: bytes32("78") + }); + + // TierProof + uint32 id = 0; + address newInstance = address(0x33); + bytes memory signature = new bytes(65); // invalid length + bytes memory data = abi.encodePacked(id, newInstance, signature); + TaikoData.TierProof memory proof = TaikoData.TierProof({ + tier: 0, + data: data + }); + + // `verifyProof()` + vm.expectRevert('ECDSA: invalid signature'); + sv.verifyProof(ctx, transition, proof); + + vm.stopPrank(); + } + + // Test `verifyProof()` invalid instance + function test_verifyProof_invalidInstance() public { + vm.startPrank(address(L1)); + + uint32 id = uint32(sv.nextInstanceId()); + + // Context + IVerifier.Context memory ctx = IVerifier.Context({ + metaHash: bytes32("ab"), + blobHash: bytes32("cd"), + prover: Alice, + blockId: 10, + isContesting: false, + blobUsed: false + }); + + // Transition + TaikoData.Transition memory transition = TaikoData.Transition({ + parentHash: bytes32("12"), + blockHash: bytes32("34"), + signalRoot: bytes32("56"), + graffiti: bytes32("78") + }); + + // TierProof + address newInstance = address(0x33); + + bytes32 signedHash = sv.getSignedHash(transition, newInstance, ctx.prover, ctx.metaHash); + (uint8 v, bytes32 r, bytes32 s) = vm.sign(KNOWN_ADDRESS_PRIV_KEY, signedHash); + bytes memory signature = abi.encodePacked(r, s, v); + + bytes memory data = abi.encodePacked(id, newInstance, signature); + TaikoData.TierProof memory proof = TaikoData.TierProof({ + tier: 0, + data: data + }); + + // `verifyProof()` + vm.expectRevert(SgxVerifier.SGX_INVALID_INSTANCE.selector); + sv.verifyProof(ctx, transition, proof); + + vm.stopPrank(); + } + + // Test `verifyProof()` call is not taiko or higher tier proof + function test_verifyProof_invalidCaller() public { + vm.startPrank(Alice); // invalid caller + + // Context + IVerifier.Context memory ctx = IVerifier.Context({ + metaHash: bytes32("ab"), + blobHash: bytes32("cd"), + prover: Alice, + blockId: 10, + isContesting: false, + blobUsed: false + }); + + // Transition + TaikoData.Transition memory transition = TaikoData.Transition({ + parentHash: bytes32("12"), + blockHash: bytes32("34"), + signalRoot: bytes32("56"), + graffiti: bytes32("78") + }); + + // TierProof + uint32 id = 0; + address newInstance = address(0x33); + + bytes32 signedHash = sv.getSignedHash(transition, newInstance, ctx.prover, ctx.metaHash); + (uint8 v, bytes32 r, bytes32 s) = vm.sign(KNOWN_ADDRESS_PRIV_KEY, signedHash); + bytes memory signature = abi.encodePacked(r, s, v); + + bytes memory data = abi.encodePacked(id, newInstance, signature); + TaikoData.TierProof memory proof = TaikoData.TierProof({ + tier: 100, + data: data + }); + + // `verifyProof()` + vm.expectRevert(AddressResolver.RESOLVER_DENIED.selector); + sv.verifyProof(ctx, transition, proof); + + vm.stopPrank(); } } From 480d61b31c9ec9aabbfabe5ee3c2a2ffdf739902 Mon Sep 17 00:00:00 2001 From: Daniel Wang <99078276+dantaik@users.noreply.github.com> Date: Thu, 8 Feb 2024 16:56:26 +0800 Subject: [PATCH 2/3] refactor(protocol): format test code and fix license (#15682) --- .../protocol/test/L1/gov/TaikoGovernor.t.sol | 99 +++++++---- packages/protocol/test/L2/LibL2Signer.sol | 13 -- .../AutomataDcapV3AttestationTest.t.sol | 2 +- .../common/AttestationBase.t.sol | 2 +- .../utils/DcapTestUtils.t.sol | 2 +- .../utils/V3QuoteParseUtils.t.sol | 2 +- .../protocol/test/common/AddressManager.t.sol | 11 +- .../test/common/AddressResolver.t.sol | 30 +--- .../test/common/AuthorizableContract.t.sol | 29 +--- .../test/common/erc20/FreeMintERC20.sol | 13 -- .../common/erc20/MayFailFreeMintERC20.sol | 13 -- .../test/libs/LibFixedPointMath.t.sol | 2 +- .../protocol/test/mocks/MockPlonkVerifier.sol | 5 +- .../test/thirdparty/LibFixedPointMath.t.sol | 28 +-- .../test/thirdparty/optimisim/Bytes.t.sol | 130 +++++++------- .../thirdparty/optimisim/rlp/RLPReader.t.sol | 33 ++-- .../optimisim/trie/SecureMerkleTrie.t.sol | 117 +++++++------ .../test/verifiers/GuardianVerifier.t.sol | 15 +- .../test/verifiers/PseZkVerifier.t.sol | 163 +++++++----------- .../protocol/test/verifiers/SgxVerifier.t.sol | 47 ++--- 20 files changed, 346 insertions(+), 410 deletions(-) diff --git a/packages/protocol/test/L1/gov/TaikoGovernor.t.sol b/packages/protocol/test/L1/gov/TaikoGovernor.t.sol index 65a80f1c5fd..729f893d6d8 100644 --- a/packages/protocol/test/L1/gov/TaikoGovernor.t.sol +++ b/packages/protocol/test/L1/gov/TaikoGovernor.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: UNLICENSED +// SPDX-License-Identifier: MIT pragma solidity 0.8.24; import "../TaikoL1TestBase.sol"; @@ -48,9 +48,7 @@ contract TestTaikoGovernor is TaikoL1TestBase { ); // init TaikoGovernor - taikoGovernor.init(tko, taikoTimelockController); // not sure if the token should be TaikoToken here - - + taikoGovernor.init(tko, taikoTimelockController); // Alice delegate voting power to self vm.startPrank(Alice); tko.delegate(Alice); @@ -59,9 +57,15 @@ contract TestTaikoGovernor is TaikoL1TestBase { address owner = taikoTimelockController.owner(); vm.startPrank(owner); // Owner set access controls for timelock controller - taikoTimelockController.grantRole(taikoTimelockController.PROPOSER_ROLE(), address(taikoGovernor)); - taikoTimelockController.grantRole(taikoTimelockController.EXECUTOR_ROLE(), address(taikoGovernor)); - taikoTimelockController.grantRole(taikoTimelockController.CANCELLER_ROLE(), address(taikoGovernor)); + taikoTimelockController.grantRole( + taikoTimelockController.PROPOSER_ROLE(), address(taikoGovernor) + ); + taikoTimelockController.grantRole( + taikoTimelockController.EXECUTOR_ROLE(), address(taikoGovernor) + ); + taikoTimelockController.grantRole( + taikoTimelockController.CANCELLER_ROLE(), address(taikoGovernor) + ); // Owner delegate voting power to self tko.delegate(owner); @@ -70,42 +74,60 @@ contract TestTaikoGovernor is TaikoL1TestBase { uint256 proposalThreshold = taikoGovernor.proposalThreshold(); tko.transfer(Alice, proposalThreshold * 2); tko.transfer(Bob, proposalThreshold * 5); - vm.roll(block.number + 1); // increase block number to help facilitate snapshots in TaikoToken + vm.roll(block.number + 1); // increase block number to help facilitate snapshots in + // TaikoToken vm.stopPrank(); } function test_init() public { // GovernorVotesQuorumFractionUpgradeable - assertEq(taikoGovernor.quorumNumerator(), 4, 'Incorrect initial quorum numerator'); - assertEq(taikoGovernor.quorumNumerator(block.number), 4, 'Incorrect initial block quorum numerator'); - assertEq(taikoGovernor.quorumDenominator(), 100, 'Incorrect quorum denominator'); + assertEq(taikoGovernor.quorumNumerator(), 4, "Incorrect initial quorum numerator"); + assertEq( + taikoGovernor.quorumNumerator(block.number), + 4, + "Incorrect initial block quorum numerator" + ); + assertEq(taikoGovernor.quorumDenominator(), 100, "Incorrect quorum denominator"); // GovernorUpgradeable - assertEq(taikoGovernor.name(), 'TaikoGovernor', 'Incorrect name'); - assertEq(taikoGovernor.version(), '1', 'Incorrect version'); + assertEq(taikoGovernor.name(), "TaikoGovernor", "Incorrect name"); + assertEq(taikoGovernor.version(), "1", "Incorrect version"); // GovernorVotesUpgradeable - assertEq(address(taikoGovernor.token()), address(tko), 'Incorrect token'); + assertEq(address(taikoGovernor.token()), address(tko), "Incorrect token"); // GovernorCompatibilityBravoUpgradeable - assertEq(taikoGovernor.COUNTING_MODE(), 'support=bravo&quorum=bravo', 'Incorrect counting mode'); + assertEq( + taikoGovernor.COUNTING_MODE(), "support=bravo&quorum=bravo", "Incorrect counting mode" + ); // GovernorTimelockControlUpgradeable - assertEq(taikoGovernor.timelock(), address(taikoTimelockController), 'Incorrect timelock'); + assertEq(taikoGovernor.timelock(), address(taikoTimelockController), "Incorrect timelock"); // Interfaces - assertEq(taikoGovernor.supportsInterface(type(IGovernorTimelockUpgradeable).interfaceId), true, 'Incorrect supports interface'); - assertEq(taikoGovernor.supportsInterface(type(IGovernorUpgradeable).interfaceId), true, 'Incorrect supports interface'); - assertEq(taikoGovernor.supportsInterface(type(IERC1155ReceiverUpgradeable).interfaceId), true, 'Incorrect supports interface'); + assertEq( + taikoGovernor.supportsInterface(type(IGovernorTimelockUpgradeable).interfaceId), + true, + "Incorrect supports interface" + ); + assertEq( + taikoGovernor.supportsInterface(type(IGovernorUpgradeable).interfaceId), + true, + "Incorrect supports interface" + ); + assertEq( + taikoGovernor.supportsInterface(type(IERC1155ReceiverUpgradeable).interfaceId), + true, + "Incorrect supports interface" + ); // TaikoGovernor - assertEq(taikoGovernor.votingDelay(), 7200, 'Incorrect voting delay'); - assertEq(taikoGovernor.votingPeriod(), 50_400, 'Incorrect voting period'); - assertEq(taikoGovernor.proposalThreshold(), 100_000 ether, 'Incorrect proposal threshold'); + assertEq(taikoGovernor.votingDelay(), 7200, "Incorrect voting delay"); + assertEq(taikoGovernor.votingPeriod(), 50_400, "Incorrect voting period"); + assertEq(taikoGovernor.proposalThreshold(), 100_000 ether, "Incorrect proposal threshold"); } - // Tests `propose()` function test_propose() public { // Parameters for `TaikoGovernor.propose()` @@ -117,7 +139,7 @@ contract TestTaikoGovernor is TaikoL1TestBase { bytes[] memory calldatas = new bytes[](1); - string memory description = 'Send alice an ether'; + string memory description = "Send alice an ether"; address proposer = Alice; vm.startPrank(proposer); @@ -125,7 +147,8 @@ contract TestTaikoGovernor is TaikoL1TestBase { // Prepare for event emission uint256 startBlock = block.number + taikoGovernor.votingDelay(); uint256 endBlock = startBlock + taikoGovernor.votingPeriod(); - uint256 calculatedProposalId = taikoGovernor.hashProposal(targets, values, calldatas, keccak256(bytes(description))); + uint256 calculatedProposalId = + taikoGovernor.hashProposal(targets, values, calldatas, keccak256(bytes(description))); vm.expectEmit(true, true, true, true); emit IGovernor.ProposalCreated( @@ -145,10 +168,18 @@ contract TestTaikoGovernor is TaikoL1TestBase { vm.stopPrank(); // Validate proposal - assertEq(proposalId, calculatedProposalId, 'Proposal does not have the correct ID'); - assertEq(taikoGovernor.state(proposalId) == IGovernorUpgradeable.ProposalState.Pending, true, 'Incorrect proposal state'); - assertEq(taikoGovernor.proposalSnapshot(proposalId), startBlock, 'Incorrect proposal snapshot'); - assertEq(taikoGovernor.proposalDeadline(proposalId), endBlock, 'Incorrect proposal deadline'); + assertEq(proposalId, calculatedProposalId, "Proposal does not have the correct ID"); + assertEq( + taikoGovernor.state(proposalId) == IGovernorUpgradeable.ProposalState.Pending, + true, + "Incorrect proposal state" + ); + assertEq( + taikoGovernor.proposalSnapshot(proposalId), startBlock, "Incorrect proposal snapshot" + ); + assertEq( + taikoGovernor.proposalDeadline(proposalId), endBlock, "Incorrect proposal deadline" + ); } // Tests `castVote()`, `queue()` and `execute()` @@ -160,11 +191,11 @@ contract TestTaikoGovernor is TaikoL1TestBase { uint256[] memory values = new uint256[](1); values[0] = 1 ether; bytes[] memory calldatas = new bytes[](1); - string memory description = 'Send alice an ether'; + string memory description = "Send alice an ether"; bytes32 descriptionHash = keccak256(bytes(description)); // Send the values to the timelock controller for execute - (bool success,) = address(taikoTimelockController).call{value: values[0]}(""); + (bool success,) = address(taikoTimelockController).call{ value: values[0] }(""); assertEq(success, true, "Transfer funds unsuccessful"); @@ -193,7 +224,9 @@ contract TestTaikoGovernor is TaikoL1TestBase { vm.warp(eta + 1); // Prepare execute event - bytes32 timelockId = taikoTimelockController.hashOperationBatch(targets, values, calldatas, 0, descriptionHash); + bytes32 timelockId = taikoTimelockController.hashOperationBatch( + targets, values, calldatas, 0, descriptionHash + ); vm.expectEmit(true, true, true, true); emit TimelockController.CallExecuted(timelockId, 0, targets[0], values[0], calldatas[0]); @@ -203,4 +236,4 @@ contract TestTaikoGovernor is TaikoL1TestBase { vm.stopPrank(); } -} \ No newline at end of file +} diff --git a/packages/protocol/test/L2/LibL2Signer.sol b/packages/protocol/test/L2/LibL2Signer.sol index 9fce6048b82..52f29867589 100644 --- a/packages/protocol/test/L2/LibL2Signer.sol +++ b/packages/protocol/test/L2/LibL2Signer.sol @@ -1,17 +1,4 @@ // SPDX-License-Identifier: MIT -// _____ _ _ _ _ -// |_ _|_ _(_) |_____ | | __ _| |__ ___ -// | |/ _` | | / / _ \ | |__/ _` | '_ (_-< -// |_|\__,_|_|_\_\___/ |____\__,_|_.__/__/ -// -// Email: security@taiko.xyz -// Website: https://taiko.xyz -// GitHub: https://github.com/taikoxyz -// Discord: https://discord.gg/taikoxyz -// Twitter: https://twitter.com/taikoxyz -// Blog: https://mirror.xyz/labs.taiko.eth -// Youtube: https://www.youtube.com/@taikoxyz - pragma solidity 0.8.24; import "../thirdparty/LibUint512Math.sol"; diff --git a/packages/protocol/test/automata-attestation/AutomataDcapV3AttestationTest.t.sol b/packages/protocol/test/automata-attestation/AutomataDcapV3AttestationTest.t.sol index f37ed790f10..d67d438c44c 100644 --- a/packages/protocol/test/automata-attestation/AutomataDcapV3AttestationTest.t.sol +++ b/packages/protocol/test/automata-attestation/AutomataDcapV3AttestationTest.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: UNLICENSED +// SPDX-License-Identifier: MIT pragma solidity 0.8.24; import "forge-std/Test.sol"; diff --git a/packages/protocol/test/automata-attestation/common/AttestationBase.t.sol b/packages/protocol/test/automata-attestation/common/AttestationBase.t.sol index daa99bf8565..68c1a3cac9d 100644 --- a/packages/protocol/test/automata-attestation/common/AttestationBase.t.sol +++ b/packages/protocol/test/automata-attestation/common/AttestationBase.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: UNLICENSED +// SPDX-License-Identifier: MIT pragma solidity 0.8.24; import "forge-std/Test.sol"; diff --git a/packages/protocol/test/automata-attestation/utils/DcapTestUtils.t.sol b/packages/protocol/test/automata-attestation/utils/DcapTestUtils.t.sol index 7e6dbff65c0..a7045ec0360 100644 --- a/packages/protocol/test/automata-attestation/utils/DcapTestUtils.t.sol +++ b/packages/protocol/test/automata-attestation/utils/DcapTestUtils.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: UNLICENSED +// SPDX-License-Identifier: MIT pragma solidity ^0.8.13; import { TCBInfoStruct } from "../../../contracts/automata-attestation/lib/TCBInfoStruct.sol"; diff --git a/packages/protocol/test/automata-attestation/utils/V3QuoteParseUtils.t.sol b/packages/protocol/test/automata-attestation/utils/V3QuoteParseUtils.t.sol index cfc869cc550..6c3414125a1 100644 --- a/packages/protocol/test/automata-attestation/utils/V3QuoteParseUtils.t.sol +++ b/packages/protocol/test/automata-attestation/utils/V3QuoteParseUtils.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: UNLICENSED +// SPDX-License-Identifier: MIT pragma solidity ^0.8.13; import { V3Struct } from "../../../contracts/automata-attestation/lib/QuoteV3Auth/V3Struct.sol"; diff --git a/packages/protocol/test/common/AddressManager.t.sol b/packages/protocol/test/common/AddressManager.t.sol index d6636d4c266..f4470d43a64 100644 --- a/packages/protocol/test/common/AddressManager.t.sol +++ b/packages/protocol/test/common/AddressManager.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: UNLICENSED +// SPDX-License-Identifier: MIT pragma solidity 0.8.24; import "../L1/TaikoL1TestBase.sol"; @@ -27,11 +27,7 @@ contract TestAddressManager is TaikoL1TestBase { addressManager.setAddress(chainid, name, newAddress); // validation - assertEq( - addressManager.getAddress(chainid, name), - Bob, - "should return Bob address" - ); + assertEq(addressManager.getAddress(chainid, name), Bob, "should return Bob address"); } function test_setAddress_callerNotOwner() external { @@ -53,5 +49,4 @@ contract TestAddressManager is TaikoL1TestBase { "expected address should be TaikoL1" ); } - -} \ No newline at end of file +} diff --git a/packages/protocol/test/common/AddressResolver.t.sol b/packages/protocol/test/common/AddressResolver.t.sol index 16a9683af03..27f266c0828 100644 --- a/packages/protocol/test/common/AddressResolver.t.sol +++ b/packages/protocol/test/common/AddressResolver.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: UNLICENSED +// SPDX-License-Identifier: MIT pragma solidity 0.8.24; import "../L1/TaikoL1TestBase.sol"; @@ -17,46 +17,29 @@ contract TestAddressResolver is TaikoL1TestBase { function test_resolve() external { assertEq( - bridge.resolve( - uint64(block.chainid), - bytes32(bytes("tier_guardian")), - false - ), + bridge.resolve(uint64(block.chainid), bytes32(bytes("tier_guardian")), false), address(gv), "wrong guardianVerifier address" ); assertEq( - bridge.resolve( - uint64(block.chainid), - bytes32(bytes("tier_sgx")), - false - ), + bridge.resolve(uint64(block.chainid), bytes32(bytes("tier_sgx")), false), address(sv), " wrong sgxVerifier address" ); assertEq( - bridge.resolve( - uint64(block.chainid), - bytes32(bytes("tier_pse_zkevm")), - false - ), + bridge.resolve(uint64(block.chainid), bytes32(bytes("tier_pse_zkevm")), false), address(pv), "wrong pseZkVerifier address" ); } - // Tests `resolve()` revert on zero address function test_resolve_revertZeroAddress() external { bytes32 name = bytes32(bytes("signal_service")); vm.expectRevert( - abi.encodeWithSelector( - AddressResolver.RESOLVER_ZERO_ADDR.selector, - 666, - name - ) + abi.encodeWithSelector(AddressResolver.RESOLVER_ZERO_ADDR.selector, 666, name) ); bridge.resolve(uint64(666), name, false); @@ -70,5 +53,4 @@ contract TestAddressResolver is TaikoL1TestBase { " should return address(0)" ); } - -} \ No newline at end of file +} diff --git a/packages/protocol/test/common/AuthorizableContract.t.sol b/packages/protocol/test/common/AuthorizableContract.t.sol index d3f4368e5d6..2458d46bb9c 100644 --- a/packages/protocol/test/common/AuthorizableContract.t.sol +++ b/packages/protocol/test/common/AuthorizableContract.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: UNLICENSED +// SPDX-License-Identifier: MIT pragma solidity 0.8.24; import "../L1/TaikoL1TestBase.sol"; @@ -24,16 +24,8 @@ contract TestAuthorizableContract is TaikoL1TestBase { ss.authorize(Bob, bobLabel); // validation - assertEq( - ss.authorizedAddresses(Bob), - bobLabel, - "wrong Label" - ); - assertEq( - ss.isAuthorizedAs(Bob, bobLabel), - true, - "should return true" - ); + assertEq(ss.authorizedAddresses(Bob), bobLabel, "wrong Label"); + assertEq(ss.isAuthorizedAs(Bob, bobLabel), true, "should return true"); //stop prank vm.stopPrank(); @@ -72,16 +64,7 @@ contract TestAuthorizableContract is TaikoL1TestBase { // call authorize ss.authorize(Bob, bobLabel); - assertEq( - ss.isAuthorizedAs(Bob, bobLabel), - true, - "should return true" - ); - assertEq( - ss.isAuthorizedAs(Alice, 0), - false, - "should return false" - ); + assertEq(ss.isAuthorizedAs(Bob, bobLabel), true, "should return true"); + assertEq(ss.isAuthorizedAs(Alice, 0), false, "should return false"); } - -} \ No newline at end of file +} diff --git a/packages/protocol/test/common/erc20/FreeMintERC20.sol b/packages/protocol/test/common/erc20/FreeMintERC20.sol index b6183d7e754..7a099c1d270 100644 --- a/packages/protocol/test/common/erc20/FreeMintERC20.sol +++ b/packages/protocol/test/common/erc20/FreeMintERC20.sol @@ -1,17 +1,4 @@ // SPDX-License-Identifier: MIT -// _____ _ _ _ _ -// |_ _|_ _(_) |_____ | | __ _| |__ ___ -// | |/ _` | | / / _ \ | |__/ _` | '_ (_-< -// |_|\__,_|_|_\_\___/ |____\__,_|_.__/__/ -// -// Email: security@taiko.xyz -// Website: https://taiko.xyz -// GitHub: https://github.com/taikoxyz -// Discord: https://discord.gg/taikoxyz -// Twitter: https://twitter.com/taikoxyz -// Blog: https://mirror.xyz/labs.taiko.eth -// Youtube: https://www.youtube.com/@taikoxyz - pragma solidity 0.8.24; import "lib/openzeppelin-contracts/contracts/token/ERC20/ERC20.sol"; diff --git a/packages/protocol/test/common/erc20/MayFailFreeMintERC20.sol b/packages/protocol/test/common/erc20/MayFailFreeMintERC20.sol index cdcaa87e328..4f7f813ecf7 100644 --- a/packages/protocol/test/common/erc20/MayFailFreeMintERC20.sol +++ b/packages/protocol/test/common/erc20/MayFailFreeMintERC20.sol @@ -1,17 +1,4 @@ // SPDX-License-Identifier: MIT -// _____ _ _ _ _ -// |_ _|_ _(_) |_____ | | __ _| |__ ___ -// | |/ _` | | / / _ \ | |__/ _` | '_ (_-< -// |_|\__,_|_|_\_\___/ |____\__,_|_.__/__/ -// -// Email: security@taiko.xyz -// Website: https://taiko.xyz -// GitHub: https://github.com/taikoxyz -// Discord: https://discord.gg/taikoxyz -// Twitter: https://twitter.com/taikoxyz -// Blog: https://mirror.xyz/labs.taiko.eth -// Youtube: https://www.youtube.com/@taikoxyz - pragma solidity 0.8.24; import "lib/openzeppelin-contracts/contracts/token/ERC20/ERC20.sol"; diff --git a/packages/protocol/test/libs/LibFixedPointMath.t.sol b/packages/protocol/test/libs/LibFixedPointMath.t.sol index b66828ca26e..d06b368cb1a 100644 --- a/packages/protocol/test/libs/LibFixedPointMath.t.sol +++ b/packages/protocol/test/libs/LibFixedPointMath.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: UNLICENSED +// SPDX-License-Identifier: MIT // Some of the tests are taken from: // https://github.com/recmo/experiment-solexp/blob/main/src/test/FixedPointMathLib.t.sol pragma solidity 0.8.24; diff --git a/packages/protocol/test/mocks/MockPlonkVerifier.sol b/packages/protocol/test/mocks/MockPlonkVerifier.sol index 11cb23de808..4065fbdb22f 100644 --- a/packages/protocol/test/mocks/MockPlonkVerifier.sol +++ b/packages/protocol/test/mocks/MockPlonkVerifier.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: UNLICENSED +// SPDX-License-Identifier: MIT pragma solidity 0.8.24; import "../../contracts/thirdparty/optimism/Bytes.sol"; @@ -7,7 +7,6 @@ import "../../contracts/thirdparty/optimism/Bytes.sol"; contract MockPlonkVerifier { bool public _shouldRevert; - // Mock verifier that just returns what is sent in the proof after the first 64 bytes fallback(bytes calldata input) external returns (bytes memory) { require(!_shouldRevert, "We're going to revert here for fun :)"); @@ -18,4 +17,4 @@ contract MockPlonkVerifier { function setShouldRevert(bool shouldRevert) public { _shouldRevert = shouldRevert; } -} \ No newline at end of file +} diff --git a/packages/protocol/test/thirdparty/LibFixedPointMath.t.sol b/packages/protocol/test/thirdparty/LibFixedPointMath.t.sol index 8524239b8ce..917a31bc936 100644 --- a/packages/protocol/test/thirdparty/LibFixedPointMath.t.sol +++ b/packages/protocol/test/thirdparty/LibFixedPointMath.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: UNLICENSED +// SPDX-License-Identifier: MIT pragma solidity 0.8.24; import "../TaikoTest.sol"; @@ -6,18 +6,26 @@ import "../TaikoTest.sol"; /// @author Kirk Baird contract TestLibFixedPointMath is TaikoTest { function test_exp() external { - assertEq(LibFixedPointMath.exp(1e18), 2718281828459045235); // 2.718281828459045235 - assertEq(LibFixedPointMath.exp(2e18), 7389056098930650227); // 7.389056098930650227 - assertEq(LibFixedPointMath.exp(0), 1000000000000000000); // 1 - assertEq(LibFixedPointMath.exp(-1e18), 367879441171442321); // 0.3678794411714423216 - assertEq(LibFixedPointMath.exp(1), 1000000000000000001); //1.000000000000000001 - assertEq(LibFixedPointMath.exp(-1), 999999999999999999); //0.9999999999999999990 + assertEq(LibFixedPointMath.exp(1e18), 2_718_281_828_459_045_235); // 2.718281828459045235 + assertEq(LibFixedPointMath.exp(2e18), 7_389_056_098_930_650_227); // 7.389056098930650227 + assertEq(LibFixedPointMath.exp(0), 1_000_000_000_000_000_000); // 1 + assertEq(LibFixedPointMath.exp(-1e18), 367_879_441_171_442_321); // 0.3678794411714423216 + assertEq(LibFixedPointMath.exp(1), 1_000_000_000_000_000_001); //1.000000000000000001 + assertEq(LibFixedPointMath.exp(-1), 999_999_999_999_999_999); //0.9999999999999999990 // accurate up to 1e-16% - assertApproxEqRel(LibFixedPointMath.exp(135e18), 42633899483147210448936866880765989356468745853255281087440011736227864297277, 1); // 42633899483147210448936866880765989356468745853255281087440.011736227864297277 + assertApproxEqRel( + LibFixedPointMath.exp(135e18), + 42_633_899_483_147_210_448_936_866_880_765_989_356_468_745_853_255_281_087_440_011_736_227_864_297_277, + 1 + ); // 42633899483147210448936866880765989356468745853255281087440.011736227864297277 // accurate up to 1e-16% - assertApproxEqRel(LibFixedPointMath.exp(135_305_999_368_893_231_588), 57896044618658097649816762928942336782129491980154662247847962410455084893091, 1); // 57896044618658097649816762928942336782129491980154662247847.962410455084893091 + assertApproxEqRel( + LibFixedPointMath.exp(135_305_999_368_893_231_588), + 57_896_044_618_658_097_649_816_762_928_942_336_782_129_491_980_154_662_247_847_962_410_455_084_893_091, + 1 + ); // 57896044618658097649816762928942336782129491980154662247847.962410455084893091 assertEq(LibFixedPointMath.exp(-40e18), 4); @@ -27,6 +35,6 @@ contract TestLibFixedPointMath is TaikoTest { function test_exp_overflow() external { vm.expectRevert(LibFixedPointMath.Overflow.selector); - LibFixedPointMath.exp(135305999368893231589); // max input is 135305999368893231588 + LibFixedPointMath.exp(135_305_999_368_893_231_589); // max input is 135305999368893231588 } } diff --git a/packages/protocol/test/thirdparty/optimisim/Bytes.t.sol b/packages/protocol/test/thirdparty/optimisim/Bytes.t.sol index 371813e7004..d86e23aa9ef 100644 --- a/packages/protocol/test/thirdparty/optimisim/Bytes.t.sol +++ b/packages/protocol/test/thirdparty/optimisim/Bytes.t.sol @@ -1,16 +1,18 @@ -// SPDX-License-Identifier: UNLICENSED +// SPDX-License-Identifier: MIT pragma solidity 0.8.24; import "../../TaikoTest.sol"; /// @author Kirk Baird contract TestBytes is TaikoTest { - function test_toNibbles() external { // 20 Bytes input bytes memory someBytes = hex"0123456789012345678901234567890123456789"; bytes memory nibbles = Bytes.toNibbles(someBytes); - assertEq(hex"00010203040506070809000102030405060708090001020304050607080900010203040506070809", nibbles); + assertEq( + hex"00010203040506070809000102030405060708090001020304050607080900010203040506070809", + nibbles + ); // Empty bytes input bytes memory emptyBytes; @@ -23,86 +25,93 @@ contract TestBytes is TaikoTest { // 1. 20 bytes input bytes memory someBytes = hex"0123456789012345678901234567890123456789"; - // 1.A. 0 length - // 1.A.i. 0 start - assertEq(Bytes.slice(someBytes, 0, 0), hex""); + // 1.A. 0 length + // 1.A.i. 0 start + assertEq(Bytes.slice(someBytes, 0, 0), hex""); - // 1.A.ii. partial start - assertEq(Bytes.slice(someBytes, 7, 0), hex""); + // 1.A.ii. partial start + assertEq(Bytes.slice(someBytes, 7, 0), hex""); - // 1.A.iii. end start - assertEq(Bytes.slice(someBytes, someBytes.length, 0), hex""); + // 1.A.iii. end start + assertEq(Bytes.slice(someBytes, someBytes.length, 0), hex""); - // 1.B. full length - // 1.B.i. 0 start - assertEq(Bytes.slice(someBytes, 0, someBytes.length), hex"0123456789012345678901234567890123456789"); + // 1.B. full length + // 1.B.i. 0 start + assertEq( + Bytes.slice(someBytes, 0, someBytes.length), + hex"0123456789012345678901234567890123456789" + ); - // 1.B.ii. partial start - vm.expectRevert("slice_outOfBounds"); - Bytes.slice(someBytes, 7, someBytes.length); + // 1.B.ii. partial start + vm.expectRevert("slice_outOfBounds"); + Bytes.slice(someBytes, 7, someBytes.length); - // 1.C. partial length - // 1.C.i. 0 start - assertEq(Bytes.slice(someBytes, 0, 9), hex"012345678901234567"); + // 1.C. partial length + // 1.C.i. 0 start + assertEq(Bytes.slice(someBytes, 0, 9), hex"012345678901234567"); - // 1.C.ii. partial start - assertEq(Bytes.slice(someBytes, 7, 9), hex"456789012345678901"); + // 1.C.ii. partial start + assertEq(Bytes.slice(someBytes, 7, 9), hex"456789012345678901"); - // 1.C.iii. partial start, until exact end of input - assertEq(Bytes.slice(someBytes, 11, 9), hex"234567890123456789"); + // 1.C.iii. partial start, until exact end of input + assertEq(Bytes.slice(someBytes, 11, 9), hex"234567890123456789"); - // 1.C.iv. end start - vm.expectRevert("slice_outOfBounds"); - Bytes.slice(someBytes, someBytes.length, 9); + // 1.C.iv. end start + vm.expectRevert("slice_outOfBounds"); + Bytes.slice(someBytes, someBytes.length, 9); // 2. 64 byte input - someBytes = hex"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"; + someBytes = + hex"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"; - // 2.A. 0 length - // 2.A.i. 0 start - assertEq(Bytes.slice(someBytes, 0, 0), hex""); + // 2.A. 0 length + // 2.A.i. 0 start + assertEq(Bytes.slice(someBytes, 0, 0), hex""); - // 2.A.ii. partial start - assertEq(Bytes.slice(someBytes, 7, 0), hex""); + // 2.A.ii. partial start + assertEq(Bytes.slice(someBytes, 7, 0), hex""); - // 2.A.iii. end start - assertEq(Bytes.slice(someBytes, someBytes.length, 0), hex""); + // 2.A.iii. end start + assertEq(Bytes.slice(someBytes, someBytes.length, 0), hex""); - // 2.B. full length - // 2.B.i. 0 start - assertEq(Bytes.slice(someBytes, 0, someBytes.length), hex"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"); + // 2.B. full length + // 2.B.i. 0 start + assertEq( + Bytes.slice(someBytes, 0, someBytes.length), + hex"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" + ); - // 2.B.ii. partial start - vm.expectRevert("slice_outOfBounds"); - Bytes.slice(someBytes, 7, someBytes.length); // TODO Foundry bug + // 2.B.ii. partial start + vm.expectRevert("slice_outOfBounds"); + Bytes.slice(someBytes, 7, someBytes.length); // TODO Foundry bug - // 2.C. partial length - // 2.C.i. 0 start - assertEq(Bytes.slice(someBytes, 0, 9), hex"0123456789abcdef01"); + // 2.C. partial length + // 2.C.i. 0 start + assertEq(Bytes.slice(someBytes, 0, 9), hex"0123456789abcdef01"); - // 2.C.ii. partial start - assertEq(Bytes.slice(someBytes, 7, 9), hex"ef0123456789abcdef"); + // 2.C.ii. partial start + assertEq(Bytes.slice(someBytes, 7, 9), hex"ef0123456789abcdef"); - // 2.C.iii. partial start, until exact end of input - assertEq(Bytes.slice(someBytes, 55, 9), hex"ef0123456789abcdef"); + // 2.C.iii. partial start, until exact end of input + assertEq(Bytes.slice(someBytes, 55, 9), hex"ef0123456789abcdef"); - // 2.C.iv. end start - vm.expectRevert("slice_outOfBounds"); - Bytes.slice(someBytes, someBytes.length, 9); + // 2.C.iv. end start + vm.expectRevert("slice_outOfBounds"); + Bytes.slice(someBytes, someBytes.length, 9); // 3. 0 byte input someBytes = hex""; - // 3.A. 0 start - assertEq(Bytes.slice(someBytes, 0, 0), hex""); + // 3.A. 0 start + assertEq(Bytes.slice(someBytes, 0, 0), hex""); - // 3.B. overflow start - vm.expectRevert("slice_outOfBounds"); - Bytes.slice(someBytes, 1, 0); + // 3.B. overflow start + vm.expectRevert("slice_outOfBounds"); + Bytes.slice(someBytes, 1, 0); - // 3.C. overflow length - vm.expectRevert("slice_outOfBounds"); - Bytes.slice(someBytes, 0, 1); + // 3.C. overflow length + vm.expectRevert("slice_outOfBounds"); + Bytes.slice(someBytes, 0, 1); } function test_slice2() external { @@ -113,6 +122,7 @@ contract TestBytes is TaikoTest { assertEq(Bytes.slice(someBytes, 10), hex"01234567890123456789"); - assertEq(Bytes.slice(someBytes, someBytes.length*1000), hex""); //Doesnt revert if start is out of bounds + assertEq(Bytes.slice(someBytes, someBytes.length * 1000), hex""); //Doesnt revert if start + // is out of bounds } -} \ No newline at end of file +} diff --git a/packages/protocol/test/thirdparty/optimisim/rlp/RLPReader.t.sol b/packages/protocol/test/thirdparty/optimisim/rlp/RLPReader.t.sol index 811aa0a861b..d9986ce4efc 100644 --- a/packages/protocol/test/thirdparty/optimisim/rlp/RLPReader.t.sol +++ b/packages/protocol/test/thirdparty/optimisim/rlp/RLPReader.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: UNLICENSED +// SPDX-License-Identifier: MIT pragma solidity 0.8.24; import "../../../TaikoTest.sol"; @@ -39,13 +39,17 @@ contract TestRLPReader is TaikoTest { function test_readList_invalidLength() external { bytes memory encodedList = hex"e1a00000000000000000000000000000000000000000000000000001"; - vm.expectRevert("RLPReader: length of content must be greater than list length (short list)"); + vm.expectRevert( + "RLPReader: length of content must be greater than list length (short list)" + ); RLPReader.readList(encodedList); } function test_readList_empty() external { bytes memory empty = hex""; - vm.expectRevert("RLPReader: length of an RLP item must be greater than zero to be decodable"); + vm.expectRevert( + "RLPReader: length of an RLP item must be greater than zero to be decodable" + ); RLPReader.readList(empty); } @@ -69,11 +73,14 @@ contract TestRLPReader is TaikoTest { } function test_readBytes_correctSixtyFourBytes() external { - bytes memory encodedBytes = hex"b8400123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"; + bytes memory encodedBytes = + hex"b8400123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"; bytes memory decodedBytes = RLPReader.readBytes(encodedBytes); assertEq(decodedBytes.length, 64); - assertEq(decodedBytes, hex"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"); - + assertEq( + decodedBytes, + hex"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" + ); } function test_readBytes_null() external { @@ -83,7 +90,9 @@ contract TestRLPReader is TaikoTest { function test_readBytes_empty() external { bytes memory empty = hex""; - vm.expectRevert("RLPReader: length of an RLP item must be greater than zero to be decodable"); + vm.expectRevert( + "RLPReader: length of an RLP item must be greater than zero to be decodable" + ); RLPReader.readBytes(empty); } @@ -99,13 +108,16 @@ contract TestRLPReader is TaikoTest { } function test_readRawBytes_longBytes() external { - bytes memory encodedBytes = hex"b8400123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"; + bytes memory encodedBytes = + hex"b8400123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"; assertEq(RLPReader.readRawBytes(RLPReader.toRLPItem(encodedBytes)), encodedBytes); } function test_readRawBytes_empty() external { bytes memory encodedBytes = hex""; - vm.expectRevert("RLPReader: length of an RLP item must be greater than zero to be decodable"); + vm.expectRevert( + "RLPReader: length of an RLP item must be greater than zero to be decodable" + ); RLPReader.readRawBytes(RLPReader.toRLPItem(encodedBytes)); } @@ -113,5 +125,4 @@ contract TestRLPReader is TaikoTest { bytes memory encodedBytes = hex"80"; assertEq(RLPReader.readRawBytes(RLPReader.toRLPItem(encodedBytes)), encodedBytes); } - -} \ No newline at end of file +} diff --git a/packages/protocol/test/thirdparty/optimisim/trie/SecureMerkleTrie.t.sol b/packages/protocol/test/thirdparty/optimisim/trie/SecureMerkleTrie.t.sol index 83dedab3347..b679d08611e 100644 --- a/packages/protocol/test/thirdparty/optimisim/trie/SecureMerkleTrie.t.sol +++ b/packages/protocol/test/thirdparty/optimisim/trie/SecureMerkleTrie.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: UNLICENSED +// SPDX-License-Identifier: MIT pragma solidity 0.8.24; import "../../../TaikoTest.sol"; @@ -6,46 +6,47 @@ import "../../../TaikoTest.sol"; /// @author Kirk Baird contract TestSecureMerkleTrie is TaikoTest { function test_verifyInclusionProof_simple() external { - bytes memory slot = hex"0000000000000000000000000000000000000000000000000000000000000006"; // hash = 0xf652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d3f + bytes memory slot = hex"0000000000000000000000000000000000000000000000000000000000000006"; // hash + // = 0xf652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d3f bytes memory value = hex"01"; - // Leaf node (target): ["0x3652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d3f","0x01"] // hash = 4c020f5af4649ee703bbfa974846790d332abacef03c89036babb2238c01c337 - // Branch node (root): ["0x","0x","0x","0x","0x","0x","0x","0x","0x","0x","0x","0x","0x","0x","0x","0x4c020f5af4649ee703bbfa974846790d332abacef03c89036babb2238c01c337", "0x"] // hash = b21a635028fc2f2a4ba5b688497165f7096500771fd493e0695ef750c6c1845c + // Leaf node (target): + // ["0x3652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d3f","0x01"] // hash = + // 4c020f5af4649ee703bbfa974846790d332abacef03c89036babb2238c01c337 + // Branch node (root): + // ["0x","0x","0x","0x","0x","0x","0x","0x","0x","0x","0x","0x","0x","0x","0x","0x4c020f5af4649ee703bbfa974846790d332abacef03c89036babb2238c01c337", + // "0x"] // hash = b21a635028fc2f2a4ba5b688497165f7096500771fd493e0695ef750c6c1845c bytes32 rootHash = hex"b21a635028fc2f2a4ba5b688497165f7096500771fd493e0695ef750c6c1845c"; bytes[] memory proof = new bytes[](2); - proof[0] = hex"f1808080808080808080808080808080a04c020f5af4649ee703bbfa974846790d332abacef03c89036babb2238c01c33780"; + proof[0] = + hex"f1808080808080808080808080808080a04c020f5af4649ee703bbfa974846790d332abacef03c89036babb2238c01c33780"; proof[1] = hex"e2a03652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d3f01"; - - assertTrue(SecureMerkleTrie.verifyInclusionProof( - slot, - value, - proof, - rootHash - )); + assertTrue(SecureMerkleTrie.verifyInclusionProof(slot, value, proof, rootHash)); } - // based on deployed contract 0xcD5e2bebd3DfE46e4BF96aE2ac7B89B22cc6a982 (SignalService Proxy) on Sepolia + // based on deployed contract 0xcD5e2bebd3DfE46e4BF96aE2ac7B89B22cc6a982 (SignalService Proxy) + // on Sepolia function test_verifyInclusionProof_realProof() external { bytes memory slot = hex"0000000000000000000000000000000000000000000000000000000000000000"; bytes memory value = hex"01"; bytes32 rootHash = hex"45e9f670f31850ee0771a6ce85f36721526bc413bd91d58b8b9002adacb418ca"; bytes[] memory proof = new bytes[](6); - proof[0] = hex"f90211a01bf8dc9db1d06b09a1593db05232aa42c2b417e20251d71e8f32086b57573e06a0f541e279cb44d7e034fd4a8fda716291d8bb5cc2fb67249197c373e4405333d9a09ac7f4d030a807bf868f0e9122a537e6ea6f029a3bbae5477f5bec9367477538a012795298d14f24c7876a15303f38c794fe4d22c385d6b15adf136a65287d64aca0db8ff50aeed396a753e2b582a2101807146b9abad224956c8c0b2914e8bc6308a050e2462dd19498a35aabf6a701e90756cd519129c04095fde7b35ced53548967a01d4d98eae2c34085bef8029256fbc79dfd08ce2413742e006c16057ee23d8415a05ee9d91e8763e4ab8bfddb682f1579d91189d77435e69e186788b1236c07b400a06e867457693097e1ac54bca407a9b7241740e64d110e661b71b708776bf951cea038440f0f7488fc76ba3f7a35b1789dd4658b9b206441ef824acb7fe2a3a76a20a0285e98d81740593ef5a9a529c4d733ebe64f15f40732b3a0d0623c1cb71f8ed0a0a80dd18c30ffd2792e4856b13097aad1e5afe7439b7f343cf9ae856d68af2ba7a0c2d74f432cab091d90bae5ec862089ae1272f39108f1cba4f57c7b5671e5c816a0aceebc0b41cf40fe8313c2b524f03e732b8385727de1abae876d9057b2d85e1fa00ee8b4f21e2f328d027884d9ffbac6fac35539a7d74b11d9f17e5a3a185b8386a0e52242d3cc5dd7773ec21fbfae2141144d02ce74ff601c375bda5fff96aef12b80"; - proof[1] = hex"f90211a09c081fac815d03d3ef97f0f6ec100c24a7057fff79a870a22756b374a67a67eaa008586c30da747166360003b1eed874a0b915ca98cbfa84964f7d88ab8da1989aa0449474ec27502c1a3a5d21050bbfd57cc514adae298412e23f132534ff932dfca08434310370976516d70c7b3b6b33a383e46a94563ec48da41ce3074141c29d37a0912079ec50d4499209c32b2f7dd8d12cb9c152136812df496876fae92d485335a0505627a88c1028e9ce54238f9f5d79e196b9fee338aa642afe511886ed53f04aa0e411917634b30a3767de43f4208ee6a7bef92e63e4afd83b9318da18b5664a6ea03f5bbccdf60e44fa45761b107f34166d4b511d0343af2464afed818dfdc57963a002920171377ba261586e2733d3d0f19696b44848abb95ad91b08484f7cbe74bea0815f25e6680089a62b7219ee2957b19e773d41545fe2140a4dbcd7e8cd3dffd7a0204c53730d2e8b4840012807a3ccfb3dab97a9abcbddea7b470e72c31ed47e64a0e37b499b1b6139944109adfffe5a303f26efc14627a85bdd06f5f67fa18d1f27a070660c887064df8b7d89a942b0553427dd18f06b8bbb39db5365786e780fc749a07b51a6dbe67bad62c92538c859a66937162cb61a000d7e5f21695e490199b18ba0b80c116ca1493c4a017f3189e519614295c4ec23edcaa199f16f64ad9b9527c7a09cea6ec2caee96a5cacbae86e88c15e0f2a5d26d4b75137179fd5666fbb5aa7480"; - proof[2] = hex"f90211a0edff33fe5c95b4fa868d66431769e22577932ee13b18b1da8ee5419aec59c5e7a09320d0ae25a44b54b44f69b435a3edb6503d0aab80052a4ba2d0069e840ffcf3a084d002a67ee8281c3681b11d948ab4d2a6440a2803f6025b54dcaa4a2bb86047a00104b82f9c6c5a0d3bc9f1af1ccde26293e680e26d525f9d542a9ebb5d623eada02b2522787d006e41d10c12bff567be8eb13ca23784a926eddeda28550bc50843a03d02c42758d7f7107850431572c6275b64a9da09107d588c732a45804ec8b650a0be4b44daa2d677c7163e0b6b8334c39ddb92ae0701b573196ed2e422d08d7f79a0c4c06e7eded093383c6c3e2460462a49d356a4fc3165ec0207490cf62b382653a0d54b62359a6a9c0541e660b151009cc42a48e3ba12b7059e7aa40ea55f7d627fa08ee6a1a4cc20035c4ac7aea9d80dfc1dd13d83b9c9941c180caf0496a261a525a02885741fff2f4e61c3cd76ea387978030d9d0a79d2accdaaa535e9fd69be9dc0a013f67d5965341a354b659eddf810ad1801ed6cdbc85922fbf4f1d5690d4dec5ea0014ce0d9af419fb75af5ebf396786cd3f415429d30e174c864c6f355e46e9e9fa04ad594c616d61e8b911359309131516d9e29d9a435cec91520d0831bcee6752fa06aeb091d8001bf97c0861ea1900e85edad54c00e7d368fae73a5d980a4479a2da07e2aa9f31c59e36b69154fbd34de81c6b1feed1a6ed868813e923d2f98d8c31480"; - proof[3] = hex"f90211a0d2c363378ebc8717d552d4137cba842e6d00f045121f885d88f1146121c299e5a09f6f5a03356b3033f75fba1956afe0242be8dc508ce83e356ea5f48b3c17b571a0ba32e8ef62fdfc524822241c471024cba2b1d4a6a9d049424e2ac3868435f2eaa0284ecc45af9d2cc173636750eef4fc9c3e8828a5469732571950259cd25b2ae5a0a4a384dba0939acbcc8b14ce2411df265cc91162debb84ffd94f9a5f185e6c04a02542ba4e13a2571665afb8a8d6b5e972e018d1d6f3ae57707d725254530f27aaa05b1f61c8dea59ac83181d4faa4d3c322970f5ecacd0bd07028bc87b6e3174baba02fa86ead02062c2671a3de5460efe03e179184e3602320ab8478aa51239ca5f1a0b0a1ed80fa8eef67af1193c2080d04976d2b28ed3a70ad64afc9d31864ddf0d3a0afd61230c619715051e37d73754063a58da86e17fa9f1f702038b88b762fda4ea0cdb772381aec1978ad17c8c0e13298b1f9ce4b937f45a7b5ade7bce5ec374665a0db07f3614888c57b8ccbddca9e1575e63b663acada279262261b43e8d328ba88a00de0759c749651d9b8960feed63fbeecaaa145f47927e7f2d2d3f56bb802d676a01c3384e31a91e9d39ee8c728c24cf49a2d1c27ed4d96075c760d470e0812731da07e7fc146b9cc0be8af894c7a6cd93b4857011483f299c5b68737de3f0eb53304a0466878f42b7f4b98bdf104bede4313aade1c2cf0186db3e5806b74935129d00e80"; - proof[4] = hex"f90171a031dde6777fd092b1b9769b2402355e81e3e03e5d5c336f5edc583836ed15cfa580a0bb779ade81cb7fa701d963b9c1ae32d7cf58d926d14217bf96e3b44cdc93426da08cfeef6342385fbb0b452adca5c2ae1c5c651839137c15ce646d2a2011358e0ba0354480a6556b60a6af02f5f138eac24b268af77d85b3a7e241b1c6ec30125e17a08b6d79c69add140fd1bdd694ded36b248961ce0a6c905aac15ae928b925d730f80a0665dd3eb57bd0fd5bf2476a2c7ce190bbe4cfe92862d2ca644ec2f24a5e1545980a0321c382b719c93b3d816c3876a5f36b265186988c4a7994bc5927357f64d82bfa0adbd467e4d446b07a0f755954da22d7480373fdb139e93ec52799aa4239571a980a0a3eed0a41205afb11767756e464a4b99b0cbec8ac9f0919f46b831118a6847f880a0954e8545cb42ac37f2ef0f79f745a03c660dd143a7b621132385060a8345e821a00fe18033d0e53a5d97855111b656f4aefc4b32538df7aba9a01592bb1337d15380"; + proof[0] = + hex"f90211a01bf8dc9db1d06b09a1593db05232aa42c2b417e20251d71e8f32086b57573e06a0f541e279cb44d7e034fd4a8fda716291d8bb5cc2fb67249197c373e4405333d9a09ac7f4d030a807bf868f0e9122a537e6ea6f029a3bbae5477f5bec9367477538a012795298d14f24c7876a15303f38c794fe4d22c385d6b15adf136a65287d64aca0db8ff50aeed396a753e2b582a2101807146b9abad224956c8c0b2914e8bc6308a050e2462dd19498a35aabf6a701e90756cd519129c04095fde7b35ced53548967a01d4d98eae2c34085bef8029256fbc79dfd08ce2413742e006c16057ee23d8415a05ee9d91e8763e4ab8bfddb682f1579d91189d77435e69e186788b1236c07b400a06e867457693097e1ac54bca407a9b7241740e64d110e661b71b708776bf951cea038440f0f7488fc76ba3f7a35b1789dd4658b9b206441ef824acb7fe2a3a76a20a0285e98d81740593ef5a9a529c4d733ebe64f15f40732b3a0d0623c1cb71f8ed0a0a80dd18c30ffd2792e4856b13097aad1e5afe7439b7f343cf9ae856d68af2ba7a0c2d74f432cab091d90bae5ec862089ae1272f39108f1cba4f57c7b5671e5c816a0aceebc0b41cf40fe8313c2b524f03e732b8385727de1abae876d9057b2d85e1fa00ee8b4f21e2f328d027884d9ffbac6fac35539a7d74b11d9f17e5a3a185b8386a0e52242d3cc5dd7773ec21fbfae2141144d02ce74ff601c375bda5fff96aef12b80"; + proof[1] = + hex"f90211a09c081fac815d03d3ef97f0f6ec100c24a7057fff79a870a22756b374a67a67eaa008586c30da747166360003b1eed874a0b915ca98cbfa84964f7d88ab8da1989aa0449474ec27502c1a3a5d21050bbfd57cc514adae298412e23f132534ff932dfca08434310370976516d70c7b3b6b33a383e46a94563ec48da41ce3074141c29d37a0912079ec50d4499209c32b2f7dd8d12cb9c152136812df496876fae92d485335a0505627a88c1028e9ce54238f9f5d79e196b9fee338aa642afe511886ed53f04aa0e411917634b30a3767de43f4208ee6a7bef92e63e4afd83b9318da18b5664a6ea03f5bbccdf60e44fa45761b107f34166d4b511d0343af2464afed818dfdc57963a002920171377ba261586e2733d3d0f19696b44848abb95ad91b08484f7cbe74bea0815f25e6680089a62b7219ee2957b19e773d41545fe2140a4dbcd7e8cd3dffd7a0204c53730d2e8b4840012807a3ccfb3dab97a9abcbddea7b470e72c31ed47e64a0e37b499b1b6139944109adfffe5a303f26efc14627a85bdd06f5f67fa18d1f27a070660c887064df8b7d89a942b0553427dd18f06b8bbb39db5365786e780fc749a07b51a6dbe67bad62c92538c859a66937162cb61a000d7e5f21695e490199b18ba0b80c116ca1493c4a017f3189e519614295c4ec23edcaa199f16f64ad9b9527c7a09cea6ec2caee96a5cacbae86e88c15e0f2a5d26d4b75137179fd5666fbb5aa7480"; + proof[2] = + hex"f90211a0edff33fe5c95b4fa868d66431769e22577932ee13b18b1da8ee5419aec59c5e7a09320d0ae25a44b54b44f69b435a3edb6503d0aab80052a4ba2d0069e840ffcf3a084d002a67ee8281c3681b11d948ab4d2a6440a2803f6025b54dcaa4a2bb86047a00104b82f9c6c5a0d3bc9f1af1ccde26293e680e26d525f9d542a9ebb5d623eada02b2522787d006e41d10c12bff567be8eb13ca23784a926eddeda28550bc50843a03d02c42758d7f7107850431572c6275b64a9da09107d588c732a45804ec8b650a0be4b44daa2d677c7163e0b6b8334c39ddb92ae0701b573196ed2e422d08d7f79a0c4c06e7eded093383c6c3e2460462a49d356a4fc3165ec0207490cf62b382653a0d54b62359a6a9c0541e660b151009cc42a48e3ba12b7059e7aa40ea55f7d627fa08ee6a1a4cc20035c4ac7aea9d80dfc1dd13d83b9c9941c180caf0496a261a525a02885741fff2f4e61c3cd76ea387978030d9d0a79d2accdaaa535e9fd69be9dc0a013f67d5965341a354b659eddf810ad1801ed6cdbc85922fbf4f1d5690d4dec5ea0014ce0d9af419fb75af5ebf396786cd3f415429d30e174c864c6f355e46e9e9fa04ad594c616d61e8b911359309131516d9e29d9a435cec91520d0831bcee6752fa06aeb091d8001bf97c0861ea1900e85edad54c00e7d368fae73a5d980a4479a2da07e2aa9f31c59e36b69154fbd34de81c6b1feed1a6ed868813e923d2f98d8c31480"; + proof[3] = + hex"f90211a0d2c363378ebc8717d552d4137cba842e6d00f045121f885d88f1146121c299e5a09f6f5a03356b3033f75fba1956afe0242be8dc508ce83e356ea5f48b3c17b571a0ba32e8ef62fdfc524822241c471024cba2b1d4a6a9d049424e2ac3868435f2eaa0284ecc45af9d2cc173636750eef4fc9c3e8828a5469732571950259cd25b2ae5a0a4a384dba0939acbcc8b14ce2411df265cc91162debb84ffd94f9a5f185e6c04a02542ba4e13a2571665afb8a8d6b5e972e018d1d6f3ae57707d725254530f27aaa05b1f61c8dea59ac83181d4faa4d3c322970f5ecacd0bd07028bc87b6e3174baba02fa86ead02062c2671a3de5460efe03e179184e3602320ab8478aa51239ca5f1a0b0a1ed80fa8eef67af1193c2080d04976d2b28ed3a70ad64afc9d31864ddf0d3a0afd61230c619715051e37d73754063a58da86e17fa9f1f702038b88b762fda4ea0cdb772381aec1978ad17c8c0e13298b1f9ce4b937f45a7b5ade7bce5ec374665a0db07f3614888c57b8ccbddca9e1575e63b663acada279262261b43e8d328ba88a00de0759c749651d9b8960feed63fbeecaaa145f47927e7f2d2d3f56bb802d676a01c3384e31a91e9d39ee8c728c24cf49a2d1c27ed4d96075c760d470e0812731da07e7fc146b9cc0be8af894c7a6cd93b4857011483f299c5b68737de3f0eb53304a0466878f42b7f4b98bdf104bede4313aade1c2cf0186db3e5806b74935129d00e80"; + proof[4] = + hex"f90171a031dde6777fd092b1b9769b2402355e81e3e03e5d5c336f5edc583836ed15cfa580a0bb779ade81cb7fa701d963b9c1ae32d7cf58d926d14217bf96e3b44cdc93426da08cfeef6342385fbb0b452adca5c2ae1c5c651839137c15ce646d2a2011358e0ba0354480a6556b60a6af02f5f138eac24b268af77d85b3a7e241b1c6ec30125e17a08b6d79c69add140fd1bdd694ded36b248961ce0a6c905aac15ae928b925d730f80a0665dd3eb57bd0fd5bf2476a2c7ce190bbe4cfe92862d2ca644ec2f24a5e1545980a0321c382b719c93b3d816c3876a5f36b265186988c4a7994bc5927357f64d82bfa0adbd467e4d446b07a0f755954da22d7480373fdb139e93ec52799aa4239571a980a0a3eed0a41205afb11767756e464a4b99b0cbec8ac9f0919f46b831118a6847f880a0954e8545cb42ac37f2ef0f79f745a03c660dd143a7b621132385060a8345e821a00fe18033d0e53a5d97855111b656f4aefc4b32538df7aba9a01592bb1337d15380"; proof[5] = hex"e09e3cd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e56301"; - assertTrue(SecureMerkleTrie.verifyInclusionProof( - slot, - value, - proof, - rootHash - )); + assertTrue(SecureMerkleTrie.verifyInclusionProof(slot, value, proof, rootHash)); } function test_verifyInclusionProof_fakeValue() external { @@ -54,72 +55,76 @@ contract TestSecureMerkleTrie is TaikoTest { bytes32 rootHash = hex"b21a635028fc2f2a4ba5b688497165f7096500771fd493e0695ef750c6c1845c"; bytes[] memory proof = new bytes[](2); - proof[0] = hex"f1808080808080808080808080808080a04c020f5af4649ee703bbfa974846790d332abacef03c89036babb2238c01c33780"; + proof[0] = + hex"f1808080808080808080808080808080a04c020f5af4649ee703bbfa974846790d332abacef03c89036babb2238c01c33780"; proof[1] = hex"e2a03652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d3f01"; - assertFalse(SecureMerkleTrie.verifyInclusionProof( - slot, - value, - proof, - rootHash - )); + assertFalse(SecureMerkleTrie.verifyInclusionProof(slot, value, proof, rootHash)); } function test_verifyInclusionProof_fakeRoot() external { - bytes memory slot = hex"0000000000000000000000000000000000000000000000000000000000000006"; // hash = 0xf652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d3f + bytes memory slot = hex"0000000000000000000000000000000000000000000000000000000000000006"; // hash + // = 0xf652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d3f bytes memory value = hex"01"; - // Leaf node (target): ["0x3652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d3f","0x01"] // hash = 4c020f5af4649ee703bbfa974846790d332abacef03c89036babb2238c01c337 - // Branch node (root): ["0x","0x","0x","0x","0x","0x","0x","0x","0x","0x","0x","0x","0x","0x","0x","0x4c020f5af4649ee703bbfa974846790d332abacef03c89036babb2238c01c337", "0x"] // hash = b21a635028fc2f2a4ba5b688497165f7096500771fd493e0695ef750c6c1845c + // Leaf node (target): + // ["0x3652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d3f","0x01"] // hash = + // 4c020f5af4649ee703bbfa974846790d332abacef03c89036babb2238c01c337 + // Branch node (root): + // ["0x","0x","0x","0x","0x","0x","0x","0x","0x","0x","0x","0x","0x","0x","0x","0x4c020f5af4649ee703bbfa974846790d332abacef03c89036babb2238c01c337", + // "0x"] // hash = b21a635028fc2f2a4ba5b688497165f7096500771fd493e0695ef750c6c1845c bytes32 rootHash = hex"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"; bytes[] memory proof = new bytes[](2); - proof[0] = hex"f1808080808080808080808080808080a04c020f5af4649ee703bbfa974846790d332abacef03c89036babb2238c01c33780"; + proof[0] = + hex"f1808080808080808080808080808080a04c020f5af4649ee703bbfa974846790d332abacef03c89036babb2238c01c33780"; proof[1] = hex"e2a03652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d3f01"; vm.expectRevert("MerkleTrie: invalid root hash"); - SecureMerkleTrie.verifyInclusionProof( - slot, - value, - proof, - rootHash - ); + SecureMerkleTrie.verifyInclusionProof(slot, value, proof, rootHash); } function test_verifyInclusionProof_fakeIntermediateNode() external { - bytes memory slot = hex"0000000000000000000000000000000000000000000000000000000000000006"; // hash = 0xf652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d3f + bytes memory slot = hex"0000000000000000000000000000000000000000000000000000000000000006"; // hash + // = 0xf652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d3f bytes memory value = hex"01"; - // Leaf node (target): ["0x3123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef","0x01"] // hash = 7b074e96d2dcd6ae7a05e7e35c748e067706d28e47bfecf0c0e642f4dff48d17 - // Branch node (root): ["0x","0x","0x","0x","0x","0x","0x","0x","0x","0x","0x","0x","0x","0x","0x","0x4c020f5af4649ee703bbfa974846790d332abacef03c89036babb2238c01c337", "0x"] // hash = b21a635028fc2f2a4ba5b688497165f7096500771fd493e0695ef750c6c1845c + // Leaf node (target): + // ["0x3123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef","0x01"] // hash = + // 7b074e96d2dcd6ae7a05e7e35c748e067706d28e47bfecf0c0e642f4dff48d17 + // Branch node (root): + // ["0x","0x","0x","0x","0x","0x","0x","0x","0x","0x","0x","0x","0x","0x","0x","0x4c020f5af4649ee703bbfa974846790d332abacef03c89036babb2238c01c337", + // "0x"] // hash = b21a635028fc2f2a4ba5b688497165f7096500771fd493e0695ef750c6c1845c bytes32 rootHash = hex"b21a635028fc2f2a4ba5b688497165f7096500771fd493e0695ef750c6c1845c"; bytes[] memory proof = new bytes[](2); - proof[0] = hex"f1808080808080808080808080808080a04c020f5af4649ee703bbfa974846790d332abacef03c89036babb2238c01c33780"; + proof[0] = + hex"f1808080808080808080808080808080a04c020f5af4649ee703bbfa974846790d332abacef03c89036babb2238c01c33780"; proof[1] = hex"e2a03123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef01"; vm.expectRevert("MerkleTrie: invalid large internal hash"); - SecureMerkleTrie.verifyInclusionProof( - slot, - value, - proof, - rootHash - ); + SecureMerkleTrie.verifyInclusionProof(slot, value, proof, rootHash); } function test_get() external { - bytes memory slot = hex"0000000000000000000000000000000000000000000000000000000000000006"; // hash = 0xf652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d3f + bytes memory slot = hex"0000000000000000000000000000000000000000000000000000000000000006"; // hash + // = 0xf652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d3f bytes memory value = hex"01"; - // Leaf node (target): ["0x3652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d3f","0x01"] // hash = 4c020f5af4649ee703bbfa974846790d332abacef03c89036babb2238c01c337 - // Branch node (root): ["0x","0x","0x","0x","0x","0x","0x","0x","0x","0x","0x","0x","0x","0x","0x","0x4c020f5af4649ee703bbfa974846790d332abacef03c89036babb2238c01c337", "0x"] // hash = b21a635028fc2f2a4ba5b688497165f7096500771fd493e0695ef750c6c1845c + // Leaf node (target): + // ["0x3652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d3f","0x01"] // hash = + // 4c020f5af4649ee703bbfa974846790d332abacef03c89036babb2238c01c337 + // Branch node (root): + // ["0x","0x","0x","0x","0x","0x","0x","0x","0x","0x","0x","0x","0x","0x","0x","0x4c020f5af4649ee703bbfa974846790d332abacef03c89036babb2238c01c337", + // "0x"] // hash = b21a635028fc2f2a4ba5b688497165f7096500771fd493e0695ef750c6c1845c bytes32 rootHash = hex"b21a635028fc2f2a4ba5b688497165f7096500771fd493e0695ef750c6c1845c"; bytes[] memory proof = new bytes[](2); - proof[0] = hex"f1808080808080808080808080808080a04c020f5af4649ee703bbfa974846790d332abacef03c89036babb2238c01c33780"; + proof[0] = + hex"f1808080808080808080808080808080a04c020f5af4649ee703bbfa974846790d332abacef03c89036babb2238c01c33780"; proof[1] = hex"e2a03652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d3f01"; bytes memory fetchedValue = SecureMerkleTrie.get(slot, proof, rootHash); assertEq(fetchedValue, value); } -} \ No newline at end of file +} diff --git a/packages/protocol/test/verifiers/GuardianVerifier.t.sol b/packages/protocol/test/verifiers/GuardianVerifier.t.sol index 7c88ba04e59..b216bddb41f 100644 --- a/packages/protocol/test/verifiers/GuardianVerifier.t.sol +++ b/packages/protocol/test/verifiers/GuardianVerifier.t.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: UNLICENSED +// SPDX-License-Identifier: MIT pragma solidity 0.8.24; import "../L1/TaikoL1TestBase.sol"; @@ -15,7 +15,6 @@ contract TestGuardianVerifier is TaikoL1TestBase { super.setUp(); } - // Tests `verifyProof()` with the correct prover function test_verifyProof() public { // Context @@ -37,16 +36,12 @@ contract TestGuardianVerifier is TaikoL1TestBase { }); // TierProof - TaikoData.TierProof memory proof = TaikoData.TierProof({ - tier: 0, - data: "" - }); + TaikoData.TierProof memory proof = TaikoData.TierProof({ tier: 0, data: "" }); // `verifyProof()` gv.verifyProof(ctx, transition, proof); } - // Tests `verifyProof()` with the wrong prover function test_verifyProof_invalidProver() public { // Context @@ -68,14 +63,10 @@ contract TestGuardianVerifier is TaikoL1TestBase { }); // TierProof - TaikoData.TierProof memory proof = TaikoData.TierProof({ - tier: 0, - data: "" - }); + TaikoData.TierProof memory proof = TaikoData.TierProof({ tier: 0, data: "" }); // `verifyProof()` with invalid ctx.prover vm.expectRevert(GuardianVerifier.PERMISSION_DENIED.selector); gv.verifyProof(ctx, transition, proof); } } - diff --git a/packages/protocol/test/verifiers/PseZkVerifier.t.sol b/packages/protocol/test/verifiers/PseZkVerifier.t.sol index 645e0e78ce7..51e658fd370 100644 --- a/packages/protocol/test/verifiers/PseZkVerifier.t.sol +++ b/packages/protocol/test/verifiers/PseZkVerifier.t.sol @@ -1,11 +1,11 @@ -// SPDX-License-Identifier: UNLICENSED +// SPDX-License-Identifier: MIT pragma solidity 0.8.24; import "../L1/TaikoL1TestBase.sol"; import "lib/openzeppelin-contracts/contracts/utils/Strings.sol"; -import {IVerifier} from "../../contracts/verifiers/IVerifier.sol"; -import {TaikoData} from "../../contracts/L1/TaikoData.sol"; -import {MockPlonkVerifier} from "../mocks/MockPlonkVerifier.sol"; +import { IVerifier } from "../../contracts/verifiers/IVerifier.sol"; +import { TaikoData } from "../../contracts/L1/TaikoData.sol"; +import { MockPlonkVerifier } from "../mocks/MockPlonkVerifier.sol"; /// @author Kirk Baird contract TestPseZkVerifier is TaikoL1TestBase { @@ -22,16 +22,14 @@ contract TestPseZkVerifier is TaikoL1TestBase { super.setUp(); // Create a mock PLONK Verifier - mockPlonkVerifierId = 12345; + mockPlonkVerifierId = 12_345; mockPlonkVerifier = address(new MockPlonkVerifier()); // Add the mock PLONK verifier to the address resolver bytes32 verifierName = pv.getVerifierName(mockPlonkVerifierId); addressManager.setAddress( - uint64(block.chainid), - bytes32(verifierName), - address(mockPlonkVerifier) + uint64(block.chainid), bytes32(verifierName), address(mockPlonkVerifier) ); } @@ -56,10 +54,7 @@ contract TestPseZkVerifier is TaikoL1TestBase { }); // TierProof - TaikoData.TierProof memory proof = TaikoData.TierProof({ - tier: 0, - data: "" - }); + TaikoData.TierProof memory proof = TaikoData.TierProof({ tier: 0, data: "" }); // `verifyProof()` pv.verifyProof(ctx, transition, proof); @@ -94,8 +89,12 @@ contract TestPseZkVerifier is TaikoL1TestBase { pointProof: point }); - bytes32 instance = pv.calcInstance(transition, ctx.prover, ctx.metaHash, pointProof.txListHash, pointProof.pointValue); - bytes memory instanceWords = abi.encodePacked(bytes16(0), bytes16(instance), bytes16(0), bytes16(uint128(uint256(instance)))); + bytes32 instance = pv.calcInstance( + transition, ctx.prover, ctx.metaHash, pointProof.txListHash, pointProof.pointValue + ); + bytes memory instanceWords = abi.encodePacked( + bytes16(0), bytes16(instance), bytes16(0), bytes16(uint128(uint256(instance))) + ); bytes memory zkp = abi.encodePacked(instanceWords, abi.encode(keccak256("taiko"))); PseZkVerifier.ZkEvmProof memory zkProof = PseZkVerifier.ZkEvmProof({ @@ -104,10 +103,8 @@ contract TestPseZkVerifier is TaikoL1TestBase { pointProof: abi.encode(pointProof) }); - TaikoData.TierProof memory proof = TaikoData.TierProof({ - tier: 0, - data: abi.encode(zkProof) - }); + TaikoData.TierProof memory proof = + TaikoData.TierProof({ tier: 0, data: abi.encode(zkProof) }); // `verifyProof()` vm.expectRevert(Lib4844.EVAL_FAILED_2.selector); @@ -136,19 +133,16 @@ contract TestPseZkVerifier is TaikoL1TestBase { // TierProof bytes32 instance = pv.calcInstance(transition, ctx.prover, ctx.metaHash, ctx.blobHash, 0); - bytes memory instanceWords = abi.encodePacked(bytes16(0), bytes16(instance), bytes16(0), bytes16(uint128(uint256(instance)))); + bytes memory instanceWords = abi.encodePacked( + bytes16(0), bytes16(instance), bytes16(0), bytes16(uint128(uint256(instance))) + ); bytes memory zkp = abi.encodePacked(instanceWords, abi.encode(keccak256("taiko"))); - PseZkVerifier.ZkEvmProof memory zkProof = PseZkVerifier.ZkEvmProof({ - verifierId: mockPlonkVerifierId, - zkp: zkp, - pointProof: "" - }); + PseZkVerifier.ZkEvmProof memory zkProof = + PseZkVerifier.ZkEvmProof({ verifierId: mockPlonkVerifierId, zkp: zkp, pointProof: "" }); - TaikoData.TierProof memory proof = TaikoData.TierProof({ - tier: 0, - data: abi.encode(zkProof) - }); + TaikoData.TierProof memory proof = + TaikoData.TierProof({ tier: 0, data: abi.encode(zkProof) }); // `verifyProof()` pv.verifyProof(ctx, transition, proof); @@ -175,10 +169,8 @@ contract TestPseZkVerifier is TaikoL1TestBase { }); // TierProof - TaikoData.TierProof memory proof = TaikoData.TierProof({ - tier: 0, - data: abi.encode(uint256(0)) - }); + TaikoData.TierProof memory proof = + TaikoData.TierProof({ tier: 0, data: abi.encode(uint256(0)) }); // `verifyProof()` vm.expectRevert(); @@ -207,19 +199,16 @@ contract TestPseZkVerifier is TaikoL1TestBase { // TierProof bytes32 instance = pv.calcInstance(transition, ctx.prover, ctx.metaHash, ctx.blobHash, 0); - bytes memory instanceWords = abi.encodePacked(bytes16(0), bytes16(0), bytes16(0), bytes16(uint128(uint256(instance)))); + bytes memory instanceWords = abi.encodePacked( + bytes16(0), bytes16(0), bytes16(0), bytes16(uint128(uint256(instance))) + ); bytes memory zkp = abi.encodePacked(instanceWords, abi.encode(keccak256("taiko"))); - PseZkVerifier.ZkEvmProof memory zkProof = PseZkVerifier.ZkEvmProof({ - verifierId: mockPlonkVerifierId, - zkp: zkp, - pointProof: "" - }); + PseZkVerifier.ZkEvmProof memory zkProof = + PseZkVerifier.ZkEvmProof({ verifierId: mockPlonkVerifierId, zkp: zkp, pointProof: "" }); - TaikoData.TierProof memory proof = TaikoData.TierProof({ - tier: 0, - data: abi.encode(zkProof) - }); + TaikoData.TierProof memory proof = + TaikoData.TierProof({ tier: 0, data: abi.encode(zkProof) }); // `verifyProof()` vm.expectRevert(PseZkVerifier.L1_INVALID_PROOF.selector); @@ -248,19 +237,15 @@ contract TestPseZkVerifier is TaikoL1TestBase { // TierProof bytes32 instance = pv.calcInstance(transition, ctx.prover, ctx.metaHash, ctx.blobHash, 0); - bytes memory instanceWords = abi.encodePacked(bytes16(0), bytes16(0), bytes16(instance), bytes16(0)); + bytes memory instanceWords = + abi.encodePacked(bytes16(0), bytes16(0), bytes16(instance), bytes16(0)); bytes memory zkp = abi.encodePacked(instanceWords, abi.encode(keccak256("taiko"))); - PseZkVerifier.ZkEvmProof memory zkProof = PseZkVerifier.ZkEvmProof({ - verifierId: mockPlonkVerifierId, - zkp: zkp, - pointProof: "" - }); + PseZkVerifier.ZkEvmProof memory zkProof = + PseZkVerifier.ZkEvmProof({ verifierId: mockPlonkVerifierId, zkp: zkp, pointProof: "" }); - TaikoData.TierProof memory proof = TaikoData.TierProof({ - tier: 0, - data: abi.encode(zkProof) - }); + TaikoData.TierProof memory proof = + TaikoData.TierProof({ tier: 0, data: abi.encode(zkProof) }); // `verifyProof()` vm.expectRevert(PseZkVerifier.L1_INVALID_PROOF.selector); @@ -290,16 +275,11 @@ contract TestPseZkVerifier is TaikoL1TestBase { // TierProof bytes memory zkp = abi.encodePacked("invalid"); - PseZkVerifier.ZkEvmProof memory zkProof = PseZkVerifier.ZkEvmProof({ - verifierId: mockPlonkVerifierId, - zkp: zkp, - pointProof: "" - }); + PseZkVerifier.ZkEvmProof memory zkProof = + PseZkVerifier.ZkEvmProof({ verifierId: mockPlonkVerifierId, zkp: zkp, pointProof: "" }); - TaikoData.TierProof memory proof = TaikoData.TierProof({ - tier: 0, - data: abi.encode(zkProof) - }); + TaikoData.TierProof memory proof = + TaikoData.TierProof({ tier: 0, data: abi.encode(zkProof) }); // `verifyProof()` vm.expectRevert("slice_outOfBounds"); @@ -328,7 +308,9 @@ contract TestPseZkVerifier is TaikoL1TestBase { // TierProof bytes32 instance = pv.calcInstance(transition, ctx.prover, ctx.metaHash, ctx.blobHash, 0); - bytes memory instanceWords = abi.encodePacked(bytes16(0), bytes16(instance), bytes16(0), bytes16(uint128(uint256(instance)))); + bytes memory instanceWords = abi.encodePacked( + bytes16(0), bytes16(instance), bytes16(0), bytes16(uint128(uint256(instance))) + ); bytes memory zkp = abi.encodePacked(instanceWords, abi.encode(keccak256("taiko"))); PseZkVerifier.ZkEvmProof memory zkProof = PseZkVerifier.ZkEvmProof({ @@ -337,10 +319,8 @@ contract TestPseZkVerifier is TaikoL1TestBase { pointProof: "" }); - TaikoData.TierProof memory proof = TaikoData.TierProof({ - tier: 0, - data: abi.encode(zkProof) - }); + TaikoData.TierProof memory proof = + TaikoData.TierProof({ tier: 0, data: abi.encode(zkProof) }); // `verifyProof()` vm.expectRevert(); @@ -369,19 +349,16 @@ contract TestPseZkVerifier is TaikoL1TestBase { // TierProof bytes32 instance = pv.calcInstance(transition, ctx.prover, ctx.metaHash, ctx.blobHash, 0); - bytes memory instanceWords = abi.encodePacked(bytes16(0), bytes16(instance), bytes16(0), bytes16(uint128(uint256(instance)))); + bytes memory instanceWords = abi.encodePacked( + bytes16(0), bytes16(instance), bytes16(0), bytes16(uint128(uint256(instance))) + ); bytes memory zkp = abi.encodePacked(instanceWords, abi.encode(keccak256("taiko"))); - PseZkVerifier.ZkEvmProof memory zkProof = PseZkVerifier.ZkEvmProof({ - verifierId: mockPlonkVerifierId, - zkp: zkp, - pointProof: "" - }); + PseZkVerifier.ZkEvmProof memory zkProof = + PseZkVerifier.ZkEvmProof({ verifierId: mockPlonkVerifierId, zkp: zkp, pointProof: "" }); - TaikoData.TierProof memory proof = TaikoData.TierProof({ - tier: 0, - data: abi.encode(zkProof) - }); + TaikoData.TierProof memory proof = + TaikoData.TierProof({ tier: 0, data: abi.encode(zkProof) }); // Tell verifier to revert MockPlonkVerifier(mockPlonkVerifier).setShouldRevert(true); @@ -413,19 +390,16 @@ contract TestPseZkVerifier is TaikoL1TestBase { // TierProof bytes32 instance = pv.calcInstance(transition, ctx.prover, ctx.metaHash, ctx.blobHash, 0); - bytes memory instanceWords = abi.encodePacked(bytes16(0), bytes16(instance), bytes16(0), bytes16(uint128(uint256(instance)))); + bytes memory instanceWords = abi.encodePacked( + bytes16(0), bytes16(instance), bytes16(0), bytes16(uint128(uint256(instance))) + ); bytes memory zkp = abi.encodePacked(instanceWords, "Hi"); - PseZkVerifier.ZkEvmProof memory zkProof = PseZkVerifier.ZkEvmProof({ - verifierId: mockPlonkVerifierId, - zkp: zkp, - pointProof: "" - }); + PseZkVerifier.ZkEvmProof memory zkProof = + PseZkVerifier.ZkEvmProof({ verifierId: mockPlonkVerifierId, zkp: zkp, pointProof: "" }); - TaikoData.TierProof memory proof = TaikoData.TierProof({ - tier: 0, - data: abi.encode(zkProof) - }); + TaikoData.TierProof memory proof = + TaikoData.TierProof({ tier: 0, data: abi.encode(zkProof) }); // `verifyProof()` vm.expectRevert(PseZkVerifier.L1_INVALID_PROOF.selector); @@ -454,19 +428,16 @@ contract TestPseZkVerifier is TaikoL1TestBase { // TierProof bytes32 instance = pv.calcInstance(transition, ctx.prover, ctx.metaHash, ctx.blobHash, 0); - bytes memory instanceWords = abi.encodePacked(bytes16(0), bytes16(instance), bytes16(0), bytes16(uint128(uint256(instance)))); + bytes memory instanceWords = abi.encodePacked( + bytes16(0), bytes16(instance), bytes16(0), bytes16(uint128(uint256(instance))) + ); bytes memory zkp = abi.encodePacked(instanceWords, bytes32("Hi")); - PseZkVerifier.ZkEvmProof memory zkProof = PseZkVerifier.ZkEvmProof({ - verifierId: mockPlonkVerifierId, - zkp: zkp, - pointProof: "" - }); + PseZkVerifier.ZkEvmProof memory zkProof = + PseZkVerifier.ZkEvmProof({ verifierId: mockPlonkVerifierId, zkp: zkp, pointProof: "" }); - TaikoData.TierProof memory proof = TaikoData.TierProof({ - tier: 0, - data: abi.encode(zkProof) - }); + TaikoData.TierProof memory proof = + TaikoData.TierProof({ tier: 0, data: abi.encode(zkProof) }); // `verifyProof()` vm.expectRevert(PseZkVerifier.L1_INVALID_PROOF.selector); diff --git a/packages/protocol/test/verifiers/SgxVerifier.t.sol b/packages/protocol/test/verifiers/SgxVerifier.t.sol index 8081029ae68..c8e483d09c7 100644 --- a/packages/protocol/test/verifiers/SgxVerifier.t.sol +++ b/packages/protocol/test/verifiers/SgxVerifier.t.sol @@ -10,8 +10,8 @@ contract TestSgxVerifier is TaikoL1TestBase, AttestationBase { address internal SGX_Z = randAddress(); address KNOWN_ADDRESS = address(0xAAAAAFE838B80D164535CD4d50058E456A4f9E16); - uint256 KNOWN_ADDRESS_PRIV_KEY = 0xde9b0c39e60bb0404347b588c6891947db2c873942b553d5d15c03ea30c04c63; - + uint256 KNOWN_ADDRESS_PRIV_KEY = + 0xde9b0c39e60bb0404347b588c6891947db2c873942b553d5d15c03ea30c04c63; function deployTaikoL1() internal override returns (TaikoL1) { return @@ -66,9 +66,13 @@ contract TestSgxVerifier is TaikoL1TestBase, AttestationBase { instances2[1] = David; vm.expectEmit(true, true, true, true); - emit SgxVerifier.InstanceAdded(startInstance + 2, instances2[0], address(0), block.timestamp); + emit SgxVerifier.InstanceAdded( + startInstance + 2, instances2[0], address(0), block.timestamp + ); vm.expectEmit(true, true, true, true); - emit SgxVerifier.InstanceAdded(startInstance + 3, instances2[1], address(0), block.timestamp); + emit SgxVerifier.InstanceAdded( + startInstance + 3, instances2[1], address(0), block.timestamp + ); // `addInstances()` ids = sv.addInstances(instances2); @@ -117,7 +121,6 @@ contract TestSgxVerifier is TaikoL1TestBase, AttestationBase { sv.addInstances(instances); } - function test_addInstancesByOwner_WithoutOwnerRole() external { address[] memory _instances = new address[](3); _instances[0] = SGX_X_0; @@ -163,7 +166,6 @@ contract TestSgxVerifier is TaikoL1TestBase, AttestationBase { sv.registerInstance(v3quote); } - // Test `verifyProof()` happy path function test_verifyProof() external { uint32 id = uint32(sv.nextInstanceId()); @@ -204,10 +206,7 @@ contract TestSgxVerifier is TaikoL1TestBase, AttestationBase { bytes memory signature = abi.encodePacked(r, s, v); bytes memory data = abi.encodePacked(id, newInstance, signature); - TaikoData.TierProof memory proof = TaikoData.TierProof({ - tier: 100, - data: data - }); + TaikoData.TierProof memory proof = TaikoData.TierProof({ tier: 100, data: data }); vm.warp(block.timestamp + 5); @@ -219,8 +218,8 @@ contract TestSgxVerifier is TaikoL1TestBase, AttestationBase { // Verification (address instanceAddr, uint64 instanceAddedAt) = sv.instances(id); - assertEq(instanceAddr, newInstance, 'Invalid instance address'); - assertEq(instanceAddedAt, block.timestamp, 'Invalid instance addedAt'); + assertEq(instanceAddr, newInstance, "Invalid instance address"); + assertEq(instanceAddedAt, block.timestamp, "Invalid instance addedAt"); vm.stopPrank(); } @@ -248,10 +247,7 @@ contract TestSgxVerifier is TaikoL1TestBase, AttestationBase { }); // TierProof - TaikoData.TierProof memory proof = TaikoData.TierProof({ - tier: 0, - data: "" - }); + TaikoData.TierProof memory proof = TaikoData.TierProof({ tier: 0, data: "" }); // `verifyProof()` sv.verifyProof(ctx, transition, proof); @@ -285,7 +281,7 @@ contract TestSgxVerifier is TaikoL1TestBase, AttestationBase { TaikoData.TierProof memory proof = TaikoData.TierProof({ tier: 0, data: new bytes(80) // invalid length - }); + }); // `verifyProof()` vm.expectRevert(SgxVerifier.SGX_INVALID_PROOF.selector); @@ -319,13 +315,10 @@ contract TestSgxVerifier is TaikoL1TestBase, AttestationBase { address newInstance = address(0x33); bytes memory signature = new bytes(65); // invalid length bytes memory data = abi.encodePacked(id, newInstance, signature); - TaikoData.TierProof memory proof = TaikoData.TierProof({ - tier: 0, - data: data - }); + TaikoData.TierProof memory proof = TaikoData.TierProof({ tier: 0, data: data }); // `verifyProof()` - vm.expectRevert('ECDSA: invalid signature'); + vm.expectRevert("ECDSA: invalid signature"); sv.verifyProof(ctx, transition, proof); vm.stopPrank(); @@ -363,10 +356,7 @@ contract TestSgxVerifier is TaikoL1TestBase, AttestationBase { bytes memory signature = abi.encodePacked(r, s, v); bytes memory data = abi.encodePacked(id, newInstance, signature); - TaikoData.TierProof memory proof = TaikoData.TierProof({ - tier: 0, - data: data - }); + TaikoData.TierProof memory proof = TaikoData.TierProof({ tier: 0, data: data }); // `verifyProof()` vm.expectRevert(SgxVerifier.SGX_INVALID_INSTANCE.selector); @@ -406,10 +396,7 @@ contract TestSgxVerifier is TaikoL1TestBase, AttestationBase { bytes memory signature = abi.encodePacked(r, s, v); bytes memory data = abi.encodePacked(id, newInstance, signature); - TaikoData.TierProof memory proof = TaikoData.TierProof({ - tier: 100, - data: data - }); + TaikoData.TierProof memory proof = TaikoData.TierProof({ tier: 100, data: data }); // `verifyProof()` vm.expectRevert(AddressResolver.RESOLVER_DENIED.selector); From 739a268622b72a9580ebc9cffb7d823721e48349 Mon Sep 17 00:00:00 2001 From: jeff <113397187+cyberhorsey@users.noreply.github.com> Date: Thu, 8 Feb 2024 17:59:50 -0800 Subject: [PATCH 3/3] chore(relayer): Bump taiko geth, several fixes, linter updates (#15692) --- go.mod | 46 ++++--- go.sum | 112 ++++++++++-------- packages/relayer/indexer/indexer.go | 1 + packages/relayer/indexer/subscribe.go | 1 + packages/relayer/pkg/mock/bridge.go | 4 + packages/relayer/pkg/proof/block_header.go | 3 + packages/relayer/pkg/repo/event_test.go | 4 + packages/relayer/processor/process_message.go | 2 + packages/relayer/processor/processor.go | 2 +- packages/relayer/types_test.go | 2 + 10 files changed, 108 insertions(+), 69 deletions(-) diff --git a/go.mod b/go.mod index 919d9aa4667..a955ab49d5d 100644 --- a/go.mod +++ b/go.mod @@ -28,8 +28,8 @@ require ( github.com/swaggo/swag v1.16.2 github.com/testcontainers/testcontainers-go v0.21.0 github.com/urfave/cli/v2 v2.25.7 - golang.org/x/exp v0.0.0-20230810033253-352e893a4cad - golang.org/x/sync v0.3.0 + golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa + golang.org/x/sync v0.5.0 gopkg.in/go-playground/assert.v1 v1.2.1 gopkg.in/yaml.v3 v3.0.1 gorm.io/datatypes v1.0.7 @@ -47,21 +47,27 @@ require ( github.com/PuerkitoBio/purell v1.1.1 // indirect github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect github.com/StackExchange/wmi v1.2.1 // indirect - github.com/VictoriaMetrics/fastcache v1.6.0 // indirect + github.com/VictoriaMetrics/fastcache v1.12.1 // indirect github.com/acomagu/bufpipe v1.0.4 // indirect github.com/andybalholm/brotli v1.0.5 // indirect github.com/aymerick/douceur v0.2.0 // indirect github.com/beorn7/perks v1.0.1 // indirect + github.com/bits-and-blooms/bitset v1.10.0 // indirect github.com/btcsuite/btcd/btcec/v2 v2.3.2 // indirect github.com/cespare/xxhash/v2 v2.2.0 // indirect github.com/cloudflare/circl v1.3.3 // indirect github.com/cockroachdb/errors v1.9.1 // indirect github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect - github.com/cockroachdb/pebble v0.0.0-20230906160148-46873a6a7a06 // indirect + github.com/cockroachdb/pebble v0.0.0-20230928194634-aa077af62593 // indirect github.com/cockroachdb/redact v1.1.3 // indirect + github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect + github.com/consensys/bavard v0.1.13 // indirect + github.com/consensys/gnark-crypto v0.12.1 // indirect github.com/containerd/containerd v1.6.19 // indirect github.com/cpuguy83/dockercfg v0.3.1 // indirect github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect + github.com/crate-crypto/go-ipa v0.0.0-20231025140028-3c0104f4b233 // indirect + github.com/crate-crypto/go-kzg-4844 v0.7.0 // indirect github.com/deckarep/golang-set/v2 v2.1.0 // indirect github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0 // indirect github.com/docker/distribution v2.8.2+incompatible // indirect @@ -69,11 +75,13 @@ require ( github.com/docker/go-connections v0.4.0 // indirect github.com/docker/go-units v0.5.0 // indirect github.com/emirpasic/gods v1.18.1 // indirect + github.com/ethereum/c-kzg-4844 v0.4.0 // indirect github.com/fsnotify/fsnotify v1.6.0 // indirect + github.com/gballet/go-verkle v0.1.1-0.20231031103413-a67434b50f46 // indirect github.com/getsentry/sentry-go v0.18.0 // indirect github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect github.com/go-git/go-billy/v5 v5.4.1 // indirect - github.com/go-ole/go-ole v1.2.5 // indirect + github.com/go-ole/go-ole v1.3.0 // indirect github.com/go-openapi/jsonpointer v0.19.5 // indirect github.com/go-openapi/jsonreference v0.19.6 // indirect github.com/go-openapi/spec v0.20.4 // indirect @@ -82,11 +90,10 @@ require ( github.com/go-playground/universal-translator v0.18.0 // indirect github.com/go-playground/validator/v10 v10.11.1 // indirect github.com/go-sql-driver/mysql v1.6.0 // indirect - github.com/go-stack/stack v1.8.1 // indirect github.com/gofrs/flock v0.8.1 // indirect github.com/gogo/protobuf v1.3.2 // indirect github.com/golang-jwt/jwt v3.2.2+incompatible // indirect - github.com/golang-jwt/jwt/v4 v4.4.3 // indirect + github.com/golang-jwt/jwt/v4 v4.5.0 // indirect github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect github.com/golang/protobuf v1.5.3 // indirect github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb // indirect @@ -94,7 +101,7 @@ require ( github.com/gorilla/css v1.0.0 // indirect github.com/gorilla/websocket v1.4.2 // indirect github.com/holiman/bloomfilter/v2 v2.0.3 // indirect - github.com/holiman/uint256 v1.2.3 // indirect + github.com/holiman/uint256 v1.2.4 // indirect github.com/iancoleman/strcase v0.2.0 // indirect github.com/imdario/mergo v0.3.15 // indirect github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect @@ -109,10 +116,11 @@ require ( github.com/magiconair/properties v1.8.7 // indirect github.com/mailru/easyjson v0.7.7 // indirect github.com/mattn/go-colorable v0.1.13 // indirect - github.com/mattn/go-isatty v0.0.16 // indirect - github.com/mattn/go-runewidth v0.0.9 // indirect + github.com/mattn/go-isatty v0.0.17 // indirect + github.com/mattn/go-runewidth v0.0.13 // indirect github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect github.com/microcosm-cc/bluemonday v1.0.21 // indirect + github.com/mmcloughlin/addchain v0.4.0 // indirect github.com/moby/patternmatcher v0.5.0 // indirect github.com/moby/sys/sequential v0.5.0 // indirect github.com/moby/term v0.5.0 // indirect @@ -128,12 +136,14 @@ require ( github.com/prometheus/client_model v0.3.0 // indirect github.com/prometheus/common v0.39.0 // indirect github.com/prometheus/procfs v0.9.0 // indirect + github.com/rivo/uniseg v0.2.0 // indirect github.com/rogpeppe/go-internal v1.9.0 // indirect github.com/russross/blackfriday/v2 v2.1.0 // indirect github.com/sergi/go-diff v1.1.0 // indirect github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible // indirect github.com/sirupsen/logrus v1.9.0 // indirect github.com/skeema/knownhosts v1.1.1 // indirect + github.com/supranational/blst v0.3.11 // indirect github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 // indirect github.com/tklauser/go-sysconf v0.3.12 // indirect github.com/tklauser/numcpus v0.6.1 // indirect @@ -142,19 +152,19 @@ require ( github.com/valyala/fasttemplate v1.2.1 // indirect github.com/xanzy/ssh-agent v0.3.3 // indirect github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect - golang.org/x/crypto v0.12.0 // indirect - golang.org/x/mod v0.11.0 // indirect - golang.org/x/net v0.10.0 // indirect - golang.org/x/sys v0.11.0 // indirect - golang.org/x/text v0.12.0 // indirect + golang.org/x/crypto v0.17.0 // indirect + golang.org/x/mod v0.14.0 // indirect + golang.org/x/net v0.18.0 // indirect + golang.org/x/sys v0.16.0 // indirect + golang.org/x/text v0.14.0 // indirect golang.org/x/time v0.3.0 // indirect - golang.org/x/tools v0.9.1 // indirect + golang.org/x/tools v0.15.0 // indirect google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect google.golang.org/grpc v1.56.3 // indirect google.golang.org/protobuf v1.30.0 // indirect - gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect gopkg.in/warnings.v0 v0.1.2 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect + rsc.io/tmplfunc v0.0.3 // indirect ) -replace github.com/ethereum/go-ethereum v1.13.1 => github.com/taikoxyz/taiko-geth v0.0.0-20230920223320-89ffc4c82519 +replace github.com/ethereum/go-ethereum v1.13.1 => github.com/taikoxyz/taiko-geth v0.0.0-20240208145922-98152a0c9fc8 diff --git a/go.sum b/go.sum index a3a10a43165..2a4e8ff062b 100644 --- a/go.sum +++ b/go.sum @@ -30,8 +30,8 @@ github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdko github.com/Shopify/goreferrer v0.0.0-20181106222321-ec9c9a553398/go.mod h1:a1uqRtAwp2Xwc6WNPJEufxJ7fx3npB4UV/JOLmbu5I0= github.com/StackExchange/wmi v1.2.1 h1:VIkavFPXSjcnS+O8yTq7NI32k0R5Aj+v39y29VYDOSA= github.com/StackExchange/wmi v1.2.1/go.mod h1:rcmrprowKIVzvc+NUiLncP2uuArMWLCbu9SBzvHz7e8= -github.com/VictoriaMetrics/fastcache v1.6.0 h1:C/3Oi3EiBCqufydp1neRZkqcwmEiuRT9c3fqvvgKm5o= -github.com/VictoriaMetrics/fastcache v1.6.0/go.mod h1:0qHz5QP0GMX4pfmMA/zt5RgfNuXJrTP0zS7DqpHGGTw= +github.com/VictoriaMetrics/fastcache v1.12.1 h1:i0mICQuojGDL3KblA7wUNlY5lOK6a4bwt3uRKnkZU40= +github.com/VictoriaMetrics/fastcache v1.12.1/go.mod h1:tX04vaqcNoQeGLD+ra5pU5sWkuxnzWhEzLwhP9w653o= github.com/acomagu/bufpipe v1.0.4 h1:e3H4WUzM3npvo5uv95QuJM3cQspFNtFBzvJ2oNjKIDQ= github.com/acomagu/bufpipe v1.0.4/go.mod h1:mxdxdup/WdsKVreO5GpW4+M/1CE2sMG4jeGJ2sYmHc4= github.com/ajg/form v1.5.1/go.mod h1:uL1WgH+h2mgNtvBq0339dVnzXdBETtL2LeUXaIv25UY= @@ -53,8 +53,8 @@ github.com/aymerick/douceur v0.2.0/go.mod h1:wlT5vV2O3h55X9m7iVYN0TBM0NH/MmbLnd3 github.com/aymerick/raymond v2.0.3-0.20180322193309-b565731e1464+incompatible/go.mod h1:osfaiScAUVup+UC9Nfq76eWqDhXlp+4UYaA8uhTBO6g= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= -github.com/bits-and-blooms/bitset v1.7.0 h1:YjAGVd3XmtK9ktAbX8Zg2g2PwLIMjGREZJHlV4j7NEo= -github.com/bits-and-blooms/bitset v1.7.0/go.mod h1:gIdJ4wp64HaoK2YrL1Q5/N7Y16edYb8uY+O0FJTyyDA= +github.com/bits-and-blooms/bitset v1.10.0 h1:ePXTeiPEazB5+opbv5fr8umg2R/1NlzgDsyepwsSr88= +github.com/bits-and-blooms/bitset v1.10.0/go.mod h1:7hO7Gc7Pp1vODcmWvKMRA9BNmbv6a/7QIWpPxHddWR8= github.com/btcsuite/btcd/btcec/v2 v2.3.2 h1:5n0X6hX0Zk+6omWcihdYvdAlGf2DfasC0GMf7DClJ3U= github.com/btcsuite/btcd/btcec/v2 v2.3.2/go.mod h1:zYzJ8etWJQIv1Ogk7OzpWjowwOdXY1W/17j2MW85J04= github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 h1:q0rUy8C/TYNBQS1+CGKw68tLOFYSNEs0TFnxxnS9+4U= @@ -69,7 +69,6 @@ github.com/cenkalti/backoff/v4 v4.2.1/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyY github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/cespare/cp v0.1.0 h1:SE+dxFebS7Iik5LK0tsi1k9ZCxEaFX4AjQmoyA+1dJk= github.com/cespare/cp v0.1.0/go.mod h1:SOGHArjBr4JWaSDEVpWpo/hNg6RoKrls6Oh40hiwW+s= -github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/checkpoint-restore/go-criu/v5 v5.3.0/go.mod h1:E/eQpaFtUKGOOSEBZgmKAcn+zUUwWxqcaKZlF54wK8E= @@ -83,22 +82,24 @@ github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGX github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= github.com/cockroachdb/apd v1.1.0/go.mod h1:8Sl8LxpKi29FqWXR16WEFZRNSz3SoPzUzeMeY4+DwBQ= github.com/cockroachdb/datadriven v1.0.2/go.mod h1:a9RdTaap04u637JoCzcUoIcDmvwSUtcUFtT/C3kJlTU= -github.com/cockroachdb/datadriven v1.0.3-0.20230801171734-e384cf455877 h1:1MLK4YpFtIEo3ZtMA5C795Wtv5VuUnrXX7mQG+aHg6o= -github.com/cockroachdb/datadriven v1.0.3-0.20230801171734-e384cf455877/go.mod h1:a9RdTaap04u637JoCzcUoIcDmvwSUtcUFtT/C3kJlTU= +github.com/cockroachdb/datadriven v1.0.3-0.20230413201302-be42291fc80f h1:otljaYPt5hWxV3MUfO5dFPFiOXg9CyG5/kCfayTqsJ4= +github.com/cockroachdb/datadriven v1.0.3-0.20230413201302-be42291fc80f/go.mod h1:a9RdTaap04u637JoCzcUoIcDmvwSUtcUFtT/C3kJlTU= github.com/cockroachdb/errors v1.9.1 h1:yFVvsI0VxmRShfawbt/laCIDy/mtTqqnvoNgiy5bEV8= github.com/cockroachdb/errors v1.9.1/go.mod h1:2sxOtL2WIc096WSZqZ5h8fa17rdDq9HZOZLBCor4mBk= github.com/cockroachdb/logtags v0.0.0-20211118104740-dabe8e521a4f/go.mod h1:Vz9DsVWQQhf3vs21MhPMZpMGSht7O/2vFW2xusFUVOs= github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b h1:r6VH0faHjZeQy818SGhaone5OnYfxFR/+AzdY3sf5aE= github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b/go.mod h1:Vz9DsVWQQhf3vs21MhPMZpMGSht7O/2vFW2xusFUVOs= -github.com/cockroachdb/pebble v0.0.0-20230906160148-46873a6a7a06 h1:T+Np/xtzIjYM/P5NAw0e2Rf1FGvzDau1h54MKvx8G7w= -github.com/cockroachdb/pebble v0.0.0-20230906160148-46873a6a7a06/go.mod h1:bynZ3gvVyhlvjLI7PT6dmZ7g76xzJ7HpxfjgkzCGz6s= +github.com/cockroachdb/pebble v0.0.0-20230928194634-aa077af62593 h1:aPEJyR4rPBvDmeyi+l/FS/VtA00IWvjeFvjen1m1l1A= +github.com/cockroachdb/pebble v0.0.0-20230928194634-aa077af62593/go.mod h1:6hk1eMY/u5t+Cf18q5lFMUA1Rc+Sm5I6Ra1QuPyxXCo= github.com/cockroachdb/redact v1.1.3 h1:AKZds10rFSIj7qADf0g46UixK8NNLwWTNdCIGS5wfSQ= github.com/cockroachdb/redact v1.1.3/go.mod h1:BVNblN9mBWFyMyqK1k3AAiSxhvhfK2oOZZ2lK+dpvRg= +github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 h1:zuQyyAKVxetITBuuhv3BI9cMrmStnpT18zmgmTxunpo= +github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06/go.mod h1:7nc4anLGjupUW/PeY5qiNYsdNXj7zopG+eqsS7To5IQ= github.com/codegangsta/inject v0.0.0-20150114235600-33e0aa1cb7c0/go.mod h1:4Zcjuz89kmFXt9morQgcfYZAYZ5n8WHjt81YYWIwtTM= github.com/consensys/bavard v0.1.13 h1:oLhMLOFGTLdlda/kma4VOJazblc7IM5y5QPd2A/YjhQ= github.com/consensys/bavard v0.1.13/go.mod h1:9ItSMtA/dXMAiL7BG6bqW2m3NdSEObYWoH223nGHukI= -github.com/consensys/gnark-crypto v0.10.0 h1:zRh22SR7o4K35SoNqouS9J/TKHTyU2QWaj5ldehyXtA= -github.com/consensys/gnark-crypto v0.10.0/go.mod h1:Iq/P3HHl0ElSjsg2E1gsMwhAyxnxoKK5nVyZKd+/KhU= +github.com/consensys/gnark-crypto v0.12.1 h1:lHH39WuuFgVHONRl3J0LRBtuYdQTumFSDtJF7HpyG8M= +github.com/consensys/gnark-crypto v0.12.1/go.mod h1:v2Gy7L/4ZRosZ7Ivs+9SfUDr0f5UlG+EM5t7MPHiLuY= github.com/containerd/console v1.0.3/go.mod h1:7LqA/THxQ86k76b8c/EMSiaJ3h1eZkMkXar0TQ1gf3U= github.com/containerd/containerd v1.6.19 h1:F0qgQPrG0P2JPgwpxWxYavrVeXAG0ezUIB9Z/4FTUAU= github.com/containerd/containerd v1.6.19/go.mod h1:HZCDMn4v/Xl2579/MvtOC2M206i+JJ6VxFWU/NetrGY= @@ -114,8 +115,10 @@ github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwc github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w= github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= -github.com/crate-crypto/go-kzg-4844 v0.3.0 h1:UBlWE0CgyFqqzTI+IFyCzA7A3Zw4iip6uzRv5NIXG0A= -github.com/crate-crypto/go-kzg-4844 v0.3.0/go.mod h1:SBP7ikXEgDnUPONgm33HtuDZEDtWa3L4QtN1ocJSEQ4= +github.com/crate-crypto/go-ipa v0.0.0-20231025140028-3c0104f4b233 h1:d28BXYi+wUpz1KBmiF9bWrjEMacUEREV6MBi2ODnrfQ= +github.com/crate-crypto/go-ipa v0.0.0-20231025140028-3c0104f4b233/go.mod h1:geZJZH3SzKCqnz5VT0q/DyIG/tvu/dZk+VIfXicupJs= +github.com/crate-crypto/go-kzg-4844 v0.7.0 h1:C0vgZRk4q4EZ/JgPfzuSoxdCq3C3mOZMBShovmncxvA= +github.com/crate-crypto/go-kzg-4844 v0.7.0/go.mod h1:1kMhvPgI0Ky3yIa+9lFySEBUBXkYxeOi8ZF1sYioxhc= github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/creack/pty v1.1.18 h1:n56/Zwd5o6whRC5PMGretI4IdRLlmBXYNjScPaBgsbY= @@ -162,8 +165,8 @@ github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1m github.com/envoyproxy/go-control-plane v0.9.9-0.20210217033140-668b12f5399d/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/etcd-io/bbolt v1.3.3/go.mod h1:ZF2nL25h33cCyBtcyWeZ2/I3HQOfTP+0PIEvHjkjCrw= -github.com/ethereum/c-kzg-4844 v0.3.1 h1:sR65+68+WdnMKxseNWxSJuAv2tsUrihTpVBTfM/U5Zg= -github.com/ethereum/c-kzg-4844 v0.3.1/go.mod h1:VewdlzQmpT5QSrVhbBuGoCdFJkpaJlO1aQputP83wc0= +github.com/ethereum/c-kzg-4844 v0.4.0 h1:3MS1s4JtA868KpJxroZoepdV0ZKBp3u/O5HcZ7R3nlY= +github.com/ethereum/c-kzg-4844 v0.4.0/go.mod h1:VewdlzQmpT5QSrVhbBuGoCdFJkpaJlO1aQputP83wc0= github.com/fasthttp-contrib/websocket v0.0.0-20160511215533-1f3b11f56072/go.mod h1:duJ4Jxv5lDcvg4QuQr0oowTf7dz4/CR8NtyCooz9HL8= github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M= github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5 h1:FtmdgXiUlNeRsoNMFlKLDt+S+6hbjVMEW6RGQ7aUf7c= @@ -176,6 +179,8 @@ github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbS github.com/gavv/httpexpect v2.0.0+incompatible/go.mod h1:x+9tiU1YnrOvnB725RkpoLv1M62hOWzwo5OXotisrKc= github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff h1:tY80oXqGNY4FhTFhk+o9oFHGINQ/+vhlm8HFzi6znCI= github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff/go.mod h1:x7DCsMOv1taUwEWCzT4cmDeAkigA5/QCwUodaVOe8Ww= +github.com/gballet/go-verkle v0.1.1-0.20231031103413-a67434b50f46 h1:BAIP2GihuqhwdILrV+7GJel5lyPV3u1+PgzrWLc0TkE= +github.com/gballet/go-verkle v0.1.1-0.20231031103413-a67434b50f46/go.mod h1:QNpY22eby74jVhqH4WhDLDwxc/vqsern6pW+u2kbkpc= github.com/getsentry/sentry-go v0.12.0/go.mod h1:NSap0JBYWzHND8oMbyi0+XZhUalc1TBdRL1M71JZW2c= github.com/getsentry/sentry-go v0.18.0 h1:MtBW5H9QgdcJabtZcuJG80BMOwaBpkRDZkxRkNC1sN0= github.com/getsentry/sentry-go v0.18.0/go.mod h1:Kgon4Mby+FJ7ZWHFUAZgVaIa8sxHtnRJRLTXZr51aKQ= @@ -198,8 +203,9 @@ github.com/go-git/go-git/v5 v5.7.0/go.mod h1:coJHKEOk5kUClpsNlXrUvPrDxY3w3gjHvhc github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY= github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= github.com/go-martini/martini v0.0.0-20170121215854-22fa46961aab/go.mod h1:/P9AEU963A2AYjv4d1V5eVL1CQbEJq6aCNHDDjibzu8= -github.com/go-ole/go-ole v1.2.5 h1:t4MGB5xEDZvXI+0rMjjsfBsD7yAgp/s9ZDkL1JndXwY= github.com/go-ole/go-ole v1.2.5/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= +github.com/go-ole/go-ole v1.3.0 h1:Dt6ye7+vXGIKZ7Xtk4s6/xVdGDQynvom7xCFEdWr6uE= +github.com/go-ole/go-ole v1.3.0/go.mod h1:5LS6F96DhAwUc7C+1HLexzMXY1xGRSryjyPPKW6zv78= github.com/go-openapi/jsonpointer v0.19.3/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg= github.com/go-openapi/jsonpointer v0.19.5 h1:gZr+CIYByUqjcgeLXnQu2gHYQC9o73G2XUeOFYEICuY= github.com/go-openapi/jsonpointer v0.19.5/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg= @@ -224,8 +230,6 @@ github.com/go-playground/validator/v10 v10.11.1/go.mod h1:i+3WkQ1FvaUjjxh1kSvIA4 github.com/go-sql-driver/mysql v1.6.0 h1:BCTh4TKNUYmOmMUcQ3IipzF5prigylS7XXjEkfCHuOE= github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= -github.com/go-stack/stack v1.8.1 h1:ntEHSVwIt7PNXNpgPmVfMrNhLtgjlmnZha2kOpuRiDw= -github.com/go-stack/stack v1.8.1/go.mod h1:dcoOX6HbPZSZptuspn9bctJ+N/CnF5gGygcUP3XYfe4= github.com/gobwas/httphead v0.0.0-20180130184737-2c6c146eadee/go.mod h1:L0fX3K22YWvt/FAX9NnzrNzcI4wNYi9Yku4O0LKYflo= github.com/gobwas/pool v0.2.0/go.mod h1:q8bcK0KcYlCgd9e7WYLm9LpyS+YeLd8JVDW6WezmKEw= github.com/gobwas/ws v1.0.2/go.mod h1:szmBTxLgaFppYjEmNtny/v3w89xOydFnnZMcgRRu/EM= @@ -242,8 +246,9 @@ github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69 github.com/gogo/status v1.1.0/go.mod h1:BFv9nrluPLmrS0EmGVvLaPNmRosr9KapBYd5/hpY1WM= github.com/golang-jwt/jwt v3.2.2+incompatible h1:IfV12K8xAKAnZqdXVzCZ+TOjboZ2keLg81eXfW3O+oY= github.com/golang-jwt/jwt v3.2.2+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I= -github.com/golang-jwt/jwt/v4 v4.4.3 h1:Hxl6lhQFj4AnOX6MLrsCb/+7tCj7DxP7VA+2rDIq5AU= github.com/golang-jwt/jwt/v4 v4.4.3/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= +github.com/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg= +github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0= github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9 h1:au07oEsX2xN0ktxqI+Sida1w446QrXBRJ0nee3SNZlA= github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0= @@ -270,7 +275,6 @@ github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaS github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= -github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb h1:PBC98N2aIaM3XXiurYmW7fx4GZkL8feAMVq7nEjURHk= github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= @@ -288,7 +292,10 @@ github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= +github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= +github.com/google/subcommands v1.2.0/go.mod h1:ZjhPrFU+Olkh9WazFPsl27BQ4UPiG37m3yTrtFlrHVk= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4= @@ -307,11 +314,11 @@ github.com/holiman/billy v0.0.0-20230718173358-1c7e68d277a7 h1:3JQNjnMRil1yD0IfZ github.com/holiman/billy v0.0.0-20230718173358-1c7e68d277a7/go.mod h1:5GuXa7vkL8u9FkFuWdVvfR5ix8hRB7DbOAaYULamFpc= github.com/holiman/bloomfilter/v2 v2.0.3 h1:73e0e/V0tCydx14a0SCYS/EWCxgwLZ18CZcZKVu0fao= github.com/holiman/bloomfilter/v2 v2.0.3/go.mod h1:zpoh+gs7qcpqrHr3dB55AMiJwo0iURXE7ZOP9L9hSkA= -github.com/holiman/uint256 v1.2.3 h1:K8UWO1HUJpRMXBxbmaY1Y8IAMZC/RsKB+ArEnnK4l5o= -github.com/holiman/uint256 v1.2.3/go.mod h1:SC8Ryt4n+UBbPbIBKaG9zbbDlp4jOru9xFZmPzLUTxw= +github.com/holiman/uint256 v1.2.4 h1:jUc4Nk8fm9jZabQuqr2JzednajVmBpC+oiTiXZJEApU= +github.com/holiman/uint256 v1.2.4/go.mod h1:EOMSn4q6Nyt9P6efbI3bueV4e1b3dGlUCXeiRV4ng7E= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= -github.com/huin/goupnp v1.0.3 h1:N8No57ls+MnjlB+JPiCVSOyy/ot7MJTqlo7rn+NYSqQ= -github.com/huin/goupnp v1.0.3/go.mod h1:ZxNlw5WqJj6wSsRK5+YfflQGXYfccj5VgQsMNixHM7Y= +github.com/huin/goupnp v1.3.0 h1:UvLUlWDNpoUdYzb2TCn+MuTWtcjXKSza2n6CBdQ0xXc= +github.com/huin/goupnp v1.3.0/go.mod h1:gnGPsThkYa7bFi/KWmEysQRf48l2dvR5bxr2OFckNX8= github.com/hydrogen18/memlistener v0.0.0-20200120041712-dcc25e7acd91/go.mod h1:qEIFzExnS6016fRpRfxrExeVn2gbClQA99gQhnIcdhE= github.com/iancoleman/strcase v0.1.3/go.mod h1:SK73tn/9oHe+/Y0h39VT4UCxmurVJkR5NA7kMEAOgSE= github.com/iancoleman/strcase v0.2.0 h1:05I4QRnGpI0m37iZQRuskXh+w77mr6Z41lwQzuHLwW0= @@ -439,6 +446,8 @@ github.com/labstack/gommon v0.2.8/go.mod h1:/tj9csK2iPSBvn+3NLM9e52usepMtrd5ilFY github.com/labstack/gommon v0.3.0/go.mod h1:MULnywXg0yavhxWKc+lOruYdAhDwPK9wf0OL7NoOu+k= github.com/labstack/gommon v0.4.0 h1:y7cvthEAEbU0yHOf4axH8ZG2NH8knB9iNSoTO8dyIk8= github.com/labstack/gommon v0.4.0/go.mod h1:uW6kP17uPlLJsD3ijUYn3/M5bAxtlZhMI6m3MFxTMTM= +github.com/leanovate/gopter v0.2.9 h1:fQjYxZaynp97ozCzfOyOuAGOU4aU/z37zf/tOujFk7c= +github.com/leanovate/gopter v0.2.9/go.mod h1:U2L/78B+KVFIx2VmW6onHJQzXtFb+p5y3y2Sh+Jxxv8= github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII= github.com/leodido/go-urn v1.2.1 h1:BqpAaACuzVSgi/VLzGZIobT2z4v53pjosyNd9Yv6n/w= github.com/leodido/go-urn v1.2.1/go.mod h1:zt4jvISO2HfUBqxjfIshjdMTYS56ZS/qv49ictyFfxY= @@ -471,10 +480,12 @@ github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hd github.com/mattn/go-isatty v0.0.9/go.mod h1:YNRxwqDuOph6SZLI9vUUz6OYw3QyUt7WiY2yME+cCiQ= github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= -github.com/mattn/go-isatty v0.0.16 h1:bq3VjFmv/sOjHtdEhmkEV4x1AJtvUvOJ2PFAZ5+peKQ= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= -github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0= +github.com/mattn/go-isatty v0.0.17 h1:BTarxUcIeDqL27Mc+vyvdWYSL28zpIhv3RoTdsLMPng= +github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= +github.com/mattn/go-runewidth v0.0.13 h1:lTGmDsbAYt5DmK6OnoV7EuIF1wEIFAcxld6ypU4OSgU= +github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/mattn/go-sqlite3 v1.14.5/go.mod h1:WVKg1VTActs4Qso6iwGbiFih2UIHo0ENGwNd0Lj+XmI= github.com/mattn/go-sqlite3 v1.14.9/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU= github.com/mattn/go-sqlite3 v1.14.12 h1:TJ1bhYJPV44phC+IMu1u2K/i5RriLTPe+yc68XDJ1Z0= @@ -495,6 +506,7 @@ github.com/mitchellh/pointerstructure v1.2.0 h1:O+i9nHnXS3l/9Wu7r4NrEdwA2VFTicjU github.com/mitchellh/pointerstructure v1.2.0/go.mod h1:BRAsLI5zgXmw97Lf6s25bs8ohIXc3tViBH44KcwB2g4= github.com/mmcloughlin/addchain v0.4.0 h1:SobOdjm2xLj1KkXN5/n0xTIWyZA2+s99UCY1iPfkHRY= github.com/mmcloughlin/addchain v0.4.0/go.mod h1:A86O+tHqZLMNO4w6ZZ4FlVQEadcoqkyU72HC5wJ4RlU= +github.com/mmcloughlin/profile v0.1.1/go.mod h1:IhHD7q1ooxgwTgjxQYkACGA77oFTDdFVejUS1/tS/qU= github.com/moby/patternmatcher v0.5.0 h1:YCZgJOeULcxLw1Q+sVR636pmS7sPEn1Qo2iAN6M7DBo= github.com/moby/patternmatcher v0.5.0/go.mod h1:hDPoyOpDY7OrrMDLaYoY3hf52gNCR/YOUYxkhApJIxc= github.com/moby/sys/mountinfo v0.5.0/go.mod h1:3bMD3Rg+zkqx8MRYPi7Pyb0Ie97QEBmdxbhnCLlSvSU= @@ -571,6 +583,8 @@ github.com/rabbitmq/amqp091-go v1.8.1 h1:RejT1SBUim5doqcL6s7iN6SBmsQqyTgXb1xMlH0 github.com/rabbitmq/amqp091-go v1.8.1/go.mod h1:+jPrT9iY2eLjRaMSRHUhc3z14E/l85kv/f+6luSD3pc= github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 h1:OdAsTTz6OkFY5QxjkYwrChwuRruF69c169dPK26NUlk= github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo= +github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY= +github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6poM+XZ2dLUbcbE= @@ -640,8 +654,8 @@ github.com/swaggo/swag v1.16.2/go.mod h1:6YzXnDcpr0767iOejs318CwYkCQqyGer6BizOg0 github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww= github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 h1:epCh84lMvA70Z7CTTCmYQn2CKbY8j86K7/FAIr141uY= github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45IWZaF22tdD+VEXcAWRA037jwmWEB5VWYORlTpc= -github.com/taikoxyz/taiko-geth v0.0.0-20230920223320-89ffc4c82519 h1:erGTosWbilG2cMXaBW+qxol2Bu/gEXx1cDS80hQ/WXE= -github.com/taikoxyz/taiko-geth v0.0.0-20230920223320-89ffc4c82519/go.mod h1:1cRAEV+rp/xX0zraSCBnu9Py3HQ+geRMj3HdR+k0wfI= +github.com/taikoxyz/taiko-geth v0.0.0-20240208145922-98152a0c9fc8 h1:PE5B0McCy7+So4zQFO6b9E2qhCRhKEu+QF7EbRaLiog= +github.com/taikoxyz/taiko-geth v0.0.0-20240208145922-98152a0c9fc8/go.mod h1:gFtlVORuUcT+UUIcJ/veCNjkuOSujCi338uSHJrYAew= github.com/testcontainers/testcontainers-go v0.21.0 h1:syePAxdeTzfkap+RrJaQZpJQ/s/fsUgn11xIvHrOE9U= github.com/testcontainers/testcontainers-go v0.21.0/go.mod h1:c1ez3WVRHq7T/Aj+X3TIipFBwkBaNT5iNCY8+1b83Ng= github.com/tklauser/go-sysconf v0.3.12 h1:0QaGUFOdQaIVdPgfITYzaTegZvdCjmYO52cSFAEVmqU= @@ -726,11 +740,11 @@ golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3/go.mod h1:IxCIyHEi3zRg3s0 golang.org/x/crypto v0.0.0-20220214200702-86341886e292/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= -golang.org/x/crypto v0.12.0 h1:tFM/ta59kqch6LlvYnPa0yx5a83cL2nHflFhYKvv9Yk= -golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98yw= +golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k= +golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/exp v0.0.0-20230810033253-352e893a4cad h1:g0bG7Z4uG+OgH2QDODnjp6ggkk1bJDsINcuWmJN1iJU= -golang.org/x/exp v0.0.0-20230810033253-352e893a4cad/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc= +golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa h1:FRnLl4eNAQl8hwxVVC17teOw8kdjVDVAiFMtgUdTSRQ= +golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa/go.mod h1:zk2irFbV9DP96SEBUUAy67IdHUaZuSnrz1n472HUCLE= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= @@ -743,8 +757,8 @@ golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= -golang.org/x/mod v0.11.0 h1:bUO06HqtnRcc/7l71XBe4WcqTZ+3AH1J59zWDDwLKgU= -golang.org/x/mod v0.11.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= +golang.org/x/mod v0.14.0 h1:dGoOF9QVLYng8IHTm7BAyWqCqSheQ5pYWGhzW00YJr0= +golang.org/x/mod v0.14.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -774,8 +788,8 @@ golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug golang.org/x/net v0.0.0-20220906165146-f3363e06e74c/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= -golang.org/x/net v0.10.0 h1:X2//UzNDwYmtCLn7To6G58Wr6f5ahEAQgKNzv9Y951M= -golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= +golang.org/x/net v0.18.0 h1:mIYleuAkSbHh0tCv7RvjL3F6ZVbLjq4+R7zbOn3Kokg= +golang.org/x/net v0.18.0/go.mod h1:/czyP5RqHAH4odGYxBJ1qz0+CE5WZ+2j1YgoEo8F2jQ= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -787,8 +801,8 @@ golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E= -golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= +golang.org/x/sync v0.5.0 h1:60k92dhOjHxJkrqnwsfl8KuaHbn/5dl0lUPUklKo3qE= +golang.org/x/sync v0.5.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -817,7 +831,6 @@ golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210225134936-a50acf3fe073/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210324051608-47abb6519492/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210403161142-5e06dd20ab57/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210420072515-93ed5bcd2bfe/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -840,19 +853,21 @@ golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM= golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU= +golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U= -golang.org/x/term v0.11.0 h1:F9tnn/DA/Im8nCwm+fX+1/eBwi4qFjRT++MhtVC4ZX0= -golang.org/x/term v0.11.0/go.mod h1:zC9APTIj3jG3FdV/Ons+XE1riIZXG4aZ4GTHiPZJPIU= +golang.org/x/term v0.15.0 h1:y/Oo/a/q3IXu26lQgl04j/gjuBDOBlx7X6Om1j2CPW4= +golang.org/x/term v0.15.0/go.mod h1:BDl952bC7+uMoWR75FIrCDx79TPU9oHkTZ9yRbYOrX0= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= @@ -862,8 +877,8 @@ golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= -golang.org/x/text v0.12.0 h1:k+n5B8goJNdU7hSvEtMUz3d1Q6D/XW4COJSJR6fN0mc= -golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= +golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= +golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/time v0.0.0-20201208040808-7e3f01d25324/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.3.0 h1:rg5rLMjNzMS1RkNLzCG38eapWhnYLFYXDXj2gOlr8j4= golang.org/x/time v0.3.0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -888,16 +903,15 @@ golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4f golang.org/x/tools v0.1.3/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= -golang.org/x/tools v0.9.1 h1:8WMNJAz3zrtPmnYC7ISf5dEn3MT0gY7jBJfw27yrrLo= -golang.org/x/tools v0.9.1/go.mod h1:owI94Op576fPu3cIGQeHs3joujW/2Oc6MtlxbF5dfNc= +golang.org/x/tools v0.15.0 h1:zdAyfUGbYmuVokhzVmghFl2ZJh5QhcfebBgmVPFYA+8= +golang.org/x/tools v0.15.0/go.mod h1:hpksKq4dtpQWS1uQ61JkdqWM3LscIS6Slf+VVkm+wQk= golang.org/x/xerrors v0.0.0-20190410155217-1f06c39b4373/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20190513163551-3ee3066db522/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20220517211312-f3a8303e98df h1:5Pf6pFKu98ODmgnpvkJ3kFUOQGGLIzLIkbzUHp47618= -golang.org/x/xerrors v0.0.0-20220517211312-f3a8303e98df/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/genproto v0.0.0-20180518175338-11a468237815/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= @@ -946,8 +960,6 @@ gopkg.in/ini.v1 v1.51.1/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/mgo.v2 v2.0.0-20180705113604-9856a29383ce/go.mod h1:yeKp02qBN3iKW1OzL3MGk2IdtZzaj7SFntXj72NppTA= gopkg.in/natefinch/lumberjack.v2 v2.0.0 h1:1Lc07Kr7qY4U2YPouBjpCLxpiyxIVoxqXgkXLknAOE8= gopkg.in/natefinch/lumberjack.v2 v2.0.0/go.mod h1:l0ndWWf7gzL7RNwBG7wST/UCcT4T24xpD6X8LsfU/+k= -gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce h1:+JknDZhAj8YMt7GC73Ei8pv4MzjDUNPHgQWJdtMAaDU= -gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce/go.mod h1:5AcXVHNjg+BDxry382+8OKon8SEWiKktQR07RKPsv1c= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME= diff --git a/packages/relayer/indexer/indexer.go b/packages/relayer/indexer/indexer.go index e5d8b31154c..8c2f2cc23f2 100644 --- a/packages/relayer/indexer/indexer.go +++ b/packages/relayer/indexer/indexer.go @@ -346,6 +346,7 @@ func (i *Indexer) filter(ctx context.Context) error { } else { slog.Info("handled event successfully") } + return nil }) } diff --git a/packages/relayer/indexer/subscribe.go b/packages/relayer/indexer/subscribe.go index d6ec937465e..1f85694f8aa 100644 --- a/packages/relayer/indexer/subscribe.go +++ b/packages/relayer/indexer/subscribe.go @@ -108,6 +108,7 @@ func (i *Indexer) subscribeMessageStatusChanged(ctx context.Context, chainID *bi if err != nil { slog.Error("i.bridge.WatchMessageStatusChanged", "error", err) } + slog.Info("resubscribing to WatchMessageStatusChanged events") return i.bridge.WatchMessageStatusChanged(&bind.WatchOpts{ diff --git a/packages/relayer/pkg/mock/bridge.go b/packages/relayer/pkg/mock/bridge.go index f9961bbaca0..649007466ce 100644 --- a/packages/relayer/pkg/mock/bridge.go +++ b/packages/relayer/pkg/mock/bridge.go @@ -65,6 +65,7 @@ func (b *Bridge) WatchMessageSent( DestChainId: MockChainID.Uint64(), }, } + b.MessagesSent++ }(sink) @@ -74,6 +75,7 @@ func (b *Bridge) WatchMessageSent( errChan <- errors.New("fail") s.done = true + b.ErrorsSent++ }(s.errChan) @@ -100,6 +102,7 @@ func (b *Bridge) WatchMessageStatusChanged( <-time.After(2 * time.Second) sink <- &bridge.BridgeMessageStatusChanged{} + b.MessageStatusesChanged++ }(sink) @@ -109,6 +112,7 @@ func (b *Bridge) WatchMessageStatusChanged( errChan <- errors.New("fail") s.done = true + b.ErrorsSent++ }(s.errChan) diff --git a/packages/relayer/pkg/proof/block_header.go b/packages/relayer/pkg/proof/block_header.go index fcb62d21d5e..cc8f6a0fdad 100644 --- a/packages/relayer/pkg/proof/block_header.go +++ b/packages/relayer/pkg/proof/block_header.go @@ -2,6 +2,7 @@ package proof import ( "context" + "log/slog" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" @@ -26,6 +27,8 @@ func (p *Prover) blockHeader( return encoding.BlockHeader{}, errors.Wrap(err, "blocker.BlockByNumber") } } else { + slog.Info("getting block by hash", "blockHash", blockHash.Hex()) + b, err = blocker.BlockByHash(ctx, blockHash) if err != nil { return encoding.BlockHeader{}, errors.Wrap(err, "blocker.BlockByHash") diff --git a/packages/relayer/pkg/repo/event_test.go b/packages/relayer/pkg/repo/event_test.go index bf9ba228e57..eea99c7f9ab 100644 --- a/packages/relayer/pkg/repo/event_test.go +++ b/packages/relayer/pkg/repo/event_test.go @@ -193,7 +193,9 @@ func TestIntegration_Event_UpdateStatus(t *testing.T) { ) assert.Equal(t, nil, err) } + err := eventRepo.UpdateStatus(context.Background(), tt.id, tt.status) + assert.Equal(t, tt.wantErr, err != nil) }) } @@ -206,6 +208,7 @@ func TestIntegration_Event_FindAllByAddress(t *testing.T) { defer close() eventRepo, err := NewEventRepository(db) + assert.Equal(t, nil, err) addr := common.HexToAddress("0x71C7656EC7ab88b098defB751B7401B5f6d8976F") @@ -225,6 +228,7 @@ func TestIntegration_Event_FindAllByAddress(t *testing.T) { MessageOwner: addr.Hex(), Event: relayer.EventNameMessageSent, }) + assert.Equal(t, nil, err) _, err = eventRepo.Save(context.Background(), relayer.SaveEventOpts{ diff --git a/packages/relayer/processor/process_message.go b/packages/relayer/processor/process_message.go index 1110bafdfa2..13a016469d6 100644 --- a/packages/relayer/processor/process_message.go +++ b/packages/relayer/processor/process_message.go @@ -354,6 +354,7 @@ func (p *Processor) sendProcessMessageCall( // or whether the contract is deployed. if err != nil || gas == 0 { slog.Info("gas estimation failed, hardcoding gas limit", "p.estimateGas:", err) + err = p.hardcodeGasLimit(ctx, auth, event, eventType, canonicalToken) if err != nil { return nil, errors.Wrap(err, "p.hardcodeGasLimit") @@ -568,6 +569,7 @@ func (p *Processor) setGasTipOrPrice(ctx context.Context, auth *bind.TransactOpt if err != nil { return errors.Wrap(err, "p.destBridge.SuggestGasPrice") } + auth.GasPrice = gasPrice } } diff --git a/packages/relayer/processor/processor.go b/packages/relayer/processor/processor.go index ae769851080..d07f4b51a26 100644 --- a/packages/relayer/processor/processor.go +++ b/packages/relayer/processor/processor.go @@ -292,7 +292,7 @@ func InitFromConfig(ctx context.Context, p *Processor, cfg *Config) error { } var q queue.Queue - if p.targetTxHash != nil { + if cfg.TargetTxHash == nil { q, err = cfg.OpenQueueFunc() if err != nil { return err diff --git a/packages/relayer/types_test.go b/packages/relayer/types_test.go index a8942f90940..0a2ae764a46 100644 --- a/packages/relayer/types_test.go +++ b/packages/relayer/types_test.go @@ -102,6 +102,7 @@ func Test_WaitReceipt(t *testing.T) { } else { assert.Nil(t, err) } + assert.Equal(t, tt.wantReceipt, receipt) }) } @@ -193,6 +194,7 @@ func Test_DecodeMessageSentData(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { eventType, canonicalToken, amount, err := DecodeMessageSentData(tt.event) + assert.Equal(t, tt.wantEventType, eventType) assert.Equal(t, tt.wantCanonicalToken, canonicalToken) assert.Equal(t, tt.wantAmount, amount)