Skip to content

test(u4): validate LSB projection under Core policy - #225

Merged
RobinLinus merged 2 commits into
solving-bitcoin:mainfrom
brenorb:test/u4-lsb-core-next
Sep 28, 2026
Merged

RobinLinus merged 2 commits into
solving-bitcoin:mainfrom
brenorb:test/u4-lsb-core-next

Conversation

@brenorb

@brenorb brenorb commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

This adds a complete 16-nibble u4 LSB projection to the shared Bitcoin Core v30.3 fixture suite. The funded Taproot leaf checks every output for the canonical witness encoding of 0x0123456789abcdef and is accepted under consensus and default relay policy.

Evidence is scoped to the exact complete leaf: 264 policy-compiled script bytes, 333 serialized Taproot witness bytes, 16 data items plus script/control block (18 total items), zero hints, and a 34-item combined stack peak in the strict local helper. The existing 32-nibble fragment remains locally-reproduced / unclassified, with unchanged 440-byte script and 50-item peak.

Current main's LSB boundary and preserved-state tests are retained. Malformed-input checks use raw runtime witnesses, exact validation errors, and a validator-bypass control. The fixture test pins script and Tapleaf hashes and complete-leaf metrics. Existing Core fixtures, catalog configurations and metric entries are preserved.

Validation: focused LSB tests, the named LSB metric, the shared fixture example and Core harness unit tests, KB validation, formatting, and an actual funded Core run. All 45 Core fixtures meet their consensus/policy expectations. No metric refresh or local broad/field-arithmetic suite was run.

Copy link
Copy Markdown
Contributor

Review: changes required before merge.

The new Core fixture covers 16 nibbles, but promoting record-level evidence / execution also promotes the existing 32-nibble configuration: tools/kb.py inherits those values when configuration-level overrides are absent. This contradicts the PR's stated 16-nibble-only scope. Add a separate configuration for the exact validated Taproot leaf, including complete witness/leaf metrics, and retain the 32-nibble fragment's local classification. The new fixture is valuable once the catalog scope matches the actual evidence.

Evidence: inspected. Run the affected focused checks after the correction; no full-repository run is requested.

Reviewed commit: 9bdbaa4721901cfada069dd00f66f5a9222a0e22.

@brenorb
brenorb force-pushed the test/u4-lsb-core-next branch from 9bdbaa4 to 75d3db3 Compare September 19, 2026 02:55
@brenorb

brenorb commented Sep 19, 2026

Copy link
Copy Markdown
Contributor Author

Updated in commit 75d3db3. The reusable 32-nibble LSB fragment is now classified as locally-reproduced and unclassified. Core evidence is isolated to the exact 0x0123456789abcdef complete 16-nibble Taproot leaf: 264-byte leaf, 333-byte serialized Taproot witness, 18 complete witness items, 34-item strict peak, and 184 static non-push opcodes. The separate catalog configuration records differentially-validated and policy-validated scope at Core v30.3 commit 49faec4f87f5cd19c88db01a82e5c68b087c8227. Focused checks passed: cargo test --locked --example core_validation_fixtures, cargo fmt --all -- --check, python3 tools/kb.py validate, and git diff --cached --check.

Copy link
Copy Markdown
Contributor

Review of 75d3db37317c51a46ee5753697fc2959cb711589:

The earlier evidence-inheritance issue is addressed: the 16-nibble funded leaf now has its own configuration, and the 32-nibble fragment retains local/unclassified status. Keep that separation when rebasing over the newly merged LSB boundary tests. Rerun the focused LSB and metric checks plus the funded Core fixture on the integrated tree.

Current integration conflicts: knowledge/catalog.json, knowledge/primitives/u4-lsb.md, src/arithmetic/u4/README.md. These must be resolved and the integrated result validated before merging.

Validation scope: source/diff and existing CI review; no new full-repository or field-arithmetic test run was requested.

@brenorb

brenorb commented Sep 26, 2026

Copy link
Copy Markdown
Contributor Author

Addressed the integration review on 0a0d790344d4708aab92eed3a822f4a53536db7d, preserving both the PR head and current main (e9d5a66b6391eccee64f72cc5af590bc14ed550c).

  • Retained the separate u4-lsb-0123456789abcdef complete-leaf configuration. Only that exact 16-nibble fixture is differentially-validated / policy-validated; the existing 32-nibble fragment remains locally-reproduced / unclassified with unchanged metrics.
  • Preserved main's range-only terminology, output-order, malformed-input, preserved-state and exact stack-frontier tests, all existing catalog configurations and metric entries, and all 44 existing Core fixtures. The integrated Core suite now has 45 fixtures.
  • Strengthened the malformed-input test with runtime encodings for -1, 16 and an oversized five-byte ScriptNum at each position, exact validation errors, and a valid-input control through the same cleanup harness. An executed test-only range-check bypass produces EqualVerify; the shared assertion expecting Verify rejects it. The production generator is unchanged.
  • Pinned the complete fixture's script/Tapleaf hashes and metrics in its test: 264 policy-compiled script bytes, 32 serialized data-witness bytes, 333 complete Taproot witness bytes, 16 data items, zero hints, 18 complete witness items, and a 34-item strict local combined-stack peak. The local helper remains a tapscript-context fragment executor; complete transaction and policy acceptance are measured separately by Core.

Validation on the integrated tree passed: focused LSB tests, the named LSB metric, the shared fixture example, shared Core harness unit tests, KB validation, formatting and whitespace checks. The final funded Core v30.3 run (49faec4f87f5cd19c88db01a82e5c68b087c8227) meets all 45 consensus/policy expectations. The LSB spend is accepted by both consensus and default policy, with transaction weight 711 and script SHA256 58fcbbe71361ce2f2c80fc73f80724ad10870e97696ffcfce14cd24fa7e3f708. I independently regenerated the fixture JSON and verified that it matches the final report's fixture hash. No metric refresh or local broad/field-arithmetic suite was run.

@RobinLinus
RobinLinus merged commit cc00bec into solving-bitcoin:main Sep 28, 2026
3 checks passed
brenorb added a commit to brenorb/bitcoin-scripts that referenced this pull request Sep 28, 2026
…solving-bitcoin#236 and Core fixture solving-bitcoin#225

Resolve conflicts in knowledge/catalog.json, knowledge/primitives/u4-lsb.md,
src/arithmetic/u4/README.md, src/arithmetic/u4/lsb.rs and
src/arithmetic/u4/mod.rs (the last one is new relative to e9d5a66 because
main now also carries solving-bitcoin#244).

- lsb.rs: keep solving-bitcoin#236's range-checked wording, imports and its three tests
  (projects_all_nibble_least_significant_bits_in_order,
  rejects_out_of_range_nibbles_at_each_position,
  respects_stack_frontier_and_preserves_state); keep this PR's separate
  u4_nibbles_to_lsb_canonical API, its 981-input bound and its four tests.
  Document the canonical API's contract distinctly.
- mod.rs: take main's sorted module list (superset of the PR's).
- catalog: keep main's range-only summary/security wording and solving-bitcoin#225's Core
  complete-leaf configuration; add the PR's canonical-checked-batch32
  configuration, list the canonical tests and metric, and state that only
  the canonical API enforces canonical ScriptNum encoding.
- knowledge page / README: keep solving-bitcoin#236 and solving-bitcoin#225 text verbatim; add the canonical
  adapter as a separate API with its 1..=981 frontier and the note that the
  Core fixture does not validate it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@brenorb
brenorb deleted the test/u4-lsb-core-next branch October 28, 2026 02:57
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