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

Stage transactions not included in swapped chain #775

Merged
merged 3 commits into from
Feb 4, 2020

Conversation

moreal
Copy link
Contributor

@moreal moreal commented Jan 23, 2020

It fixes a bug where transactions included in unrendered blocks, could not be included in a block when reorg happened. It's based on network problem which they were not propagated sufficiently, so IMO it will be better to see this PR while looking message propagation after #767 PR was merged.

@codecov
Copy link

codecov bot commented Jan 23, 2020

Codecov Report

Merging #775 into master will decrease coverage by <.01%.
The diff coverage is 91.02%.

@@            Coverage Diff             @@
##           master     #775      +/-   ##
==========================================
- Coverage   86.43%   86.42%   -0.01%     
==========================================
  Files         226      226              
  Lines       19427    19496      +69     
==========================================
+ Hits        16791    16850      +59     
- Misses       1431     1434       +3     
- Partials     1205     1212       +7
Impacted Files Coverage Δ
Libplanet.Tests/Net/SwarmTest.cs 96.42% <100%> (+0.09%) ⬆️
Libplanet/Blockchain/BlockChain.cs 90.65% <69.56%> (-1.04%) ⬇️
Libplanet.Tests/Net/Protocols/TestTransport.cs 75.94% <0%> (-0.64%) ⬇️
Libplanet/Net/Protocols/KademliaProtocol.cs 64.09% <0%> (-0.39%) ⬇️
Libplanet.Tests/Common/Action/DumbAction.cs 83.92% <0%> (+1.78%) ⬆️

@moreal moreal self-assigned this Jan 23, 2020
@moreal moreal force-pushed the bugfix/stage-after-reorg branch 2 times, most recently from ce7e8ae to f6a2e2b Compare January 31, 2020 11:32
@moreal moreal changed the title Stage transactions included in unrendered blocks again Stage transactions not included in swapped chain Jan 31, 2020
@moreal moreal marked this pull request as ready for review January 31, 2020 11:58
@moreal moreal added the bug Something isn't working label Jan 31, 2020
CHANGES.md Outdated
@@ -188,6 +188,8 @@ To be released.
[[#759]]
- Fixed a bug where `BlockChain<T>` had rendered and evaluated actions in
the genesis block during forking. [[#763]]
- Fixed a bug where transactions which were not propagated sufficiently,
could not be included in a block when reorg happened. [[#775]]
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe this explanation does not sufficiently scope the situation, e.g., it is vague where's the borderline between sufficient and insufficient propagation. How about this?

Fixed a Swam<T>'s bug that some Transaction<T>s had become excluded from mining Block<T>s after reorg from α to β where a Transaction<T> was once included by a Block<T> (α) and not included by an other Block<T> (β) for the same Index due to the latency gap between nodes.

{
if (t.Equals(o))
if (this[index].Equals(other[index]))
Copy link
Contributor

Choose a reason for hiding this comment

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

How about using Block<T>.PreviousHash instead of random access?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It was to use index, not Block<T>.PreviousHash because I didn't have any idea for how to traverse, including the genesis block. Do you have some ideas for it?

Libplanet.Tests/Net/SwarmTest.cs Outdated Show resolved Hide resolved
Libplanet.Tests/Net/SwarmTest.cs Outdated Show resolved Hide resolved
dahlia
dahlia previously approved these changes Feb 3, 2020
limebell
limebell previously approved these changes Feb 3, 2020
@moreal moreal dismissed stale reviews from limebell and dahlia via c483e0d February 3, 2020 09:01
Assert.Equal((Text)dumbItem, minerA.BlockChain.GetState(_fx1.Address1));
Assert.Equal((Text)dumbItem, minerB.BlockChain.GetState(_fx1.Address2));

Log.Debug("Reorg occurred.");
Copy link
Contributor

Choose a reason for hiding this comment

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

At this time the reorg is not happened yet, right?

Suggested change
Log.Debug("Reorg occurred.");
Log.Debug("Reorg occurrs.");


Log.Debug("Reorg occurred.");
minerB.BroadcastBlock(blockC);
await minerA.BlockAppended.WaitAsync();
Copy link
Contributor

Choose a reason for hiding this comment

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

… or it might be better to write the log message at this time.

Suggested change
await minerA.BlockAppended.WaitAsync();
await minerA.BlockAppended.WaitAsync();
Log.Debug("Reorg occurred.");

Libplanet.Tests/Net/SwarmTest.cs Outdated Show resolved Hide resolved
Libplanet.Tests/Net/SwarmTest.cs Outdated Show resolved Hide resolved
Libplanet.Tests/Net/SwarmTest.cs Outdated Show resolved Hide resolved
Libplanet/Blockchain/BlockChain.cs Outdated Show resolved Hide resolved
Libplanet/Blockchain/BlockChain.cs Outdated Show resolved Hide resolved
Libplanet/Blockchain/BlockChain.cs Outdated Show resolved Hide resolved
Co-Authored-By: Hong Minhee <hong.minhee@gmail.com>
Co-Authored-By: Ko Chanhyuck <lime_bell@naver.com>
@moreal moreal merged commit 17d654f into planetarium:master Feb 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants