-
Notifications
You must be signed in to change notification settings - Fork 205
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
add custom error for trie get node #4724
Changes from 12 commits
088cc58
e0dbd57
004264c
0d6e8d6
0141588
8b2d6e4
8d6ea22
3bcb4a3
4462ced
6c5d073
d7e1b6b
ac87c63
113c833
482aecb
737c93e
5f852a3
349d22a
3548ad0
bec60f1
ff5674d
094f227
0a17029
73275b1
a2deeff
65e517f
7dceb49
a683564
36ddeb4
7123970
a99d8d7
141ad52
aea1014
6d65587
25dc1d4
3e522d6
90c6e21
2a46bcc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,11 +2,13 @@ package sync | |
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
"github.com/ElrondNetwork/elrond-go-core/core" | ||
"github.com/ElrondNetwork/elrond-go-core/core/check" | ||
"github.com/ElrondNetwork/elrond-go-core/data" | ||
"github.com/ElrondNetwork/elrond-go-core/data/block" | ||
"github.com/ElrondNetwork/elrond-go/common" | ||
"github.com/ElrondNetwork/elrond-go/dataRetriever" | ||
"github.com/ElrondNetwork/elrond-go/errors" | ||
"github.com/ElrondNetwork/elrond-go/process" | ||
|
@@ -180,37 +182,32 @@ func (boot *MetaBootstrap) setLastEpochStartRound() { | |
func (boot *MetaBootstrap) SyncBlock(ctx context.Context) error { | ||
err := boot.syncBlock() | ||
if errors.IsGetNodeFromDBError(err) { | ||
errSync := boot.syncAccountsDBs() | ||
getNodeErr, ok := err.(*errors.GetNodeFromDBErr) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Misleading names. We have the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not done. We have the same function and the same cast. Please refactor. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. added interface here |
||
if !ok { | ||
return err | ||
} | ||
|
||
errSync := boot.syncAccountsDBs(getNodeErr.GetKey(), getNodeErr.GetIdentifier()) | ||
boot.handleTrieSyncError(errSync, ctx) | ||
} | ||
|
||
return err | ||
} | ||
|
||
func (boot *MetaBootstrap) syncAccountsDBs() error { | ||
var err error | ||
|
||
err = boot.syncValidatorAccountsState() | ||
if err != nil { | ||
return err | ||
func (boot *MetaBootstrap) syncAccountsDBs(key []byte, id string) error { | ||
switch id { | ||
iulianpascalau marked this conversation as resolved.
Show resolved
Hide resolved
|
||
case common.AccountsTrieIdentifier: | ||
return boot.syncUserAccountsState(key) | ||
case common.PeerAccountsTrieIdentifier: | ||
return boot.syncValidatorAccountsState(key) | ||
default: | ||
return fmt.Errorf("invalid trie identifier, id: %s", id) | ||
} | ||
|
||
err = boot.syncUserAccountsState() | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return nil | ||
} | ||
|
||
func (boot *MetaBootstrap) syncValidatorAccountsState() error { | ||
rootHash, err := boot.validatorAccountsDB.RootHash() | ||
if err != nil { | ||
return err | ||
} | ||
|
||
func (boot *MetaBootstrap) syncValidatorAccountsState(key []byte) error { | ||
log.Warn("base sync: started syncValidatorAccountsState") | ||
return boot.validatorStatisticsDBSyncer.SyncAccounts(rootHash) | ||
return boot.validatorStatisticsDBSyncer.SyncAccounts(key) | ||
} | ||
|
||
// Close closes the synchronization loop | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -144,7 +144,12 @@ func (boot *ShardBootstrap) StartSyncingBlocks() { | |
func (boot *ShardBootstrap) SyncBlock(ctx context.Context) error { | ||
err := boot.syncBlock() | ||
if errors.IsGetNodeFromDBError(err) { | ||
BeniaminDrasovean marked this conversation as resolved.
Show resolved
Hide resolved
|
||
errSync := boot.syncUserAccountsState() | ||
getNodeErr, ok := err.(*errors.GetNodeFromDBErr) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. also here, misleading names, please refactor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not done |
||
if !ok { | ||
return err | ||
} | ||
|
||
errSync := boot.syncUserAccountsState(getNodeErr.GetKey()) | ||
boot.handleTrieSyncError(errSync, ctx) | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1033,6 +1033,11 @@ func (ps *PruningStorer) RangeKeys(_ func(key []byte, val []byte) bool) { | |
debug.PrintStack() | ||
} | ||
|
||
// GetIdentifier returns the identifier for storer | ||
func (ps *PruningStorer) GetIdentifier() string { | ||
return ps.identifier | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that if we somehow, change the paths and names for the accounts storers, the whole code will break. We need to find a proper way to use storers identifiers in this case. Perhaps using the trie containers implementation as seen in factory/state/stateComponents.go L151-L178? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. from what i've tested, it still seems to work, will think more on the refactoring here There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Works for now because the strings from both constant sets are the same. Will need to refactor this somehow. You can refactor now or add a TODO + task. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. added todo and separate task for this |
||
} | ||
|
||
// IsInterfaceNil returns true if there is no value under the interface | ||
func (ps *PruningStorer) IsInterfaceNil() bool { | ||
return ps == nil | ||
|
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.
go imports?
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.
Done.