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

Avoid an AwaitUtxo race condition when switching to the non-finalized state #5126

Closed
Tracked by #4937
teor2345 opened this issue Sep 9, 2022 · 1 comment
Closed
Tracked by #4937
Labels
A-state Area: State / database changes C-bug Category: This is a bug I-slow Problems with performance or responsiveness

Comments

@teor2345
Copy link
Contributor

teor2345 commented Sep 9, 2022

Motivation

Currently, Zebra ignores any UTXOs in FinalizedState.queued_by_prev_hash, because it is only used during checkpoint verification.

This creates a rare race condition between concurrent:

  • pending blocks in the last few checkpoints, and
  • the first few blocks doing full validation using UTXOs.

But it doesn't seem to happen much in practice. If it did, some blocks would temporarily fail full validation, until they get retried after the checkpointed blocks are committed.

Suggested Solution

  • Make QueuedBlocks generic, and use it for StateService.queued_finalized_blocks
  • Check StateService.queued_finalized_blocks in AwaitUtxo
  • Do a full sync to check that it's not too slow

Optional:

  • Only do the check when we're close to the last checkpoint configured for zebra_consensus::CheckpointVerifier, to avoid cloning a bunch of unused UTXOs. The last checkpoint depends on the checkpoint_sync config.
@teor2345 teor2345 changed the title Move FinalizedState.queued_blocks to the StateService, and check it in AwaitUtxo Avoid an AwaitUtxo race condition when switching to the non-finalized state Sep 9, 2022
@teor2345 teor2345 added C-bug Category: This is a bug I-slow Problems with performance or responsiveness P-Optional ✨ A-state Area: State / database changes labels Sep 9, 2022
@mpguerra mpguerra moved this to 🆕 New in Zebra Sep 22, 2022
@mpguerra mpguerra added this to Zebra Sep 22, 2022
@teor2345
Copy link
Contributor Author

teor2345 commented Oct 2, 2022

I don't think we're going to do this as part of #4937, it's not a release blocker.

@teor2345 teor2345 closed this as not planned Won't fix, can't repro, duplicate, stale Oct 3, 2022
Repository owner moved this from 🆕 New to ✅ Done in Zebra Oct 3, 2022
@mpguerra mpguerra moved this from ✅ Done to 🛑 Won't Fix in Zebra Nov 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-state Area: State / database changes C-bug Category: This is a bug I-slow Problems with performance or responsiveness
Projects
Status: Won't Fix
Development

No branches or pull requests

1 participant