feat: gate 256-bit A/B arithmetic behind AT creation version 3#12
Merged
Conversation
…ersion 3 Introduce AT creation version 3, which keeps version 2's page-size semantics and differs only in function code availability. The eight 256-bit A/B arithmetic function codes (ADD_A_TO_B..DIV_B_BY_A, 0x0140-0x0147) now declare minVersion 3 and FunctionCode.execute() throws IllegalFunctionCodeException for ATs created with an earlier version, exactly as an unknown function code would - verified bit-identical (final packed machine state, steps, PC, balance) against pre-batch commit 070e22c for raw codes 0x0140-0x0148 under version 2. Version 3 is accepted by creation-bytes parsing and toCreationBytes, with a round-trip test. ABArithmeticFunctionCodeTests now run under a version 3 header, plus explicit version-2 fault tests (mutation-checked: removing the gate makes them fail). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
Summary
Gates the eight 256-bit A/B arithmetic function codes
0x0140-0x0147(added in #11) behind AT creation version 3, so a consumer chain can control their availability by AT version rather than having them execute unconditionally the moment the jar is repinned.minVersionfield onFunctionCode; the eight arithmetic codes declareminVersion = 3. The gate is the first statement ofFunctionCode.execute()— before any signature/value checks or state mutation — throwingIllegalFunctionCodeExceptionfor version-1/2 ATs.MachineStategains creation version 3, byte-identical to version 2 except opcode availability; creation-bytes parse/round-trip accept it.Why this matters (consensus)
Without version gating, repinning a consumer chain to this jar is a silent flag-day: bytecode containing
0x0140-0x0147faults on the old jar but executes on the new one. Gating by creation version lets the consumer chain reject version-3 deploys until a coordinated activation height, then allow them — no ambiguous window.Backward compatibility (proven)
Version-1/2 execution is bit-identical to the current pinned
33df17djar: for those versions the arithmetic codes fault at the version check exactly as unknown codes did before, charging the same steps, writing no registers, entering the same fatal-error path (only log text differs). Verified by a byte-for-byte machine-state comparison harness against pre-batch070e22c.Verification
mvn -B clean verify: 211 tests, 0 failures.The dual-model review's finding: gating execution by version is necessary but not sufficient — the consuming chain (qortium-core) must also reject deployment of version-3 creation bytes before the activation height (
DeployAtTransaction), or a v3DEPLOY_ATbroadcast pre-activation forks upgraded vs un-upgraded nodes. That Core-side deploy-gate + repin is the companion "phase-2" change. This jar PR is correct in isolation and can be reviewed/merged, but Core must not be repinned to it until the phase-2 deploy-gate lands.🤖 Generated with Claude Code