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

Improve ProposerVM Window-er #1292

Closed
aaronbuchwald opened this issue Apr 4, 2023 · 0 comments · Fixed by #1638
Closed

Improve ProposerVM Window-er #1292

aaronbuchwald opened this issue Apr 4, 2023 · 0 comments · Fixed by #1638
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Looking for someone to address this warp
Milestone

Comments

@aaronbuchwald
Copy link
Collaborator

aaronbuchwald commented Apr 4, 2023

When building a ProposerVM header for a block, the block builder can select any P-Chain height that is >= the parent P-Chain height. Nodes will consider the block valid iff they have accepted the P-Chain block at that height.

When the ProposerVM builds a new post-fork block: https://github.com/ava-labs/avalanchego/blob/master/vms/proposervm/block.go#L177

It calculates the optimal P-Chain Height here: https://github.com/ava-labs/avalanchego/blob/master/vms/proposervm/block.go#L191 by using the maximum of the parent proposervm header height (must be >= than the parent as mentioned above) and the result of GetMinimumHeight reported by the P-Chain: https://github.com/ava-labs/avalanchego/blob/master/vms/proposervm/vm.go#L779.

GetMinimumHeight uses a window of blocks accepted within the last 5 minutes where the "tip" of the window uses wall clock time to determine when to evict blocks that are >= 5 minutes old.

This is intended as an optimization to ensure that if two nodes disagree slightly about the accepted tip of the P-Chain, they should in the happy path still agree on a block that was accepted X amount of time ago (5 minutes with the current code).

This issue is to suggest two possible changes:

  1. reduce the size of the window to reduce the amount of lookbacks and diff set calculations performed by the P-Chain
  2. use the last accepted block on the P-Chain as the timestamp for the "tip" of the window rather than wall clock time

Improvement (1) is based on the observation that 5 minutes is very high and we should be able to reduce the size of the window, which will reduce the cost of diff set calculations at a minimal cost. This is an optimization in the spirit of, if you never miss a flight, then you're wasting time at the airport.

Improvement (2) should improve fault isolation for the ProposerVM in the case that no blocks have been accepted on the P-Chain in the last 5 minutes, the current behavior is to use the last accepted block. Instead, we should use the timestamp of the last accepted block on the P-Chain as the tip of the window-er. This will ensure that on the happy path, block building will keep using a slightly older block with respect to the tip of the P-Chain as opposed to falling back to the current height after wall clock time advances 5 minutes.

@aaronbuchwald aaronbuchwald added enhancement New feature or request good first issue Good for newcomers labels Apr 4, 2023
@aaronbuchwald aaronbuchwald changed the title Change ProposerVM Block Building Logic to Use P-Chain Time instead of Wall Clock Time for Windower Interval Improve ProposerVM Window-er Apr 4, 2023
@github-project-automation github-project-automation bot moved this to Backlog 🗄 in Ski Patrol May 16, 2023
@patrick-ogrady patrick-ogrady moved this from Backlog 🗄 to Selected for Development ⏳ in Ski Patrol May 16, 2023
@StephenButtolph StephenButtolph added the help wanted Looking for someone to address this label May 26, 2023
@StephenButtolph StephenButtolph modified the milestones: v1.10.3, v1.10.4 Jun 15, 2023
@joshua-kim joshua-kim moved this from Selected for Development ⏳ to In Review 👀 in Ski Patrol Jun 27, 2023
@joshua-kim joshua-kim linked a pull request Jun 27, 2023 that will close this issue
@github-project-automation github-project-automation bot moved this from In Review 👀 to Done ✅ in Ski Patrol Jun 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Looking for someone to address this warp
Projects
No open projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants