Skip to content

Commit dd06a35

Browse files
authored
Merge branch 'feat/supernova-async-exec' into fix-api-meta-block
2 parents 234ae9c + bd57fc8 commit dd06a35

File tree

4 files changed

+22
-15
lines changed

4 files changed

+22
-15
lines changed

factory/state/stateComponents.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,7 @@ func (scf *stateComponentsFactory) createAccountsAdapters(triesContainer common.
261261
AddressConverter: scf.core.AddressPubKeyConverter(),
262262
SnapshotsManager: snapshotsManager,
263263
StateAccessesCollector: StateAccessesCollector,
264+
PruningEnabled: scf.config.StateTriesConfig.AccountsStatePruningEnabled,
264265
}
265266
accountsAdapter, err := state.NewAccountsDB(argsProcessingAccountsDB)
266267
if err != nil {
@@ -364,6 +365,7 @@ func (scf *stateComponentsFactory) createPeerAdapter(triesContainer common.Tries
364365
AddressConverter: scf.core.AddressPubKeyConverter(),
365366
SnapshotsManager: snapshotManager,
366367
StateAccessesCollector: disabled.NewDisabledStateAccessesCollector(),
368+
PruningEnabled: scf.config.StateTriesConfig.PeerStatePruningEnabled,
367369
}
368370
peerAdapter, err := state.NewPeerAccountsDB(argsProcessingPeerAccountsDB)
369371
if err != nil {

integrationTests/testInitializer.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,7 @@ func CreateAccountsDBWithEnableEpochsHandler(
499499
AddressConverter: &testscommon.PubkeyConverterMock{},
500500
SnapshotsManager: snapshotsManager,
501501
StateAccessesCollector: disabled.NewDisabledStateAccessesCollector(),
502+
PruningEnabled: trieStorageManager.IsPruningEnabled(),
502503
}
503504
adb, _ := state.NewAccountsDB(args)
504505

state/accountsDB.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ type AccountsDB struct {
8989
mutOp sync.RWMutex
9090
loadCodeMeasurements *loadingMeasurements
9191
addressConverter core.PubkeyConverter
92+
pruningEnabled bool
9293

9394
stackDebug []byte
9495
}
@@ -105,6 +106,7 @@ type ArgsAccountsDB struct {
105106
AddressConverter core.PubkeyConverter
106107
SnapshotsManager SnapshotsManager
107108
StateAccessesCollector StateAccessesCollector
109+
PruningEnabled bool
108110
}
109111

110112
// NewAccountsDB creates a new account manager
@@ -134,6 +136,7 @@ func createAccountsDb(args ArgsAccountsDB) *AccountsDB {
134136
addressConverter: args.AddressConverter,
135137
snapshotsManger: args.SnapshotsManager,
136138
stateAccessesCollector: args.StateAccessesCollector,
139+
pruningEnabled: args.PruningEnabled,
137140
}
138141
}
139142

@@ -971,7 +974,7 @@ func (adb *AccountsDB) markForEviction(
971974
oldHashes common.ModifiedHashes,
972975
newHashes common.ModifiedHashes,
973976
) error {
974-
if !adb.mainTrie.GetStorageManager().IsPruningEnabled() {
977+
if !adb.pruningEnabled {
975978
return nil
976979
}
977980

@@ -985,7 +988,7 @@ func (adb *AccountsDB) markForEviction(
985988
}
986989

987990
func (adb *AccountsDB) commitTrie(tr common.Trie, oldHashes common.ModifiedHashes, newHashes common.ModifiedHashes) error {
988-
if adb.mainTrie.GetStorageManager().IsPruningEnabled() {
991+
if adb.pruningEnabled {
989992
oldTrieHashes := tr.GetObsoleteHashes()
990993
newTrieHashes, err := tr.GetDirtyHashes()
991994
if err != nil {
@@ -1256,7 +1259,7 @@ func emptyErrChanReturningHadContained(errChan chan error) bool {
12561259

12571260
// IsPruningEnabled returns true if state pruning is enabled
12581261
func (adb *AccountsDB) IsPruningEnabled() bool {
1259-
return adb.getMainTrie().GetStorageManager().IsPruningEnabled()
1262+
return adb.pruningEnabled
12601263
}
12611264

12621265
// GetAllLeaves returns all the leaves from a given rootHash

state/accountsDB_test.go

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ func getDefaultStateComponents(
181181
AddressConverter: &testscommon.PubkeyConverterMock{},
182182
SnapshotsManager: snapshotsManager,
183183
StateAccessesCollector: collector,
184+
PruningEnabled: true,
184185
}
185186
adb, _ := state.NewAccountsDB(argsAccountsDB)
186187

@@ -1657,19 +1658,16 @@ func TestAccountsDB_SnapshotStateCallsRemoveFromAllActiveEpochs(t *testing.T) {
16571658
func TestAccountsDB_IsPruningEnabled(t *testing.T) {
16581659
t.Parallel()
16591660

1660-
trieStub := &trieMock.TrieStub{
1661-
GetStorageManagerCalled: func() common.StorageManager {
1662-
return &storageManager.StorageManagerStub{
1663-
IsPruningEnabledCalled: func() bool {
1664-
return true
1665-
},
1666-
}
1667-
},
1668-
}
1669-
adb := generateAccountDBFromTrie(trieStub)
1670-
res := adb.IsPruningEnabled()
1661+
args := createMockAccountsDBArgs()
1662+
args.PruningEnabled = true
1663+
adb, err := state.NewAccountsDB(args)
1664+
assert.Nil(t, err)
1665+
assert.True(t, adb.IsPruningEnabled())
16711666

1672-
assert.Equal(t, true, res)
1667+
args.PruningEnabled = false
1668+
adb, err = state.NewAccountsDB(args)
1669+
assert.Nil(t, err)
1670+
assert.False(t, adb.IsPruningEnabled())
16731671
}
16741672

16751673
func TestAccountsDB_RevertToSnapshotOutOfBounds(t *testing.T) {
@@ -2135,6 +2133,7 @@ func TestAccountsDB_MainTrieAutomaticallyMarksCodeUpdatesForEviction(t *testing.
21352133
spm, _ := storagePruningManager.NewStoragePruningManager(ewl, 5)
21362134

21372135
argsAccountsDB := createMockAccountsDBArgs()
2136+
argsAccountsDB.PruningEnabled = true
21382137
argsAccountsDB.Trie = tr
21392138
argsAccountsDB.Hasher = hasher
21402139
argsAccountsDB.Marshaller = marshaller
@@ -2217,6 +2216,7 @@ func TestAccountsDB_RemoveAccountMarksObsoleteHashesForEviction(t *testing.T) {
22172216
spm, _ := storagePruningManager.NewStoragePruningManager(ewl, 5)
22182217

22192218
argsAccountsDB := createMockAccountsDBArgs()
2219+
argsAccountsDB.PruningEnabled = true
22202220
argsAccountsDB.Trie = tr
22212221
argsAccountsDB.Hasher = hasher
22222222
argsAccountsDB.Marshaller = marshaller
@@ -3200,6 +3200,7 @@ func TestAccountsDB_RevertTxWhichMigratesDataRemovesMigratedData(t *testing.T) {
32003200
tr, _ := trie.NewTrie(tsm, marshaller, hasher, enableEpochsHandler, uint(5))
32013201
spm := &stateMock.StoragePruningManagerStub{}
32023202
argsAccountsDB := createMockAccountsDBArgs()
3203+
argsAccountsDB.PruningEnabled = true
32033204
argsAccountsDB.Trie = tr
32043205
argsAccountsDB.Hasher = hasher
32053206
argsAccountsDB.Marshaller = marshaller

0 commit comments

Comments
 (0)