-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
[Feature] Introduce BLOCK_SPEND_LIMIT
#2565
base: staging
Are you sure you want to change the base?
Conversation
Extend deployment verification benchmarks
synthesizer/src/vm/finalize.rs
Outdated
if current_block_height >= N::CONSENSUS_V2_HEIGHT { | ||
// If the transaction is an execution, ensure that the total finalize cost does not exceed the block spend limit. | ||
if let Transaction::Execute(_, execution, _) = transaction { |
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.
nit: it might be a good idea to swap these conditions in order to not suggest that the code block below contains the only CONSENSUS_V2
logic (since there is also extra logic for deploy txs); alternatively, that extra logic applicable to deploy txs could be moved under this code block (without altering the order), keeping all the V2
logic in one place
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.
Agree I like the clarity: fcbbb68
synthesizer/process/src/cost.rs
Outdated
@@ -86,6 +89,12 @@ fn execution_storage_cost<N: Network>(size_in_bytes: u64) -> u64 { | |||
} | |||
} | |||
|
|||
/// Returns the fixed cost for an execution. | |||
/// NOTE: this constant reflects the compute cost of an execution, but is not required to be paid by the user. | |||
pub fn execution_fixed_cost<N: Network>() -> u64 { |
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.
are there plans to extend this logic (in which case an alternative name might be more fitting)? I'm wondering about the rationale for the existence of a (non-const) function wrapper for a const
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 swear this was in my git staging area already: 3443c3e
are there plans to extend this logic (in which case an alternative name might be more fitting)?
Unclear at the moment. Only other name I can imagine is execution_compute_cost
?
Motivation
This PR introduces
BLOCK_SPEND_LIMIT
, the maximum amount in microcredits that can be spent on finalizing executions and synthesizing deployments in a block. This gives much greater certainty of maximum blocktimes. The advantages of this limit, analogous to a gas limit, are:more accurate (validator/mining) rewards if they're assuming a particular blocktimeNo longer relevantThe new limit is only enabled from
CONSENSUS_V2_HEIGHT
onwards.A limit of 950 credits was chosen because:
BLOCKTIME
is supposed to be 10 seconds.Solution
verification, this incurs significant free compute. 4 solutions take 180ms to verify on macbook M1 max.EXECUTION_FIXED_COST
of 2 credits is introduced. This is not reflected in fees, as it is subsidized, but it does count towards theBLOCK_SPEND_LIMIT
. Benchmarks on M2 max imply between 15ms and 25ms verification time for executions.137
executions, which would still remain below thisBLOCK_SPEND_LIMIT
.Open questions
ROUND_SPEND_LIMIT*num_rounds
orPROPOSAL_SPEND_LIMIT*num_proposals
? Or better: could we impose a spend limit per individual proposal?Out of scope / future work
Test Plan
Related PRs
Replaces #2371