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
e0160775
Commit
e0160775
authored
Nov 06, 2021
by
George Hotz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix chain oracle
parent
7c3b3af0
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
19 additions
and
14 deletions
+19
-14
compare_evmchain_test.go
mipsevm/compare_evmchain_test.go
+2
-2
compare_unievm_test.go
mipsevm/compare_unievm_test.go
+1
-1
main.go
mipsevm/main.go
+1
-1
minievm.go
mipsevm/minievm.go
+8
-3
mips_chain_test.go
mipsevm/mips_chain_test.go
+1
-1
mips_evm_test.go
mipsevm/mips_evm_test.go
+1
-1
run_chain.go
mipsevm/run_chain.go
+1
-1
run_evm.go
mipsevm/run_evm.go
+4
-4
No files found.
mipsevm/compare_evmchain_test.go
View file @
e0160775
...
...
@@ -35,7 +35,7 @@ func TestCompareEvmChain(t *testing.T) {
fmt
.
Println
(
"state root"
,
root
,
"nodes"
,
len
(
Preimages
))
// deploy chain
interpreter
,
statedb
:=
GetInterpreter
(
0
,
true
)
interpreter
,
statedb
:=
GetInterpreter
(
0
,
true
,
""
)
DeployChain
(
interpreter
,
statedb
)
// load chain trie node
...
...
@@ -68,7 +68,7 @@ func TestCompareEvmChain(t *testing.T) {
// run on evm
go
func
()
{
for
step
:=
0
;
step
<
totalSteps
;
step
++
{
RunWithRam
(
ram
,
1
,
0
,
nil
)
RunWithRam
(
ram
,
1
,
0
,
""
,
nil
)
root
=
RamToTrie
(
ram
)
cuni
<-
root
}
...
...
mipsevm/compare_unievm_test.go
View file @
e0160775
...
...
@@ -42,7 +42,7 @@ func TestCompareUnicornEvm(t *testing.T) {
WriteRam
(
evmram
,
i
,
0
)
}
go
RunWithRam
(
evmram
,
steps
,
0
,
func
(
step
int
,
ram
map
[
uint32
](
uint32
))
{
go
RunWithRam
(
evmram
,
steps
,
0
,
""
,
func
(
step
int
,
ram
map
[
uint32
](
uint32
))
{
//fmt.Printf("%d evm %x\n", step, ram[0xc0000080])
cevm
<-
RegSerialize
(
ram
)
done
.
Lock
()
...
...
mipsevm/main.go
View file @
e0160775
...
...
@@ -40,7 +40,7 @@ func main() {
LoadMappedFile
(
"../mipigo/minigeth.bin"
,
ram
,
0
)
WriteCheckpoint
(
ram
,
"/tmp/cannon/golden.json"
,
-
1
)
LoadMappedFile
(
fmt
.
Sprintf
(
"%s/input"
,
root
),
ram
,
0x30000000
)
RunWithRam
(
ram
,
target
-
1
,
0
,
nil
)
RunWithRam
(
ram
,
target
-
1
,
0
,
root
,
nil
)
lastStep
+=
target
-
1
fn
:=
fmt
.
Sprintf
(
"%s/checkpoint_%d.json"
,
root
,
lastStep
)
WriteCheckpoint
(
ram
,
fn
,
lastStep
)
...
...
mipsevm/minievm.go
View file @
e0160775
...
...
@@ -4,6 +4,7 @@ import (
"encoding/binary"
"fmt"
"io/ioutil"
"log"
"math/big"
"os"
"time"
...
...
@@ -27,15 +28,17 @@ type StateDB struct {
PcCount
int
seenWrite
bool
useRealState
bool
root
string
}
func
NewStateDB
(
debug
int
,
realState
bool
)
*
StateDB
{
func
NewStateDB
(
debug
int
,
realState
bool
,
root
string
)
*
StateDB
{
statedb
:=
&
StateDB
{}
statedb
.
Bytecodes
=
make
(
map
[
common
.
Address
]([]
byte
))
statedb
.
RealState
=
make
(
map
[
common
.
Hash
](
common
.
Hash
))
statedb
.
Debug
=
debug
statedb
.
seenWrite
=
true
statedb
.
useRealState
=
realState
statedb
.
root
=
root
return
statedb
}
...
...
@@ -124,8 +127,10 @@ func (s *StateDB) GetState(fakeaddr common.Address, hash common.Hash) common.Has
binary
.
BigEndian
.
PutUint32
(
oracle_hash
[
i
:
i
+
4
],
ram
[
0x30001000
+
i
])
}
hash
:=
common
.
BytesToHash
(
oracle_hash
)
// TODO: this is wrong, need root
key
:=
fmt
.
Sprintf
(
"/tmp/eth/%s"
,
hash
)
if
s
.
root
==
""
{
log
.
Fatal
(
"need root if using hash oracle"
)
}
key
:=
fmt
.
Sprintf
(
"%s/%s"
,
s
.
root
,
hash
)
value
,
_
:=
ioutil
.
ReadFile
(
key
)
WriteRam
(
ram
,
0x31000000
,
uint32
(
len
(
value
)))
...
...
mipsevm/mips_chain_test.go
View file @
e0160775
...
...
@@ -15,7 +15,7 @@ func TestMipsChain(t *testing.T) {
ram
:=
LoadRam
()
root
:=
RamToTrie
(
ram
)
interpreter
,
statedb
:=
GetInterpreter
(
1
,
true
)
interpreter
,
statedb
:=
GetInterpreter
(
1
,
true
,
""
)
DeployChain
(
interpreter
,
statedb
)
// load chain trie node
...
...
mipsevm/mips_evm_test.go
View file @
e0160775
...
...
@@ -27,7 +27,7 @@ func TestSimpleEVM(t *testing.T) {
LoadMappedFile
(
fn
,
ram
,
0
)
start
:=
time
.
Now
()
remainingGas
,
err
:=
RunWithRam
(
ram
,
100
,
0
,
nil
)
remainingGas
,
err
:=
RunWithRam
(
ram
,
100
,
0
,
""
,
nil
)
elapsed
:=
time
.
Now
()
.
Sub
(
start
)
fmt
.
Println
(
err
,
remainingGas
,
elapsed
,
...
...
mipsevm/run_chain.go
View file @
e0160775
...
...
@@ -101,7 +101,7 @@ func LoadMappedFile(fn string, ram map[uint32](uint32), base uint32) {
}
func
RunFull
()
{
interpreter
,
statedb
:=
GetInterpreter
(
0
,
true
)
interpreter
,
statedb
:=
GetInterpreter
(
0
,
true
,
""
)
DeployChain
(
interpreter
,
statedb
)
ram
:=
make
(
map
[
uint32
](
uint32
))
...
...
mipsevm/run_evm.go
View file @
e0160775
...
...
@@ -34,8 +34,8 @@ func GetBytecode(deployed bool) []byte {
}
}
func
GetInterpreter
(
ldebug
int
,
realState
bool
)
(
*
vm
.
EVMInterpreter
,
*
StateDB
)
{
statedb
:=
NewStateDB
(
ldebug
,
realState
)
func
GetInterpreter
(
ldebug
int
,
realState
bool
,
root
string
)
(
*
vm
.
EVMInterpreter
,
*
StateDB
)
{
statedb
:=
NewStateDB
(
ldebug
,
realState
,
root
)
var
header
types
.
Header
header
.
Number
=
big
.
NewInt
(
13284469
)
...
...
@@ -52,8 +52,8 @@ func GetInterpreter(ldebug int, realState bool) (*vm.EVMInterpreter, *StateDB) {
return
interpreter
,
statedb
}
func
RunWithRam
(
lram
map
[
uint32
](
uint32
),
steps
int
,
debug
int
,
lcallback
func
(
int
,
map
[
uint32
](
uint32
)))
(
uint64
,
error
)
{
interpreter
,
statedb
:=
GetInterpreter
(
debug
,
false
)
func
RunWithRam
(
lram
map
[
uint32
](
uint32
),
steps
int
,
debug
int
,
root
string
,
lcallback
func
(
int
,
map
[
uint32
](
uint32
)))
(
uint64
,
error
)
{
interpreter
,
statedb
:=
GetInterpreter
(
debug
,
false
,
root
)
statedb
.
Ram
=
lram
callback
=
lcallback
...
...
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