-
Notifications
You must be signed in to change notification settings - Fork 12
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
query cost, gas, and fees #410
Comments
Missed this, will circle back after release with some thoughts |
I've been thinking a lot about gas and fees. Monetization is a big focus for us this year, and so in addition to block gas limits, it is becoming a big priority. The intent of the transaction No real suggestions here, but we don't have any strict precedents / legacy to adhere to, so we can design a solution as we wish. |
I think is bumped fro 0.8, but perhaps tentatively could find it's way to 0.8 with some initial iteration? I'll put in in the 0.8.0 milestone so we can make the plan definitive and remove it or not. |
Plan for mitigating cost estimate exploits and gross inaccuracy, which are both inevitable.
We will do our best at achieving these goals with a cost computed for each query. However, it will be almost impossible to do this without any loopholes, bugs, or any other inaccurate cost constants used in the computation. Because the cost value is consensus (gas deducted from account balance), we cannot simply tweak and patch this repeatedly as we wish. Changes that result in frequent network migration or coordinated upgrade for the rule change is a poor outcome. To be robust to issues that result in an actual query cost (i.e. execution time in
Despite the determinism requirement for A basic simulation with a random rejection in |
See https://github.com/kwilteam/kwil-db/wiki/Kwil-v0.9 for v0.9 goals w.r.t. cost and pricing.
This issue breaks down into roughly a few main hurdles:
tasks
costmodel
functions for computing cost fromLogicalPlan
, similar to virtual_plan pkg. This is now working, but not completely accurate. Selectivity needs to be computed to reduce cost. Expression cost is now computed. Accessing the scan/from plan's statistics in child plans is ready and will inform selectivity computations, which is most important in a join where one table's size can become small due to filter. In progress.Work branch: https://github.com/jchappelow/kwil-db/commits/cost-stats/
IMPORTANT NOTE: Development will take an incremental approach. We wish to have functional components along the way even if they are simplistic and contain known limitations. For example, there may be a point where we've wired up the app/engine changes, but we run with a cost system that involves no live updates of statistics, only query based cost. Similarly, an intermediate cost system may some statistics, perhaps just row count, and only some of the logical plans working (e.g. no proper updates or join costs, only a constant penalty for these). Similarly, fitting a postgres extension to support procedures should come relatively late so that the general approach is solidified and we won't have to rewrite the extension multiple times.
Note that some statistics cannot be updated without a full scan. There may be some ground truth refresh at the end of a block, or action, etc.
The original issue, which was more speculative, is below:
There are a few things to decide upon regarding gas and fees in Kwil.
First, there's a funny detail regarding the txn fee in all of our spending code where if a transaction specifies a fee
X
>price
, the actual amount spent from the account's balance is justprice
rather thanX
. That essentially makes theFee
field of the transaction body more like the fee limit, but it is not documented this way. I feel like the transaction should reduce account balance by the given fee. Or is there a reason to interpret this as a limit, like removing a painful client footgun?Another thing is gas vs. fee. We have an implicit gas cost of unity i.e. 1 atom (a kwil?) per gas. The transaction has no way to specify a fee rate, which is typically how transactions would be prioritized on a busy chain, just an absolute fee or fee limit depending on how we want to interpret this field.
Lastly, every abci module returns an "ExecutionResponse" with
GasUsed
left at zero, only aFee
set. The event logs are confusing since they say gasUsed is zero despite a fee being paid based on our hardcoded "prices". This is sorta OK since we are handling execution costs (gas!) at the app level, and keeping cometBFT blind to it. So, do we remove this "gas used" info and keep cometbft in the dark, or do we formalize what we mean by gas and fees?I think it's too late for big decisions for 0.6.0, but we should discuss these points anyway.
The text was updated successfully, but these errors were encountered: