Skip to content

Commit

Permalink
feat: update
Browse files Browse the repository at this point in the history
  • Loading branch information
georgehao committed Aug 28, 2023
2 parents 3a8dce6 + e990e02 commit 0349993
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 5 deletions.
8 changes: 6 additions & 2 deletions common/types/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,10 @@ func (w *WrappedBlock) EstimateL1CommitCalldataSize() uint64 {
if txData.Type == types.L1MessageTxType {
continue
}
size += 64 // 60 bytes BlockContext + 4 bytes payload length
size += 4 // 4 bytes payload length
size += w.getTxPayloadLength(txData)
}
size += 60 // 60 bytes BlockContext
return size
}

Expand All @@ -116,10 +117,13 @@ func (w *WrappedBlock) EstimateL1CommitGas() uint64 {

txPayloadLength := w.getTxPayloadLength(txData)
total += CalldataNonZeroByteGas * txPayloadLength // an over-estimate: treat each byte as non-zero
total += CalldataNonZeroByteGas * 64 // 60 bytes BlockContext + 4 bytes payload length
total += CalldataNonZeroByteGas * 4 // 4 bytes payload length
total += GetKeccak256Gas(txPayloadLength) // l2 tx hash
}

// 60 bytes BlockContext calldata
total += CalldataNonZeroByteGas * 60

// sload
total += 2100 * numL1Messages // numL1Messages times cold sload in L1MessageQueue

Expand Down
4 changes: 2 additions & 2 deletions common/types/chunk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ func TestChunkEncode(t *testing.T) {
wrappedBlock := &WrappedBlock{}
assert.NoError(t, json.Unmarshal(templateBlockTrace, wrappedBlock))
assert.Equal(t, uint64(0), wrappedBlock.NumL1Messages(0))
assert.Equal(t, uint64(358), wrappedBlock.EstimateL1CommitCalldataSize())
assert.Equal(t, uint64(298), wrappedBlock.EstimateL1CommitCalldataSize())
assert.Equal(t, uint64(2), wrappedBlock.NumL2Transactions())
chunk = &Chunk{
Blocks: []*WrappedBlock{
wrappedBlock,
},
}
assert.Equal(t, uint64(0), chunk.NumL1Messages(0))
assert.Equal(t, uint64(6966), chunk.EstimateL1CommitGas())
assert.Equal(t, uint64(6006), chunk.EstimateL1CommitGas())
bytes, err = chunk.Encode(0)
hexString := hex.EncodeToString(bytes)
assert.NoError(t, err)
Expand Down
2 changes: 1 addition & 1 deletion common/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"strings"
)

var tag = "v4.2.2"
var tag = "v4.2.4"

var commit = func() string {
if info, ok := debug.ReadBuildInfo(); ok {
Expand Down
19 changes: 19 additions & 0 deletions database/migrate/migrations/00010_add_index_chunk_prover_task.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
-- +goose Up
-- +goose StatementBegin

create index if not exists idx_chunk_hash on chunk(hash, deleted_at) where deleted_at IS NULL;

create index if not exists idx_proving_status_end_block_number_index on chunk(index, end_block_number, proving_status, deleted_at) where deleted_at IS NULL;

create index if not exists idx_publickey_proving_status on prover_task(prover_public_key, proving_status, deleted_at, id) where deleted_at is null;

-- +goose StatementEnd

-- +goose Down
-- +goose StatementBegin

drop index if exists idx_chunk_hash;
drop index if exists idx_proving_status_end_block_number_index;
drop index if exists idx_publickey_proving_status;

-- +goose StatementEnd

0 comments on commit 0349993

Please sign in to comment.