fix: target Solidity 0.8.26 (#75)

Co-authored-by: Victorien Gauch <85494462+VGau@users.noreply.github.com>
Co-authored-by: The Dark Jester <thedarkjester@users.noreply.github.com>
This commit is contained in:
Ivo Kubjas
2024-09-26 19:05:47 +02:00
committed by GitHub
parent 1456389879
commit c895052eb0
2 changed files with 11 additions and 3 deletions

View File

@@ -19,6 +19,7 @@ import (
plonk_bls12377 "github.com/consensys/gnark/backend/plonk/bls12-377"
plonk_bn254 "github.com/consensys/gnark/backend/plonk/bn254"
plonk_bw6761 "github.com/consensys/gnark/backend/plonk/bw6-761"
"github.com/consensys/gnark/backend/solidity"
"github.com/sirupsen/logrus"
kzg377 "github.com/consensys/gnark-crypto/ecc/bls12-377/kzg"
@@ -31,6 +32,12 @@ import (
"github.com/consensys/linea-monorepo/prover/utils"
)
const (
// solidityPragmaVersion is the version of the Solidity compiler to target.
// it is used for generating the verifier contract from the PLONK verifying key.
solidityPragmaVersion = "0.8.26"
)
// Setup contains the proving and verifying keys of a circuit, as well as the constraint system.
// It's a common structure used to pass around the resources associated with a circuit.
type Setup struct {
@@ -76,7 +83,7 @@ func MakeSetup(
hasSolidity := setup.Circuit.Field().String() == ecc.BN254.ScalarField().String()
if hasSolidity {
h := sha256.New()
if err = vk.ExportSolidity(h); err != nil {
if err = vk.ExportSolidity(h, solidity.WithPragmaVersion(solidityPragmaVersion)); err != nil {
return Setup{}, fmt.Errorf("computing checksum for verifier contract: %w", err)
}
setup.Manifest.Checksums.VerifierContract = "0x" + hex.EncodeToString(h.Sum(nil))
@@ -131,7 +138,7 @@ func (s *Setup) WriteTo(rootDir string) error {
return fmt.Errorf("creating verifier contract file: %w", err)
}
defer f.Close()
if err = s.VerifyingKey.ExportSolidity(f); err != nil {
if err = s.VerifyingKey.ExportSolidity(f, solidity.WithPragmaVersion(solidityPragmaVersion)); err != nil {
return fmt.Errorf("exporting verifier contract to file: %w", err)
}
}

View File

@@ -11,6 +11,7 @@ import (
"strings"
"github.com/consensys/gnark-crypto/ecc"
"github.com/consensys/gnark/backend/solidity"
"github.com/consensys/linea-monorepo/prover/backend/aggregation"
"github.com/consensys/linea-monorepo/prover/backend/blobsubmission"
"github.com/consensys/linea-monorepo/prover/backend/files"
@@ -367,7 +368,7 @@ func dumpVerifierContract(odir string, circID circuits.MockCircuitID) {
printlnAndExit("could not create public parameters: %v", err)
}
if err := pp.VerifyingKey.ExportSolidity(f); err != nil {
if err := pp.VerifyingKey.ExportSolidity(f, solidity.WithPragmaVersion("0.8.26")); err != nil {
printlnAndExit("could not export verifying key to solidity: %v", err)
}
}