-
Notifications
You must be signed in to change notification settings - Fork 142
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
Sponsored Fees #1068
base: main
Are you sure you want to change the base?
Sponsored Fees #1068
Conversation
Signed-off-by: Nana Essilfie-Conduah <[email protected]>
✅ Deploy Preview for hedera-hips ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
…types Signed-off-by: Nana Essilfie-Conduah <[email protected]>
Updated HIP with scope concept and fixed PR description with updated Abstract |
Would it be possible for sponsored fees to be optionally set towards spending by a smart contract, thus limiting the scope of the approval to executing only 1 particular smart contract. |
@tud0r6 I like this idea, to be clear, you mean that if I grant some hbar to Alice, I would be able to specify that Alice can only spend the hBar on executing transactions related to a specific contract, nothing else. She would not be able to execute another contract, or create an NFT, etc... Note, hbar in this case is gas for contracts, does the allowance extend to paying for gas (through the SDK and/or relay), or just native fees ? If only native fees, we may need to consider supporting gas payments. |
Great considerations @gregscullard and @tud0r6 . |
Indeed, I won't want to sponsor general-use gas(HBAR), rather application(SC)-specific gas(HBAR). |
Signed-off-by: Nana Essilfie-Conduah <[email protected]>
Signed-off-by: Nana Essilfie-Conduah <[email protected]>
@gregscullard and @tud0r6 I've added the gas scope but also added thoughts in the open questions section around some challenges here. |
@Nana-EC on the gas scope and the EVM tooling question, could we not consider that if an EOA account has 0 balance, then gas fees should be paid out of the allowance, or if the account has balance, it consumes that balance first, then dips into allowances if they exist ? I think we're still missing something with regards to the applicability of allowances for gas. Specifically the ability to be explicit about which contracts can be executed with a given allowance. User-stories-ish for example:
|
Hey @gregscullard , |
Hey @gregscullard , |
Signed-off-by: Nana Essilfie-Conduah <[email protected]>
|
||
1. As an existing account on the network I want to be able to sponsor up to a certain HBAR limit the cost of future | ||
transaction fees due by another account by granting an explicit allowance. | ||
2. As an existing account on the network I want to be able to sponsor an unlimited amount of HBARs to cover the cost |
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 behaviour seems similar to the behaviour we have for NFT allowances, more specifically approvedForAll=true, where each new serial number of a given NFT will have been granted as an allowance to the spender.
Is the concept here the same? Since hbars are fungible there might be some applications like:
- If a sponsor gives allowance to multiple accounts with unlimited HBAR amounts - the granted accounts might use a competative greedy approach to try to use a part or the whole balance for their personal use before another account and thus having unfair share of the sponsored balance
- Defend the sponsor against a malicious account which performs operations in a loop, exhausting all of the balance
There might be safe use cases for this unlimited amount sponsorship, but I wanted to raise some security implications and corner cases, which can be thought of.
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.
Interesting points.
If by similar you mean will new hbars or FTs made available by a treasury be applicable to an existing allowance then yes, this would continue to be the case.
The cases noted are the same today I believe if an account was to provide one or multiple allowances with large enough values in comparison to their balance, so I don't believe this is a new edge case.
Solid consideration but I think it's already covered within the service capabilities.
It's the responsibility of the account to consider its awarded allowances.
|
||
A new new allowance scope will be added to help define which type of fee an allowance can be used for | ||
```protobuf | ||
enum AllowanceScope { |
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 GAS
scope seems to be missing.
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.
Isn't GAS part of the TRANSACTION_FEE for a Smart contract call?
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.
There is an interesting case that we should make sure is covered properly by this scope concept.
If we perform a precompile smart contract call that creates a token - this precompile requires gas amount in tinybars + separate value sent in tinybars, since the gas amount will be above some of the limits. This implies that calling createFungibleToken precompile call might make use of both GAS
and TRANSACTION_FEE
scopes.
We can elaborate more of what TRANSACTION_FEE
covers in this HIP as a scope? I understand it as hbar amount needed to cover transaction expenses different than the gas itself. Or is it actually the gas amount itself?
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.
But at some other points GAS is used as a scope (Mirror Node endpoint, for example). Here it must be clear what is the difference and if GAS must be included.
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 agree, I'm a bit confused regarding the difference between GAS
and TRANSACTION_FEE
scope.
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.
To clarify, gas is a concept of resource utilization.
Gas fee is how much each unit of gas costs a user in HBAR.
Here the allowance is capturing the cost in hbar when settlement occurs
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.
Gas is an EVM concept which is a proxy for the amount of work the EVM needs to do to porcesss your transaction, which is not the same as the Hedera transaction fee (cost assigned to each HAPI transaction based on the feeSchedule)
Gas is indeed settled in HBAR and charged to an EOA so this might be where things are getting mixed up.
They are separate concepts and scopes so we have a TRANSACTION_FEE and a GAS_FEE to cover each separately.
Both cases are existing concepts on Hedera and are noted in summary in the HIP in the protobuf summary.
Maybe additional illustrations of the Scopes would be helpful.
It is possible as @IvanKavaldzhiev noted that a single transaction could utilize a combination of scopes. If that user has the appropriate allowances then the network will support 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.
For the EVM this is very interesting. We have two scopes: GAS_FEES
and TRANSACTION_FEES
. So we should consider (and document) the behavior of three variations:
- A
ContractCall
transaction has only a single allowance forGAS_FEES
- A
ContractCall
transaction has only a single allowance forTRANSACTION_FEES
- A
ContractCall
transaction has two scopes:GAS_FEES
andTRANSACTION_FEES
with the same sponsor - A
ContractCall
transaction has two scopes:GAS_FEES
andGAS_FEES
by two sponsors - A
ContractCall
transaction has two scopes:GAS_FEES
andTOKEN_CUSTOM_FEES
by one or more sponsors
The first case is the base expected case: the sponsor will pay for a certain amount of gas. Gas is denominated in USD, and so the amount of hbars per gas is variable. So the sponsor is saying "I will pay whatever the USD equivalent of HBAR is up to this limit of gas". So this works.
For the second case, gas fees are a subset of possible transaction fees, so it seems very reasonable that a sponsor willing to pay for transaction fees would expect it to also cover gas. For example, as a sponsor, I could say I am willing to pay a certain amount of HBAR and I don't care whether it is for crypto transfer fees for gas fees. We could instead say that gas fees are special and must be specified separately.
The third case is dependent on our answer to the second case. If we say that TRANSACTION_FEES is illegal, then the third case is also illegal. If however we say that TRANSACTION_FEES is legal, then we have a situation here where the sponsor has provided two different allowances and we have a decision to make. Is this combination saying "you can spend X gas AND Y transaction fees", or is it saying "you can spend X gas but not more than Y hbars when converted to fees".
The fourth case we should just define the behavior. I think we will go to the first sponsor and use their funds first, and only if there is insufficient, then we go to the second sponsor. This seems simple enough.
The fifth case should be a failure because TOKEN_CUSTOM_FEES
is not applicable to ContractCall
. We should fail transactions that have inapplicable scopes. This is a little frustrating for dapps because they have to analyze what the transaction type is and then select the right sponsor and claim type, they cannot just put all claims in there and let the network figure it out. But this has been our policy to this point for all our transactions, to be strict on what we accept, to have the greatest forward compatibility. If this becomes a problem we can always loosen our position, but if we start off loose, we cannot tighten it.
So I think the pivotal cases are the second and third.
… asset file Signed-off-by: Nana Essilfie-Conduah <[email protected]>
Signed-off-by: Nana Essilfie-Conduah <[email protected]>
Description:
This HIP proposes an expansion to the approval and allowance network logic (i.e. CryptoApproveAllowance, NftAllowance
and TokenAllowance) by allowing any account on the network to provide allowances that will sponsor the payment of the
fees for another account’s submitted transactions.
In this way account Alice may assign an HBAR / token transaction fee allowance for EOA account Bob or Contract account
Carol and pay the fees due to nodes, the network and accounts for any transactions they submit, thus allowing Bob or
Carol to have zero balance and still transact on chain.
This proposal extends the existing Approval and Allowance API by adding the concept of a scope that designates the type
of value transafer an allowance applies to.
The scopes will include CryptoTranafer, HAPI transsaction fee, token custom fees and gas fees.
This enables value transfer and fee payments to another account without requiring one-off
approval for each transaction. This feature enhances flexibility and efficiency in managing transaction costs,
particularly for high volume applications.
Related issue(s):
Fixes #912
Notes for reviewer:
Expect more changes soon.
There's an outstanding item to condense the Allowances types to instead be scopes on the existing allowances as a cleaner API form
Checklist