Skip to content

fix(go): bound retarget wait and warn on Sepolia DKG fragility#4013

Merged
lionakhnazarov merged 3 commits into
stack/testnet4-04-go-testnet4-runtimefrom
stack/testnet4-05-runtime-hardening
Jun 4, 2026
Merged

fix(go): bound retarget wait and warn on Sepolia DKG fragility#4013
lionakhnazarov merged 3 commits into
stack/testnet4-04-go-testnet4-runtimefrom
stack/testnet4-05-runtime-hardening

Conversation

@piotr-roslaniec
Copy link
Copy Markdown
Collaborator

Stack Context

Follow-up to #4002 (stack/testnet4-04-go-testnet4-runtime).
Base: stack/testnet4-04-go-testnet4-runtime

Addresses three runtime/operability issues surfaced during review of #4002.

What's in this PR

1) Bound the synchronous retarget wait — pkg/chain/ethereum/bitcoin_difficulty.go

waitDeployBackendTransactionMined previously called bind.WaitMined(context.Background(), …) with no timeout, then BlockCounter.WaitForBlockHeight (which has no context parameter). A stalled RPC or chain that stopped producing blocks would hang the maintainer indefinitely on every Retarget / RetargetWithRefund call — including on mainnet.

Both waits are now bounded under a shared 10-minute deadline. A small waitForBlockHeightCtx shim adapts the context-less BlockCounter interface, with a regression test verifying it returns context.DeadlineExceeded when the counter blocks forever.

2) Warn loudly about Sepolia DKG fragility — pkg/tbtc/tbtc.go, pkg/chain/ethereum/tbtc.go

The Sepolia/Developer defaultGroupParameters returns {GroupSize:3, GroupQuorum:3, HonestThreshold:2}. Quorum equals size — a single offline operator prevents DKG progress.

  • Elevated the existing Infof to Warnf and spelled out the operational consequence.
  • Added a Warnf in pkg/chain/ethereum/tbtc.go where the EcdsaDkgValidator ErrAddressNotConfigured branch previously fell through silently. Operators now see at startup whether group sizing is coming from on-chain values or compile-time defaults.

No sizing values are changed.

3) Document the testnet3 → testnet4 wiring as breaking

No code change in this PR; the startup banner at config/config.go:101 already prints the resolved Bitcoin network. Operator-facing note is captured here and should be folded into release notes when #4002 lands.

After #4002 lands, network.Type=Testnet (Sepolia) resolves to bitcoin.Testnet4 rather than bitcoin.Testnet (testnet3). Existing Sepolia operators will switch both the embedded Electrum URL set and the Bitcoin network on upgrade. Pin to a pre-#4002 build to remain on testnet3.

Test Plan

  • go build ./...
  • go vet ./pkg/chain/ethereum/... ./pkg/tbtc/...
  • go test ./pkg/chain/ethereum/...
  • go test ./pkg/tbtc/
  • New regression: TestWaitForBlockHeightCtx_DeadlineExceeded, TestWaitForBlockHeightCtx_ReturnsImmediatelyOnSuccess

WaitMined previously used context.Background() with no timeout, and the
follow-up confirmation-depth wait called the context-less
BlockCounter.WaitForBlockHeight. If the RPC stalls or the chain stops
producing blocks, the maintainer would hang indefinitely on every
Retarget / RetargetWithRefund call.

Wrap both waits under a 10-minute shared deadline and add a context
shim around WaitForBlockHeight so callers can enforce timeouts on the
context-less BlockCounter interface.
Elevate the Sepolia/Developer defaultGroupParameters log to Warn level
and spell out that GroupQuorum equals GroupSize (3/3/2), so all three
operators must stay online for DKG to progress.

Also emit a Warn when the EcdsaDkgValidator contract address is not
configured. The fallthrough was previously silent, leaving operators
unaware that group sizing was coming from compile-time defaults rather
than the on-chain validator.
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 4, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 60c28c54-44de-4a5b-879a-6474e47221e9

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch stack/testnet4-05-runtime-hardening

Comment @coderabbitai help to get the list of available commands and usage tips.

@lionakhnazarov lionakhnazarov merged commit 5beefc4 into stack/testnet4-04-go-testnet4-runtime Jun 4, 2026
31 checks passed
@lionakhnazarov lionakhnazarov deleted the stack/testnet4-05-runtime-hardening branch June 4, 2026 19:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants