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

Reference scripts impl - publication of a script #4086

Merged
merged 14 commits into from
Sep 12, 2023

Conversation

paweljakubas
Copy link
Contributor

@paweljakubas paweljakubas commented Aug 10, 2023

  • logic in constructTransaction on api and Cardano.Wallet level
  • extension of TransactionCtx
  • use the added field in mkUnsignedTx
  • fix toCardanoTxOut
  • adjust fee when reference script is present
  • integration test showing reference script publication

Comments

PR tackles publication of reference script to be used in later transactions by using reference inputs when minting/burning.
Script is propagated in blockchain in the first of TxOut of a given transaction. It is shown in integration tests that construction/signing/submitting of such a transaction works, plus when decoding transaction a script is present in witness count as expected.

Issue Number

https://cardanofoundation.atlassian.net/browse/ADP-3090

@paweljakubas paweljakubas self-assigned this Aug 10, 2023
@paweljakubas paweljakubas force-pushed the paweljakubas/adp-3090/reference-scripts-impl branch from bbb30a4 to ba4f707 Compare August 11, 2023 14:03
@paweljakubas paweljakubas force-pushed the paweljakubas/adp-3090/reference-scripts-impl branch from ba4f707 to 2ed37b0 Compare August 22, 2023 10:03
@paweljakubas paweljakubas mentioned this pull request Aug 22, 2023
1 task
@@ -901,6 +906,8 @@ selectAssets era (ProtocolParameters pp) utxoAssumptions outs redeemers
, txChange = view #skeletonChange skeleton
, txPaymentTemplate = view #template <$>
assumedInputScriptTemplate utxoAssumptions
, txReferenceScript =
Copy link
Member

@Anviking Anviking Aug 22, 2023

Choose a reason for hiding this comment

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

As said in DM: The changes to Write.{Balance, SizeEstimation, UTxOAssumptions} shouldn't be needed. As long as the new inline-script-containing TxOut is part of the partial tx given to balanceTx, then balanceTx will know of its size and fee-contribution. So it should just work with the changes reverted.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks! indeed adjusting estimateTxSize was not needed!

@paweljakubas paweljakubas force-pushed the paweljakubas/adp-3090/reference-scripts-impl branch from 2ed37b0 to 491776d Compare August 23, 2023 10:49
@paweljakubas paweljakubas changed the title Reference scripts impl Reference scripts impl - publication of script Aug 23, 2023
@paweljakubas paweljakubas marked this pull request as ready for review August 23, 2023 12:28
@paweljakubas paweljakubas changed the title Reference scripts impl - publication of script Reference scripts impl - publication of a script Aug 23, 2023
@paweljakubas paweljakubas force-pushed the paweljakubas/adp-3090/reference-scripts-impl branch 3 times, most recently from 5830774 to 72ec1b3 Compare August 29, 2023 12:41
@paweljakubas paweljakubas mentioned this pull request Aug 29, 2023
8 tasks
@paweljakubas paweljakubas force-pushed the paweljakubas/adp-3090/reference-scripts-impl branch from 72ec1b3 to 7022fd3 Compare August 30, 2023 06:25
Copy link
Contributor

@HeinrichApfelmus HeinrichApfelmus left a comment

Choose a reason for hiding this comment

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

The implementation and test look sensible to me, but it appears to me that the validation checks when parsing a reference script template do not match the specification. 🤔

(In addition, I believe that the specific validation checks here should not be performed — definitely for the validity interval one; less definitely for the checks on the number of cosigners, as there is some correlation to which minting scripts that we allow.)

wrongMintingTemplate script =
isLeft (validateScriptOfTemplate RecommendedValidation script)
|| countCosigners script /= (1 :: Int)
|| existsNonZeroCosigner script
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are these conditions checked? According to the specification (swagger.yaml), any script template should be acceptable. 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

script template allows more than one cosigner in general. But here we are using script for minting/burning in SHELLEY (not in shared style) so we need to make sure one cosigner is present.

Copy link
Contributor

Choose a reason for hiding this comment

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

That's alright with me — all I'm asking for is that this fact is highlighted in the specification. 🤓📓 Could you amend the documents mint-burn.md and swagger.yaml to describe the allowed values for reference_policy_script_template?

(By definition, if the implementation is different from the specification, that's a bug.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah, ok. done

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for adding a description of the restriction to mint-burn.md — could you add it to swagger.yaml as well?

@paweljakubas paweljakubas force-pushed the paweljakubas/adp-3090/reference-scripts-impl branch 4 times, most recently from a78a6b3 to 5edc807 Compare September 6, 2023 10:45
@paweljakubas paweljakubas force-pushed the paweljakubas/adp-3090/reference-scripts-impl branch from 718ddae to bf1b84a Compare September 8, 2023 12:57
@@ -16,7 +16,7 @@ Specifically:

1. Creation of a transaction output that contains a minting script and is suitable for use as reference input.

In the `reference_policy_script_template` field, you can optionally add a script template. The HTTP endpoint will map this script template into a script using the wallet's policy public key, and this script will be included in the first transaction output (i.e. at index `0`) of the transaction.
In the `reference_policy_script_template` field, you can optionally add a script template. The HTTP endpoint will map this script template into a script using the wallet's policy public key, and this script will be included in the first transaction output (i.e. at index `0`) of the transaction. It is worth mentioning that for shelley wallets script template needs to include one cosigner only.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
In the `reference_policy_script_template` field, you can optionally add a script template. The HTTP endpoint will map this script template into a script using the wallet's policy public key, and this script will be included in the first transaction output (i.e. at index `0`) of the transaction. It is worth mentioning that for shelley wallets script template needs to include one cosigner only.
In the `reference_policy_script_template` field, you can optionally add a script template. The HTTP endpoint will map this script template into a script using the wallet's policy public key, and this script will be included in the first transaction output (i.e. at index `0`) of the transaction. For Shelley-style wallets, the script template must contain a single cosigner only, but it may include time locks.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

wrongMintingTemplate script =
isLeft (validateScriptOfTemplate RecommendedValidation script)
|| countCosigners script /= (1 :: Int)
|| existsNonZeroCosigner script
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for adding a description of the restriction to mint-burn.md — could you add it to swagger.yaml as well?

Copy link
Contributor

@HeinrichApfelmus HeinrichApfelmus left a comment

Choose a reason for hiding this comment

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

Thanks! 😊 No major objections anymore. Could you address the remaining comments? — Small change to description in mint-burn.md, and I would like to see a change to swagger.yaml as well.

@paweljakubas paweljakubas added this pull request to the merge queue Sep 12, 2023
Merged via the queue into master with commit d6ef2b1 Sep 12, 2023
2 checks passed
@paweljakubas paweljakubas deleted the paweljakubas/adp-3090/reference-scripts-impl branch September 12, 2023 16:19
WilliamKingNoel-Bot pushed a commit that referenced this pull request Sep 12, 2023
…etail in a few bullet points the work accomplished in this PR. Before you submit, don't forget to: CODE-OF-CONDUCT.md CONTRIBUTING.md LICENSE MAINTAINERS.md README.md cabal.project default.nix docker-compose.yml docs flake.lock flake.nix floskell.json fourmolu.yaml hie-direnv.yaml justfile lib nix prototypes reports scripts shell.nix specifications test touch.me.CI weeder.dhall Make sure the GitHub PR fields are correct: ✓ Set a good Title for your PR. ✓ Assign yourself to the PR. ✓ Assign one or more reviewer(s). ✓ Link to a Jira issue, and/or other GitHub issues or PRs. ✓ In the PR description delete any empty sections and all text commented in <!--, so that this text does not appear in merge commit messages. CODE-OF-CONDUCT.md CONTRIBUTING.md LICENSE MAINTAINERS.md README.md cabal.project default.nix docker-compose.yml docs flake.lock flake.nix floskell.json fourmolu.yaml hie-direnv.yaml justfile lib nix prototypes reports scripts shell.nix specifications test touch.me.CI weeder.dhall Don't waste reviewers' time: ✓ If it's a draft, select the Create Draft PR option. ✓ Self-review your changes to make sure nothing unexpected slipped through. CODE-OF-CONDUCT.md CONTRIBUTING.md LICENSE MAINTAINERS.md README.md cabal.project default.nix docker-compose.yml docs flake.lock flake.nix floskell.json fourmolu.yaml hie-direnv.yaml justfile lib nix prototypes reports scripts shell.nix specifications test touch.me.CI weeder.dhall Try to make your intent clear: ✓ Write a good Description that explains what this PR is meant to do. ✓ Jira will detect and link to this PR once created, but you can also link this PR in the description of the corresponding Jira ticket. ✓ Highlight what Testing you have done. ✓ Acknowledge any changes required to the Documentation. --> - [x] logic in `constructTransaction` on api and `Cardano.Wallet` level - [x] extension of `TransactionCtx` - [x] use the added field in `mkUnsignedTx` - [x] fix `toCardanoTxOut` - [x] adjust fee when reference script is present - [x] integration test showing reference script publication ### Comments PR tackles publication of reference script to be used in later transactions by using reference inputs when minting/burning. Script is propagated in blockchain in the first of TxOut of a given transaction. It is shown in integration tests that construction/signing/submitting of such a transaction works, plus when decoding transaction a script is present in witness count as expected. <!-- Additional comments, links, or screenshots to attach, if any. --> ### Issue Number https://cardanofoundation.atlassian.net/browse/ADP-3090 <!-- Reference the Jira/GitHub issue that this PR relates to, and which requirements it tackles. Note: Jira issues of the form ADP- will be auto-linked. --> Source commit: d6ef2b1
github-merge-queue bot pushed a commit that referenced this pull request Sep 18, 2023
<!--
Detail in a few bullet points the work accomplished in this PR.

Before you submit, don't forget to:

* Make sure the GitHub PR fields are correct:
   ✓ Set a good Title for your PR.
   ✓ Assign yourself to the PR.
   ✓ Assign one or more reviewer(s).
   ✓ Link to a Jira issue, and/or other GitHub issues or PRs.
   ✓ In the PR description delete any empty sections
     and all text commented in <!--, so that this text does not appear
     in merge commit messages.

* Don't waste reviewers' time:
   ✓ If it's a draft, select the Create Draft PR option.
✓ Self-review your changes to make sure nothing unexpected slipped
through.

* Try to make your intent clear:
   ✓ Write a good Description that explains what this PR is meant to do.
   ✓ Jira will detect and link to this PR once created, but you can also
     link this PR in the description of the corresponding Jira ticket.
   ✓ Highlight what Testing you have done.
   ✓ Acknowledge any changes required to the Documentation.
-->

- [x] update `ApiMinBurnFromInput` to accommodate policy id
- [x] update swagger and spec
- [x] regenerate golden and make sure unit tests pass
- [x] incorporate new `ApiMinBurnData` inside `constructTransaction`
- [x] introduce ScriptSource
- [x] handle from input case to `mkUnsignedTx`
- [x] adjust `mkUnsignedTx`
- [x] show the case in integration testing`

### Comments

builds on top of
#4086

<!-- Additional comments, links, or screenshots to attach, if any. -->

### Issue Number
adp-3090

<!-- Reference the Jira/GitHub issue that this PR relates to, and which
requirements it tackles.
  Note: Jira issues of the form ADP- will be auto-linked. -->
WilliamKingNoel-Bot pushed a commit that referenced this pull request Sep 18, 2023
…the work accomplished in this PR. Before you submit, don't forget to: CODE-OF-CONDUCT.md CONTRIBUTING.md LICENSE MAINTAINERS.md README.md cabal.project default.nix docker-compose.yml docs flake.lock flake.nix floskell.json fourmolu.yaml hie-direnv.yaml justfile lib nix prototypes reports scripts shell.nix specifications test touch.me.CI weeder.dhall Make sure the GitHub PR fields are correct: ✓ Set a good Title for your PR. ✓ Assign yourself to the PR. ✓ Assign one or more reviewer(s). ✓ Link to a Jira issue, and/or other GitHub issues or PRs. ✓ In the PR description delete any empty sections and all text commented in <!--, so that this text does not appear in merge commit messages. CODE-OF-CONDUCT.md CONTRIBUTING.md LICENSE MAINTAINERS.md README.md cabal.project default.nix docker-compose.yml docs flake.lock flake.nix floskell.json fourmolu.yaml hie-direnv.yaml justfile lib nix prototypes reports scripts shell.nix specifications test touch.me.CI weeder.dhall Don't waste reviewers' time: ✓ If it's a draft, select the Create Draft PR option. ✓ Self-review your changes to make sure nothing unexpected slipped through. CODE-OF-CONDUCT.md CONTRIBUTING.md LICENSE MAINTAINERS.md README.md cabal.project default.nix docker-compose.yml docs flake.lock flake.nix floskell.json fourmolu.yaml hie-direnv.yaml justfile lib nix prototypes reports scripts shell.nix specifications test touch.me.CI weeder.dhall Try to make your intent clear: ✓ Write a good Description that explains what this PR is meant to do. ✓ Jira will detect and link to this PR once created, but you can also link this PR in the description of the corresponding Jira ticket. ✓ Highlight what Testing you have done. ✓ Acknowledge any changes required to the Documentation. --> - [x] update `ApiMinBurnFromInput` to accommodate policy id - [x] update swagger and spec - [x] regenerate golden and make sure unit tests pass - [x] incorporate new `ApiMinBurnData` inside `constructTransaction` - [x] introduce ScriptSource - [x] handle from input case to `mkUnsignedTx` - [x] adjust `mkUnsignedTx` - [x] show the case in integration testing` ### Comments builds on top of #4086 <!-- Additional comments, links, or screenshots to attach, if any. --> ### Issue Number adp-3090 <!-- Reference the Jira/GitHub issue that this PR relates to, and which requirements it tackles. Note: Jira issues of the form ADP- will be auto-linked. --> Source commit: 6157932
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