Skip to content
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

Update Cardano.Api.Script in preparation for the Alonzo era #2649

Merged
merged 12 commits into from
May 20, 2021

Conversation

Jimbo4350
Copy link
Contributor

@Jimbo4350 Jimbo4350 commented Apr 23, 2021

No description provided.

@johnalotoski
Copy link
Contributor

Adding a hydra-dont-build label to this PR as it's continually failing eval in hydra, but consuming memory each time it tries. Please feel free to remove the label when you need to continue work on this.

@Jimbo4350
Copy link
Contributor Author

Adding a hydra-dont-build label to this PR as it's continually failing eval in hydra, but consuming memory each time it tries. Please feel free to remove the label when you need to continue work on this.

Thanks @johnalotoski !

@Jimbo4350 Jimbo4350 force-pushed the jordan/adjust-script-module-for-alonzo branch 5 times, most recently from 0a35977 to 7176971 Compare May 14, 2021 08:39
@dcoutts dcoutts force-pushed the jordan/adjust-script-module-for-alonzo branch from 7176971 to 2868a7d Compare May 17, 2021 00:45
@dcoutts
Copy link
Contributor

dcoutts commented May 17, 2021

Rebased on top of #2657 and significantly extended.

dcoutts and others added 12 commits May 20, 2021 15:41
To the existing PlutusScriptVersion type which previously had no
constructors at all.

Co-authored-by: Jordan Millar <jordan.millar@iohk.io>
Needed for using Plutus script witnesses.

Co-authored-by: Jordan Millar <jordan.millar@iohk.io>
The old ones and of course Plutus

Co-authored-by: Jordan Millar <jordan.millar@iohk.io>
Add the PlutusScript type itself, and adjust the existing PlutusScript
constructor in the Script type to use it.

Add serialisation instances for PlutusScript and extend the existing
serialisation instances with the Plutus case.

Extend the existing conversion functions.

This patch does not cover JSON instances.

Co-authored-by: Jordan Millar <jordan.millar@iohk.io>
Change the CBOR round-trip tests to be per-language rather than per-era.

We are going to remove the CBOR instances for ScriptInAnyLang and
ScriptInEra, so we need the tests to cover the Script type instead, for
each language.
Instead of testing per-era, we test per language instead.

This means we rely on the JSON instances for the SimpleScript type
rather than the ScriptInEra type. In future the ScriptInEra type will
not support JSON serialisation because that type is being extended to
contain Plutus scripts, and Plutus scripts do not have a native JSON
representation.
And use it in more places.

The existing one supported only the JSON format for the simple script
language. This is a problem for Plutus since it does not have such a
JSON format.

The new one supports both the existing simple script JSON format and
also the JSON text envelope format for all script languages, inclduing
Plutus scripts.

This means the simple scripts can be either in binary (via text
envelope) or in JSON, while the Plutus scripts can only be binary (via
the text envelope).

This change means the CLI no longer relies on JSON instances fpr the
Script, or ScriptInEra or ScriptInAnyLang types. It only needs the JSON
instances for the SimpleScript type. This is important because those
other script types have to cover Plutus and Plutus does not have such a
JSON representation.
These instances are unnecessary, and are not used by the CLI. It's a bit
unhelpful to provide such instances since they are not compatible with
the the formats used by the Script instance for SerialiseAsCBOR.

The (Script lang) instance for SerialiseAsCBOR instance provides a
binary format and corresponding HasTextEnvelope type names for each
language individually.

The ScriptInAnyLang (and hence ScriptInEra) instance has to provide a
single binary format for all languages, which means it has to use tags
and is a different binary format. Providing this format is unhelpful
because it is different and if it does get used by tools could lead to
confusing compatibility / interop problems.
These types have to cover both the simple script languages and the
Plutus language. Only the simple script language supports an external
JSON representation. The Plutus languages only have a binary
representation. Hence with the addition of Plutus support it is no
longer possible to provide such JSON instances.

This is not a problem because the SimpleScript type still has JSON
instances, and those can be used where appropriate, such as in the CLI.
Add a new PlutusScriptWitness constructor to the existing ScriptWitness
type.

Also add ScriptDatum, ScriptRedeemer and a placeholder ScriptData type.

Co-authored-by: Jordan Millar <jordan.millar@iohk.io>
@Jimbo4350 Jimbo4350 force-pushed the jordan/adjust-script-module-for-alonzo branch from 4b9ac3e to 238c2c6 Compare May 20, 2021 14:49
@Jimbo4350 Jimbo4350 marked this pull request as ready for review May 20, 2021 14:51
Copy link
Contributor

@dcoutts dcoutts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉

@dcoutts
Copy link
Contributor

dcoutts commented May 20, 2021

bors merge

@iohk-bors
Copy link
Contributor

iohk-bors bot commented May 20, 2021

@iohk-bors iohk-bors bot merged commit 1022092 into master May 20, 2021
@iohk-bors iohk-bors bot deleted the jordan/adjust-script-module-for-alonzo branch May 20, 2021 17:47
iohk-bors bot added a commit that referenced this pull request May 24, 2021
2642: Update Cardano.Api.Tx in preparation for Alonzo r=dcoutts a=Jimbo4350

Depends on: 
1. #2657
2. #2400 
3. #2699
4. #2649

Co-authored-by: John Ky <john.ky@iohk.io>
Co-authored-by: Duncan Coutts <duncan@well-typed.com>
Co-authored-by: Jordan Millar <jordan.millar@iohk.io>
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.

3 participants