Skip to content

Introduce test_network feature #3572

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

Open
wants to merge 15 commits into
base: staging
Choose a base branch
from
Open

Conversation

kpandl
Copy link
Collaborator

@kpandl kpandl commented Apr 2, 2025

Motivation

For testing purposes, it would be practical to test the snarkVM consensus version (and proof targets) heights through a --features test_network compilation flag in snarkOS. This PR introduces such a flag.

It also updates the snarkVM ref to the version where ProvableHQ/snarkVM#2693 is merged.

Test Plan

Tested with an added CLI output of consensus height thresholds for testing purposes, and verified it works.

@kpandl kpandl marked this pull request as ready for review April 2, 2025 15:53
@kpandl kpandl requested review from vicsn and kaimast April 2, 2025 15:53
@vicsn vicsn requested a review from niklaslong April 2, 2025 16:16
@kaimast
Copy link
Collaborator

kaimast commented Apr 2, 2025

This looks fine to me.

There is one thing to consider, though. Should the test feature enable test for all crates in the workspace? ledger-service, storage-service, router, and sync all have such a feature.
If not, we should leave a comment somewhere that explains what features/behavior it enables and why. Alternatively, we could name the feature something like test-consenus-heights instead.

"Big Picture" Comments

  • I dug through these feature flags a while ago when trying to debug [Bug] A test in the cli package fails when testing the entire workspace #3546. It's a little confusing how the test and test_targets features are used in some, but not all, unit tests (usually by having the feature set in a dev-dependency).

  • We should document all feature flags for the top-level crate/workspace. The Rust documentation points to this README as a good example of how to do it.

@vicsn
Copy link
Collaborator

vicsn commented Apr 2, 2025

We should document all feature flags for the top-level crate/workspace. The Rust documentation points to this README as a good example of how to do it.

Really good idea. Not sure if its overkill to use a tool to visualize the feature trees. This documentation can also document the discrepancy you noted regarding test and test_targets. CC Perhaps @joske wants to take a stab at this because he also has context on the addition of test_targets.

@niklaslong
Copy link
Collaborator

Not sure if its overkill to use a tool to visualize the feature trees.

You should be able to get quite far with cargo tree: https://doc.rust-lang.org/cargo/commands/cargo-tree.html, specifically the -e option used for searching through features, perhaps combined with -i for a reverse search.

@vicsn
Copy link
Collaborator

vicsn commented Apr 8, 2025

There is one thing to consider, though. Should the test feature enable test for all crates in the workspace? ledger-service, storage-service, router, and sync all have such a feature.

@kpandl want to give this a try, and see if we can still run a local devnet and land a transaction? No rush on this.

@kpandl
Copy link
Collaborator Author

kpandl commented Apr 14, 2025

Thanks, I've added the test feature to router, sync, and through feature propagation of bft to ledger-service and storage-service. I've also updated the router crate to propagate the test feature to the submodule.

Ran a devnet and verified a transaction still lands when using the test feature (didn't test anything else).

Copy link
Collaborator

@kaimast kaimast left a comment

Choose a reason for hiding this comment

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

Looks good!

@kaimast
Copy link
Collaborator

kaimast commented Apr 15, 2025

Seems like adding the snarkVM test feature broke something.

Does the test feature get enabled in unit tests? If it isn't, these changes shouldn't affect the tests, but it seems like they do.

@vicsn
Copy link
Collaborator

vicsn commented Apr 16, 2025

Seems like adding the snarkVM test feature broke something.
Does the test feature get enabled in unit tests? If it isn't, these changes shouldn't affect the tests, but it seems like they do.

Indeed, it seems like for some subcrates, features = [ "test" ] is enabled in a dev-dependencies subsection. Note for example that router had an empty test feature which is now suddenly enabled with a lot more junk in there: https://github.com/ProvableHQ/snarkOS/pull/3572/files#diff-f5e82e097aa5005ad9c92fe29abb9de43cddfbf974a5dcafcdad98e4cbb7b715R20

I see a couple of directions to achieve the original goal: ensure we can run a snarkOS network where novel features are enabled on a low block height.

  1. We introduce a new test_consensus_versions feature in snarkVM and snarkOS, which will use the test consensus version heights.
  2. We introduce test_targets and test_consensus_versions in snarkVM, but use a single feature in snarkOS called test_network which will enable both in snarkVM.
  3. We consolidate test_targets and test_consensus_versions into a single feature called test, but this requires untangling the morass of git grep -C2 test | grep Cargo.toml.

I vote for starting with option 2., and we can create an issue to clean up 3.

@kpandl
Copy link
Collaborator Author

kpandl commented Apr 23, 2025

Thanks, addressed option 2 now. Tested it along with ProvableHQ/snarkVM#2693 on a local devnet.
Note that CI will fail because it needs this snarkVM: ProvableHQ/snarkVM#2693

I'd suggest I temporarily change the snarkVM ref here so that we can let CI run and see if it passes.

@kpandl kpandl changed the title Introduce test feature Introduce test_network feature Apr 23, 2025
Cargo.toml Outdated
test_targets = [ "snarkos-cli/test_targets" ]
test_network = [
"snarkos-cli/test_network",
"snarkos-node/test_network"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why do we only have to activate these two subdirectories (cli and node)?

Given that we didn't activate snarkos-node/test_targets before, was that effectively some dead configuration code?

Copy link
Collaborator

Choose a reason for hiding this comment

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

@kpandl this question still stands - is snarkos-node/test_network actually used? Should it be called from cli/Cargo.toml or not?

Copy link
Collaborator

@vicsn vicsn left a comment

Choose a reason for hiding this comment

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

Lets wait with merging until snarkVM test_migration_heights is fixed

@kpandl kpandl requested a review from vicsn May 2, 2025 15:02
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.

4 participants