-
Notifications
You must be signed in to change notification settings - Fork 720
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
Rewrite the Scripts API module and use it in the CLI to support the new script language version #2141
Merged
Conversation
This file contains 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
Split the Shelley genesis example from the script examples. They are mostly unrelated and use very different imports. We will shortly rewrite the script examples.
It contains a CardanoEra but hides the era type arg. This allows us to use CardanoEra in contexts where we do not statically know what era it will be. This is useful for example in error reports (where it is inconvenient and unnecessary to parametrise by era) or in the CLI when selecting an era to use.
This also allows eliminating the withCardanoEra helper, since simply pattern matching on AnyCardanoEra does the same thing.
We will actually use a different impl for scripts, using JSON format not the text envelope binary format. The rule for the CLI is that we use input scripts in JSON, but witnesses in binary (even for witnesses consisting of only scripts). Also remove unused readFileInAnyShelleyBasedEra.
Jimbo4350
reviewed
Nov 30, 2020
-- of 'SimpleScriptV1' plus new atomic predicates: | ||
-- | ||
-- * require the time be before a given slot number | ||
-- * require the time be before a given slot number |
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.
require the time be after a given slot number
Jimbo4350
approved these changes
Nov 30, 2020
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!
This makes a change similar to the one we made with addresses recently. With addresses we identified that there are two independent dimensions: the address type (i.e. Byron vs Shelley address), and the era in which the address is valid. With scripts the dimensions are the language, and the era in which the language is supported. So with this change we can talk about script languages independently of the era in which those languages are supported. We also gain a type covering all language, irrespective of era, which is useful as an intermediate type for converting from weakly typed input (e.g. in the CLI) to the strongly-typed internal types. Another advantage of splitting the dimensions this way is that it will be easier to add new eras that inherit all the earlier languages, especially if they do not add new eras themselves. Also add numerous utility functions for handling scripts in language-generic and era-generic ways. Though right now we only support the simple script language, structure the types so that it is clear where to add Plutus once it arrives. Do the minimal updates to the CLI. There is more cleanup that can be done here, but that can wait for later commits.
We use deriving (Show, IsString) via UsingRawBytesHex for all the verification and signing keys, but we had missed it for the key hash types. Use this to simplify the multi-sig script examples.
We have several clones of this util open-coded in the cli. This will help clean those up.
This is consistent with making tx witnesses. Add reusable readFileScriptInAnyLang
Replace the impl in readWitnessSigningData with the shared util.
dcoutts
force-pushed
the
dcoutts/api-script-langs
branch
from
November 30, 2020 09:41
7d91fb8
to
7c99d98
Compare
bors merge |
Build succeeded: |
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.
This makes a change similar to the one we made with addresses recently.
With addresses we identified that there are two independent dimensions:
the address type (i.e. Byron vs Shelley address), and the era in which
the address is valid.
With scripts the dimensions are the language, and the era in which the
language is supported. So with this change we can talk about script
languages independently of the era in which those languages are
supported. We also gain a type covering all language, irrespective of
era, which is useful as an intermediate type for converting from weakly
typed input (e.g. in the CLI) to the strongly-typed internal types.
Another advantage of splitting the dimensions this way is that it will
be easier to add new eras that inherit all the earlier languages,
especially if they do not add new eras themselves.
Though right now we only support the simple script language, structure
the types so that it is clear where to add Plutus once it arrives.
Update the CLI to use this. The effect is that it now supports the
appropriate languages in each era.