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
ab6e83e6
Unverified
Commit
ab6e83e6
authored
Jun 16, 2023
by
protolambda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cannon: polish evm tracer setup and fix linting
parent
1588712f
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
30 additions
and
19 deletions
+30
-19
run.go
cannon/cmd/run.go
+2
-2
evm.go
cannon/mipsevm/evm.go
+1
-1
evm_test.go
cannon/mipsevm/evm_test.go
+25
-14
state_test.go
cannon/mipsevm/state_test.go
+1
-1
witness.go
cannon/mipsevm/witness.go
+1
-1
No files found.
cannon/cmd/run.go
View file @
ab6e83e6
...
@@ -15,7 +15,7 @@ import (
...
@@ -15,7 +15,7 @@ import (
"github.com/pkg/profile"
"github.com/pkg/profile"
"github.com/ethereum-optimism/optimism/cannon/mipsevm"
"github.com/ethereum-optimism/optimism/cannon/mipsevm"
"github.com/ethereum-optimism/optimism/op-preimage"
preimage
"github.com/ethereum-optimism/optimism/op-preimage"
)
)
var
(
var
(
...
@@ -184,7 +184,7 @@ func Guard(proc *os.ProcessState, fn StepFn) StepFn {
...
@@ -184,7 +184,7 @@ func Guard(proc *os.ProcessState, fn StepFn) StepFn {
wit
,
err
:=
fn
(
proof
)
wit
,
err
:=
fn
(
proof
)
if
err
!=
nil
{
if
err
!=
nil
{
if
proc
.
Exited
()
{
if
proc
.
Exited
()
{
return
nil
,
fmt
.
Errorf
(
"pre-image server exited with code %d, resulting in err %
v
"
,
proc
.
ExitCode
(),
err
)
return
nil
,
fmt
.
Errorf
(
"pre-image server exited with code %d, resulting in err %
w
"
,
proc
.
ExitCode
(),
err
)
}
else
{
}
else
{
return
nil
,
err
return
nil
,
err
}
}
...
...
cannon/mipsevm/evm.go
View file @
ab6e83e6
...
@@ -37,7 +37,7 @@ func LoadContracts() (*Contracts, error) {
...
@@ -37,7 +37,7 @@ func LoadContracts() (*Contracts, error) {
oracle
.
DeployedBytecode
.
Object
=
hexutil
.
MustDecode
(
bindings
.
OracleDeployedBin
)
oracle
.
DeployedBytecode
.
Object
=
hexutil
.
MustDecode
(
bindings
.
OracleDeployedBin
)
oracle
.
DeployedBytecode
.
SourceMap
=
bindings
.
OracleDeployedSourceMap
oracle
.
DeployedBytecode
.
SourceMap
=
bindings
.
OracleDeployedSourceMap
return
&
Contracts
{
return
&
Contracts
{
MIPS
:
&
mips
,
MIPS
:
&
mips
,
Oracle
:
&
oracle
,
Oracle
:
&
oracle
,
},
nil
},
nil
}
}
...
...
cannon/mipsevm/evm_test.go
View file @
ab6e83e6
...
@@ -14,39 +14,46 @@ import (
...
@@ -14,39 +14,46 @@ import (
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/core/vm"
"github.com/ethereum/go-ethereum/core/vm"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/eth/tracers/logger"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/require"
"github.com/ethereum-optimism/optimism/op-chain-ops/srcmap"
"github.com/ethereum-optimism/optimism/op-chain-ops/srcmap"
)
)
func
testContractsSetup
(
t
*
testing
.
T
)
(
*
Contracts
,
*
Addresses
,
vm
.
EVMLogger
)
{
func
testContractsSetup
(
t
*
testing
.
T
)
(
*
Contracts
,
*
Addresses
)
{
contracts
,
err
:=
LoadContracts
()
contracts
,
err
:=
LoadContracts
()
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
mipsSrcMap
,
err
:=
contracts
.
MIPS
.
SourceMap
([]
string
{
"../../packages/contracts-bedrock/contracts/cannon/MIPS.sol"
})
require
.
NoError
(
t
,
err
)
oracleSrcMap
,
err
:=
contracts
.
Oracle
.
SourceMap
([]
string
{
"../../packages/contracts-bedrock/contracts/cannon/Oracle.sol"
})
require
.
NoError
(
t
,
err
)
addrs
:=
&
Addresses
{
addrs
:=
&
Addresses
{
MIPS
:
common
.
Address
{
0
:
0xff
,
19
:
1
},
MIPS
:
common
.
Address
{
0
:
0xff
,
19
:
1
},
Oracle
:
common
.
Address
{
0
:
0xff
,
19
:
2
},
Oracle
:
common
.
Address
{
0
:
0xff
,
19
:
2
},
Sender
:
common
.
Address
{
0x13
,
0x37
},
Sender
:
common
.
Address
{
0x13
,
0x37
},
FeeRecipient
:
common
.
Address
{
0xaa
},
FeeRecipient
:
common
.
Address
{
0xaa
},
}
}
var
tracer
vm
.
EVMLogger
tracer
=
srcmap
.
NewSourceMapTracer
(
map
[
common
.
Address
]
*
srcmap
.
SourceMap
{
addrs
.
MIPS
:
mipsSrcMap
,
addrs
.
Oracle
:
oracleSrcMap
},
os
.
Stdout
)
//tracer = logger.NewMarkdownLogger(&logger.Config{}, os.Stdout)
tracer
=
nil
// disable tracer
return
contracts
,
addrs
return
contracts
,
addrs
,
tracer
}
func
SourceMapTracer
(
t
*
testing
.
T
,
contracts
*
Contracts
,
addrs
*
Addresses
)
vm
.
EVMLogger
{
mipsSrcMap
,
err
:=
contracts
.
MIPS
.
SourceMap
([]
string
{
"../../packages/contracts-bedrock/contracts/cannon/MIPS.sol"
})
require
.
NoError
(
t
,
err
)
oracleSrcMap
,
err
:=
contracts
.
Oracle
.
SourceMap
([]
string
{
"../../packages/contracts-bedrock/contracts/cannon/Oracle.sol"
})
require
.
NoError
(
t
,
err
)
return
srcmap
.
NewSourceMapTracer
(
map
[
common
.
Address
]
*
srcmap
.
SourceMap
{
addrs
.
MIPS
:
mipsSrcMap
,
addrs
.
Oracle
:
oracleSrcMap
},
os
.
Stdout
)
}
func
MarkdownTracer
()
vm
.
EVMLogger
{
return
logger
.
NewMarkdownLogger
(
&
logger
.
Config
{},
os
.
Stdout
)
}
}
func
TestEVM
(
t
*
testing
.
T
)
{
func
TestEVM
(
t
*
testing
.
T
)
{
testFiles
,
err
:=
os
.
ReadDir
(
"open_mips_tests/test/bin"
)
testFiles
,
err
:=
os
.
ReadDir
(
"open_mips_tests/test/bin"
)
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
contracts
,
addrs
,
tracer
:=
testContractsSetup
(
t
)
contracts
,
addrs
:=
testContractsSetup
(
t
)
var
tracer
vm
.
EVMLogger
// no-tracer by default, but see SourceMapTracer and MarkdownTracer
//tracer = SourceMapTracer(t, contracts, addrs)
sender
:=
common
.
Address
{
0x13
,
0x37
}
sender
:=
common
.
Address
{
0x13
,
0x37
}
for
_
,
f
:=
range
testFiles
{
for
_
,
f
:=
range
testFiles
{
...
@@ -113,7 +120,9 @@ func TestEVM(t *testing.T) {
...
@@ -113,7 +120,9 @@ func TestEVM(t *testing.T) {
}
}
func
TestHelloEVM
(
t
*
testing
.
T
)
{
func
TestHelloEVM
(
t
*
testing
.
T
)
{
contracts
,
addrs
,
tracer
:=
testContractsSetup
(
t
)
contracts
,
addrs
:=
testContractsSetup
(
t
)
var
tracer
vm
.
EVMLogger
// no-tracer by default, but see SourceMapTracer and MarkdownTracer
//tracer = SourceMapTracer(t, contracts, addrs)
sender
:=
common
.
Address
{
0x13
,
0x37
}
sender
:=
common
.
Address
{
0x13
,
0x37
}
elfProgram
,
err
:=
elf
.
Open
(
"../example/bin/hello.elf"
)
elfProgram
,
err
:=
elf
.
Open
(
"../example/bin/hello.elf"
)
...
@@ -180,7 +189,9 @@ func TestHelloEVM(t *testing.T) {
...
@@ -180,7 +189,9 @@ func TestHelloEVM(t *testing.T) {
}
}
func
TestClaimEVM
(
t
*
testing
.
T
)
{
func
TestClaimEVM
(
t
*
testing
.
T
)
{
contracts
,
addrs
,
tracer
:=
testContractsSetup
(
t
)
contracts
,
addrs
:=
testContractsSetup
(
t
)
var
tracer
vm
.
EVMLogger
// no-tracer by default, but see SourceMapTracer and MarkdownTracer
//tracer = SourceMapTracer(t, contracts, addrs)
elfProgram
,
err
:=
elf
.
Open
(
"../example/bin/claim.elf"
)
elfProgram
,
err
:=
elf
.
Open
(
"../example/bin/claim.elf"
)
require
.
NoError
(
t
,
err
,
"open ELF file"
)
require
.
NoError
(
t
,
err
,
"open ELF file"
)
...
...
cannon/mipsevm/state_test.go
View file @
ab6e83e6
...
@@ -16,7 +16,7 @@ import (
...
@@ -16,7 +16,7 @@ import (
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/crypto"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/require"
"github.com/ethereum-optimism/optimism/op-preimage"
preimage
"github.com/ethereum-optimism/optimism/op-preimage"
)
)
// 0xbf_c0_00_00 ... baseAddrEnd is used in tests to write the results to
// 0xbf_c0_00_00 ... baseAddrEnd is used in tests to write the results to
...
...
cannon/mipsevm/witness.go
View file @
ab6e83e6
...
@@ -5,7 +5,7 @@ import (
...
@@ -5,7 +5,7 @@ import (
"errors"
"errors"
"fmt"
"fmt"
"github.com/ethereum-optimism/optimism/op-preimage"
preimage
"github.com/ethereum-optimism/optimism/op-preimage"
)
)
type
StepWitness
struct
{
type
StepWitness
struct
{
...
...
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