diff --git a/common/types/message/message.go b/common/types/message/message.go index 9e912c5ab6..57d78a9723 100644 --- a/common/types/message/message.go +++ b/common/types/message/message.go @@ -53,7 +53,7 @@ type ChunkTaskDetail struct { type BatchTaskDetail struct { ChunkInfos []*ChunkInfo `json:"chunk_infos"` ChunkProofs []*ChunkProof `json:"chunk_proofs"` - BatchHeader string `json:"batch_header"` + BatchHeader interface{} `json:"batch_header"` BlobBytes []byte `json:"blob_bytes"` } diff --git a/coordinator/internal/logic/provertask/batch_prover_task.go b/coordinator/internal/logic/provertask/batch_prover_task.go index 6dc96ee16b..ebcd4e9bea 100644 --- a/coordinator/internal/logic/provertask/batch_prover_task.go +++ b/coordinator/internal/logic/provertask/batch_prover_task.go @@ -242,7 +242,7 @@ func (bp *BatchProverTask) getBatchTaskDetail(ctx context.Context, hardForkName ChunkProofs: chunkProofs, } - if hardForkName != "darwin" { + if encoding.CodecVersion(dbBatch.CodecVersion) != encoding.CodecV3 && encoding.CodecVersion(dbBatch.CodecVersion) != encoding.CodecV4 { return taskDetail, nil } @@ -267,7 +267,7 @@ func (bp *BatchProverTask) getBatchTaskDetail(ctx context.Context, hardForkName Chunks: chunks, } - if !dbBatch.EnableEncode { + if encoding.CodecVersion(dbBatch.CodecVersion) == encoding.CodecV3 { daBatch, createErr := codecv3.NewDABatch(batchEncoding) if createErr != nil { return nil, fmt.Errorf("failed to create DA batch (v3) for batch %d: %w", dbBatch.Index, createErr) @@ -279,11 +279,7 @@ func (bp *BatchProverTask) getBatchTaskDetail(ctx context.Context, hardForkName return nil, fmt.Errorf("failed to decode batch header (v3) for batch %d: %w", dbBatch.Index, decodeErr) } - jsonData, marshalErr := json.Marshal(batchHeader) - if marshalErr != nil { - return nil, fmt.Errorf("failed to marshal batch header (v3) for batch %d: %w", dbBatch.Index, marshalErr) - } - taskDetail.BatchHeader = string(jsonData) + taskDetail.BatchHeader = batchHeader } else { daBatch, createErr := codecv4.NewDABatch(batchEncoding, dbBatch.EnableEncode) if createErr != nil { @@ -296,11 +292,7 @@ func (bp *BatchProverTask) getBatchTaskDetail(ctx context.Context, hardForkName return nil, fmt.Errorf("failed to decode batch header (v4) for batch %d: %w", dbBatch.Index, decodeErr) } - jsonData, marshalErr := json.Marshal(batchHeader) - if marshalErr != nil { - return nil, fmt.Errorf("failed to marshal batch header (v4) for batch %d: %w", dbBatch.Index, marshalErr) - } - taskDetail.BatchHeader = string(jsonData) + taskDetail.BatchHeader = batchHeader } return taskDetail, nil diff --git a/coordinator/internal/orm/batch.go b/coordinator/internal/orm/batch.go index 12dc0338d1..11698340bb 100644 --- a/coordinator/internal/orm/batch.go +++ b/coordinator/internal/orm/batch.go @@ -31,6 +31,7 @@ type Batch struct { WithdrawRoot string `json:"withdraw_root" gorm:"column:withdraw_root"` ParentBatchHash string `json:"parent_batch_hash" gorm:"column:parent_batch_hash"` BatchHeader []byte `json:"batch_header" gorm:"column:batch_header"` + CodecVersion int16 `json:"codec_version" gorm:"column:codec_version"` EnableEncode bool `json:"enable_encode" gorm:"column:enable_encode"` // proof