From 29682b73324f0c891dbec733a39f828e12e8ce93 Mon Sep 17 00:00:00 2001 From: xiaodino Date: Mon, 16 Dec 2024 07:03:01 -0800 Subject: [PATCH] chore(protocol): fix issues in test:coverage (#18582) Co-authored-by: xiaodino Co-authored-by: Daniel Wang <99078276+dantaik@users.noreply.github.com> Co-authored-by: dantaik --- packages/protocol/foundry.toml | 5 ++--- packages/protocol/package.json | 2 +- .../mainnet/SendMessageToDelegateOwner.s.sol | 3 ++- .../snapshots/TaikoL1Test_Suite1.json | 4 ++-- .../test/layer1/based/TaikoL1TestBase.sol | 22 +++++++++---------- .../protocol/test/layer2/LibEIP1559.t.sol | 16 +++++++------- packages/protocol/test/layer2/TaikoL2.t.sol | 8 +++---- 7 files changed, 30 insertions(+), 30 deletions(-) diff --git a/packages/protocol/foundry.toml b/packages/protocol/foundry.toml index 64bd1ffdc22..4c37fe185a1 100644 --- a/packages/protocol/foundry.toml +++ b/packages/protocol/foundry.toml @@ -4,6 +4,8 @@ gas_price = 10_000_000_000 # 10 Gwei gas_limit = "18446744073709551615" # u64::MAX optimizer = true optimizer_runs = 200 +fuzz_runs = 200 +fuzz_runs_show_logs = false ffi = true memory_limit = 2_073_741_824 solc_version = "0.8.27" @@ -44,9 +46,6 @@ fs_permissions = [ # 5740: Unreachable code ignored_error_codes = [2394, 3860, 5574, 5740] -[fuzz] -runs = 200 - [fmt] bracket_spacing = true line_length = 100 diff --git a/packages/protocol/package.json b/packages/protocol/package.json index 06dd334776f..c91b7fe52bb 100644 --- a/packages/protocol/package.json +++ b/packages/protocol/package.json @@ -20,7 +20,7 @@ "test:deploy:l1": "./script/download_solc.sh && ./script/layer1/deploy_protocol_on_l1.sh", "eslint": "pnpm exec eslint --fix --ignore-path .eslintignore --ext .js,.ts .", "fmt:sol": "forge fmt && pnpm solhint 'contracts/**/*.sol'", - "test:coverage": "mkdir -p coverage && forge coverage --report lcov && lcov --remove ./lcov.info -o ./coverage/lcov.info 'test/' 'script/' 'contracts/thirdparty/' && genhtml coverage/lcov.info --branch-coverage --output-dir coverage --ignore-errors category && open coverage/index.html", + "test:coverage": "mkdir -p coverage && forge coverage --report lcov && lcov --ignore-errors inconsistent --ignore-errors unused --remove ./lcov.info -o ./coverage/lcov.info 'test/' 'script/' 'contracts/thirdparty/' && genhtml coverage/lcov.info --branch-coverage --output-dir coverage --ignore-errors category --ignore-errors inconsistent --ignore-errors corrupt && open coverage/index.html", "genesis:gen": "pnpm compile:l2 && ts-node ./test/genesis/generate/generate.ts", "genesis:test": "./test/genesis/genesis.test.sh", "export:simconf": "mkdir -p simulation/out && FOUNDRY_PROFILE=layer2 forge test --match-test 'test_L2_NoFeeCheck_simulation' -vv > simulation/out/simconf_$(date +%s).txt" diff --git a/packages/protocol/script/layer1/mainnet/SendMessageToDelegateOwner.s.sol b/packages/protocol/script/layer1/mainnet/SendMessageToDelegateOwner.s.sol index 374309d422b..116591cfb1e 100644 --- a/packages/protocol/script/layer1/mainnet/SendMessageToDelegateOwner.s.sol +++ b/packages/protocol/script/layer1/mainnet/SendMessageToDelegateOwner.s.sol @@ -11,7 +11,8 @@ contract SendMessageToDelegateOwner is BaseScript { address public delegateOwnerImpl = 0x1f0511cDae2fbfD93563469dA02b82dEd320C8Bd; address public multicall3 = 0xcA11bde05977b3631167028862bE2a173976CA11; address public l1Bridge = 0xd60247c6848B7Ca29eDdF63AA924E53dB6Ddd8EC; - address public testAddress1 = vm.envAddress("TEST_ADDRESS_1"); + address public testAddress1 = + vm.envOr("TEST_ADDRESS_1", address(0x0000000000000000000000000000000000000000)); function run() external broadcast { Multicall3.Call3[] memory calls = new Multicall3.Call3[](2); diff --git a/packages/protocol/snapshots/TaikoL1Test_Suite1.json b/packages/protocol/snapshots/TaikoL1Test_Suite1.json index c5a40884749..92a9fb210e8 100644 --- a/packages/protocol/snapshots/TaikoL1Test_Suite1.json +++ b/packages/protocol/snapshots/TaikoL1Test_Suite1.json @@ -1,4 +1,4 @@ { - "proposeBlocksV3": "84973", - "proveBlocksV3": "133553" + "proposeBlocksV3": "84963", + "proveBlocksV3": "133546" } \ No newline at end of file diff --git a/packages/protocol/test/layer1/based/TaikoL1TestBase.sol b/packages/protocol/test/layer1/based/TaikoL1TestBase.sol index da159cd0a4d..38ba74824a0 100644 --- a/packages/protocol/test/layer1/based/TaikoL1TestBase.sol +++ b/packages/protocol/test/layer1/based/TaikoL1TestBase.sol @@ -131,7 +131,7 @@ abstract contract TaikoL1TestBase is Layer1Test { } function _logAllBlocksAndTransitions() internal view { - console2.log(unicode"├───────────────────────────────────────────────────────────────"); + console2.log(unicode"|───────────────────────────────────────────────────────────────"); ITaikoL1.Stats1 memory stats1 = taikoL1.getStats1(); console2.log("Stats1 - lastSyncedBlockId:", stats1.lastSyncedBlockId); console2.log("Stats1 - lastSyncedAt:", stats1.lastSyncedAt); @@ -153,25 +153,25 @@ abstract contract TaikoL1TestBase is Layer1Test { for (uint64 i = firstBlockId; i < stats2.numBlocks; ++i) { ITaikoL1.BlockV3 memory blk = taikoL1.getBlockV3(i); if (blk.blockId <= stats2.lastVerifiedBlockId) { - console2.log(unicode"├─ ✔ block#", blk.blockId); + console2.log(unicode"|─ ✔ block#", blk.blockId); } else { - console2.log(unicode"├─── block#", blk.blockId); + console2.log(unicode"|─── block#", blk.blockId); } - console2.log(unicode"│ ├── metahash:", Strings.toHexString(uint256(blk.metaHash))); - console2.log(unicode"│ ├── timestamp:", blk.timestamp); - console2.log(unicode"│ ├── anchorBlockId:", blk.anchorBlockId); - console2.log(unicode"│ ├── nextTransitionId:", blk.nextTransitionId); - console2.log(unicode"│ ├── verifiedTransitionId:", blk.verifiedTransitionId); + console2.log(unicode"│ |── metahash:", Strings.toHexString(uint256(blk.metaHash))); + console2.log(unicode"│ |── timestamp:", blk.timestamp); + console2.log(unicode"│ |── anchorBlockId:", blk.anchorBlockId); + console2.log(unicode"│ |── nextTransitionId:", blk.nextTransitionId); + console2.log(unicode"│ |── verifiedTransitionId:", blk.verifiedTransitionId); for (uint24 j = 1; j < blk.nextTransitionId; ++j) { ITaikoL1.TransitionV3 memory tran = taikoL1.getTransitionV3(blk.blockId, j); - console2.log(unicode"│ ├── transition#", j); + console2.log(unicode"│ |── transition#", j); console2.log( - unicode"│ │ ├── parentHash:", + unicode"│ │ |── parentHash:", Strings.toHexString(uint256(tran.parentHash)) ); console2.log( - unicode"│ │ ├── blockHash:", + unicode"│ │ |── blockHash:", Strings.toHexString(uint256(tran.blockHash)) ); console2.log( diff --git a/packages/protocol/test/layer2/LibEIP1559.t.sol b/packages/protocol/test/layer2/LibEIP1559.t.sol index 0a7493124b5..d1e60fc7da8 100644 --- a/packages/protocol/test/layer2/LibEIP1559.t.sol +++ b/packages/protocol/test/layer2/LibEIP1559.t.sol @@ -98,23 +98,23 @@ contract TestLibEIP1559 is Layer2Test { assertEq(baselineBasefee, basefee); } - /// forge-config: layer2.fuzz.runs = 1000 - /// forge-config: layer2.fuzz.show-logs = true + /// forge-config: default.fuzz_runs = 1000 + /// forge-config: default.fuzz_runs_show_logs = true function test_fuzz_ethQty(uint64 _gasTarget, uint64 _gasExcess) external pure { if (_gasTarget == 0) _gasTarget = 1; uint256 result = LibEIP1559.ethQty(_gasTarget, _gasExcess); assertTrue(result > 0); } - /// forge-config: layer2.fuzz.runs = 2000 - /// forge-config: layer2.fuzz.show-logs = true + /// forge-config: default.fuzz_runs = 2000 + /// forge-config: default.fuzz_runs_show_logs = true function test_fuzz_basefee(uint64 _gasTarget, uint64 _gasExcess) external pure { uint256 result = LibEIP1559.basefee(_gasTarget, _gasExcess); assertTrue(result >= 1); } - /// forge-config: layer2.fuzz.runs = 2000 - /// forge-config: layer2.fuzz.show-logs = true + /// forge-config: default.fuzz_runs = 2000 + /// forge-config: default.fuzz_runs_show_logs = true function test_fuzz_adjustExcess( uint64 _oldGasTarget, uint64 _newGasTarget, @@ -134,8 +134,8 @@ contract TestLibEIP1559 is Layer2Test { } } - /// forge-config: layer2.fuzz.runs = 2000 - /// forge-config: layer2.fuzz.show-logs = true + /// forge-config: default.fuzz_runs = 2000 + /// forge-config: default.fuzz_runs_show_logs = true function test_fuzz_calc1559BaseFee( uint64 _gasTarget, uint64 _gasExcess, diff --git a/packages/protocol/test/layer2/TaikoL2.t.sol b/packages/protocol/test/layer2/TaikoL2.t.sol index c8105534792..b739e69af88 100644 --- a/packages/protocol/test/layer2/TaikoL2.t.sol +++ b/packages/protocol/test/layer2/TaikoL2.t.sol @@ -78,8 +78,8 @@ contract TestTaikoL2 is Layer2Test { assertEq(taikoL2.getBlockHash(uint64(1000)), 0); } - /// forge-config: layer2.fuzz.runs = 2000 - /// forge-config: layer2.fuzz.show-logs = true + /// forge-config: default.fuzz_runs = 2000 + /// forge-config: default.fuzz_runs_show_logs = true function test_fuzz_getBasefeeV2( uint32 _parentGasUsed, uint32 _gasIssuancePerSecond, @@ -103,8 +103,8 @@ contract TestTaikoL2 is Layer2Test { assertTrue(basefee_ != 0, "basefee is 0"); } - /// forge-config: layer2.fuzz.runs = 2000 - /// forge-config: layer2.fuzz.show-logs = true + /// forge-config: default.fuzz_runs = 2000 + /// forge-config: default.fuzz_runs_show_logs = true function test_fuzz_anchorV2( uint32 _parentGasUsed, uint32 _gasIssuancePerSecond,