-
Notifications
You must be signed in to change notification settings - Fork 113
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
Transfer to Transaction NEP-TTT #137
Comments
Related to neo-project/neo#1468 |
So these two transactions must be included in the same block? |
The idea is that this is a single and atomic transaction. One way to implement this is to put some new verification script field on tx header (I'm avoiding this approach) With this, Neo system just needs to catch the "promiseNotification" from GAS for "transaction balance" (and maybe the specific contract scopes of that witness), and this can be done deterministically (I hope so), before the transactions is put on block (the same as fee calculation currently being done). This way, we don't interfere much with Neo system, and for user, it just needs to implement NEP-TTT together with NEP-17:
And maybe another way (not sure now if it's necessary): |
So this is a solution to let the contract pay for the fee? |
I think so @erikzhang |
Then why not use the contract hash as the sender of the transaction? |
🤔 |
[EDIT]: That's a very good question. Using the sender looks nicer indeed. I think that using the balance from sender requires permission, and it could indeed provide permission to spend its GAS assets. I just don't know how it could give "partial permission" over a limited amount of assets (imagining some "unbounded" But I think you're right, Neo System could automatically invoke this "scheduleTransfer" directly from sender (as a contract), to launch "promiseNotification" and guarantee the existence of GAS to make whole its future operation, and store it on current transaction (this is much easier for everyone as no new script is required, all automatic). |
Let me just highlight the most fundamental points trying to be accomplished here, in my opinion:
|
IIUC this requires changes to NEP-17 and if we're using "transactioned" GAS for fees then it also requires senders to be 256-bit wide which is quite invasive.
Verification context has access to transaction and it can get fee values to decide whether it wants to allow spending a particular amount of GAS for fees.
Isn't it all controlled by witness scopes?
I think I don't quite understand this "stored on transaction" part. If actual contract storage isn't affected then it's a kind of "ephemeral" storage and this then raises questions like what happens if 0.5 GAS was requested and 0.4 spent, what transfer events should be generated for this storage/spending (especially for fees). Also IIRC notifications are forbidden at the moment in verification context.
But do we have any problem with that? I think we have any minting/staking/depositing case covered by simple NEP17 transfers with additional data to contract's address, then the contract in question can do anything it needs to in
I think this case can be perfectly handled by Notary subsystem from neo-project/neo#1573. Contract's address can still be used as a sender (but some other address can be used if needed), but user will create an incomplete transaction and then the decision on whether this transaction should be completed or not can be made by dApp backend instead of (inevitably limited) contract's verification method. Backend can have some state-dependent logic for which addresses can use this feature and how much GAS they could spend, it can also parse the entry script and for example only allow some specific calls to be made. |
Thanks for taking the time to evaluate this proposal @roman-khimov. I agree that neo-project/neo#1573 is an interesting approach, specially as it deals with P2P operations, so I don't see any conflict with this proposal here. This aims at providing temporary storage at current transaction and allow scoped-acess to this temporary storage.
This is important: NEP-17 isn't affected in any way (and certainly no address change!). The main intention at the moment is to having GAS contract implementing NEP-17 and NEP-TTT (an extra method), although other contracts may benefit from it as well.
That's the core of this proposal, I'll try to clarify. Currently, user informs that tx "fee" on GAS will be, and then Neo System automatically takes this from user "GAS account" and uses this to makewhole its operational costs. Since data can only be read from inside Transaction itself, TransactionHash part can be ommitted on practice (not a global information, not even block-level, just single-transaction-level). [EDIT]: The workflow I imagine is:
Note that if
Another interesting feature is that we can have an extra method (like I mentioned before,
No, we can solve minting using OnPayment strategy. But it's powerful to have some "shared space" for assets during contract invocation, so that one can give assets to another one, or even cover system fees directly (it could even re-fill system fees during runtime, but we decide how much flexibility and complication we want to provide). Does it makes it clearer or more confusing? 😂 |
@erikzhang when you have some time, please take a look at the workflow above. Afterall, I don't think using |
@roman-khimov please take a look at the workflow I've put in details. General Outline: What do you think of the idea of Transactions holding temporary assets (including scoped-execution GAS)?
|
If the account balance is insufficient, it will cause the transaction that did not pay the network fee to be included in the block. This can lead to attacks. |
I've accounted for that already @erikzhang , and this won't happen with GAS as the existing accounting model will be immediately mirrored into this new one. As soon as a This variable gas_amount on ApplicationEngine No attacks can happen, because no non-determinism on balance is generated from this (as no Storage access is performed, besides intrinsic |
Let me give a numerical example, because this reasoning you mentioned is fundamental @erikzhang . Please inform me of the possible mistakes I'm making here! [EDIT]: Scenario:
Current mechanism:
Proposed mechanism:
|
Why not put contractTKN as the sender? |
I knew you were going to ask @erikzhang 😂 [EDIT]: Just because the real |
I think |
And don't forget about "scope"... why should ContractTKN give GAS to some TX that doesn't even execute ContractTKN? [EDIT]: I put ContractTKN as Instead of loading ApplicationEngine with such advanced logic, I would rather put a Dictionary/Map into Transaction, and consider that execution GAS is part of the Transaction Balance, instead of considering it part of "ApplicationEngine Balance". |
In fact there is no
You add it as one of the signers, the |
Ok, I'll fix description as
That's the trickiest of all... there could be perhaps some theoretical way of doing this, but it's not possible "on practice" to deduce contract logic just by inspecting invocation script. It's simply so much easier to consider that, as long as If at least this change is made, ContractTKN logic for verify() becomes simple: it just checks that user put it as |
Besides the scoped GAS, which I believe now to be very important, there's another fundamental contribution of this NEP: GAS reloading during contract invocation. As long as some contract has the ability to invoke |
I still think this NEP is valid, and honestly, I find it quite beautiful to be able to store assets on a transaction. Specially, the idea of a transaction having a temporary balance, that expires once it's finished, and then it automatically invokes then cleaning method to handle non-zero pending balances. From a practical perspective on GAS, I'll open two issues directly on Neo: neo-project/neo#2442 and neo-project/neo#2443 |
Certainly clearer, thanks @igormcoelho. Technically I'd be concerned about these things:
Also, there is a huge difference going from
to
The first one tries to solve local contract sponsoring problem (and it has other solutions), the second one is much more generic and raises a question of what data and how could be stored in transaction. This generic case of this proposal probably is interesting in that it can allow limiting the amount of assets approved to use in some situations, but I'm not sure we can reliably implement this more generic case and I'm also not sure it's to be used a lot, current scoping and |
Very interesting technical points @roman-khimov. Regarding re-verification, it's not needed for the reason described in this comment here: #137 (comment) Another interesting behavior of this proposal is that:
It's like creating a pool of funds that can be used during transaction execution. I think it's nice, but I agree we must find some "killer application" using this mechanism, to justify such trouble implementing it (maybe it helps on minting, maybe it helps with managing execution gas, ...). |
@erikzhang @roman-khimov we have a problem... (or maybe my head is not quite right at this moment) So if it can't read storage during verification, then this NEP-TTT is absolutely necessary, in my opinion, as a way to provide accounting mechanism similar to GAS to other NEP-17 tokens, otherwise it's not possible to do contract sponsoring onchain. I'll begin drafting a document to properly explain this to the community. If you have any questions, I'm willing to debate this as long as it is necessary, because I really think this is important for N3. |
I recall that the essence of this NEP-TTT is:
Now it's clear to me that this is precisely what GAS does, and that's how it manages to escape non-determinism and still avoid a second re-verification. We need that for other tokens and this NEP can provide that. If we have that, users will be able to truly enforce collateral guarantees on any NEP-17 token before Invocation happens, without breaking non-determinism and avoiding re-verification, by the virtue of fact that balances are additive (we have talked about that sooooome time ago neo-project/neo#814). As long as it is additive, mempool can keep on memory the updated balances for any token that has GetBalance(), besides GAS, and perform these transfers for ALL transactions in block, before any invocation happens (that's the way to prevent double spending and that's exactly how GAS manages to survive it, right?). |
It can. |
It can do something useful or it can access storage? 😂 Last time I seen there was a discussion on this, but if it has access to storage, we can manage many things. |
It has access to storage and therefore it can do many useful things. |
Thanks @roman-khimov , I got confused about that. On the other hand, this means that transactions are still being re-verified (on the witness part) after every block is put... I thought that only GAS parts would require updates by now (thus preventing any re-verification). Worse, it should re-verify transactions after each transaction is executed, otherwise it risks breaking |
Summary: this NEP called Transfer to Transaction tries to provide a practical manner to redistribute assets during Verification time on transaction, thus allowing implementation of practical mechanisms for "free transactions".
[EDIT 1] - This doesn't affect NEP-17 in any case. At the time of writing, this is mainly intended for adoption only on GAS contract, as NEP-17 and NEP-TTT.
[EDIT 2] - Two methods are proposed in this NEP:
scheduleTransfer
andfinalizeTransfer
.[ORIGINAL PART]
=====
Transfer to Transaction
This NEP considers a transaction as a valid (and temporary) token holder (as HASH256 identifier, not usual HASH160).
It can be done with operation "contract.scheduleTransfer(from, target_tx, value)" that launches a "promiseNotification" (consumed before actual contract invocation).
Contracts can easily extract funds from transaction, for example, in a mint operation. Neo system can also consume funds from Transaction, for example, GAS funds to cover fee for operations. User can also specify a "contract scope" or "group scope" as the temporary holder (instead of global "transaction scope") and funds are consumed according to the scope.
Example 1 (usual operation):
fee
field on transaction and script runs directly from WitnessExample 2:
This "request" operation at ContractY can do some interesting thing such "redistributing" GAS for user operation, in that specific scope, with some simple rule as:
This means that giveaway operation only works after few blocks, and with limited gas supply (limited per block hold time and user shares on that contract).
The text was updated successfully, but these errors were encountered: