internal/ethapi: cap default tx sync timeout at RPC max

SendRawTransactionSync capped an explicitly requested timeout but not
the configured default. Clamp defaultTimeout to the max so a misconfigured
default cannot wait longer than RPCTxSyncMaxTimeout.
This commit is contained in:
Weixie Cui 2026-07-14 20:00:00 +08:00
parent abfb2de574
commit a34dbd8435

View file

@ -1790,6 +1790,9 @@ func (api *TransactionAPI) SendRawTransactionSync(ctx context.Context, input hex
defaultTimeout = api.b.RPCTxSyncDefaultTimeout() defaultTimeout = api.b.RPCTxSyncDefaultTimeout()
timeout = defaultTimeout timeout = defaultTimeout
) )
if timeout > maxTimeout {
timeout = maxTimeout
}
if timeoutMs != nil && *timeoutMs > 0 { if timeoutMs != nil && *timeoutMs > 0 {
req := time.Duration(*timeoutMs) * time.Millisecond req := time.Duration(*timeoutMs) * time.Millisecond
if req > maxTimeout { if req > maxTimeout {