CIP-0172? | Self-Usable Transaction Outputs - #1135
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
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.
| 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.
There was a problem hiding this comment.
There were enough people getting enthusiastically behind this proposal shortly after it was submitted — and repeatedly confirmed — that I think it needs to ride that momentum out into whatever discussion circles would lead to its implementation & then its usage by Cardano projects & protocol developers.
@carlostome the only remaining review point #1135 (comment) would be nice to have an answer — in the CIP, if possible — but not necessary since I think the general case of this feature's usability has already been established without making such a detailed study.
Generally we would not merge this without other editors' opportunity to review, which often happens in anticipation of a Last Check discussion so I've tagged it as such for the next CIP meeting: https://hackmd.io/@cip-editors/129
lehins
left a comment
There was a problem hiding this comment.
Aside from inclusion of inline datums in this proposal and few other minor points this CIP looks great.
Co-authored-by: Alexey Kuleshevich <lehins@yandex.ru>
|
@carlostome I'm taking this back from the optimistically scheduled If the Implementation Plan is still |
This comment was marked as low quality.
This comment was marked as low quality.
|
@kylixafonso Flash loans are already possible if dApps just compose inside the same tx like I'm pushing for with the DeFi Kernel philosophy. You can only spend the UTxO with the liquidity if you return it in the same tx + a fee. No ledger changes are needed; just different dApp architectures. |
I think you're conflating two fundamentally different concepts. What you're describing is transaction-level atomic composition: liquidity can be accessed and must be returned within the same transaction. That's certainly a useful pattern, but it's not equivalent to what most people mean by a flash loan, which derives its properties from broader state transitions and block-level execution context. More importantly, I don't think sequencer-based/shared-state architectures and fragmented UTxO architectures should be treated as mutually exclusive or ideologically opposed design choices. Different applications have different requirements, and the ecosystem benefits from supporting both approaches. In practice, many of the lending and liquidity protocols that have achieved meaningful scale across the industry - including the dominant lending protocols on Cardano - Liqwid - rely on pooled liquidity and shared-state semantics. Supporting those designs requires access to richer block-level context and coordination mechanisms, rather than restricting everything to strict transaction atomicity. So the question isn't whether transaction-level composition is possible - it clearly is. The question is whether the platform should also support the broader class of architectures that many large-scale DeFi systems depend on. I would strongly argue that it should. |
There was a problem hiding this comment.
@carlostome @lehins (as the two principal review & response parties) although this was stalled I can see that it has passed through two rounds of review while:
- attracting some support for the pathological cases that it would solve (better explained by @colll78 above & confirming what was noted in the prior CIP meeting);
- the unique confirmation from @lehins that "it should have originally been designed to work this way" (paraphrased from memory);
- answering questions from community experts (e.g. @ch1bo) who might not originally have understood the purpose for this but appear to have all questions answered here.
The one remaining item that pulled this back from Last Check before was an uncertainty about which hard fork this would be included in (as documented in the OP #1135 (comment)).
- I don't see why this should be a problem since we've had many CIPs over the years which defined future changes to the Ledger but only indicated that "a hard fork" would be required without divining any hard fork names or scope in advance.
- Therefore I've installed a simple
Path to Activethat resolves thatTODOitem — giving us a Path to Active consistent with the Nested Transactions work scope & timeline — as explained already in this comment & change.
I think this puts us safely back at Last Check but please @lehins feel free to go over this again: especially if there are any Ledger considerations that should be added to the Path to Active to make it plausible.
- I would hope to merge this with no further reservations but please post if so & we'll take it off the agenda for now: https://hackmd.io/@cip-editors/141
Note I'll be submitting some commits below to correct the validation problems but these will just be formatting & not substantial changes.
Allow transactions to use scripts and data from their own outputs during validation.
(rendered proposal)
Notes: