Skip to content

Commit 0c6e954

Browse files
committed
feat(coordinator): remove concrete proof types
1 parent c591328 commit 0c6e954

File tree

5 files changed

+12
-91
lines changed

5 files changed

+12
-91
lines changed

common/types/message/message.go

Lines changed: 4 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package message
22

33
import (
4-
"errors"
4+
"encoding/json"
55
"fmt"
66

77
"github.com/scroll-tech/go-ethereum/common"
@@ -80,84 +80,10 @@ type SubCircuitRowUsage struct {
8080
}
8181

8282
// ChunkProof includes the proof info that are required for chunk verification and rollup.
83-
type ChunkProof struct {
84-
StorageTrace []byte `json:"storage_trace,omitempty"`
85-
Protocol []byte `json:"protocol"`
86-
Proof []byte `json:"proof"`
87-
Instances []byte `json:"instances"`
88-
Vk []byte `json:"vk"`
89-
// cross-reference between cooridinator computation and prover compution
90-
ChunkInfo *ChunkInfo `json:"chunk_info,omitempty"`
91-
GitVersion string `json:"git_version,omitempty"`
92-
RowUsages []SubCircuitRowUsage `json:"row_usages,omitempty"`
93-
}
83+
type ChunkProof json.RawMessage
9484

9585
// BatchProof includes the proof info that are required for batch verification and rollup.
96-
type BatchProof struct {
97-
Protocol []byte `json:"protocol"`
98-
Proof []byte `json:"proof"`
99-
Instances []byte `json:"instances"`
100-
Vk []byte `json:"vk"`
101-
// cross-reference between cooridinator computation and prover compution
102-
BatchHash common.Hash `json:"batch_hash"`
103-
GitVersion string `json:"git_version,omitempty"`
104-
}
105-
106-
// SanityCheck checks whether a BatchProof is in a legal format
107-
func (ap *BatchProof) SanityCheck() error {
108-
if ap == nil {
109-
return errors.New("agg_proof is nil")
110-
}
111-
112-
if len(ap.Proof) == 0 {
113-
return errors.New("proof not ready")
114-
}
115-
116-
if len(ap.Proof)%32 != 0 {
117-
return fmt.Errorf("proof buffer length must be a multiple of 32, got: %d", len(ap.Proof))
118-
}
119-
120-
if len(ap.Instances) == 0 {
121-
return errors.New("instance not ready")
122-
}
123-
124-
if len(ap.Vk) == 0 {
125-
return errors.New("vk not ready")
126-
}
127-
128-
return nil
129-
}
86+
type BatchProof json.RawMessage
13087

13188
// BundleProof includes the proof info that are required for verification of a bundle of batch proofs.
132-
type BundleProof struct {
133-
Proof []byte `json:"proof"`
134-
Instances []byte `json:"instances"`
135-
Vk []byte `json:"vk"`
136-
// cross-reference between cooridinator computation and prover compution
137-
GitVersion string `json:"git_version,omitempty"`
138-
}
139-
140-
// SanityCheck checks whether a BundleProof is in a legal format
141-
func (ap *BundleProof) SanityCheck() error {
142-
if ap == nil {
143-
return errors.New("agg_proof is nil")
144-
}
145-
146-
if len(ap.Proof) == 0 {
147-
return errors.New("proof not ready")
148-
}
149-
150-
if len(ap.Proof)%32 != 0 {
151-
return fmt.Errorf("proof buffer length must be a multiple of 32, got: %d", len(ap.Proof))
152-
}
153-
154-
if len(ap.Instances) == 0 {
155-
return errors.New("instance not ready")
156-
}
157-
158-
if len(ap.Vk) == 0 {
159-
return errors.New("vk not ready")
160-
}
161-
162-
return nil
163-
}
89+
type BundleProof json.RawMessage

coordinator/internal/logic/provertask/batch_prover_task.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -232,9 +232,6 @@ func (bp *BatchProverTask) formatProverTask(ctx context.Context, task *orm.Prove
232232
DataHash: common.HexToHash(chunk.Hash),
233233
IsPadding: false,
234234
}
235-
if proof.ChunkInfo != nil {
236-
chunkInfo.TxBytes = proof.ChunkInfo.TxBytes
237-
}
238235
chunkInfos = append(chunkInfos, &chunkInfo)
239236
}
240237

coordinator/internal/logic/verifier/mock.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,23 @@ func NewVerifier(cfg *config.VerifierConfig) (*Verifier, error) {
1717

1818
// VerifyChunkProof return a mock verification result for a ChunkProof.
1919
func (v *Verifier) VerifyChunkProof(proof *message.ChunkProof, forkName string) (bool, error) {
20-
if string(proof.Proof) == InvalidTestProof {
20+
if string(*proof) == InvalidTestProof {
2121
return false, nil
2222
}
2323
return true, nil
2424
}
2525

2626
// VerifyBatchProof return a mock verification result for a BatchProof.
2727
func (v *Verifier) VerifyBatchProof(proof *message.BatchProof, forkName string) (bool, error) {
28-
if string(proof.Proof) == InvalidTestProof {
28+
if string(*proof) == InvalidTestProof {
2929
return false, nil
3030
}
3131
return true, nil
3232
}
3333

3434
// VerifyBundleProof return a mock verification result for a BundleProof.
3535
func (v *Verifier) VerifyBundleProof(proof *message.BundleProof, forkName string) (bool, error) {
36-
if string(proof.Proof) == InvalidTestProof {
36+
if string(*proof) == InvalidTestProof {
3737
return false, nil
3838
}
3939
return true, nil

coordinator/internal/logic/verifier/verifier.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ func NewVerifier(cfg *config.VerifierConfig) (*Verifier, error) {
113113
func (v *Verifier) VerifyBatchProof(proof *message.BatchProof, forkName string) (bool, error) {
114114
if v.cfg.MockMode {
115115
log.Info("Mock mode, batch verifier disabled")
116-
if string(proof.Proof) == InvalidTestProof {
116+
if string(*proof) == InvalidTestProof {
117117
return false, nil
118118
}
119119
return true, nil
@@ -140,7 +140,7 @@ func (v *Verifier) VerifyBatchProof(proof *message.BatchProof, forkName string)
140140
func (v *Verifier) VerifyChunkProof(proof *message.ChunkProof, forkName string) (bool, error) {
141141
if v.cfg.MockMode {
142142
log.Info("Mock mode, verifier disabled")
143-
if string(proof.Proof) == InvalidTestProof {
143+
if string(*proof) == InvalidTestProof {
144144
return false, nil
145145
}
146146
return true, nil
@@ -167,7 +167,7 @@ func (v *Verifier) VerifyChunkProof(proof *message.ChunkProof, forkName string)
167167
func (v *Verifier) VerifyBundleProof(proof *message.BundleProof, forkName string) (bool, error) {
168168
if v.cfg.MockMode {
169169
log.Info("Mock mode, verifier disabled")
170-
if string(proof.Proof) == InvalidTestProof {
170+
if string(*proof) == InvalidTestProof {
171171
return false, nil
172172
}
173173
return true, nil

coordinator/test/mock_prover.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -223,15 +223,13 @@ func (r *mockProver) submitProof(t *testing.T, proverTaskSchema *types.GetTaskSc
223223
if proofStatus == verifiedFailed {
224224
switch proverTaskSchema.TaskType {
225225
case int(message.ProofTypeChunk):
226-
chunkProof := message.ChunkProof{}
227-
chunkProof.Proof = []byte(verifier.InvalidTestProof)
226+
chunkProof := []byte(verifier.InvalidTestProof)
228227
encodeData, err := json.Marshal(&chunkProof)
229228
assert.NoError(t, err)
230229
assert.NotEmpty(t, encodeData)
231230
proof = encodeData
232231
case int(message.ProofTypeBatch):
233-
batchProof := message.BatchProof{}
234-
batchProof.Proof = []byte(verifier.InvalidTestProof)
232+
batchProof := []byte(verifier.InvalidTestProof)
235233
encodeData, err := json.Marshal(&batchProof)
236234
assert.NoError(t, err)
237235
assert.NotEmpty(t, encodeData)

0 commit comments

Comments
 (0)