Skip to content

tooling: anvil_fork.sh needs upstream throttle — free-tier dRPC 429s lose 35+ Venus markets at boot without it #332

@obchain

Description

@obchain

Problem

scripts/anvil_fork.sh launches anvil without --compute-units-per-second or --retries, so anvil's per-call concurrency saturates whatever upstream RPC it forks against. Free-tier dRPC (the script's default keyless archive) returns HTTP 429 / code: 35 Too many request on the very first burst of 48 parallel vToken.underlying() calls during Venus snapshot init.

Result of an unthrottled boot:

INFO charon_protocols::venus: Venus adapter connected
  market_count=48  mapped_markets=11   <- 37 markets dropped

After adding --compute-units-per-second 80 --fork-retry-backoff 1500 --retries 15:

mapped_markets=46

Two markets still dropped — but a recoverable two, not a catastrophic 37.

Impact

P1. With unthrottled defaults, ~75% of Venus markets are silently absent from the adapter snapshot. Any borrower whose collateral or debt sits in one of the dropped markets is invisible. The downstream "scanner not finding opportunities" symptom is masked because borrower-discovery is a separate gap (issue #329).

Proposed fix

 ANVIL_ARGS=(
     --fork-url "$RPC"
     --chain-id "$CHAIN_ID"
     --port "$PORT"
     --host 0.0.0.0
     --block-time 3
+    # Throttle upstream call rate so free-tier RPCs don't 429 us
+    # during the boot-time snapshot of Venus markets and Chainlink feeds.
+    --compute-units-per-second "${FORK_CUPS:-150}"
+    --fork-retry-backoff "${FORK_RETRY_BACKOFF:-1500}"
+    --retries "${FORK_RETRIES:-15}"
 )

Override knobs already documented in the diff are intentional: keyed-tier operators want to disable the throttle.

Acceptance

  • Fresh boot against unthrottled dRPC reliably maps 46+ of 48 Venus markets across three consecutive runs.
  • Operator can disable via FORK_CUPS=0 (or override to a higher value when on a keyed plan).
  • Documented in the script header alongside FORK_RPC / FORK_BLOCK.

Found during the local mainnet validation walk on 2026-04-25.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinglayer:devopsCI / deploy / infra / telemetrypriority:p1-coreCore MVP scopestatus:readyScoped and ready to pick up

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions