-
Notifications
You must be signed in to change notification settings - Fork 88
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
Add golden plutus scripts #772
Conversation
This ensures we do not accidentally change scripts and also persist the binary scripts (in case we cannot reproduce them).
Transactions CostsSizes and execution budgets for Hydra protocol transactions. Note that unlisted parameters are currently using
Script summary
Cost of Init Transaction
Cost of Commit TransactionCurrently only one UTxO per commit allowed (this is about to change soon)
Cost of CollectCom Transaction
Cost of Close Transaction
Cost of Contest Transaction
Cost of Abort TransactionSome variation because of random mixture of still initial and already committed outputs.
Cost of FanOut TransactionInvolves spending head output and burning head tokens. Uses ada-only UTxO for better comparability.
|
ffb1380
to
fb7aaa4
Compare
We do not gain anything from the files, when the hashes don't match and we want to acknowledge, we would just drop the golden file and have it regenerated by the test.
The text envelope of persisted, golden scripts is a good location to give a full description of what script is actually included. For this, let's also incorporate the git describe output, as it gives a very good indication. Ideally, we change them to the actual tag, but even if not it's a good starting point.
fb7aaa4
to
7a8817c
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.
This review tries to apply the perfection game protocol
I will describe what I like about this P.R. and then what improvement I can think of to make it perfect.
Ask for clarifications if my comments are not clear.
If you disagree with my comments, just ignore them and don’t answer or explain.
Hence I, in advance, approve the P.R.
What I like about this P.R.:
- I just love it. It is a tremendous improvement to our code base
For me to find it perfect you would have to:
- see other improvement proposals inline
-- | Get the applied head minting policy script given a seed 'TxOutRef'. | ||
mintingPolicyScript :: TxOutRef -> Script | ||
mintingPolicyScript txOutRef = | ||
getMintingPolicy . mkMintingPolicyScript $ | ||
$$(PlutusTx.compile [||\vInitial vHead ref -> wrapMintingPolicy (validate vInitial vHead ref)||]) | ||
`PlutusTx.applyCode` PlutusTx.liftCode Initial.validatorHash | ||
`PlutusTx.applyCode` PlutusTx.liftCode Head.validatorHash | ||
`PlutusTx.applyCode` PlutusTx.liftCode txOutRef |
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.
I would use the new unappliedMintingPolicy
function here. Something in the line of (doesn't compile nor work):
-- | Get the applied head minting policy script given a seed 'TxOutRef'. | |
mintingPolicyScript :: TxOutRef -> Script | |
mintingPolicyScript txOutRef = | |
getMintingPolicy . mkMintingPolicyScript $ | |
$$(PlutusTx.compile [||\vInitial vHead ref -> wrapMintingPolicy (validate vInitial vHead ref)||]) | |
`PlutusTx.applyCode` PlutusTx.liftCode Initial.validatorHash | |
`PlutusTx.applyCode` PlutusTx.liftCode Head.validatorHash | |
`PlutusTx.applyCode` PlutusTx.liftCode txOutRef | |
-- | Get the applied head minting policy script given a seed 'TxOutRef'. | |
mintingPolicyScript :: TxOutRef -> Script | |
mintingPolicyScript txOutRef = | |
getMintingPolicy . mkMintingPolicyScript $ | |
unappliedMintingPolicy | |
`PlutusTx.applyCode` PlutusTx.liftCode txOutRef |
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.
Good point. I only made the unappliedMintingPolicy
work later and forgot to inline it :)
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.
BAM!
🥇 Adds our scripts in a binary form as golden files. This is also useful in case we can't reproduce them exactly as they were originally compiled using plutus-tx; which is not unlikely given we need to have the exact same version of plutus-tx, all its dependencies, and GHC.
🥇 Adds golden test suite to ensure we do not accidentally change scripts and also helps in writing the plutus scripts of the Hydra protocol as blobs into the repository.
First execution:
When flipping a
$
in the code:Some more notes in the logbook.