Skip to content
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

[Proposal] Finalize cost should not include commands skipped by branch command #1753

Open
HarukaMa opened this issue Jul 5, 2023 · 3 comments

Comments

@HarukaMa
Copy link
Contributor

HarukaMa commented Jul 5, 2023

💥 Proposal

Currently snarkVM counts every command for the finalize fee. However, skipped commands should take a lot less resource to execute on-chain, so the fee can't represent the real effort for nodes to execute the finalizers. Considering the current implementation for branch commands literally skips those commands, they should not contribute to the finalize fee.

Possible implications: the fee for each function call might differ for a huge amount, especially if block.height or rand.chacha is involved (we can't reliably simulate executions for those cases, especially for rand.chacha). As we don't have a complicated gas fee system like Ethereum, it would be difficult for users to always use a reasonable fee when executing programs.

@raychu86
Copy link
Contributor

raychu86 commented Jul 5, 2023

Great observation!

We are in the process of determining the fee model for finalize, in the current form, we are checking that you pay for the entirety of the finalize logic regardless of if the branch occurs or not. Meaning, we regard your transaction as invalid due to insufficient fees, before attempting to add it to the chain.

A solution we are planning to explore is as follows:

  1. Soften the initial enforcements and provide a "suggested" fee up front.
  2. Tally the proper finalize costs when actually executing the finalize in atomic_speculate.
  3. Accept/Reject the transaction based on the fee. (We can abort the execution early if the provided fee is already "consumed")

This would effectively bring us to the Ethereum model where you pay for execution like gas (and halts early).

Note - We are also exploring the costs of each finalize command in this PR - https://github.com/AleoHQ/snarkVM/pull/1717

@HarukaMa
Copy link
Contributor Author

HarukaMa commented Jul 5, 2023

I believe even in this approach, the user would still pay for the full amount that is submitted, as we don't (can't?) have refund mechanisms with the fee transition?

@raychu86
Copy link
Contributor

raychu86 commented Jul 5, 2023

Yes, at the moment we do not have a concept of "refunds" with the fee transition, because the fee transition must be constructed prior to broadcasting the transaction. For privacy reasons, we also can't explore the route of refunds via public credits due to the fee payer being private.

It is up to the developer to determine the amount of fee they'd like to provide. The upper-bound of the fee is deterministic and a fee estimate to account for branches can be determined by running VM::speculate locally (assuming a synced VM).

Any additional fee amount that is not consumed by the execution costs is effectively a "priority fee".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants