Files
linea-monorepo/prover/zkevm/partial.go
David Pearce bf71b6b5ca Prover: compatibility check between zkevmbin and lt trace file (#745)
* update `go-corset` to `v0.9.4`

* feat: add binfile / tracefile compatibility check

This adds a compatibility check between the zkevm.bin file and the lt
trace file.  The compatibility check extracts the constraints commit
used to generate the respective asset, and ensures a match.  If not, the
code panics with an error.  Likewise, if the metadata is missing then
code will panic with an error.

* support "relaxed mode"

This intention here is to enable the strong compatibility check to be
disabled.  It seems sensible to have an option to turn it off, and a
flag is added to the `bin/checker` to disable it.

* remove file-based constraints version check

* update to later version of `go-corset`

In order to allow embedded line count information (as requested
separately from this PR), go-corset now uses a structured form of
metadata.  This simply updates this PR to use the revised API.

* rename "RelaxedMode" => "IgnoreCompabitilityCheck"

This simply renames the "relaxed mode" to something more direct, namely
"IgnoreCompatiblityCheck" which does what it says on the tin.

* update `go-corset` to v1.0.0

* add IgnoreCompatibilityCheck option to prover config

* remove unnecessary variable

* Update compatibility check to fail early on incompatibility

* add log when IgnoreCompatibilityCheck is enabled

---------

Co-authored-by: gusiri <dreamerty@postech.ac.kr>
2025-03-07 08:45:54 +09:00

66 lines
2.2 KiB
Go

package zkevm
import (
"sync"
"github.com/consensys/go-corset/pkg/mir"
"github.com/consensys/linea-monorepo/prover/config"
"github.com/consensys/linea-monorepo/prover/protocol/compiler"
"github.com/consensys/linea-monorepo/prover/protocol/compiler/vortex"
"github.com/consensys/linea-monorepo/prover/protocol/wizard"
"github.com/consensys/linea-monorepo/prover/zkevm/arithmetization"
)
const (
// Number of columns from the arithmetization that are kept to instantiate
// light prover.
numColLimitLight = 10
)
var (
partialZkEvm *ZkEvm
oncePartialZkEvm = sync.Once{}
partialCompilationSuite = compilationSuite{
compiler.Arcane(1<<16, 1<<17, true),
vortex.Compile(2, vortex.WithDryThreshold(16)),
}
)
// Returns the zkEVM objects corresponding to the light zkEVM prover. Namely,
// it will generate a proof checking only a small portion of the requested
// computation it is meant primarily for testing and integration testing
// purpose. When called for the first time, it will compile the corresponding
// light zkEVM using the config option. The next times it is called, it will
// ignore the configuration options and directly return the previously compiled
// object. It therefore means that it should not be called twice with different
// config options.
func PartialZkEvm(tl *config.TracesLimits, cfg *config.Config) *ZkEvm {
// This is hidden behind a once, because the compilation time can take a
// significant amount of time and we want it to be only triggered when we
// need it and only once (for instance not when we are using the full mode
// prover).
oncePartialZkEvm.Do(func() {
// The light-prover does not support other features than the
// arithmetization itself, i.e. it currently does not instantiate the
// modules to verify keccak or the state-manager traces.
settings := Settings{
Arithmetization: arithmetization.Settings{
Limits: tl,
OptimisationLevel: &mir.DEFAULT_OPTIMISATION_LEVEL,
IgnoreCompatibilityCheck: &cfg.Execution.IgnoreCompatibilityCheck,
},
CompilationSuite: partialCompilationSuite,
Metadata: wizard.VersionMetadata{
Title: "linea/evm-execution/partial",
Version: "beta-v1",
},
}
partialZkEvm = NewZkEVM(settings)
})
return partialZkEvm
}