core: fix broken stateroot storage

Store stateroot by DataMPTAux prefix instead of storing it by index only.
This commit is contained in:
Anna Shaleva 2022-04-22 18:23:38 +03:00
parent 2c5fbd57fb
commit 8be6823cb1
2 changed files with 2 additions and 2 deletions

View file

@ -277,7 +277,7 @@ func TestBlockchain_StartFromExistingDB(t *testing.T) {
cache := storage.NewMemCachedStore(ps) // Extra wrapper to avoid good DB corruption. cache := storage.NewMemCachedStore(ps) // Extra wrapper to avoid good DB corruption.
key := make([]byte, 5) key := make([]byte, 5)
key[0] = byte(storage.DataMPTAux) key[0] = byte(storage.DataMPTAux)
binary.BigEndian.PutUint32(key, h) binary.BigEndian.PutUint32(key[1:], h)
cache.Delete(key) cache.Delete(key)
_, _, _, err := chain.NewMultiWithCustomConfigAndStoreNoCheck(t, customConfig, cache) _, _, _, err := chain.NewMultiWithCustomConfigAndStoreNoCheck(t, customConfig, cache)

View file

@ -51,7 +51,7 @@ func (s *Module) getStateRoot(key []byte) (*state.MPTRoot, error) {
func makeStateRootKey(index uint32) []byte { func makeStateRootKey(index uint32) []byte {
key := make([]byte, 5) key := make([]byte, 5)
key[0] = byte(storage.DataMPTAux) key[0] = byte(storage.DataMPTAux)
binary.BigEndian.PutUint32(key, index) binary.BigEndian.PutUint32(key[1:], index)
return key return key
} }