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

Handle duplicate blocks in zebra-state #1198

Merged
merged 11 commits into from
Oct 26, 2020
Merged

Handle duplicate blocks in zebra-state #1198

merged 11 commits into from
Oct 26, 2020

Conversation

yaahc
Copy link
Contributor

@yaahc yaahc commented Oct 22, 2020

Motivation

The zebra-state service needs to be able to handle duplicate blocks
idempotently. When we receive a CommitBlock request for a block that has
already been queued we should subscribe to the existing channel for sending the
result of commiting that block. If we receive a block that has already been
succesfully committed to the non-finalized or finalized state we should
immediately respond to the request that the block was committed succesfully.

Solution

This implements changes already outlined by The State
RFC
. We check for
successfully committed blocks first, since interacting with the queued blocks
struct at this point just complicates the implimentation. If the block has not
already been committed we then check if the block has already been queued, if
not we handle the block normally (normally here being the bit we already had
implemented).

Documentation Changes

  • Update the state RFC to match the ways this fix departs from the design
    • the main thing is that I switched the order of checking for duplicates
  • Add newly added functions to the state rfc Decided not to do this because they're minor getters that don't influence the rest of the design and aren't exposed as part of the API
  • Document newly added functions inline

Testing

Related Issues

@yaahc yaahc requested review from teor2345 and hdevalence October 22, 2020 19:58
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 really good, I like how neat the implementation is.

I'd like @hdevalence to double-check the channel stuff.

zebra-state/src/service.rs Outdated Show resolved Hide resolved
zebra-state/src/sled_state.rs Outdated Show resolved Hide resolved
teor2345
teor2345 previously approved these changes Oct 23, 2020
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.

Edit: This error was due to #1041.

@teor2345
Copy link
Contributor

teor2345 commented Oct 23, 2020

Edit: This error was due to #1041.

dconnolly
dconnolly previously approved these changes Oct 23, 2020
@hdevalence
Copy link
Contributor

Just to back up a second, why do we need to handle duplicate blocks idempotently?

@yaahc
Copy link
Contributor Author

yaahc commented Oct 23, 2020

@hdevalence previous discussion #1101 (comment)

@hdevalence
Copy link
Contributor

Thanks for the pointer!

Co-authored-by: teor <teor@riseup.net>
@yaahc yaahc dismissed stale reviews from dconnolly and teor2345 via 48e79fe October 23, 2020 20:23
@yaahc yaahc mentioned this pull request Oct 23, 2020
1 task
yaahc and others added 2 commits October 26, 2020 13:15
Co-authored-by: teor <teor@riseup.net>
Co-authored-by: teor <teor@riseup.net>
hdevalence
hdevalence previously approved these changes Oct 26, 2020
Copy link
Contributor

@hdevalence hdevalence left a comment

Choose a reason for hiding this comment

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

LGTM

@hdevalence
Copy link
Contributor

Clippy failures are unrelated to this PR

@yaahc yaahc merged commit 971765a into main Oct 26, 2020
@yaahc yaahc deleted the duplicate-blocks branch October 26, 2020 20:54
Copy link
Contributor

@dconnolly dconnolly left a comment

Choose a reason for hiding this comment

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

👍

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.

Panic: hashes must be unique in memory_state
4 participants