From 22a5bbcef36b8fda5d14ce98a6496d4ad59b2878 Mon Sep 17 00:00:00 2001 From: Anna Shaleva Date: Thu, 6 Mar 2025 15:25:23 +0300 Subject: [PATCH] mpt: extend Billet constructor documentation Billet's mode must match the DB's MPT mode, otherwise Billet-level nodes decoding won't work properly startign from 86cb4ed8. Ref. https://github.com/nspcc-dev/neo-go/pull/3808#issuecomment-2703668032 and 49945e9ae957f7e2f6e47200bb3e594f3565f73d. Signed-off-by: Anna Shaleva --- pkg/core/mpt/billet.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkg/core/mpt/billet.go b/pkg/core/mpt/billet.go index 462fdbff5..e6495beaf 100644 --- a/pkg/core/mpt/billet.go +++ b/pkg/core/mpt/billet.go @@ -37,7 +37,10 @@ type Billet struct { // NewBillet returns a new billet for MPT trie restoring. It accepts a MemCachedStore // to decouple storage errors from logic errors so that all storage errors are // processed during `store.Persist()` at the caller. Another benefit is -// that every `Put` can be considered an atomic operation. +// that every `Put` can be considered an atomic operation. Note that mode +// parameter must match precisely the Trie mode that is used in the underlying +// DB to store the MPT nodes. Using wrong mode will lead to improper MPT nodes +// decoding and even runtime panic. func NewBillet(rootHash util.Uint256, mode TrieMode, prefix storage.KeyPrefix, store *storage.MemCachedStore) *Billet { return &Billet{ TempStoragePrefix: prefix,