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
71e0fd84
Unverified
Commit
71e0fd84
authored
Jun 16, 2023
by
protolambda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cannon: move sourcemap tracing util to op-chain-ops
parent
26c461ae
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
40 additions
and
4 deletions
+40
-4
evm.go
cannon/mipsevm/evm.go
+3
-2
evm_test.go
cannon/mipsevm/evm_test.go
+3
-1
solutil.go
op-chain-ops/srcmap/solutil.go
+6
-1
solutil_test.go
op-chain-ops/srcmap/solutil_test.go
+28
-0
No files found.
cannon/mipsevm/evm.go
View file @
71e0fd84
...
@@ -20,6 +20,7 @@ import (
...
@@ -20,6 +20,7 @@ import (
"github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/params"
"github.com/ethereum-optimism/optimism/op-bindings/bindings"
"github.com/ethereum-optimism/optimism/op-bindings/bindings"
"github.com/ethereum-optimism/optimism/op-chain-ops/srcmap"
)
)
var
(
var
(
...
@@ -78,8 +79,8 @@ type Contract struct {
...
@@ -78,8 +79,8 @@ type Contract struct {
// ignore abi,bytecode,etc.
// ignore abi,bytecode,etc.
}
}
func
(
c
*
Contract
)
SourceMap
(
sourcePaths
[]
string
)
(
*
SourceMap
,
error
)
{
func
(
c
*
Contract
)
SourceMap
(
sourcePaths
[]
string
)
(
*
srcmap
.
SourceMap
,
error
)
{
return
ParseSourceMap
(
sourcePaths
,
c
.
DeployedBytecode
.
Object
,
c
.
DeployedBytecode
.
SourceMap
)
return
srcmap
.
ParseSourceMap
(
sourcePaths
,
c
.
DeployedBytecode
.
Object
,
c
.
DeployedBytecode
.
SourceMap
)
}
}
type
Contracts
struct
{
type
Contracts
struct
{
...
...
cannon/mipsevm/evm_test.go
View file @
71e0fd84
...
@@ -15,6 +15,8 @@ import (
...
@@ -15,6 +15,8 @@ import (
"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/stretchr/testify/require"
"github.com/stretchr/testify/require"
"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
,
vm
.
EVMLogger
)
{
...
@@ -33,7 +35,7 @@ func testContractsSetup(t *testing.T) (*Contracts, *Addresses, vm.EVMLogger) {
...
@@ -33,7 +35,7 @@ func testContractsSetup(t *testing.T) (*Contracts, *Addresses, vm.EVMLogger) {
FeeRecipient
:
common
.
Address
{
0xaa
},
FeeRecipient
:
common
.
Address
{
0xaa
},
}
}
var
tracer
vm
.
EVMLogger
var
tracer
vm
.
EVMLogger
tracer
=
NewSourceMapTracer
(
map
[
common
.
Address
]
*
SourceMap
{
addrs
.
MIPS
:
mipsSrcMap
,
addrs
.
Oracle
:
oracleSrcMap
},
os
.
Stdout
)
tracer
=
srcmap
.
NewSourceMapTracer
(
map
[
common
.
Address
]
*
srcmap
.
SourceMap
{
addrs
.
MIPS
:
mipsSrcMap
,
addrs
.
Oracle
:
oracleSrcMap
},
os
.
Stdout
)
//tracer = logger.NewMarkdownLogger(&logger.Config{}, os.Stdout)
//tracer = logger.NewMarkdownLogger(&logger.Config{}, os.Stdout)
tracer
=
nil
// disable tracer
tracer
=
nil
// disable tracer
...
...
cannon/mipsevm
/solutil.go
→
op-chain-ops/srcmap
/solutil.go
View file @
71e0fd84
package
mipsevm
package
srcmap
import
(
import
(
"fmt"
"fmt"
...
@@ -108,6 +108,11 @@ func (s *SourceMap) FormattedInfo(pc uint64) string {
...
@@ -108,6 +108,11 @@ func (s *SourceMap) FormattedInfo(pc uint64) string {
// ParseSourceMap parses a solidity sourcemap: mapping bytecode indices to source references.
// ParseSourceMap parses a solidity sourcemap: mapping bytecode indices to source references.
// See https://docs.soliditylang.org/en/latest/internals/source_mappings.html
// See https://docs.soliditylang.org/en/latest/internals/source_mappings.html
//
// Sources is the list of source files, which will be read from the filesystem
// to transform token numbers into line/column numbers.
// The sources are as referenced in the source-map by index.
// Not all sources are necessary, some indices may be unknown.
func
ParseSourceMap
(
sources
[]
string
,
bytecode
[]
byte
,
sourceMap
string
)
(
*
SourceMap
,
error
)
{
func
ParseSourceMap
(
sources
[]
string
,
bytecode
[]
byte
,
sourceMap
string
)
(
*
SourceMap
,
error
)
{
instructions
:=
strings
.
Split
(
sourceMap
,
";"
)
instructions
:=
strings
.
Split
(
sourceMap
,
";"
)
...
...
cannon/mipsevm
/solutil_test.go
→
op-chain-ops/srcmap
/solutil_test.go
View file @
71e0fd84
package
mipsevm
package
srcmap
import
(
import
(
"strings"
"strings"
"testing"
"testing"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/require"
"github.com/ethereum-optimism/optimism/op-bindings/bindings"
)
)
func
TestSourcemap
(
t
*
testing
.
T
)
{
func
TestSourcemap
(
t
*
testing
.
T
)
{
contract
,
err
:=
LoadContract
(
"MIPS"
)
sourcePath
:=
"../../packages/contracts-bedrock/contracts/cannon/MIPS.sol"
require
.
NoError
(
t
,
err
)
deployedByteCode
:=
hexutil
.
MustDecode
(
bindings
.
MIPSDeployedBin
)
srcMap
,
err
:=
contract
.
SourceMap
([]
string
{
"../../packages/contracts-bedrock/contracts/cannon/MIPS.sol"
})
srcMap
,
err
:=
ParseSourceMap
(
[]
string
{
sourcePath
},
deployedByteCode
,
bindings
.
MIPSDeployedSourceMap
)
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
for
i
:=
0
;
i
<
len
(
contract
.
DeployedBytecode
.
Object
);
i
++
{
for
i
:=
0
;
i
<
len
(
deployedByteCode
);
i
++
{
info
:=
srcMap
.
FormattedInfo
(
uint64
(
i
))
info
:=
srcMap
.
FormattedInfo
(
uint64
(
i
))
if
!
strings
.
HasPrefix
(
info
,
"generated:"
)
&&
!
strings
.
HasPrefix
(
info
,
"../../packages/contracts-bedrock/contracts/cannon/MIPS.sol"
)
{
if
!
strings
.
HasPrefix
(
info
,
"generated:"
)
&&
!
strings
.
HasPrefix
(
info
,
sourcePath
)
{
t
.
Fatalf
(
"unexpected info: %q"
,
info
)
t
.
Fatalf
(
"unexpected info: %q"
,
info
)
}
}
}
}
...
...
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