Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wire OverridePragueTime into txpool #11234

Merged
merged 6 commits into from
Jul 22, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Wire Prague time into txpool
  • Loading branch information
yperbasis committed Jul 19, 2024
commit 215f507494a8a3fce8bd6716f2cdc39bfa09abc0
1 change: 1 addition & 0 deletions cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -1885,6 +1885,7 @@ func SetEthConfig(ctx *cli.Context, nodeConfig *nodecfg.Config, cfg *ethconfig.C

if ctx.IsSet(OverridePragueFlag.Name) {
cfg.OverridePragueTime = flags.GlobalBig(ctx, OverridePragueFlag.Name)
cfg.TxPool.OverridePragueTime = cfg.OverridePragueTime
}

if clparams.EmbeddedSupported(cfg.NetworkID) {
Expand Down
10 changes: 9 additions & 1 deletion erigon-lib/txpool/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ type TxPool struct {
isPostAgra atomic.Bool
cancunTime *uint64
isPostCancun atomic.Bool
pragueTime *uint64
maxBlobsPerBlock uint64
feeCalculator FeeCalculator
logger log.Logger
Expand All @@ -238,7 +239,7 @@ type FeeCalculator interface {
}

func New(newTxs chan types.Announcements, coreDB kv.RoDB, cfg txpoolcfg.Config, cache kvcache.Cache,
chainID uint256.Int, shanghaiTime, agraBlock, cancunTime *big.Int, maxBlobsPerBlock uint64,
chainID uint256.Int, shanghaiTime, agraBlock, cancunTime, pragueTime *big.Int, maxBlobsPerBlock uint64,
feeCalculator FeeCalculator, logger log.Logger,
) (*TxPool, error) {
localsHistory, err := simplelru.NewLRU[string, struct{}](10_000, nil)
Expand Down Expand Up @@ -310,6 +311,13 @@ func New(newTxs chan types.Announcements, coreDB kv.RoDB, cfg txpoolcfg.Config,
cancunTimeU64 := cancunTime.Uint64()
res.cancunTime = &cancunTimeU64
}
if pragueTime != nil {
if !pragueTime.IsUint64() {
return nil, errors.New("pragueTime overflow")
}
pragueTimeU64 := pragueTime.Uint64()
res.pragueTime = &pragueTimeU64
}

return res, nil
}
Expand Down
4 changes: 2 additions & 2 deletions erigon-lib/txpool/pool_fuzz_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ func FuzzOnNewBlocks(f *testing.F) {

cfg := txpoolcfg.DefaultConfig
sendersCache := kvcache.New(kvcache.DefaultCoherentConfig)
pool, err := New(ch, coreDB, cfg, sendersCache, *u256.N1, nil, nil, nil, fixedgas.DefaultMaxBlobsPerBlock, nil, log.New())
pool, err := New(ch, coreDB, cfg, sendersCache, *u256.N1, nil, nil, nil, nil, fixedgas.DefaultMaxBlobsPerBlock, nil, log.New())
assert.NoError(err)

err = pool.Start(ctx, db)
Expand Down Expand Up @@ -561,7 +561,7 @@ func FuzzOnNewBlocks(f *testing.F) {
check(p2pReceived, types.TxSlots{}, "after_flush")
checkNotify(p2pReceived, types.TxSlots{}, "after_flush")

p2, err := New(ch, coreDB, txpoolcfg.DefaultConfig, sendersCache, *u256.N1, nil, nil, nil, fixedgas.DefaultMaxBlobsPerBlock, nil, log.New())
p2, err := New(ch, coreDB, txpoolcfg.DefaultConfig, sendersCache, *u256.N1, nil, nil, nil, nil, fixedgas.DefaultMaxBlobsPerBlock, nil, log.New())
assert.NoError(err)

p2.senders = pool.senders // senders are not persisted
Expand Down
18 changes: 9 additions & 9 deletions erigon-lib/txpool/pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func TestNonceFromAddress(t *testing.T) {

cfg := txpoolcfg.DefaultConfig
sendersCache := kvcache.New(kvcache.DefaultCoherentConfig)
pool, err := New(ch, coreDB, cfg, sendersCache, *u256.N1, nil, nil, nil, fixedgas.DefaultMaxBlobsPerBlock, nil, log.New())
pool, err := New(ch, coreDB, cfg, sendersCache, *u256.N1, nil, nil, nil, nil, fixedgas.DefaultMaxBlobsPerBlock, nil, log.New())
assert.NoError(err)
require.True(pool != nil)
ctx := context.Background()
Expand Down Expand Up @@ -177,7 +177,7 @@ func TestReplaceWithHigherFee(t *testing.T) {

cfg := txpoolcfg.DefaultConfig
sendersCache := kvcache.New(kvcache.DefaultCoherentConfig)
pool, err := New(ch, coreDB, cfg, sendersCache, *u256.N1, nil, nil, nil, fixedgas.DefaultMaxBlobsPerBlock, nil, log.New())
pool, err := New(ch, coreDB, cfg, sendersCache, *u256.N1, nil, nil, nil, nil, fixedgas.DefaultMaxBlobsPerBlock, nil, log.New())
assert.NoError(err)
require.NotEqual(nil, pool)
ctx := context.Background()
Expand Down Expand Up @@ -296,7 +296,7 @@ func TestReverseNonces(t *testing.T) {

cfg := txpoolcfg.DefaultConfig
sendersCache := kvcache.New(kvcache.DefaultCoherentConfig)
pool, err := New(ch, coreDB, cfg, sendersCache, *u256.N1, nil, nil, nil, fixedgas.DefaultMaxBlobsPerBlock, nil, log.New())
pool, err := New(ch, coreDB, cfg, sendersCache, *u256.N1, nil, nil, nil, nil, fixedgas.DefaultMaxBlobsPerBlock, nil, log.New())
assert.NoError(err)
require.True(pool != nil)
ctx := context.Background()
Expand Down Expand Up @@ -422,7 +422,7 @@ func TestTxPoke(t *testing.T) {

cfg := txpoolcfg.DefaultConfig
sendersCache := kvcache.New(kvcache.DefaultCoherentConfig)
pool, err := New(ch, coreDB, cfg, sendersCache, *u256.N1, nil, nil, nil, fixedgas.DefaultMaxBlobsPerBlock, nil, log.New())
pool, err := New(ch, coreDB, cfg, sendersCache, *u256.N1, nil, nil, nil, nil, fixedgas.DefaultMaxBlobsPerBlock, nil, log.New())
assert.NoError(err)
require.True(pool != nil)
ctx := context.Background()
Expand Down Expand Up @@ -711,7 +711,7 @@ func TestShanghaiValidateTx(t *testing.T) {
}

cache := &kvcache.DummyCache{}
pool, err := New(ch, coreDB, cfg, cache, *u256.N1, shanghaiTime, nil /* agraBlock */, nil /* cancunTime */, fixedgas.DefaultMaxBlobsPerBlock, nil, logger)
pool, err := New(ch, coreDB, cfg, cache, *u256.N1, shanghaiTime, nil /* agraBlock */, nil /* cancunTime */, nil /* pragueTime */, fixedgas.DefaultMaxBlobsPerBlock, nil, logger)
asrt.NoError(err)
ctx := context.Background()
tx, err := coreDB.BeginRw(ctx)
Expand Down Expand Up @@ -760,7 +760,7 @@ func TestBlobTxReplacement(t *testing.T) {

cfg := txpoolcfg.DefaultConfig
sendersCache := kvcache.New(kvcache.DefaultCoherentConfig)
pool, err := New(ch, coreDB, cfg, sendersCache, *u256.N1, common.Big0, nil, common.Big0, fixedgas.DefaultMaxBlobsPerBlock, nil, log.New())
pool, err := New(ch, coreDB, cfg, sendersCache, *u256.N1, common.Big0, nil, common.Big0, nil, fixedgas.DefaultMaxBlobsPerBlock, nil, log.New())
assert.NoError(err)
require.True(pool != nil)
ctx := context.Background()
Expand Down Expand Up @@ -979,7 +979,7 @@ func TestDropRemoteAtNoGossip(t *testing.T) {
logger := log.New()
sendersCache := kvcache.New(kvcache.DefaultCoherentConfig)

txPool, err := New(ch, coreDB, cfg, sendersCache, *u256.N1, big.NewInt(0), big.NewInt(0), nil, fixedgas.DefaultMaxBlobsPerBlock, nil, logger)
txPool, err := New(ch, coreDB, cfg, sendersCache, *u256.N1, big.NewInt(0), big.NewInt(0), nil, nil, fixedgas.DefaultMaxBlobsPerBlock, nil, logger)
assert.NoError(err)
require.True(txPool != nil)

Expand Down Expand Up @@ -1087,7 +1087,7 @@ func TestBlobSlots(t *testing.T) {
cfg.TotalBlobPoolLimit = 20

sendersCache := kvcache.New(kvcache.DefaultCoherentConfig)
pool, err := New(ch, coreDB, cfg, sendersCache, *u256.N1, common.Big0, nil, common.Big0, fixedgas.DefaultMaxBlobsPerBlock, nil, log.New())
pool, err := New(ch, coreDB, cfg, sendersCache, *u256.N1, common.Big0, nil, common.Big0, nil, fixedgas.DefaultMaxBlobsPerBlock, nil, log.New())
assert.NoError(err)
require.True(pool != nil)
ctx := context.Background()
Expand Down Expand Up @@ -1163,7 +1163,7 @@ func TestGasLimitChanged(t *testing.T) {
db := memdb.NewTestPoolDB(t)
cfg := txpoolcfg.DefaultConfig
sendersCache := kvcache.New(kvcache.DefaultCoherentConfig)
pool, err := New(ch, coreDB, cfg, sendersCache, *u256.N1, nil, nil, nil, fixedgas.DefaultMaxBlobsPerBlock, nil, log.New())
pool, err := New(ch, coreDB, cfg, sendersCache, *u256.N1, nil, nil, nil, nil, fixedgas.DefaultMaxBlobsPerBlock, nil, log.New())
assert.NoError(err)
require.True(pool != nil)
ctx := context.Background()
Expand Down
2 changes: 2 additions & 0 deletions erigon-lib/txpool/txpoolcfg/txpoolcfg.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package txpoolcfg
import (
"fmt"
"math"
"math/big"
"time"

"github.com/c2h5oh/datasize"
Expand All @@ -44,6 +45,7 @@ type Config struct {
TotalBlobPoolLimit uint64 // Total number of blobs (not txs) allowed within the txpool
PriceBump uint64 // Price bump percentage to replace an already existing transaction
BlobPriceBump uint64 //Price bump percentage to replace an existing 4844 blob txn (type-3)
OverridePragueTime *big.Int

// regular batch tasks processing
SyncToNewPeersEvery time.Duration
Expand Down
7 changes: 6 additions & 1 deletion erigon-lib/txpool/txpooluitl/all_components.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,13 @@ func AllComponents(ctx context.Context, cfg txpoolcfg.Config, cache kvcache.Cach
agraBlock = chainConfig.Bor.GetAgraBlock()
}
cancunTime := chainConfig.CancunTime
pragueTime := chainConfig.PragueTime
if cfg.OverridePragueTime != nil {
pragueTime = cfg.OverridePragueTime
}

txPool, err := txpool.New(newTxs, chainDB, cfg, cache, *chainID, shanghaiTime, agraBlock, cancunTime, maxBlobsPerBlock, feeCalculator, logger)
txPool, err := txpool.New(newTxs, chainDB, cfg, cache, *chainID, shanghaiTime, agraBlock, cancunTime, pragueTime,
maxBlobsPerBlock, feeCalculator, logger)
if err != nil {
return nil, nil, nil, nil, nil, err
}
Expand Down
4 changes: 3 additions & 1 deletion turbo/stages/mock/mock_sentry.go
Original file line number Diff line number Diff line change
Expand Up @@ -333,8 +333,10 @@ func MockWithEverything(tb testing.TB, gspec *types.Genesis, key *ecdsa.PrivateK
chainID, _ := uint256.FromBig(mock.ChainConfig.ChainID)
shanghaiTime := mock.ChainConfig.ShanghaiTime
cancunTime := mock.ChainConfig.CancunTime
pragueTime := mock.ChainConfig.PragueTime
maxBlobsPerBlock := mock.ChainConfig.GetMaxBlobsPerBlock()
mock.TxPool, err = txpool.New(newTxs, mock.DB, poolCfg, kvcache.NewDummy(), *chainID, shanghaiTime, nil /* agraBlock */, cancunTime, maxBlobsPerBlock, nil, logger)
mock.TxPool, err = txpool.New(newTxs, mock.DB, poolCfg, kvcache.NewDummy(), *chainID, shanghaiTime,
nil /* agraBlock */, cancunTime, pragueTime, maxBlobsPerBlock, nil, logger)
if err != nil {
tb.Fatal(err)
}
Expand Down
Loading