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
1a68a4ba
Commit
1a68a4ba
authored
Oct 12, 2021
by
George Hotz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
trie test is working
parent
d7ffc3e7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
2 deletions
+19
-2
trie.go
mipsevm/trie.go
+12
-2
trie_test.go
mipsevm/trie_test.go
+7
-0
No files found.
mipsevm/trie.go
View file @
1a68a4ba
...
...
@@ -5,14 +5,22 @@ import (
"fmt"
"sort"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/trie"
)
type
PreimageKeyValueWriter
struct
{}
var
preimages
=
make
(
map
[
common
.
Hash
][]
byte
)
// TODO: this is copied from the oracle
func
(
kw
PreimageKeyValueWriter
)
Put
(
key
[]
byte
,
value
[]
byte
)
error
{
//fmt.Println("preimage", key, value)
// cache this
hash
:=
crypto
.
Keccak256Hash
(
value
)
if
hash
!=
common
.
BytesToHash
(
key
)
{
panic
(
"bad preimage value write"
)
}
preimages
[
hash
]
=
common
.
CopyBytes
(
value
)
return
nil
}
...
...
@@ -43,4 +51,6 @@ func RamToTrie(ram map[uint32](uint32)) {
mt
.
Update
(
tk
,
tv
)
}
fmt
.
Println
(
"ram hash"
,
mt
.
Hash
())
fmt
.
Println
(
"hash count"
,
len
(
preimages
))
fmt
.
Println
(
"root node"
,
preimages
[
mt
.
Hash
()])
}
mipsevm/trie_test.go
View file @
1a68a4ba
...
...
@@ -9,7 +9,14 @@ import (
func
TestTrie
(
t
*
testing
.
T
)
{
fn
:=
"../mipigo/minigeth.bin"
ram
:=
make
(
map
[
uint32
](
uint32
))
// TODO: copied from compare_test.go
LoadMappedFile
(
fn
,
ram
,
0
)
/*inputFile := fmt.Sprintf("/tmp/eth/%d", 13284469)
LoadMappedFile(inputFile, ram, 0xB0000000)*/
for
i
:=
uint32
(
0xC0000000
);
i
<
0xC0000000
+
36
*
4
;
i
+=
4
{
WriteRam
(
ram
,
i
,
0
)
}
RamToTrie
(
ram
)
}
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