-
Notifications
You must be signed in to change notification settings - Fork 116
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
feat: dot/state: implement import-state subcommand #1455
Conversation
@@ -180,6 +180,18 @@ func (v *VerificationManager) VerifyBlock(header *types.Header) error { | |||
|
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.
We should Unlock
above when we return early. (line:168 and line:173)
dot/sync/syncer.go
Outdated
} | ||
|
||
hasHeader, _ := s.blockState.HasHeader(bd.Hash) | ||
hasBody, _ := s.blockState.HasBlockBody(bd.Hash) | ||
if hasHeader && hasBody && bd.Number().Int64() <= bestNum.Int64() { | ||
if hasHeader && hasBody || bd.Number() != nil && bd.Number().Int64() <= bestNum.Int64() { |
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.
This is harder to read. Group logical statements in brackets.
dot/state/service.go
Outdated
DataDir: s.dbPath, | ||
} | ||
|
||
var err error |
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.
Move this variable declaration inside the else statement.
dot/state/epoch.go
Outdated
// SkipVerify returns whether verification for the given header should be skipped or not. | ||
// Only used in the case of imported state. | ||
func (s *EpochState) SkipVerify(header *types.Header) (bool, error) { | ||
skipToEpoch := s.skipToEpoch |
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.
Can the variable copy avoided?
entries := make(map[string]string) | ||
for _, pair := range pairs { | ||
pairArr := pair.([]interface{}) | ||
entries[pairArr[0].(string)] = pairArr[1].(string) |
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.
Can we assert as a safety check that the length of pairArr is always equal to two?
@arijitAD comments addressed! |
noot: feat: dot/state: implement import-state subcommand (#1455)
Changes
import-state
subcommand which imports state at a given block and starts the chain at that block when the node is startedTests
I also wrote some docs on how to use the
import-state
subcommand with a substrate archive node: https://hackmd.io/@nZ-twauPRISEa6G9zg3XRw/SJ8BgXOXO please try it and let me know how it goesChecklist
Issues