Skip to content

Commit

Permalink
fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
colinlyguo committed Aug 19, 2024
1 parent d495b25 commit 9cb1ac5
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 13 deletions.
2 changes: 1 addition & 1 deletion common/types/message/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}

Expand Down
16 changes: 4 additions & 12 deletions coordinator/internal/logic/provertask/batch_prover_task.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -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)
Expand All @@ -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 {
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions coordinator/internal/orm/batch.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9cb1ac5

Please sign in to comment.