Skip to content
Bitcoin Roots

v31.1-roots.1 · Commit 4: [PATCH 04/17] feat(mining): preserve Roots priority and template policies

doc/roots-v31-port-review.md

Before: doc/roots-v31-port-review.md · After: doc/roots-v31-port-review.md

File metadata
index ed0e6801d8e20769989961c3e1f2eb053db943ff..17b088f77e5b1e74c074db3f70766dea64156ca2 100644

Download original patch · Release notes

Diff rows 1–121 of 121. Line numbers refer to the original before/after files.

+ Added− RemovedUnmarked lines are context.

Scroll the code area horizontally to read long lines. The two line-number columns refer to before and after.

doc/roots-v31-port-review.md CHANGED
@@ -108,7 +108,7 @@ contract with remaining Roots behavior. Existing source gaps remain explicit.
108
108
 
109
109
  | Contract | Disposition / theme | Upstream comparison, adaptation and acceptance gate |
110
110
  | --- | --- | --- |
111
- | policy-parsing | adapted / L7,L8 | `node::ApplyArgsManOptions` consumes cluster limits and scoped grammar; L8 consumes graph controls and repairs dynamic-dust publication. Mining controls remain parsing-only until L9. Preserve L2's complete-token/range/diagnostic decisions, quarter-vbyte rounding and CLI/config precedence. Parser unit/startup and L5 fuzz boundaries are carried; integrated read/write precedence remains L12. |
111
+ | policy-parsing | adapted / L7,L8 | `node::ApplyArgsManOptions` consumes cluster limits and scoped grammar; L8 consumes graph controls and repairs dynamic-dust publication. L9 consumes mining size and priority controls. Preserve L2's complete-token/range/diagnostic decisions, quarter-vbyte rounding and CLI/config precedence. Parser unit/startup and L5 fuzz boundaries are carried; integrated read/write precedence remains L12. |
112
112
  | effective-policy | adapted / L12 | `getmempoolinfo` has cluster-era size/fee information but no Roots `policy` object. Read authoritative initialized v31 state plus synchronized dynamic dust; retain L3's schema, units and enforcement gates. Port `rpc_effective_policy.py`, help and admission parity assertions. L4 supplied no snapshot refactor to carry. |
113
113
  | policy-standardness | adapted / L7 | Core `IsStandardTx` takes carrier budget, bare-multisig flag and dust rate. Core permits bare multisig by default and lacks Roots configurable script/witness, strict sigop, CAT21/token and ephemeral modes. Preserve Roots limits/defaults/reasons solely in local gates. Run transaction/sigop/TRUC cases and valid-block fixtures; do not change script consensus. |
114
114
  | policy-carrier | adapted / L7,L8 | Core defaults to a 100,000-vbyte OP_RETURN budget, not Roots' aggregate 83-byte budget, and lacks recognized input/witness carriers and cost weighting. L7 adapts detection/budgets; L8 adapts extra policy weight to `TxGraph` fee/weight accounting. Retain Roots `multi-op-return` rejection despite source help conflict. Port `mempool_datacarrier.py`, extra-weight boundaries, tapscript and L5 dust-cost interactions. |
@@ -347,8 +347,8 @@ L5 interaction ownership remains bounded:
347
347
  | Parser grammar, types, negation, cost and dynamic syntax round trips | L7 unit/startup and actual sanitizer fuzz; no dynamic runtime claim. |
348
348
  | Fixed dust thresholds, ephemeral/local standardness, carrier budgets and valid blocks | L7 focused tests and broader native regression fixtures. |
349
349
  | Subdust deficit rounding/saturation, carrier extra weight, fee deltas, replacement/package/TRUC/reuse combinations | L8; existing source methods and arithmetic fuzz remain required gates. L7's native regression runs do not establish these Roots extensions. |
350
- | Dynamic startup, publication, estimator fallback, extreme scaling and retry/shutdown | Authorized bounded L8 repair, still deferred; default off remains unchanged. |
351
- | Priority ancestors, residual mining, template normalization, actual-versus-modified reward interactions | L9, including source L5 joint mining/block fixtures; native mining passes are regression evidence only. |
350
+ | Dynamic startup, publication, estimator fallback, extreme scaling and retry/shutdown | Authorized bounded L8 repair delivered; L9 repeats the joint publication/template/reward gate. Default off is unchanged. |
351
+ | Priority ancestors, residual mining, template normalization, actual-versus-modified reward interactions | L9 source L5 fixtures and native residual/priority/resource regressions delivered; joint gates below. |
352
352
  | Integrated Roots confrw precedence | L12 only; ordinary CLI/config/JSON cases run in L7. |
353
353
 
354
354
  Prior-release mempool compatibility remains skipped because release fixtures are
@@ -450,3 +450,103 @@ publication, changing-rate test and standardness-snapshot source history.
450
450
  L8.1's conservative representable-case graph restrictions remain explicit in
451
451
  [sub-dust semantics](feature-contracts/subdust.md). L9 mining combinations and
452
452
  L12 integrated runtime configuration remain their respective owners.
453
+
454
+ ## L9.1 priority selection and residual native chunks
455
+
456
+ Local mining defaults are Roots' 1,200,000 weight units, 1,000 sat/kvB and
457
+ 100,000 serialized-byte priority area. Size-only and weight-only settings
458
+ leave the other resource at its protocol maximum; both settings enforce both.
459
+ Serialized size reserves 1,000 bytes as on the source; native weight reserve
460
+ normalization and additional coinbase sigops remain intact. Resource equality
461
+ is excluded by the inherited conservative template boundary.
462
+
463
+ Coin age is evaluated from the active UTXO set under the chain and mempool
464
+ locks, using the source's modified-vsize input discount. This deliberately
465
+ replaces entry caches and confirmation/reorg repair indexes: formerly
466
+ unconfirmed inputs start aging when present in the active UTXO set. Parent
467
+ readiness, priority/individual actual-feerate/descending-txid ordering and the final
468
+ area/threshold-crossing transaction follow source behavior. No priority delta
469
+ API is added; the existing mining RPC changes fee deltas only.
470
+
471
+ After a nonempty priority prefix, a temporary native TxGraph contains exactly
472
+ the remaining entries and direct dependencies. Already included parents and
473
+ their policy fees/weights are absent, so each descendant's native residual
474
+ chunk has accurate resource and fee accounting. It retains configured cluster
475
+ bounds, native bounded optimization and L8's conservative aggregate signed
476
+ budgets. This costs O(mempool) temporary storage plus native cluster work;
477
+ priority-disabled or empty-prefix templates use the existing graph directly.
478
+ Builders have local RAII ownership and are destroyed before residual refs and
479
+ graphs. Template assembly does not mutate or stage the live mempool graph.
480
+ Chunks are included/skipped whole, in native dependency order. Actual
481
+ serialized sizes and sigops are checked alongside native policy weight;
482
+ entries are asserted unique and actual fees alone fund the coinbase reward.
483
+
484
+ Provenance: priority/template content from `1b73fe3d21`, `ec9db369f5`,
485
+ `875fa15829`, `9ab60f217b`, `9d9c125d9e` and joint fixtures from
486
+ `10d772eb7f`. Retain Jaromil/devjoinedthechat credit and inherited Core/Knots
487
+ lineage. L9.2 owns the whole joint policy/mining gate and split-test accounting;
488
+ only integrated `confrw` remains deferred to L12.
489
+
490
+ ## L9.2 split coverage and consensus separation
491
+
492
+ The source L5 commit `10d772eb7f` adds twelve functional subdust methods; every
493
+ method is present and invoked in the candidate. Ownership is reconciled here:
494
+
495
+ | Source methods / coverage | Delivered candidate gate |
496
+ | --- | --- |
497
+ | `test_dust_output_increases_required_fee`, `test_partial_dust_proportional_penalty`, `test_multiple_dust_outputs_stack`, `test_penalty_disabled`, `test_op_return_not_penalized`, `test_above_dust_not_penalized` | L8 admission/accounting boundaries, retained in the joint subdust functional run. |
498
+ | `test_threshold_and_low_rate_boundaries`, `test_anchor_and_standardness` | L7 dust/standardness plus L8 rounding; retained zero/low-rate and local-reject/valid-block gates. |
499
+ | `test_carrier_cost_interaction` | L8 independently charged carrier weight and deficit; L9 residual odd policy weight and exact descendant fee/resource boundaries. |
500
+ | `test_fee_delta_and_replacement` | L8 actual/modified fields and replacement fee diagrams; L9 residual delta one-sat boundary and priority tie independence from operator deltas. |
501
+ | `test_package_and_truc` | L8 ordinary-parent relay floor, native sponsorship, TRUC mode selection and modified package fields; joint package/RBF/TRUC scripts run with L9 assembly. |
502
+ | `test_mining_and_block_acceptance` | L9 priority on/off, minfee equality, penalty disabled, fee delta, actual rewards under both selection modes, and local-reject/valid-block acceptance. |
503
+ | Source parser `policy_args` and arithmetic/admission `subdust_fee_penalty` fuzz | L7/L8 independent grammar/arithmetic oracles retained; current bounded L9 sanitizer smoke plus native pool template option fuzz. |
504
+ | L8 dynamic runtime/publication/estimator/retry/reload and immutability | Existing functional cases retained, with current template fee fields and mined rewards checked after publication and operator-delta persistence. |
505
+ | Source priority-parent/stale-ancestor mining corrections | Native one/two-parent, shared/waiting descendant, repeated-build, exact remaining fee/weight/size and duplicate/order regressions. |
506
+ | Source integrated Roots `confrw` precedence subsection | Only split-policy/mining integration deferral; L12. Ordinary CLI/config/JSON startup cases remain active. |
507
+
508
+ Synthetic residual accounting tests combine a priority-selected negative-modified
509
+ parent with a carrier-adjusted descendant. The descendant meets an exact
510
+ rounded-vsize floor, misses it after a one-sat operator delta, and respects the
511
+ remaining policy-weight boundary. Actual parent/child fees and coinbase rewards
512
+ are checked separately. Pool fuzz assembly varies priority enabled/disabled,
513
+ serialized size, weight, reserve and sigop reservations before block removal
514
+ and reorg admission. These are short smoke checks, not exhaustive campaigns.
515
+
516
+ Mining's synthetic fixtures now lock cs_main before mempool, matching production
517
+ lock order. Fee-only ephemeral and estimation fixtures explicitly disable the
518
+ source priority area; the estimator retains its native low-feerate sampling
519
+ with an explicit template fee floor. The disconnected-pool bulk fixture requests
520
+ the source's protocol-max template weight and FIFO fee ordering. Assertions
521
+ are retained. Sequence-lock fixtures use fee selection, and large-block upload
522
+ accounting requests the source size-only profile. The general mining test checks
523
+ the Roots default weight/fee limits and explicitly requests protocol-max weight
524
+ for its separate reserve-boundary case. Roots defaults remain covered by the
525
+ dedicated template matrix.
526
+
527
+ `validation.cpp` from `bool CheckBlock(` through end-of-file is byte-identical
528
+ to the authenticated v31.1 base. The consensus subtree, interpreter, block
529
+ primitive and kernel chain files have no candidate changes. This L9 diff touches
530
+ only local template selection/configuration plus tests/docs and a read-only
531
+ mempool builder accessor. No block-size/weight acceptance gate reads Roots local
532
+ template limits. Functional and unit tests add transactions excluded by local
533
+ policy/templates to valid blocks and accept them through the native interface.
534
+ No RDTS/BIP110 or other new consensus rule is present.
535
+
536
+ The per-contract/source-commit accounting above remains complete (72 commits,
537
+ 25 contracts) and retains Jaromil/devjoinedthechat plus Core/Knots attribution.
538
+ Within the L7–L9 policy/mining split no parsing-only mining controls or unowned
539
+ source interaction cases remain. Optional platform/dependency gates remain
540
+ explicit environment gaps; heavy/nightly CI is L13.2, not a preservation claim.
541
+
542
+ The L9 acceptance gate includes 751 GCC unit cases, 154 CTest passes plus the
543
+ external script-assets skip, and 274 functional passes plus 17 environment
544
+ skips. One frozen functional sweep exposed six inherited fixture assumptions;
545
+ only those fixtures were corrected and rerun against the same daemon. CTest
546
+ launches interrupted by a unit-binary relink were rerun after the build finished.
547
+ The current miner cases also passed separately after the lock-order fixture
548
+ correction. Scoped Clang ASan/UBSan checks cover 44 policy/miner unit cases and
549
+ the dynamic/subdust template-reward interactions. The existing template matrix
550
+ sanitizer evidence retains the same production source and daemon hash. Parser,
551
+ penalty arithmetic and randomized native pool assembly have bounded sanitizer
552
+ fuzz smoke coverage. No repeated full sweep or exhaustive fuzz claim is made.