-
Notifications
You must be signed in to change notification settings - Fork 23
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
Deprecate serialiseTxLedgerCddl
#534
Conversation
4782bcb
to
b4d72e8
Compare
cardano-api/test/cardano-api-test/Test/Cardano/Api/Typed/CBOR.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.
Looking good but we should take this a little further.
@@ -134,6 +134,7 @@ instance Error TextEnvelopeCddlError where | |||
TextEnvelopeCddlErrByronKeyWitnessUnsupported -> | |||
"TextEnvelopeCddl error: Byron key witnesses are currently unsupported." | |||
|
|||
{-# DEPRECATED serialiseTxLedgerCddl "Use 'serialiseToTextEnvelope' from 'Cardano.Api.SerialiseTextEnvelope' instead." #-} | |||
serialiseTxLedgerCddl :: ShelleyBasedEra era -> Tx era -> TextEnvelopeCddl |
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.
We can go further here. We can have serialiseTxLedgerCddl
call serialiseToTextEnvelope
and remove some of the additional unnecessary types e.g TextEnvelopeCddl
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.
Like in this commit?
It looks like this is likely a breaking change. Is that ok?
b773202
to
39eb80f
Compare
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.
LGTM. Can you make sure that tests in cardano-testnet and cardano-cli pass prior to merge?
39eb80f
to
d4d32e4
Compare
Co-authored-by: Clément Hurlin <[email protected]>
c74c589
to
5743a60
Compare
serialiseTxLedgerCddl
serialiseTxLedgerCddl
128e9e6
to
c95aad2
Compare
c73d277
to
0266459
Compare
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.
Nice work 👍
-- | This is a backwards-compatibility patch to ensure that old envelopes | ||
-- generated by 'serialiseTxLedgerCddl' can be deserialised after switching | ||
-- to the 'serialiseToTextEnvelope'. | ||
legacyComparison :: TextEnvelopeType -> TextEnvelopeType -> Bool |
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.
Nice 👍 . What we want to do is complain in the cli when a "legacy" text envelope type is used. The complaint would instruct them to convert the type
field to the "correct" type. However before we do this, we should decide on a type format. I.e should we use the Witnesses
vs Unwitnessed
distinction or use the previous Tx $era
format? You could start a discussion in discord on this.
Changelog
Context
In the past, we had an intermediate tx body format (sometimes called the intermediate cli format). This format did not adhere to the CDDL format in the ledger. So
serialiseTxLedgerCddl
was introduced to remedy this, with the aim of dropping the "intermediate cli format".We have completely dropped the "intermediate cli format" so both functions will serialize txs that adhere to the ledger's CDDL format.
Therefore
serialiseTxLedgerCddl
is no longer necessary.This PR deprecates it and reimplements
serialiseTxLedgerCddl
to useserialiseToTextEnvelope
, which causes slight changes to the formats, seeHow to trust this PR
below for more detail.cardano-api
serialiseTxLedgerCddl
#534cardano-cli
serialiseTxLedgerCddl
cardano-cli#772cardano-node
serialiseTxLedgerCddl
cardano-node#5867How to trust this PR
Make sure that the message makes sense, that the functions deprecated are the one we want to deprecate, and that there are no other functions associated that we want to deprecate. Also that we want to override the deprecation in the tests (which makes sense to me, but maybe we want to remove or adapt the tests instead).
Also make sure the amount of backwards compatibility adaptors is adequate and in the right places.
Migrating to using
serialiseToTextEnvelope
changes the serialization format in three ways:description
: is provided by current functions but is a parameter toserialiseToTextEnvelope
:deserialiseFromTextEnvelope
because it ignores the field, so we get compatibility for free.serialiseToTextEnvelope
to ensure old functions keep producing the samedescription
just to avoid breaking golden tests at this point.type
: is deduced from theHasTextEnvelope
instance of the serialised type, butserialiseTxLedgerCddl
has hardcoded types which do not matchHasTextEnvelop
instances:deserialiseToTextEnvelope
to loosely compare types (seelegacyComparison
function) allowing for support for theserialiseTxLedgerCddl
versions.serialiseTxLedgerCddl
by wrappingserialiseToTextEnvelope
and patch the output to produce the old types too. This is, again, just to avoid breaking golden tests at this point.rawCBOR
: is serialised pretty much identically byserialiseToTextEnvelope
with one exception:serialiseWitnessLedgerCddl
encodesKeyWitness
slightly differently thanserialiseToTextEnvelope
. In fact,deserialiseWitnessLedgerCddl
relies ondescription
to decide on the constructor to deserialise to ofKeyWitness
. This is a breaking change in the format and is not parsable bydeserialiseFromTextEnvelope
because it ignores thedescription
. ChangingdeserialiseFromTextEnvelope
to support this would be very patchy. So, this PR:serialiseWitnessLedgerCddl
to directly useserialiseToTextEnvelope
(while keeping descriptions).deserialiseWitnessLedgerCddl
to usedeserialiseFromTextEnvelope
and to use the old decoding when that fails (this is done by the sub-functionlegacyDecoding
).These decisions provide a fair level of backwards compatibility but, at the same time, CBOR produced after the PR will be compatible with
deserialiseFromTextEnvelope
so functions inSerialiseLedgerCddl
will become less necessary over time.Also, to check these claims, you can see the results of running the tests in
cardano-testnet
andcardano-cli
that are in the PRs linked in theContext
section above.Checklist