ACP-226: Dynamic Minimum Block Times
Details for Avalanche Community Proposal 226: Dynamic Minimum Block Times
ACP | 226 |
---|---|
Title | Dynamic Minimum Block Times |
Author(s) | Stephen Buttolph (@StephenButtolph), Michael Kaplan (@michaelkaplan13) |
Status | Proposed (Discussion) |
Track | Standards |
Abstract
Proposes replacing the current block production rate limiting mechanism on Avalanche EVM chains with a new mechanism where validators collectively and dynamically determine the minimum time between blocks.
Motivation
Currently, Avalanche EVM chains employ a mechanism to limit the rate of block production by increasing the "block gas cost" that must be burned if blocks are produced more frequently than the target block rate specified for the chain. The block gas cost is paid by summing the "priority fee" amounts that all transactions included in the block collectively burn. This mechanism has a few notable suboptimal aspects:
- There is no explicit minimum block delay time. Validators are capable of producing blocks as frequently as they would like by paying the additional fee, and too rapid block production could cause network stability issues.
- The target block rate can only be changed in a required network upgrade, which makes updates difficult to coordinate and operationalize.
- The target block rate can only be specified with 1-second granularity, which does not allow for configuring sub-second block times as performance improvements are made to make them feasible.
With the prospect of ACP-194 removing block execution from consensus and allowing for increases to the gas target through the dynamic ACP-176 mechanism, Avalanche EVM chains would be better suited by having a dynamic minimum block delay time denominated in milliseconds. This allows networks to ensure that blocks are never produced more frequently than the minimum block delay, and allows validators to dynamically influence the minimum block delay value by setting their preference.
Specification
Block Header Changes
Upon activation of this ACP, the blockGasCost
field in block headers will be required to be set to 0. This means that no validation of the cumulative priority fee amounts of transactions within the block exceeding the block gas cost is required. Additionally, two new fields will be added to EVM block headers: timestampMilliseconds
and minimumBlockDelayExcess
.
timestampMilliseconds
The canonical serialization and interpretation of EVM blocks already contains a block timestamp specified in seconds. Altering this would require deep changes to the EVM codebase, as well as cause breaking changes to tooling such as indexers and block explorers. Instead, a new field is added representing the unix timestamp in milliseconds. Header verification should verify the block.timestamp
(in seconds) is aligned with the block.timeMilliseconds
, more precisely: block.timestampMilliseconds / 1000 == block.timestamp
.
Existing tools that do not need millisecond granularity do not need to parse the new field, which limits the amount of breaking changes.
The timestampMilliseconds
field will be represented in block headers as a uint64
.
minimumBlockDelayExcess
The new minimumBlockDelayExcess
field in the block header will be used to derive the minimum number of milliseconds that must pass before the next block is allowed to be accepted. Specifically, if block has a minimumBlockDelayExcess
of , then the effective timestamp of block in milliseconds must be at least greater than the effective timestamp of block in milliseconds. , , and are defined below in the mechanism specification.
The minimumBlockDelayExcess
field will be represented in block headers as a uint64
.
The value of minimumBlockDelayExcess
can be updated in each block, similar to the gas target excess field introduced in ACP-176. The mechanism is specified below.
Dynamic minimumBlockDelay
mechanism
The minimumBlockDelay
can be defined as:
Where:
- is the global minimum
minimumBlockDelay
value in milliseconds - is a non-negative integer that is initialized upon the activation of this mechanism, referred to as the
minimumBlockDelayExcess
- is a constant that helps control the rate of change of
minimumBlockDelay
After the execution of transactions in block , the value of can be increased or decreased by up to . It must be the case that , or block is considered invalid. The amount by which changes after executing block is specified by the block builder.
Block builders (i.e., validators) may set their desired value for (i.e., their desired minimumBlockDelay
) in their configuration, and their desired value for can then be calculated as:
Note that since is only used locally and can be different for each node, it is safe for implementations to approximate the value of and round the resulting value to the nearest integer. Alternatively, client implementations can choose to use binary search to find the closest integer solution, as coreth
does to calculate a node's desired target excess.
When building a block, builders can calculate their next preferred value for based on the network's current value (q_current
) according to:
# Calculates a node's new desired value for q for a given block
def calc_next_q(q_current: int, q_desired: int, max_change: int) -> int:
if q_desired > q_current:
return q_current + min(q_desired - q_current, max_change)
else:
return q_current - min(q_current - q_desired, max_change)
As is updated after the execution of transactions within the block, is also updated such that at all times. As noted above, the change to only takes effect for subsequent block production, and cannot change the time at which block can be produced itself.
Gas Accounting Updates
Currently, the amount of gas capacity available is only incremented on a per second basis, as defined by ACP-176. With this ACP, it is expected for chains to be able to have sub-second block times. However, in the case when a chain's gas capacity is fully consumed (i.e. during period of heavy transaction load), blocks would not be able to produced at sub-second intervals because at least one second would need to elapse for new gas capacity to be added. To correct this, upon activation of this ACP, gas capacity will be added on a per millisecond basis.
The ACP-176 mechanism for determing the target gas consumption per second will remain unchanged, but its result will now be used to derive the target gas consumption per millisecond by dividing by 1000, and gas capacity will be added at that rate as each block advances time by some number of milliseconds.
Activation Parameters for the C-Chain
Parameters at activation on the C-Chain are:
Parameter | Description | C-Chain Configuration |
---|---|---|
minimum minimumBlockDelay value | 1 millisecond | |
initial minimumBlockDelayExcess | 7,970,124 | |
minimumBlockDelay update constant | ||
minimumBlockDelay update factor change limit | 200 |
was chosen as a lower bound for minimumBlockDelay
values to allow high-performance Avalanche L1s to be able to realize maximum performance and minimal transaction latency.
Based on the 1 millisecond value for , was chosen such that the effective minimumBlockDelay
value at time of activation is as close as possible to the current target block rate of the C-Chain, which is 2 seconds.
and were chosen such that it takes approximately 3,600 consecutive blocks of the maximum allowed change in for the effective minimumBlockDelay
value to either halve or double.
ProposerVM MinBlkDelay
The ProposerVM currently offers a static, configurable MinBlkDelay
seconds for consecutive blocks. With this ACP enforcing a dynamic minimum block delay time, any EVM instance adopting this ACP that also leverages the ProposerVM should ensure that the ProposerVM MinBlkDelay
is set to 0.
Note on Block Building
While there is no longer a requirement for blocks to burn a minimum block gas cost after the activation of this ACP, block builders should still take priority fees into account when building blocks to allow for transaction prioritization and to maximize the amount of native token (AVAX) burned in the block.
From a user (transaction issuer) perspective, this means that a non-zero priority fee would only ever need to be set to ensure inclusion during periods of maximum gas utilization.
Backwards Compatibility
While this proposal requires a network upgrade and updates the EVM block header format, it does so in a way that tries to maintain as much backwards compatibility as possible. Specifically, applications that currently parse and use the existing timestamp field that is denominated in seconds can continue to do so. The timestampMilliseconds
header value only needs to be used in cases where more granular timestamps are required.
Reference Implementation
A reference implementation is not yet provided, and must be made available for this ACP to be considered implementable
.
Security Considerations
Too rapid block production may cause availability issues if validators of the given blockchain are not able to keep up with blocks being proposed to consensus. This new mechanism allows validators to help influence the maximum frequency at which blocks are allowed to be produced, but potential misconfiguration or overly aggressive settings may cause problems for some validators.
The mechanism for the minimum block delay time to adapt based on validator preference has already been used previously to allow for dynamic gas targets based on validator preference on the C-Chain, providing more confidence that it is suitable for controlling this network parameter as well. However, because each block is capable of changing the value of the minimum block delay by a certain amount, the lower the minimum block delay is, the more blocks that can be produced in a given time, and the faster the minimum block delay value will be able to change. This creates a dynamic where the mechanism for controlling minimumBlockDelay
is more reactive at lower values, and less reactive at higher values. The global minimum minimumBlockDelay
() provides a lower bound of how quickly blocks can ever be produced, but it is left to validators to ensure that the effective value does not exceed their collective preference.
Acknowledgments
Thanks to Luigi D'Onorio DeMeo for continually bringing up the idea of reducing block times to provide better UX for users of Avalanche blockchains.
Copyright
Copyright and related rights waived via CC0.
Is this guide helpful?