Skip to content

Commit

Permalink
fix: fix some PR review comments;
Browse files Browse the repository at this point in the history
  • Loading branch information
galaio committed Feb 27, 2024
1 parent 018e298 commit 6998db0
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 10 deletions.
8 changes: 6 additions & 2 deletions core/rawdb/accessors_chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -946,8 +946,12 @@ func writeAncientBlob(op ethdb.AncientWriteOp, num uint64, blobs types.BlobTxSid
// Attention: The caller must set blobs after cancun
func writeAncientBlockWithBlob(op ethdb.AncientWriteOp, block *types.Block, header *types.Header, receipts []*types.ReceiptForStorage, td *big.Int, blobs types.BlobTxSidecars) error {
num := block.NumberU64()
writeAncientBlock(op, block, header, receipts, td)
writeAncientBlob(op, num, blobs)
if err := writeAncientBlock(op, block, header, receipts, td); err != nil {
return err
}
if err := writeAncientBlob(op, num, blobs); err != nil {
return err
}
return nil
}

Expand Down
3 changes: 2 additions & 1 deletion core/rawdb/accessors_chain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,15 @@ import (
rand2 "crypto/rand"
"encoding/hex"
"fmt"
"github.com/stretchr/testify/require"
"io"
"math/big"
"math/rand"
"os"
"reflect"
"testing"

"github.com/stretchr/testify/require"

"github.com/ethereum/go-ethereum/crypto/kzg4844"
"github.com/holiman/uint256"

Expand Down
2 changes: 1 addition & 1 deletion core/rawdb/freezer.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ type Freezer struct {
closeOnce sync.Once
offset uint64 // Starting BlockNumber in current freezer

additionTableKinds []string
additionTableKinds []string // additionTableKinds are post-filled tables that start as empty
}

// NewChainFreezer is a small utility method around NewFreezer that sets the
Expand Down
5 changes: 3 additions & 2 deletions core/rawdb/freezer_batch.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ package rawdb

import (
"fmt"
"golang.org/x/exp/slices"
"sync/atomic"

"golang.org/x/exp/slices"

"github.com/ethereum/go-ethereum/common/math"
"github.com/ethereum/go-ethereum/rlp"
"github.com/golang/snappy"
Expand All @@ -33,7 +34,7 @@ const freezerBatchBufferLimit = 2 * 1024 * 1024
// freezerBatch is a write operation of multiple items on a freezer.
type freezerBatch struct {
tables map[string]*freezerTableBatch
additionTableKinds []string
additionTableKinds []string // additionTableKinds are post-filled tables that start as empty
}

func newFreezerBatch(f *Freezer) *freezerBatch {
Expand Down
2 changes: 1 addition & 1 deletion core/rawdb/freezer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ func TestFreezer_AdditionTables(t *testing.T) {

f, err = NewFreezer(dir, "", false, 0, 2049, map[string]bool{"o1": true, "o2": true, "a1": true}, "a1")
require.NoError(t, err)
frozen, err := f.Ancients()
frozen, _ := f.Ancients()
f.ResetTable("a1", frozen, frozen, true)
_, err = f.ModifyAncients(func(op ethdb.AncientWriteOp) error {
if err := op.AppendRaw("o1", 2, item); err != nil {
Expand Down
3 changes: 2 additions & 1 deletion core/types/tx_blob_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ package types

import (
"crypto/ecdsa"
"github.com/stretchr/testify/require"
"testing"

"github.com/stretchr/testify/require"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/crypto/kzg4844"
Expand Down
2 changes: 2 additions & 0 deletions ethdb/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,9 @@ type AncientWriter interface {
ResetTable(kind string, tail uint64, head uint64, onlyEmpty bool) error
}

// AncientFreezer defines the help functions for freezing ancient data
type AncientFreezer interface {
// SetupFreezerEnv provides params.ChainConfig for checking hark forks, like isCancun.
SetupFreezerEnv(chainCfg *params.ChainConfig) error
}

Expand Down
4 changes: 2 additions & 2 deletions params/protocol_params.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,8 @@ const (
BlobTxTargetBlobGasPerBlock = 3 * BlobTxBlobGasPerBlob // Target consumable blob gas for data blobs per block (for 1559-like pricing)
MaxBlobGasPerBlock = 6 * BlobTxBlobGasPerBlob // Maximum consumable blob gas for data blobs per block

BlobLocalAvailableThreshold = 518400 // it keeps blob data available for 18 days in local.
BlobLocalAvailableExtraThreshold = 400 // it adds more time for expired blobs for some request cases, like expiry blob when remote peer is syncing.
BlobLocalAvailableThreshold = 18 * (24 * 3600) / 3 // it keeps blob data available for 18 days in local.
BlobLocalAvailableExtraThreshold = 2 * 200 // it adds more time for expired blobs for some request cases, like expiry blob when remote peer is syncing, default 2 epochs.
)

// Gas discount table for BLS12-381 G1 and G2 multi exponentiation operations
Expand Down

0 comments on commit 6998db0

Please sign in to comment.