From bc8f9dbc83e662aa06db161b0e4dc686a6b5818d Mon Sep 17 00:00:00 2001 From: colin <102356659+colinlyguo@users.noreply.github.com> Date: Wed, 23 Oct 2024 22:15:15 +0800 Subject: [PATCH] fix(rollup-relayer): wrong l1 messages popped num (#1550) --- common/version/version.go | 2 +- coordinator/internal/orm/batch.go | 12 ++++++------ rollup/internal/orm/batch.go | 6 +++--- rollup/internal/utils/utils.go | 2 +- tests/integration-test/orm/batch.go | 12 ++++++------ 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/common/version/version.go b/common/version/version.go index c254d9bf8..696291edd 100644 --- a/common/version/version.go +++ b/common/version/version.go @@ -5,7 +5,7 @@ import ( "runtime/debug" ) -var tag = "v4.4.69" +var tag = "v4.4.70" var commit = func() string { if info, ok := debug.ReadBuildInfo(); ok { diff --git a/coordinator/internal/orm/batch.go b/coordinator/internal/orm/batch.go index d5313f8fe..3dd8412e5 100644 --- a/coordinator/internal/orm/batch.go +++ b/coordinator/internal/orm/batch.go @@ -260,7 +260,7 @@ func (o *Batch) InsertBatch(ctx context.Context, batch *encoding.Batch, dbTX ... if err != nil { log.Error("failed to create new DA batch", "index", batch.Index, "total l1 message popped before", batch.TotalL1MessagePoppedBefore, - "parent hash", batch.ParentBatchHash, "number of chunks", numChunks, "err", err) + "parent hash", batch.ParentBatchHash.Hex(), "number of chunks", numChunks, "err", err) return nil, err } @@ -268,7 +268,7 @@ func (o *Batch) InsertBatch(ctx context.Context, batch *encoding.Batch, dbTX ... parentBatch, err := o.GetLatestBatch(ctx) if err != nil { log.Error("failed to get latest batch", "index", batch.Index, "total l1 message popped before", batch.TotalL1MessagePoppedBefore, - "parent hash", batch.ParentBatchHash, "number of chunks", numChunks, "err", err) + "parent hash", batch.ParentBatchHash.Hex(), "number of chunks", numChunks, "err", err) return nil, fmt.Errorf("Batch.InsertBatch error: %w", err) } @@ -282,14 +282,14 @@ func (o *Batch) InsertBatch(ctx context.Context, batch *encoding.Batch, dbTX ... startDAChunk, err := codec.NewDAChunk(batch.Chunks[0], batch.TotalL1MessagePoppedBefore) if err != nil { log.Error("failed to create start DA chunk", "index", batch.Index, "total l1 message popped before", batch.TotalL1MessagePoppedBefore, - "parent hash", batch.ParentBatchHash, "number of chunks", numChunks, "err", err) + "parent hash", batch.ParentBatchHash.Hex(), "number of chunks", numChunks, "err", err) return nil, fmt.Errorf("Batch.InsertBatch error: %w", err) } startDAChunkHash, err := startDAChunk.Hash() if err != nil { log.Error("failed to get start DA chunk hash", "index", batch.Index, "total l1 message popped before", batch.TotalL1MessagePoppedBefore, - "parent hash", batch.ParentBatchHash, "number of chunks", numChunks, "err", err) + "parent hash", batch.ParentBatchHash.Hex(), "number of chunks", numChunks, "err", err) return nil, fmt.Errorf("Batch.InsertBatch error: %w", err) } @@ -300,14 +300,14 @@ func (o *Batch) InsertBatch(ctx context.Context, batch *encoding.Batch, dbTX ... endDAChunk, err := codec.NewDAChunk(batch.Chunks[numChunks-1], totalL1MessagePoppedBeforeEndDAChunk) if err != nil { log.Error("failed to create end DA chunk", "index", batch.Index, "total l1 message popped before", totalL1MessagePoppedBeforeEndDAChunk, - "parent hash", batch.ParentBatchHash, "number of chunks", numChunks, "err", err) + "parent hash", batch.ParentBatchHash.Hex(), "number of chunks", numChunks, "err", err) return nil, fmt.Errorf("Batch.InsertBatch error: %w", err) } endDAChunkHash, err := endDAChunk.Hash() if err != nil { log.Error("failed to get end DA chunk hash", "index", batch.Index, "total l1 message popped before", totalL1MessagePoppedBeforeEndDAChunk, - "parent hash", batch.ParentBatchHash, "number of chunks", numChunks, "err", err) + "parent hash", batch.ParentBatchHash.Hex(), "number of chunks", numChunks, "err", err) return nil, fmt.Errorf("Batch.InsertBatch error: %w", err) } diff --git a/rollup/internal/orm/batch.go b/rollup/internal/orm/batch.go index 3aa515711..6f909f296 100644 --- a/rollup/internal/orm/batch.go +++ b/rollup/internal/orm/batch.go @@ -265,7 +265,7 @@ func (o *Batch) InsertBatch(ctx context.Context, batch *encoding.Batch, codecVer parentBatch, getErr := o.GetBatchByIndex(ctx, batch.Index-1) if getErr != nil { log.Error("failed to get batch by index", "index", batch.Index, "total l1 message popped before", batch.TotalL1MessagePoppedBefore, - "parent hash", batch.ParentBatchHash, "number of chunks", numChunks, "err", getErr) + "parent hash", batch.ParentBatchHash.Hex(), "number of chunks", numChunks, "err", getErr) return nil, fmt.Errorf("Batch.InsertBatch error: %w", getErr) } startChunkIndex = parentBatch.EndChunkIndex + 1 @@ -274,14 +274,14 @@ func (o *Batch) InsertBatch(ctx context.Context, batch *encoding.Batch, codecVer batchMeta, err := rutils.GetBatchMetadata(batch, codecVersion) if err != nil { log.Error("failed to get batch metadata", "index", batch.Index, "total l1 message popped before", batch.TotalL1MessagePoppedBefore, - "parent hash", batch.ParentBatchHash, "number of chunks", numChunks, "err", err) + "parent hash", batch.ParentBatchHash.Hex(), "number of chunks", numChunks, "err", err) return nil, fmt.Errorf("Batch.InsertBatch error: %w", err) } enableCompress, err := encoding.GetBatchEnableCompression(codecVersion, batch) if err != nil { log.Error("failed to get batch enable compress", "index", batch.Index, "total l1 message popped before", batch.TotalL1MessagePoppedBefore, - "parent hash", batch.ParentBatchHash, "number of chunks", numChunks, "err", err) + "parent hash", batch.ParentBatchHash.Hex(), "number of chunks", numChunks, "err", err) return nil, fmt.Errorf("Batch.InsertBatch error: %w", err) } diff --git a/rollup/internal/utils/utils.go b/rollup/internal/utils/utils.go index 6a66e8ec3..e23860f81 100644 --- a/rollup/internal/utils/utils.go +++ b/rollup/internal/utils/utils.go @@ -199,7 +199,7 @@ func GetBatchMetadata(batch *encoding.Batch, codecVersion encoding.CodecVersion) return nil, fmt.Errorf("failed to get start DA chunk hash, version: %v, err: %w", codecVersion, err) } - var totalL1MessagePoppedBeforeEndDAChunk uint64 + totalL1MessagePoppedBeforeEndDAChunk := batch.TotalL1MessagePoppedBefore for i := 0; i < len(batch.Chunks)-1; i++ { totalL1MessagePoppedBeforeEndDAChunk += batch.Chunks[i].NumL1Messages(totalL1MessagePoppedBeforeEndDAChunk) } diff --git a/tests/integration-test/orm/batch.go b/tests/integration-test/orm/batch.go index d6727d0e1..b88ed060a 100644 --- a/tests/integration-test/orm/batch.go +++ b/tests/integration-test/orm/batch.go @@ -106,7 +106,7 @@ func (o *Batch) InsertBatch(ctx context.Context, batch *encoding.Batch, dbTX ... if err != nil { log.Error("failed to create new DA batch", "index", batch.Index, "total l1 message popped before", batch.TotalL1MessagePoppedBefore, - "parent hash", batch.ParentBatchHash, "number of chunks", numChunks, "err", err) + "parent hash", batch.ParentBatchHash.Hex(), "number of chunks", numChunks, "err", err) return nil, err } @@ -114,7 +114,7 @@ func (o *Batch) InsertBatch(ctx context.Context, batch *encoding.Batch, dbTX ... parentBatch, err := o.GetLatestBatch(ctx) if err != nil { log.Error("failed to get latest batch", "index", batch.Index, "total l1 message popped before", batch.TotalL1MessagePoppedBefore, - "parent hash", batch.ParentBatchHash, "number of chunks", numChunks, "err", err) + "parent hash", batch.ParentBatchHash.Hex(), "number of chunks", numChunks, "err", err) return nil, fmt.Errorf("Batch.InsertBatch error: %w", err) } @@ -128,14 +128,14 @@ func (o *Batch) InsertBatch(ctx context.Context, batch *encoding.Batch, dbTX ... startDAChunk, err := codec.NewDAChunk(batch.Chunks[0], batch.TotalL1MessagePoppedBefore) if err != nil { log.Error("failed to create start DA chunk", "index", batch.Index, "total l1 message popped before", batch.TotalL1MessagePoppedBefore, - "parent hash", batch.ParentBatchHash, "number of chunks", numChunks, "err", err) + "parent hash", batch.ParentBatchHash.Hex(), "number of chunks", numChunks, "err", err) return nil, fmt.Errorf("Batch.InsertBatch error: %w", err) } startDAChunkHash, err := startDAChunk.Hash() if err != nil { log.Error("failed to get start DA chunk hash", "index", batch.Index, "total l1 message popped before", batch.TotalL1MessagePoppedBefore, - "parent hash", batch.ParentBatchHash, "number of chunks", numChunks, "err", err) + "parent hash", batch.ParentBatchHash.Hex(), "number of chunks", numChunks, "err", err) return nil, fmt.Errorf("Batch.InsertBatch error: %w", err) } @@ -146,14 +146,14 @@ func (o *Batch) InsertBatch(ctx context.Context, batch *encoding.Batch, dbTX ... endDAChunk, err := codec.NewDAChunk(batch.Chunks[numChunks-1], totalL1MessagePoppedBeforeEndDAChunk) if err != nil { log.Error("failed to create end DA chunk", "index", batch.Index, "total l1 message popped before", totalL1MessagePoppedBeforeEndDAChunk, - "parent hash", batch.ParentBatchHash, "number of chunks", numChunks, "err", err) + "parent hash", batch.ParentBatchHash.Hex(), "number of chunks", numChunks, "err", err) return nil, fmt.Errorf("Batch.InsertBatch error: %w", err) } endDAChunkHash, err := endDAChunk.Hash() if err != nil { log.Error("failed to get end DA chunk hash", "index", batch.Index, "total l1 message popped before", totalL1MessagePoppedBeforeEndDAChunk, - "parent hash", batch.ParentBatchHash, "number of chunks", numChunks, "err", err) + "parent hash", batch.ParentBatchHash.Hex(), "number of chunks", numChunks, "err", err) return nil, fmt.Errorf("Batch.InsertBatch error: %w", err) }