Skip to content

Order script_purpose.compare by the ledger's script purpose ordering - #134

Merged
KtorZ merged 1 commit into
aiken-lang:mainfrom
MavenRain:fix/125-redeemers-script-purpose-ordering
Sep 26, 2026
Merged

KtorZ merged 1 commit into
aiken-lang:mainfrom
MavenRain:fix/125-redeemers-script-purpose-ordering

Conversation

@MavenRain

Copy link
Copy Markdown
Contributor

Fixes #125.

Problem

cardano/transaction/script_purpose.compare follows the constructor order of ScriptPurpose (Mint first, Withdraw before Publish). The redeemers list in the script context follows the internal ledger's ordering of script purposes instead: spending purposes come first, and certificate publications come before withdrawals. So sorting or searching redeemers with compare disagrees with the on-chain order.

Fix

  • Reorder the constructor arms of compare to the ledger ordering: Spend < Mint < Publish < Withdraw < Vote < Propose. The within-constructor comparators already match the ledger (inputs are a set ordered by output reference, mint policies are ordered lexicographically, Publish/Propose carry their pointer index, and credential.compare already puts Script below VerificationKey as reward accounts are ordered).
  • Flip the four affected expectations in compare_matrix (done first, to confirm they fail against the old implementation).
  • Reword the redeemers doc note on Transaction, and document the ordering on compare itself.
  • CHANGELOG entry with the breaking-change marker.

Prepared against next since the issue is milestoned v4.0.0; I'd be happy to retarget main instead.

Testing

aiken check: 977 passed, 0 failed. With only the test flips applied, exactly those four assertions fail, so the matrix does exercise the new ordering.

@KtorZ
KtorZ force-pushed the fix/125-redeemers-script-purpose-ordering branch from 64decd1 to b4d8979 Compare September 26, 2026 15:32
@KtorZ
KtorZ changed the base branch from next to main September 26, 2026 15:33
The redeemers list in the script context follows the internal ledger's
ordering of script purposes (Spend < Mint < Publish < Withdraw < Vote <
Propose), not the constructor order of ScriptPurpose.  Adjust compare,
flip the four affected compare_matrix expectations, and reword the
Transaction.redeemers doc note.

Fixes aiken-lang#125

Signed-off-by: Onyeka Obi <softwareengineerasaservant@isurvivable.cv>
@KtorZ
KtorZ force-pushed the fix/125-redeemers-script-purpose-ordering branch from b4d8979 to 8ace46c Compare September 26, 2026 15:42
@KtorZ
KtorZ merged commit a8f3f85 into aiken-lang:main Sep 26, 2026
10 of 11 checks passed
@MavenRain
MavenRain deleted the fix/125-redeemers-script-purpose-ordering branch September 27, 2026 05:16

This branch had an error being deployed

1 failed deployment
github-pages — 8ace46c7 Deployed Sep 26, 2026 by KtorZ via deploy-docs #500
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.

Redeemers assoc list is not actually ordered on ScriptPurpose

2 participants