Txpool tracing by sender addresses (#3113)

* Txpool tracing by sender addresses

* Update to latest erigon-lib

Co-authored-by: Alexey Sharp <alexeysharp@Alexeys-iMac.local>
This commit is contained in:
ledgerwatch 2021-12-14 16:15:54 +00:00 committed by GitHub
parent 9fba783c98
commit bcdff3cb9b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 22 additions and 5 deletions

View File

@ -215,6 +215,11 @@ var (
Usage: "Maximum amount of time non-executable transaction are queued",
Value: ethconfig.Defaults.TxPool.Lifetime,
}
TxPoolTraceSendersFlag = cli.StringFlag{
Name: "txpool.trace.senders",
Usage: "Comma separared list of addresses, whoes transactions will traced in transaction pool with debug printing",
Value: "",
}
// Miner settings
MiningEnabledFlag = cli.BoolFlag{
Name: "mine",
@ -1035,6 +1040,15 @@ func setTxPool(ctx *cli.Context, cfg *core.TxPoolConfig) {
if ctx.GlobalIsSet(TxPoolLifetimeFlag.Name) {
cfg.Lifetime = ctx.GlobalDuration(TxPoolLifetimeFlag.Name)
}
if ctx.GlobalIsSet(TxPoolTraceSendersFlag.Name) {
// Parse the command separated flag
senderHexes := SplitAndTrim(ctx.GlobalString(TxPoolTraceSendersFlag.Name))
cfg.TracedSenders = make([]string, len(senderHexes))
for i, senderHex := range senderHexes {
sender := common.HexToAddress(senderHex)
cfg.TracedSenders[i] = string(sender[:])
}
}
}
func setEthash(ctx *cli.Context, datadir string, cfg *ethconfig.Config) {

View File

@ -77,6 +77,7 @@ type TxPoolConfig struct {
Lifetime time.Duration // Maximum amount of time non-executable transaction are queued
StartOnInit bool
TracedSenders []string // List of senders for which tx pool should print out debugging info
}
// DefaultTxPoolConfig contains the default configurations for the transaction

View File

@ -316,6 +316,7 @@ func New(stack *node.Node, config *ethconfig.Config, logger log.Logger) (*Ethere
cfg.AccountSlots = config.TxPool.AccountSlots
cfg.LogEvery = 1 * time.Minute
cfg.CommitEvery = 5 * time.Minute
cfg.TracedSenders = config.TxPool.TracedSenders
//cacheConfig := kvcache.DefaultCoherentCacheConfig
//cacheConfig.MetricsLabel = "txpool"

2
go.mod
View File

@ -37,7 +37,7 @@ require (
github.com/json-iterator/go v1.1.12
github.com/julienschmidt/httprouter v1.3.0
github.com/kevinburke/go-bindata v3.21.0+incompatible
github.com/ledgerwatch/erigon-lib v0.0.0-20211213041304-7fb44e022d47
github.com/ledgerwatch/erigon-lib v0.0.0-20211214133332-bb6dfef7c845
github.com/ledgerwatch/log/v3 v3.4.0
github.com/ledgerwatch/secp256k1 v1.0.0
github.com/logrusorgru/aurora/v3 v3.0.0

4
go.sum
View File

@ -617,8 +617,8 @@ github.com/kylelemons/godebug v0.0.0-20170224010052-a616ab194758 h1:0D5M2HQSGD3P
github.com/kylelemons/godebug v0.0.0-20170224010052-a616ab194758/go.mod h1:B69LEHPfb2qLo0BaaOLcbitczOKLWTsrBG9LczfCD4k=
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-20211213041304-7fb44e022d47 h1:Y4OJ9Z1RNNJ9GceKcFC8JVruvgrAFg+6NJr9O1qoRnU=
github.com/ledgerwatch/erigon-lib v0.0.0-20211213041304-7fb44e022d47/go.mod h1:lyGP3i0x4CeabdKZ4beycD5xZfHWZwJsAX+70OfGj4Y=
github.com/ledgerwatch/erigon-lib v0.0.0-20211214133332-bb6dfef7c845 h1:K7Zg42nG8GGnrkALkHECx+RQgpJ2neluY5PrcwpDZfQ=
github.com/ledgerwatch/erigon-lib v0.0.0-20211214133332-bb6dfef7c845/go.mod h1:lyGP3i0x4CeabdKZ4beycD5xZfHWZwJsAX+70OfGj4Y=
github.com/ledgerwatch/log/v3 v3.4.0 h1:SEIOcv5a2zkG3PmoT5jeTU9m/0nEUv0BJS5bzsjwKCI=
github.com/ledgerwatch/log/v3 v3.4.0/go.mod h1:VXcz6Ssn6XEeU92dCMc39/g1F0OYAjw1Mt+dGP5DjXY=
github.com/ledgerwatch/secp256k1 v1.0.0 h1:Usvz87YoTG0uePIV8woOof5cQnLXGYa162rFf3YnwaQ=

View File

@ -24,6 +24,7 @@ var DefaultFlags = []cli.Flag{
utils.TxPoolAccountQueueFlag,
utils.TxPoolGlobalQueueFlag,
utils.TxPoolLifetimeFlag,
utils.TxPoolTraceSendersFlag,
PruneFlag,
PruneHistoryFlag,
PruneReceiptFlag,