-
Notifications
You must be signed in to change notification settings - Fork 328
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
Conversation
Codecov Report
@@ 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
Continue to review full report at Codecov.
|
Codecov Report
@@ 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
Continue to review full report at Codecov.
|
@@ -958,13 +958,16 @@ func (bc *blockchain) startExistingBlockchain(recoveryHeight uint64) error { | |||
} | |||
startHeight = 1 | |||
} | |||
if recoveryHeight > 0 && startHeight <= recoveryHeight { | |||
if recoveryHeight > 0 { |
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.
pls add unit test to cover this case.
blockchain/blockchain_test.go
Outdated
require.NoError(chain.startExistingBlockchain(2)) | ||
height, _ = chain.sf.Height() | ||
require.Equal(bc.TipHeight(), height) | ||
require.True(2 == height) |
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.
don't use Yoda conditions (from stylecheck
)
description needed |
blockchain/blockchain_test.go
Outdated
@@ -1098,7 +1098,7 @@ func TestStartExistingBlockchain(t *testing.T) { | |||
}() | |||
|
|||
require.NoError(addTestingTsfBlocks(bc)) | |||
require.True(5 == bc.TipHeight()) | |||
require.True(bc.TipHeight() == 5) |
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.
require.Equal
blockchain/blockchain_test.go
Outdated
@@ -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) |
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.
require.Equal
…e current state height
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.