Skip to content

Commit

Permalink
Merge branch 'state-changes-read-operations' into update_enums_state
Browse files Browse the repository at this point in the history
  • Loading branch information
cristure authored Oct 1, 2024
2 parents d866489 + d6383f5 commit 0aa84f3
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 29 deletions.
3 changes: 1 addition & 2 deletions genesis/process/genesisBlockCreator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (
"github.com/multiversx/mx-chain-go/state"
"github.com/multiversx/mx-chain-go/state/accounts"
factoryState "github.com/multiversx/mx-chain-go/state/factory"
"github.com/multiversx/mx-chain-go/state/stateChanges"
"github.com/multiversx/mx-chain-go/storage"
"github.com/multiversx/mx-chain-go/testscommon"
commonMocks "github.com/multiversx/mx-chain-go/testscommon/common"
Expand Down Expand Up @@ -204,7 +203,7 @@ func createMockArgument(
Hasher: &hashingMocks.HasherMock{},
Marshaller: &mock.MarshalizerMock{},
EnableEpochsHandler: &enableEpochsHandlerMock.EnableEpochsHandlerStub{},
StateChangesCollector: stateChanges.NewStateChangesCollector(),
StateChangesCollector: &stateMock.StateChangesCollectorStub{},
}
accCreator, err := factoryState.NewAccountCreator(argsAccCreator)
require.Nil(t, err)
Expand Down
9 changes: 4 additions & 5 deletions integrationTests/state/stateTrie/stateTrie_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ import (
"github.com/multiversx/mx-chain-go/state/factory"
"github.com/multiversx/mx-chain-go/state/iteratorChannelsProvider"
"github.com/multiversx/mx-chain-go/state/lastSnapshotMarker"
"github.com/multiversx/mx-chain-go/state/stateChanges"
"github.com/multiversx/mx-chain-go/state/storagePruningManager"
"github.com/multiversx/mx-chain-go/state/storagePruningManager/evictionWaitingList"
"github.com/multiversx/mx-chain-go/storage"
Expand Down Expand Up @@ -1063,7 +1062,7 @@ func createAccounts(
Hasher: integrationTests.TestHasher,
Marshaller: integrationTests.TestMarshalizer,
EnableEpochsHandler: &enableEpochsHandlerMock.EnableEpochsHandlerStub{},
StateChangesCollector: stateChanges.NewStateChangesCollector(),
StateChangesCollector: &stateMock.StateChangesCollectorStub{},
}
accCreator, _ := factory.NewAccountCreator(argsAccCreator)
snapshotsManager, _ := state.NewSnapshotsManager(state.ArgsNewSnapshotsManager{
Expand All @@ -1085,7 +1084,7 @@ func createAccounts(
StoragePruningManager: spm,
AddressConverter: &testscommon.PubkeyConverterMock{},
SnapshotsManager: snapshotsManager,
StateChangesCollector: stateChanges.NewStateChangesCollector(),
StateChangesCollector: &stateMock.StateChangesCollectorStub{},
}
adb, _ := state.NewAccountsDB(argsAccountsDB)

Expand Down Expand Up @@ -2737,7 +2736,7 @@ func createAccountsDBTestSetup() *state.AccountsDB {
Hasher: integrationTests.TestHasher,
Marshaller: integrationTests.TestMarshalizer,
EnableEpochsHandler: &enableEpochsHandlerMock.EnableEpochsHandlerStub{},
StateChangesCollector: stateChanges.NewStateChangesCollector(),
StateChangesCollector: &stateMock.StateChangesCollectorStub{},
}
accCreator, _ := factory.NewAccountCreator(argsAccCreator)

Expand All @@ -2761,7 +2760,7 @@ func createAccountsDBTestSetup() *state.AccountsDB {
StoragePruningManager: spm,
AddressConverter: &testscommon.PubkeyConverterMock{},
SnapshotsManager: snapshotsManager,
StateChangesCollector: stateChanges.NewStateChangesCollector(),
StateChangesCollector: &stateMock.StateChangesCollectorStub{},
}
adb, _ := state.NewAccountsDB(argsAccountsDB)

Expand Down
3 changes: 1 addition & 2 deletions integrationTests/testProcessorNode.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ import (
"github.com/multiversx/mx-chain-go/sharding/nodesCoordinator"
"github.com/multiversx/mx-chain-go/state"
"github.com/multiversx/mx-chain-go/state/blockInfoProviders"
stateDisabled "github.com/multiversx/mx-chain-go/state/disabled"
"github.com/multiversx/mx-chain-go/storage"
"github.com/multiversx/mx-chain-go/storage/cache"
"github.com/multiversx/mx-chain-go/storage/storageunit"
Expand Down Expand Up @@ -2235,7 +2234,7 @@ func (tpn *TestProcessorNode) initBlockProcessor() {
BlockProcessingCutoffHandler: &testscommon.BlockProcessingCutoffStub{},
ManagedPeersHolder: &testscommon.ManagedPeersHolderStub{},
SentSignaturesTracker: &testscommon.SentSignatureTrackerStub{},
StateChangesCollector: stateDisabled.NewDisabledStateChangesCollector(),
StateChangesCollector: &stateMock.StateChangesCollectorStub{},
}

if check.IfNil(tpn.EpochStartNotifier) {
Expand Down
4 changes: 2 additions & 2 deletions outport/process/outportDataProvider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ import (

"github.com/multiversx/mx-chain-go/outport/mock"
"github.com/multiversx/mx-chain-go/outport/process/transactionsfee"
"github.com/multiversx/mx-chain-go/state/stateChanges"
"github.com/multiversx/mx-chain-go/testscommon"
commonMocks "github.com/multiversx/mx-chain-go/testscommon/common"
"github.com/multiversx/mx-chain-go/testscommon/enableEpochsHandlerMock"
"github.com/multiversx/mx-chain-go/testscommon/genericMocks"
"github.com/multiversx/mx-chain-go/testscommon/hashingMocks"
"github.com/multiversx/mx-chain-go/testscommon/marshallerMock"
"github.com/multiversx/mx-chain-go/testscommon/shardingMocks"
"github.com/multiversx/mx-chain-go/testscommon/state"
)

func createArgOutportDataProvider() ArgOutportDataProvider {
Expand All @@ -47,7 +47,7 @@ func createArgOutportDataProvider() ArgOutportDataProvider {
ExecutionOrderHandler: &commonMocks.TxExecutionOrderHandlerStub{},
Marshaller: &marshallerMock.MarshalizerMock{},
Hasher: &hashingMocks.HasherMock{},
StateChangesCollector: stateChanges.NewStateChangesCollector(),
StateChangesCollector: &state.StateChangesCollectorStub{},
}
}

Expand Down
3 changes: 1 addition & 2 deletions process/rewardTransaction/process_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"github.com/multiversx/mx-chain-go/process/mock"
"github.com/multiversx/mx-chain-go/process/rewardTransaction"
"github.com/multiversx/mx-chain-go/state/accounts"
"github.com/multiversx/mx-chain-go/state/disabled"
"github.com/multiversx/mx-chain-go/state/trackableDataTrie"
"github.com/multiversx/mx-chain-go/testscommon/enableEpochsHandlerMock"
"github.com/multiversx/mx-chain-go/testscommon/hashingMocks"
Expand Down Expand Up @@ -266,7 +265,7 @@ func TestRewardTxProcessor_ProcessRewardTransactionToASmartContractShouldWork(t
&hashingMocks.HasherMock{},
&marshallerMock.MarshalizerMock{},
enableEpochsHandlerMock.NewEnableEpochsHandlerStub(),
disabled.NewDisabledStateChangesCollector(),
&stateMock.StateChangesCollectorStub{},
)
userAccount, _ := accounts.NewUserAccount(address, dtt, &trie.TrieLeafParserStub{})
accountsDb := &stateMock.AccountsStub{
Expand Down
3 changes: 1 addition & 2 deletions process/scToProtocol/stakingToPeer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"github.com/multiversx/mx-chain-go/process/mock"
"github.com/multiversx/mx-chain-go/state"
"github.com/multiversx/mx-chain-go/state/accounts"
"github.com/multiversx/mx-chain-go/state/stateChanges"
"github.com/multiversx/mx-chain-go/state/trackableDataTrie"
"github.com/multiversx/mx-chain-go/testscommon"
"github.com/multiversx/mx-chain-go/testscommon/enableEpochsHandlerMock"
Expand Down Expand Up @@ -67,7 +66,7 @@ func createStakingScAccount() state.UserAccountHandler {
&hashingMocks.HasherMock{},
&marshallerMock.MarshalizerMock{},
enableEpochsHandlerMock.NewEnableEpochsHandlerStub(),
stateChanges.NewStateChangesCollector(),
&stateMock.StateChangesCollectorStub{},
)

userAcc, _ := accounts.NewUserAccount(vm.StakingSCAddress, dtt, &trie.TrieLeafParserStub{})
Expand Down
3 changes: 1 addition & 2 deletions process/smartContract/processorV2/process_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import (
"github.com/multiversx/mx-chain-go/sharding"
"github.com/multiversx/mx-chain-go/state"
stateFactory "github.com/multiversx/mx-chain-go/state/factory"
"github.com/multiversx/mx-chain-go/state/stateChanges"
"github.com/multiversx/mx-chain-go/storage/storageunit"
"github.com/multiversx/mx-chain-go/storage/txcache"
"github.com/multiversx/mx-chain-go/testscommon"
Expand Down Expand Up @@ -67,7 +66,7 @@ func createAccount(address []byte) state.UserAccountHandler {
Hasher: &hashingMocks.HasherMock{},
Marshaller: &marshallerMock.MarshalizerMock{},
EnableEpochsHandler: enableEpochsHandlerMock.NewEnableEpochsHandlerStub(),
StateChangesCollector: stateChanges.NewStateChangesCollector(),
StateChangesCollector: &stateMock.StateChangesCollectorStub{},
}
accountFactory, _ := stateFactory.NewAccountCreator(argsAccCreation)
account, _ := accountFactory.CreateAccount(address)
Expand Down
17 changes: 8 additions & 9 deletions state/accountsDB_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import (
"github.com/multiversx/mx-chain-go/state"
"github.com/multiversx/mx-chain-go/state/accounts"
"github.com/multiversx/mx-chain-go/state/dataTrieValue"
stateDisabled "github.com/multiversx/mx-chain-go/state/disabled"
"github.com/multiversx/mx-chain-go/state/factory"
"github.com/multiversx/mx-chain-go/state/iteratorChannelsProvider"
"github.com/multiversx/mx-chain-go/state/lastSnapshotMarker"
Expand Down Expand Up @@ -86,7 +85,7 @@ func createMockAccountsDBArgs() state.ArgsAccountsDB {
StoragePruningManager: disabled.NewDisabledStoragePruningManager(),
AddressConverter: &testscommon.PubkeyConverterMock{},
SnapshotsManager: snapshotsManager,
StateChangesCollector: stateChanges.NewStateChangesCollector(),
StateChangesCollector: &stateMock.StateChangesCollectorStub{},
}
}

Expand Down Expand Up @@ -157,7 +156,7 @@ func getDefaultStateComponents(
Hasher: hasher,
Marshaller: marshaller,
EnableEpochsHandler: enableEpochsHandler,
StateChangesCollector: stateDisabled.NewDisabledStateChangesCollector(),
StateChangesCollector: &stateMock.StateChangesCollectorStub{},
}
accCreator, _ := factory.NewAccountCreator(argsAccCreator)

Expand Down Expand Up @@ -1935,7 +1934,7 @@ func TestAccountsDB_MainTrieAutomaticallyMarksCodeUpdatesForEviction(t *testing.
Hasher: hasher,
Marshaller: marshaller,
EnableEpochsHandler: &enableEpochsHandlerMock.EnableEpochsHandlerStub{},
StateChangesCollector: stateChanges.NewStateChangesCollector(),
StateChangesCollector: &stateMock.StateChangesCollectorStub{},
}
argsAccountsDB.AccountFactory, _ = factory.NewAccountCreator(argsAccCreator)
argsAccountsDB.StoragePruningManager = spm
Expand Down Expand Up @@ -2017,7 +2016,7 @@ func TestAccountsDB_RemoveAccountMarksObsoleteHashesForEviction(t *testing.T) {
Hasher: hasher,
Marshaller: marshaller,
EnableEpochsHandler: &enableEpochsHandlerMock.EnableEpochsHandlerStub{},
StateChangesCollector: stateChanges.NewStateChangesCollector(),
StateChangesCollector: &stateMock.StateChangesCollectorStub{},
}
argsAccountsDB.AccountFactory, _ = factory.NewAccountCreator(argsAccCreator)
argsAccountsDB.StoragePruningManager = spm
Expand Down Expand Up @@ -2220,7 +2219,7 @@ func TestAccountsDB_GetCode(t *testing.T) {
Hasher: hasher,
Marshaller: marshaller,
EnableEpochsHandler: &enableEpochsHandlerMock.EnableEpochsHandlerStub{},
StateChangesCollector: stateChanges.NewStateChangesCollector(),
StateChangesCollector: &stateMock.StateChangesCollectorStub{},
}
argsAccountsDB.AccountFactory, _ = factory.NewAccountCreator(argsAccCreator)
argsAccountsDB.StoragePruningManager = spm
Expand Down Expand Up @@ -2388,7 +2387,7 @@ func TestAccountsDB_Close(t *testing.T) {
Hasher: hasher,
Marshaller: marshaller,
EnableEpochsHandler: &enableEpochsHandlerMock.EnableEpochsHandlerStub{},
StateChangesCollector: stateChanges.NewStateChangesCollector(),
StateChangesCollector: &stateMock.StateChangesCollectorStub{},
}
argsAccountsDB.AccountFactory, _ = factory.NewAccountCreator(argsAccCreator)
argsAccountsDB.StoragePruningManager = spm
Expand Down Expand Up @@ -2677,7 +2676,7 @@ func BenchmarkAccountsDb_GetCodeEntry(b *testing.B) {
Hasher: hasher,
Marshaller: marshaller,
EnableEpochsHandler: &enableEpochsHandlerMock.EnableEpochsHandlerStub{},
StateChangesCollector: stateChanges.NewStateChangesCollector(),
StateChangesCollector: &stateMock.StateChangesCollectorStub{},
}
argsAccountsDB.AccountFactory, _ = factory.NewAccountCreator(argsAccCreator)
argsAccountsDB.StoragePruningManager = spm
Expand Down Expand Up @@ -3000,7 +2999,7 @@ func TestAccountsDB_RevertTxWhichMigratesDataRemovesMigratedData(t *testing.T) {
Hasher: hasher,
Marshaller: marshaller,
EnableEpochsHandler: enableEpochsHandler,
StateChangesCollector: stateChanges.NewStateChangesCollector(),
StateChangesCollector: &stateMock.StateChangesCollectorStub{},
}
argsAccountsDB.AccountFactory, _ = factory.NewAccountCreator(argsAccCreator)
argsAccountsDB.StoragePruningManager = spm
Expand Down
4 changes: 1 addition & 3 deletions state/stateChanges/dataAnalysisCollector.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,7 @@ func (scc *dataAnalysisCollector) getDataAnalysisStateChangesForTxs() ([]dataAna
dataAnalysisStateChangesForTxs := make([]dataAnalysisStateChangesForTx, 0)

for _, stateChangeForTx := range stateChangesForTxs {
txHash := string(stateChangeForTx.TxHash)

cachedTx, txOk := scc.cachedTxs[txHash]
cachedTx, txOk := scc.cachedTxs[string(stateChangeForTx.TxHash)]
if !txOk {
return nil, fmt.Errorf("did not find tx in cache")
}
Expand Down

0 comments on commit 0aa84f3

Please sign in to comment.