diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index f3e2e0d84bd..d231eb39f9c 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -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) { diff --git a/erigon-lib/txpool/pool.go b/erigon-lib/txpool/pool.go index 441c356ee48..7ac81600223 100644 --- a/erigon-lib/txpool/pool.go +++ b/erigon-lib/txpool/pool.go @@ -983,31 +983,34 @@ func requiredBalance(txn *types.TxSlot) *uint256.Int { return total } -func (p *TxPool) isShanghai() bool { +func isTimeBasedForkActivated(isPostFlag *atomic.Bool, forkTime *uint64) bool { // once this flag has been set for the first time we no longer need to check the timestamp - set := p.isPostShanghai.Load() + set := isPostFlag.Load() if set { return true } - if p.shanghaiTime == nil { + if forkTime == nil { // the fork is not enabled return false } - shanghaiTime := *p.shanghaiTime - // a zero here means Shanghai is always active - if shanghaiTime == 0 { - p.isPostShanghai.Swap(true) + // a zero here means the fork is always active + if *forkTime == 0 { + isPostFlag.Swap(true) return true } now := time.Now().Unix() - activated := uint64(now) >= shanghaiTime + activated := uint64(now) >= *forkTime if activated { - p.isPostShanghai.Swap(true) + isPostFlag.Swap(true) } return activated } +func (p *TxPool) isShanghai() bool { + return isTimeBasedForkActivated(&p.isPostShanghai, p.shanghaiTime) +} + func (p *TxPool) isAgra() bool { // once this flag has been set for the first time we no longer need to check the block set := p.isPostAgra.Load() @@ -1045,53 +1048,11 @@ func (p *TxPool) isAgra() bool { } func (p *TxPool) isCancun() bool { - // once this flag has been set for the first time we no longer need to check the timestamp - set := p.isPostCancun.Load() - if set { - return true - } - if p.cancunTime == nil { - return false - } - cancunTime := *p.cancunTime - - // a zero here means Cancun is always active - if cancunTime == 0 { - p.isPostCancun.Swap(true) - return true - } - - now := time.Now().Unix() - activated := uint64(now) >= cancunTime - if activated { - p.isPostCancun.Swap(true) - } - return activated + return isTimeBasedForkActivated(&p.isPostCancun, p.cancunTime) } func (p *TxPool) isPrague() bool { - // once this flag has been set for the first time we no longer need to check the timestamp - set := p.isPostPrague.Load() - if set { - return true - } - if p.pragueTime == nil { - return false - } - pragueTime := *p.pragueTime - - // a zero here means Prague is always active - if pragueTime == 0 { - p.isPostPrague.Swap(true) - return true - } - - now := time.Now().Unix() - activated := uint64(now) >= pragueTime - if activated { - p.isPostPrague.Swap(true) - } - return activated + return isTimeBasedForkActivated(&p.isPostPrague, p.pragueTime) } // Check that the serialized txn should not exceed a certain max size diff --git a/erigon-lib/txpool/txpoolcfg/txpoolcfg.go b/erigon-lib/txpool/txpoolcfg/txpoolcfg.go index cfcbb0c6a65..5cb562fd390 100644 --- a/erigon-lib/txpool/txpoolcfg/txpoolcfg.go +++ b/erigon-lib/txpool/txpoolcfg/txpoolcfg.go @@ -19,6 +19,7 @@ package txpoolcfg import ( "fmt" "math" + "math/big" "time" "github.com/c2h5oh/datasize" @@ -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 diff --git a/erigon-lib/txpool/txpoolutil/all_components.go b/erigon-lib/txpool/txpoolutil/all_components.go index 2fefe01ecb8..b2884a6f98c 100644 --- a/erigon-lib/txpool/txpoolutil/all_components.go +++ b/erigon-lib/txpool/txpoolutil/all_components.go @@ -141,8 +141,12 @@ func AllComponents(ctx context.Context, cfg txpoolcfg.Config, cache kvcache.Cach } 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, pragueTime, 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 }