Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nebula
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
exchain
nebula
Commits
1037f881
Commit
1037f881
authored
Oct 14, 2021
by
George Hotz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
shift >>2 for much smaller ram trie
parent
ce93e39b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
2 deletions
+4
-2
trie.go
mipsevm/trie.go
+2
-2
trie_test.go
mipsevm/trie_test.go
+2
-0
No files found.
mipsevm/trie.go
View file @
1037f881
...
@@ -44,7 +44,7 @@ func (kw PreimageKeyValueWriter) Delete(key []byte) error {
...
@@ -44,7 +44,7 @@ func (kw PreimageKeyValueWriter) Delete(key []byte) error {
// full nodes / BRANCH_NODE have 17 values, each a hash
// full nodes / BRANCH_NODE have 17 values, each a hash
// LEAF or EXTENSION nodes have 2 values, a path and value
// LEAF or EXTENSION nodes have 2 values, a path and value
func
parseNode
(
node
common
.
Hash
,
depth
int
)
{
func
parseNode
(
node
common
.
Hash
,
depth
int
)
{
if
depth
>
2
{
if
depth
>
3
{
return
return
}
}
sprefix
:=
strings
.
Repeat
(
" "
,
depth
)
sprefix
:=
strings
.
Repeat
(
" "
,
depth
)
...
@@ -85,7 +85,7 @@ func RamToTrie(ram map[uint32](uint32)) common.Hash {
...
@@ -85,7 +85,7 @@ func RamToTrie(ram map[uint32](uint32)) common.Hash {
for
_
,
kv
:=
range
sram
{
for
_
,
kv
:=
range
sram
{
k
,
v
:=
uint32
(
kv
>>
32
),
uint32
(
kv
)
k
,
v
:=
uint32
(
kv
>>
32
),
uint32
(
kv
)
//fmt.Printf("insert %x = %x\n", k, v)
//fmt.Printf("insert %x = %x\n", k, v)
binary
.
BigEndian
.
PutUint32
(
tk
,
k
)
binary
.
BigEndian
.
PutUint32
(
tk
,
k
>>
2
)
binary
.
BigEndian
.
PutUint32
(
tv
,
v
)
binary
.
BigEndian
.
PutUint32
(
tv
,
v
)
mt
.
Update
(
tk
,
tv
)
mt
.
Update
(
tk
,
tv
)
}
}
...
...
mipsevm/trie_test.go
View file @
1037f881
package
main
package
main
import
(
import
(
"fmt"
"io/ioutil"
"io/ioutil"
"testing"
"testing"
)
)
...
@@ -21,5 +22,6 @@ func TestTrie(t *testing.T) {
...
@@ -21,5 +22,6 @@ func TestTrie(t *testing.T) {
root
:=
RamToTrie
(
ram
)
root
:=
RamToTrie
(
ram
)
dat
:=
SerializeTrie
(
root
)
dat
:=
SerializeTrie
(
root
)
fmt
.
Println
(
"serialized length is"
,
len
(
dat
))
ioutil
.
WriteFile
(
"/tmp/eth/ramtrie"
,
dat
,
0644
)
ioutil
.
WriteFile
(
"/tmp/eth/ramtrie"
,
dat
,
0644
)
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment