stateroot: try to fix MPT caching/updating

It was completely ruined by bf20db09e0. MPT was
updating bc.dao directly which shouldn't ever happen, it must write into the
same cache and then Persist these KVs as usual.
This commit is contained in:
Roman Khimov 2021-03-27 00:13:19 +03:00
parent 56fd375c6d
commit d143696328
4 changed files with 36 additions and 28 deletions

View file

@ -557,7 +557,8 @@ func TestContractDestroy(t *testing.T) {
err = bc.dao.PutStorageItem(cs1.ID, []byte{1, 2, 3}, state.StorageItem{3, 2, 1})
require.NoError(t, err)
b := bc.dao.GetMPTBatch()
require.NoError(t, bc.GetStateModule().(*stateroot.Module).AddMPTBatch(bc.BlockHeight(), b))
_, _, err = bc.GetStateModule().(*stateroot.Module).AddMPTBatch(bc.BlockHeight(), b, bc.dao.Store)
require.NoError(t, err)
t.Run("no contract", func(t *testing.T) {
res, err := invokeContractMethod(bc, 1_00000000, mgmtHash, "destroy")