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

Snow VM #1831

Merged
merged 69 commits into from
Jan 15, 2025
Merged

Snow VM #1831

merged 69 commits into from
Jan 15, 2025

Conversation

aaronbuchwald
Copy link
Collaborator

@aaronbuchwald aaronbuchwald commented Dec 10, 2024

This PR integrates the changes added in #1867.

The overall change separates implementing the AvalancheGo block.VM and snowman.Block interfaces to fulfill DynamicStateSync into a separate, independently tested package.

This splits up the VM into individual pieces that can be overridden and creates a new Chain interface that can define three concrete block types

  • input - parsed directly from bytes with no further changes or processing
  • output - verified against its already verified parent (represents a processing block in consensus)
  • accepted - accepted against its verified version and accepted parent (represents latest accepted block)

Additionally, Chain implements Initialize and SetConsensusIndex to take in all of the necessary parameters supplied by AvalancheGo and to set the required subscriptions or hooks needed to operate ie. accepted/verified/rejected block subscriptions, notifications when the VM transitions to NormalOp, etc.

After integrating, this PR adds new integration action/auth agnostic integration tests for the updated VM package. This replaces the test coverage previously added through MorpheusVM and cuts down the MorpheusVM integration tests to only the tests written to run against workload.TestNetwork.

@aaronbuchwald aaronbuchwald added the DO NOT MERGE This PR is not meant to be merged in its current state label Dec 10, 2024
snow/vm.go Fixed Show fixed Hide fixed
vm/vm.go Fixed Show fixed Hide fixed
vm/vm.go Fixed Show fixed Hide fixed
vm/vm.go Fixed Show fixed Hide fixed
vm/vm.go Fixed Show fixed Hide fixed
vm/vm.go Fixed Show fixed Hide fixed
vm/vm.go Fixed Show fixed Hide fixed
vm/vm.go Fixed Show fixed Hide fixed
vm/vm.go Fixed Show fixed Hide fixed
vm/vm.go Fixed Show fixed Hide fixed
@aaronbuchwald
Copy link
Collaborator Author

aaronbuchwald commented Dec 11, 2024

Next steps:

  1. Clean up dynamic state sync and write snow dynamic state sync tests
  2. Move general purpose config out of snow package and replace with "context" that can either be a singleton or passed around similar to require.Equal(t, a, b) or r.Equal(a, b)
  3. Update out of date comments
  4. Replace "Options" misnomer (Configuration?)
  5. Handle cyclic dependency with chain index (chain must currently return last accepted block and potentially re-process blocks)
  6. Update VM package + rename to HyperVM + add HyperVM integration tests

Most importantly break this PR up

vm/vm.go Fixed Show fixed Hide fixed
Comment on lines +56 to +60
res.Errors = make([]string, len(errs))
for i, err := range errs {
if err != nil {
res.Errors[i] = err.Error()
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixes a bug discovered in a newly added test. If the error was nil, then the previous code triggered a panic.

Comment on lines +38 to +40
return fmt.Errorf("%w: tx timestamp (%d) < block timestamp (%d)", ErrTimestampTooLate, b.Timestamp, timestamp)
case b.Timestamp > timestamp+r.GetValidityWindow(): // tx: 100 block 10
return ErrTimestampTooEarly
return fmt.Errorf("%w: tx timestamp (%d) > block timestamp (%d) + validity window (%d)", ErrTimestampTooEarly, b.Timestamp, timestamp, r.GetValidityWindow())
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added details while debugging newly added tests. These errors are much more helpful with the added information.

@@ -72,10 +71,8 @@ func (p *PreExecutor) PreExecute(
}

// Verify auth if not already verified by caller
if verifyAuth {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This was never false previously.

Comment on lines +157 to +158
// NewTransaction creates a Transaction and initializes the private fields.
func NewTransaction(base *Base, actions Actions, auth Auth) (*Transaction, error) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Need this exported for newly added tests

examples/morpheusvm/tests/e2e/e2e_test.go Show resolved Hide resolved
internal/gossiper/handler.go Show resolved Hide resolved
internal/mempool/mempool_test.go Show resolved Hide resolved
tests/integration/integration.go Show resolved Hide resolved
@aaronbuchwald aaronbuchwald removed the DO NOT MERGE This PR is not meant to be merged in its current state label Jan 15, 2025
@aaronbuchwald aaronbuchwald marked this pull request as ready for review January 15, 2025 21:21
@aaronbuchwald aaronbuchwald merged commit a51a6c6 into main Jan 15, 2025
17 checks passed
@aaronbuchwald aaronbuchwald deleted the snow-vm branch January 15, 2025 22:05
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.

1 participant