Skip to content

Commit

Permalink
Merge branch 'main' into New_branch_for_corrections
Browse files Browse the repository at this point in the history
  • Loading branch information
666devs authored Jan 7, 2025
2 parents 5d10d10 + 574e0ef commit 74d7e36
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 86 deletions.
22 changes: 12 additions & 10 deletions prover/cmd/prover/cmd/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ type SetupArgs struct {
ConfigFile string
}

var AllCircuits = []string{
string(circuits.ExecutionCircuitID),
string(circuits.ExecutionLargeCircuitID),
string(circuits.BlobDecompressionV0CircuitID),
string(circuits.BlobDecompressionV1CircuitID),
string(circuits.PublicInputInterconnectionCircuitID),
string(circuits.AggregationCircuitID),
string(circuits.EmulationCircuitID),
string(circuits.EmulationDummyCircuitID), // we want to generate Verifier.sol for this one
var AllCircuits = []circuits.CircuitID{
circuits.ExecutionCircuitID,
circuits.ExecutionLargeCircuitID,
circuits.BlobDecompressionV0CircuitID,
circuits.BlobDecompressionV1CircuitID,
circuits.PublicInputInterconnectionCircuitID,
circuits.AggregationCircuitID,
circuits.EmulationCircuitID,
circuits.EmulationDummyCircuitID, // we want to generate Verifier.sol for this one
}

func Setup(context context.Context, args SetupArgs) error {
Expand Down Expand Up @@ -88,7 +88,9 @@ func Setup(context context.Context, args SetupArgs) error {

// for each circuit, we start by compiling the circuit
// then we do a sha sum and compare against the one in the manifest.json
for c, setup := range inCircuits {
for _, c := range AllCircuits {

setup := inCircuits[c]
if !setup {
// we skip aggregation in this first loop since the setup is more complex
continue
Expand Down
17 changes: 14 additions & 3 deletions prover/cmd/prover/main.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package main

import (
"os"
"strings"

"github.com/consensys/gnark/logger"
"github.com/consensys/linea-monorepo/prover/cmd/prover/cmd"
"github.com/rs/zerolog"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"os"
"strings"
)

var (
Expand Down Expand Up @@ -53,7 +54,7 @@ func init() {

rootCmd.AddCommand(setupCmd)
setupCmd.Flags().BoolVar(&setupArgs.Force, "force", false, "overwrites existing files")
setupCmd.Flags().StringVar(&setupArgs.Circuits, "circuits", strings.Join(cmd.AllCircuits, ","), "comma separated list of circuits to setup")
setupCmd.Flags().StringVar(&setupArgs.Circuits, "circuits", strings.Join(allCircuitList(), ","), "comma separated list of circuits to setup")
setupCmd.Flags().StringVar(&setupArgs.DictPath, "dict", "", "path to the dictionary file used in blob (de)compression")
setupCmd.Flags().StringVar(&setupArgs.AssetsDir, "assets-dir", "", "path to the directory where the assets are stored (override conf)")

Expand All @@ -75,3 +76,13 @@ func cmdProve(*cobra.Command, []string) error {
proverArgs.ConfigFile = fConfigFile
return cmd.Prove(proverArgs)
}

// allCircuitList returns the list [cmd.AllCircuits] where the circuit id
// are converted into strings.
func allCircuitList() []string {
res := make([]string, len(cmd.AllCircuits))
for i := range res {
res[i] = string(cmd.AllCircuits[i])
}
return res
}
4 changes: 2 additions & 2 deletions prover/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ go 1.22.7
toolchain go1.23.0

require (
github.com/bits-and-blooms/bitset v1.14.3
github.com/consensys/bavard v0.1.24
github.com/consensys/compress v0.2.5
github.com/consensys/gnark v0.11.1-0.20241217141116-f3d91999250b
github.com/consensys/gnark v0.11.1-0.20250107100237-2cb190338a01
github.com/consensys/gnark-crypto v0.14.1-0.20241217134352-810063550bd4
github.com/consensys/go-corset v0.0.0-20241125005324-5cb0c289c021
github.com/crate-crypto/go-kzg-4844 v1.1.0
Expand All @@ -34,7 +35,6 @@ require (
github.com/DataDog/zstd v1.5.5 // indirect
github.com/VictoriaMetrics/fastcache v1.12.2 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bits-and-blooms/bitset v1.14.3 // indirect
github.com/blang/semver/v4 v4.0.0 // indirect
github.com/btcsuite/btcd/btcec/v2 v2.3.4 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
Expand Down
4 changes: 2 additions & 2 deletions prover/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ github.com/consensys/bavard v0.1.24 h1:Lfe+bjYbpaoT7K5JTFoMi5wo9V4REGLvQQbHmatoN
github.com/consensys/bavard v0.1.24/go.mod h1:k/zVjHHC4B+PQy1Pg7fgvG3ALicQw540Crag8qx+dZs=
github.com/consensys/compress v0.2.5 h1:gJr1hKzbOD36JFsF1AN8lfXz1yevnJi1YolffY19Ntk=
github.com/consensys/compress v0.2.5/go.mod h1:pyM+ZXiNUh7/0+AUjUf9RKUM6vSH7T/fsn5LLS0j1Tk=
github.com/consensys/gnark v0.11.1-0.20241217141116-f3d91999250b h1:isTN/YOs57bOt0JlJHJ8gF8C3CdETU2Z9ao4y8R6qms=
github.com/consensys/gnark v0.11.1-0.20241217141116-f3d91999250b/go.mod h1:8YNyW/+XsYiLRzROLaj/PSktYO4VAdv6YW1b1P3UsZk=
github.com/consensys/gnark v0.11.1-0.20250107100237-2cb190338a01 h1:YCHI04nMKFC60P78x+05QR3jxgBFlDXzJq+7bQOmbfs=
github.com/consensys/gnark v0.11.1-0.20250107100237-2cb190338a01/go.mod h1:8YNyW/+XsYiLRzROLaj/PSktYO4VAdv6YW1b1P3UsZk=
github.com/consensys/gnark-crypto v0.14.1-0.20241217134352-810063550bd4 h1:Kp6egjRqKZf4469dfAWqFe6gi3MRs4VvNHmTfEjUlS8=
github.com/consensys/gnark-crypto v0.14.1-0.20241217134352-810063550bd4/go.mod h1:GMPeN3dUSslNBYJsK3WTjIGd3l0ccfMbcEh/d5knFrc=
github.com/consensys/go-corset v0.0.0-20241125005324-5cb0c289c021 h1:zAPMHjY72pXmjuyb/niQ816pd+B9RAmZoL/W/f5uJSU=
Expand Down
43 changes: 0 additions & 43 deletions prover/protocol/compiler/dummy/dummy_prover_level.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"fmt"
"sync"

"github.com/consensys/linea-monorepo/prover/protocol/column"
"github.com/consensys/linea-monorepo/prover/protocol/wizard"
"github.com/consensys/linea-monorepo/prover/utils"
"github.com/consensys/linea-monorepo/prover/utils/parallel"
Expand Down Expand Up @@ -38,48 +37,6 @@ func CompileAtProverLvl(comp *wizard.CompiledIOP) {
queriesParamsToCompile := comp.QueriesParams.AllUnignoredKeys()
queriesNoParamsToCompile := comp.QueriesNoParams.AllUnignoredKeys()

for i := 0; i < numRounds; i++ {
// Mark all the commitments as messages
coms := comp.Columns.AllKeysAt(i)
for _, com := range coms {
// Check the status of the commitment
status := comp.Columns.Status(com)

if status == column.Ignored {
// If the column is ignored, we can just skip it
continue
}

if status.IsPublic() {
// Nothing specific to do on the prover side
continue
}

// Mark them as "public" to the verifier
switch status {
case column.Precomputed:
// send it to the verifier directly as part of the verifying key
comp.Columns.SetStatus(com, column.VerifyingKey)
case column.Committed:
// send it to the verifier directly as part of the proof
comp.Columns.SetStatus(com, column.Proof)
default:
utils.Panic("Unknown status : %v", status.String())
}
}
}

/*
And mark the queries as already compiled
*/
for _, q := range queriesNoParamsToCompile {
comp.QueriesNoParams.MarkAsIgnored(q)
}

for _, q := range queriesParamsToCompile {
comp.QueriesParams.MarkAsIgnored(q)
}

/*
One step to be run at the end, by verifying every constraint
"a la mano"
Expand Down
38 changes: 19 additions & 19 deletions prover/zkevm/prover/publicInput/public_input.go
Original file line number Diff line number Diff line change
Expand Up @@ -326,24 +326,24 @@ func (pi *PublicInput) generateExtractor(comp *wizard.CompiledIOP) {
}

comp.PublicInputs = append(comp.PublicInputs,
wizard.PublicInput{Name: "DataNbBytes", Acc: accessors.NewLocalOpeningAccessor(pi.Extractor.DataNbBytes, 0)},
wizard.PublicInput{Name: "DataChecksum", Acc: accessors.NewLocalOpeningAccessor(pi.Extractor.DataChecksum, 0)},
wizard.PublicInput{Name: "L2MessageHash", Acc: accessors.NewLocalOpeningAccessor(pi.Extractor.L2MessageHash, 0)},
wizard.PublicInput{Name: "InitialStateRootHash", Acc: accessors.NewLocalOpeningAccessor(pi.Extractor.InitialStateRootHash, 0)},
wizard.PublicInput{Name: "FinalStateRootHash", Acc: accessors.NewLocalOpeningAccessor(pi.Extractor.FinalStateRootHash, 0)},
wizard.PublicInput{Name: "InitialBlockNumber", Acc: accessors.NewLocalOpeningAccessor(pi.Extractor.InitialBlockNumber, 0)},
wizard.PublicInput{Name: "FinalBlockNumber", Acc: accessors.NewLocalOpeningAccessor(pi.Extractor.FinalBlockNumber, 0)},
wizard.PublicInput{Name: "InitialBlockTimestamp", Acc: accessors.NewLocalOpeningAccessor(pi.Extractor.InitialBlockTimestamp, 0)},
wizard.PublicInput{Name: "FinalBlockTimestamp", Acc: accessors.NewLocalOpeningAccessor(pi.Extractor.FinalBlockTimestamp, 0)},
wizard.PublicInput{Name: "FirstRollingHashUpdate[0]", Acc: accessors.NewLocalOpeningAccessor(pi.Extractor.FirstRollingHashUpdate[0], 0)},
wizard.PublicInput{Name: "FirstRollingHashUpdate[1]", Acc: accessors.NewLocalOpeningAccessor(pi.Extractor.FirstRollingHashUpdate[1], 0)},
wizard.PublicInput{Name: "LastRollingHashUpdate[0]", Acc: accessors.NewLocalOpeningAccessor(pi.Extractor.LastRollingHashUpdate[0], 0)},
wizard.PublicInput{Name: "LastRollingHashUpdate[1]", Acc: accessors.NewLocalOpeningAccessor(pi.Extractor.LastRollingHashUpdate[1], 0)},
wizard.PublicInput{Name: "FirstRollingHashUpdateNumber", Acc: accessors.NewLocalOpeningAccessor(pi.Extractor.FirstRollingHashUpdateNumber, 0)},
wizard.PublicInput{Name: "LastRollingHashNumberUpdate", Acc: accessors.NewLocalOpeningAccessor(pi.Extractor.LastRollingHashUpdateNumber, 0)},
wizard.PublicInput{Name: "ChainID", Acc: accessors.NewLocalOpeningAccessor(pi.Extractor.ChainID, 0)},
wizard.PublicInput{Name: "NBytesChainID", Acc: accessors.NewLocalOpeningAccessor(pi.Extractor.NBytesChainID, 0)},
wizard.PublicInput{Name: "L2MessageServiceAddrHi", Acc: pi.Extractor.L2MessageServiceAddrHi},
wizard.PublicInput{Name: "L2MessageServiceAddrLo", Acc: pi.Extractor.L2MessageServiceAddrLo},
wizard.PublicInput{Name: DataNbBytes, Acc: accessors.NewLocalOpeningAccessor(pi.Extractor.DataNbBytes, 0)},
wizard.PublicInput{Name: DataChecksum, Acc: accessors.NewLocalOpeningAccessor(pi.Extractor.DataChecksum, 0)},
wizard.PublicInput{Name: L2MessageHash, Acc: accessors.NewLocalOpeningAccessor(pi.Extractor.L2MessageHash, 0)},
wizard.PublicInput{Name: InitialStateRootHash, Acc: accessors.NewLocalOpeningAccessor(pi.Extractor.InitialStateRootHash, 0)},
wizard.PublicInput{Name: FinalStateRootHash, Acc: accessors.NewLocalOpeningAccessor(pi.Extractor.FinalStateRootHash, 0)},
wizard.PublicInput{Name: InitialBlockNumber, Acc: accessors.NewLocalOpeningAccessor(pi.Extractor.InitialBlockNumber, 0)},
wizard.PublicInput{Name: FinalBlockNumber, Acc: accessors.NewLocalOpeningAccessor(pi.Extractor.FinalBlockNumber, 0)},
wizard.PublicInput{Name: InitialBlockTimestamp, Acc: accessors.NewLocalOpeningAccessor(pi.Extractor.InitialBlockTimestamp, 0)},
wizard.PublicInput{Name: FinalBlockTimestamp, Acc: accessors.NewLocalOpeningAccessor(pi.Extractor.FinalBlockTimestamp, 0)},
wizard.PublicInput{Name: FirstRollingHashUpdate_0, Acc: accessors.NewLocalOpeningAccessor(pi.Extractor.FirstRollingHashUpdate[0], 0)},
wizard.PublicInput{Name: FirstRollingHashUpdate_1, Acc: accessors.NewLocalOpeningAccessor(pi.Extractor.FirstRollingHashUpdate[1], 0)},
wizard.PublicInput{Name: LastRollingHashUpdate_0, Acc: accessors.NewLocalOpeningAccessor(pi.Extractor.LastRollingHashUpdate[0], 0)},
wizard.PublicInput{Name: LastRollingHashUpdate_1, Acc: accessors.NewLocalOpeningAccessor(pi.Extractor.LastRollingHashUpdate[1], 0)},
wizard.PublicInput{Name: FirstRollingHashUpdateNumber, Acc: accessors.NewLocalOpeningAccessor(pi.Extractor.FirstRollingHashUpdateNumber, 0)},
wizard.PublicInput{Name: LastRollingHashNumberUpdate, Acc: accessors.NewLocalOpeningAccessor(pi.Extractor.LastRollingHashUpdateNumber, 0)},
wizard.PublicInput{Name: ChainID, Acc: accessors.NewLocalOpeningAccessor(pi.Extractor.ChainID, 0)},
wizard.PublicInput{Name: NBytesChainID, Acc: accessors.NewLocalOpeningAccessor(pi.Extractor.NBytesChainID, 0)},
wizard.PublicInput{Name: L2MessageServiceAddrHi, Acc: pi.Extractor.L2MessageServiceAddrHi},
wizard.PublicInput{Name: L2MessageServiceAddrLo, Acc: pi.Extractor.L2MessageServiceAddrLo},
)
}
13 changes: 6 additions & 7 deletions prover/zkevm/zkevm.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"github.com/consensys/linea-monorepo/prover/zkevm/arithmetization"
"github.com/consensys/linea-monorepo/prover/zkevm/prover/ecarith"
"github.com/consensys/linea-monorepo/prover/zkevm/prover/ecdsa"
"github.com/consensys/linea-monorepo/prover/zkevm/prover/ecpair"
"github.com/consensys/linea-monorepo/prover/zkevm/prover/hash/keccak"
"github.com/consensys/linea-monorepo/prover/zkevm/prover/hash/sha2"
"github.com/consensys/linea-monorepo/prover/zkevm/prover/modexp"
Expand Down Expand Up @@ -44,7 +43,7 @@ type ZkEvm struct {
ecmul *ecarith.EcMul
// ecpair is the module responsible for the proving the calls the ecpairing
// precompile
ecpair *ecpair.ECPair
// ecpair *ecpair.ECPair
// sha2 is the module responsible for doing the computation of the sha2
// precompile.
sha2 *sha2.Sha2SingleProvider
Expand Down Expand Up @@ -103,8 +102,8 @@ func newZkEVM(b *wizard.Builder, s *Settings) *ZkEvm {
// deactivated pending the resolution of: https://github.com/Consensys/linea-tracer/issues/954
//
// ecadd = ecarith.NewEcAddZkEvm(comp, &s.Ecadd)
ecmul = ecarith.NewEcMulZkEvm(comp, &s.Ecmul)
ecpair = ecpair.NewECPairZkEvm(comp, &s.Ecpair)
ecmul = ecarith.NewEcMulZkEvm(comp, &s.Ecmul)
// ecpair = ecpair.NewECPairZkEvm(comp, &s.Ecpair)
sha2 = sha2.NewSha2ZkEvm(comp, s.Sha2)
publicInput = publicInput.NewPublicInputZkEVM(comp, &s.PublicInput, &stateManager.StateSummary)
)
Expand All @@ -118,8 +117,8 @@ func newZkEVM(b *wizard.Builder, s *Settings) *ZkEvm {
// deactivated pending the resolution of: https://github.com/Consensys/linea-tracer/issues/954
//
// ecadd: ecadd,
ecmul: ecmul,
ecpair: ecpair,
ecmul: ecmul,
// ecpair: ecpair,
sha2: sha2,
PublicInput: &publicInput,
}
Expand All @@ -144,7 +143,7 @@ func (z *ZkEvm) prove(input *Witness) (prover wizard.ProverStep) {
//
// z.ecadd.Assign(run)
z.ecmul.Assign(run)
z.ecpair.Assign(run)
// z.ecpair.Assign(run)
z.sha2.Run(run)
z.PublicInput.Assign(run, input.L2BridgeAddress)
}
Expand Down

0 comments on commit 74d7e36

Please sign in to comment.