diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index 82a79eeb61..3e139ff7d6 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -754,10 +754,11 @@ var ( Usage: "Gas price below which gpo will ignore transactions", Value: ethconfig.Defaults.GPO.IgnorePrice.Int64(), } - // fetcher flag to set arrival timeout - TxArrivalWaitFlag = cli.IntFlag{ + // flag to set the transaction fetcher's txArrivalWait value, which is the maximum waiting + // period the fetcher will wait to receive an announced tx before explicitly requesting it + TxArrivalWaitFlag = cli.DurationFlag{ Name: "txarrivalwait", - Usage: "Maximum number of milliseconds to wait for a transaction before requesting it (defaults to 500ms)", + Usage: "Maximum duration to wait for a transaction before requesting it (defaults to 500ms)", Value: node.DefaultConfig.P2P.TxArrivalWait, } diff --git a/docs/cli/server.md b/docs/cli/server.md index 69c21232a8..9775db4d6e 100644 --- a/docs/cli/server.md +++ b/docs/cli/server.md @@ -146,7 +146,7 @@ The ```bor server``` command runs the Bor client. - ```v5disc```: Enables the experimental RLPx V5 (Topic Discovery) mechanism (default: false) -- ```txarrivalwait```: Maximum number of milliseconds to wait before requesting an announced transaction (default: 500) +- ```txarrivalwait```: Maximum duration to wait before requesting an announced transaction (default: 500) ### Sealer Options diff --git a/eth/backend.go b/eth/backend.go index c98b31966d..ad00cfacd2 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -266,7 +266,7 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) { EthAPI: ethAPI, PeerRequiredBlocks: config.PeerRequiredBlocks, checker: checker, - txArrivalWait: time.Duration(eth.p2pServer.TxArrivalWait) * time.Millisecond, + txArrivalWait: eth.p2pServer.TxArrivalWait, }); err != nil { return nil, err } diff --git a/eth/handler.go b/eth/handler.go index 24f41e017a..b58fab1773 100644 --- a/eth/handler.go +++ b/eth/handler.go @@ -93,7 +93,7 @@ type handlerConfig struct { PeerRequiredBlocks map[uint64]common.Hash // Hard coded map of required block hashes for sync challenges checker ethereum.ChainValidator - txArrivalWait time.Duration // Max time in milliseconds to wait for an announced tx before requesting it + txArrivalWait time.Duration // Maximum duration to wait for an announced tx before requesting it } type handler struct { diff --git a/internal/cli/server/config.go b/internal/cli/server/config.go index 3a7102a686..15a8eac8ce 100644 --- a/internal/cli/server/config.go +++ b/internal/cli/server/config.go @@ -132,8 +132,9 @@ type P2PConfig struct { // Discovery has the p2p discovery related settings Discovery *P2PDiscovery `hcl:"discovery,block" toml:"discovery,block"` - // TxArrivalWait sets the maximum wait for announced transactions - TxArrivalWait uint64 `hcl:"txarrivalwait,optional" toml:"txarrivalwait,optional"` + // TxArrivalWait sets the maximum duration the transaction fetcher will wait for + // an announced transaction to arrive before explicitly requesting it + TxArrivalWait time.Duration `hcl:"txarrivalwait,optional" toml:"txarrivalwait,optional"` } type P2PDiscovery struct { @@ -458,7 +459,7 @@ func DefaultConfig() *Config { Port: 30303, NoDiscover: false, NAT: "any", - TxArrivalWait: 500, + TxArrivalWait: 500 * time.Millisecond, Discovery: &P2PDiscovery{ V5Enabled: false, Bootnodes: []string{}, @@ -1051,7 +1052,7 @@ func (c *Config) buildNode() (*node.Config, error) { MaxPendingPeers: int(c.P2P.MaxPendPeers), ListenAddr: c.P2P.Bind + ":" + strconv.Itoa(int(c.P2P.Port)), DiscoveryV5: c.P2P.Discovery.V5Enabled, - TxArrivalWait: int(c.P2P.TxArrivalWait), + TxArrivalWait: c.P2P.TxArrivalWait, }, HTTPModules: c.JsonRPC.Http.API, HTTPCors: c.JsonRPC.Http.Cors, diff --git a/internal/cli/server/flags.go b/internal/cli/server/flags.go index 51ccbe0142..613c8a105b 100644 --- a/internal/cli/server/flags.go +++ b/internal/cli/server/flags.go @@ -548,9 +548,9 @@ func (c *Command) Flags() *flagset.Flagset { Default: c.cliConfig.P2P.Discovery.V5Enabled, Group: "P2P", }) - f.Uint64Flag(&flagset.Uint64Flag{ + f.DurationFlag(&flagset.DurationFlag{ Name: "txarrivalwait", - Usage: "Maximum number of milliseconds to wait for a transaction before requesting it (defaults to 500ms)", + Usage: "Maximum duration to wait for a transaction before explicitly requesting it (defaults to 500ms)", Value: &c.cliConfig.P2P.TxArrivalWait, Default: c.cliConfig.P2P.TxArrivalWait, Group: "P2P", diff --git a/node/defaults.go b/node/defaults.go index e7c148b09c..a32fa868ef 100644 --- a/node/defaults.go +++ b/node/defaults.go @@ -21,6 +21,7 @@ import ( "os/user" "path/filepath" "runtime" + "time" "github.com/ethereum/go-ethereum/p2p" "github.com/ethereum/go-ethereum/p2p/nat" @@ -63,7 +64,7 @@ var DefaultConfig = Config{ ListenAddr: ":30303", MaxPeers: 50, NAT: nat.Any(), - TxArrivalWait: 500, + TxArrivalWait: 500 * time.Millisecond, }, } diff --git a/p2p/server.go b/p2p/server.go index 0f9285b01a..c51ba3f5b7 100644 --- a/p2p/server.go +++ b/p2p/server.go @@ -159,7 +159,7 @@ type Config struct { // TxArrivalWait is the duration (ms) that the node will wait after seeing // an announced transaction before explicitly requesting it - TxArrivalWait int + TxArrivalWait time.Duration } // Server manages all peer connections.