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

Make state recover from empty if the recovery height is lower than the current state height #513

Merged
merged 2 commits into from
Feb 6, 2019

Conversation

lizhefeng
Copy link
Contributor

@lizhefeng lizhefeng commented Feb 5, 2019

Previously we only support recovering state db to a specific height which is lower than the blockchain height if and only if the existing state db height is lower than the target height. Now the state db can recover to any lower target height by clearing the existing state db and rebuilding it from scratch.

@lizhefeng lizhefeng requested a review from a team as a code owner February 5, 2019 18:51
@codecov
Copy link

codecov bot commented Feb 5, 2019

Codecov Report

Merging #513 into master will increase coverage by <.01%.
The diff coverage is 33.33%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #513      +/-   ##
==========================================
+ Coverage   60.77%   60.78%   +<.01%     
==========================================
  Files         128      128              
  Lines       11652    11654       +2     
==========================================
+ Hits         7082     7084       +2     
  Misses       3629     3629              
  Partials      941      941
Impacted Files Coverage Δ
blockchain/blockchain.go 55.09% <33.33%> (-0.2%) ⬇️
db/trie/extensionnode.go 59.32% <0%> (+1.69%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 657c047...f49fdd0. Read the comment docs.

@codecov
Copy link

codecov bot commented Feb 5, 2019

Codecov Report

Merging #513 into master will increase coverage by 0.01%.
The diff coverage is 33.33%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #513      +/-   ##
==========================================
+ Coverage   60.71%   60.73%   +0.01%     
==========================================
  Files         128      128              
  Lines       11682    11690       +8     
==========================================
+ Hits         7093     7100       +7     
+ Misses       3648     3644       -4     
- Partials      941      946       +5
Impacted Files Coverage Δ
blockchain/blockchain.go 55.53% <33.33%> (+0.44%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b480fe1...b8b0f91. Read the comment docs.

@@ -958,13 +958,16 @@ func (bc *blockchain) startExistingBlockchain(recoveryHeight uint64) error {
}
startHeight = 1
}
if recoveryHeight > 0 && startHeight <= recoveryHeight {
if recoveryHeight > 0 {
Copy link
Member

Choose a reason for hiding this comment

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

pls add unit test to cover this case.

require.NoError(chain.startExistingBlockchain(2))
height, _ = chain.sf.Height()
require.Equal(bc.TipHeight(), height)
require.True(2 == height)

Choose a reason for hiding this comment

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

don't use Yoda conditions (from stylecheck)

@raullenchai
Copy link
Member

No description provided.

description needed

@@ -1098,7 +1098,7 @@ func TestStartExistingBlockchain(t *testing.T) {
}()

require.NoError(addTestingTsfBlocks(bc))
require.True(5 == bc.TipHeight())
require.True(bc.TipHeight() == 5)
Copy link
Member

Choose a reason for hiding this comment

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

require.Equal

@@ -1125,7 +1125,13 @@ func TestStartExistingBlockchain(t *testing.T) {
require.NoError(chain.startExistingBlockchain(3))
height, _ = chain.sf.Height()
require.Equal(bc.TipHeight(), height)
require.True(3 == height)
require.True(height == 3)
Copy link
Member

Choose a reason for hiding this comment

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

require.Equal

@lizhefeng lizhefeng merged commit 731bc58 into iotexproject:master Feb 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants