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
330c2f74
Commit
330c2f74
authored
Oct 11, 2023
by
clabby
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Dynamically load selectors - @tynes review
Co-Authored-By:
Mark Tyneway
<
mark.tyneway@gmail.com
>
parent
7820f5f8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
4 deletions
+26
-4
evm.go
cannon/mipsevm/evm.go
+26
-4
No files found.
cannon/mipsevm/evm.go
View file @
330c2f74
...
@@ -16,7 +16,6 @@ import (
...
@@ -16,7 +16,6 @@ import (
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/types"
"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/params"
"github.com/ethereum/go-ethereum/params"
"github.com/ethereum-optimism/optimism/op-bindings/bindings"
"github.com/ethereum-optimism/optimism/op-bindings/bindings"
...
@@ -24,9 +23,9 @@ import (
...
@@ -24,9 +23,9 @@ import (
)
)
var
(
var
(
StepBytes4
=
crypto
.
Keccak256
([]
byte
(
"step(bytes,bytes,uint256)"
))[
:
4
]
StepBytes4
[]
byte
LoadKeccak256PreimagePartBytes4
=
crypto
.
Keccak256
([]
byte
(
"loadKeccak256PreimagePart(uint256,bytes)"
))[
:
4
]
LoadKeccak256PreimagePartBytes4
[]
byte
LoadLocalDataBytes4
=
crypto
.
Keccak256
([]
byte
(
"loadLocalData(uint256,uint256,bytes32,uint256,uint256)"
))[
:
4
]
LoadLocalDataBytes4
[]
byte
)
)
// LoadContracts loads the Cannon contracts, from op-bindings package
// LoadContracts loads the Cannon contracts, from op-bindings package
...
@@ -36,6 +35,9 @@ func LoadContracts() (*Contracts, error) {
...
@@ -36,6 +35,9 @@ func LoadContracts() (*Contracts, error) {
mips
.
DeployedBytecode
.
SourceMap
=
bindings
.
MIPSDeployedSourceMap
mips
.
DeployedBytecode
.
SourceMap
=
bindings
.
MIPSDeployedSourceMap
oracle
.
DeployedBytecode
.
Object
=
hexutil
.
MustDecode
(
bindings
.
PreimageOracleDeployedBin
)
oracle
.
DeployedBytecode
.
Object
=
hexutil
.
MustDecode
(
bindings
.
PreimageOracleDeployedBin
)
oracle
.
DeployedBytecode
.
SourceMap
=
bindings
.
PreimageOracleDeployedSourceMap
oracle
.
DeployedBytecode
.
SourceMap
=
bindings
.
PreimageOracleDeployedSourceMap
if
err
:=
InitSelectors
();
err
!=
nil
{
return
nil
,
err
}
return
&
Contracts
{
return
&
Contracts
{
MIPS
:
&
mips
,
MIPS
:
&
mips
,
Oracle
:
&
oracle
,
Oracle
:
&
oracle
,
...
@@ -52,12 +54,32 @@ func LoadContractsFromFiles() (*Contracts, error) {
...
@@ -52,12 +54,32 @@ func LoadContractsFromFiles() (*Contracts, error) {
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
if
err
:=
InitSelectors
();
err
!=
nil
{
return
nil
,
err
}
return
&
Contracts
{
return
&
Contracts
{
MIPS
:
mips
,
MIPS
:
mips
,
Oracle
:
oracle
,
Oracle
:
oracle
,
},
nil
},
nil
}
}
func
InitSelectors
()
error
{
mipsAbi
,
err
:=
bindings
.
MIPSMetaData
.
GetAbi
()
if
err
!=
nil
{
return
fmt
.
Errorf
(
"failed to load MIPS ABI: %w"
,
err
)
}
StepBytes4
=
mipsAbi
.
Methods
[
"step"
]
.
ID
[
:
4
]
preimageAbi
,
err
:=
bindings
.
PreimageOracleMetaData
.
GetAbi
()
if
err
!=
nil
{
return
fmt
.
Errorf
(
"failed to load pre-image oracle ABI: %w"
,
err
)
}
LoadKeccak256PreimagePartBytes4
=
preimageAbi
.
Methods
[
"loadKeccak256PreimagePart"
]
.
ID
[
:
4
]
LoadLocalDataBytes4
=
preimageAbi
.
Methods
[
"loadLocalData"
]
.
ID
[
:
4
]
return
nil
}
func
LoadContract
(
name
string
)
(
*
Contract
,
error
)
{
func
LoadContract
(
name
string
)
(
*
Contract
,
error
)
{
dat
,
err
:=
os
.
ReadFile
(
fmt
.
Sprintf
(
"../../packages/contracts-bedrock/forge-artifacts/%s.sol/%s.json"
,
name
,
name
))
dat
,
err
:=
os
.
ReadFile
(
fmt
.
Sprintf
(
"../../packages/contracts-bedrock/forge-artifacts/%s.sol/%s.json"
,
name
,
name
))
if
err
!=
nil
{
if
err
!=
nil
{
...
...
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