Add test for proposervm BuildBlock after bootstrapping #2876
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Why this should be merged
time.Now()
- so the scheduler is initialized to allowBuildBlock
requests from the inner vm.a. https://github.com/ava-labs/avalanchego/blob/master/snow/engine/snowman/transitive.go#L513. Notice that this is before
SetState
is called, so we wouldn't expect the inner VM to have requested block building yet.a. What I had forgotten was that the scheduler was actually initialized to allow the BuildBlock calls through from the inner VM (by initially passing in
time.Now()
).a. https://github.com/ava-labs/avalanchego/blob/master/vms/proposervm/vm.go#L279
b. https://github.com/ava-labs/avalanchego/blob/master/vms/proposervm/post_fork_block.go#L148
c. https://github.com/ava-labs/avalanchego/blob/master/vms/proposervm/block.go#L203
d. https://github.com/ava-labs/avalanchego/blob/master/vms/proposervm/block.go#L413
Now, I'm not exactly sure how we want to handle this... Normally we'd re-add the the
PendingTxs
notification to the inner VM'stoEngine
channel... But in this case that would just be a passthrough to the proposer VM'stoEngine
channel... So we'd just spin callingBuildBlock
.Alternatively, rather than passing in
time.Now()
to the scheduler initialization, we could pass in something likeMaxTime
. But ifSetPreference
isn't isn't called after the P-chain advances... then we'd never build the block. We could just pick some random time in the future... But that seems arbitrary and fragile.Perhaps we should add some method to the
validators.State
interface that blocks until the requested height is accepted (or just periodically poll the existing functions) so that we could then manually re-calculate the scheduler window at that time.How this works
How this was tested