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

consensus: add timeout to UTXO queries #1391

Merged
merged 1 commit into from
Nov 26, 2020
Merged

consensus: add timeout to UTXO queries #1391

merged 1 commit into from
Nov 26, 2020

Conversation

hdevalence
Copy link
Contributor

@hdevalence hdevalence commented Nov 25, 2020

The state service API says explicitly that AwaitUTXO requests should be coupled
with a timeout layer. I didn't add this when I was testing and fixing the UTXO
lookup code (#1348, #1358) because causing zebrad to hang on a failed
dependency was useful for identifying cases where the code wasn't useful (and
then inspecting execution traces).

As a side effect, I believe this fixes the UTXO part of #1389, because far-future gossiped
blocks will have their UTXO lookups time out, though we may wish to do other
work as part of debugging the combined sync+gossip logic (#1372)

The state service API says explicitly that AwaitUTXO requests should be coupled
with a timeout layer. I didn't add this when I was testing and fixing the UTXO
lookup code (#1348, #1358) because causing zebrad to hang on a failed
dependency was useful for identifying cases where the code wasn't useful (and
then inspecting execution traces).

As a side effect, I believe this closes #1389, because far-future gossiped
blocks will have their UTXO lookups time out, though we may wish to do other
work as part of debugging the combined sync+gossip logic.
@teor2345
Copy link
Contributor

teor2345 commented Nov 26, 2020

As a side effect, I believe this closes #1389, because far-future gossiped
blocks will have their UTXO lookups time out, though we may wish to do other
work as part of debugging the combined sync+gossip logic (#1372)

I think this is true for most blocks, but not for blocks that:

  • are in the checkpoint verifier queue,
  • only have a coinbase transaction
  • only have shielded inputs

The checkpoint queue blocks will wait on their checkpoint range.

The coinbase-only and shielded-only blocks will pass the UTXO part of block verification, and end up waiting in the non-finalized state queue for their parent block.

So I might keep #1389 open, with a note that we've solved part of the issue with UTXO timeouts.

This fix might also fix the hangs in #1398, but we should double-check before closing that issue.

}

impl<ZS> Verifier<ZS> {
pub fn new(state: ZS) -> Self {
Self { state }
Self {
state: Timeout::new(state, UTXO_LOOKUP_TIMEOUT),
Copy link
Contributor

Choose a reason for hiding this comment

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

Note: Due to the mapping in the BlockVerifier, timeout errors should appear as VerifyBlockError::Transaction(Elapsed).

Ideally, we'd say that the UTXO request elapsed, but that doesn't really matter until we have a mempool. I've opened #1401 in the first stable release for follow-up.

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.

Looks good enough for the first alpha release.

@teor2345 teor2345 merged commit 5e48acf into main Nov 26, 2020
@teor2345 teor2345 deleted the script-utxo-timeout branch November 26, 2020 23:55
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.

2 participants