-
Notifications
You must be signed in to change notification settings - Fork 844
refactor(reexecute): export NewMainnetCChainVM() [1/2] #4758
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
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.
Pull request overview
This PR refactors the NewMainnetCChainVM() function by moving it from tests/reexecute/c/vm_reexecute.go to tests/reexecute/vm.go and exporting it. This enables the function to be reused by both the existing reexecute/c package and a future reexecute/chaos package as part of the work for #4695.
Key changes:
- Exported
newMainnetCChainVM()asNewMainnetCChainVM()and relocated it to the parentreexecutepackage - Updated the call site in
tests/reexecute/c/vm_reexecute.goto use the newly exported function - Removed unused imports from
tests/reexecute/c/vm_reexecute.gofollowing the function relocation
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| tests/reexecute/vm.go | New file containing the exported NewMainnetCChainVM() function with all necessary imports and mainnet chain ID constants |
| tests/reexecute/c/vm_reexecute.go | Updated to call reexecute.NewMainnetCChainVM() instead of the local newMainnetCChainVM(), removed the now-redundant function definition and associated imports |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| } | ||
| } | ||
|
|
||
| func newMainnetCChainVM( |
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.
Why does this have to move to be exported?
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 function lives in an executable package (main) - functions in executable packages can't be exported for reuse:
avalanchego/tests/reexecute/c/vm_reexecute.go
Lines 1 to 4 in 0aaf682
| // Copyright (C) 2019-2025, Ava Labs, Inc. All rights reserved. | |
| // See the file LICENSE for licensing terms. | |
| package main |
Why this should be merged
A prerequiste of #4695 is that we need to create a Coreth instance to read the last accepted block. We can do this with
newCChainMainnetVM(), but this is currently unexported and lives in thereexecute/cpackage.How this works
Exports
NewMainnetCChainVM()and moves it toreexecutefor usage byreexecute/cand the futurereexecute/chaospackages.How this was tested
CI
Need to be documented in RELEASES.md?
No