You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[0.32][Backend] Shorten low-mask immediates with validated logical right shifts #41
Parent: #40. Target: 0.32. The maintainer authorized this implementation on September 27 after retaining the completed 0.31 scope.
Baseline: 54d639a7230060cc0bcc009dcf26e1830e2011c6, whose tree is identical to the validated 0.31 closure 648bb836.
Accepted slice
Consider exactly one additional immediate construction for nonempty low-bit masks: addi rd, zero, -1; srli rd, rd, leading_zeros(mask). Validate reconstructed bits and adopt it only when strictly shorter than the existing 0.31 plan; preserve the existing choice on ties. This shortens 2^n - 1 for n=31..63 from three instructions to two. Zero, all ones, non-mask constants and the fixed entry trampoline retain their previous handling.
Use the existing RV64 SRLI surface and independent checker. No general sequence search, ADDIW expansion, compressed instructions, register retention, dispatch redesign, or witness changes are included. Cargo and wire/schema versions are unchanged; invalidate the incremental artifact cache because generated bytes change.
Acceptance
Cover every low-mask width and neighboring values, signed/unsigned endpoints, zero destination, deterministic full-width samples and far branches.
Run real encoded CKB-VM programs against independent read-only expected values. Measure the old explicit three-instruction sequence against the new generated sequence, separating instruction bytes, padded ELF bytes and VM cycles.
Exercise high policy tags in both editions and optimization levels 0–3. Rebind outer hashes after mutating the seed, shift amount and logical/arithmetic shift; require independent checker rejection.
Reproduce the clean 0.31 baseline and compare the unchanged cost matrix and multi-Script report pair. Preserve frozen budgets and report per-fixture gains or regressions.
Refresh only evidence identities/measurements actually changed by the new ELF, retaining outcomes and acceptance budgets.
Pass dev, ci and backend gates, document the measured outcome and remaining scope, and publish the 0.32 implementation branch.
Implementer: Codex. Compiler/checker engineering review will be recorded with source and test evidence; an implementation-author review is not independent review. Independent release review, version promotion, fresh distribution bundles and release publication remain separate and are not claimed here.
Implemented and pushed on 0.32, 8017a7bd. Implementation: 0e544ce1; clean evidence package: a3fe7440; complete timelock identity refresh and its regression test: 8017a7bd.
The new candidate constructs low masks with 31..63 set bits using addi rd, zero, -1; srli rd, rd, 64-n. It is selected only after exact 64-bit reconstruction succeeds and only when strictly shorter. Existing ties, endpoints, non-mask values and the fixed entry trampoline retain their previous handling. Layout and encoding use the same planner; no scratch register or new ISA extension is required. The artifact cache was advanced because generated bytes change; source editions and wire/schema versions were retained.
Author engineering review and execution evidence:
All 63 mask widths, adjacent/complement values, signed/unsigned endpoints, zero destination and relaxed branches are covered; the deterministic full-width corpus retains 100,000 samples and checks non-growth against the old planner.
Encoded programs run in the pinned CKB-VM. Each rewritten materialization removes four instruction bytes and one executed cycle. Whole-file alignment can absorb the byte saving: one site is 488→488 ELF bytes and 518→517 cycles; 64 sites are 2,256→2,000 bytes and 1,085→1,021 cycles.
Independent-checker tests cover both editions and optimization levels 0..3. Rebound seed, shift-count and logical-to-arithmetic-shift mutations are rejected in both precheck and dispatch sites. The checker already supports SRLI, so its production logic did not need widening.
The archived clean baseline/implementation report pairs pass 6,782 comparable metrics with zero regressions. A fresh comparison on clean final commit 8017a7bd also passes all 6,782 metrics. Budgets and Rust references are unchanged. Existing high-tag fixtures save 1–3 successful transaction cycles; the separate runtime-view fixture improves from 9,896→9,864 ELF bytes and 18,329→18,313 cycles. These are small whole-program gains, not a 33% application speedup.
Scenario identities and measured values were refreshed without changing verdicts or budgets. The initial full backend run correctly rejected stale timelock recipe hashes before node startup. A compile-only run regenerated 69 artifacts, identified exactly three changed recipe artifacts, and supplied the 22 code-hash substitutions. Live replay then exposed 13 stale derived full-Script-hash references in owner fields and witnesses. Those identities were refreshed; a new native ckb-types regression failed on the stale fixture and passes on the corrected one. The corrected bounded local-node replay passed all 43 actions, 17 lock cases, and 26 stateful scenarios (46 steps).
Validation at final commit 8017a7bd:
./scripts/cellscript_gate.sh dev: passed before commit.
./scripts/cellscript_gate.sh ci: passed on clean final commit.
./scripts/cellscript_gate.sh backend: passed on clean final commit, including production-mode local-node replay of 43 actions, 17 lock cases and 26 stateful scenarios (46 steps). Receipt: strict-backend-audit-full-20260927-132820.json.
GitHub CI run 36296786532: manually dispatched for 8017a7bd, still in progress when this completion record was posted; not counted as a passed remote receipt. Local unified CI has passed.
Archived report checksums and the native cost comparator: passed.
This completes the bounded implementation task. #40 and its other research tracks remain open. This is implementation-author engineering evidence, not independent boundary review or release approval; no release/tag or merge into 0.30/0.31 was performed.
Activity
a19q3 commentedon Sep 27, 2026
Implemented and pushed on
0.32, 8017a7bd. Implementation:0e544ce1; clean evidence package:a3fe7440; complete timelock identity refresh and its regression test:8017a7bd.The new candidate constructs low masks with 31..63 set bits using
addi rd, zero, -1; srli rd, rd, 64-n. It is selected only after exact 64-bit reconstruction succeeds and only when strictly shorter. Existing ties, endpoints, non-mask values and the fixed entry trampoline retain their previous handling. Layout and encoding use the same planner; no scratch register or new ISA extension is required. The artifact cache was advanced because generated bytes change; source editions and wire/schema versions were retained.Author engineering review and execution evidence:
8017a7bdalso passes all 6,782 metrics. Budgets and Rust references are unchanged. Existing high-tag fixtures save 1–3 successful transaction cycles; the separate runtime-view fixture improves from 9,896→9,864 ELF bytes and 18,329→18,313 cycles. These are small whole-program gains, not a 33% application speedup.ckb-typesregression failed on the stale fixture and passes on the corrected one. The corrected bounded local-node replay passed all 43 actions, 17 lock cases, and 26 stateful scenarios (46 steps).Validation at final commit
8017a7bd:./scripts/cellscript_gate.sh dev: passed before commit../scripts/cellscript_gate.sh ci: passed on clean final commit../scripts/cellscript_gate.sh backend: passed on clean final commit, including production-mode local-node replay of 43 actions, 17 lock cases and 26 stateful scenarios (46 steps). Receipt:strict-backend-audit-full-20260927-132820.json.8017a7bd, still in progress when this completion record was posted; not counted as a passed remote receipt. Local unified CI has passed.Raw reports, hashes, per-fixture measurements and reproduction instructions.
This completes the bounded implementation task. #40 and its other research tracks remain open. This is implementation-author engineering evidence, not independent boundary review or release approval; no release/tag or merge into 0.30/0.31 was performed.