Skip to content

Commit

Permalink
Prover: adds field dict_path in config (#314)
Browse files Browse the repository at this point in the history
* feat(conf): adds a config field to explicitly set the dictionary path
* fix(typo): prover assets path
* fix(e2e): specifies an explicit dict path
* comment(dict_path): adds a comment stressing to not use the field outside E2E testing context.
  • Loading branch information
AlexandreBelling authored Nov 20, 2024
1 parent 0615fa3 commit c0b28f1
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 8 deletions.
1 change: 1 addition & 0 deletions docker/config/prover/v3/prover-config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ requests_root_dir = "/data/prover/v3/execution"
[blob_decompression]
prover_mode = "dev"
requests_root_dir = "/data/prover/v3/compression"
dict_path = "/opt/linea/prover/lib/compressor/compressor_dict.bin"

[aggregation]
prover_mode = "dev"
Expand Down
3 changes: 1 addition & 2 deletions prover/backend/blobdecompression/prove.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"encoding/base64"
"fmt"
"os"
"path/filepath"

blob_v0 "github.com/consensys/linea-monorepo/prover/lib/compressor/blob/v0"
blob_v1 "github.com/consensys/linea-monorepo/prover/lib/compressor/blob/v1"
Expand Down Expand Up @@ -69,7 +68,7 @@ func Prove(cfg *config.Config, req *Request) (*Response, error) {
return nil, fmt.Errorf("unsupported blob version: %v", version)
}

dictPath := filepath.Join(cfg.PathForSetup(string(circuitID)), config.DictionaryFileName)
dictPath := cfg.BlobDecompressionDictPath(string(circuitID))

logrus.Infof("reading the dictionary at %v", dictPath)

Expand Down
2 changes: 1 addition & 1 deletion prover/cmd/prover/cmd/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ func Setup(context context.Context, args SetupArgs) error {
}
if dict != nil {
// we save the dictionary to disk
dictPath := filepath.Join(cfg.PathForSetup(string(c)), config.DictionaryFileName)
dictPath := cfg.BlobDecompressionDictPath(string(c))
if err := os.WriteFile(dictPath, dict, 0600); err != nil {
return fmt.Errorf("%s failed to write dictionary file: %w", cmdName, err)
}
Expand Down
22 changes: 22 additions & 0 deletions prover/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"os"
"path"
"path/filepath"
"text/template"

"github.com/ethereum/go-ethereum/common"
Expand Down Expand Up @@ -216,6 +217,14 @@ type BlobDecompression struct {

// ProverMode stores the kind of prover to use.
ProverMode ProverMode `mapstructure:"prover_mode" validate:"required,oneof=dev full"`

// DictPath is an optional parameters allowing the user to specificy explicitly
// where to look for the compression dictionary. If the input is not provided
// then the dictionary will be fetched in <assets_dir>/<version>/<circuitID>/compression_dict.bin.
//
// We stress that the feature should not be used in production and should
// only be used in E2E testing context.
DictPath string `mapstructure:"dict_path"`
}

type Aggregation struct {
Expand Down Expand Up @@ -270,3 +279,16 @@ type PublicInput struct {
L2MsgServiceAddr common.Address // duplicate from Config

}

// BlobDecompressionDictPath returns the filepath where to look for the blob
// decompression dictionary file. If provided in the config, the function returns
// in priority the provided [BlobDecompression.DictPath] or it returns a
// prover assets path depending on the provided circuitID.
func (cfg *Config) BlobDecompressionDictPath(circuitID string) string {

if len(cfg.BlobDecompression.DictPath) > 0 {
return cfg.BlobDecompression.DictPath
}

return filepath.Join(cfg.PathForSetup(string(circuitID)), DefaultDictionaryFileName)
}
10 changes: 5 additions & 5 deletions prover/config/constants.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package config

const (
VerifyingKeyFileName = "verifying_key.bin"
CircuitFileName = "circuit.bin"
VerifierContractFileName = "Verifier.sol"
ManifestFileName = "manifest.json"
DictionaryFileName = "compressor_dict.bin"
VerifyingKeyFileName = "verifying_key.bin"
CircuitFileName = "circuit.bin"
VerifierContractFileName = "Verifier.sol"
ManifestFileName = "manifest.json"
DefaultDictionaryFileName = "compressor_dict.bin"

RequestsFromSubDir = "requests"
RequestsToSubDir = "responses"
Expand Down

0 comments on commit c0b28f1

Please sign in to comment.