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
462199c1
Commit
462199c1
authored
Oct 16, 2021
by
George Hotz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
working, fixed early exit
parent
3b929256
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
12 additions
and
5 deletions
+12
-5
MIPS.sol
contracts/MIPS.sol
+3
-1
Lib_MerkleTrie.sol
contracts/lib/Lib_MerkleTrie.sol
+3
-0
minievm.go
mipsevm/minievm.go
+4
-2
trie.go
mipsevm/trie.go
+1
-1
mips_test_trie.js
test/mips_test_trie.js
+1
-1
No files found.
contracts/MIPS.sol
View file @
462199c1
...
...
@@ -37,6 +37,7 @@ contract MIPS {
event DidStep(bytes32 stateHash);
event DidWriteMemory(uint32 addr, uint32 value);
event TryReadMemory(uint32 addr);
event DidReadMemory(uint32 addr, uint32 value);
function WriteMemory(bytes32 stateHash, uint32 addr, uint32 value) internal returns (bytes32) {
...
...
@@ -54,8 +55,9 @@ contract MIPS {
function ReadMemory(bytes32 stateHash, uint32 addr) internal returns (uint32 ret) {
if (address(m) != address(0)) {
emit TryReadMemory(addr);
ret = m.ReadMemory(stateHash, addr);
emit DidReadMemory(addr, ret);
//
emit DidReadMemory(addr, ret);
} else {
assembly {
ret := sload(addr)
...
...
contracts/lib/Lib_MerkleTrie.sol
View file @
462199c1
...
...
@@ -204,6 +204,9 @@ library Lib_MerkleTrie {
// Proof is top-down, so we start at the first element (root).
while (true) {
if (currentNodeID == bytes32(RLP_NULL)) {
break;
}
if (currentNodeLength >= 32) {
currentNode = getTrieNode(trie, currentNodeID);
} else {
...
...
mipsevm/minievm.go
View file @
462199c1
...
...
@@ -42,8 +42,10 @@ func NewStateDB(debug int, realState bool) *StateDB {
func
(
s
*
StateDB
)
AddAddressToAccessList
(
addr
common
.
Address
)
{}
func
(
s
*
StateDB
)
AddBalance
(
addr
common
.
Address
,
amount
*
big
.
Int
)
{}
func
(
s
*
StateDB
)
AddLog
(
log
*
types
.
Log
)
{
if
log
.
Topics
[
0
]
==
common
.
HexToHash
(
"0x7b1a2ade00e6a076351ef8a0f302b160b7fd0c65c18234dfe8218c4fa4fa10ab"
)
{
fmt
.
Printf
(
"R: %x -> %x
\n
"
,
bytesTo32
(
log
.
Data
[
0
:
32
]),
bytesTo32
(
log
.
Data
[
32
:
]))
if
log
.
Topics
[
0
]
==
common
.
HexToHash
(
"0x70c25ce54e55d181671946b6120c8147a91806a3620c981a355f3ae5b11deb13"
)
{
fmt
.
Printf
(
"R: %x
\n
"
,
bytesTo32
(
log
.
Data
[
0
:
32
]))
}
else
if
log
.
Topics
[
0
]
==
common
.
HexToHash
(
"0x7b1a2ade00e6a076351ef8a0f302b160b7fd0c65c18234dfe8218c4fa4fa10ab"
)
{
//fmt.Printf("R: %x -> %x\n", bytesTo32(log.Data[0:32]), bytesTo32(log.Data[32:]))
}
else
if
log
.
Topics
[
0
]
==
common
.
HexToHash
(
"0x486ca368095cbbef9046ac7858bec943e866422cc388f49da1aa3aa77c10aa35"
)
{
fmt
.
Printf
(
"W: %x <- %x
\n
"
,
bytesTo32
(
log
.
Data
[
0
:
32
]),
bytesTo32
(
log
.
Data
[
32
:
]))
}
else
{
...
...
mipsevm/trie.go
View file @
462199c1
...
...
@@ -95,7 +95,7 @@ func RamToTrie(ram map[uint32](uint32)) common.Hash {
for
_
,
kv
:=
range
sram
{
k
,
v
:=
uint32
(
kv
>>
32
),
uint32
(
kv
)
k
>>=
2
fmt
.
Printf
(
"insert %x = %x
\n
"
,
k
,
v
)
//
fmt.Printf("insert %x = %x\n", k, v)
tk
:=
make
([]
byte
,
4
)
tv
:=
make
([]
byte
,
4
)
binary
.
BigEndian
.
PutUint32
(
tk
,
k
)
...
...
test/mips_test_trie.js
View file @
462199c1
...
...
@@ -14,7 +14,7 @@ describe("MIPS contract", function () {
}
let
root
=
trieAdd
[
'
root
'
]
for
(
let
i
=
0
;
i
<
1
0
;
i
++
)
{
for
(
let
i
=
0
;
i
<
1
5
;
i
++
)
{
ret
=
await
m
.
Step
(
root
)
const
receipt
=
await
ret
.
wait
()
for
(
l
of
receipt
.
logs
)
{
...
...
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