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

fix(blocksync): don't block in blocksync if our voting power is blocking the chain (backport #3406) #3421

Merged
merged 6 commits into from
Jul 5, 2024

Conversation

mergify[bot]
Copy link
Contributor

@mergify mergify bot commented Jul 4, 2024

Partially addresses #3415

The a node has no peers, blocksync gets stuck without switching to consesnus, because it needs info from other peers to have an idea of maximum height.

However, there is an edge case (mainly when testing) where a validator might have >2/3 of the voting power and other validators are not started. In this case, we know we are blocking the chain, so we don't need to stay in blockchain if the only condition is that we don't have peers.

Moreover, in order to block a chain, 1/3 of the voting power is enough, so the reasoning of this fix is the following:

  • I am a node and I am starting... shall I run blocksync?
  • Well, looks like I have 1/3 of the voting power (or more) at my current height... so there's no way the chain could advance in my absence... so I don't need to blocksync"

Explanation of commits:

  • Commit 1: e2e testbed reproducing the issue
  • Commit 2: commit with a trivial change to trigger e2e tests. Check the error: ❌ next to the commit hash (3fb1057)
  • Commit 3: Tentative fix. Although there is a ❌ next to the commit hash (16a46ea), if you click on it, you'll see that e2e are passing now.
  • Commit 4: revert commit2
  • Commit 5: Move the check for "local node is blocking the chain" outside the pool, as suggested by @cason
  • Commit 6: Fixed unit tests

All further commits: addressing other comments and tidying up the code


PR checklist

  • Tests written/updated
  • Changelog entry added in .changelog (we use unclog to manage our changelog)
  • [ ] Updated relevant documentation (docs/ or spec/) and code comments
  • Title follows the Conventional Commits spec

This is an automatic backport of pull request #3406 done by [Mergify](https://mergify.com).

…king the chain (#3406)

Partially addresses #3415

The a node has no peers, blocksync gets stuck without switching to
consesnus, because it needs info from other peers to have an idea of
maximum height.

However, there is an edge case (mainly when testing) where a validator
might have >2/3 of the voting power and other validators are not
started. In this case, we know we are blocking the chain, so we don't
need to stay in blockchain if the only condition is that we don't have
peers.

Moreover, in order to block a chain, 1/3 of the voting power is enough,
so the reasoning of this fix is the following:

* _I am a node and I am starting... shall I run blocksync?_
* _Well, looks like I have 1/3 of the voting power (or more) at my
current height... so there's no way the chain could advance in my
absence... so I don't need to blocksync"_

Explanation of commits:

* Commit 1: `e2e` testbed reproducing the issue
* Commit 2: commit with a trivial change to trigger `e2e` tests. Check
the error: ❌ next to the commit hash (3fb1057)
* Commit 3: Tentative fix. Although there is a ❌ next to the commit hash
(16a46ea), if you click on it, you'll see that `e2e` are passing now.
* Commit 4: revert commit2
* Commit 5: Move the check for "local node is blocking the chain"
outside the pool, as suggested by @cason
* Commit 6: Fixed unit tests

All further commits: addressing other comments and tidying up the code

---

#### PR checklist

- [x] Tests written/updated
- [x] Changelog entry added in `.changelog` (we use
[unclog](https://github.com/informalsystems/unclog) to manage our
changelog)
- ~[ ] Updated relevant documentation (`docs/` or `spec/`) and code
comments~
- [x] Title follows the [Conventional
Commits](https://www.conventionalcommits.org/en/v1.0.0/) spec

---------

Co-authored-by: Daniel <daniel.cason@informal.systems>
(cherry picked from commit bd95579)

# Conflicts:
#	.changelog/v0.38.3/bug-fixes/3406-blocksync-dont-stall-if-blocking-chain.md
#	blocksync/reactor.go
#	blocksync/reactor_test.go
#	node/node.go
@mergify mergify bot requested a review from a team as a code owner July 4, 2024 08:56
@mergify mergify bot added the conflicts label Jul 4, 2024

This comment was marked as resolved.

sergio-mena and others added 3 commits July 4, 2024 19:05
…king the chain (#3406)

Partially addresses #3415

The a node has no peers, blocksync gets stuck without switching to
consesnus, because it needs info from other peers to have an idea of
maximum height.

However, there is an edge case (mainly when testing) where a validator
might have >2/3 of the voting power and other validators are not
started. In this case, we know we are blocking the chain, so we don't
need to stay in blockchain if the only condition is that we don't have
peers.

Moreover, in order to block a chain, 1/3 of the voting power is enough,
so the reasoning of this fix is the following:

* _I am a node and I am starting... shall I run blocksync?_
* _Well, looks like I have 1/3 of the voting power (or more) at my
current height... so there's no way the chain could advance in my
absence... so I don't need to blocksync"_

Explanation of commits:

* Commit 1: `e2e` testbed reproducing the issue
* Commit 2: commit with a trivial change to trigger `e2e` tests. Check
the error: ❌ next to the commit hash (3fb1057)
* Commit 3: Tentative fix. Although there is a ❌ next to the commit hash
(16a46ea), if you click on it, you'll see that `e2e` are passing now.
* Commit 4: revert commit2
* Commit 5: Move the check for "local node is blocking the chain"
outside the pool, as suggested by @cason
* Commit 6: Fixed unit tests

All further commits: addressing other comments and tidying up the code

---

- [x] Tests written/updated
- [x] Changelog entry added in `.changelog` (we use
[unclog](https://github.com/informalsystems/unclog) to manage our
changelog)
- ~[ ] Updated relevant documentation (`docs/` or `spec/`) and code
comments~
- [x] Title follows the [Conventional
Commits](https://www.conventionalcommits.org/en/v1.0.0/) spec

---------

Co-authored-by: Daniel <daniel.cason@informal.systems>
@sergio-mena sergio-mena self-assigned this Jul 5, 2024
@sergio-mena sergio-mena added bug Something isn't working block-sync labels Jul 5, 2024
@sergio-mena sergio-mena changed the title fix(blocksync)!: don't block in blocksync if our voting power is blocking the chain (backport #3406) fix(blocksync): don't block in blocksync if our voting power is blocking the chain (backport #3406) Jul 5, 2024
Copy link
Contributor

@cason cason left a comment

Choose a reason for hiding this comment

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

Diff match except for some details and the introduction of NewReactorWithAddr, which by the way could be the original solution also in main.

Copy link
Contributor

@melekes melekes left a comment

Choose a reason for hiding this comment

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

👍

@sergio-mena sergio-mena merged commit 0aeebd5 into v0.38.x Jul 5, 2024
21 checks passed
@sergio-mena sergio-mena deleted the mergify/bp/v0.38.x/pr-3406 branch July 5, 2024 11:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
block-sync bug Something isn't working
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants