Skip to content

fix(prover): remove global overwrite in FullZKEVMWithSuite #3114

Merged
gusiri merged 2 commits into
prover/fix-ftxfrom
prover/fix-invalidity-setup
May 18, 2026
Merged

fix(prover): remove global overwrite in FullZKEVMWithSuite #3114
gusiri merged 2 commits into
prover/fix-ftxfrom
prover/fix-invalidity-setup

Conversation

@gusiri
Copy link
Copy Markdown
Contributor

@gusiri gusiri commented May 15, 2026

Problem

FullZKEVMWithSuite() is a utility function that creates a new *ZkEvm with a given compilation suite. However, it assigns its result to the package-level global fullZkEvm before returning (fullZkEvm = NewZkEVM(settings)). This silently overwrites the cached instance that FullZkEvm() guards with sync.Once.

During make setup (all circuits), execution-limitless calls NewLimitlessZkEVM() → FullZKEVMWithSuite(..., nil), which creates a ZkEvm with RecursionCompiledIOP = nil (because PostRecursionCompilationSuite is nil) and overwrites the global. When invalidity-precompile-logs runs next, FullZkEvm() returns the corrupted instance (the sync.Once already fired), and BadPrecompileCircuit.Allocate() panics on config.ZkEvmComp.NumRounds().

Error

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x98 pc=0x19fbc1c]

goroutine 1 [running]:
github.com/consensys/linea-monorepo/prover/protocol/wizard.(*CompiledIOP).NumRounds(...)
        prover/protocol/wizard/compiled.go:142
github.com/consensys/linea-monorepo/prover/circuits/invalidity.(*BadPrecompileCircuit).Allocate(...)
        prover/circuits/invalidity/bad_precompile.go:68

Fix

Changed FullZKEVMWithSuite() to return a local value (return NewZkEVM(settings)) instead of writing to the global. Only the sync.Once closures in FullZkEvm(), FullZkEvmLarge(), and FullZkEVMCheckOnly() should write to their respective globals.

Why this wasn't caught before

The bug existed since FullZKEVMWithSuite was extracted into its own function — the global assignment came along as a copy-paste artifact. It was hidden because nothing reused FullZkEvm() during setup until the invalidity circuits were added. The invalidity-precompile circuits are the first to call FullZkEvm() after the corrupted write, which exposed the nil pointer.

Checklist

  • I wrote new tests for my new core changes.
  • I have successfully ran tests, style checker and build against my new changes locally.
  • If this change is deployed to any environment (including Devnet), E2E test coverage exists or is included in this
    PR.
  • I have informed the team of any breaking changes if there are any.

Note

Medium Risk
Touches zkEVM construction/memoization logic used across prover setups; a mistake here could change which compiled instance is reused and lead to hard-to-debug runtime panics. Change is small and covered by a targeted regression test.

Overview
Stops FullZKEVMWithSuite from overwriting the package-level fullZkEvm cache by returning NewZkEVM(settings) directly instead of assigning to the global.

Adds a regression test (TestFullZKEVMWithSuiteNoGlobalOverwrite) to ensure calling FullZKEVMWithSuite does not mutate the memoized fullZkEvm instance.

Reviewed by Cursor Bugbot for commit 783eb17. Bugbot is set up for automated code reviews on this repo. Configure here.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 15, 2026

coordinator Changelog Preview (informational)

[Unreleased] diff (commits touching coordinator/** since latest releases/coordinator/v* tag)

[unreleased]

🐛 Bug Fixes

⚙️ Miscellaneous Tasks

Generated by git-cliff-action using cliff.toml. This comment is informational and does not gate the PR.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 15, 2026

prover Changelog Preview (informational)

[Unreleased] diff (commits touching prover/** since latest releases/prover/v* tag)

[unreleased]

🐛 Bug Fixes

⚙️ Miscellaneous Tasks

Generated by git-cliff-action using cliff.toml. This comment is informational and does not gate the PR.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 15, 2026

tx-exclusion-api Changelog Preview (informational)

[Unreleased] diff (commits touching tx-exclusion-api/** since latest releases/tx-exclusion-api/v* tag)

[unreleased]

⚙️ Miscellaneous Tasks

Generated by git-cliff-action using cliff.toml. This comment is informational and does not gate the PR.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 15, 2026

postman Changelog Preview (informational)

[Unreleased] diff (commits touching postman/** since latest releases/postman/v* tag)

[unreleased]

⚙️ Miscellaneous Tasks

Generated by git-cliff-action using cliff.toml. This comment is informational and does not gate the PR.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 15, 2026

linea-besu Changelog Preview (informational)

[Unreleased] diff (commits touching linea-besu/** since latest releases/linea-besu/v* tag)

[unreleased]

🐛 Bug Fixes

⚙️ Miscellaneous Tasks

Generated by git-cliff-action using cliff.toml. This comment is informational and does not gate the PR.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a critical caching bug in the prover’s zkEVM builder by removing an unintended package-global overwrite from FullZKEVMWithSuite(), ensuring only the sync.Once-guarded entrypoints populate their respective cached instances.

Changes:

  • Stop FullZKEVMWithSuite() from mutating the package-level fullZkEvm global.
  • Ensure FullZKEVMWithSuite() simply constructs and returns a fresh *ZkEvm, leaving memoization solely to FullZkEvm(), FullZkEvmLarge(), and FullZkEVMCheckOnly().

Comment thread prover/zkevm/full.go
Comment on lines 416 to 418
// Initialize the Full zkEVM arithmetization
fullZkEvm = NewZkEVM(settings)
return fullZkEvm
return NewZkEVM(settings)
}
@codecov-commenter
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 77.24%. Comparing base (b56778e) to head (7dc0e58).
⚠️ Report is 337 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #3114      +/-   ##
============================================
- Coverage     77.25%   77.24%   -0.01%     
  Complexity     6991     6991              
============================================
  Files          1121     1121              
  Lines         44418    44412       -6     
  Branches       5335     5335              
============================================
- Hits          34314    34308       -6     
  Misses         8751     8751              
  Partials       1353     1353              
Flag Coverage Δ *Carryforward flag
hardhat 96.17% <ø> (ø)
kotlin 55.91% <ø> (-0.02%) ⬇️ Carriedforward from b56778e
lido-governance-monitor 97.61% <ø> (ø) Carriedforward from b56778e
linea-native-libs 90.69% <ø> (ø) Carriedforward from b56778e
linea-shared-utils 96.18% <ø> (ø) Carriedforward from b56778e
native-yield-automation-service 97.68% <ø> (ø) Carriedforward from b56778e
postman 99.92% <ø> (ø) Carriedforward from b56778e
sdk-core 98.09% <ø> (ø) Carriedforward from b56778e
sdk-ethers 89.83% <ø> (ø) Carriedforward from b56778e
sdk-viem 99.45% <ø> (ø) Carriedforward from b56778e
tracer 88.55% <ø> (ø) Carriedforward from b56778e

*This pull request uses carry forward flags. Click here to find out more.
see 90 files with indirect coverage changes

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@gusiri gusiri requested a deployment to docker-build-and-e2e May 15, 2026 01:00 — with GitHub Actions Waiting
@gusiri gusiri changed the base branch from main to prover/fix-ftx May 18, 2026 10:57
@gusiri gusiri merged commit 0b7b00f into prover/fix-ftx May 18, 2026
38 of 41 checks passed
@gusiri gusiri deleted the prover/fix-invalidity-setup branch May 18, 2026 10:57
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.

4 participants