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
64807a35
Commit
64807a35
authored
Oct 16, 2021
by
George Hotz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
events in minievm
parent
b8868034
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
22 deletions
+15
-22
MIPS.sol
contracts/MIPS.sol
+8
-21
minievm.go
mipsevm/minievm.go
+7
-1
No files found.
contracts/MIPS.sol
View file @
64807a35
...
...
@@ -35,14 +35,13 @@ contract MIPS {
bool constant public debug = true;
event DidStep(bytes32 stateHash);
event DidWriteMemory(uint32 addr, uint32 value);
event DidReadMemory(uint32 addr, uint32 value);
function WriteMemory(bytes32 stateHash, uint32 addr, uint32 value) internal returns (bytes32) {
if (address(m) != address(0)) {
if (debug) {
assembly {
// TODO: this is actually doing an SLOAD first
sstore(addr, value)
}
}
emit DidWriteMemory(addr, value);
return m.WriteMemory(stateHash, addr, value);
} else {
assembly {
...
...
@@ -53,21 +52,10 @@ contract MIPS {
}
}
function DebugEmit(uint32 val) internal view {
if (debug) {
uint256 junk;
assembly {
junk := sload(val)
}
require(junk != 0x133713371337, "huh");
}
}
function ReadMemory(bytes32 stateHash, uint32 addr) internal view returns (uint32 ret) {
function ReadMemory(bytes32 stateHash, uint32 addr) internal returns (uint32 ret) {
if (address(m) != address(0)) {
DebugEmit(addr);
ret = m.ReadMemory(stateHash, addr);
DebugEmit(
ret);
emit DidReadMemory(addr,
ret);
} else {
assembly {
ret := sload(addr)
...
...
@@ -121,7 +109,6 @@ contract MIPS {
return (stateHash, exit);
}
event Stepped(bytes32 stateHash);
function Step(bytes32 stateHash) public returns (bytes32 newStateHash) {
uint32 pc = ReadMemory(stateHash, REG_PC);
if (pc == 0x5ead0000) {
...
...
@@ -129,7 +116,7 @@ contract MIPS {
}
newStateHash = stepPC(stateHash, pc, pc+4);
if (address(m) != address(0)) {
emit
Stepped
(newStateHash);
emit
DidStep
(newStateHash);
}
}
...
...
mipsevm/minievm.go
View file @
64807a35
...
...
@@ -42,7 +42,13 @@ 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
)
{
fmt
.
Println
(
"AddLog"
,
log
)
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
{
fmt
.
Println
(
"AddLog"
,
log
.
Topics
,
log
.
Data
)
}
}
func
(
s
*
StateDB
)
AddPreimage
(
hash
common
.
Hash
,
preimage
[]
byte
)
{}
func
(
s
*
StateDB
)
AddRefund
(
gas
uint64
)
{}
...
...
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