Skip to content

fix les fuzz test and upgrade to go native fuzzing#276

Open
b3hollis wants to merge 1 commit intomorph-l2:mainfrom
b3hollis:refactor/upgrade-fuzzer-to-native
Open

fix les fuzz test and upgrade to go native fuzzing#276
b3hollis wants to merge 1 commit intomorph-l2:mainfrom
b3hollis:refactor/upgrade-fuzzer-to-native

Conversation

@b3hollis
Copy link
Contributor

@b3hollis b3hollis commented Jan 15, 2026

Summary

  • Upgrade fuzzers from go-fuzz to Go native fuzzing (Go 1.18+)
  • Add _test.go wrapper files for 12 fuzzers
  • Fix ARM64 compatibility (go-fuzz doesn't support ARM64)

Changes

  • Remove //go:build gofuzz tag from bn256/bn256_fuzz.go
  • Add native fuzzing wrappers for: bitutil, bn256, difficulty, keystore, les, rangeproof, rlp, runtime, stacktrie, trie, txfetcher, vflux

Summary by CodeRabbit

Release Notes

  • Tests

    • Added fuzz test harnesses for multiple packages (bitutil, bn256, difficulty, keystore, les, rangeproof, rlp, runtime, stacktrie, trie, txfetcher, vflux) to enhance test coverage through randomized testing.
    • Enabled Go fuzzing framework integration across these packages.
  • Bug Fixes

    • Updated contract creation transactions to use non-zero gas pricing in les fuzzer.

✏️ Tip: You can customize this high-level summary in your review settings.

@b3hollis b3hollis requested a review from a team as a code owner January 15, 2026 04:23
@b3hollis b3hollis requested review from r3aker86 and removed request for a team January 15, 2026 04:23
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 15, 2026

📝 Walkthrough

Walkthrough

Go native fuzzing entry points are added across 12 test packages (bitutil, bn256, difficulty, keystore, les, rangeproof, rlp, runtime, stacktrie, trie, txfetcher, vflux) using the testing.F API. Legacy gofuzz build constraints are removed from bn256_fuzz.go, and a gas price parameter in les-fuzzer.go is updated from 0 to params.GWei.

Changes

Cohort / File(s) Summary
Fuzz Test Harness Additions
tests/fuzzers/bitutil/bitutil_test.go, tests/fuzzers/bn256/bn256_test.go, tests/fuzzers/difficulty/difficulty_test.go, tests/fuzzers/keystore/keystore_test.go, tests/fuzzers/les/les_test.go, tests/fuzzers/rangeproof/rangeproof_test.go, tests/fuzzers/rlp/rlp_test.go, tests/fuzzers/runtime/runtime_test.go, tests/fuzzers/stacktrie/stacktrie_test.go, tests/fuzzers/trie/trie_test.go, tests/fuzzers/txfetcher/txfetcher_test.go, tests/fuzzers/vflux/vflux_test.go
New exported fuzz test functions (FuzzBitutil, FuzzBn256Add/Mul/Pair, FuzzDifficulty, FuzzKeystore, FuzzLes, FuzzRangeproof, FuzzRlp, FuzzRuntime, FuzzStacktrie, FuzzTrie, FuzzTxfetcher, FuzzVfluxClientPool) that register Go fuzzing entry points via testing.F, delegating to existing Fuzz(data) functions
Build Constraint Removal
tests/fuzzers/bn256/bn256_fuzz.go
Removal of gofuzz build tags allows file to participate in default builds rather than only when gofuzz tag is provided
Gas Price Update
tests/fuzzers/les/les-fuzzer.go
Contract creation transaction gas price changed from 0 to params.GWei when i%4 == 0

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Suggested reviewers

  • secmgt
  • Kukoomomo

Poem

🐰 Fuzzing comes alive today,
With Go's new native test array!
From bitutil to vflux's call,
Entry points now cover all—
Legacy constraints drift away! 🎲✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix les fuzz test and upgrade to go native fuzzing' directly reflects the main changes: fixing the les fuzzer and migrating all fuzzers to Go's native fuzzing framework.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings


📜 Recent review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d108c19 and a8dc19b.

📒 Files selected for processing (14)
  • tests/fuzzers/bitutil/bitutil_test.go
  • tests/fuzzers/bn256/bn256_fuzz.go
  • tests/fuzzers/bn256/bn256_test.go
  • tests/fuzzers/difficulty/difficulty_test.go
  • tests/fuzzers/keystore/keystore_test.go
  • tests/fuzzers/les/les-fuzzer.go
  • tests/fuzzers/les/les_test.go
  • tests/fuzzers/rangeproof/rangeproof_test.go
  • tests/fuzzers/rlp/rlp_test.go
  • tests/fuzzers/runtime/runtime_test.go
  • tests/fuzzers/stacktrie/stacktrie_test.go
  • tests/fuzzers/trie/trie_test.go
  • tests/fuzzers/txfetcher/txfetcher_test.go
  • tests/fuzzers/vflux/vflux_test.go
💤 Files with no reviewable changes (1)
  • tests/fuzzers/bn256/bn256_fuzz.go
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-11-10T06:56:24.937Z
Learnt from: Kukoomomo
Repo: morph-l2/go-ethereum PR: 205
File: core/token_gas.go:140-155
Timestamp: 2025-11-10T06:56:24.937Z
Learning: In the ERC20 fee implementation (core/token_gas.go), ERC20 transfer and balance check calls use math.MaxUint64 gas limit. This is intentional given that fee tokens are restricted to an allowlist (via IsTokenActive checks and AllowListSlot/AllowListEnabledSlot in rollup/rcfg/config.go), so only vetted contracts can be invoked. The team has chosen this approach understanding the tradeoffs versus adding fixed gas stipends.

Applied to files:

  • tests/fuzzers/les/les-fuzzer.go
🧬 Code graph analysis (10)
tests/fuzzers/les/les_test.go (1)
tests/fuzzers/les/les-fuzzer.go (1)
  • Fuzz (278-407)
tests/fuzzers/difficulty/difficulty_test.go (1)
tests/fuzzers/les/les-fuzzer.go (1)
  • Fuzz (278-407)
tests/fuzzers/bitutil/bitutil_test.go (1)
tests/fuzzers/les/les-fuzzer.go (1)
  • Fuzz (278-407)
tests/fuzzers/txfetcher/txfetcher_test.go (1)
tests/fuzzers/les/les-fuzzer.go (1)
  • Fuzz (278-407)
tests/fuzzers/runtime/runtime_test.go (1)
tests/fuzzers/les/les-fuzzer.go (1)
  • Fuzz (278-407)
tests/fuzzers/stacktrie/stacktrie_test.go (1)
tests/fuzzers/les/les-fuzzer.go (1)
  • Fuzz (278-407)
tests/fuzzers/bn256/bn256_test.go (1)
tests/fuzzers/bn256/bn256_fuzz.go (3)
  • FuzzAdd (54-84)
  • FuzzMul (88-126)
  • FuzzPair (128-155)
tests/fuzzers/vflux/vflux_test.go (1)
tests/fuzzers/vflux/clientpool-fuzzer.go (1)
  • FuzzClientPool (217-335)
tests/fuzzers/keystore/keystore_test.go (1)
tests/fuzzers/les/les-fuzzer.go (1)
  • Fuzz (278-407)
tests/fuzzers/les/les-fuzzer.go (2)
core/types/transaction_signing.go (1)
  • SignTx (113-120)
params/denomination.go (1)
  • GWei (26-26)
🔇 Additional comments (13)
tests/fuzzers/bitutil/bitutil_test.go (1)

5-9: LGTM!

This is the correct pattern for Go native fuzzing. The wrapper properly delegates to the existing Fuzz function. The unused t *testing.T parameter is required by the testing.F.Fuzz signature.

tests/fuzzers/les/les-fuzzer.go (1)

72-78: LGTM! Gas price fix for contract creation transactions.

This aligns the contract creation transaction's gas price with the regular transaction path on line 77. Using a zero gas price could cause transactions to be rejected by the tx pool or fail validation, which would reduce fuzzing coverage.

tests/fuzzers/txfetcher/txfetcher_test.go (1)

5-9: LGTM!

Follows the same Go native fuzzing pattern as the other wrapper files.

tests/fuzzers/difficulty/difficulty_test.go (1)

5-9: LGTM!

Consistent with the other native fuzzing wrappers in this PR.

tests/fuzzers/runtime/runtime_test.go (1)

5-9: LGTM!

Consistent with the other native fuzzing wrappers in this PR.

tests/fuzzers/trie/trie_test.go (1)

1-9: LGTM!

The Go native fuzzing wrapper follows the standard pattern correctly. The fuzz entry point properly delegates to the existing Fuzz(data) function.

Consider adding seed corpus values via f.Add([]byte{...}) to provide initial interesting inputs, though this is optional and can be deferred.

tests/fuzzers/rangeproof/rangeproof_test.go (1)

1-9: LGTM!

The native fuzzing wrapper correctly implements the Go 1.18+ fuzzing pattern, delegating input to the existing Fuzz(data) function.

tests/fuzzers/bn256/bn256_test.go (1)

1-21: LGTM!

The three separate fuzz entry points are appropriately structured to target different bn256 operations (addition, multiplication, pairing). The naming convention FuzzBn256Xxx is clear and distinguishes these from the underlying FuzzAdd/Mul/Pair functions.

tests/fuzzers/keystore/keystore_test.go (1)

1-9: LGTM!

The native fuzzing wrapper is correctly implemented and consistent with the pattern used across other fuzzer packages in this PR.

tests/fuzzers/stacktrie/stacktrie_test.go (1)

1-9: LGTM!

The native fuzzing wrapper correctly follows the established pattern. This completes the consistent set of fuzz entry points across the codebase.

tests/fuzzers/rlp/rlp_test.go (1)

1-9: LGTM!

Clean and correct Go native fuzzing wrapper. The pattern correctly delegates to the existing Fuzz(data) function, enabling go test -fuzz=FuzzRlp for this package.

tests/fuzzers/les/les_test.go (1)

1-9: LGTM!

Correct native fuzzing wrapper for the LES protocol fuzzer. The underlying Fuzz function (in les-fuzzer.go) handles input validation internally, so the simple delegation pattern works well here.

tests/fuzzers/vflux/vflux_test.go (1)

1-9: LGTM!

Correct native fuzzing wrapper for the vflux client pool fuzzer. The descriptive name FuzzVfluxClientPool clearly indicates it targets the FuzzClientPool function, which is appropriate given the underlying fuzzer exercises specific client pool operations.

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 golangci-lint (2.5.0)

Error: can't load config: unsupported version of the configuration: "" See https://golangci-lint.run/docs/product/migration-guide for migration instructions
The command is terminated due to an error: can't load config: unsupported version of the configuration: "" See https://golangci-lint.run/docs/product/migration-guide for migration instructions


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant