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
dc8ce147
Commit
dc8ce147
authored
Oct 27, 2021
by
George Hotz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
more generic fix
parent
9e366fb3
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
21 deletions
+18
-21
Lib_MerkleTrie.sol
contracts/lib/Lib_MerkleTrie.sol
+14
-17
Lib_RLPReader.sol
contracts/lib/Lib_RLPReader.sol
+2
-2
mips_test_memory.js
test/mips_test_memory.js
+2
-2
No files found.
contracts/lib/Lib_MerkleTrie.sol
View file @
dc8ce147
...
...
@@ -443,7 +443,7 @@ library Lib_MerkleTrie {
// We're dealing with an unnecessary extension node.
// We're going to delete the node entirely.
// Simply insert its current value into the branch index.
newBranch = _editBranchIndex
RLP(newBranch, branchKey, lastNode.decoded[lastNode.decoded.length-1]
);
newBranch = _editBranchIndex
(newBranch, branchKey, _getNodeValue(lastNode)
);
}
}
...
...
@@ -648,7 +648,19 @@ library Lib_MerkleTrie {
bytes memory _value
)
{
return Lib_RLPReader.readBytes(_node.decoded[_node.decoded.length - 1]);
Lib_RLPReader.RLPItem memory _in = _node.decoded[_node.decoded.length - 1];
// this is bytes only if the length is 32
(
uint256 itemOffset,
uint256 itemLength,
Lib_RLPReader.RLPItemType itemType
) = Lib_RLPReader._decodeLength(_in);
if (itemType == Lib_RLPReader.RLPItemType.DATA_ITEM) {
return Lib_RLPReader._copy(_in.ptr, itemOffset, itemLength);
} else {
return Lib_RLPReader._copy(_in.ptr, 0, _in.length);
}
}
/**
...
...
@@ -908,21 +920,6 @@ library Lib_MerkleTrie {
return _makeNode(_branch.decoded);
}
function _editBranchIndexRLP(
TrieNode memory _branch,
uint8 _index,
Lib_RLPReader.RLPItem memory encoded
)
private
pure
returns (
TrieNode memory _updatedNode
)
{
_branch.decoded[_index] = encoded;
return _makeNode(_branch.decoded);
}
/**
* @notice Utility; adds a prefix to a key.
* @param _key Key to prefix.
...
...
contracts/lib/Lib_RLPReader.sol
View file @
dc8ce147
...
...
@@ -457,7 +457,7 @@ library Lib_RLPReader {
function _decodeLength(
RLPItem memory _in
)
private
internal
pure
returns (
uint256,
...
...
@@ -564,7 +564,7 @@ library Lib_RLPReader {
uint256 _offset,
uint256 _length
)
private
internal
pure
returns (
bytes memory
...
...
test/mips_test_memory.js
View file @
dc8ce147
...
...
@@ -39,7 +39,7 @@ describe("MIPSMemory contract", function () {
expect
(
await
mm
.
ReadMemory
(
root
,
4
)).
to
.
equal
(
2
)
expect
(
await
mm
.
ReadMemory
(
root
,
0x40
)).
to
.
equal
(
3
)
})
/*
it("write four should work", async function() {
it
(
"
write four should work
"
,
async
function
()
{
await
mm
.
AddTrieNode
(
new
Uint8Array
([
0x80
]))
let
root
=
"
0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421
"
...
...
@@ -51,5 +51,5 @@ describe("MIPSMemory contract", function () {
expect
(
await
mm
.
ReadMemory
(
root
,
0x7fffd00c
)).
to
.
equal
(
1
)
expect
(
await
mm
.
ReadMemory
(
root
,
0x7fffd010
)).
to
.
equal
(
2
)
expect
(
await
mm
.
ReadMemory
(
root
,
0x7fffcffc
)).
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