CIP-0172? | Self-Usable Transaction Outputs#1135
CIP-0172? | Self-Usable Transaction Outputs#1135carlostome wants to merge 10 commits intocardano-foundation:masterfrom
Conversation
|
@carlostome I'm marking this Also @colll78 @polinavino @fallen-icarus especially from your interaction with the Nested Transactions CIP I think we would benefit from your insights about this proposal: including views on use cases, efficiency, safety, and other factors that have come up before. Personally I can't yet understand how this proposal and CIP-0118 are intertwined & I hope to get a better view of that through upcoming review. |
|
@carlostome Do you know of any concrete use cases for this? As a dApp developer, I've never found myself wishing for this ability. |
Hi @fallen-icarus, in the CIP, I have outlined the use case I have in mind. That is, making sharing scripts between top- and sub- level transactions (in the context of Nested transactions) independent on the order in which they are processed within a batch. I'm happy to add more explanation and/or clarifications if you find it is not clear enough. I do not know of other use cases at the moment. |
This is an abstract use case. What real world product needs this ability? Do batchers need this for aggregating sub-txs? Why wouldn't they just have the sub-txs omit the required script/data from the sub-tx so they can just add it to the top-level? |
|
summary notes from today's CIP meeting: ➤ Use cases: as noted above, this question also came up at the meeting. My understanding is that this demand has already been met: when we combine @fallen-icarus's enquiry about use cases with @carlostome's response that "Nested Transactions" is itself the use case, it appears that "use cases of Nested Transactions" are also generally use cases of this proposal.
➤ Thanks mainly to @colll78, we highlighted a substantial benefit for this proposal (by avoiding an "ordering dependency") in that protocol creators wouldn't have to wait for the effects of something like a token minting to be processed by the chain in a previous transaction (whose Tx would be far too big to include as another Tx input) before submitting further transactions to define that protocol.
My own list of review questions that came up are:
Mainly pending Ledger response about feasibility we chose to leave this |
I don't know.
This allows batchers to reduce duplication (and thus fees) in the case of cyclic dependencies between data and/or scripts in the top- and sub-level transactions.
Because batchers cannot modify sub-txs since they are signed. Scripts are not signed but data is (via |
I've changed the CIP to reflect the particular nature of the use case within nested transactions.
I'm not sure what the scope of anything currently under development is, but a priori yes, in the sense that this change modifies the behaviour of some part of the Ledger rules.
I can't foresee any implications in terms of performance and/or efficiency. However, this change will definitely simplify the implementation of data and script sharing in Nested transactions. |
I don't fully understand this scenario and how it could benefit from script sharing. In particular I don't understand the part about submitting further transactions to define the protocol after minting the token. |
This feature was originally motivated by a simplification of the logic of the specification. So any implementation that implements the logic in a similar manner should also see a simplification in their code. Roughly speaking, checking that everything is ordered correctly is extra work, and this CIP recognises that this extra work is unnecessary and not doing it gives some extra flexibility to DApp authors. |
apologies @carlostome: I didn't mean to introduce a potentially infinite scope. 😅 What I meant more practically was (if you might know of some answers): What common design patterns in Cardano development would depend upon the unmodified Ledger rules and therefore be affected by this CIP? The editors (among others) would just be trying to estimate the trade impact of making this change, and so anything you (or other reviewers) can provide here would be helpful: especially if you add these scenarios to the CIP itself.
@colll78 can you please document here this example as you described it at yesterday's CIP meeting — a typical project launch, beginning with a token mint, with this CIP avoiding waiting periods for prior transactions to be verified before continuing to each new step — which was considered an advantage and use case for this CIP? I think we need your precision here so the author knows what to do with that suggestion & perhaps include it as a use case. @carlostome please note that my writing above is mainly feedback from a CIP meeting yesterday (held biweekly) in which I put your proposal on the agenda for introduction. We can't rely on those present at the meeting to record their meeting statements back on GitHub... so during or after the meetings one of the CIP editors will generally try to document it back here. We do our best to record these statements but often can't perfectly reproduce the same point of view or technical understanding. You'd be very welcome at the meeting yourself & please find the schedule here: https://luma.com/cardano-cip |
|
I believe it should have been implemented this way right from the start when reference scripts where introduced as a feature, because I can't see a single reason why it shouldn't have been done that way, especially since implementation for this is very simple. Luckily we should be able to retroactively enable this feature for PlutusV1-V3 scripts as well, without much effort, since witnesses are not supplied in the script context, so scripts cannot know for sure whether script was provided as a witness or as a reference script. In my opinion, this CIP is simply an optimization. All it does is allows a user to use a script in the same transaction that adds it to the UTxO for sub-subsequent transaction to reuse as reference script. In a common case, it does not really make something that was previously impossible possible, except when a script that a person is trying to use is pretty big in size. It only makes some certain use cases cheaper, simpler for users and reduce amount of data placed on chain. This point is quite simple to prove: any transaction that could benefit out of using a script that was supplied in one of the outputs that it is creating, could always also add it to the witness set. So, all this CIP will allow is to do is accommodate those cases without including such script in a transaction twice, which is also why scripts that are so large in size that two copies of it would not fit in a transaction, could really benefit from this CIP. Some benefits from this CIP that come to mind:
Best thing I like about this CIP is that implementation of this feature is very simple and, as far as I can see it, there are only benefits and no drawbacks. Big 👍 from me. |
I can try and make it concrete. Here is an example without this CIP:
With this CIP, top-level transaction builder will have this ability to add a script to UTxO that any of the sub-transactions might need for immediate and sub-subsequent use. So, IMHO, this CIP is especially useful for the top-level transaction builder. |
There was a problem hiding this comment.
@carlostome @lehins the elaboration of Ledger impact in #1135 (comment) abundantly addresses the only blocker we had at our last CIP meeting — uncertainty over whether this could be implemented easily enough in the Ledger — and so I'd like to promptly confirm this as a CIP candidate: as we would have if we'd been sure of this on Tuesday's meeting.
I've added this back on Review for the next CIP meeting (https://hackmd.io/@cip-editors/127), where we could do that: but if both @Ryun1 and @perturbing agree here in the meantime we'd have unanimity & can re-tag this as Confirmed, assign a CIP number, and start tagging other devs for a deep (technical) and broad (ecosystem) review.
|
@rphair |
Currently to deploy just about any DeFi protocol or dApp on Cardano requires multiple transactions, even for an extremely simple dApp that only has a single script. The minimal flow for a stateful dApp at the moment is roughly: With this proposal you could deploy such applications in a single transaction that produces the reference script UTxOs (ie. that contain the minting policy of the state tokens) and mint the state tokens in the same transaction (ie. create a DEX pool in the same tx where you publish the DEX pool script). |
rphair
left a comment
There was a problem hiding this comment.
Since all editors who left this Unconfirmed at last week's CIP meeting have now supported making this a candidate, we're promoting it without waiting for the next meeting. @carlostome please rename the containing directory to CIP-0172 and updated the "rendered" link in your original comment. 🎉
Also please consider adding those couple of things to the Motivation and Rationale to resolve the comments in #1135 (comment) & #1135 (comment) based on @Ryun1's & other editorial feedback.
Though this proposal is of general developer interest and we would welcome comments from anyone, I'm tagging some further reviewers with a good eye for overall design patterns — especially contributors to the Nested Transactions discussion & roundtable — to review the CIP and maybe help us plan how to introduce this to the dev community:
@perturbing @Quantumplation @polinavino @ch1bo @sandtreader @AndrewWestberg @michele-nuzzi @disassembler @MicroProofs
4859aca to
a5de397
Compare
a5de397 to
63ea4c1
Compare
There was a problem hiding this comment.
@carlostome thanks for all your updates in response to previous reviews which I can see have addressed all the commentary from editor's review and our last meeting discussion. Thanks especially for your force-push being done in a way that preserves the commit history from different sources. 🙏
Editors will keep an eye out for further technical review as hopefully launched with those tagged in #1135 (review), and if no objection or further evolution will keep moving it forward in the CIP review cycle towards merge.
Once the suggestions below settle, plus hopefully some confirming review, I'd be ready to approve this CIP.
| ### Acceptance Criteria | ||
|
|
||
| - Fully implemented in Cardano node | ||
|
|
||
| ### Implementation Plan | ||
|
|
||
| - TODO |
There was a problem hiding this comment.
| ### Acceptance Criteria | |
| - Fully implemented in Cardano node | |
| ### Implementation Plan | |
| - TODO | |
| ### Acceptance Criteria | |
| - [ ] Fully implemented in Cardano node | |
| ### Implementation Plan | |
| - [ ] Update the formal Ledger specification with "changes to the Ledger logic" above | |
| - [ ] Implement the outlined changes in the Cardano node | |
| - [ ] Complete a hard fork enabling support for the changes outlined here |
I used https://github.com/carlostome/CIPs/tree/master/CIP-0118#implementation-plan as a template:
- @Ryun1 @lehins can please double check for consistency with similar Ledger proposals?
- @carlostome & others please add anything in developer relations that could be seen as a dependency (a common issue with Ledger changes so perhaps implicit & therefore no need to publicise it?)
There was a problem hiding this comment.
p.s. I can also see (somehow missed before) in the original comment the current uncertainty about implementation in Conway vs. Dijkstra... understandably this would still be TODO while that decision is made.
Co-authored-by: Robert Phair <rphair@cosd.com>
ch1bo
left a comment
There was a problem hiding this comment.
Gave a look because I got notified through Github and I could not really follow the motivation for this.
| transaction, which simultaneously produces the reference script UTxO's and | ||
| mints the state token. This eliminates the need for submitting multiple | ||
| transactions, thereby reducing costs, while at the same time improving the | ||
| developer's experience. |
There was a problem hiding this comment.
Why is a reference script at all needed in this use case?
This exact annoyance could guide a dApp developer to not use reference scripts, but just include the script in the witness set of the transaction that mints the tokens. Thus, only incurring a transaction fee and not require the additional deposit for the reference script in the output (which grows the utxo state, that must be paid).
There was a problem hiding this comment.
Comparing to just including the witness set, adding a script to the UTxO will require the user to lock up the funds in the form of minUtxO, so that is the motivating factor against it. Which means the only reason why a user would want to do this instead of just using a script in witnesses is for further reuse.
So, this statement is incorrect: "not require the additional deposit for the reference script" There is still deposit for including a script in the output.
There was a problem hiding this comment.
The point is that the script that is used to deploy the initial state tokens will of-course be reused. IE. A DEX pool script (minting policy and spending validator multi-validator). Right now you need to deploy reference scripts, and create the pool in two separate txs.
You could just mint the tokens providing pool script as witness and then deploy reference scripts after but that's still two txs.
There was a problem hiding this comment.
Then, it was just not clear to me as a reader that this example is not an isolated usage, but the optimization of combined publishing scripts as reference + the first usage in the same transaction. The example was helpful and I suggest it should be added to the CIP / existing examples be made more concrete.
There was a problem hiding this comment.
@carlostome I think adding such an example would help make the proposal more "user friendly" - which has been important for other CIPs to keep people aware of best-practice design patterns.
| Instead, the transaction must provide a redundant copy of the same script or | ||
| data (e.g., in the transaction witnesses). This forced redundancy increases | ||
| transaction size, and thus transaction fees, directly inflating the costs | ||
| incurred by users. |
There was a problem hiding this comment.
I don't follow the argument of re-using inlined data.
If a transaction wants to spend an output that carries inlined data, that data would already be in the utxo set and thus the creating tx paid for it. For "normal" datum use, there would only be a datumhash on the utxo and the spending transaction provides the preimage in the witness set. This data resolves across any spent inputs that are parameterized by the same data (hash). I don't know how this evolves for nested transactions but I would expect it to allow re-use of hashed data. For other validation purposes, there is no datum in the context.
So, what exactly motivates the sketched change of getDatum in the agda spec?
There was a problem hiding this comment.
I do agree with this point, since datums are not reusable from reference inputs either. This change alone would lead to strange semantic where datum from outputs created can be reused throughout a transaction, while ones specified in inputs and reference inputs cannot. If we are to make such a change it would require its own CIP. However, I vaguely remember discussing this point long time ago with some folks that actually write DApps and their argument against was that it is very rare that a script requires the same data and it is usually fairly small anyways.
I think it would be worthwhile analyzing the chain and see whether there could actually be some space savings if we were to add such feature of inline datums being shared throughout a transaction.
Allow transactions to use scripts and data from their own outputs during validation.
(rendered proposal)
Notes: