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

Move already in state check #2327

Closed
wants to merge 3 commits into from

Conversation

oxarbitrage
Copy link
Contributor

@oxarbitrage oxarbitrage commented Jun 16, 2021

Motivation

We want to move an already in the state check from the zebra-consensus into the downloaders. Will close #2307 when done.

This change also implements part of #862.

Solution

We have 2 very similar downloaders in zebrad:

The inbound one already have this check in https://github.com/ZcashFoundation/zebra/blob/main/zebrad/src/components/inbound/downloads.rs#L200-L208
For the sync we bring the state and use the same check as the inbound, we then remove the check from zebra-consensus.

I used the check from inbound to sync instead of https://github.com/ZcashFoundation/zebra/blob/main/zebra-consensus/src/block.rs#L125-L139 because it looks simpler.

Review

This is currently a draft to ask @teor2345 some questions i added to the code as comments.

Reviewer Checklist

  • Code implements Specs and Designs
  • Tests for Expected Behaviour
  • Tests for Errors

@@ -70,6 +70,9 @@ const MIN_LOOKAHEAD_LIMIT: usize = zebra_consensus::MAX_CHECKPOINT_HEIGHT_GAP *
/// failure loop.
const TIPS_RESPONSE_TIMEOUT: Duration = Duration::from_secs(6);

/// Controls how long we wait for a state `Depth` response to return.
const DEPTH_RESPONSE_TIMEOUT: Duration = Duration::from_secs(6);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am not totally sure if we want a timeout for this, or if we can use some already existing constant, or if we don't need a timer at all.

Copy link
Contributor

Choose a reason for hiding this comment

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

This request doesn't need a timeout - there are no awaits or futures in its code:
https://github.com/ZcashFoundation/zebra/blob/main/zebra-state/src/service.rs#L601

Only block verify/commit, transaction verify/commit, and AwaitUTXO requests need timeouts.

Janito just asked a similar question, so I've updated the documentation:
https://github.com/ZcashFoundation/zebra/pull/2337/files#diff-750c624c9e2c5c7252b8cb6036b9d6ac8d90bb6c4e4afa68025feb98223ea2eb

Copy link
Contributor

Choose a reason for hiding this comment

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

You can also read the Depth request docs here:
https://github.com/ZcashFoundation/zebra/blob/main/zebra-state/src/request.rs#L207

It says that if the block is missing, it returns None.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It seems not possible to remove the timer wrapper from this service due to https://github.com/ZcashFoundation/zebra/pull/2327/files#diff-d62cdeb1ec8372f0d832318236258f39a8b89a7fe87989723199a06f5deddeacR267

If this is changed and just attempt to pass the service:

expected struct tower::timeout::Timeout, found type parameter ZS

Copy link
Contributor

@teor2345 teor2345 left a comment

Choose a reason for hiding this comment

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

This looks good, just needs a tweak due to bug #2339

@teor2345 teor2345 added the P-Low label Jun 18, 2021
@teor2345
Copy link
Contributor

This PR is still worth doing, because it fixes part of #862. But it's a low priority.

@oxarbitrage oxarbitrage marked this pull request as ready for review June 18, 2021 13:13
@oxarbitrage oxarbitrage marked this pull request as draft June 18, 2021 13:23
@teor2345
Copy link
Contributor

teor2345 commented Jul 7, 2021

I added this PR to ticket #862, we can re-open it when we do that ticket.

@teor2345 teor2345 closed this Jul 7, 2021
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.

Move Block in State Checks to Downloaders
2 participants