Skip to content

Commit fedfa04

Browse files
authored
refactor(coordinator): simplify logic post-Euclid (#1652)
1 parent 0d8b00c commit fedfa04

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+179
-8186
lines changed

.github/workflows/prover.yml

Lines changed: 0 additions & 99 deletions
This file was deleted.

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Please note that this project is released with a [Contributor Code of Conduct][c
1111

1212
## Contribute to Scroll
1313

14-
Did you know there are many ways of contributing to Scroll? If you are looking to contribute to by adding Scroll to existing Dev Tools or by doing integrations please go to the [Contribute to Scroll](https://github.com/scroll-tech/contribute-to-scroll) repo instead. If you are looking to contribute to Scroll's Halo2 zkEVM circuits please refer to the [zkEVM circuits](https://github.com/scroll-tech/zkevm-circuits) repo. This repository covers the Scroll infrastructure and smart contracts, if you want to contribute to these areas continue reading this document.
14+
Did you know there are many ways of contributing to Scroll? If you are looking to contribute to by adding Scroll to existing Dev Tools or by doing integrations please go to the [Contribute to Scroll](https://github.com/scroll-tech/contribute-to-scroll) repo instead. This repository covers the Scroll infrastructure and smart contracts, if you want to contribute to these areas continue reading this document.
1515

1616
## Issues and PRs
1717

common/libzkp/impl/src/lib.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,6 @@ pub unsafe extern "C" fn verify_chunk_proof(
2626

2727
fn verify_proof(proof: *const c_char, fork_name: *const c_char, task_type: TaskType) -> c_char {
2828
let fork_name_str = c_char_to_str(fork_name);
29-
// Skip verification for darwinV2 as we can't host darwinV2 and euclid verifiers on the same
30-
// binary.
31-
if fork_name_str == "darwinV2" {
32-
return true as c_char;
33-
}
34-
3529
let proof = c_char_to_vec(proof);
3630
let verifier = verifier::get_verifier(fork_name_str);
3731

common/types/message/message.go

Lines changed: 11 additions & 163 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ const (
1414
EuclidFork = "euclid"
1515
EuclidV2Fork = "euclidV2"
1616

17-
EuclidForkNameForProver = "euclidv1"
1817
EuclidV2ForkNameForProver = "euclidv2"
1918
)
2019

@@ -99,22 +98,22 @@ func (e *Byte48) UnmarshalJSON(input []byte) error {
9998
// BatchTaskDetail is a type containing BatchTask detail.
10099
type BatchTaskDetail struct {
101100
// use one of the string of EuclidFork / EuclidV2Fork
102-
ForkName string `json:"fork_name"`
103-
ChunkInfos []*ChunkInfo `json:"chunk_infos"`
104-
ChunkProofs []ChunkProof `json:"chunk_proofs"`
105-
BatchHeader interface{} `json:"batch_header"`
106-
BlobBytes []byte `json:"blob_bytes"`
107-
KzgProof Byte48 `json:"kzg_proof,omitempty"`
108-
KzgCommitment Byte48 `json:"kzg_commitment,omitempty"`
109-
ChallengeDigest common.Hash `json:"challenge_digest,omitempty"`
101+
ForkName string `json:"fork_name"`
102+
ChunkInfos []*ChunkInfo `json:"chunk_infos"`
103+
ChunkProofs []*OpenVMChunkProof `json:"chunk_proofs"`
104+
BatchHeader interface{} `json:"batch_header"`
105+
BlobBytes []byte `json:"blob_bytes"`
106+
KzgProof Byte48 `json:"kzg_proof,omitempty"`
107+
KzgCommitment Byte48 `json:"kzg_commitment,omitempty"`
108+
ChallengeDigest common.Hash `json:"challenge_digest,omitempty"`
110109
}
111110

112111
// BundleTaskDetail consists of all the information required to describe the task to generate a proof for a bundle of batches.
113112
type BundleTaskDetail struct {
114113
// use one of the string of EuclidFork / EuclidV2Fork
115-
ForkName string `json:"fork_name"`
116-
BatchProofs []BatchProof `json:"batch_proofs"`
117-
BundleInfo *OpenVMBundleInfo `json:"bundle_info,omitempty"`
114+
ForkName string `json:"fork_name"`
115+
BatchProofs []*OpenVMBatchProof `json:"batch_proofs"`
116+
BundleInfo *OpenVMBundleInfo `json:"bundle_info,omitempty"`
118117
}
119118

120119
// ChunkInfo is for calculating pi_hash for chunk
@@ -143,157 +142,6 @@ type BlockContextV2 struct {
143142
NumL1Msgs uint16 `json:"num_l1_msgs"`
144143
}
145144

146-
// SubCircuitRowUsage tracing info added in v0.11.0rc8
147-
type SubCircuitRowUsage struct {
148-
Name string `json:"name"`
149-
RowNumber uint64 `json:"row_number"`
150-
}
151-
152-
// ChunkProof
153-
type ChunkProof interface {
154-
Proof() []byte
155-
}
156-
157-
// NewChunkProof creates a new ChunkProof instance.
158-
func NewChunkProof(hardForkName string) ChunkProof {
159-
switch hardForkName {
160-
case EuclidFork, EuclidV2Fork:
161-
return &OpenVMChunkProof{}
162-
default:
163-
return &Halo2ChunkProof{}
164-
}
165-
}
166-
167-
// Halo2ChunkProof includes the proof info that are required for chunk verification and rollup.
168-
type Halo2ChunkProof struct {
169-
StorageTrace []byte `json:"storage_trace,omitempty"`
170-
Protocol []byte `json:"protocol"`
171-
RawProof []byte `json:"proof"`
172-
Instances []byte `json:"instances"`
173-
Vk []byte `json:"vk"`
174-
// cross-reference between cooridinator computation and prover compution
175-
ChunkInfo *ChunkInfo `json:"chunk_info,omitempty"`
176-
GitVersion string `json:"git_version,omitempty"`
177-
RowUsages []SubCircuitRowUsage `json:"row_usages,omitempty"`
178-
}
179-
180-
// Proof returns the proof bytes of a ChunkProof
181-
func (ap *Halo2ChunkProof) Proof() []byte {
182-
return ap.RawProof
183-
}
184-
185-
// BatchProof
186-
type BatchProof interface {
187-
SanityCheck() error
188-
Proof() []byte
189-
}
190-
191-
// NewBatchProof creates a new BatchProof instance.
192-
func NewBatchProof(hardForkName string) BatchProof {
193-
switch hardForkName {
194-
case EuclidFork, EuclidV2Fork:
195-
return &OpenVMBatchProof{}
196-
default:
197-
return &Halo2BatchProof{}
198-
}
199-
}
200-
201-
// Halo2BatchProof includes the proof info that are required for batch verification and rollup.
202-
type Halo2BatchProof struct {
203-
Protocol []byte `json:"protocol"`
204-
RawProof []byte `json:"proof"`
205-
Instances []byte `json:"instances"`
206-
Vk []byte `json:"vk"`
207-
// cross-reference between cooridinator computation and prover compution
208-
BatchHash common.Hash `json:"batch_hash"`
209-
GitVersion string `json:"git_version,omitempty"`
210-
}
211-
212-
// Proof returns the proof bytes of a BatchProof
213-
func (ap *Halo2BatchProof) Proof() []byte {
214-
return ap.RawProof
215-
}
216-
217-
// SanityCheck checks whether a BatchProof is in a legal format
218-
func (ap *Halo2BatchProof) SanityCheck() error {
219-
if ap == nil {
220-
return errors.New("agg_proof is nil")
221-
}
222-
223-
if len(ap.RawProof) == 0 {
224-
return errors.New("proof not ready")
225-
}
226-
227-
if len(ap.RawProof)%32 != 0 {
228-
return fmt.Errorf("proof buffer length must be a multiple of 32, got: %d", len(ap.RawProof))
229-
}
230-
231-
if len(ap.Instances) == 0 {
232-
return errors.New("instance not ready")
233-
}
234-
235-
if len(ap.Vk) == 0 {
236-
return errors.New("vk not ready")
237-
}
238-
239-
return nil
240-
}
241-
242-
// BundleProof
243-
type BundleProof interface {
244-
SanityCheck() error
245-
Proof() []byte
246-
}
247-
248-
// NewBundleProof creates a new BundleProof instance.
249-
func NewBundleProof(hardForkName string) BundleProof {
250-
switch hardForkName {
251-
case EuclidFork, EuclidV2Fork:
252-
return &OpenVMBundleProof{}
253-
default:
254-
return &Halo2BundleProof{}
255-
}
256-
}
257-
258-
// BundleProof includes the proof info that are required for verification of a bundle of batch proofs.
259-
type Halo2BundleProof struct {
260-
RawProof []byte `json:"proof"`
261-
Instances []byte `json:"instances"`
262-
Vk []byte `json:"vk"`
263-
// cross-reference between cooridinator computation and prover compution
264-
GitVersion string `json:"git_version,omitempty"`
265-
}
266-
267-
// Proof returns the proof bytes of a BundleProof
268-
func (ap *Halo2BundleProof) Proof() []byte {
269-
return ap.RawProof
270-
}
271-
272-
// SanityCheck checks whether a BundleProof is in a legal format
273-
func (ap *Halo2BundleProof) SanityCheck() error {
274-
if ap == nil {
275-
return errors.New("agg_proof is nil")
276-
}
277-
278-
if len(ap.RawProof) == 0 {
279-
return errors.New("proof not ready")
280-
}
281-
282-
if len(ap.RawProof)%32 != 0 {
283-
return fmt.Errorf("proof buffer length must be a multiple of 32, got: %d", len(ap.RawProof))
284-
}
285-
286-
if len(ap.Instances) == 0 {
287-
return errors.New("instance not ready")
288-
}
289-
290-
if len(ap.Vk) == 0 {
291-
return errors.New("vk not ready")
292-
}
293-
294-
return nil
295-
}
296-
297145
// Proof for flatten VM proof
298146
type OpenVMProof struct {
299147
Proof []byte `json:"proofs"`

common/version/version.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"runtime/debug"
66
)
77

8-
var tag = "v4.5.9"
8+
var tag = "v4.5.10"
99

1010
var commit = func() string {
1111
if info, ok := debug.ReadBuildInfo(); ok {

coordinator/cmd/api/app/mock_app.go

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -90,17 +90,9 @@ func (c *CoordinatorApp) MockConfig(store bool) error {
9090
cfg.ProverManager = &coordinatorConfig.ProverManager{
9191
ProversPerSession: 1,
9292
Verifier: &coordinatorConfig.VerifierConfig{
93-
MockMode: true,
94-
LowVersionCircuit: &coordinatorConfig.CircuitConfig{
95-
ParamsPath: "",
96-
AssetsPath: "",
97-
ForkName: "darwin",
98-
MinProverVersion: "v4.4.57",
99-
},
10093
HighVersionCircuit: &coordinatorConfig.CircuitConfig{
101-
ParamsPath: "",
10294
AssetsPath: "",
103-
ForkName: "darwinV2",
95+
ForkName: "euclidV2",
10496
MinProverVersion: "v4.4.89",
10597
},
10698
},

coordinator/cmd/tool/tool.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,14 @@ func action(ctx *cli.Context) error {
6262
return fmt.Errorf("failed to get batch proofs for bundle task id:%s, no batch found", taskID)
6363
}
6464

65-
var batchProofs []message.BatchProof
65+
var batchProofs []*message.OpenVMBatchProof
6666
for _, batch := range batches {
67-
proof := message.NewBatchProof("darwinV2")
67+
var proof message.OpenVMBatchProof
6868
if encodeErr := json.Unmarshal(batch.Proof, &proof); encodeErr != nil {
6969
log.Error("failed to unmarshal batch proof")
7070
return fmt.Errorf("failed to unmarshal proof: %w, bundle hash: %v, batch hash: %v", encodeErr, taskID, batch.Hash)
7171
}
72-
batchProofs = append(batchProofs, proof)
72+
batchProofs = append(batchProofs, &proof)
7373
}
7474

7575
taskDetail := message.BundleTaskDetail{

coordinator/conf/config.json

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,9 @@
77
"batch_collection_time_sec": 180,
88
"chunk_collection_time_sec": 180,
99
"verifier": {
10-
"mock_mode": true,
11-
"low_version_circuit": {
12-
"params_path": "params",
13-
"assets_path": "assets",
14-
"fork_name": "darwin",
15-
"min_prover_version": "v4.4.43"
16-
},
1710
"high_version_circuit": {
18-
"params_path": "params",
1911
"assets_path": "assets",
20-
"fork_name": "darwinV2",
12+
"fork_name": "euclidV2",
2113
"min_prover_version": "v4.4.45"
2214
}
2315
}

0 commit comments

Comments
 (0)