From 763e9d402e78d866f872015df75e9ce4f5c53b10 Mon Sep 17 00:00:00 2001 From: colinlyguo Date: Mon, 9 Oct 2023 11:55:40 +0800 Subject: [PATCH] fix bug --- common/types/block.go | 2 +- common/types/chunk_test.go | 6 +++--- .../internal/controller/watcher/batch_proposer_test.go | 10 +++++----- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/common/types/block.go b/common/types/block.go index bf900dc5e9..64b8c70e8c 100644 --- a/common/types/block.go +++ b/common/types/block.go @@ -17,7 +17,7 @@ const CalldataNonZeroByteGas = 16 // GetKeccak256Gas calculates the gas cost for computing the keccak256 hash of a given size. func GetKeccak256Gas(size uint64) uint64 { - return GetMemoryExpansionCost(size) + 30 + 6*((size+31)/32) + GetMemoryExpansionCost(size) + return GetMemoryExpansionCost(size) + 30 + 6*((size+31)/32) } // GetMemoryExpansionCost calculates the cost of memory expansion for a given memoryByteSize. diff --git a/common/types/chunk_test.go b/common/types/chunk_test.go index 5bfb4c6fa5..8d7e27f08b 100644 --- a/common/types/chunk_test.go +++ b/common/types/chunk_test.go @@ -46,7 +46,7 @@ func TestChunkEncode(t *testing.T) { }, } assert.Equal(t, uint64(0), chunk.NumL1Messages(0)) - assert.Equal(t, uint64(6078), chunk.EstimateL1CommitGas()) + assert.Equal(t, uint64(6042), chunk.EstimateL1CommitGas()) bytes, err = chunk.Encode(0) hexString := hex.EncodeToString(bytes) assert.NoError(t, err) @@ -68,7 +68,7 @@ func TestChunkEncode(t *testing.T) { }, } assert.Equal(t, uint64(11), chunk.NumL1Messages(0)) - assert.Equal(t, uint64(5344), chunk.EstimateL1CommitGas()) + assert.Equal(t, uint64(5329), chunk.EstimateL1CommitGas()) bytes, err = chunk.Encode(0) hexString = hex.EncodeToString(bytes) assert.NoError(t, err) @@ -84,7 +84,7 @@ func TestChunkEncode(t *testing.T) { }, } assert.Equal(t, uint64(11), chunk.NumL1Messages(0)) - assert.Equal(t, uint64(10642), chunk.EstimateL1CommitGas()) + assert.Equal(t, uint64(10612), chunk.EstimateL1CommitGas()) bytes, err = chunk.Encode(0) hexString = hex.EncodeToString(bytes) assert.NoError(t, err) diff --git a/rollup/internal/controller/watcher/batch_proposer_test.go b/rollup/internal/controller/watcher/batch_proposer_test.go index e530c3002e..580d1bdc38 100644 --- a/rollup/internal/controller/watcher/batch_proposer_test.go +++ b/rollup/internal/controller/watcher/batch_proposer_test.go @@ -109,9 +109,9 @@ func testBatchProposerLimits(t *testing.T) { chunkOrm := orm.NewChunk(db) chunks, err := chunkOrm.GetChunksInRange(context.Background(), 0, 1) assert.NoError(t, err) - assert.Equal(t, uint64(6078), chunks[0].TotalL1CommitGas) + assert.Equal(t, uint64(6042), chunks[0].TotalL1CommitGas) assert.Equal(t, uint32(298), chunks[0].TotalL1CommitCalldataSize) - assert.Equal(t, uint64(95190), chunks[1].TotalL1CommitGas) + assert.Equal(t, uint64(94586), chunks[1].TotalL1CommitGas) assert.Equal(t, uint32(5735), chunks[1].TotalL1CommitCalldataSize) bp := NewBatchProposer(context.Background(), &config.BatchProposerConfig{ @@ -168,9 +168,9 @@ func testBatchCommitGasAndCalldataSizeEstimation(t *testing.T) { chunkOrm := orm.NewChunk(db) chunks, err := chunkOrm.GetChunksInRange(context.Background(), 0, 1) assert.NoError(t, err) - assert.Equal(t, uint64(6078), chunks[0].TotalL1CommitGas) + assert.Equal(t, uint64(6042), chunks[0].TotalL1CommitGas) assert.Equal(t, uint32(298), chunks[0].TotalL1CommitCalldataSize) - assert.Equal(t, uint64(95190), chunks[1].TotalL1CommitGas) + assert.Equal(t, uint64(94586), chunks[1].TotalL1CommitGas) assert.Equal(t, uint32(5735), chunks[1].TotalL1CommitCalldataSize) bp := NewBatchProposer(context.Background(), &config.BatchProposerConfig{ @@ -199,6 +199,6 @@ func testBatchCommitGasAndCalldataSizeEstimation(t *testing.T) { assert.Equal(t, types.ProvingTaskUnassigned, types.ProvingStatus(chunk.ProvingStatus)) } - assert.Equal(t, uint64(255208), batches[0].TotalL1CommitGas) + assert.Equal(t, uint64(254562), batches[0].TotalL1CommitGas) assert.Equal(t, uint32(6033), batches[0].TotalL1CommitCalldataSize) }