-
Notifications
You must be signed in to change notification settings - Fork 741
Make AVM implement block.HeightIndexedChainVM
#1699
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
Conversation
7558d33
to
4bc89d1
Compare
GetBlockID
-> GetBlockIDAtHeight
block.HeightIndexedChainVM
stale
stopVertexID ids.ID | ||
} | ||
|
||
func NewLinearizeOnInitializeVM(vm vertex.LinearizableVMWithEngine) *linearizeOnInitializeVM { | ||
hVM, _ := vm.(block.HeightIndexedChainVM) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this ever not be ok?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess it would just be nil then and we handle that below...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not in our usage but it could not be okay by somebody implementing a linearizable vm (definitely not advised haha).
return vm.state.GetBlockIDAtHeight(height) | ||
} | ||
|
||
func (*VM) VerifyHeightIndex(context.Context) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is never called because it is wrapped by the HeightIndexedVM?
(if so, may make sense to clarify that)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The vm itself implements HeightIndexedVM, it doesn't wrap it. This function is called here when we're generating the proposervm height index.
Reason why it's nil
is because the AVM has always had a height index so we don't need to verify it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does it always have it if it is performed async (and could be interrupted)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The AVM height index is not performed async. Since we linearized, each block was included in the height index on accept.
This is different than the P-chain where there is a period of time where both the inner vm and the proposervm height indexes are incomplete so we cannot simply return nil
there.
Signed-off-by: Dhruba Basu <7675102+dhrubabasu@users.noreply.github.com>
Why this should be merged
We use both
GetBlockID
andGetBlockIDAtHeight
in different places in the repo. This standardizes all of these calls toGetBlockIDAtHeight
.Additionally, implements
block.HeightIndexedChainVM
on the AVM to kick off the X-chain proposervm height index (https://github.com/ava-labs/avalanchego/blob/master/vms/proposervm/vm.go#L341)How this works
Find + replace + implement interface
How this was tested
CI