Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

chore(protocol): fix issues in test:coverage #18582

Merged
merged 7 commits into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,087 changes: 526 additions & 561 deletions packages/protocol/contract_layout_layer1.md

Large diffs are not rendered by default.

4 changes: 1 addition & 3 deletions packages/protocol/foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ gas_price = 10_000_000_000 # 10 Gwei
gas_limit = "18446744073709551615" # u64::MAX
optimizer = true
optimizer_runs = 200
fuzz_runs = 200
ffi = true
memory_limit = 2_073_741_824
solc_version = "0.8.27"
Expand Down Expand Up @@ -44,9 +45,6 @@ fs_permissions = [
# 5740: Unreachable code
ignored_error_codes = [2394, 3860, 5574, 5740]

[fuzz]
runs = 200

[fmt]
bracket_spacing = true
line_length = 100
Expand Down
2 changes: 1 addition & 1 deletion packages/protocol/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 0 additions & 3 deletions packages/protocol/script/gen-layouts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ contracts_shared=(
contracts_layer1=(
"contracts/layer1/token/TaikoToken.sol:TaikoToken"
"contracts/layer1/verifiers/compose/ComposeVerifier.sol:ComposeVerifier"
"contracts/layer1/verifiers/compose/TeeAnyVerifier.sol:TeeAnyVerifier"
"contracts/layer1/verifiers/compose/ZkAndTeeVerifier.sol:ZkAndTeeVerifier"
"contracts/layer1/verifiers/compose/ZkAnyVerifier.sol:ZkAnyVerifier"
"contracts/layer1/verifiers/Risc0Verifier.sol:Risc0Verifier"
"contracts/layer1/verifiers/SP1Verifier.sol:SP1Verifier"
"contracts/layer1/verifiers/SgxVerifier.sol:SgxVerifier"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ 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);
Expand Down
6 changes: 3 additions & 3 deletions packages/protocol/snapshots/TaikoL1Test_Suite1.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"proposeBlocksV3": "84387",
"proveBlocksV3": "133463"
}
"proposeBlocksV3": "102241",
"proveBlocksV3": "159549"
}
22 changes: 11 additions & 11 deletions packages/protocol/test/layer1/based/TaikoL1TestBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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(
Expand Down
16 changes: 8 additions & 8 deletions packages/protocol/test/layer2/LibEIP1559.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should also change layer_2.fuzz_runs to default.fuzz_runs, no?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. Rename both layer2.fuzz.runs and layer2.fuzz.show-logs to default.fuzz_runs and default.fuzz_runs_show_logs

/// forge-config: layer_2.fuzz.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: layer_2.fuzz.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: layer_2.fuzz.show-logs = true
function test_fuzz_adjustExcess(
uint64 _oldGasTarget,
uint64 _newGasTarget,
Expand All @@ -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: layer_2.fuzz.show-logs = true
function test_fuzz_calc1559BaseFee(
uint64 _gasTarget,
uint64 _gasExcess,
Expand Down
8 changes: 4 additions & 4 deletions packages/protocol/test/layer2/TaikoL2.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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: layer_2.fuzz.show-logs = true
function test_fuzz_getBasefeeV2(
uint32 _parentGasUsed,
uint32 _gasIssuancePerSecond,
Expand All @@ -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: layer_2.fuzz.show-logs = true
function test_fuzz_anchorV2(
uint32 _parentGasUsed,
uint32 _gasIssuancePerSecond,
Expand Down
Loading