Conversation
5598803 to
8abec23
Compare
8abec23 to
5026f34
Compare
5026f34 to
d4dc39e
Compare
d4dc39e to
807d778
Compare
7e4b8b8 to
e516014
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #673 +/- ##
==========================================
- Coverage 86.23% 86.19% -0.05%
==========================================
Files 440 440
Lines 34068 34056 -12
Branches 5330 5327 -3
==========================================
- Hits 29378 29353 -25
- Misses 3668 3677 +9
- Partials 1022 1026 +4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| best_tip_blocks = [block_hash] | ||
|
|
||
| # XXX: if there's more than one we filter it so it's the smallest hash | ||
| if len(best_tip_blocks) > 1: |
There was a problem hiding this comment.
Should we create an issue to refactor this method and simply store the current best block in the storage?
There was a problem hiding this comment.
#540 sort of does this by using the height-index, but because it's not using this PR as a base it does this incorrectly and hides other tips, after this PR that change would be correct
There was a problem hiding this comment.
#1200 uses the block-height index to get the best block now, which will now always match with the best-block-tip since they can't be voided because of a tie
17c1ffc to
93d9f89
Compare
e516014 to
1b93f4d
Compare
93d9f89 to
da4ac0d
Compare
da4ac0d to
b74fa0d
Compare
1b93f4d to
b9b2390
Compare
b74fa0d to
45884e3
Compare
b9b2390 to
2dddd20
Compare
45884e3 to
b21d67c
Compare
2f2d7a8 to
1a3e1d0
Compare
299608f to
dd0b9fe
Compare
dda0697 to
4c5e2c1
Compare
|
|
||
| self.assert_response_equal(responses, expected) | ||
|
|
||
| @pytest.mark.skip(reason='broken') |
There was a problem hiding this comment.
This test needs to be fixed.
|
|
||
| self.assert_response_equal(responses, expected) | ||
|
|
||
| @pytest.mark.skip(reason='broken') |
There was a problem hiding this comment.
This test needs to be fixed.
bd3fc3e to
e789495
Compare
jansegre
left a comment
There was a problem hiding this comment.
We still need to have the tests passing, but I'm OK with the implementation.
0122823 to
ebac414
Compare
ebac414 to
da8b8d0
Compare
da8b8d0 to
248b99e
Compare
Co-authored-by: Jan Segre <jan@hathor.network>
Motivation
We've always supported "block ties", meaning that blocks that have the same score will tie and both void each other, while at the same time having to remain as "best block tips" (which always had to be a list). This pushes some unnecessary complexity throughout the code. There are no disadvantages to using the block hash as a tie-breaker and simplifying this complexity.
In practice there's a slight difference in the consensus of certain situations, the difference is that before some tied block chains would be voided all the way back until they weren't tied anymore, now one of them would be picked as best chain. This situation does not cause any incompatibility in how nodes sync and any new block with higher score will cause the same state on both chains.
This PR is the first step, that only focuses on removing ties at the consensus level. Subsequent PRs will focus on refactoring out the complexity of supporting multiple tips.
Acceptance criteria
update_voided_infoso when testing if a new block might be a winner, and its score is neither higher or lower than the current winner (that is, a tie), the hash is used as a tie breakerupdate_voided_infoso when a new block is not a winner, only the tip with highest score and lowest hash is stored as "best block tips" cacheget_best_block_tipsso it only ever returns a list of size 1, when the block tips index returns more than one tip with the highest score, the one if lowest hash is selectedtest_split_brain_only_blocks_different_heightso it checks the node will correctly not void everything back to the genesis and tie the two blocks (when before it used to)test_single_fork_not_bestsimilarly, so it checks that the best chain is considered