Skip to content

Commit

Permalink
fixes after review
Browse files Browse the repository at this point in the history
  • Loading branch information
BeniaminDrasovean committed Sep 4, 2024
1 parent 5331072 commit 9836fde
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion epochStart/metachain/systemSCs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -764,7 +764,7 @@ func createAccountsDB(
StoragePruningManager: spm,
AddressConverter: &testscommon.PubkeyConverterMock{},
SnapshotsManager: disabledState.NewDisabledSnapshotsManager(),
StateChangesCollector: state.NewStateChangesCollector(),
StateChangesCollector: disabledState.NewDisabledStateChangesCollector(),
}
adb, _ := state.NewAccountsDB(args)
return adb
Expand Down
2 changes: 1 addition & 1 deletion factory/processing/blockProcessorCreator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ func createAccountAdapter(
StoragePruningManager: disabled.NewDisabledStoragePruningManager(),
AddressConverter: &testscommon.PubkeyConverterMock{},
SnapshotsManager: disabledState.NewDisabledSnapshotsManager(),
StateChangesCollector: state.NewStateChangesCollector(),
StateChangesCollector: disabledState.NewDisabledStateChangesCollector(),
}
adb, err := state.NewAccountsDB(args)
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions process/transaction/shardProcess.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ func (txProc *txProcessor) ProcessTransaction(tx *transaction.Transaction) (vmco
txProc.pubkeyConv,
)

// TODO refactor to set the tx hash for the following state changes before the processing occurs
defer txProc.accounts.SetTxHashForLatestStateChanges(txHash)

txType, dstShardTxType := txProc.txTypeHandler.ComputeTransactionType(tx)
Expand Down
7 changes: 4 additions & 3 deletions state/accountsDB.go
Original file line number Diff line number Diff line change
Expand Up @@ -280,15 +280,15 @@ func (adb *AccountsDB) SaveAccount(account vmcommon.AccountHandler) error {
}
adb.stateChangesCollector.AddStateChange(stateChange)

return err
return nil
}

func (adb *AccountsDB) saveCodeAndDataTrie(oldAcc, newAcc vmcommon.AccountHandler) ([]DataTrieChange, error) {
baseNewAcc, newAccOk := newAcc.(baseAccountHandler)
baseOldAccount, _ := oldAcc.(baseAccountHandler)

if !newAccOk {
return make([]DataTrieChange, 0), nil
return nil, nil
}

newValues, err := adb.saveDataTrie(baseNewAcc)
Expand All @@ -301,7 +301,7 @@ func (adb *AccountsDB) saveCodeAndDataTrie(oldAcc, newAcc vmcommon.AccountHandle
return nil, err
}

return newValues, err
return newValues, nil
}

func (adb *AccountsDB) saveCode(newAcc, oldAcc baseAccountHandler) error {
Expand Down Expand Up @@ -384,6 +384,7 @@ func (adb *AccountsDB) updateOldCodeEntry(oldCodeHash []byte) (*CodeEntry, error
return nil, err
}

// TODO refactor this after remove code leaf is merged
stateChange := StateChangeDTO{
MainTrieKey: oldCodeHash,
MainTrieVal: codeEntryBytes,
Expand Down
2 changes: 1 addition & 1 deletion state/accountsDBApi.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ func (accountsDB *accountsDBApi) SetTxHashForLatestStateChanges(txHash []byte) {

// ResetStateChangesCollector returns nil
func (accountsDB *accountsDBApi) ResetStateChangesCollector() []StateChangesForTx {
return nil
return accountsDB.innerAccountsAdapter.ResetStateChangesCollector()
}

// Close will handle the closing of the underlying components
Expand Down

0 comments on commit 9836fde

Please sign in to comment.