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

SCP-1514 Extract scripts #2499

Merged
merged 7 commits into from
Jan 12, 2021
Merged

Conversation

j-mueller
Copy link
Contributor

@j-mueller j-mueller commented Nov 27, 2020

  • Add applied validators & monetary policy scripts to emulated node event log
  • Write out all scripts from plutus-use-cases to ${folder} with cabal new-run plutus-use-cases-scripts -- ${folder}

Pre-submit checklist:

  • Branch
    • Commit sequence broadly makes sense
    • Key commits have useful messages
    • Relevant tickets are mentioned in commit messages
  • PR
    • Self-reviewed the diff
    • Useful pull request description
    • Reviewer requested
  • If you updated any cabal files or added Haskell packages:
    • $(nix-build default.nix -A pkgsLocal.updateMaterialized) to update the materialized Nix files
    • Update hie-*.yaml files if needed
  • If you changed any Haskell files:
    • $(nix-shell shell.nix --run fix-stylish-haskell) to fix any formatting issues
  • If you changed any Purescript files:
    • $(nix-shell shell.nix --run fix-purty) to fix any formatting issues

Pre-merge checklist:

  • Someone approved it
  • Commits have useful messages
  • Review clarifications made it into the code
  • History is moderately tidy; or going to squash-merge

@j-mueller j-mueller force-pushed the j-mueller/scp-1514-extract-scripts branch from f1726ee to 4ca46e8 Compare November 27, 2020 13:40
@j-mueller
Copy link
Contributor Author

j-mueller commented Nov 27, 2020

Depends on #2314, so probably no point in reviewing it yet. But it does work and it writes out all the scripts.

, ("multisig-success", MultiSig.succeedingTrace)
, ("multisig-failure", MultiSig.failingTrace)
, ("multisig-sm_1", MultiSigStateMachine.lockProposeSignPay 3 1)
, ("multisig-sm_2", MultiSigStateMachine.lockProposeSignPay 3 3)
Copy link
Contributor

Choose a reason for hiding this comment

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

Just a remark, but I found a lot more distinct validations when I was experimenting with the use cases: for example in the multisig state machine example ten different combinations of scripts appeared (see https://github.com/input-output-hk/plutus/tree/master/plutus-benchmark/validation/data/multisigSM). I just got those by writing out all the scripts appearing in Ledger.Scripts.runScript and manually eliminating duplicates. Admittedly I was never able to work out exactly which stages of the contract those corresponded to! Maybe some of them were for subsidiary transactions?

Copy link
Contributor Author

@j-mueller j-mueller Nov 27, 2020

Choose a reason for hiding this comment

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

Thanks for the link, I didn't know about that README.

lockProposeSignPay k n should result in up to (k+2)*n script validations - there are n rounds, and for each round we have k steps where a signature is added, 1 step for the proposal and 1 step for the payment transition. The actual number may be smaller because attempting to make an invalid transition doesn't produce a transaction.

Actually I think that lockProposeSignPay 3 2 covers all ten variations you got.

The cases where the transition is invalid (for example lockProposeSignPay 2 1) don't result in an invalid transaction because the client realises that the transaction would fail and doesn't submit it.

@j-mueller j-mueller force-pushed the j-mueller/scp-737-refactor branch from a26c48b to 80025d6 Compare December 8, 2020 14:57
@j-mueller j-mueller force-pushed the j-mueller/scp-737-refactor branch 2 times, most recently from 6978c80 to 9f0f729 Compare December 17, 2020 13:43
@j-mueller j-mueller force-pushed the j-mueller/scp-1514-extract-scripts branch from 2ed4410 to 0310d58 Compare December 18, 2020 09:34
@j-mueller j-mueller requested a review from michaelpj December 18, 2020 09:38
@j-mueller j-mueller marked this pull request as ready for review December 18, 2020 09:38
@j-mueller j-mueller force-pushed the j-mueller/scp-1514-extract-scripts branch 2 times, most recently from 0b39381 to e309d1a Compare December 18, 2020 13:40
@j-mueller j-mueller changed the base branch from j-mueller/scp-737-refactor to master December 18, 2020 14:10
@j-mueller j-mueller force-pushed the j-mueller/scp-1514-extract-scripts branch from 3fcd551 to 277ca32 Compare January 11, 2021 09:27
@j-mueller
Copy link
Contributor Author

What do you think of this one @michaelpj ?

Copy link
Contributor

@michaelpj michaelpj left a comment

Choose a reason for hiding this comment

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

Looks fine to me!

@@ -341,3 +349,33 @@ mkIn TxIn{txInRef, txInType} = do
let witness = (Scripts.validatorHash v, Scripts.redeemerHash r, Scripts.datumHash d)
in Validation.TxInInfo txInRef (Just witness) vl
ConsumePublicKeyAddress -> Validation.TxInInfo txInRef Nothing vl

data ScriptType = ValidatorScript | MonetaryPolicyScript
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm, kind of makes me want to turn the various XScript types into a Script (ty :: ScriptType GADT. But that's probably overkill...

Copy link
Contributor

Choose a reason for hiding this comment

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

Or maybe we need a class? Anyway, probably not worth it :D

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I made an issue for it (https://jira.iohk.io/browse/SCP-1667), I think it's a good thing to do

plutus-use-cases/plutus-use-cases.cabal Show resolved Hide resolved
plutus-use-cases/test/Spec/Currency.hs Show resolved Hide resolved
@j-mueller j-mueller merged commit 333f5b9 into master Jan 12, 2021
@j-mueller j-mueller deleted the j-mueller/scp-1514-extract-scripts branch January 12, 2021 07:32
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