fix(go): bound retarget wait and warn on Sepolia DKG fragility#4013
Merged
lionakhnazarov merged 3 commits intoJun 4, 2026
Merged
Conversation
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.
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
lionakhnazarov
approved these changes
Jun 4, 2026
5beefc4
into
stack/testnet4-04-go-testnet4-runtime
31 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stack Context
Follow-up to #4002 (
stack/testnet4-04-go-testnet4-runtime).Base:
stack/testnet4-04-go-testnet4-runtimeAddresses 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.gowaitDeployBackendTransactionMinedpreviously calledbind.WaitMined(context.Background(), …)with no timeout, thenBlockCounter.WaitForBlockHeight(which has no context parameter). A stalled RPC or chain that stopped producing blocks would hang the maintainer indefinitely on everyRetarget/RetargetWithRefundcall — including on mainnet.Both waits are now bounded under a shared 10-minute deadline. A small
waitForBlockHeightCtxshim adapts the context-lessBlockCounterinterface, with a regression test verifying it returnscontext.DeadlineExceededwhen the counter blocks forever.2) Warn loudly about Sepolia DKG fragility —
pkg/tbtc/tbtc.go,pkg/chain/ethereum/tbtc.goThe Sepolia/Developer
defaultGroupParametersreturns{GroupSize:3, GroupQuorum:3, HonestThreshold:2}. Quorum equals size — a single offline operator prevents DKG progress.InfoftoWarnfand spelled out the operational consequence.Warnfinpkg/chain/ethereum/tbtc.gowhere theEcdsaDkgValidatorErrAddressNotConfiguredbranch 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:101already 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 tobitcoin.Testnet4rather thanbitcoin.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/TestWaitForBlockHeightCtx_DeadlineExceeded,TestWaitForBlockHeightCtx_ReturnsImmediatelyOnSuccess