!5258huginn-rsi/test-speed-20261020 → develop54efe86079

Bifrost suites wait for what they assert; cheaper key and random fixtures

AI-generatedEverything on this page was written by an AI agent from the diff: the summaries, the narration, the diagrams, the flags and the glossary. It can be wrong or incomplete, so check it against the code before you rely on it.

16commits
40files
799lines changed
79lines to read
87.9→75.9sbatch wall (author)
4seam vars, same default
1prod path changed

Where the diff is

Tests34 files · 720 lines

bifrost/thorclient/keys_test.go+91 −0bifrost/blockscanner/blockscanner_test.go+58 −14…/oracle/providers/provider_test.go+28 −35…/utxo/rpc/rpc_test.go+46 −1bifrost/blockscanner/blockscanner_extra_test.go+37 −7bifrost/tss/tss_signer_test.go+41 −1bifrost/signer/keysign_batch_test.go+41 −0…/oracle/providers/ws_settle_test.go+35 −1bifrost/signer/sign_test.go+27 −4x/thorchain/telemetry_benchmark_test.go+20 −5…/oracle/providers/coinbase_test.go+13 −8…/oracle/providers/lbank_test.go+13 −8
+22 more filesshow fewer186bifrost/observer/observe_extra_test.go+12 −7common/common_coverage_test.go+19 −0…/oracle/providers/bitstamp_test.go+11 −2…/oracle/providers/gemini_test.go+11 −2…/oracle/providers/thorchain_test.go+10 −2bifrost/p2p/party_coordinator_test.go+7 −3bifrost/signer/keygen_policy_test.go+7 −2bifrost/blockscanner/blockscanner_stall_test.go+6 −2…/oracle/providers/binance_test.go+4 −2…/oracle/providers/bitfinex_test.go+4 −2…/oracle/providers/bitget_test.go+4 −2…/oracle/providers/bitmart_test.go+4 −2…/oracle/providers/bybit_test.go+4 −2…/oracle/providers/coinw_test.go+4 −2…/oracle/providers/crypto_test.go+4 −2…/oracle/providers/digifinex_test.go+4 −2…/oracle/providers/gate_test.go+4 −2…/oracle/providers/htx_test.go+4 −2…/oracle/providers/kraken_test.go+4 −2…/oracle/providers/kucoin_test.go+4 −2…/oracle/providers/okx_test.go+4 −2bifrost/observer/mock_test.go+4 −1
1go test -race ./bifrost/...2go test ./common/...3TestGetPrivateKeyMatchesArmorRoundTrip4TestRandHexStringUniform5TestRetryBackoff

5-minute explainer

What changed

Where the time went

Oracle −85%, blockscanner −75%; batch median −13.6% (author's runs).

oracleblockscannerutxo rpcgrey = before · green = after (seconds ×10 px)

Blockscanner waits on progress

Count pause checks; 50ms block time per test; rollback twice as a barrier.

Startcheck 1check 2Stop

was: sleep 1–2s per test · now ≤10s deadline

Observer streams end at once

A finished mock remote returns EOF instead of retrying for 5s.

readEOFremoteClosed → return

Oracle waits for prices

Poll tickers until the asserted prices land; subscribe pause is a var.

waitForPrices ≤5ssettleStartPollwsSubscribeDelay 100ms → 0 in tests

Signer and TSS batch faster

KeySignBatchInterval 1s (prod) → 10ms in tss and signer tests.

prod quiet window1stests10msXMR recheck: block time → 10ms in handoff test

UTXO retries record backoffs

retrySleep records 1,2,4,8,10,10s instead of sleeping 35s.

1s2s4s8s10s10sasserted with DeepEquals, not slept

Keys skip the argon2 round trip

Production: ExportPrivateKeyObject when the keyring has it; armor as fallback.

keyringarmor → argon2 ×2keybefore (now fallback only)keyringExportPrivateKeyObjectkeyafter (SDK keystore)

Cheaper fixtures

RandHexString: one read + rejection ≥242; ETH addrs from bytes; p2p 3s.

024225511 × 22 symbolsbytes ≥ 242 are redrawn → uniform over 22 chars

State + upgrade

Test seams (package vars, production default unchanged)

  • newtss.KeySignBatchIntervaltime.After(time.Second) → 1s
  • newsigner.xmrKeygenRecheckIntervalNewTicker(ThorchainBlockTime) → ThorchainBlockTime
  • newrpc.retrySleeptime.Sleep(backoff) → time.Sleep
  • newproviders.wsSubscribeDelaytime.Sleep(100ms) → 100ms

Line by line · every changed logic line, narrated

5:53runtime
9code chapters
100%logic lines narrated (47/47)
7flagged spots
speed

Chapters

What to check

Ask an AI about this change

Chat assistantClaude, ChatGPT, … (reads a link)

Coding agentClaude Code, Cursor, … (reads the repo)

The context file is context.md. Use Copy with context for an AI that can't open links; it pastes the whole file in.

Glossary

Armor (ExportPrivKeyArmor)
The SDK keyring's export of a private key as an argon2-encrypted, ASCII-armored blob. Bifrost used to export then immediately decrypt it with the same password. bifrost/thorclient/keys.go ↗
Bifrost
THORNode's off-chain service that watches external chains and signs outbound transactions with TSS. Every package this MR touches except common and x/thorchain lives here. how-bifrost-works.md ↗
ExportPrivateKeyObject
SDK keyring method returning the decoded private key directly; bifrost now uses it when the keyring has it, skipping the two argon2 derivations. keys.go ↗
KeySignBatchInterval
New package var: how long the keysign queue must stay quiet before its batch goes to TSS. 1s in production, 10ms in tss and signer tests. tss_signer.go ↗
Rejection sampling
Drawing random bytes and discarding those at or above 242 (11 × 22), so byte mod 22 picks each of RandHexString's 22 characters equally often. common/random_string.go ↗
remoteClosed
New flag on the observer's mock stream: the remote already sent everything, so EOF means done and Read returns it at once instead of retrying. observer/mock_test.go ↗
Test seam
A package variable holding a production constant or function (a pause, a sleep), so tests can shrink or record it while the default stays the old value.
ThorchainBlockTime
Global block-time variable: 6s on mainnet, 1s on mocknet. The blockscanner suite now sets it to 50ms per test and restores it. constants_mocknet.go ↗
TSS
Threshold signature scheme: vault members sign jointly without any one holding the key. The keysign loop batches requests before sending them to TSS. docs/bifrost/tss.md ↗ bifrost/tss/tss_signer.go ↗
XMR keygen retention
A signer worker that keeps one XMR keygen request and re-runs it on each tick, for repeated errors and promoted requests. Its tick is now a var defaulting to ThorchainBlockTime. keygen_admission.go ↗