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

Refactor validator windowing #882

Merged

Conversation

pgarg66
Copy link
Contributor

@pgarg66 pgarg66 commented Aug 6, 2018

@pgarg66 pgarg66 force-pushed the refactor-validator-windowing branch from a9ecf9d to 7d65fc0 Compare August 6, 2018 23:16
@pgarg66 pgarg66 added the CI Pull Request is ready to enter CI label Aug 6, 2018
@solana-grimes solana-grimes removed the CI Pull Request is ready to enter CI label Aug 6, 2018
src/streamer.rs Outdated
pix: u64,
consumed: u64,
received: &mut u64,
) -> bool {
Copy link
Contributor

Choose a reason for hiding this comment

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

Return Option<u64>?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

with u64 carrying received?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@garious , wondering how Option helps here. Is this to differentiate between different error conditions? Or something more?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, with u64 carrying received. It's more idiomatic Rust to avoid mut. You'll see those tests get shorter.

@pgarg66 pgarg66 force-pushed the refactor-validator-windowing branch from 7d65fc0 to 86ccd84 Compare August 7, 2018 01:29
@pgarg66
Copy link
Contributor Author

pgarg66 commented Aug 7, 2018

@garious , please see the latest patch. It simplified the tests, as you had mentioned.

Copy link
Contributor

@garious garious left a comment

Choose a reason for hiding this comment

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

Looks great, just a few quick nits.

src/streamer.rs Outdated
return None;
}

if pix > received {
Copy link
Contributor

Choose a reason for hiding this comment

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

Some(cmp::max(pix, received))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Cool.

src/streamer.rs Outdated
);

let result = validate_blob_against_window(debug_id, pix, *consumed, *received);
if result.is_none() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you use a match here? Under the hood, both is_none() and result.unwrap() below would use a match. I'm guessing clippy is about to suggest this as well. Let's see!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Funny, as I used match initially, and then changed it to this. I'll change it to match.

src/streamer.rs Outdated
#[test]
pub fn validate_blob_against_window_test() {
let recvd: u64 = 100;
assert!(validate_blob_against_window(0, 90 + WINDOW_SIZE, 90, recvd).is_none());
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you use assert_eq! in all of these? It'll give you better error messages.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure. I'll change it.

src/streamer.rs Outdated
) -> Option<u64> {
// Prevent receive window from running over
if pix >= consumed + WINDOW_SIZE {
debug!(
Copy link
Contributor

Choose a reason for hiding this comment

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

Does it bother anyone that this information is lost if not logging in debug mode? I see the original code did this, so I'm not going to ask you to clean that up here, but could you add a ticket to add an error type and change this function from Option<u64> to Result<u64>?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, will do.

- a unit test for windowing functions
- issue anza-xyz#857
@pgarg66 pgarg66 force-pushed the refactor-validator-windowing branch from 86ccd84 to 35ce82a Compare August 7, 2018 04:58
@pgarg66
Copy link
Contributor Author

pgarg66 commented Aug 7, 2018

@garious , this should address most of the comments.

Copy link
Contributor

@rob-solana rob-solana left a comment

Choose a reason for hiding this comment

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

nice rusting

Copy link
Contributor

@garious garious left a comment

Choose a reason for hiding this comment

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

:)

@garious garious added the automerge Merge this Pull Request automatically once CI passes label Aug 7, 2018
@solana-grimes solana-grimes merged commit ceb5a76 into solana-labs:master Aug 7, 2018
@pgarg66 pgarg66 deleted the refactor-validator-windowing branch August 7, 2018 16:24
brooksprumo pushed a commit to brooksprumo/solana that referenced this pull request Apr 18, 2024
* some test tweaks

* get rid of some redundancy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge Merge this Pull Request automatically once CI passes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants