mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-20 11:46:44 +00:00
unset Duration changes
This commit is contained in:
parent
79c20ba069
commit
ce18f79cb0
7 changed files with 47 additions and 49 deletions
|
|
@ -1772,10 +1772,10 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) {
|
||||||
cfg.LogQueryLimit = ctx.Int(RPCGlobalLogQueryLimit.Name)
|
cfg.LogQueryLimit = ctx.Int(RPCGlobalLogQueryLimit.Name)
|
||||||
}
|
}
|
||||||
if ctx.IsSet(RPCTxSyncDefaultTimeoutFlag.Name) {
|
if ctx.IsSet(RPCTxSyncDefaultTimeoutFlag.Name) {
|
||||||
cfg.TxSyncDefaultTimeout = uint64(ctx.Duration(RPCTxSyncDefaultTimeoutFlag.Name).Milliseconds())
|
cfg.TxSyncDefaultTimeout = ctx.Duration(RPCTxSyncDefaultTimeoutFlag.Name)
|
||||||
}
|
}
|
||||||
if ctx.IsSet(RPCTxSyncMaxTimeoutFlag.Name) {
|
if ctx.IsSet(RPCTxSyncMaxTimeoutFlag.Name) {
|
||||||
cfg.TxSyncMaxTimeout = uint64(ctx.Duration(RPCTxSyncMaxTimeoutFlag.Name).Milliseconds())
|
cfg.TxSyncMaxTimeout = ctx.Duration(RPCTxSyncMaxTimeoutFlag.Name)
|
||||||
}
|
}
|
||||||
if ctx.IsSet(RPCGlobalRangeLimitFlag.Name) {
|
if ctx.IsSet(RPCGlobalRangeLimitFlag.Name) {
|
||||||
cfg.RangeLimit = ctx.Uint64(RPCGlobalRangeLimitFlag.Name)
|
cfg.RangeLimit = ctx.Uint64(RPCGlobalRangeLimitFlag.Name)
|
||||||
|
|
|
||||||
|
|
@ -492,10 +492,10 @@ func (b *EthAPIBackend) StateAtTransaction(ctx context.Context, block *types.Blo
|
||||||
return b.eth.stateAtTransaction(ctx, block, txIndex, reexec)
|
return b.eth.stateAtTransaction(ctx, block, txIndex, reexec)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *EthAPIBackend) RPCTxSyncDefaultTimeout() uint64 {
|
func (b *EthAPIBackend) RPCTxSyncDefaultTimeout() time.Duration {
|
||||||
return b.eth.config.TxSyncDefaultTimeout
|
return b.eth.config.TxSyncDefaultTimeout
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *EthAPIBackend) RPCTxSyncMaxTimeout() uint64 {
|
func (b *EthAPIBackend) RPCTxSyncMaxTimeout() time.Duration {
|
||||||
return b.eth.config.TxSyncMaxTimeout
|
return b.eth.config.TxSyncMaxTimeout
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -72,10 +72,10 @@ var Defaults = Config{
|
||||||
RPCGasCap: 50000000,
|
RPCGasCap: 50000000,
|
||||||
RPCEVMTimeout: 5 * time.Second,
|
RPCEVMTimeout: 5 * time.Second,
|
||||||
GPO: FullNodeGPO,
|
GPO: FullNodeGPO,
|
||||||
RPCTxFeeCap: 1, // 1 ether
|
RPCTxFeeCap: 1, // 1 ether
|
||||||
TxSyncDefaultTimeout: uint64(20000), // 20 seconds in milliseconds
|
TxSyncDefaultTimeout: 20 * time.Second,
|
||||||
TxSyncMaxTimeout: uint64(60000), // 1 minute in milliseconds
|
TxSyncMaxTimeout: 1 * time.Minute,
|
||||||
SlowBlockThreshold: -1, // Disabled by default; set via --debug.logslowblock flag
|
SlowBlockThreshold: -1, // Disabled by default; set via --debug.logslowblock flag
|
||||||
RangeLimit: 0,
|
RangeLimit: 0,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -204,8 +204,8 @@ type Config struct {
|
||||||
OverrideVerkle *uint64 `toml:",omitempty"`
|
OverrideVerkle *uint64 `toml:",omitempty"`
|
||||||
|
|
||||||
// EIP-7966: eth_sendRawTransactionSync timeouts
|
// EIP-7966: eth_sendRawTransactionSync timeouts
|
||||||
TxSyncDefaultTimeout uint64 `toml:",omitempty"`
|
TxSyncDefaultTimeout time.Duration `toml:",omitempty"`
|
||||||
TxSyncMaxTimeout uint64 `toml:",omitempty"`
|
TxSyncMaxTimeout time.Duration `toml:",omitempty"`
|
||||||
|
|
||||||
// RangeLimit restricts the maximum range (end - start) for range queries.
|
// RangeLimit restricts the maximum range (end - start) for range queries.
|
||||||
RangeLimit uint64 `toml:",omitempty"`
|
RangeLimit uint64 `toml:",omitempty"`
|
||||||
|
|
|
||||||
|
|
@ -61,13 +61,13 @@ func (c Config) MarshalTOML() (interface{}, error) {
|
||||||
RPCGasCap uint64
|
RPCGasCap uint64
|
||||||
RPCEVMTimeout time.Duration
|
RPCEVMTimeout time.Duration
|
||||||
RPCTxFeeCap float64
|
RPCTxFeeCap float64
|
||||||
OverrideOsaka *uint64 `toml:",omitempty"`
|
OverrideOsaka *uint64 `toml:",omitempty"`
|
||||||
OverrideBPO1 *uint64 `toml:",omitempty"`
|
OverrideBPO1 *uint64 `toml:",omitempty"`
|
||||||
OverrideBPO2 *uint64 `toml:",omitempty"`
|
OverrideBPO2 *uint64 `toml:",omitempty"`
|
||||||
OverrideVerkle *uint64 `toml:",omitempty"`
|
OverrideVerkle *uint64 `toml:",omitempty"`
|
||||||
TxSyncDefaultTimeout uint64 `toml:",omitempty"`
|
TxSyncDefaultTimeout time.Duration `toml:",omitempty"`
|
||||||
TxSyncMaxTimeout uint64 `toml:",omitempty"`
|
TxSyncMaxTimeout time.Duration `toml:",omitempty"`
|
||||||
RangeLimit uint64 `toml:",omitempty"`
|
RangeLimit uint64 `toml:",omitempty"`
|
||||||
}
|
}
|
||||||
var enc Config
|
var enc Config
|
||||||
enc.Genesis = c.Genesis
|
enc.Genesis = c.Genesis
|
||||||
|
|
@ -171,13 +171,13 @@ func (c *Config) UnmarshalTOML(unmarshal func(interface{}) error) error {
|
||||||
RPCGasCap *uint64
|
RPCGasCap *uint64
|
||||||
RPCEVMTimeout *time.Duration
|
RPCEVMTimeout *time.Duration
|
||||||
RPCTxFeeCap *float64
|
RPCTxFeeCap *float64
|
||||||
OverrideOsaka *uint64 `toml:",omitempty"`
|
OverrideOsaka *uint64 `toml:",omitempty"`
|
||||||
OverrideBPO1 *uint64 `toml:",omitempty"`
|
OverrideBPO1 *uint64 `toml:",omitempty"`
|
||||||
OverrideBPO2 *uint64 `toml:",omitempty"`
|
OverrideBPO2 *uint64 `toml:",omitempty"`
|
||||||
OverrideVerkle *uint64 `toml:",omitempty"`
|
OverrideVerkle *uint64 `toml:",omitempty"`
|
||||||
TxSyncDefaultTimeout *uint64 `toml:",omitempty"`
|
TxSyncDefaultTimeout *time.Duration `toml:",omitempty"`
|
||||||
TxSyncMaxTimeout *uint64 `toml:",omitempty"`
|
TxSyncMaxTimeout *time.Duration `toml:",omitempty"`
|
||||||
RangeLimit *uint64 `toml:",omitempty"`
|
RangeLimit *uint64 `toml:",omitempty"`
|
||||||
}
|
}
|
||||||
var dec Config
|
var dec Config
|
||||||
if err := unmarshal(&dec); err != nil {
|
if err := unmarshal(&dec); err != nil {
|
||||||
|
|
|
||||||
|
|
@ -1689,18 +1689,19 @@ func (api *TransactionAPI) SendRawTransactionSync(ctx context.Context, input hex
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
maxTimeoutMs = api.b.RPCTxSyncMaxTimeout()
|
maxTimeout = api.b.RPCTxSyncMaxTimeout()
|
||||||
defaultTimeoutMs = api.b.RPCTxSyncDefaultTimeout()
|
defaultTimeout = api.b.RPCTxSyncDefaultTimeout()
|
||||||
effectiveMs = defaultTimeoutMs
|
timeout = defaultTimeout
|
||||||
)
|
)
|
||||||
if timeoutMs != nil && *timeoutMs > 0 {
|
if timeoutMs != nil && *timeoutMs > 0 {
|
||||||
if *timeoutMs > maxTimeoutMs {
|
req := time.Duration(*timeoutMs) * time.Millisecond
|
||||||
effectiveMs = maxTimeoutMs
|
if req > maxTimeout {
|
||||||
|
timeout = maxTimeout
|
||||||
} else {
|
} else {
|
||||||
effectiveMs = *timeoutMs
|
timeout = req
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
receiptCtx, cancel := context.WithTimeout(ctx, time.Duration(effectiveMs)*time.Millisecond)
|
receiptCtx, cancel := context.WithTimeout(ctx, timeout)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
// Fast path.
|
// Fast path.
|
||||||
|
|
@ -1715,10 +1716,7 @@ func (api *TransactionAPI) SendRawTransactionSync(ctx context.Context, input hex
|
||||||
// If server-side wait window elapsed, return the structured timeout.
|
// If server-side wait window elapsed, return the structured timeout.
|
||||||
if errors.Is(receiptCtx.Err(), context.DeadlineExceeded) {
|
if errors.Is(receiptCtx.Err(), context.DeadlineExceeded) {
|
||||||
return nil, &txSyncTimeoutError{
|
return nil, &txSyncTimeoutError{
|
||||||
msg: fmt.Sprintf(
|
msg: fmt.Sprintf("The transaction was added to the transaction pool but wasn't processed in %v", timeout),
|
||||||
"The transaction was added to the transaction pool but wasn't processed in %v",
|
|
||||||
time.Duration(effectiveMs)*time.Millisecond,
|
|
||||||
),
|
|
||||||
hash: hash,
|
hash: hash,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -447,8 +447,8 @@ type testBackend struct {
|
||||||
sentTx *types.Transaction
|
sentTx *types.Transaction
|
||||||
sentTxHash common.Hash
|
sentTxHash common.Hash
|
||||||
|
|
||||||
syncDefaultTimeout uint64 // in milliseconds
|
syncDefaultTimeout time.Duration
|
||||||
syncMaxTimeout uint64 // in milliseconds
|
syncMaxTimeout time.Duration
|
||||||
}
|
}
|
||||||
|
|
||||||
func fakeBlockHash(txh common.Hash) common.Hash {
|
func fakeBlockHash(txh common.Hash) common.Hash {
|
||||||
|
|
@ -3949,20 +3949,20 @@ func (b configTimeBackend) CurrentHeader() *types.Header {
|
||||||
return &types.Header{Time: b.time}
|
return &types.Header{Time: b.time}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *testBackend) RPCTxSyncDefaultTimeout() uint64 {
|
func (b *testBackend) RPCTxSyncDefaultTimeout() time.Duration {
|
||||||
if b.syncDefaultTimeout != 0 {
|
if b.syncDefaultTimeout != 0 {
|
||||||
return b.syncDefaultTimeout
|
return b.syncDefaultTimeout
|
||||||
}
|
}
|
||||||
return 2000 // 2 seconds in milliseconds
|
return 2 * time.Second
|
||||||
}
|
}
|
||||||
func (b *testBackend) RPCTxSyncMaxTimeout() uint64 {
|
func (b *testBackend) RPCTxSyncMaxTimeout() time.Duration {
|
||||||
if b.syncMaxTimeout != 0 {
|
if b.syncMaxTimeout != 0 {
|
||||||
return b.syncMaxTimeout
|
return b.syncMaxTimeout
|
||||||
}
|
}
|
||||||
return 300000 // 5 minutes in milliseconds
|
return 5 * time.Minute
|
||||||
}
|
}
|
||||||
func (b *backendMock) RPCTxSyncDefaultTimeout() uint64 { return 2000 } // 2 seconds
|
func (b *backendMock) RPCTxSyncDefaultTimeout() time.Duration { return 2 * time.Second }
|
||||||
func (b *backendMock) RPCTxSyncMaxTimeout() uint64 { return 300000 } // 5 minutes
|
func (b *backendMock) RPCTxSyncMaxTimeout() time.Duration { return 5 * time.Minute }
|
||||||
|
|
||||||
func makeSignedRaw(t *testing.T, api *TransactionAPI, from, to common.Address, value *big.Int) (hexutil.Bytes, *types.Transaction) {
|
func makeSignedRaw(t *testing.T, api *TransactionAPI, from, to common.Address, value *big.Int) (hexutil.Bytes, *types.Transaction) {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
|
|
|
||||||
|
|
@ -49,12 +49,12 @@ type Backend interface {
|
||||||
ChainDb() ethdb.Database
|
ChainDb() ethdb.Database
|
||||||
AccountManager() *accounts.Manager
|
AccountManager() *accounts.Manager
|
||||||
ExtRPCEnabled() bool
|
ExtRPCEnabled() bool
|
||||||
RPCGasCap() uint64 // global gas cap for eth_call over rpc: DoS protection
|
RPCGasCap() uint64 // global gas cap for eth_call over rpc: DoS protection
|
||||||
RPCEVMTimeout() time.Duration // global timeout for eth_call over rpc: DoS protection
|
RPCEVMTimeout() time.Duration // global timeout for eth_call over rpc: DoS protection
|
||||||
RPCTxFeeCap() float64 // global tx fee cap for all transaction related APIs
|
RPCTxFeeCap() float64 // global tx fee cap for all transaction related APIs
|
||||||
UnprotectedAllowed() bool // allows only for EIP155 transactions.
|
UnprotectedAllowed() bool // allows only for EIP155 transactions.
|
||||||
RPCTxSyncDefaultTimeout() uint64 // default timeout for eth_sendRawTransactionSync in milliseconds
|
RPCTxSyncDefaultTimeout() time.Duration
|
||||||
RPCTxSyncMaxTimeout() uint64 // maximum timeout for eth_sendRawTransactionSync in milliseconds
|
RPCTxSyncMaxTimeout() time.Duration
|
||||||
|
|
||||||
// Blockchain API
|
// Blockchain API
|
||||||
SetHead(number uint64)
|
SetHead(number uint64)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue