Add support for Plutus scripts on compatible Tx - #1282
Draft
carbolymer wants to merge 4 commits into
Draft
Conversation
The ledger resolves the Proposing purpose's redeemer pointer index against proposalProceduresTxBodyL, an OSet whose Indexable instance walks the underlying StrictSeq in insertion order (StrictSeq.findIndexL), never Ord order. compareWitnesses' WitProposal branch instead sorted proposals by their Ord instance before assigning indices, so makeUnsignedTx could embed a redeemer pointer at the wrong index whenever a caller's OMap insertion order differed from Ord order. Fix the WitProposal branch to a constant LT, mirroring WitTxCert's existing stable no-op, which preserves insertion order through the stable sort in createIndexedPlutusScriptWitnesses.
The ledger resolves the Certifying purpose's redeemer pointer index against certsTxBodyL's full StrictSeq, which contains every certificate - witnessed and unwitnessed alike - in original order. Unwitnessed certs still consume an index slot there (indexCertificatesWith already gets this right for the Compatible and legacy Fee builders). extractWitnessableCertificates instead filtered out unwitnessed certs before handing the list to createIndexedPlutusScriptWitnesses, so a Plutus-witnessed cert's assigned index only counted its position among OTHER WITNESSED certs, undercounting by the number of preceding unwitnessed certs. Fix by keeping every certificate in the list, pairing unwitnessed ones with a placeholder credential and AnyKeyWitnessPlaceholder so their index slot is still consumed by createIndexedPlutusScriptWitnesses' zip [0 ..] (which already filters back down to plutus-witnessed entries afterwards, discarding the placeholders once their slot has been counted).
Replace the positional-arguments-plus-CompatibleTxExtraContent signature with a single CompatibleTxBodyContent record covering exactly the features Compatible implements, named after the experimental TxBodyContent vocabulary. Reuse the experimental Witnessable machinery for spending, certifying and proposing redeemer pointer indexing, replacing the bespoke ScriptWitnessIndex-based plumbing. Add regression tests for the proposal and certificate redeemer ordering fixes, and harden getVotes against voter-map gaps.
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.
Context
Additional context for the PR goes here. If the PR fixes a particular issue please provide a link to the issue.
How to trust this PR
Highlight important bits of the PR that will make the review faster. If there are commands the reviewer can run to observe the new behavior, describe them.
Checklist
.changes/