diff --git a/coordinator/internal/logic/provertask/batch_prover_task.go b/coordinator/internal/logic/provertask/batch_prover_task.go index 41b671354..78789764e 100644 --- a/coordinator/internal/logic/provertask/batch_prover_task.go +++ b/coordinator/internal/logic/provertask/batch_prover_task.go @@ -249,7 +249,7 @@ func (bp *BatchProverTask) getBatchTaskDetail(dbBatch *orm.Batch, chunkInfos []* codec, err := encoding.CodecFromVersion(encoding.CodecVersion(dbBatch.CodecVersion)) if err != nil { - return nil, fmt.Errorf("failed to get codec from version %d: %w", dbBatch.CodecVersion, err) + return nil, fmt.Errorf("failed to get codec from version %d, err: %w", dbBatch.CodecVersion, err) } batchHeader, decodeErr := codec.NewDABatchFromBytes(dbBatch.BatchHeader) diff --git a/rollup/internal/controller/relayer/l2_relayer.go b/rollup/internal/controller/relayer/l2_relayer.go index a48cd1a1e..e58dd2411 100644 --- a/rollup/internal/controller/relayer/l2_relayer.go +++ b/rollup/internal/controller/relayer/l2_relayer.go @@ -966,7 +966,7 @@ func (r *Layer2Relayer) handleL2RollupRelayerConfirmLoop(ctx context.Context) { func (r *Layer2Relayer) constructCommitBatchPayloadCodecV0AndV1AndV2(dbBatch *orm.Batch, dbParentBatch *orm.Batch, dbChunks []*orm.Chunk, chunks []*encoding.Chunk) ([]byte, *kzg4844.Blob, error) { codec, err := encoding.CodecFromVersion(encoding.CodecVersion(dbBatch.CodecVersion)) if err != nil { - return nil, nil, fmt.Errorf("failed to get codec from version: %w", err) + return nil, nil, fmt.Errorf("failed to get codec from version %d, err: %w", dbBatch.CodecVersion, err) } batch := &encoding.Batch{ @@ -1011,7 +1011,7 @@ func (r *Layer2Relayer) constructCommitBatchPayloadCodecV3AndV4(dbBatch *orm.Bat codec, err := encoding.CodecFromVersion(encoding.CodecVersion(dbBatch.CodecVersion)) if err != nil { - return nil, nil, fmt.Errorf("failed to get codec from version: %w", err) + return nil, nil, fmt.Errorf("failed to get codec from version %d, err: %w", dbBatch.CodecVersion, err) } daBatch, createErr := codec.NewDABatch(batch) @@ -1083,7 +1083,7 @@ func (r *Layer2Relayer) constructFinalizeBatchPayloadCodecV1AndV2(dbBatch *orm.B codec, err := encoding.CodecFromVersion(encoding.CodecVersion(dbBatch.CodecVersion)) if err != nil { - return nil, fmt.Errorf("failed to get codec from version: %w", err) + return nil, fmt.Errorf("failed to get codec from version %d, err: %w", dbBatch.CodecVersion, err) } daBatch, createErr := codec.NewDABatch(batch) diff --git a/rollup/internal/controller/watcher/batch_proposer.go b/rollup/internal/controller/watcher/batch_proposer.go index 46080d8f6..f107abf5e 100644 --- a/rollup/internal/controller/watcher/batch_proposer.go +++ b/rollup/internal/controller/watcher/batch_proposer.go @@ -278,8 +278,6 @@ func (p *BatchProposer) proposeBatch() error { return err } - codecVersion := encoding.GetCodecVersion(p.chainCfg, firstUnbatchedChunk.StartBlockNumber, firstUnbatchedChunk.StartBlockTime) - var batch encoding.Batch batch.Index = dbParentBatch.Index + 1 batch.ParentBatchHash = common.HexToHash(dbParentBatch.Hash) @@ -287,7 +285,7 @@ func (p *BatchProposer) proposeBatch() error { for i, chunk := range daChunks { batch.Chunks = append(batch.Chunks, chunk) - metrics, calcErr := utils.CalculateBatchMetrics(&batch, codecVersion) + metrics, calcErr := utils.CalculateBatchMetrics(&batch, codec.Version()) if calcErr != nil { return fmt.Errorf("failed to calculate batch metrics: %w", calcErr) } @@ -316,17 +314,17 @@ func (p *BatchProposer) proposeBatch() error { batch.Chunks = batch.Chunks[:len(batch.Chunks)-1] - metrics, err := utils.CalculateBatchMetrics(&batch, codecVersion) + metrics, err := utils.CalculateBatchMetrics(&batch, codec.Version()) if err != nil { return fmt.Errorf("failed to calculate batch metrics: %w", err) } p.recordAllBatchMetrics(metrics) - return p.updateDBBatchInfo(&batch, codecVersion, metrics) + return p.updateDBBatchInfo(&batch, codec.Version(), metrics) } } - metrics, calcErr := utils.CalculateBatchMetrics(&batch, codecVersion) + metrics, calcErr := utils.CalculateBatchMetrics(&batch, codec.Version()) if calcErr != nil { return fmt.Errorf("failed to calculate batch metrics: %w", calcErr) } @@ -340,7 +338,7 @@ func (p *BatchProposer) proposeBatch() error { p.batchFirstBlockTimeoutReached.Inc() p.recordAllBatchMetrics(metrics) - return p.updateDBBatchInfo(&batch, codecVersion, metrics) + return p.updateDBBatchInfo(&batch, codec.Version(), metrics) } log.Debug("pending chunks do not reach one of the constraints or contain a timeout block") diff --git a/rollup/internal/orm/chunk.go b/rollup/internal/orm/chunk.go index 18ee27609..893290f75 100644 --- a/rollup/internal/orm/chunk.go +++ b/rollup/internal/orm/chunk.go @@ -210,7 +210,7 @@ func (o *Chunk) InsertChunk(ctx context.Context, chunk *encoding.Chunk, codecVer enableCompress, err := encoding.GetChunkEnableCompression(codecVersion, chunk) if err != nil { - log.Error("failed to get chunk enable compression", "err", err) + log.Error("failed to get chunk enable compression", "version", codecVersion, "err", err) return nil, fmt.Errorf("Chunk.InsertChunk error: %w", err) } diff --git a/rollup/internal/utils/utils.go b/rollup/internal/utils/utils.go index c6c203ef5..1c7f14ceb 100644 --- a/rollup/internal/utils/utils.go +++ b/rollup/internal/utils/utils.go @@ -47,7 +47,7 @@ func CalculateChunkMetrics(chunk *encoding.Chunk, codecVersion encoding.CodecVer codec, err := encoding.CodecFromVersion(codecVersion) if err != nil { - return nil, fmt.Errorf("failed to get codec from version: %w", err) + return nil, fmt.Errorf("failed to get codec from version: %v, err: %w", codecVersion, err) } start := time.Now() @@ -104,7 +104,7 @@ func CalculateBatchMetrics(batch *encoding.Batch, codecVersion encoding.CodecVer codec, err := encoding.CodecFromVersion(codecVersion) if err != nil { - return nil, fmt.Errorf("failed to get codec from version: %w", err) + return nil, fmt.Errorf("failed to get codec from version: %v, err: %w", codecVersion, err) } start := time.Now() @@ -133,7 +133,7 @@ func CalculateBatchMetrics(batch *encoding.Batch, codecVersion encoding.CodecVer func GetChunkHash(chunk *encoding.Chunk, totalL1MessagePoppedBefore uint64, codecVersion encoding.CodecVersion) (common.Hash, error) { codec, err := encoding.CodecFromVersion(codecVersion) if err != nil { - return common.Hash{}, fmt.Errorf("failed to get codec from version: %w", err) + return common.Hash{}, fmt.Errorf("failed to get codec from version: %v, err: %w", codecVersion, err) } daChunk, err := codec.NewDAChunk(chunk, totalL1MessagePoppedBefore) @@ -164,7 +164,7 @@ type BatchMetadata struct { func GetBatchMetadata(batch *encoding.Batch, codecVersion encoding.CodecVersion) (*BatchMetadata, error) { codec, err := encoding.CodecFromVersion(codecVersion) if err != nil { - return nil, fmt.Errorf("failed to get codec from version: %w", err) + return nil, fmt.Errorf("failed to get codec from version: %v, err: %w", codecVersion, err) } daBatch, err := codec.NewDABatch(batch) @@ -174,7 +174,7 @@ func GetBatchMetadata(batch *encoding.Batch, codecVersion encoding.CodecVersion) batchMeta := &BatchMetadata{ BatchHash: daBatch.Hash(), - BatchDataHash: common.Hash{}, // Assuming DataHash is not directly accessible from DABatch interface + BatchDataHash: daBatch.DataHash(), BatchBytes: daBatch.Encode(), BlobBytes: daBatch.BlobBytes(), }