Order script_purpose.compare by the ledger's script purpose ordering - #134
Open
MavenRain wants to merge 1 commit into
Open
Order script_purpose.compare by the ledger's script purpose ordering#134MavenRain wants to merge 1 commit into
MavenRain wants to merge 1 commit into
Conversation
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>
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.
Fixes #125.
Problem
cardano/transaction/script_purpose.comparefollows the constructor order ofScriptPurpose(Mintfirst,WithdrawbeforePublish). 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 withcomparedisagrees with the on-chain order.Fix
compareto 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/Proposecarry their pointer index, andcredential.comparealready putsScriptbelowVerificationKeyas reward accounts are ordered).compare_matrix(done first, to confirm they fail against the old implementation).redeemersdoc note onTransaction, and document the ordering oncompareitself.Prepared against
nextsince the issue is milestoned v4.0.0; I'd be happy to retargetmaininstead.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.