Skip to content

Commit

Permalink
replace embed vks to config path
Browse files Browse the repository at this point in the history
  • Loading branch information
amoylan2 committed Aug 21, 2024
1 parent 5e15321 commit acafdd7
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 32 deletions.
12 changes: 0 additions & 12 deletions coordinator/internal/logic/verifier/legacy_vk/upgrade_vks.sh

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.
29 changes: 9 additions & 20 deletions coordinator/internal/logic/verifier/verifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,9 @@ package verifier
import "C" //nolint:typecheck

import (
"embed"
"encoding/base64"
"encoding/json"
"io"
"io/fs"
"os"
"path"
"unsafe"
Expand Down Expand Up @@ -81,7 +79,7 @@ func NewVerifier(cfg *config.VerifierConfig) (*Verifier, error) {
v.BatchVKMap[batchVK] = struct{}{}
v.ChunkVKMap[chunkVK] = struct{}{}

if err := v.loadEmbedVK(); err != nil {
if err := v.loadLowVersionVKs(cfg); err != nil {
return nil, err
}
return v, nil
Expand Down Expand Up @@ -186,31 +184,22 @@ func (v *Verifier) readVK(filePat string) (string, error) {
return base64.StdEncoding.EncodeToString(byt), nil
}

//go:embed legacy_vk/*
var legacyVKFS embed.FS

func (v *Verifier) loadEmbedVK() error {
chunkVKBytes, err := fs.ReadFile(legacyVKFS, "legacy_vk/vk_chunk.vkey")
// load low version vks, current is darwin
func (v *Verifier) loadLowVersionVKs(cfg *config.VerifierConfig) error {
bundleVK, err := v.readVK(path.Join(cfg.LowVersionCircuit.AssetsPath, "vk_bundle.vkey"))
if err != nil {
log.Error("load embed chunk vk failure", "err", err)
return err
}

batchVKBytes, err := fs.ReadFile(legacyVKFS, "legacy_vk/vk_batch.vkey")
batchVK, err := v.readVK(path.Join(cfg.LowVersionCircuit.AssetsPath, "vk_batch.vkey"))
if err != nil {
log.Error("load embed batch vk failure", "err", err)
return err
}

bundleVKBytes, err := fs.ReadFile(legacyVKFS, "legacy_vk/vk_bundle.vkey")
chunkVK, err := v.readVK(path.Join(cfg.LowVersionCircuit.AssetsPath, "vk_chunk.vkey"))
if err != nil {
log.Error("load embed chunk vk failure", "err", err)
return err
}

v.ChunkVKMap[base64.StdEncoding.EncodeToString(chunkVKBytes)] = struct{}{}
v.BatchVKMap[base64.StdEncoding.EncodeToString(batchVKBytes)] = struct{}{}
v.BundleVkMap[base64.StdEncoding.EncodeToString(bundleVKBytes)] = struct{}{}

v.BundleVkMap[bundleVK] = struct{}{}
v.BatchVKMap[batchVK] = struct{}{}
v.ChunkVKMap[chunkVK] = struct{}{}
return nil
}

0 comments on commit acafdd7

Please sign in to comment.