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
b8868034
Commit
b8868034
authored
Oct 16, 2021
by
George Hotz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
touch ups
parent
d3682d8a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
20 deletions
+23
-20
MIPS.sol
contracts/MIPS.sol
+18
-17
MIPSMemory.sol
contracts/MIPSMemory.sol
+1
-1
Lib_MerkleTrie.sol
contracts/lib/Lib_MerkleTrie.sol
+4
-2
No files found.
contracts/MIPS.sol
View file @
b8868034
...
...
@@ -128,7 +128,9 @@ contract MIPS {
return stateHash;
}
newStateHash = stepPC(stateHash, pc, pc+4);
emit Stepped(newStateHash);
if (address(m) != address(0)) {
emit Stepped(newStateHash);
}
}
// will revert if any required input state is missing
...
...
@@ -180,22 +182,6 @@ contract MIPS {
storeAddr = rtReg;
}
// memory fetch (all I-type)
// we do the load for stores also
uint32 mem;
if (opcode >= 0x20) {
// M[R[rs]+SignExtImm]
uint32 SignExtImm = SE(insn&0xFFFF, 16);
rs += SignExtImm;
uint32 addr = rs & 0xFFFFFFFC;
mem = ReadMemory(stateHash, addr);
if (opcode >= 0x28 && opcode != 0x30) {
// store
storeAddr = addr;
}
}
if ((opcode >= 4 && opcode < 8) || opcode == 1) {
bool shouldBranch = false;
...
...
@@ -221,6 +207,21 @@ contract MIPS {
}
// memory fetch (all I-type)
// we do the load for stores also
uint32 mem;
if (opcode >= 0x20) {
// M[R[rs]+SignExtImm]
uint32 SignExtImm = SE(insn&0xFFFF, 16);
rs += SignExtImm;
uint32 addr = rs & 0xFFFFFFFC;
mem = ReadMemory(stateHash, addr);
if (opcode >= 0x28 && opcode != 0x30) {
// store
storeAddr = addr;
}
}
// ALU
uint32 val = execute(insn, rs, rt, mem);
...
...
contracts/MIPSMemory.sol
View file @
b8868034
...
...
@@ -61,7 +61,7 @@ contract MIPSMemory {
return ret;
}
function fb(bytes memory dat) internal
view
returns (uint32) {
function fb(bytes memory dat) internal
pure
returns (uint32) {
require(dat.length == 4, "wrong length value");
uint32 ret = uint32(uint8(dat[0])) << 24 |
uint32(uint8(dat[1])) << 16 |
...
...
contracts/lib/Lib_MerkleTrie.sol
View file @
b8868034
...
...
@@ -89,7 +89,7 @@ library Lib_MerkleTrie {
return _getUpdatedTrieRoot(newPath, _key, trie);
}
function getRawNode(bytes memory encoded) private
view
returns (TrieNode memory) {
function getRawNode(bytes memory encoded) private
pure
returns (TrieNode memory) {
return TrieNode({
encoded: encoded,
decoded: Lib_RLPReader.readList(encoded)
...
...
@@ -97,7 +97,9 @@ library Lib_MerkleTrie {
}
function getTrieNode(mapping(bytes32 => bytes) storage trie, bytes32 nodeId) private view returns (TrieNode memory) {
return getRawNode(trie[nodeId]);
bytes memory encoded = trie[nodeId];
require(keccak256(encoded) == nodeId, "bad hash in trie lookup");
return getRawNode(encoded);
}
/**
...
...
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