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
6f7b2c8d
Commit
6f7b2c8d
authored
Oct 16, 2021
by
George Hotz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
woot! we are committing trie nodes
parent
205d51ff
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
6 deletions
+8
-6
MIPSMemory.sol
contracts/MIPSMemory.sol
+2
-2
Lib_MerkleTrie.sol
contracts/lib/Lib_MerkleTrie.sol
+6
-4
No files found.
contracts/MIPSMemory.sol
View file @
6f7b2c8d
...
...
@@ -82,12 +82,12 @@ contract MIPSMemory {
proofs[stateHash][addr] = proof;
}*/
function WriteMemory(bytes32 stateHash, uint32 addr, uint32 value) public
view
returns (bytes32) {
function WriteMemory(bytes32 stateHash, uint32 addr, uint32 value) public returns (bytes32) {
require(addr & 3 == 0, "write memory must be 32-bit aligned");
return Lib_MerkleTrie.update(tb(addr>>2), tb(value), trie, stateHash);
}
function WriteBytes32(bytes32 stateHash, uint32 addr, bytes32 val) public
view
returns (bytes32) {
function WriteBytes32(bytes32 stateHash, uint32 addr, bytes32 val) public returns (bytes32) {
for (uint32 i = 0; i < 32; i += 4) {
uint256 tv = uint256(val>>(224-(i*8)));
stateHash = WriteMemory(stateHash, addr+i, uint32(tv));
...
...
contracts/lib/Lib_MerkleTrie.sol
View file @
6f7b2c8d
...
...
@@ -74,7 +74,6 @@ library Lib_MerkleTrie {
bytes32 _root
)
internal
view
returns (
bytes32 _updatedRoot
)
...
...
@@ -87,7 +86,7 @@ library Lib_MerkleTrie {
(TrieNode[] memory proof, uint256 pathLength, bytes memory keyRemainder, ) = _walkNodePath(trie, _key, _root);
TrieNode[] memory newPath = _getNewPath(proof, pathLength, keyRemainder, _value);
return _getUpdatedTrieRoot(newPath, _key);
return _getUpdatedTrieRoot(newPath, _key
, trie
);
}
function getRawNode(bytes memory encoded) private view returns (TrieNode memory) {
...
...
@@ -437,10 +436,10 @@ library Lib_MerkleTrie {
*/
function _getUpdatedTrieRoot(
TrieNode[] memory _nodes,
bytes memory _key
bytes memory _key,
mapping(bytes32 => bytes) storage trie
)
private
pure
returns (
bytes32 _updatedRoot
)
...
...
@@ -487,6 +486,9 @@ library Lib_MerkleTrie {
// Compute the node hash for the next iteration.
previousNodeHash = _getNodeHash(currentNode.encoded);
if (currentNode.encoded.length >= 32) {
trie[keccak256(currentNode.encoded)] = currentNode.encoded;
}
}
// Current node should be the root at this point.
...
...
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