Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(libzkp): different paths for assets of lower and higher versions #1461

Merged
merged 5 commits into from
Jul 26, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions common/libzkp/impl/src/chunk.rs
Original file line number Diff line number Diff line change
@@ -42,16 +42,18 @@ pub unsafe extern "C" fn init_chunk_prover(params_dir: *const c_char, assets_dir

/// # Safety
#[no_mangle]
pub unsafe extern "C" fn init_chunk_verifier(params_dir: *const c_char, assets_dir: *const c_char) {
pub unsafe extern "C" fn init_chunk_verifier(params_dir: *const c_char, v3_assets_dir: *const c_char, v4_assets_dir: *const c_char) {
init_env_and_log("ffi_chunk_verify");

let params_dir = c_char_to_str(params_dir);
let assets_dir = c_char_to_str(assets_dir);
let v3_assets_dir = c_char_to_str(v3_assets_dir);
let v4_assets_dir = c_char_to_str(v4_assets_dir);

// TODO: add a settings in scroll-prover.
env::set_var("SCROLL_PROVER_ASSETS_DIR", assets_dir);
let verifier_v3 = VerifierV3::from_dirs(params_dir, assets_dir);
let verifier_v4 = VerifierV4::from_dirs(params_dir, assets_dir);
env::set_var("SCROLL_PROVER_ASSETS_DIR", v3_assets_dir);
let verifier_v3 = VerifierV3::from_dirs(params_dir, v3_assets_dir);
env::set_var("SCROLL_PROVER_ASSETS_DIR", v4_assets_dir);
let verifier_v4 = VerifierV4::from_dirs(params_dir, v4_assets_dir);

VERIFIER_V3.set(verifier_v3).unwrap();
VERIFIER_V4.set(verifier_v4).unwrap();
2 changes: 1 addition & 1 deletion common/libzkp/interface/libzkp.h
Original file line number Diff line number Diff line change
@@ -17,7 +17,7 @@ char* gen_bundle_proof(char* batch_proofs);
char verify_bundle_proof(char* proof);

void init_chunk_prover(char* params_dir, char* assets_dir);
void init_chunk_verifier(char* params_dir, char* assets_dir);
void init_chunk_verifier(char* params_dir, char* v3_assets_dir, char* v4_assets_dir);
char* get_chunk_vk();
char* gen_chunk_proof(char* block_traces);
char verify_chunk_proof(char* proof, char* fork_name);
3 changes: 2 additions & 1 deletion coordinator/conf/config.json
Original file line number Diff line number Diff line change
@@ -9,7 +9,8 @@
"fork_name": "bernoulli",
"mock_mode": true,
"params_path": "",
"assets_path": ""
"assets_path_v3": "",
"assets_path_v4": ""
},
"max_verifier_workers": 4,
"min_prover_version": "v1.0.0"
9 changes: 5 additions & 4 deletions coordinator/internal/config/config.go
Original file line number Diff line number Diff line change
@@ -52,10 +52,11 @@ type Config struct {

// VerifierConfig load zk verifier config.
type VerifierConfig struct {
ForkName string `json:"fork_name"`
MockMode bool `json:"mock_mode"`
ParamsPath string `json:"params_path"`
AssetsPath string `json:"assets_path"`
ForkName string `json:"fork_name"`
MockMode bool `json:"mock_mode"`
ParamsPath string `json:"params_path"`
AssetsPathV3 string `json:"assets_path_v3"`
AssetsPathV4 string `json:"assets_path_v4"`
}

// NewConfig returns a new instance of Config.
16 changes: 9 additions & 7 deletions coordinator/internal/logic/verifier/verifier.go
Original file line number Diff line number Diff line change
@@ -36,14 +36,16 @@ func NewVerifier(cfg *config.VerifierConfig) (*Verifier, error) {
return &Verifier{cfg: cfg, ChunkVKMap: chunkVKMap, BatchVKMap: batchVKMap, BundleVkMap: bundleVKMap}, nil
}
paramsPathStr := C.CString(cfg.ParamsPath)
assetsPathStr := C.CString(cfg.AssetsPath)
assetsPathV3Str := C.CString(cfg.AssetsPathV3)
assetsPathV4Str := C.CString(cfg.AssetsPathV4)
defer func() {
C.free(unsafe.Pointer(paramsPathStr))
C.free(unsafe.Pointer(assetsPathStr))
C.free(unsafe.Pointer(assetsPathV3Str))
C.free(unsafe.Pointer(assetsPathV4Str))
}()

C.init_batch_verifier(paramsPathStr, assetsPathStr)
C.init_chunk_verifier(paramsPathStr, assetsPathStr)
C.init_batch_verifier(paramsPathStr, assetsPathV4Str)
C.init_chunk_verifier(paramsPathStr, assetsPathV3Str, assetsPathV4Str)

v := &Verifier{
cfg: cfg,
@@ -52,15 +54,15 @@ func NewVerifier(cfg *config.VerifierConfig) (*Verifier, error) {
BundleVkMap: make(map[string]string),
}

bundleVK, err := v.readVK(path.Join(cfg.AssetsPath, "vk_bundle.vkey"))
bundleVK, err := v.readVK(path.Join(cfg.AssetsPathV4, "vk_bundle.vkey"))
if err != nil {
return nil, err
}
batchVK, err := v.readVK(path.Join(cfg.AssetsPath, "vk_batch.vkey"))
batchVK, err := v.readVK(path.Join(cfg.AssetsPathV4, "vk_batch.vkey"))
if err != nil {
return nil, err
}
chunkVK, err := v.readVK(path.Join(cfg.AssetsPath, "vk_chunk.vkey"))
chunkVK, err := v.readVK(path.Join(cfg.AssetsPathV4, "vk_chunk.vkey"))
if err != nil {
return nil, err
}
Loading