-
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
Changes from all commits
4bc89d1
efd4dff
495b7c1
a79b86b
e6e77a6
55f7278
fd95c16
7478712
041e891
7b1ef34
9d3ed63
d70a4fc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,7 @@ import ( | |
"github.com/ava-labs/avalanchego/snow/consensus/snowstorm" | ||
"github.com/ava-labs/avalanchego/snow/engine/avalanche/vertex" | ||
"github.com/ava-labs/avalanchego/snow/engine/common" | ||
"github.com/ava-labs/avalanchego/snow/engine/snowman/block" | ||
"github.com/ava-labs/avalanchego/utils/json" | ||
"github.com/ava-labs/avalanchego/utils/linkedhashmap" | ||
"github.com/ava-labs/avalanchego/utils/set" | ||
|
@@ -62,6 +63,7 @@ var ( | |
errBootstrapping = errors.New("chain is currently bootstrapping") | ||
|
||
_ vertex.LinearizableVMWithEngine = (*VM)(nil) | ||
_ block.HeightIndexedChainVM = (*VM)(nil) | ||
) | ||
|
||
type VM struct { | ||
|
@@ -387,6 +389,14 @@ func (vm *VM) LastAccepted(context.Context) (ids.ID, error) { | |
return vm.chainManager.LastAccepted(), nil | ||
} | ||
|
||
func (vm *VM) GetBlockIDAtHeight(_ context.Context, height uint64) (ids.ID, error) { | ||
return vm.state.GetBlockIDAtHeight(height) | ||
} | ||
|
||
func (*VM) VerifyHeightIndex(context.Context) error { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe 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 |
||
return nil | ||
} | ||
|
||
/* | ||
****************************************************************************** | ||
*********************************** DAG VM *********************************** | ||
|
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).