-
Notifications
You must be signed in to change notification settings - Fork 87
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
Validator can assume head output is the first one #700
Validator can assume head output is the first one #700
Conversation
5b398c8
to
cc7f8f4
Compare
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.
|
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.
The fact that we need to add artificial change outputs to our off-chain code in some tests is smelly and must be changed IMO.
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'm expecting the author of the P.R. to just not include my ideas if they disagree with them without any form of justification. Hence I, in advance, approve the P.R. Please ask for clarifications if my comments are unclear.
I will try to extensively use the suggest change feature of GitHub as I believe this is the most efficient way to upload data from my brain to the authors' brains. That being said, the suggestions I will write will probably not compile or pass the test so do not just accept them but consider them for what they are: the description of an improvement to make the P.R. perfect to me.
What I like about this P.R.:
- I can see a small list of clear and small commits which makes the review smoother as I can just review one commit at a time and understand how you walked through the change
For me to find it perfect you would have to:
- amend the commit
Use foldr when traversing inputs
to explain why it's more interesting to do so - amend the commits with failing tests to make them pass. For instance, now, looking at the commit history, I can't figure out how a commit named
Add a note related to change outputs in collectCom
can make the test pass when they were not passing in the previous commit
*amend the commitAdd a note related to change outputs in collectCom
to make two separate commits, one only adding the note and another one adding the production code and explaining why we add this code. - see other improvement proposals below
@@ -205,28 +206,17 @@ checkCollectCom ctx@ScriptContext{scriptContextTxInfo = txInfo} (contestationPer | |||
-- Collect fuel and commits from resolved inputs. Any output containing a PT | |||
-- is treated as a commit, "our" output is the head output and all remaining | |||
-- will be accumulated as 'fuel'. | |||
traverseInputs (fuel, commits, nCommits) = \case | |||
[] -> | |||
traverseInputs TxInInfo{txInInfoResolved} (fuel, commits, nCommits) |
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 function does not traverse all the inputs anymore, I would, either, rename the function to make that clear but I'm not sure:
traverseInputs TxInInfo{txInInfoResolved} (fuel, commits, nCommits) | |
traverseInput TxInInfo{txInInfoResolved} (fuel, commits, nCommits) |
Or I would keep the function's name and keep the call site as it was by introducing some auxiliary function to traverseInputs:
traverseInputs TxInInfo{txInInfoResolved} (fuel, commits, nCommits) | |
traverseInputs someList = | |
foldr auxiliary someList | |
where | |
auxiliary TxInInfo{txInInfoResolved} (fuel, commits, nCommits) = |
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.
extractAndCountCommits
it is! :)
a3db761
to
c1fa047
Compare
d391fa2
to
d22a236
Compare
traverseInputs | ||
(negate (txInfoAdaFee txInfo), [], 0) | ||
(collectedCommits, nTotalCommits) = | ||
foldr |
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.
nice refactor!
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.
Nice and small. Notice that we removed some 1.2kB of script code in this PR!
Why
Since we can assume the v_head output is always the first one in the list of outputs there is a possibility to simplify some
validator code
To check before merging: