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
9108c4e7
Commit
9108c4e7
authored
Oct 28, 2021
by
George Hotz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
isBytes, who knows if this is right
parent
4020dc1e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
12 deletions
+13
-12
.swp
.swp
+0
-0
Lib_MerkleTrie.sol
contracts/lib/Lib_MerkleTrie.sol
+12
-12
trie.go
mipsevm/trie.go
+1
-0
No files found.
.swp
0 → 100644
View file @
9108c4e7
File added
contracts/lib/Lib_MerkleTrie.sol
View file @
9108c4e7
...
...
@@ -6,7 +6,7 @@ import { Lib_BytesUtils } from "./Lib_BytesUtils.sol";
import { Lib_RLPReader } from "./Lib_RLPReader.sol";
import { Lib_RLPWriter } from "./Lib_RLPWriter.sol";
import "hardhat/console.sol";
//
import "hardhat/console.sol";
/**
* @title Lib_MerkleTrie
...
...
@@ -91,10 +91,6 @@ library Lib_MerkleTrie {
TrieNode[] memory newPath = _getNewPath(proof, pathLength, _key, keyRemainder, _value);
_updatedRoot = _getUpdatedTrieRoot(newPath, _key);
for (uint i = 0; i < newPath.length; i++) {
console.log(i, newPath[i].decoded.length);
}
}
function getRawNode(bytes memory encoded) private pure returns (TrieNode memory) {
...
...
@@ -399,7 +395,7 @@ library Lib_MerkleTrie {
// We've got some shared nibbles between the last node and our key remainder.
// We'll need to insert an extension node that covers these shared nibbles.
bytes memory nextNodeKey = Lib_BytesUtils.slice(lastNodeKey, 0, sharedNibbleLength);
newNodes[totalNewNodes] = _makeExtensionNode(nextNodeKey, _getNodeHash(_value));
newNodes[totalNewNodes] = _makeExtensionNode(nextNodeKey, _getNodeHash(_value)
, true
);
totalNewNodes += 1;
// Cut down the keys since we've just covered these shared nibbles.
...
...
@@ -436,7 +432,7 @@ library Lib_MerkleTrie {
// We're dealing with a shrinking extension node.
// We need to modify the node to decrease the size of the key.
TrieNode memory modifiedLastNode =
_makeExtensionNode(lastNodeKey, _getNodeValue(lastNode));
_makeExtensionNode(lastNodeKey, _getNodeValue(lastNode)
, false
);
newBranch =
_editBranchIndex(
newBranch,
...
...
@@ -677,11 +673,11 @@ library Lib_MerkleTrie {
bytes memory _hash
)
{
console.logBytes(_encoded);
//
console.logBytes(_encoded);
if (_encoded.length < 32) {
return _encoded;
} else {
console.logBytes32(keccak256(_encoded));
//
console.logBytes32(keccak256(_encoded));
GetTrie()[keccak256(_encoded)] = _encoded;
return abi.encodePacked(keccak256(_encoded));
}
...
...
@@ -792,10 +788,10 @@ library Lib_MerkleTrie {
*/
function _makeExtensionNode(
bytes memory _key,
bytes memory _value
bytes memory _value,
bool isBytes
)
private
pure
returns (
TrieNode memory _node
)
...
...
@@ -803,7 +799,11 @@ library Lib_MerkleTrie {
bytes[] memory raw = new bytes[](2);
bytes memory key = _addHexPrefix(_key, false);
raw[0] = Lib_RLPWriter.writeBytes(Lib_BytesUtils.fromNibbles(key));
raw[1] = Lib_RLPWriter.writeBytes(_value);
if (_value.length >= 32 || isBytes) {
raw[1] = Lib_RLPWriter.writeBytes(_value);
} else {
raw[1] = _value;
}
return _makeNode(raw);
}
...
...
mipsevm/trie.go
View file @
9108c4e7
...
...
@@ -84,6 +84,7 @@ func ParseNode(node common.Hash, depth int, callback func(common.Hash) []byte) {
return
}
buf
:=
callback
(
node
)
//fmt.Println("callback", node, len(buf), hex.EncodeToString(buf))
elems
,
_
,
err
:=
rlp
.
SplitList
(
buf
)
check
(
err
)
ParseNodeInternal
(
elems
,
depth
,
callback
)
...
...
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