Refactor dMint v2 contract layout and fix bytecode issues - #23
Merged
Antares-RXD merged 4 commits intoApr 11, 2026
Merged
Conversation
…atch - Remove redundant clearTimeout(this.connectedTimeout) from onOpen() - Keep single clearTimeout in onClose() to prevent timeout leak - Update patch hash in pnpm-lock.yaml to reflect simplified patch
… bytecode-embedded DAA params - Remove variable state item count; all v2 contracts now use 10 state items - Add lastTime to state layout (height, contractRef, tokenRef, maxHeight, reward, algoId, daaMode, targetTime, lastTime, target) - Move halfLife from state to bytecode constant in ASERT DAA implementation - Split Part B into B1 (PoW extraction), B2 (target comparison), B4 (cleanup), and dynamic DAA bytecode - Add buildAsertDaaBytecode()
The code sequence is OP_OUTPOINTTXHASH OP_INPUTBYTECODE <N> OP_PICK. OP_INPUTBYTECODE pushes an extra item onto the stack before the PICK, so all PICK/ROLL indices must be +1 vs. the naive stateItemCount formula. Before (wrong): contractRefPick = stateItemCount-1 (9 for 10 items) After (correct): contractRefPick = stateItemCount (10 for 10 items) Similarly: ioPick: +3 -> +4, nonceRoll: +4 -> +5 This caused 'mandatory-script-verify-flag-failed (Operation not valid with the current stack size)' on broadcast because OP_9 PICK was reaching tokenRef instead of contractRef at runtime. Also adds inputBytecode to the assertDmintPreimageLayout stack simulation so the self-verification catches future index drift.
The original Part A bytecode 5175c0c8 included both OP_INPUTINDEX (c0) and OP_OUTPOINTTXHASH (c8). After Part A execution, txHash is consumed by OP_CAT with contractRef, but inputIndex (from c0) remains on the stack, shifting B.2's OP_1 PICK away from target and breaking the DAA. Fix: remove c0 from buildDmintPreimageBytecodePartA so the code starts with 5175c8 only. With a single push opcode (c8=OP_OUTPOINTTXHASH), the stack is clean after Part A and OP_1 PICK in B.2 correctly reaches the target. Indices remain stateItemCount-1 / +3 / +4. Update assertDmintPreimageLayout simulation to use outpointTxHash (matching runtime) and update test expectations accordingly.
Antares-RXD
merged commit Apr 11, 2026
0a8b33d
into
RadiantBlockchain-Community:master
1 of 3 checks passed
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.
No description provided.