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
049555b2
Commit
049555b2
authored
Oct 27, 2021
by
George Hotz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test passes, but it has a different hash
parent
be3760dc
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
7 deletions
+17
-7
Lib_MerkleTrie.sol
contracts/lib/Lib_MerkleTrie.sol
+5
-2
trie_test.go
mipsevm/trie_test.go
+2
-2
mips_test_memory.js
test/mips_test_memory.js
+10
-3
No files found.
contracts/lib/Lib_MerkleTrie.sol
View file @
049555b2
...
...
@@ -500,14 +500,17 @@ library Lib_MerkleTrie {
} else if (currentNodeType == NodeType.ExtensionNode) {
// Shift the key over to account for the nodes key.
bytes memory nodeKey = _getNodeKey(currentNode);
key = Lib_BytesUtils.slice(key, 0, key.length - nodeKey.length);
// this is likely wrong!
if (nodeKey.length < key.length) {
key = Lib_BytesUtils.slice(key, 0, key.length - nodeKey.length);
}
// If this node is the last element in the path, it'll be correctly encoded
// and we can skip this part.
if (previousNodeHash.length > 0) {
// Re-encode the node based on the previous node.
currentNode = _editExtensionNodeValue(currentNode, previousNodeHash);
//currentNode = _makeExtensionNode(nodeKey, previousNodeHash);
}
} else if (currentNodeType == NodeType.BranchNode) {
// If this node is the last element in the path, it'll be correctly encoded
...
...
mipsevm/trie_test.go
View file @
049555b2
...
...
@@ -26,7 +26,7 @@ func TestBuggedTrie(t *testing.T) {
ram
:=
make
(
map
[
uint32
](
uint32
))
ram
[
0
]
=
1
ram
[
4
]
=
1
ram
[
4
]
=
2
root
:=
RamToTrie
(
ram
)
fmt
.
Println
(
"root(0,4) ="
,
root
)
...
...
@@ -34,7 +34,7 @@ func TestBuggedTrie(t *testing.T) {
return
Preimages
[
t
]
})
ram
[
0x40
]
=
1
ram
[
0x40
]
=
3
root
=
RamToTrie
(
ram
)
fmt
.
Println
(
"root(0,4,0x40) ="
,
root
)
...
...
test/mips_test_memory.js
View file @
049555b2
...
...
@@ -22,14 +22,21 @@ describe("MIPSMemory contract", function () {
let
root
=
"
0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421
"
root
=
await
write
(
mm
,
root
,
0
,
1
)
root
=
await
write
(
mm
,
root
,
4
,
1
)
root
=
await
write
(
mm
,
root
,
4
,
2
)
expect
(
await
mm
.
ReadMemory
(
root
,
0
)).
to
.
equal
(
1
)
expect
(
await
mm
.
ReadMemory
(
root
,
4
)).
to
.
equal
(
2
)
})
it
(
"
write three should work
"
,
async
function
()
{
await
mm
.
AddTrieNode
(
new
Uint8Array
([
0x80
]))
let
root
=
"
0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421
"
root
=
await
write
(
mm
,
root
,
0
,
1
)
root
=
await
write
(
mm
,
root
,
4
,
1
)
root
=
await
write
(
mm
,
root
,
0x40
,
1
)
root
=
await
write
(
mm
,
root
,
4
,
2
)
root
=
await
write
(
mm
,
root
,
0x40
,
3
)
expect
(
await
mm
.
ReadMemory
(
root
,
0
)).
to
.
equal
(
1
)
expect
(
await
mm
.
ReadMemory
(
root
,
4
)).
to
.
equal
(
2
)
expect
(
await
mm
.
ReadMemory
(
root
,
0x40
)).
to
.
equal
(
3
)
})
})
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