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 a bug to have invalid state references cache #759

Merged

Conversation

@moreal
Copy link
Contributor

moreal commented Jan 14, 2020

Originally, when the chain has forked, it was able to execute the genesis block multiple times and it caused invalid states cache because states cache works on only SetBlockStates(), GetBlockStates(). So ForkStateReferences() became to clear state references cache after the end of the task.

@moreal moreal added the bug label Jan 14, 2020
@moreal moreal requested review from dahlia, longfin, limebell and earlbread Jan 14, 2020
@moreal moreal self-assigned this Jan 14, 2020
@codecov

This comment has been minimized.

Copy link

codecov bot commented Jan 14, 2020

Codecov Report

Merging #759 into master will increase coverage by 0.02%.
The diff coverage is 100%.

@@            Coverage Diff             @@
##           master     #759      +/-   ##
==========================================
+ Coverage   86.36%   86.38%   +0.02%     
==========================================
  Files         222      222              
  Lines       19196    19218      +22     
==========================================
+ Hits        16579    16602      +23     
  Misses       1421     1421              
+ Partials     1196     1195       -1
Impacted Files Coverage Δ
Libplanet/Store/DefaultStore.cs 82.83% <100%> (+0.02%) ⬆️
Libplanet.Tests/Blockchain/BlockChainTest.cs 98.71% <100%> (+0.01%) ⬆️
Libplanet/Crypto/PrivateKey.cs 85.34% <0%> (-0.87%) ⬇️
Libplanet.Tests/Net/SwarmTest.cs 96.12% <0%> (+0.09%) ⬆️
Copy link
Member

dahlia left a comment

We need a regression test for this fix too.

@moreal moreal force-pushed the moreal:avoid-execute-genesis-block-many-times branch from 34e9c66 to add9fa0 Jan 14, 2020
@moreal moreal changed the title Avoid to execute actions in the genesis block when forking Fix a bug to have invalid state references cache Jan 14, 2020
@moreal moreal force-pushed the moreal:avoid-execute-genesis-block-many-times branch from add9fa0 to 9b48ab8 Jan 14, 2020
@moreal

This comment has been minimized.

Copy link
Contributor Author

moreal commented Jan 14, 2020

The solution to fix the bug where DefaultStore has invalid state references cache after fork, was changed into clearing the state references cache of forked chain after ForkStateReferences(). Also added a regression test for this fix.

moreal added 2 commits Jan 14, 2020
Originally, when the chain has forked, it was able to execute the genesis block
multiple times and it caused invalid states cache because states cache works on
only `SetBlockStates()`, `GetBlockStates()`.  So `ForkStateReferences()` became
to clear state references cache after the end of the task.
@moreal moreal force-pushed the moreal:avoid-execute-genesis-block-many-times branch from 9b48ab8 to 11bb64c Jan 14, 2020
@dahlia
dahlia approved these changes Jan 14, 2020
@moreal moreal merged commit 1c7ac4f into planetarium:master Jan 14, 2020
20 checks passed
20 checks passed
benchmarks (macos-latest)
Details
dist
Details
benchmarks (ubuntu-18.04)
Details
benchmarks (windows-latest)
Details
docs
Details
WIP Ready for review
Details
changelog This contains self-describing changelog.
Details
codecov/patch 100% of diff hit (target 86.36%)
Details
codecov/project 86.38% (+0.02%) compared to 25a97f5
Details
license/cla Contributor License Agreement is signed.
Details
planetarium.libplanet Build #20200114.13 succeeded
Details
planetarium.libplanet (Linux_Mono) Linux_Mono succeeded
Details
planetarium.libplanet (Linux_NETCore) Linux_NETCore succeeded
Details
planetarium.libplanet (Windows_Mono) Windows_Mono succeeded
Details
planetarium.libplanet (Windows_NETCore) Windows_NETCore succeeded
Details
planetarium.libplanet (Windows_NETCore_coverage) Windows_NETCore_coverage succeeded
Details
planetarium.libplanet (Windows_NETFramework) Windows_NETFramework succeeded
Details
planetarium.libplanet (macOS_Mono) macOS_Mono succeeded
Details
planetarium.libplanet (macOS_NETCore) macOS_NETCore succeeded
Details
planetarium.libplanet (macOS_Unity) macOS_Unity succeeded
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants
You can’t perform that action at this time.