core: implement MPT Billet structure for MPT restore
MPT restore process is much simpler then regular MPT maintaining: trie has a fixed structure, we don't need to remove or rebuild MPT nodes. The only thing we should do is to replace Hash nodes to their unhashed counterparts and increment refcount. It's better not to touch the regular MPT code and create a separate structure for this.
This commit is contained in:
parent
c9e62769a6
commit
a22b1caa3e
3 changed files with 290 additions and 0 deletions
20
pkg/core/mpt/helpers_test.go
Normal file
20
pkg/core/mpt/helpers_test.go
Normal file
|
@ -0,0 +1,20 @@
|
|||
package mpt
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestToNibblesFromNibbles(t *testing.T) {
|
||||
check := func(t *testing.T, expected []byte) {
|
||||
actual := fromNibbles(toNibbles(expected))
|
||||
require.Equal(t, expected, actual)
|
||||
}
|
||||
t.Run("empty path", func(t *testing.T) {
|
||||
check(t, []byte{})
|
||||
})
|
||||
t.Run("non-empty path", func(t *testing.T) {
|
||||
check(t, []byte{0x01, 0xAC, 0x8d, 0x04, 0xFF})
|
||||
})
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue