Introduction
Hi, I'm cardene, a software engineer and technical writer focused on blockchain and AI.
I've also authored Japanese technical books on specification-driven development with LLMs and decentralized application (DApp) development.
I also build and publish a variety of tools, libraries, and open-source projects.
This article examines ACP181, a proposal to introduce time intervals called epochs for views of Avalanche's P-Chain. By fixing the referenced P-Chain block height for each epoch, the scheme improves the efficiency of validator set retrieval and the reliability of ICM message verification.
This article translates, summarizes, and expands on the following specification.
I also cover various EIPs, BIPs, SLIPs, CAIPs, ENSIPs, RFCs, and ACPs.
Overview
ACP181 defines a standard scheme for epoched views of the P-Chain, Avalanche's Platform Chain. A virtual machine (VM) implementing ACP181 can know in advance which P-Chain block height it will use when producing its next block.
In other words, the mechanism establishes which P-Chain state the VM will reference when building the next block. This makes it possible to optimize validator set retrieval in advance, rather than retrieving the set during block execution.
The standard does not introduce epochs directly into the P-Chain's own VM. Instead, it allows ACP181 to be implemented in layers that provide P-Chain state to VMs, such as the ProposerVM, the VM wrapper responsible for block proposal functionality.
Motivation
The P-Chain manages validators for L1 blockchains, including validators of the Primary Network (Avalanche's main network of built-in chains).
Adding or removing validators and changing their weights (for example, stake amounts) is recorded through transactions included in P-Chain blocks. Consequently, describing the validator set of an L1 or Subnet means describing its active validators at a particular P-Chain block height, including their weights, BLS keys, and node IDs.
The challenge is that applications need validator information from different points in time.
- On-demand access to historical state The validator set must be retrieved at an arbitrary P-Chain block height.
- Continuous access to up-to-date state Validator information may need to be retrieved as often as every P-Chain block.
Frequent retrieval is inefficient, particularly when traversing historical state involves substantial computational work.
The proposal therefore introduces a mechanism that fixes the referenced P-Chain block height for a period of time (an epoch). VMs and Subnets can reference a stable view of P-Chain state for that period.
Epoching allows the following optimizations.
- Efficient prefetching The validator set can be retrieved once per epoch instead of once per block.
- Efficient historical access Historical validator state can be traversed by epoch, allowing more efficient retrieval than examining individual blocks.
P-Chain epoching is intended to improve both the performance and consistency of VMs and network layers that work with validator information.
Specification
The Problem
Avalanche's P-Chain maintains validator sets for L1 blockchains and Subnets. Before this change, VMs could have to traverse P-Chain history during block execution to retrieve validator information at the required P-Chain height. This presents several problems.
- High computational cost The search depth is variable, so verification gas charges must account for the worst case.
- Unreliable ICM (Interchain Messaging) verification Off-chain relayers can encounter verification failures when changes to P-Chain state between message construction and verification affect the relevant validator set.
- Inefficient historical access Retrieving historical validator state can require traversing P-Chain blocks individually.
Block-by-block changes to the referenced P-Chain state therefore create challenges for both performance and reliability.
The Proposed Solution
ACP181 addresses these problems by fixing the referenced P-Chain block height for an epoch, a time interval covering a sequence of blocks.
Fixing the P-Chain View for an Epoch
An epoch consists of consecutive blocks that share the following three values.
| Field | Meaning |
|---|---|
| Epoch Number | A number identifying the epoch. |
| Epoch P-Chain Height | The P-Chain block height fixed for that epoch. |
| Epoch Start Time | The epoch's starting timestamp. |
Once at least the duration D has elapsed, the first qualifying block seals the epoch, and the following block starts the next epoch. This lets the VM continue referencing the same P-Chain state throughout the epoch.
More Reliable ICM Verification and Relaying
With epochs, the P-Chain block height used for ICM verification is fixed for the duration of each epoch. This has the following benefits.
- Potential gas cost reduction The validator set can be fetched in advance once per epoch rather than requiring a traversal for each block.
- Improved relayer reliability Since the P-Chain view used for verification remains unchanged within an epoch, relayers can determine which validator set to use ahead of time.
Efficient Historical Access
Historical validator state can also be traversed by epoch rather than block by block. This makes validator information retrieval more efficient and reduces the cost of historical processing.
Summary
ACP181 introduces epochs that stabilize the referenced P-Chain state over time and addresses the following problems.
| Problem | Solution |
|---|---|
| Expensive validator set retrieval | Fix the referenced block height for each epoch so the set can be prefetched. |
| Relayer verification failures | Keep the P-Chain state used for verification fixed throughout the epoch. |
| Inefficient historical access | Traverse historical state by epoch to speed up retrieval. |
ACP181 improves the predictability, efficiency, and stability of how VMs reference P-Chain state.
Assumptions
ACP181 assumes that a block has the following two pieces of information.
| Symbol | Meaning |
|---|---|
| Timestamp of block . | |
| P-Chain block height associated with block . |
Based on these assumptions, an epoch is defined as a group of consecutive blocks within a time interval.
Epoch Definition
An epoch is a period defined by three values shared by a contiguous sequence of blocks.
| Field | Meaning |
|---|---|
| Epoch Number | The number identifying the epoch. |
| Epoch P-Chain Height | The P-Chain block height associated with the epoch. |
| Epoch Start Time | The epoch's starting timestamp. |
Let denote the epoch with number . Its starting timestamp is , and its P-Chain height is .
Suppose block activates ACP181. The first epoch is defined as follows.
- The timestamp of the block immediately before the activation block becomes the first epoch's start time.
- Likewise, the P-Chain height of that preceding block becomes the first epoch's P-Chain height.
The initial epoch therefore begins using information from the last block before ACP activation.
Epoch Sealing
An epoch is sealed by the first block that satisfies the following condition.
- The block timestamp is greater than or equal to . Here, is a constant defined in the network upgrade that activates this specification.
This first qualifying block is called (the sealing block).
Importantly, the sealing block itself belongs to the epoch that it seals. This definition guarantees that every epoch contains at least one block.
Advancing an Epoch
The transition from epoch to epoch occurs when the block following the sealing block is produced. The first block of the next epoch has the following values.
| Field | Value |
|---|---|
| The P-Chain height of the sealing block . | |
| The timestamp of the sealing block . | |
| Epoch Number | , the preceding epoch number incremented by one. |
Each epoch has a well-defined boundary, with the information from the sealing block determining the next epoch.
Properties
Epoch Duration Bounds
The start time of an epoch is the timestamp of the block that sealed the preceding epoch. Every epoch therefore has a duration of at least , measured from its start time to its sealing block's timestamp.
However, because the sealing block is part of the epoch it seals, there is no upper bound on the duration of an epoch.
The actual epoch duration varies according to when the sealing block is produced. In theory, if that block is produced much later, the epoch can remain active for a very long time.
Fixing the P-Chain Height
When Avalanche blockchains build a block, the P-Chain height embedded in that block is used to determine the relevant validator set.
If the epoch's P-Chain height is used instead of the individual block's height, the validator set required for the next block can be determined in advance.
-
If block seals epoch , the next block belongs to the new epoch , and its P-Chain height is the P-Chain height of ().
-
If does not seal , continues to belong to and uses .
In either case, the possible P-Chain heights used by ( or ) are already known when is produced.
This design allows the validator set to be retrieved in advance and accessed promptly during block production, improving retrieval efficiency and predictability.
Use Cases
ICM Verification Optimization
Verifying an ICM (Interchain Messaging) message requires retrieving the validator set of the L1 or Subnet that signed the message. Under the pre-epoch mechanism, validator set retrieval took place during block execution, resulting in the following problem.
When verifying a block, the VM traverses backward from the current P-Chain height to the P-Chain height supplied by the ProposerVM to retrieve the validator set. The cost of this backward traversal varies considerably. To account for the worst case, VM implementations charge a relatively high fixed amount of gas for the verification.
Improvements Introduced by Epochs
With epochs, validator sets are retrieved at heights that remain fixed within each epoch and advance at epoch boundaries.
The following optimizations become possible because epoch boundaries are clearly defined.
| Improvement | Description |
|---|---|
| Retrieval at predictable intervals | The referenced P-Chain height is fixed for each epoch, making retrieval points predictable. |
| Asynchronous retrieval | Once an epoch has been sealed, after at least has elapsed, the next validator set can be prefetched independently of block execution. |
| Gas cost reduction | More predictable retrieval, including caching and prefetching, makes significant and safe reductions in verification gas charges possible in optimized VM implementations. |
This makes ICM message verification more efficient, including in terms of cost.
Improved Relayer Reliability
Before epoching, ICM VM implementations verified messages against the P-Chain state identified by the P-Chain height set by the ProposerVM. Under that mechanism, off-chain relayers (nodes responsible for delivering ICM messages to other chains) send messages as follows.
| Step | Operation |
|---|---|
| 1 | Retrieve the source chain's validator set at the verifying chain's currently proposed P-Chain height. |
| 2 | Collect BLS signatures from that validator set and construct a signed ICM message. |
| 3 | Submit a transaction containing the signed message to the verifying chain. |
If the relevant validator set changes between steps 1 and 3, the message can fail verification. In other words, changes to the P-Chain state between submission preparation and verification can reduce relayer reliability.
Reliability Improvements Introduced by Epochs
With epochs, the P-Chain height used for verification remains fixed for the duration of an epoch. This offers the following improvements for off-chain relayers.
| Improvement | Description |
|---|---|
| Stable state | The P-Chain height does not change during an epoch, so the referenced validator set remains stable. |
| Predictable behavior | Relayers can derive epoch boundaries from the specification or retrieve them via a node API, allowing them to determine the appropriate P-Chain height to query. |
| Flexible verification rules | If a VM permits verification against the preceding epoch's validator set as a fallback, failures caused by timing differences around epoch boundaries can be avoided. |
Epochs help relayers predict when and at which P-Chain height verification will occur, substantially improving the reliability and stability of cross-chain message delivery.
Backwards Compatibility
This change requires a network upgrade and is not backward compatible with the previous network rules. After the upgrade, implementing VMs use an epoched view of the P-Chain.
Consequently, downstream components and external systems that depend on a VM's view of P-Chain state must also account for epoched views. For example, ICM messages are signed by an L1's validator set at a specific P-Chain block height. Before epoching, using a validator set near the P-Chain tip was practical because deployed Avalanche VMs were at most a fixed number of blocks behind the P-Chain.
After epoching, however, the verifying chain's epoch P-Chain height must be taken into account. This height may be arbitrarily far behind the P-Chain tip. An ICM message constructor must therefore select the validator set based on the epoch P-Chain height of the chain that will verify the message.
Reference Implementation
The following pseudocode illustrates how the epoch to which a block belongs is determined. The key is whether the parent block's timestamp has reached the parent epoch's start time + D (the epoch duration).
// Epoch Duration
const D time.Duration
type Epoch struct {
PChainHeight uint64
Number uint64
StartTime time.Time
}
type Block interface {
Timestamp() time.Time
PChainHeight() uint64
Epoch() Epoch
}
func GetPChainEpoch(parent Block) Epoch {
parentTimestamp := parent.Timestamp()
parentEpoch := parent.Epoch()
epochEndTime := parentEpoch.StartTime.Add(D)
if parentTimestamp.Before(epochEndTime) {
// If the parent was issued before the end of its epoch, then it did not
// seal the epoch.
return parentEpoch
}
// The parent sealed the epoch, so the child is the first block of the new
// epoch.
return Epoch{
PChainHeight: parent.PChainHeight(),
Number: parentEpoch.Number + 1,
StartTime: parentTimestamp,
}
}The main points of the process are as follows.
-
If the parent block's timestamp is before the parent epoch's start time + D, the parent has not sealed the epoch, so the same epoch is returned.
-
If the parent block's timestamp is at or after the start time + D, the parent has sealed the epoch. The child block is the first block of a new epoch, initialized as follows.
PChainHeightis the parent block's P-Chain height.Numberis the parent epoch number plus one.StartTimeis the parent block's timestamp.
Setting the Epoch Duration
The epoch duration is configured at the network level. At the activation of ACP181, is set to five minutes on both Fuji (network ID 5) and Mainnet (network ID 1). Any future change to requires another network upgrade.
Changing the Epoch Duration
If a future network upgrade changes the epoch duration from to , the new value does not take effect until the current epoch ends. In other words, becomes effective at the end of the current epoch rather than at the upgrade's activation time.
This prevents an epoch in progress at the moment of the upgrade from having a realized duration shorter than both and . It preserves the minimum duration guarantee and the timing assumptions on which VMs and surrounding components depend.
Implementation Considerations
-
Consistent boundary conditions The first block whose timestamp reaches or exceeds
StartTime + Dseals the epoch. The sealing block is a member of the epoch it seals. -
Predictable P-Chain block height The new epoch's
PChainHeightis equal to the sealing block's P-Chain height, so the validator set relevant to the next epoch is known when the next block is built. -
Distribution of network configuration The value of affects protocol rules and must be agreed upon through a coordinated network upgrade. Using the same initial value (five minutes) on Fuji and Mainnet makes it easier to share tooling and operational procedures.
Security Considerations
Epoch P-Chain Height Skew
In theory, an epoch can have an unbounded duration.
A block's PChainEpochHeight (the P-Chain height fixed for its epoch) can therefore fall far behind the actual P-Chain tip.
This does not affect the validity of ICM verification within a VM implementing epoched P-Chain views, because the validator set at PChainEpochHeight is always known.
However, the following concerns arise.
| Potential problem | Description |
|---|---|
| Unresponsive nodes | When validators exit the validator set, their physical nodes may no longer respond to BLS signature requests. This makes constructing a valid ICM message more difficult. |
| Signatures from a stale validator set | A valid ICM message may still have been signed by a stale validator set. Signatures from validators that exited between PChainEpochHeight and the latest P-Chain tip no longer represent active stake. |
The following two measures can mitigate these risks.
- Use shorter epoch durations Reduce the delay between P-Chain updates and their use in ICM verification on an L1.
- Maintain consistent block production Produce new blocks promptly after (the epoch duration) has elapsed so epochs do not last unnecessarily long.
These measures help keep P-Chain progress and verification aligned and reduce the risks of relying on stale validator information.
Excessive Validator Churn
If a consensus engine uses an epoched view of the P-Chain, changes to the validator set during an epoch are concentrated into a single block at the epoch boundary.
If too many validators are replaced or their stake weights change too much at once, the following risks arise.
- Consensus inconsistencies, such as forks or failures.
- Network disruption due to an unstable validator set.
To avoid these situations, it is important to limit the amount of validator weight change at epoch boundaries. Possible strategies include the following.
| Strategy | Description |
|---|---|
| Queue validator changes | Accumulate change requests and apply them across multiple epochs. |
| Batch changes to the same validator | Offset weight increases and decreases for individual validators to minimize their net change. |
The primary purpose of ACP181 is optimizing ICM verification at the VM level. Mechanisms for mitigating these consensus-layer risks are therefore outside the scope of this ACP.
Open Questions
The proposal recorded two open questions.
| Question | Description |
|---|---|
| What is the optimal value of the epoch duration ? | A shorter duration increases the frequency of validator-set refreshes, while a longer duration increases the risks of stale validator sets. The chosen value must balance stability and efficiency. |
Is it safe for PChainEpochHeight and PChainHeight to differ significantly? |
If an epoch lasts a long time, the two heights can differ substantially within a block. The implications for consensus and ICM verification require further assessment. |
These questions concern operational parameter tuning and the safety evaluation of VM designs, and call for further evidence and discussion during implementation and operation.
Conclusion
ACP181 introduces epochs for P-Chain views, fixing the referenced P-Chain block height for each epoch to improve validator set retrieval, ICM message verification, and network stability.
The official ACP is now listed as Activated. This article retains the scope of the original explanation, including the proposal's historical open questions. The current specification also contains a section on EVM ICM verification gas cost updates.
If you have questions, feel free to contact me via Twitter DM.
I also publish on other platforms.


