-
Notifications
You must be signed in to change notification settings - Fork 155
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding support for a generalized Utxow rule #2176
Conversation
shelley/chain-and-ledger/executable-spec/src/Cardano/Ledger/AuxiliaryData.hs
Outdated
Show resolved
Hide resolved
alonzo/impl/test/lib/Test/Cardano/Ledger/Alonzo/Serialisation/Generators.hs
Outdated
Show resolved
Hide resolved
shelley/chain-and-ledger/executable-spec/src/Shelley/Spec/Ledger/Address.hs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @TimSheard , this is a ton of great work! There are a few comments that can be removed, but besides that this looks really good!
wrote a generic version. Replaced Shelley, Allegra, and Mary with this generic version. Next step write an Alonzo version that calls the generice version, and then does Alonzo stuff.
Still to do: Add a new type for errors in the Utxow rule. Make some Hasfield instances
The Alonzo Script datatype had a stub for Plutus scripts. Imported the right type and completed Show, Eq, PrettyA, ToCBOR and FromCBOR instances. The Uxtow rule is now complete. Introduced AlonzoPredFail the UtxoW PredicateFailure type for the Alonzo era. It embeds the PredicateFaliure type from the Shelley and ShelleyMa Eras. Wrote Show, Eq, ToCBOR and FromCBOR instances. The Utxow rule now uses this type for Failures. Generalized the ShelleyStyleWitness to lift from one PredicateFailure type to another so it could be reused in any ERa that uses this style of PredicateFailure Embedding.
The missing HasField instances needed for the Uxtow rule were added. Generalized the ValidateScript class to have the method 'scriptPrefixTag' and made a default method for 'hashScript' Had to move a few things in the Shelley Era to make the dependencies work out.
The ValidateScript class was moved from Shelley.Tx(..) to Cardano.Ledger.Era(..). The field had it type changed to scriptPrefixTag :: Core.Script era -> BS.ByteString this way the tag written can be chosen dynamically by looking at the script. Filled in the mising CBOR instances fo the PredicateFailure for Utxos rule. Wrote roundtrip serilaization tests for all of the new PredicateFailure type. BIG TODO, some Alonzo era PredicateFailure type encode Scripts, and Scripts do not have FromCBOR instances (they have FromCBOR(Annotator Script) instance.) We will have to address this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bunch of spurious commented lines that should go, but otherwise looks great.
) => | ||
AlonzoPredFail era -> | ||
Encode 'Open (AlonzoPredFail era) | ||
encodePredFail (Embed x) = Sum Embed 0 !> E toCBOR x |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be better to flatten the encoding here, since we'd like the implementation detail (that we're wrapping) to be hidden. Shouldn't need any extra boilerplate, I think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a bit involved, since the CBOR instances for (UtxowPredicateFailure era) in the Shelley era (ie. the type of x in (Embed x)) is written by hand, so making it inline would require going back and changing that. For a future time? Even if we flattened in CBOR, it remains unflattened (and visible) in the type AlonzoPredFail.
First steps in writing a generalized Utxow rule that can be applied to the Alonzo Era.
Generalized wisFromWitnessSet (now witsFromTxWitnesses), scriptsNeeded, validateAuxiliaryData, validateScript, verifiedWits. Made a new WellFormed constraint
HasField "adHash" (Core.TxBody era) (StrictMaybe (AuxiliaryDataHash (Crypto era)))"