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(net): reset block demand when not changed #1167
fix(net): reset block demand when not changed #1167
Conversation
90b1c05
to
81d7c28
Compare
Codecov Report
@@ Coverage Diff @@
## main #1167 +/- ##
==========================================
- Coverage 87.77% 87.67% -0.10%
==========================================
Files 355 355
Lines 30812 30840 +28
==========================================
- Hits 27044 27039 -5
- Misses 2057 2088 +31
- Partials 1711 1713 +2
|
51404b2
to
5d70c66
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we have a regression test for this bug? Would it be difficult or too complicated?
7b93570
to
61dcf01
Compare
@dahlia I tried to write the test in 61dcf01. As a comment, I felt those events should be reorganized once. For example, the |
Libplanet/Net/Swarm.cs
Outdated
@@ -1758,9 +1761,14 @@ CancellationToken cancellationToken | |||
{ | |||
// FIXME: Should only reset when BlockDemand has not changed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO we can remove this FIXME.
61dcf01
to
596683e
Compare
// FIXME: Should only reset when BlockDemand has not changed | ||
// from the beginning of this operation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@limebell I removed the lines also 🙏
596683e
to
a2f1f96
Compare
[changelog skip]
This commit checks the situation like below steps - Received `BlockHeader` 19 and `BlockDemand` 19 block. - `ProcessFillBlocks()` starts to download the 19 blocks. - Received `BlockHeader` 20 and `BlockDemand` 20 block. - `ProcessFillBlocks()` finished to download the 19 blocks and reset `Swarm<T>.BlockDemand` as `null`. - Though `BlockHeader` 101 was received, it will be ignored. [changelog skip]
a2f1f96
to
e14af51
Compare
I rebased this pull request, PTAL @planetarium/libplanet 🙏 |
…d-on-correct-time fix(net): reset block demand when not changed
This fixes an issue where it can reset block demand at an incorrect time. For instance:
BlockHeader
100 andBlockDemand
100 block.ProcessFillBlocks()
starts to download the 100 blocks.BlockHeader
101 andBlockDemand
101 block.ProcessFillBlocks()
finished to download the 100 blocks and resetSwarm<T>.BlockDemand
asnull
.BlockHeader
101 was received, it was ignored.I tried to fix the problem by resetting the block demand as
null
when startingSyncPreviousBlocksAsync()
after moving the block demand as the local variable, but it makes many code changes and I felt hard to build the situation. So I fixed the problem with the current changes simply. Also, I skipped the changelog becauseSwarm<T>.BlockDemand
was not released yet. If you think it needs to be recorded in the changelog or have other suggestions, please leave your opinions free.