MvP-4597 Upgrade bdk 1.2.4#839
Conversation
|
🤖 Claude Code Review Status: Complete SummaryThis PR successfully upgrades the embedded gobdk module from v1.2.3 to v1.2.4, adapting Teranodes validator to BDKs refactored API. The changes are well-structured, reducing code duplication by moving validation logic into BDK. No issues found - the changes are clean, well-documented, and correctly implement the BDK 1.2.4 integration. Key Changes Verified✅ API Rename: CheckTransaction → ValidateTransaction correctly applied throughout Architecture ImpactThe validator surface has shrunk appropriately - Teranode now keeps only the checks that need node context (coinbase routing, MaxCoinsViewCacheSize, fee policy, consolidation exemption), while BDK handles transaction structure, value, standardness, sigops, and scripts. This is the correct separation of concerns. Review completed following AGENTS.md guidelines - static analysis only, no code execution. |
Benchmark Comparison ReportBaseline: Current: Summary
All benchmark results (sec/op)
Threshold: >10% with p < 0.05 | Generated: 2026-05-18 06:13 UTC |
a719f3c to
f0e134d
Compare
oskarszoon
left a comment
There was a problem hiding this comment.
Thanks for the upgrade. Two real fixes wanted before merge, plus a handful of nits.
Must-fix
1. DoS misclassification — DOS_ERR_NOT_FREE_CONSOLIDATION → ErrTxInvalid (should be ErrTxPolicy)
BDK's core/doserror.hpp lists DOS_ERR_NOT_FREE_CONSOLIDATION with DoS=0, i.e. policy. The mapping in services/validator/ScriptVerifierGoBDK.go classifies it as ErrTxInvalid, and the new test at services/validator/ScriptVerifierGoBDK_test.go:207 encodes that. If a peer relays a non-free-consolidation tx, the node will treat it as invalid and ban — that's a peer-banning consequence for a policy reject. Re-map to ErrTxPolicy (and update the test to match).
2. TestCheckP2SHOutput is a no-op stub (services/validator/TxValidator_test.go:661-676)
The body is now _ = txValidator; _ = txP2SH — no assertions. P2SH-output coverage on the Teranode side drops to zero with this PR. Either restore the assertions against the BDK path, or delete the test if the check now lives entirely in BDK and is covered upstream.
Nits
Test_ScriptVerificationGoBDKuses zero-defaultedsettings.NewPolicySettings(), butTestMaxTxSizePolicycarries a comment saying "BDK rejects values below 99999". One of the two is wrong — either the test will be rejected at construction, or the comment is stale.bdkBlockHeightpre-subtracts 1 in policy mode (services/validator/ScriptVerifierGoBDK.go:166-176). Semantically correct vs BDK 1.2.4'sconsensus=false uses blockHeight+1 eraconvention, but the rationale isn't obvious at the call site — please add a one-line comment.- Deleted constants
MaxBlockSize,MaxTxSizeConsensus*,MaxTxSigopsCountPolicyAfterGenesis— grep is clean, but please confirm block-validation still has an effective bound from the BDK side (just a sanity-check). NewPolicySettings()still returns zero defaults with// TODO set defaults(settings/policy_settings.go:35-39). This PR widens the consumer surface; would be a good moment to either tackle the TODO or document why zero is the right default.- Stale
pushDataCheckreference indocs/references/services/validator_reference.md:230— pre-existing, but the PR touches the file, easy to fix in-flight.
Happy to re-approve once the two must-fix items are in.
543be27 to
5b84390
Compare
19314d2 to
a3b4675
Compare
oskarszoon
left a comment
There was a problem hiding this comment.
Thanks for the quick turnaround. Both must-fix items resolved cleanly in a3b46755:
- MF1 (
DOS_ERR_NOT_FREE_CONSOLIDATION→ErrTxPolicy) — mapping moved into the policy-codes case atScriptVerifierGoBDK.go:214; test atScriptVerifierGoBDK_test.go:205flipped towantPolicy: true. Locked in across both consensus modes. - MF2 (
TestCheckP2SHOutput) — restored with stronger assertions than the original.NotErrorIs(err, ErrTxPolicy)pins this as a consensus rejection (which it is post-Genesis), andSkipPolicyChecks: trueensures the test doesn't accidentally pass via the policy bypass. Nice fix.
Also liked the 9b3f80f8 cleanup txvalidator interface commit — dropping the GoBT/GoSDK alternates and the two-phase API simplifies the validator surface considerably.
Approving. A few housekeeping items still open from the original review, none gating — fold into a follow-up commit whenever or carry as separate issues:
bdkBlockHeightpre-subtract atScriptVerifierGoBDK.go:162-172could use a one-line comment explaining BDK 1.2.4'sconsensus=false → blockHeight+1era convention so the next reader doesn't suspect an off-by-one.NewPolicySettings()still returns zero-defaults with// TODO set defaults. Test usage proves BDK treats zero as unlimited, so not broken — but consider renaming toEmptyPolicySettings()or populating from struct tags.docs/references/services/validator_reference.md:209still listspushDataCheck(tx *bt.Tx)which doesn't exist anywhere in the package.
One operational note worth flagging before prod rollout: bumping to 1.2.4 doesn't fix the testnet 245k-OP_2DUP+OP_CHECKSIGVERIFY hang — that's BDK PR #41, expected in v1.2.5. The go.mod warning comment about #41 was removed in the fix commit; worth a one-line note in the PR description (or an updated go.mod comment) so the next reader understands why the pin moved without #41 having landed. Existing alert regexes matching _Cfunc_ScriptEngine_VerifyScript will also need to be widened to match _Cfunc_TxValidator_ValidateTransaction post-upgrade, since the symbol moved.
ordishs
left a comment
There was a problem hiding this comment.
Approving — the architectural shift (Teranode → BDK for tx structure/sigops/standardness/output checks) is a clear improvement, and the bdkValidator interface gives clean test injection. Strong coverage in the new boundary tests (TestBDKBlockHeight, TestScriptVerifierGoBDKMapDoSErrors, TestScriptVerifierGoBDKMapScriptErrors).
A few minor cleanups worth addressing in this PR or a follow-up:
Worth a second look before merge:
-
Behavioural change in
TestTx5f37c7a38b5e0bc177a4c353481f30c6de1bc46db534019846d7bc829f58254a(services/validator/TxValidator_test.go:743) — historical tx now rejected withErrTxInvalidunder consensus mode. Test expectation flipped without a comment explaining which BDK 1.2.4 check newly rejects it (MvP-4615 input value range?). One-line comment would help future debugging. -
bdkBlockHeightrejectsblockHeight=0in policy mode (ScriptVerifierGoBDK.go:141). Correct in principle, but a new failure mode — worth confirming no mempool/test path hits this.
Non-blocking polish:
-
Opaque "T14 parity decision" comment in
TxValidator.checkInputs— future maintainers won't know what T14 references. Link the tracking issue or restate as "SVNode parity, tracked in MvP-XXXX". -
Dead params in
checkInputs— after the dedup logic was removed,blockHeightandvalidationOptionsare unused (the_ = blockHeightcomment claiming "required by the interface" is no longer true). Either drop the params or inline the ~15 remaining lines intoValidateTransaction. -
BenchmarkConsolidationValidationImpact(TxValidator_benchmark_test.go:135) leavestv.bdknil after removinginterpreter:. Works today since onlycheckFees/isConsolidationTxare called, but it's a footgun — setbdk: noopBDKValidator{}for safety. -
TestMaxTxSigopsCountsPolicyskipped "until a focused BDK ValidateTransaction sigops-policy fixture is added" — given MvP-4613 is a headline behaviour in this PR, please track that fixture in an issue rather than leaving the skip dangling. -
Direct
txValidator.bdk = noopBDKValidator{}mutation inTest_MinFeePolicyandValidator_test.gois awkward — consider aWithBDKValidator(...)option onNewTxValidatorif this injection becomes recurring. -
PR description states
DOS_ERR_NOT_FREE_CONSOLIDATIONmapping is a "follow-up" item, but the code already maps it toErrTxPolicy(ScriptVerifierGoBDK.go:165). Either the description is stale or there's a different disagreement still to resolve — please clarify. -
Stale naming —
ScriptVerifierGoBDK.go/scriptVerifierGoBDKno longer "verify scripts"; they adapt to BDK's full transaction validator. Reasonable to defer for diff minimality, but worth a follow-up rename. -
Please tick the test-plan checkboxes (
-tags=bdkand nobdk paths,test/consensus) before merge so reviewers can confirm verification ran.
a3b4675 to
cd0f09e
Compare
|
Adopt main's BDK-only validator architecture (MvP-4597, #839): - Delete ScriptVerifierGoBT.go and ScriptVerifierGoSDK.go (removed on main) - Take main's TxValidator.go (no interpreter registry, BDK direct) - Take main's ScriptVerifierGoBDK.go (BDK 1.2.5 API) - Take main's go.mod versions (BDK 1.2.5, go-bt 2.6.3, go-chaincfg 1.5.8, go-sdk 1.2.23, go-subtree 1.4.1, plus ginkgo/gomega/rapid additions) - Drop ValidateTransactionScriptsBatch / VerifyScriptBatch plumbing and the validator_scriptBatchThreads setting; no callers and the API on BDK 1.2.5 differs (NewValidateBatch / ValidateBatch, no per-call thread count). Batch verification can be reintroduced in a follow-up if and when a consumer is added. - Remove TestMaxScriptNumLengthPolicy skip; the test passes against BDK 1.2.5. - Keep both PR 655's docker-build / docker-build-purego targets and main's network-chaos-test target in the Makefile. - Keep PR 655's Dockerfile.purego, CI purego build, and daemon/test_daemon !prod build tags as-is. Validator and settings packages build and test clean against the merged tree.



Summary
Upgrades the embedded
gobdkmodule fromv1.2.3→v1.2.4and adapts Teranode's validator service to the renamed/restructured BDK API. Several validator checks (sigops counting, duplicate-input detection, coinbase handling, standardness gating) move from Teranode into BDK; the consumer surface shrinks accordingly. New build-tag-gated integration test scaffolding lets the consensus suite run with or without BDK.What flowed in from BDK 1.2.3 → 1.2.4
Upstream commits between
module/gobdk/v1.2.3andmodule/gobdk/v1.2.4:5faf041Reimplement validate batch instead of verify batch5773757RenameCheckTransaction→ValidateTransaction7fee083MvP-4597 Document skipping points6a7bd48MvP-4615 Input value range and in-out value balance checks70f03b6MvP-4614 Fix sigop count for p2sh flag gating22603d7MvP-4613 Enforce Post-Genesis sigops policy limit2c8231aMvP-4612MEMPOOL_HEIGHTuntyped error inGetProtocolEraa1f9744MvP-4606 Fix standardness check gatef939aa3MvP-4605 Off-by-one era height in the policy pathf36dfd5MvP-4604 Check duplicate inputs130274dMvP-4603 Add coinbase transaction handling8c39fcbMvP-4602 Fix missingCheckTransactionCommonchecksChanges on the Teranode side
Validator (
services/validator/)ScriptVerifierGoBDK.go: adapts to theCheckTransaction→ValidateTransactionrename; reworks the batch path to BDK 1.2.4'svalidate batchsemantics; pre-subtracts 1 from block height for policy-mode calls to match BDK'sconsensus=false uses blockHeight+1 eraconvention.TxValidator.go: ~250-line reduction. Sigops counting, duplicate-input detection, coinbase handling, and standardness gating now come from BDK rather than being duplicated in Teranode.Validator.go: pipeline wiring adjusted for the renamed/restructured BDK entry points.ScriptVerifierGoBDK_test.go(+186) covering the renamed API, error-classification mapping, and batch path.Settings (
settings/)policy_settings.go/settings.go: new tunables surfaced for the BDK 1.2.4 policy controls (post-Genesis sigops limit, etc.).Integration tests (
test/consensus/)validator_integration.gotrimmed of the duplicated checks now living in BDK.validator_integration_bdk.go(//go:build bdk) andvalidator_integration_nobdk.go(//go:build !bdk) split — same interface, two backends, so the consensus suite stays runnable without the BDK build dependency.Docs
docs/references/services/validator_reference.mdanddocs/topics/services/validator.mdupdated to reflect the renamed BDK entry points and the shrunk Teranode validator surface.Behaviour / consensus notes
core/doserror.hpp) is now the source of truth for whether a reject is policy vs invalid. Teranode's mapping inScriptVerifierGoBDK.gofollows BDK's classification; one disagreement remains and will be adjusted in a follow-up commit on this PR (DOS_ERR_NOT_FREE_CONSOLIDATION— DoS=0, should map toErrTxPolicy).Migration / config
settings/policy_settings.godiff) — defaults preserved byNewPolicySettings(); operators with custom settings should re-validate against the new BDK-side limits.Test plan
go test -tags=bdk ./services/validator/...go test ./services/validator/...(nobdk path)go test -tags=bdk ./test/consensus/...Linked issue
MvP-4597