Skip to content

Commit 76e9283

Browse files
committed
TaskProvingTask omit kzg part in validium mode
1 parent 58c8ca3 commit 76e9283

File tree

3 files changed

+28
-17
lines changed

3 files changed

+28
-17
lines changed

common/types/message/message.go

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -93,14 +93,15 @@ func (e *Byte48) UnmarshalJSON(input []byte) error {
9393
type BatchTaskDetail struct {
9494
Version uint8 `json:"version"`
9595
// use one of the string of "euclidv1" / "euclidv2"
96-
ForkName string `json:"fork_name"`
97-
ChunkInfos []*ChunkInfo `json:"chunk_infos"`
98-
ChunkProofs []*OpenVMChunkProof `json:"chunk_proofs"`
99-
BatchHeader interface{} `json:"batch_header"`
100-
BlobBytes []byte `json:"blob_bytes"`
101-
KzgProof Byte48 `json:"kzg_proof,omitempty"`
102-
KzgCommitment Byte48 `json:"kzg_commitment,omitempty"`
103-
ChallengeDigest common.Hash `json:"challenge_digest,omitempty"`
96+
ForkName string `json:"fork_name"`
97+
ChunkInfos []*ChunkInfo `json:"chunk_infos"`
98+
ChunkProofs []*OpenVMChunkProof `json:"chunk_proofs"`
99+
BatchHeader interface{} `json:"batch_header"`
100+
BlobBytes []byte `json:"blob_bytes"`
101+
KzgProof *Byte48 `json:"kzg_proof,omitempty"`
102+
KzgCommitment *Byte48 `json:"kzg_commitment,omitempty"`
103+
// ChallengeDigest should be a common.Hash type if it is not nil
104+
ChallengeDigest interface{} `json:"challenge_digest,omitempty"`
104105
}
105106

106107
// BundleTaskDetail consists of all the information required to describe the task to generate a proof for a bundle of batches.

coordinator/internal/logic/provertask/batch_prover_task.go

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,7 @@ func (bp *BatchProverTask) formatProverTask(ctx context.Context, task *orm.Prove
269269
InitialBlockNumber: proof.MetaData.ChunkInfo.InitialBlockNumber,
270270
BlockCtxs: proof.MetaData.ChunkInfo.BlockCtxs,
271271
TxDataLength: proof.MetaData.ChunkInfo.TxDataLength,
272+
EncryptionKey: proof.MetaData.ChunkInfo.EncryptionKey,
272273
}
273274
chunkInfos = append(chunkInfos, &chunkInfo)
274275
}
@@ -278,15 +279,15 @@ func (bp *BatchProverTask) formatProverTask(ctx context.Context, task *orm.Prove
278279
return nil, fmt.Errorf("failed to get batch task detail, taskID:%s err:%w", task.TaskID, err)
279280
}
280281

281-
chunkProofsBytes, err := json.Marshal(taskDetail)
282+
taskBytesWithchunkProofs, err := json.Marshal(taskDetail)
282283
if err != nil {
283284
return nil, fmt.Errorf("failed to marshal chunk proofs, taskID:%s err:%w", task.TaskID, err)
284285
}
285286

286287
taskMsg := &coordinatorType.GetTaskSchema{
287288
TaskID: task.TaskID,
288289
TaskType: int(message.ProofTypeBatch),
289-
TaskData: string(chunkProofsBytes),
290+
TaskData: string(taskBytesWithchunkProofs),
290291
HardForkName: hardForkName,
291292
}
292293

@@ -333,13 +334,15 @@ func (bp *BatchProverTask) getBatchTaskDetail(dbBatch *orm.Batch, chunkInfos []*
333334
}
334335
taskDetail.BatchHeader = batchHeader
335336
taskDetail.BlobBytes = dbBatch.BlobBytes
336-
taskDetail.ChallengeDigest = common.HexToHash(dbBatch.ChallengeDigest)
337-
// Memory layout of `BlobDataProof`: used in Codec.BlobDataProofForPointEvaluation()
338-
// | z | y | kzg_commitment | kzg_proof |
339-
// |---------|---------|----------------|-----------|
340-
// | bytes32 | bytes32 | bytes48 | bytes48 |
341-
taskDetail.KzgProof = message.Byte48{Big: hexutil.Big(*new(big.Int).SetBytes(dbBatch.BlobDataProof[112:160]))}
342-
taskDetail.KzgCommitment = message.Byte48{Big: hexutil.Big(*new(big.Int).SetBytes(dbBatch.BlobDataProof[64:112]))}
337+
if !bp.validiumMode() {
338+
taskDetail.ChallengeDigest = common.HexToHash(dbBatch.ChallengeDigest)
339+
// Memory layout of `BlobDataProof`: used in Codec.BlobDataProofForPointEvaluation()
340+
// | z | y | kzg_commitment | kzg_proof |
341+
// |---------|---------|----------------|-----------|
342+
// | bytes32 | bytes32 | bytes48 | bytes48 |
343+
taskDetail.KzgProof = &message.Byte48{Big: hexutil.Big(*new(big.Int).SetBytes(dbBatch.BlobDataProof[112:160]))}
344+
taskDetail.KzgCommitment = &message.Byte48{Big: hexutil.Big(*new(big.Int).SetBytes(dbBatch.BlobDataProof[64:112]))}
345+
}
343346

344347
return taskDetail, nil
345348
}

coordinator/internal/logic/provertask/prover_task.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,13 @@ func (b *BaseProverTask) version(hardForkName string) (uint8, error) {
8686
return (domain << 6) + stfVersion, nil
8787
}
8888

89+
// validiumMode induce different behavior in task generation:
90+
// + skip the point_evaluation part in batch task
91+
// +
92+
func (b *BaseProverTask) validiumMode() bool {
93+
return b.cfg.L2.ValidiumMode
94+
}
95+
8996
// hardForkName get the chunk/batch/bundle hard fork name
9097
func (b *BaseProverTask) hardForkName(ctx *gin.Context, taskCtx *proverTaskContext) (string, error) {
9198
switch {

0 commit comments

Comments
 (0)