Skip to content
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

ACP-181 ProposerVM Epochs #181

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

cam-schultz
Copy link
Contributor

@cam-schultz cam-schultz commented Feb 8, 2025

Proposes enabling epochs in the ProposerVM to provide more stable views of the P-Chain to inner VMs

Rendered

Comment on lines +32 to +38
Epochs have a constant duration $D$, such that for any given epoch $E_n$, the difference between its start and end times equals this duration:

$$
T_{end}^n - T_{start}^n = D
$$

$D$ is hardcoded into the ProposerVM source code, and may only be changed by a required network upgrade.
Copy link
Contributor

@geoff-vball geoff-vball Feb 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if, instead of having a set epoch duration, where $T_{end}^n = T_{start}^{n+1}$, we used the timestamp of the block that sealed the previous epoch as the start time of the next epoch? This would eliminate edge case 2.

You would lose being able to keep track of the numbering of the epochs, but I don't think that's important anyway. In this case we should always be able to check the timestamp of the start of the epoch, because we already have to know PChainEpochHeight.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there's a long gap between the epoch's end time and the block that seals it, you'd still have the same situation of PChainEpochHeight and PChainHeight skew.

Predictable epochs make implementing the current implementation very straightforward. I initially decided against including pseudocode of this in the ACP itself, but think it would go a long way to explaining why the definition is what it is. I'll add that.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm pretty sure it would eliminate the skew and actually simplify the current implementation. I'll write out an example...

D = 100

Epoch 0 Tstart = 0 Tend = 100 PChainEpochHeight = 0
Block 1 time = 0
Block 2 time = 57
Block 3 time = 99
Block 4 time = 103 SEALS EPOCH 0

Epoch 1 Tstart = 103 Tend = 203 PChainEpochHeight = 4
Block 5 time = 107
Block 6 time = 202
Block 7 time = 215 SEALS EPOCH 1

Epoch 2 Tstart = 215 Tend = 315 PChainEpochHeight = 7
Block 8 time = 400 SEALS EPOCH 2

Epoch 3 Tstart = 400 Tend = 500 PChainEpochHeight = 8

Copy link
Contributor

@geoff-vball geoff-vball Feb 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All we need to check is if the timestamp of the parent is greater than D + timestamp of the PChainEpochHeight of the parent. If so, we advance the epoch.

Copy link
Contributor Author

@cam-schultz cam-schultz Feb 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The edge case occurs if there's a long gap between the last block within the epoch bounds and the block that seals the epoch. Modifying your example:

Epoch 0 Tstart = 0 Tend = 100 PChainEpochHeight = 0
Block 1 time = 0
Block 2 time = 57
Block 3 time = 99
Block 4 time = 500 SEALS EPOCH 0

Block 4 will use the same PChainEpochHeight as block 1, even though many epoch durations have elapsed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants