Skip to content

Commit 6ee5fa1

Browse files
author
colinlyguo
committed
fix
1 parent cca9087 commit 6ee5fa1

File tree

14 files changed

+61
-57
lines changed

14 files changed

+61
-57
lines changed

coordinator/cmd/api/app/mock_app.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ func (c *CoordinatorApp) MockConfig(store bool) error {
9191
ProversPerSession: 1,
9292
Verifier: &coordinatorConfig.VerifierConfig{
9393
HighVersionCircuit: &coordinatorConfig.CircuitConfig{
94-
ParamsPath: "",
9594
AssetsPath: "",
9695
ForkName: "euclidV2",
9796
MinProverVersion: "v4.4.89",

coordinator/internal/config/config.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ type Config struct {
5151

5252
// CircuitConfig circuit items.
5353
type CircuitConfig struct {
54-
ParamsPath string `json:"params_path"`
5554
AssetsPath string `json:"assets_path"`
5655
ForkName string `json:"fork_name"`
5756
MinProverVersion string `json:"min_prover_version"`

coordinator/internal/logic/verifier/types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
// InvalidTestProof invalid proof used in tests
88
const InvalidTestProof = "this is a invalid proof"
99

10-
// Verifier represents a rust ffi to a halo2 verifier.
10+
// Verifier represents a rust ffi to a verifier.
1111
type Verifier struct {
1212
cfg *config.VerifierConfig
1313
OpenVMVkMap map[string]struct{}

coordinator/internal/logic/verifier/verifier.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,12 @@ import (
3030
// in `*config.CircuitConfig` being changed
3131
type rustCircuitConfig struct {
3232
ForkName string `json:"fork_name"`
33-
ParamsPath string `json:"params_path"`
3433
AssetsPath string `json:"assets_path"`
3534
}
3635

3736
func newRustCircuitConfig(cfg *config.CircuitConfig) *rustCircuitConfig {
3837
return &rustCircuitConfig{
3938
ForkName: cfg.ForkName,
40-
ParamsPath: cfg.ParamsPath,
4139
AssetsPath: cfg.AssetsPath,
4240
}
4341
}

coordinator/internal/logic/verifier/verifier_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ func TestFFI(t *testing.T) {
3030

3131
cfg := &config.VerifierConfig{
3232
HighVersionCircuit: &config.CircuitConfig{
33-
ParamsPath: *paramsPath,
3433
AssetsPath: *assetsPathHi,
3534
ForkName: "euclidV2",
3635
MinProverVersion: "",

coordinator/test/api_test.go

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ func randomURL() string {
6767
return fmt.Sprintf("localhost:%d", 10000+2000+id.Int64())
6868
}
6969

70-
func setupCoordinator(t *testing.T, proversPerSession uint8, coordinatorURL string, forks []string) (*cron.Collector, *http.Server) {
70+
func setupCoordinator(t *testing.T, proversPerSession uint8, coordinatorURL string) (*cron.Collector, *http.Server) {
7171
var err error
7272
db, err = testApps.GetGormDBClient()
7373

@@ -85,9 +85,8 @@ func setupCoordinator(t *testing.T, proversPerSession uint8, coordinatorURL stri
8585
ProversPerSession: proversPerSession,
8686
Verifier: &config.VerifierConfig{
8787
HighVersionCircuit: &config.CircuitConfig{
88-
ParamsPath: "",
8988
AssetsPath: "",
90-
ForkName: "bernoulli",
89+
ForkName: "euclidV2",
9190
MinProverVersion: "v4.4.89",
9291
},
9392
},
@@ -102,20 +101,20 @@ func setupCoordinator(t *testing.T, proversPerSession uint8, coordinatorURL stri
102101
},
103102
}
104103

105-
var chainConf params.ChainConfig
106-
for _, forkName := range forks {
107-
switch forkName {
108-
case "bernoulli":
109-
chainConf.BernoulliBlock = big.NewInt(100)
110-
case "homestead":
111-
chainConf.HomesteadBlock = big.NewInt(0)
112-
}
104+
chainConf := &params.ChainConfig{
105+
LondonBlock: big.NewInt(0),
106+
BernoulliBlock: big.NewInt(0),
107+
CurieBlock: big.NewInt(0),
108+
DarwinTime: new(uint64),
109+
DarwinV2Time: new(uint64),
110+
EuclidTime: new(uint64),
111+
EuclidV2Time: new(uint64),
113112
}
114113

115114
proofCollector := cron.NewCollector(context.Background(), db, conf, nil)
116115

117116
router := gin.New()
118-
api.InitController(conf, &chainConf, db, nil)
117+
api.InitController(conf, chainConf, db, nil)
119118
route.Route(router, conf, nil)
120119
srv := &http.Server{
121120
Addr: coordinatorURL,
@@ -191,7 +190,7 @@ func TestApis(t *testing.T) {
191190
func testHandshake(t *testing.T) {
192191
// Setup coordinator and http server.
193192
coordinatorURL := randomURL()
194-
proofCollector, httpHandler := setupCoordinator(t, 1, coordinatorURL, []string{"homestead"})
193+
proofCollector, httpHandler := setupCoordinator(t, 1, coordinatorURL)
195194
defer func() {
196195
proofCollector.Stop()
197196
assert.NoError(t, httpHandler.Shutdown(context.Background()))
@@ -204,7 +203,7 @@ func testHandshake(t *testing.T) {
204203
func testFailedHandshake(t *testing.T) {
205204
// Setup coordinator and http server.
206205
coordinatorURL := randomURL()
207-
proofCollector, httpHandler := setupCoordinator(t, 1, coordinatorURL, []string{"homestead"})
206+
proofCollector, httpHandler := setupCoordinator(t, 1, coordinatorURL)
208207
defer func() {
209208
proofCollector.Stop()
210209
}()
@@ -222,7 +221,7 @@ func testFailedHandshake(t *testing.T) {
222221

223222
func testGetTaskBlocked(t *testing.T) {
224223
coordinatorURL := randomURL()
225-
collector, httpHandler := setupCoordinator(t, 3, coordinatorURL, []string{"homestead"})
224+
collector, httpHandler := setupCoordinator(t, 3, coordinatorURL)
226225
defer func() {
227226
collector.Stop()
228227
assert.NoError(t, httpHandler.Shutdown(context.Background()))
@@ -266,7 +265,7 @@ func testGetTaskBlocked(t *testing.T) {
266265

267266
func testOutdatedProverVersion(t *testing.T) {
268267
coordinatorURL := randomURL()
269-
collector, httpHandler := setupCoordinator(t, 3, coordinatorURL, []string{"homestead"})
268+
collector, httpHandler := setupCoordinator(t, 3, coordinatorURL)
270269
defer func() {
271270
collector.Stop()
272271
assert.NoError(t, httpHandler.Shutdown(context.Background()))
@@ -291,7 +290,7 @@ func testOutdatedProverVersion(t *testing.T) {
291290

292291
func testValidProof(t *testing.T) {
293292
coordinatorURL := randomURL()
294-
collector, httpHandler := setupCoordinator(t, 3, coordinatorURL, []string{"homestead"})
293+
collector, httpHandler := setupCoordinator(t, 3, coordinatorURL)
295294
defer func() {
296295
collector.Stop()
297296
assert.NoError(t, httpHandler.Shutdown(context.Background()))
@@ -374,7 +373,7 @@ func testValidProof(t *testing.T) {
374373
func testInvalidProof(t *testing.T) {
375374
// Setup coordinator and ws server.
376375
coordinatorURL := randomURL()
377-
collector, httpHandler := setupCoordinator(t, 3, coordinatorURL, []string{"euclidV2"})
376+
collector, httpHandler := setupCoordinator(t, 3, coordinatorURL)
378377
defer func() {
379378
collector.Stop()
380379
assert.NoError(t, httpHandler.Shutdown(context.Background()))
@@ -462,7 +461,7 @@ func testInvalidProof(t *testing.T) {
462461
func testProofGeneratedFailed(t *testing.T) {
463462
// Setup coordinator and ws server.
464463
coordinatorURL := randomURL()
465-
collector, httpHandler := setupCoordinator(t, 3, coordinatorURL, []string{"euclidV2"})
464+
collector, httpHandler := setupCoordinator(t, 3, coordinatorURL)
466465
defer func() {
467466
collector.Stop()
468467
assert.NoError(t, httpHandler.Shutdown(context.Background()))
@@ -563,7 +562,7 @@ func testProofGeneratedFailed(t *testing.T) {
563562
func testTimeoutProof(t *testing.T) {
564563
// Setup coordinator and ws server.
565564
coordinatorURL := randomURL()
566-
collector, httpHandler := setupCoordinator(t, 1, coordinatorURL, []string{"euclidV2"})
565+
collector, httpHandler := setupCoordinator(t, 1, coordinatorURL)
567566
defer func() {
568567
collector.Stop()
569568
assert.NoError(t, httpHandler.Shutdown(context.Background()))
@@ -586,7 +585,9 @@ func testTimeoutProof(t *testing.T) {
586585
assert.NoError(t, err)
587586
err = chunkOrm.UpdateBatchHashInRange(context.Background(), 0, 100, batch.Hash)
588587
assert.NoError(t, err)
589-
encodeData, err := json.Marshal(message.OpenVMChunkProof{})
588+
encodeData, err := json.Marshal(message.OpenVMChunkProof{VmProof: &message.OpenVMProof{}, MetaData: struct {
589+
ChunkInfo *message.ChunkInfo `json:"chunk_info"`
590+
}{ChunkInfo: &message.ChunkInfo{}}})
590591
assert.NoError(t, err)
591592
assert.NotEmpty(t, encodeData)
592593
err = chunkOrm.UpdateProofAndProvingStatusByHash(context.Background(), dbChunk.Hash, encodeData, types.ProvingTaskUnassigned, 1)

coordinator/test/mock_prover.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -207,14 +207,16 @@ func (r *mockProver) submitProof(t *testing.T, proverTaskSchema *types.GetTaskSc
207207
}
208208

209209
var proof []byte
210-
switch proverTaskSchema.TaskType {
211-
case int(message.ProofTypeChunk):
212-
encodeData, err := json.Marshal(message.OpenVMChunkProof{})
210+
switch message.ProofType(proverTaskSchema.TaskType) {
211+
case message.ProofTypeChunk:
212+
encodeData, err := json.Marshal(message.OpenVMChunkProof{VmProof: &message.OpenVMProof{}, MetaData: struct {
213+
ChunkInfo *message.ChunkInfo `json:"chunk_info"`
214+
}{ChunkInfo: &message.ChunkInfo{}}})
213215
assert.NoError(t, err)
214216
assert.NotEmpty(t, encodeData)
215217
proof = encodeData
216-
case int(message.ProofTypeBatch):
217-
encodeData, err := json.Marshal(message.OpenVMBatchProof{})
218+
case message.ProofTypeBatch:
219+
encodeData, err := json.Marshal(message.OpenVMBatchProof{VmProof: &message.OpenVMProof{}})
218220
assert.NoError(t, err)
219221
assert.NotEmpty(t, encodeData)
220222
proof = encodeData
@@ -223,16 +225,14 @@ func (r *mockProver) submitProof(t *testing.T, proverTaskSchema *types.GetTaskSc
223225
if proofStatus == verifiedFailed {
224226
switch proverTaskSchema.TaskType {
225227
case int(message.ProofTypeChunk):
226-
chunkProof := message.OpenVMChunkProof{}
227-
chunkProof.VmProof = &message.OpenVMProof{Proof: []byte(verifier.InvalidTestProof)}
228-
encodeData, err := json.Marshal(&chunkProof)
228+
encodeData, err := json.Marshal(message.OpenVMChunkProof{VmProof: &message.OpenVMProof{Proof: []byte(verifier.InvalidTestProof)}, MetaData: struct {
229+
ChunkInfo *message.ChunkInfo `json:"chunk_info"`
230+
}{ChunkInfo: &message.ChunkInfo{}}})
229231
assert.NoError(t, err)
230232
assert.NotEmpty(t, encodeData)
231233
proof = encodeData
232234
case int(message.ProofTypeBatch):
233-
batchProof := message.OpenVMBatchProof{}
234-
batchProof.VmProof = &message.OpenVMProof{Proof: []byte(verifier.InvalidTestProof)}
235-
encodeData, err := json.Marshal(&batchProof)
235+
encodeData, err := json.Marshal(&message.OpenVMBatchProof{VmProof: &message.OpenVMProof{Proof: []byte(verifier.InvalidTestProof)}})
236236
assert.NoError(t, err)
237237
assert.NotEmpty(t, encodeData)
238238
proof = encodeData

rollup/internal/controller/relayer/l2_relayer.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -724,11 +724,9 @@ func (r *Layer2Relayer) finalizeBundle(bundle *orm.Bundle, withProof bool) error
724724
return fmt.Errorf("failed to get end chunk of batch: %w", err)
725725
}
726726

727-
hardForkName := encoding.GetHardforkName(r.chainCfg, firstChunk.StartBlockNumber, firstChunk.StartBlockTime)
728-
729727
var aggProof *message.OpenVMBundleProof
730728
if withProof {
731-
aggProof, err = r.bundleOrm.GetVerifiedProofByHash(r.ctx, bundle.Hash, hardForkName)
729+
aggProof, err = r.bundleOrm.GetVerifiedProofByHash(r.ctx, bundle.Hash)
732730
if err != nil {
733731
return fmt.Errorf("failed to get verified proof by bundle index: %d, err: %w", bundle.Index, err)
734732
}

rollup/internal/controller/relayer/l2_relayer_test.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,12 @@ func testL2RelayerProcessPendingBundles(t *testing.T) {
148148
// no valid proof, rollup status remains the same
149149
assert.Equal(t, types.RollupPending, types.RollupStatus(bundles[0].RollupStatus))
150150

151-
proof := &message.OpenVMBundleProof{
152-
Vk: []byte{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31},
153-
}
151+
patchGuard := gomonkey.ApplyMethodFunc((*message.OpenVMBundleProof)(nil), "SanityCheck", func() error {
152+
return nil
153+
})
154+
defer patchGuard.Reset()
155+
156+
proof := &message.OpenVMBundleProof{EvmProof: &message.OpenVMEvmProof{Instances: make([]byte, 384)}}
154157
err = bundleOrm.UpdateProofAndProvingStatusByHash(context.Background(), bundle.Hash, proof, types.ProvingTaskVerified, 600)
155158
assert.NoError(t, err)
156159

rollup/internal/orm/batch.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ func (o *Batch) GetBatchCount(ctx context.Context) (uint64, error) {
121121
}
122122

123123
// GetVerifiedProofByHash retrieves the verified aggregate proof for a batch with the given hash.
124-
func (o *Batch) GetVerifiedProofByHash(ctx context.Context, hash, hardForkName string) (*message.OpenVMBatchProof, error) {
124+
func (o *Batch) GetVerifiedProofByHash(ctx context.Context, hash string) (*message.OpenVMBatchProof, error) {
125125
db := o.db.WithContext(ctx)
126126
db = db.Model(&Batch{})
127127
db = db.Select("proof")

0 commit comments

Comments
 (0)