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

Add test for verify_share return type #3590

Merged
merged 8 commits into from
Aug 20, 2024
Merged

Conversation

elliedavidson
Copy link
Member

@elliedavidson elliedavidson commented Aug 20, 2024

Closes #<ISSUE_NUMBER>

This PR:

This PR fixes a bug where an invalid vid share could be marked as valid. Specifically, the verify_share function from jellyfish returns a nested Result. Previously we were only checking the outer result. This means that a call to verify_share that returned a result of Ok(Err) would be incorrectly return true. This PR checks both the inner and outer results.

This PR does not:

Key places to review:

task_impls/src/consensus/mod.rs
testing/test-1/consensus_task.rs

How to test this PR:

To test this PR, check out this branch. Next, check out the following branch of jellyfish locally, 309fb5ba80a2b401dc7d5c355ff5cecece8fa412. This jellyfish branch contains a function to create a corrupt VID share in the exact way we were not covering before. This commit in HotShot contains the test_invalid_vid_disperse test, but it is currently ignored. To test that the test is doing what it is supposed to, revert the change in the consensus/mod.rs file to what it was previously. The test will now fail.

To run the test use the following command:
just tokio test test_invalid_vid_disperse --features=test-srs

NOTE: This test is ignored in the final commit because the corresponding function in jellyfish will likely not be merged soon, if at all. The test is gated by the test-srs feature to ensure it does not compile during normal testing. The point is just to demonstrate the old bug and that it was fixed. It might make sense to only merge the bug fixes and not the tests.

Tagging @jparr721 in case we want to look for bugs of a similar class.

Copy link
Contributor

@jparr721 jparr721 left a comment

Choose a reason for hiding this comment

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

Great find!!

Copy link
Contributor

@ss-es ss-es 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 to me overall!

Just some minor comments + questions about the feature gate

crates/task-impls/src/quorum_vote/mod.rs Outdated Show resolved Hide resolved
crates/task-impls/src/consensus/mod.rs Outdated Show resolved Hide resolved
@@ -231,6 +231,12 @@ impl VidScheme for VidSchemeType {
fn get_multiplicity(common: &Self::Common) -> u32 {
<Advz as VidScheme>::get_multiplicity(common)
}

/// Helper function for testing only
#[cfg(feature = "test-srs")]
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we ever run tests with test-srs -- it doesn't seem to even be in the justfile. Is this just for downstream users like the sequencer?

Copy link
Contributor

Choose a reason for hiding this comment

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

Oops, ignore this one -- I see it was used in the test which was also feature gated

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, that's intentional that we never run with this feature. It is a feature to match the 'test-srs' feature in jellyfish.

#[cfg(test)]
#[cfg_attr(async_executor_impl = "tokio", tokio::test(flavor = "multi_thread"))]
#[cfg_attr(async_executor_impl = "async-std", async_std::test)]
#[cfg(feature = "test-srs")]
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it possible to write this test without the feature gate so that it runs in CI? We can run it with the feature gate, but it would take more work and we'd have to add it separately

Copy link
Member Author

Choose a reason for hiding this comment

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

I feature gated it because it relies on changes in Jellyfish that may not be merged for a while. So I don't think it makes sense to run it in CI until jellyfish is updated.

Copy link
Member Author

Choose a reason for hiding this comment

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

Also, as I suggested above, it may make sense just to merge the fix for now, and wait to merge the test until later.

Copy link
Contributor

@ss-es ss-es 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 to me!

@elliedavidson elliedavidson merged commit cdd03ca into main Aug 20, 2024
35 of 36 checks passed
@elliedavidson elliedavidson deleted the ed/invalid_vid_share_fix branch August 20, 2024 18:07
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.

5 participants