-
Notifications
You must be signed in to change notification settings - Fork 7
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
Estimate proving costs for Risc0 programs #27
Comments
Thanks for the write up,, agree that we need a way to approach this. Current State.The basic flow of bonsol is
Currently Bonsol executes the compute and proves it in the same "unit" of code. After resolving inputs it simply tries to execute and prove as fast as possible. Note that private imputs that use the private data server method cannot be resolved until after a claim. Prover CostThe cost to the prover goes beyond proving time and opportunity cost. Its also solana priority fees, it may also be necessary to have the median fee for the claim and proving requests be a factor in the decision to prove something. Variables needed to estimate costThinking through this from a software architecture perspective we would benefit from having the following cost variables available at the time of deciding to claim or provide a price.
In order to get a compute estimate we either need to have run the image before, rely on some new bonsol system where those metrics are published, or run a simulation over the image. In the former, at an early stage of the bonsol network with low load this equates to no knowledge of the compute estimate, Given that we cannot trust the developer to tell us what the compute estimate is , and we wont have inputs to test, we must figure out a way to test the image for an initial execution cost estimate. Solution ConstraintsSince Bonsol attempts to allow provers to differentiate and be more profitable than some base segment proving reward we don't want to simply have provers connect to some machine that has already run the execution over the inputs and is sending out segments to be proven. Similar problem spaceThis problem is very similar to the problem of simulation of vm executions on blockchain networks. In solana you can simulate a transaction to see what it will do, and also to see how much compute was used. Currently developers benefit from placing a marker in their instruction that says "this transaction will not use more than X compute cycles". If it does, the transaction automatically fails. This results in a loss of the signature fee, but the validator still gets a reward for packing it into a block. Because solana relies on re executing the vms and consensus, the incentive for the validator to just say that every transaction has busted the limit and therefore is a failure is handled. Possible Solutions for the first exection
Lets discuss other solutions and pros/cons of the proposed ones. |
Curious how much variable length/type inputs affect the execution stats. Is it reasonable to put the onus on developers to anticipate how the zk program will be used in the future? What if we consider committing to executor stats based on specific inputs in execution requests? This would shift the responsibility from developers to whoever is actually requesting the proof.
|
I think inputs can affect it alot, I mean each cpu gate is a part of the r0 trace so this can directly impact proving time. |
Summarizing our discussion via call, we'll focus on two things for the MVP:
Imagining a workflow where an application (proof requestor) creates an execution request by specifying a ZK program deployed on Bonsol. An executor would download the ELF binary and generate the execution trace corresponding to that execution request, posting the result back to be stored on Bonsol (in some sort of stats registry?). A prover would then inspect the execution stats associated with a request and decide based on the tip, stats, and own business logic, decide whether to fulfill the request. |
Estimate Proving Costs for Risc0 Programs
Estimate the cost of a RISC Zero program before submitting real workloads to Bonsol,
Motivation
We want a fair pricing mechanism for Bonsol execution requests, where buyers provide an adequate tip to provers for accepting their request and generating a proof of their program. This would involve having a ballpark figure for how to price proofs in an open market so buyers/sellers can agree on a price often and quickly.
Approach
Use executor statistics, which tell us how computationally expensive a program is. These include:
Total Cycles
andSegments Count
should contribute to a model for estimating the proof cost, where cycles indicate the total number of operations to be performed and segments indicate how parallelizable the program is. The hard part is converting these statistics to a dollar amount for proof generation, since provers will have unique hardware configs.Short Game
One approach could be to price proofs naively in order to get the market up and running. This might involve estimating a base or minimum cost for proof generation, and then adding a tip on top to incentivize provers. The tip could follow a bonding curve that diminishes over time, incentivizing provers to act quickly. For example, we could use the following equation:
Where:
Again the tip follows a bonding curve (exponential decay) that diminishes over time.
Considerations
(1) should be done by the protocol. (2) and (3) can be done by the user making the execution request.
Simulation
Next Steps (after discussion)
Long Game
Since proof pricing will be a requirement in all proving marketplaces (outside Bonsol), it may be worth coming up with a systematic approach to collecting data points on proving costs. Keeping in my these costs will change over time as hardware and incentives change...
The text was updated successfully, but these errors were encountered: