changed txArrivalWait config type from int to time.Duration, changed flags to duration type. Tested on live both w/o flag set (default) and w/ flag set

This commit is contained in:
Alex 2023-02-09 01:52:19 -08:00
parent b5ff754b70
commit 3c23de2486
8 changed files with 17 additions and 14 deletions

View file

@ -754,10 +754,11 @@ var (
Usage: "Gas price below which gpo will ignore transactions", Usage: "Gas price below which gpo will ignore transactions",
Value: ethconfig.Defaults.GPO.IgnorePrice.Int64(), Value: ethconfig.Defaults.GPO.IgnorePrice.Int64(),
} }
// fetcher flag to set arrival timeout // flag to set the transaction fetcher's txArrivalWait value, which is the maximum waiting
TxArrivalWaitFlag = cli.IntFlag{ // period the fetcher will wait to receive an announced tx before explicitly requesting it
TxArrivalWaitFlag = cli.DurationFlag{
Name: "txarrivalwait", 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, Value: node.DefaultConfig.P2P.TxArrivalWait,
} }

View file

@ -146,7 +146,7 @@ The ```bor server``` command runs the Bor client.
- ```v5disc```: Enables the experimental RLPx V5 (Topic Discovery) mechanism (default: false) - ```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 ### Sealer Options

View file

@ -266,7 +266,7 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) {
EthAPI: ethAPI, EthAPI: ethAPI,
PeerRequiredBlocks: config.PeerRequiredBlocks, PeerRequiredBlocks: config.PeerRequiredBlocks,
checker: checker, checker: checker,
txArrivalWait: time.Duration(eth.p2pServer.TxArrivalWait) * time.Millisecond, txArrivalWait: eth.p2pServer.TxArrivalWait,
}); err != nil { }); err != nil {
return nil, err return nil, err
} }

View file

@ -93,7 +93,7 @@ type handlerConfig struct {
PeerRequiredBlocks map[uint64]common.Hash // Hard coded map of required block hashes for sync challenges PeerRequiredBlocks map[uint64]common.Hash // Hard coded map of required block hashes for sync challenges
checker ethereum.ChainValidator 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 { type handler struct {

View file

@ -132,8 +132,9 @@ type P2PConfig struct {
// Discovery has the p2p discovery related settings // Discovery has the p2p discovery related settings
Discovery *P2PDiscovery `hcl:"discovery,block" toml:"discovery,block"` Discovery *P2PDiscovery `hcl:"discovery,block" toml:"discovery,block"`
// TxArrivalWait sets the maximum wait for announced transactions // TxArrivalWait sets the maximum duration the transaction fetcher will wait for
TxArrivalWait uint64 `hcl:"txarrivalwait,optional" toml:"txarrivalwait,optional"` // an announced transaction to arrive before explicitly requesting it
TxArrivalWait time.Duration `hcl:"txarrivalwait,optional" toml:"txarrivalwait,optional"`
} }
type P2PDiscovery struct { type P2PDiscovery struct {
@ -458,7 +459,7 @@ func DefaultConfig() *Config {
Port: 30303, Port: 30303,
NoDiscover: false, NoDiscover: false,
NAT: "any", NAT: "any",
TxArrivalWait: 500, TxArrivalWait: 500 * time.Millisecond,
Discovery: &P2PDiscovery{ Discovery: &P2PDiscovery{
V5Enabled: false, V5Enabled: false,
Bootnodes: []string{}, Bootnodes: []string{},
@ -1051,7 +1052,7 @@ func (c *Config) buildNode() (*node.Config, error) {
MaxPendingPeers: int(c.P2P.MaxPendPeers), MaxPendingPeers: int(c.P2P.MaxPendPeers),
ListenAddr: c.P2P.Bind + ":" + strconv.Itoa(int(c.P2P.Port)), ListenAddr: c.P2P.Bind + ":" + strconv.Itoa(int(c.P2P.Port)),
DiscoveryV5: c.P2P.Discovery.V5Enabled, DiscoveryV5: c.P2P.Discovery.V5Enabled,
TxArrivalWait: int(c.P2P.TxArrivalWait), TxArrivalWait: c.P2P.TxArrivalWait,
}, },
HTTPModules: c.JsonRPC.Http.API, HTTPModules: c.JsonRPC.Http.API,
HTTPCors: c.JsonRPC.Http.Cors, HTTPCors: c.JsonRPC.Http.Cors,

View file

@ -548,9 +548,9 @@ func (c *Command) Flags() *flagset.Flagset {
Default: c.cliConfig.P2P.Discovery.V5Enabled, Default: c.cliConfig.P2P.Discovery.V5Enabled,
Group: "P2P", Group: "P2P",
}) })
f.Uint64Flag(&flagset.Uint64Flag{ f.DurationFlag(&flagset.DurationFlag{
Name: "txarrivalwait", 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, Value: &c.cliConfig.P2P.TxArrivalWait,
Default: c.cliConfig.P2P.TxArrivalWait, Default: c.cliConfig.P2P.TxArrivalWait,
Group: "P2P", Group: "P2P",

View file

@ -21,6 +21,7 @@ import (
"os/user" "os/user"
"path/filepath" "path/filepath"
"runtime" "runtime"
"time"
"github.com/ethereum/go-ethereum/p2p" "github.com/ethereum/go-ethereum/p2p"
"github.com/ethereum/go-ethereum/p2p/nat" "github.com/ethereum/go-ethereum/p2p/nat"
@ -63,7 +64,7 @@ var DefaultConfig = Config{
ListenAddr: ":30303", ListenAddr: ":30303",
MaxPeers: 50, MaxPeers: 50,
NAT: nat.Any(), NAT: nat.Any(),
TxArrivalWait: 500, TxArrivalWait: 500 * time.Millisecond,
}, },
} }

View file

@ -159,7 +159,7 @@ type Config struct {
// TxArrivalWait is the duration (ms) that the node will wait after seeing // TxArrivalWait is the duration (ms) that the node will wait after seeing
// an announced transaction before explicitly requesting it // an announced transaction before explicitly requesting it
TxArrivalWait int TxArrivalWait time.Duration
} }
// Server manages all peer connections. // Server manages all peer connections.