HttpFetchTimeout

Constant v216 → current u64

Limits how long offchain workers wait when fetching pulses from external Drand APIs.

Current Value

1000
Relevant for: validatorsdevelopers

The Big Picture

Offchain workers fetch Drand pulses from external HTTP APIs (like api.drand.sh). This timeout prevents workers from hanging indefinitely if the beacon is slow or unreachable. It's a reliability setting - short enough to fail fast, long enough to handle normal latency.

Why This Matters

Your offchain worker has limited time per block. If it waits too long for Drand, it might miss the submission window. This timeout ensures it gives up promptly on slow responses and can try again next block.

Example

HttpFetchTimeout is 1000 (milliseconds). Your offchain worker calls api.drand.sh/public/latest. If no response in 1 second, it times out and aborts. Worker can retry next block rather than waiting indefinitely.

Common Questions

What's a good timeout value?
Depends on network latency to Drand endpoints. 1000ms (1 second) is typical - fast enough to retry quickly, slow enough for most network conditions.
What if timeouts are frequent?
Check network path to Drand endpoints. Consider running a local Drand relay for lower latency and better reliability.

From Chain Metadata

The maximum number of milliseconds we are willing to wait for the HTTP request to complete.

Use Cases

  • Offchain worker HTTP timeout configuration
  • Prevent offchain workers from hanging on slow responses
  • Balance reliability vs responsiveness for beacon fetches

Code Examples

import { ApiPromise, WsProvider } from "@polkadot/api";
import { stringCamelCase } from "@polkadot/util";

const provider = new WsProvider("wss://entrypoint-finney.opentensor.ai:443");
const api = await ApiPromise.create({ provider });

// Query HttpFetchTimeout constant
const value = api.consts[stringCamelCase("Drand")][stringCamelCase("HttpFetchTimeout")];
console.log("HttpFetchTimeout:", value.toHuman());

// Convert RAO to TAO if this is a balance value
const taoValue = value.toBigInt() / BigInt(1e9);
console.log("TAO:", taoValue.toString());

Type Information

Type
u64
Byte Size
8 bytes
Encoding
fixed
Raw Hex
0xe803000000000000

Runtime Info

Pallet
Drand
First Version
v216
Latest Version
v216
Current Runtime
v393