neo-go icon indicating copy to clipboard operation
neo-go copied to clipboard

MPT-backed storage is broken

Open AnnaShaleva opened this issue 2 years ago • 1 comments

MPT-backed storage (mpt.TrieStore) uses Billet for MPT traversal during Seek operations. MPT traversal strategy differs from the one that simple storage Seek assumes (probably due to the Branch node traversal in case when the last child is non-empty leaf and there are other children except the last in this Branch). The difference is that items with the key exactly matching provided prefix are being traversed after the ones that has extra data after prefix (by MPT-based storage). This affects every component that tries to use MPT-backed storage as a replacement to a simple storage, including:

  • MPT-based iterator sessions
  • test historic script invocations
  • findstoragehistoric RPC handler (ref. https://github.com/nspcc-dev/neo-go/pull/3099#discussion_r1302046422).

It may affect the findstates RPC handler in terms that current findstates behaviour matches the C# one, and to fix this bug we have to change the traversal strategy which will affect the findstates result.

This problem needs additional investigation, we may consider adding a traversal strategy option to Billet.

AnnaShaleva avatar Aug 23 '23 17:08 AnnaShaleva

I think it can be fixed without an additional mode.

roman-khimov avatar Aug 23 '23 18:08 roman-khimov