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

Feat/sync missing trie nodes #4616

Merged
merged 91 commits into from
May 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
91 commits
Select commit Hold shift + click to select a range
024bac0
propagate getNodeFromDb err to baseSync
BeniaminDrasovean Oct 13, 2022
b7c39e4
add unit tests
BeniaminDrasovean Oct 17, 2022
95d3774
Merge branch 'rc/v1.4.0' into propagate-getNodeFromDb-err
BeniaminDrasovean Oct 17, 2022
cfb725c
fix after review
BeniaminDrasovean Oct 18, 2022
324687a
Merge branch 'rc/v1.4.0' into propagate-getNodeFromDb-err
BeniaminDrasovean Oct 19, 2022
2f55480
Merge branch 'feat/sync-missing-trie-nodes' into propagate-getNodeFro…
BeniaminDrasovean Oct 20, 2022
b00d805
Merge pull request #4588 from ElrondNetwork/propagate-getNodeFromDb-err
BeniaminDrasovean Oct 20, 2022
f8eea9a
Merge branch 'rc/v1.4.0' into merge-rc-v1.4.0-feat-sync-missing-trie-…
ssd04 Nov 21, 2022
6144052
conflicts fix after merge
ssd04 Nov 21, 2022
0927cae
conflicts fix after merge - fix unit test
ssd04 Nov 21, 2022
8bc2f98
Merge pull request #4720 from ElrondNetwork/merge-rc-v1.4.0-feat-sync…
ssd04 Nov 21, 2022
088cc58
add custom error for trie get node
ssd04 Nov 21, 2022
e0dbd57
move get node from db custom error to common errors
ssd04 Nov 21, 2022
004264c
fix unit test on context closing
ssd04 Nov 21, 2022
0d6e8d6
fix unit tests in process sync
ssd04 Nov 21, 2022
0141588
add custom error cast check in error check function
ssd04 Nov 23, 2022
8b2d6e4
use new custom error in process unit tests
ssd04 Nov 23, 2022
8d6ea22
fix linter issue
ssd04 Nov 23, 2022
3bcb4a3
revert get node from db error additional check
ssd04 Nov 23, 2022
4462ced
use identifier to determine storage type
ssd04 Nov 23, 2022
6c5d073
add custom interface for get identifier
ssd04 Nov 23, 2022
d7e1b6b
fix comments and log messages
ssd04 Nov 23, 2022
ac87c63
fixes after review: comments fixes + renamings
ssd04 Nov 24, 2022
113c833
error from db renaming
ssd04 Dec 14, 2022
482aecb
renamed error with key in trie node
ssd04 Dec 15, 2022
737c93e
add interface for db error with key
ssd04 Dec 19, 2022
5f852a3
added todo for db identifier constants refactoring
ssd04 Dec 19, 2022
349d22a
refactor to use storer ids for dataRetriever
ssd04 Dec 22, 2022
3548ad0
fix and update unit tests for db identifier set
ssd04 Dec 22, 2022
bec60f1
fix factory processing unit tests
ssd04 Dec 23, 2022
ff5674d
refactor the set of accounts db identifier
ssd04 Dec 23, 2022
094f227
Merge pull request #4830 from ElrondNetwork/handle-duplicate-constant…
ssd04 Dec 23, 2022
0a17029
changed log warn to trace in get node from db
ssd04 Jan 9, 2023
73275b1
return err on CreateAndProcessMiniBlocks if getNodeFromDB err
BeniaminDrasovean Jan 12, 2023
a2deeff
small refactor
BeniaminDrasovean Jan 12, 2023
65e517f
return error if key not found
BeniaminDrasovean Feb 3, 2023
700cecf
Merge remote-tracking branch 'origin/rc/v1.5.0' into merge-rc/1.5.0-i…
BeniaminDrasovean Feb 3, 2023
773d9a8
fix after merge
BeniaminDrasovean Feb 3, 2023
0959e7e
Merge pull request #4955 from multiversx/merge-rc/1.5.0-in-feat/sync-…
iulianpascalau Feb 3, 2023
7dceb49
Merge branch 'feat/sync-missing-trie-nodes' into sync-missing-keys-only
BeniaminDrasovean Feb 3, 2023
a683564
fix after merge
BeniaminDrasovean Feb 3, 2023
36ddeb4
remove error wrapping from trie Get()
BeniaminDrasovean Feb 13, 2023
7123970
small logs refactor
BeniaminDrasovean Feb 14, 2023
a99d8d7
remove error wrapping when loading data trie
BeniaminDrasovean Mar 6, 2023
19022b1
Merge remote-tracking branch 'origin/rc/v1.6.0' into merge-rc/v1.6.0-…
BeniaminDrasovean Mar 6, 2023
f8ce921
Merge pull request #5058 from multiversx/merge-rc/v1.6.0-in-feat/sync…
BeniaminDrasovean Mar 6, 2023
141ad52
Merge branch 'feat/sync-missing-trie-nodes' into sync-missing-keys-only
BeniaminDrasovean Mar 6, 2023
aea1014
add GetIdentifier to StorageManager interface
BeniaminDrasovean Mar 16, 2023
6d65587
add stack trace print if getNodeFromDb error
BeniaminDrasovean Mar 16, 2023
25dc1d4
refactor log prints
BeniaminDrasovean Mar 16, 2023
ecc4f3f
Merge remote-tracking branch 'origin/rc/v1.6.0' into merge-rc/v1.6.0-…
BeniaminDrasovean Apr 3, 2023
a729637
Merge pull request #5147 from multiversx/merge-rc/v1.6.0-in-feat/sync…
BeniaminDrasovean Apr 3, 2023
3e522d6
Merge branch 'feat/sync-missing-trie-nodes' into sync-missing-keys-only
BeniaminDrasovean Apr 3, 2023
90c6e21
move IsGetNodeFromDbErr() to core
BeniaminDrasovean Apr 3, 2023
2a46bcc
fix after review
BeniaminDrasovean Apr 19, 2023
da1e15e
Merge pull request #4724 from multiversx/sync-missing-keys-only
BeniaminDrasovean Apr 21, 2023
de31e03
pass storageMarker as argument when SyncAccounts() is called
BeniaminDrasovean Apr 24, 2023
3968467
fix after review
BeniaminDrasovean Apr 25, 2023
e4cd99a
add TODOs
BeniaminDrasovean Apr 25, 2023
ad10f3c
notify and sync missing data trie node
BeniaminDrasovean May 4, 2023
4c49b06
Merge pull request #5188 from multiversx/accounts-db-syncer-refactor
BeniaminDrasovean May 4, 2023
891ac8c
Merge branch 'feat/sync-missing-trie-nodes' into sync-missing-data-tr…
BeniaminDrasovean May 4, 2023
0881d9e
add unit test for MissingDataTrieNodeFound method
BeniaminDrasovean May 4, 2023
455e0f2
fix race condition
BeniaminDrasovean May 4, 2023
e540957
reset watchdog timeout on MissingDataTrieNodeFound() call
BeniaminDrasovean May 8, 2023
1c66c1e
fix after review
BeniaminDrasovean May 11, 2023
ed65313
fix after review
BeniaminDrasovean May 12, 2023
7afe9f3
Merge pull request #5217 from multiversx/sync-missing-data-trie-nodes
BeniaminDrasovean May 12, 2023
d592f3d
Merge remote-tracking branch 'origin/rc/v1.6.0' into merge-rc/v1.6.0-…
BeniaminDrasovean May 12, 2023
5ce0b74
fix after merge
BeniaminDrasovean May 12, 2023
1722e8a
Merge pull request #5241 from multiversx/merge-rc/v1.6.0-in-feat/sync…
BeniaminDrasovean May 12, 2023
7e2d147
Merge remote-tracking branch 'origin/rc/v1.6.0' into merge-rc/1.6.0-i…
BeniaminDrasovean May 16, 2023
f2cdeee
fix after merge
BeniaminDrasovean May 16, 2023
be5247f
Merge pull request #5243 from multiversx/merge-rc/1.6.0-in-feat/sync-…
BeniaminDrasovean May 16, 2023
6a6f938
Merge remote-tracking branch 'origin/rc/v1.6.0' into merge-rc/v1.6.0-…
BeniaminDrasovean May 18, 2023
b84e042
fix after merge and update go mod
BeniaminDrasovean May 18, 2023
e183734
Merge pull request #5251 from multiversx/merge-rc/v1.6.0-in-feat/sync…
BeniaminDrasovean May 18, 2023
7ec6cfe
remove duplicate inits of NewTrieStorageManagerArgs in trie package
BeniaminDrasovean May 22, 2023
1094c2d
remove duplicated NewTrieStorageManagerArgs inits
BeniaminDrasovean May 22, 2023
cb6d084
add identifier to trie storage manager
BeniaminDrasovean May 22, 2023
b992485
use identifier from tsm instead of id from storage
BeniaminDrasovean May 22, 2023
075f73a
fix after review
BeniaminDrasovean May 23, 2023
4672b47
Merge pull request #5258 from multiversx/add-identifer-in-tsm
BeniaminDrasovean May 23, 2023
ed32aca
Merge remote-tracking branch 'origin/rc/v1.6.0' into merge-rc/v1.6.0-…
BeniaminDrasovean May 23, 2023
63d3d01
update go mod
BeniaminDrasovean May 23, 2023
fb3be8c
Merge branch 'feat/sync-missing-trie-nodes' into merge-rc/v1.6.0-in-f…
BeniaminDrasovean May 23, 2023
3c7d956
Merge pull request #5270 from multiversx/merge-rc/v1.6.0-in-feat/bala…
BeniaminDrasovean May 23, 2023
5e123e5
fix race condition in test
BeniaminDrasovean May 24, 2023
170bc43
Merge pull request #5271 from multiversx/fix-failing-test
BeniaminDrasovean May 24, 2023
9b2d400
proper release
BeniaminDrasovean May 24, 2023
ac275df
Merge pull request #5273 from multiversx/proper-releases-for-feat/syn…
BeniaminDrasovean May 24, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 0 additions & 3 deletions common/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -770,9 +770,6 @@ const HardforkResolversIdentifier = "hardfork resolver"
// EpochStartInterceptorsIdentifier represents the identifier that is used in the start-in-epoch process
const EpochStartInterceptorsIdentifier = "epoch start interceptor"

// GetNodeFromDBErrorString represents the string which is returned when a getting node from DB returns an error
const GetNodeFromDBErrorString = "getNodeFromDB error"

// TimeoutGettingTrieNodes defines the timeout in trie sync operation if no node is received
const TimeoutGettingTrieNodes = 2 * time.Minute // to consider syncing a very large trie node of 64MB at ~1MB/s

Expand Down
3 changes: 3 additions & 0 deletions common/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@ var ErrInvalidTimeout = errors.New("invalid timeout value")

// ErrNilWasmChangeLocker signals that a nil wasm change locker has been provided
var ErrNilWasmChangeLocker = errors.New("nil wasm change locker")

// ErrNilStateSyncNotifierSubscriber signals that a nil state sync notifier subscriber has been provided
var ErrNilStateSyncNotifierSubscriber = errors.New("nil state sync notifier subscriber")
35 changes: 29 additions & 6 deletions common/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ type TrieStats interface {
GetTrieStats(address string, rootHash []byte) (*statistics.TrieStatsDTO, error)
}

// StorageMarker is used to mark the given storer as synced and active
type StorageMarker interface {
MarkStorerAsSyncedAndActive(storer StorageManager)
IsInterfaceNil() bool
}

// KeyBuilder is used for building trie keys as you traverse the trie
type KeyBuilder interface {
BuildKey(keyPart []byte)
Expand All @@ -70,9 +76,8 @@ type DataTrieHandler interface {

// StorageManager manages all trie storage operations
type StorageManager interface {
Get(key []byte) ([]byte, error)
TrieStorageInteractor
GetFromCurrentEpoch(key []byte) ([]byte, error)
Put(key []byte, val []byte) error
PutInEpoch(key []byte, val []byte, epoch uint32) error
PutInEpochWithoutCache(key []byte, val []byte, epoch uint32) error
TakeSnapshot(address string, rootHash []byte, mainTrieRootHash []byte, iteratorChannels *TrieIteratorChannels, missingNodesChan chan []byte, stats SnapshotStatisticsHandler, epoch uint32)
Expand All @@ -83,7 +88,6 @@ type StorageManager interface {
EnterPruningBufferingMode()
ExitPruningBufferingMode()
AddDirtyCheckpointHashes([]byte, ModifiedHashes) bool
Remove(hash []byte) error
SetEpochForPutOperation(uint32)
ShouldTakeSnapshot() bool
GetBaseTrieStorageManager() StorageManager
Expand All @@ -92,8 +96,14 @@ type StorageManager interface {
IsInterfaceNil() bool
}

// DBWriteCacher is used to cache changes made to the trie, and only write to the database when it's needed
type DBWriteCacher interface {
// TrieStorageInteractor defines the methods used for interacting with the trie storage
type TrieStorageInteractor interface {
BaseStorer
GetIdentifier() string
}

// BaseStorer define the base methods needed for a storer
type BaseStorer interface {
Put(key, val []byte) error
Get(key []byte) ([]byte, error)
Remove(key []byte) error
Expand All @@ -103,7 +113,7 @@ type DBWriteCacher interface {

// SnapshotDbHandler is used to keep track of how many references a snapshot db has
type SnapshotDbHandler interface {
DBWriteCacher
BaseStorer
IsInUse() bool
DecreaseNumReferences()
IncreaseNumReferences()
Expand Down Expand Up @@ -364,3 +374,16 @@ type ManagedPeersHolder interface {
IsMultiKeyMode() bool
IsInterfaceNil() bool
}

// MissingTrieNodesNotifier defines the operations of an entity that notifies about missing trie nodes
type MissingTrieNodesNotifier interface {
RegisterHandler(handler StateSyncNotifierSubscriber) error
AsyncNotifyMissingTrieNode(hash []byte)
IsInterfaceNil() bool
}

// StateSyncNotifierSubscriber defines the operations of an entity that subscribes to a missing trie nodes notifier
type StateSyncNotifierSubscriber interface {
MissingDataTrieNodeFound(hash []byte)
IsInterfaceNil() bool
}
4 changes: 2 additions & 2 deletions common/logging/errorLogging.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package logging

import (
"github.com/multiversx/mx-chain-core-go/core"
"github.com/multiversx/mx-chain-core-go/core/check"
chainErrors "github.com/multiversx/mx-chain-go/errors"
logger "github.com/multiversx/mx-chain-logger-go"
)

Expand All @@ -24,7 +24,7 @@ func logErrAsLevelExceptAsDebugIfClosingError(logInstance logger.Logger, logLeve
return
}

if chainErrors.IsClosingError(err) {
if core.IsClosingError(err) {
logLevel = logger.LogDebug
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"github.com/multiversx/mx-chain-go/dataRetriever"
"github.com/multiversx/mx-chain-go/dataRetriever/factory/containers"
"github.com/multiversx/mx-chain-go/dataRetriever/resolvers"
triesFactory "github.com/multiversx/mx-chain-go/trie/factory"

"github.com/multiversx/mx-chain-core-go/marshal"
"github.com/multiversx/mx-chain-go/process/factory"
Expand Down Expand Up @@ -142,7 +141,7 @@ func (mrcf *metaResolversContainerFactory) AddShardTrieNodeResolvers(container d
identifierTrieNodes := factory.AccountTrieNodesTopic + shardC.CommunicationIdentifier(idx)
resolver, err := mrcf.createTrieNodesResolver(
identifierTrieNodes,
triesFactory.UserAccountTrie,
dataRetriever.UserAccountsUnit.String(),
idx,
)
if err != nil {
Expand Down Expand Up @@ -295,7 +294,7 @@ func (mrcf *metaResolversContainerFactory) generateTrieNodesResolvers() error {
identifierTrieNodes := factory.AccountTrieNodesTopic + core.CommunicationIdentifierBetweenShards(core.MetachainShardId, core.MetachainShardId)
resolver, err := mrcf.createTrieNodesResolver(
identifierTrieNodes,
triesFactory.UserAccountTrie,
dataRetriever.UserAccountsUnit.String(),
core.MetachainShardId,
)
if err != nil {
Expand All @@ -308,7 +307,7 @@ func (mrcf *metaResolversContainerFactory) generateTrieNodesResolvers() error {
identifierTrieNodes = factory.ValidatorTrieNodesTopic + core.CommunicationIdentifierBetweenShards(core.MetachainShardId, core.MetachainShardId)
resolver, err = mrcf.createTrieNodesResolver(
identifierTrieNodes,
triesFactory.PeerAccountTrie,
dataRetriever.PeerAccountsUnit.String(),
core.MetachainShardId,
)
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
"github.com/multiversx/mx-chain-go/testscommon/p2pmocks"
storageStubs "github.com/multiversx/mx-chain-go/testscommon/storage"
trieMock "github.com/multiversx/mx-chain-go/testscommon/trie"
triesFactory "github.com/multiversx/mx-chain-go/trie/factory"
"github.com/stretchr/testify/assert"
)

Expand Down Expand Up @@ -82,8 +81,8 @@ func createStoreForMeta() dataRetriever.StorageService {

func createTriesHolderForMeta() common.TriesHolder {
triesHolder := state.NewDataTriesHolder()
triesHolder.Put([]byte(triesFactory.UserAccountTrie), &trieMock.TrieStub{})
triesHolder.Put([]byte(triesFactory.PeerAccountTrie), &trieMock.TrieStub{})
triesHolder.Put([]byte(dataRetriever.UserAccountsUnit.String()), &trieMock.TrieStub{})
triesHolder.Put([]byte(dataRetriever.PeerAccountsUnit.String()), &trieMock.TrieStub{})
return triesHolder
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"github.com/multiversx/mx-chain-go/dataRetriever/factory/containers"
"github.com/multiversx/mx-chain-go/dataRetriever/resolvers"
"github.com/multiversx/mx-chain-go/process/factory"
triesFactory "github.com/multiversx/mx-chain-go/trie/factory"
)

var _ dataRetriever.ResolversContainerFactory = (*shardResolversContainerFactory)(nil)
Expand Down Expand Up @@ -232,7 +231,7 @@ func (srcf *shardResolversContainerFactory) generateTrieNodesResolvers() error {
identifierTrieNodes := factory.AccountTrieNodesTopic + shardC.CommunicationIdentifier(core.MetachainShardId)
resolver, err := srcf.createTrieNodesResolver(
identifierTrieNodes,
triesFactory.UserAccountTrie,
dataRetriever.UserAccountsUnit.String(),
core.MetachainShardId,
)
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
"github.com/multiversx/mx-chain-go/testscommon/p2pmocks"
storageStubs "github.com/multiversx/mx-chain-go/testscommon/storage"
trieMock "github.com/multiversx/mx-chain-go/testscommon/trie"
triesFactory "github.com/multiversx/mx-chain-go/trie/factory"
"github.com/stretchr/testify/assert"
)

Expand Down Expand Up @@ -88,8 +87,8 @@ func createStoreForShard() dataRetriever.StorageService {

func createTriesHolderForShard() common.TriesHolder {
triesHolder := state.NewDataTriesHolder()
triesHolder.Put([]byte(triesFactory.UserAccountTrie), &trieMock.TrieStub{})
triesHolder.Put([]byte(triesFactory.PeerAccountTrie), &trieMock.TrieStub{})
triesHolder.Put([]byte(dataRetriever.UserAccountsUnit.String()), &trieMock.TrieStub{})
triesHolder.Put([]byte(dataRetriever.PeerAccountsUnit.String()), &trieMock.TrieStub{})
return triesHolder
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ func (brcf *baseRequestersContainerFactory) createMiniBlocksRequester(responseTo
func (brcf *baseRequestersContainerFactory) newImportDBTrieStorage(
mainStorer storage.Storer,
checkpointsStorer storage.Storer,
storageIdentifier dataRetriever.UnitType,
) (common.StorageManager, dataRetriever.TrieDataGetter, error) {
pathManager, err := storageFactory.CreatePathManager(
storageFactory.ArgCreatePathManager{
Expand Down Expand Up @@ -261,6 +262,7 @@ func (brcf *baseRequestersContainerFactory) newImportDBTrieStorage(
MaxTrieLevelInMem: brcf.generalConfig.StateTriesConfig.MaxStateTrieLevelInMemory,
SnapshotsEnabled: brcf.snapshotsEnabled,
IdleProvider: disabled.NewProcessStatusHandler(),
Identifier: storageIdentifier.String(),
}
return trieFactoryInstance.Create(args)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ func (mrcf *metaRequestersContainerFactory) generateTrieNodesRequesters() error
storageManager, userAccountsDataTrie, err := mrcf.newImportDBTrieStorage(
userAccountsStorer,
userAccountsCheckpointStorer,
dataRetriever.UserAccountsUnit,
)
if err != nil {
return fmt.Errorf("%w while creating user accounts data trie storage getter", err)
Expand Down Expand Up @@ -230,6 +231,7 @@ func (mrcf *metaRequestersContainerFactory) generateTrieNodesRequesters() error
storageManager, peerAccountsDataTrie, err := mrcf.newImportDBTrieStorage(
peerAccountsStorer,
peerAccountsCheckpointStorer,
dataRetriever.PeerAccountsUnit,
)
if err != nil {
return fmt.Errorf("%w while creating peer accounts data trie storage getter", err)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ func (srcf *shardRequestersContainerFactory) generateTrieNodesRequesters() error
storageManager, userAccountsDataTrie, err := srcf.newImportDBTrieStorage(
userAccountsStorer,
userAccountsCheckpointStorer,
dataRetriever.UserAccountsUnit,
)
if err != nil {
return fmt.Errorf("%w while creating user accounts data trie storage getter", err)
Expand Down
4 changes: 2 additions & 2 deletions dataRetriever/storageRequesters/trieNodeRequester_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (
"github.com/multiversx/mx-chain-core-go/data/endProcess"
"github.com/multiversx/mx-chain-go/dataRetriever"
"github.com/multiversx/mx-chain-go/dataRetriever/mock"
"github.com/multiversx/mx-chain-go/testscommon"
"github.com/multiversx/mx-chain-go/testscommon/p2pmocks"
"github.com/multiversx/mx-chain-go/testscommon/storageManager"
trieMock "github.com/multiversx/mx-chain-go/testscommon/trie"
"github.com/stretchr/testify/assert"
)
Expand All @@ -23,7 +23,7 @@ func createMockTrieRequesterArguments() ArgTrieRequester {
ResponseTopicName: "",
Marshalizer: &mock.MarshalizerStub{},
TrieDataGetter: &trieMock.TrieStub{},
TrieStorageManager: &testscommon.StorageManagerStub{},
TrieStorageManager: &storageManager.StorageManagerStub{},
ManualEpochStartNotifier: &mock.ManualEpochStartNotifierStub{},
ChanGracefullyClose: make(chan endProcess.ArgEndProcess, 1),
DelayBeforeGracefulClose: 0,
Expand Down
10 changes: 4 additions & 6 deletions epochStart/bootstrap/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -1066,7 +1066,7 @@ func (e *epochStartBootstrap) syncUserAccountsState(rootHash []byte) error {
}

e.mutTrieStorageManagers.RLock()
trieStorageManager := e.trieStorageManagers[factory.UserAccountTrie]
trieStorageManager := e.trieStorageManagers[dataRetriever.UserAccountsUnit.String()]
e.mutTrieStorageManagers.RUnlock()

argsUserAccountsSyncer := syncer.ArgsNewUserAccountsSyncer{
Expand All @@ -1081,7 +1081,6 @@ func (e *epochStartBootstrap) syncUserAccountsState(rootHash []byte) error {
MaxHardCapForMissingNodes: e.maxHardCapForMissingNodes,
TrieSyncerVersion: e.trieSyncerVersion,
CheckNodesOnDisk: e.checkNodesOnDisk,
StorageMarker: storageMarker.NewTrieStorageMarker(),
UserAccountsSyncStatisticsHandler: e.trieSyncStatisticsProvider,
AppStatusHandler: e.statusHandler,
},
Expand All @@ -1094,7 +1093,7 @@ func (e *epochStartBootstrap) syncUserAccountsState(rootHash []byte) error {
return err
}

err = accountsDBSyncer.SyncAccounts(rootHash)
err = accountsDBSyncer.SyncAccounts(rootHash, storageMarker.NewTrieStorageMarker())
if err != nil {
return err
}
Expand Down Expand Up @@ -1139,7 +1138,7 @@ func (e *epochStartBootstrap) createStorageService(

func (e *epochStartBootstrap) syncValidatorAccountsState(rootHash []byte) error {
e.mutTrieStorageManagers.RLock()
peerTrieStorageManager := e.trieStorageManagers[factory.PeerAccountTrie]
peerTrieStorageManager := e.trieStorageManagers[dataRetriever.PeerAccountsUnit.String()]
e.mutTrieStorageManagers.RUnlock()

argsValidatorAccountsSyncer := syncer.ArgsNewValidatorAccountsSyncer{
Expand All @@ -1154,7 +1153,6 @@ func (e *epochStartBootstrap) syncValidatorAccountsState(rootHash []byte) error
MaxHardCapForMissingNodes: e.maxHardCapForMissingNodes,
TrieSyncerVersion: e.trieSyncerVersion,
CheckNodesOnDisk: e.checkNodesOnDisk,
StorageMarker: storageMarker.NewTrieStorageMarker(),
UserAccountsSyncStatisticsHandler: statistics.NewTrieSyncStatistics(),
AppStatusHandler: disabledCommon.NewAppStatusHandler(),
},
Expand All @@ -1164,7 +1162,7 @@ func (e *epochStartBootstrap) syncValidatorAccountsState(rootHash []byte) error
return err
}

err = accountsDBSyncer.SyncAccounts(rootHash)
err = accountsDBSyncer.SyncAccounts(rootHash, storageMarker.NewTrieStorageMarker())
if err != nil {
return err
}
Expand Down
6 changes: 0 additions & 6 deletions epochStart/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,6 @@ type PendingMiniBlocksSyncHandler interface {
IsInterfaceNil() bool
}

// AccountsDBSyncer defines the methods for the accounts db syncer
type AccountsDBSyncer interface {
SyncAccounts(rootHash []byte) error
IsInterfaceNil() bool
}

// StartOfEpochMetaSyncer defines the methods to synchronize epoch start meta block from the network when nothing is known
type StartOfEpochMetaSyncer interface {
SyncEpochStartMeta(waitTime time.Duration) (data.MetaHeaderHandler, error)
Expand Down
4 changes: 2 additions & 2 deletions epochStart/metachain/baseRewards_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1136,11 +1136,11 @@ func getBaseRewardsArguments() BaseRewardsCreatorArgs {
hasher := sha256.NewSha256()
marshalizer := &marshal.GogoProtoMarshalizer{}

storageManagerArgs, options := storage.GetStorageManagerArgsAndOptions()
storageManagerArgs := storage.GetStorageManagerArgs()
storageManagerArgs.Marshalizer = marshalizer
storageManagerArgs.Hasher = hasher

trieFactoryManager, _ := trie.CreateTrieStorageManager(storageManagerArgs, options)
trieFactoryManager, _ := trie.CreateTrieStorageManager(storageManagerArgs, storage.GetStorageManagerOptions())
userAccountsDB := createAccountsDB(hasher, marshalizer, factory.NewAccountCreator(), trieFactoryManager)
shardCoordinator := mock.NewMultiShardsCoordinatorMock(2)
shardCoordinator.CurrentShard = core.MetachainShardId
Expand Down
39 changes: 20 additions & 19 deletions epochStart/metachain/systemSCs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -910,13 +910,13 @@ func createAccountsDB(
func createFullArgumentsForSystemSCProcessing(enableEpochsConfig config.EnableEpochs, trieStorer storage.Storer) (ArgsNewEpochStartSystemSCProcessing, vm.SystemSCContainer) {
hasher := sha256.NewSha256()
marshalizer := &marshal.GogoProtoMarshalizer{}
storageManagerArgs, options := stateMock.GetStorageManagerArgsAndOptions()
storageManagerArgs := stateMock.GetStorageManagerArgs()
storageManagerArgs.Marshalizer = marshalizer
storageManagerArgs.Hasher = hasher
storageManagerArgs.MainStorer = trieStorer
storageManagerArgs.CheckpointsStorer = trieStorer

trieFactoryManager, _ := trie.CreateTrieStorageManager(storageManagerArgs, options)
trieFactoryManager, _ := trie.CreateTrieStorageManager(storageManagerArgs, stateMock.GetStorageManagerOptions())
userAccountsDB := createAccountsDB(hasher, marshalizer, factory.NewAccountCreator(), trieFactoryManager)
peerAccountsDB := createAccountsDB(hasher, marshalizer, factory.NewPeerAccountCreator(), trieFactoryManager)
en := forking.NewGenericEpochNotifier()
Expand Down Expand Up @@ -953,23 +953,24 @@ func createFullArgumentsForSystemSCProcessing(enableEpochsConfig config.EnableEp
nodesSetup := &mock.NodesSetupStub{}

argsHook := hooks.ArgBlockChainHook{
Accounts: userAccountsDB,
PubkeyConv: &testscommon.PubkeyConverterMock{},
StorageService: &storageStubs.ChainStorerStub{},
BlockChain: blockChain,
ShardCoordinator: &mock.ShardCoordinatorStub{},
Marshalizer: marshalizer,
Uint64Converter: &mock.Uint64ByteSliceConverterMock{},
BuiltInFunctions: vmcommonBuiltInFunctions.NewBuiltInFunctionContainer(),
NFTStorageHandler: &testscommon.SimpleNFTStorageHandlerStub{},
GlobalSettingsHandler: &testscommon.ESDTGlobalSettingsHandlerStub{},
DataPool: testDataPool,
CompiledSCPool: testDataPool.SmartContracts(),
EpochNotifier: en,
EnableEpochsHandler: enableEpochsHandler,
NilCompiledSCStore: true,
GasSchedule: gasScheduleNotifier,
Counter: &testscommon.BlockChainHookCounterStub{},
Accounts: userAccountsDB,
PubkeyConv: &testscommon.PubkeyConverterMock{},
StorageService: &storageStubs.ChainStorerStub{},
BlockChain: blockChain,
ShardCoordinator: &mock.ShardCoordinatorStub{},
Marshalizer: marshalizer,
Uint64Converter: &mock.Uint64ByteSliceConverterMock{},
BuiltInFunctions: vmcommonBuiltInFunctions.NewBuiltInFunctionContainer(),
NFTStorageHandler: &testscommon.SimpleNFTStorageHandlerStub{},
GlobalSettingsHandler: &testscommon.ESDTGlobalSettingsHandlerStub{},
DataPool: testDataPool,
CompiledSCPool: testDataPool.SmartContracts(),
EpochNotifier: en,
EnableEpochsHandler: enableEpochsHandler,
NilCompiledSCStore: true,
GasSchedule: gasScheduleNotifier,
Counter: &testscommon.BlockChainHookCounterStub{},
MissingTrieNodesNotifier: &testscommon.MissingTrieNodesNotifierStub{},
}

blockChainHookImpl, _ := hooks.NewBlockChainHookImpl(argsHook)
Expand Down