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

Clear mempool at a network upgrade #2773

Merged
merged 6 commits into from
Sep 23, 2021
Merged

Clear mempool at a network upgrade #2773

merged 6 commits into from
Sep 23, 2021

Conversation

upbqdn
Copy link
Member

@upbqdn upbqdn commented Sep 17, 2021

Motivation

Zebra needs a fresh mempool at each network upgrade.

Solution

At the moment, the implementation uses now_or_never() so that tip_change() behaves like a synchronous function. I tried other ways to approach this but to no avail.

The mempool is cleared whenever tip_change() returns TipAction::Reset, i.e.:

  • a newly created or cloned [ChainTipChange], which is behind the current tip,
  • extending the chain with a network upgrade activation block,
  • switching to a different best [Chain], also known as a rollback, and
  • receiving multiple blocks since the previous change.

I labeled it as a draft since I'm not sure about the solution.

Closes #2761.

@upbqdn upbqdn added the A-rust Area: Updates to Rust code label Sep 17, 2021
@upbqdn upbqdn self-assigned this Sep 17, 2021
@conradoplg
Copy link
Collaborator

The issue I'm working on also needs a ChainTipChange, so here's suggestion: open a separate PR with just passing the ChainTipChange to the mempool and storing it in a field (without doing anything with it). With that merged it's easier to start other issues that will also use it.

@upbqdn
Copy link
Member Author

upbqdn commented Sep 21, 2021

@conradoplg, have a look at #2785.

@conradoplg
Copy link
Collaborator

GitHub (wrongly?) closed this when I merged #2785 🤔

@conradoplg conradoplg reopened this Sep 21, 2021
teor2345
teor2345 previously approved these changes Sep 23, 2021
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.

Please feel free to merge as soon as #2777 is merged into this PR - I don't need to review again.

@upbqdn upbqdn marked this pull request as ready for review September 23, 2021 14:26
upbqdn and others added 2 commits September 23, 2021 20:12
* Clear the mempool by using a sync method

* Update docs

* Apply suggestions from code review

Co-authored-by: teor <teor@riseup.net>

* Refactor last_tip_change()

* Apply suggestions from code review

Co-authored-by: Janito Vaqueiro Ferreira Filho <janito.vff@gmail.com>

* Fix brackets

* Use best_tip_block instead of manual borrowing

Co-authored-by: teor <teor@riseup.net>

Co-authored-by: teor <teor@riseup.net>
Co-authored-by: Janito Vaqueiro Ferreira Filho <janito.vff@gmail.com>
Copy link
Collaborator

@conradoplg conradoplg left a comment

Choose a reason for hiding this comment

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

Approving per @teor2345's comment (I also did a quick review)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-rust Area: Updates to Rust code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Clear mempool each time the network upgrade changes
3 participants