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

Txpool 4844 upgrades Part 2 #8213

Merged
merged 32 commits into from
Sep 20, 2023
Merged
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
9be9769
Add blob pricebump flag
somnathb1 Aug 11, 2023
14d105c
Merge branch 'devel' into txpool-4844-upgrades
somnathb1 Sep 6, 2023
e020355
Pass finalized block to txpool
somnathb1 Sep 6, 2023
32453f4
fmt
somnathb1 Sep 6, 2023
501bba3
Merge remote-tracking branch 'origin/devel' into txpool-4844-upgrades
somnathb1 Sep 10, 2023
21968b7
Update deps
somnathb1 Sep 10, 2023
b4abf8e
Update lib
somnathb1 Sep 10, 2023
394f803
Add pending blob fee to sc
somnathb1 Sep 12, 2023
5d54999
Merge remote-tracking branch 'origin/devel' into txpool-4844-upgrades
somnathb1 Sep 12, 2023
a5912a5
Merge fix
somnathb1 Sep 12, 2023
426fd85
Fix pending blob fee
somnathb1 Sep 15, 2023
7e976b8
Update lib
somnathb1 Sep 15, 2023
63c643e
Merge remote-tracking branch 'origin/devel' into txpool-4844-upgrades
somnathb1 Sep 15, 2023
b5219ec
Fix blob price calc
somnathb1 Sep 15, 2023
782b48b
Revert local
somnathb1 Sep 15, 2023
a9a518e
update lib
somnathb1 Sep 15, 2023
3b7a58c
go mod tidy
somnathb1 Sep 15, 2023
6b834c9
Add blob slots flag
somnathb1 Sep 15, 2023
f9b1295
Fmt
somnathb1 Sep 16, 2023
0cc86e7
Fix init excess blob gas
somnathb1 Sep 16, 2023
74bf8cc
Update lib version
somnathb1 Sep 16, 2023
c75e6ec
Merge remote-tracking branch 'origin/devel' into txpool-4844-upgrades
somnathb1 Sep 16, 2023
32dfc01
Merge remote-tracking branch 'origin/devel' into txpool-4844-upgrades
somnathb1 Sep 16, 2023
36fba72
Update lib
somnathb1 Sep 17, 2023
3e53c4b
Update lib
somnathb1 Sep 17, 2023
69bc185
update lib
somnathb1 Sep 18, 2023
0f6a49c
Update lib
somnathb1 Sep 18, 2023
b19e700
Merge branch 'devel' into txpool-4844-upgrades
somnathb1 Sep 18, 2023
78069b7
Bump lib ver
somnathb1 Sep 18, 2023
1384b4e
Add param min fee, update lib
somnathb1 Sep 19, 2023
5ca568b
Pending base fee in startup
somnathb1 Sep 19, 2023
a8adb06
Update lib
somnathb1 Sep 20, 2023
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
3 changes: 3 additions & 0 deletions cmd/txpool/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ var (

priceLimit uint64
accountSlots uint64
blobSlots uint64
priceBump uint64
blobPriceBump uint64

Expand All @@ -75,6 +76,7 @@ func init() {
rootCmd.PersistentFlags().IntVar(&queuedPoolLimit, "txpool.globalqueue", txpoolcfg.DefaultConfig.QueuedSubPoolLimit, "Maximum number of non-executable transaction slots for all accounts")
rootCmd.PersistentFlags().Uint64Var(&priceLimit, "txpool.pricelimit", txpoolcfg.DefaultConfig.MinFeeCap, "Minimum gas price (fee cap) limit to enforce for acceptance into the pool")
rootCmd.PersistentFlags().Uint64Var(&accountSlots, "txpool.accountslots", txpoolcfg.DefaultConfig.AccountSlots, "Minimum number of executable transaction slots guaranteed per account")
rootCmd.PersistentFlags().Uint64Var(&blobSlots, "txpool.blobslots", txpoolcfg.DefaultConfig.BlobSlots, "Max allowed total number of blobs (within type-3 txs) per account")
rootCmd.PersistentFlags().Uint64Var(&priceBump, "txpool.pricebump", txpoolcfg.DefaultConfig.PriceBump, "Price bump percentage to replace an already existing transaction")
rootCmd.PersistentFlags().Uint64Var(&blobPriceBump, "txpool.blobpricebump", txpoolcfg.DefaultConfig.BlobPriceBump, "Price bump percentage to replace an existing blob (type-3) transaction")
rootCmd.PersistentFlags().DurationVar(&commitEvery, utils.TxPoolCommitEveryFlag.Name, utils.TxPoolCommitEveryFlag.Value, utils.TxPoolCommitEveryFlag.Usage)
Expand Down Expand Up @@ -141,6 +143,7 @@ func doTxpool(ctx context.Context, logger log.Logger) error {
cfg.QueuedSubPoolLimit = queuedPoolLimit
cfg.MinFeeCap = priceLimit
cfg.AccountSlots = accountSlots
cfg.BlobSlots = blobSlots
cfg.PriceBump = priceBump
cfg.BlobPriceBump = blobPriceBump

Expand Down
11 changes: 11 additions & 0 deletions cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,11 @@ var (
Usage: "Minimum number of executable transaction slots guaranteed per account",
Value: ethconfig.Defaults.DeprecatedTxPool.AccountSlots,
}
TxPoolBlobSlotsFlag = cli.Uint64Flag{
Name: "txpool.blobslots",
Usage: "Max allowed total number of blobs (within type-3 txs) per account",
Value: txpoolcfg.DefaultConfig.BlobSlots,
}
TxPoolGlobalSlotsFlag = cli.Uint64Flag{
Name: "txpool.globalslots",
Usage: "Maximum number of executable transaction slots for all accounts",
Expand Down Expand Up @@ -1243,9 +1248,15 @@ func setTxPool(ctx *cli.Context, fullCfg *ethconfig.Config) {
if ctx.IsSet(TxPoolPriceBumpFlag.Name) {
cfg.PriceBump = ctx.Uint64(TxPoolPriceBumpFlag.Name)
}
if ctx.IsSet(TxPoolBlobPriceBumpFlag.Name) {
fullCfg.TxPool.BlobPriceBump = ctx.Uint64(TxPoolBlobPriceBumpFlag.Name)
}
if ctx.IsSet(TxPoolAccountSlotsFlag.Name) {
cfg.AccountSlots = ctx.Uint64(TxPoolAccountSlotsFlag.Name)
}
if ctx.IsSet(TxPoolBlobSlotsFlag.Name) {
fullCfg.TxPool.BlobSlots = ctx.Uint64(TxPoolBlobSlotsFlag.Name)
}
if ctx.IsSet(TxPoolGlobalSlotsFlag.Name) {
cfg.GlobalSlots = ctx.Uint64(TxPoolGlobalSlotsFlag.Name)
}
Expand Down
11 changes: 9 additions & 2 deletions eth/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ import (
"github.com/ledgerwatch/erigon/consensus/clique"
"github.com/ledgerwatch/erigon/consensus/ethash"
"github.com/ledgerwatch/erigon/consensus/merge"
"github.com/ledgerwatch/erigon/consensus/misc"
"github.com/ledgerwatch/erigon/core"
"github.com/ledgerwatch/erigon/core/rawdb"
"github.com/ledgerwatch/erigon/core/state/temporal"
Expand Down Expand Up @@ -641,9 +642,15 @@ func New(stack *node.Node, config *ethconfig.Config, logger log.Logger) (*Ethere
if currentBlock.BaseFee() != nil {
baseFee = currentBlock.BaseFee().Uint64()
}
blobFee := uint64(1)
somnathb1 marked this conversation as resolved.
Show resolved Hide resolved
if currentBlock.Header().ExcessBlobGas != nil {
b, err := misc.GetBlobGasPrice(misc.CalcExcessBlobGas(currentBlock.Header()))
if err == nil && b.Cmp(uint256.NewInt(0)) > 0 {
blobFee = b.Uint64()
}
}
backend.notifications.Accumulator.StartChange(currentBlock.NumberU64(), currentBlock.Hash(), nil, false)
backend.notifications.Accumulator.SendAndReset(ctx, backend.notifications.StateChangesConsumer, baseFee, currentBlock.GasLimit(), 0)

backend.notifications.Accumulator.SendAndReset(ctx, backend.notifications.StateChangesConsumer, baseFee, blobFee, currentBlock.GasLimit(), 0)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we are sending pending rather than current blobFee, it makes sense to do the same for baseFee (pending instead of current).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, i will make that change as well. Meanwhile, in this case we are sending values (to txPool) with respect to the CurrentBlock, which is where the sync is at. Should we consider sending values for the canonical head instead?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This piece of code looks like a kludge. I'd leave currentBlock as is since it seems to be doing the job.

}()

if !config.DeprecatedTxPool.Disable {
Expand Down
1 change: 1 addition & 0 deletions eth/ethconfig/tx_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ var DefaultTxPool2Config = func(fullCfg *Config) txpoolcfg.Config {
cfg.BlobPriceBump = fullCfg.TxPool.BlobPriceBump
cfg.MinFeeCap = pool1Cfg.PriceLimit
cfg.AccountSlots = pool1Cfg.AccountSlots
cfg.BlobSlots = fullCfg.TxPool.BlobSlots
cfg.LogEvery = 1 * time.Minute
cfg.CommitEvery = 5 * time.Minute
cfg.TracedSenders = pool1Cfg.TracedSenders
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.19

require (
github.com/erigontech/mdbx-go v0.33.1
github.com/ledgerwatch/erigon-lib v0.0.0-20230918032038-e77827a43066
github.com/ledgerwatch/erigon-lib v0.0.0-20230918134006-ac899d3ba376
github.com/ledgerwatch/erigon-snapshot v1.2.1-0.20230911054727-4e865b051314
github.com/ledgerwatch/log/v3 v3.9.0
github.com/ledgerwatch/secp256k1 v1.0.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -499,8 +499,8 @@ github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/kylelemons/godebug v0.0.0-20170224010052-a616ab194758 h1:0D5M2HQSGD3PYPwICLl+/9oulQauOuETfgFvhBDffs0=
github.com/leanovate/gopter v0.2.9 h1:fQjYxZaynp97ozCzfOyOuAGOU4aU/z37zf/tOujFk7c=
github.com/leanovate/gopter v0.2.9/go.mod h1:U2L/78B+KVFIx2VmW6onHJQzXtFb+p5y3y2Sh+Jxxv8=
github.com/ledgerwatch/erigon-lib v0.0.0-20230918032038-e77827a43066 h1:hyax1voOfuHvfUYrL+IhScvUATvpa3ni9h1ijAJxOnA=
github.com/ledgerwatch/erigon-lib v0.0.0-20230918032038-e77827a43066/go.mod h1:WTy84hKK3Z939hGTqew2AMjVSnbMrPBxUDILCzCOw9k=
github.com/ledgerwatch/erigon-lib v0.0.0-20230918134006-ac899d3ba376 h1:tTaXlkKUayozzNIA/21hW634zmd1IsczE6nJa/QLocA=
github.com/ledgerwatch/erigon-lib v0.0.0-20230918134006-ac899d3ba376/go.mod h1:l1i6+H9MgizD+ObQ5cXsfA9S3egYTOCnnYGjbrJMqR4=
github.com/ledgerwatch/erigon-snapshot v1.2.1-0.20230911054727-4e865b051314 h1:TeQoOW2o0rL5jF4ava+SlB8l0mhzM8ISnq81okJ790c=
github.com/ledgerwatch/erigon-snapshot v1.2.1-0.20230911054727-4e865b051314/go.mod h1:3AuPxZc85jkehh/HA9h8gabv5MSi3kb/ddtzBsTVJFo=
github.com/ledgerwatch/log/v3 v3.9.0 h1:iDwrXe0PVwBC68Dd94YSsHbMgQ3ufsgjzXtFNFVZFRk=
Expand Down
1 change: 1 addition & 0 deletions turbo/cli/default_flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ var DefaultFlags = []cli.Flag{
&utils.TxPoolPriceBumpFlag,
&utils.TxPoolBlobPriceBumpFlag,
&utils.TxPoolAccountSlotsFlag,
&utils.TxPoolBlobSlotsFlag,
&utils.TxPoolGlobalSlotsFlag,
&utils.TxPoolGlobalBaseFeeSlotsFlag,
&utils.TxPoolAccountQueueFlag,
Expand Down
4 changes: 2 additions & 2 deletions turbo/shards/state_change_accumulator.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ func (a *Accumulator) Reset(plainStateID uint64) {
a.storageChangeIndex = nil
a.plainStateID = plainStateID
}
func (a *Accumulator) SendAndReset(ctx context.Context, c StateChangeConsumer, pendingBaseFee uint64, blockGasLimit uint64, finalizedBlock uint64) {
func (a *Accumulator) SendAndReset(ctx context.Context, c StateChangeConsumer, pendingBaseFee uint64, pendingBlobFee uint64, blockGasLimit uint64, finalizedBlock uint64) {
if a == nil || c == nil || len(a.changes) == 0 {
return
}
sc := &remote.StateChangeBatch{StateVersionId: a.plainStateID, ChangeBatch: a.changes, PendingBlockBaseFee: pendingBaseFee, BlockGasLimit: blockGasLimit, FinalizedBlock: finalizedBlock}
sc := &remote.StateChangeBatch{StateVersionId: a.plainStateID, ChangeBatch: a.changes, PendingBlockBaseFee: pendingBaseFee, BlockGasLimit: blockGasLimit, FinalizedBlock: finalizedBlock, PendingBlobFeePerGas: pendingBlobFee}
c.SendStateChanges(ctx, sc)
a.Reset(0) // reset here for GC, but there will be another Reset with correct viewID
}
Expand Down
13 changes: 12 additions & 1 deletion turbo/stages/stageloop.go
Original file line number Diff line number Diff line change
Expand Up @@ -308,8 +308,19 @@ func (h *Hook) AfterRun(tx kv.Tx, finishProgressBefore uint64) error {
if currentHeder.Number.Uint64() == 0 {
notifications.Accumulator.StartChange(0, currentHeder.Hash(), nil, false)
}
var pendingBlobFee uint64 = 1
excessBlobGas := misc.CalcExcessBlobGas(currentHeder)
if currentHeder.ExcessBlobGas != nil {
f, err := misc.GetBlobGasPrice(excessBlobGas)
yperbasis marked this conversation as resolved.
Show resolved Hide resolved
if err != nil {
return err
}
if f != nil && f.Cmp(uint256.NewInt(1)) >= 0 {
pendingBlobFee = f.Uint64()
}
}

notifications.Accumulator.SendAndReset(h.ctx, notifications.StateChangesConsumer, pendingBaseFee.Uint64(), currentHeder.GasLimit, finalizedBlock)
notifications.Accumulator.SendAndReset(h.ctx, notifications.StateChangesConsumer, pendingBaseFee.Uint64(), pendingBlobFee, currentHeder.GasLimit, finalizedBlock)
}
// -- send notifications END
return nil
Expand Down
Loading