Skip to content

Commit

Permalink
fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
colinlyguo committed Oct 9, 2023
1 parent ba4a6bd commit 763e9d4
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion common/types/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 3 additions & 3 deletions common/types/chunk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down
10 changes: 5 additions & 5 deletions rollup/internal/controller/watcher/batch_proposer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down Expand Up @@ -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{
Expand Down Expand Up @@ -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)
}

0 comments on commit 763e9d4

Please sign in to comment.