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
64361244
Unverified
Commit
64361244
authored
Sep 05, 2023
by
mergify[bot]
Committed by
GitHub
Sep 05, 2023
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'develop' into aj/require-e2e
parents
ac1a0e62
05bacdc2
Changes
27
Show whitespace changes
Inline
Side-by-side
Showing
27 changed files
with
381 additions
and
143 deletions
+381
-143
README.md
README.md
+1
-0
codecov.yml
codecov.yml
+1
-4
Dockerfile
indexer/Dockerfile
+0
-2
cli.go
indexer/cmd/indexer/cli.go
+2
-2
config.go
indexer/config/config.go
+7
-13
config_test.go
indexer/config/config_test.go
+6
-6
setup.go
indexer/e2e_tests/setup.go
+3
-5
indexer.go
indexer/indexer.go
+40
-7
indexer.toml
indexer/indexer.toml
+1
-1
README.md
op-challenger/README.md
+45
-6
init_game.sh
op-challenger/scripts/alphabet/init_game.sh
+1
-1
deposit_test.go
op-e2e/deposit_test.go
+138
-0
peers.go
op-e2e/e2eutils/geth/peers.go
+49
-0
l2_gossip_test.go
op-e2e/l2_gossip_test.go
+32
-0
setup.go
op-e2e/setup.go
+2
-2
system_test.go
op-e2e/system_test.go
+0
-62
tx_helper.go
op-e2e/tx_helper.go
+10
-8
main.go
op-node/cmd/stateviz/main.go
+1
-1
p2p_flags.go
op-node/flags/p2p_flags.go
+0
-1
metrics.go
op-node/metrics/metrics.go
+1
-1
server.go
op-node/node/server.go
+1
-1
load_config.go
op-node/p2p/cli/load_config.go
+6
-5
disk.go
op-program/host/kvstore/disk.go
+16
-1
disk_test.go
op-program/host/kvstore/disk_test.go
+16
-1
http.go
op-service/httputil/http.go
+1
-1
server.go
op-service/httputil/server.go
+0
-11
challenger.md
specs/challenger.md
+1
-1
No files found.
README.md
View file @
64361244
...
@@ -57,6 +57,7 @@ Refer to the Directory Structure section below to understand which packages are
...
@@ -57,6 +57,7 @@ Refer to the Directory Structure section below to understand which packages are
├──
<a
href=
"./op-exporter"
>
op-exporter
</a>
: Prometheus exporter client
├──
<a
href=
"./op-exporter"
>
op-exporter
</a>
: Prometheus exporter client
├──
<a
href=
"./op-heartbeat"
>
op-heartbeat
</a>
: Heartbeat monitor service
├──
<a
href=
"./op-heartbeat"
>
op-heartbeat
</a>
: Heartbeat monitor service
├──
<a
href=
"./op-node"
>
op-node
</a>
: rollup consensus-layer client
├──
<a
href=
"./op-node"
>
op-node
</a>
: rollup consensus-layer client
├──
<a
href=
"./op-preimage"
>
op-preimage
</a>
: Go bindings for Preimage Oracle
├──
<a
href=
"./op-program"
>
op-program
</a>
: Fault proof program
├──
<a
href=
"./op-program"
>
op-program
</a>
: Fault proof program
├──
<a
href=
"./op-proposer"
>
op-proposer
</a>
: L2-Output Submitter, submits proposals to L1
├──
<a
href=
"./op-proposer"
>
op-proposer
</a>
: L2-Output Submitter, submits proposals to L1
├──
<a
href=
"./op-service"
>
op-service
</a>
: Common codebase utilities
├──
<a
href=
"./op-service"
>
op-service
</a>
: Common codebase utilities
...
...
codecov.yml
View file @
64361244
comment
:
comment
:
false
layout
:
"
reach,
diff,
flags,
files"
behavior
:
default
require_changes
:
true
# only post the comment if coverage changes
ignore
:
ignore
:
-
"
op-e2e"
-
"
op-e2e"
-
"
**/*.t.sol"
-
"
**/*.t.sol"
...
...
indexer/Dockerfile
View file @
64361244
...
@@ -10,8 +10,6 @@ COPY ./op-node /app/op-node
...
@@ -10,8 +10,6 @@ COPY ./op-node /app/op-node
COPY
./go.mod /app/go.mod
COPY
./go.mod /app/go.mod
COPY
./go.sum /app/go.sum
COPY
./go.sum /app/go.sum
COPY
./.git /app/.git
WORKDIR
/app/indexer
WORKDIR
/app/indexer
RUN
go mod download
RUN
go mod download
...
...
indexer/cmd/indexer/cli.go
View file @
64361244
...
@@ -38,7 +38,7 @@ func runIndexer(ctx *cli.Context) error {
...
@@ -38,7 +38,7 @@ func runIndexer(ctx *cli.Context) error {
}
}
defer
db
.
Close
()
defer
db
.
Close
()
indexer
,
err
:=
indexer
.
NewIndexer
(
log
,
db
,
cfg
.
Chain
,
cfg
.
RPCs
,
cfg
.
Metrics
)
indexer
,
err
:=
indexer
.
NewIndexer
(
log
,
db
,
cfg
.
Chain
,
cfg
.
RPCs
,
cfg
.
HTTPServer
,
cfg
.
MetricsServer
)
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Error
(
"failed to create indexer"
,
"err"
,
err
)
log
.
Error
(
"failed to create indexer"
,
"err"
,
err
)
return
err
return
err
...
@@ -63,7 +63,7 @@ func runApi(ctx *cli.Context) error {
...
@@ -63,7 +63,7 @@ func runApi(ctx *cli.Context) error {
defer
db
.
Close
()
defer
db
.
Close
()
api
:=
api
.
NewApi
(
log
,
db
.
BridgeTransfers
)
api
:=
api
.
NewApi
(
log
,
db
.
BridgeTransfers
)
return
api
.
Listen
(
ctx
.
Context
,
cfg
.
API
.
Port
)
return
api
.
Listen
(
ctx
.
Context
,
cfg
.
HTTPServer
.
Port
)
}
}
func
runAll
(
ctx
*
cli
.
Context
)
error
{
func
runAll
(
ctx
*
cli
.
Context
)
error
{
...
...
indexer/config/config.go
View file @
64361244
...
@@ -23,8 +23,8 @@ type Config struct {
...
@@ -23,8 +23,8 @@ type Config struct {
Chain
ChainConfig
`toml:"chain"`
Chain
ChainConfig
`toml:"chain"`
RPCs
RPCsConfig
`toml:"rpcs"`
RPCs
RPCsConfig
`toml:"rpcs"`
DB
DBConfig
`toml:"db"`
DB
DBConfig
`toml:"db"`
API
APIConfig
`toml:"api
"`
HTTPServer
ServerConfig
`toml:"http
"`
Metrics
Metrics
Config
`toml:"metrics"`
Metrics
Server
Server
Config
`toml:"metrics"`
}
}
// fetch this via onchain config from RPCsConfig and remove from config in future
// fetch this via onchain config from RPCsConfig and remove from config in future
...
@@ -96,14 +96,8 @@ type DBConfig struct {
...
@@ -96,14 +96,8 @@ type DBConfig struct {
Password
string
`toml:"password"`
Password
string
`toml:"password"`
}
}
// APIConfig configures the API server
// Configures the a server
type
APIConfig
struct
{
type
ServerConfig
struct
{
Host
string
`toml:"host"`
Port
int
`toml:"port"`
}
// MetricsConfig configures the metrics server
type
MetricsConfig
struct
{
Host
string
`toml:"host"`
Host
string
`toml:"host"`
Port
int
`toml:"port"`
Port
int
`toml:"port"`
}
}
...
...
indexer/config/config_test.go
View file @
64361244
...
@@ -33,7 +33,7 @@ func TestLoadConfig(t *testing.T) {
...
@@ -33,7 +33,7 @@ func TestLoadConfig(t *testing.T) {
password = "postgres"
password = "postgres"
name = "indexer"
name = "indexer"
[
api
]
[
http
]
host = "127.0.0.1"
host = "127.0.0.1"
port = 8080
port = 8080
...
@@ -65,10 +65,10 @@ func TestLoadConfig(t *testing.T) {
...
@@ -65,10 +65,10 @@ func TestLoadConfig(t *testing.T) {
require
.
Equal
(
t
,
conf
.
DB
.
User
,
"postgres"
)
require
.
Equal
(
t
,
conf
.
DB
.
User
,
"postgres"
)
require
.
Equal
(
t
,
conf
.
DB
.
Password
,
"postgres"
)
require
.
Equal
(
t
,
conf
.
DB
.
Password
,
"postgres"
)
require
.
Equal
(
t
,
conf
.
DB
.
Name
,
"indexer"
)
require
.
Equal
(
t
,
conf
.
DB
.
Name
,
"indexer"
)
require
.
Equal
(
t
,
conf
.
API
.
Host
,
"127.0.0.1"
)
require
.
Equal
(
t
,
conf
.
HTTPServer
.
Host
,
"127.0.0.1"
)
require
.
Equal
(
t
,
conf
.
API
.
Port
,
8080
)
require
.
Equal
(
t
,
conf
.
HTTPServer
.
Port
,
8080
)
require
.
Equal
(
t
,
conf
.
Metrics
.
Host
,
"127.0.0.1"
)
require
.
Equal
(
t
,
conf
.
Metrics
Server
.
Host
,
"127.0.0.1"
)
require
.
Equal
(
t
,
conf
.
Metrics
.
Port
,
7300
)
require
.
Equal
(
t
,
conf
.
Metrics
Server
.
Port
,
7300
)
}
}
func
TestLoadConfig_WithoutPreset
(
t
*
testing
.
T
)
{
func
TestLoadConfig_WithoutPreset
(
t
*
testing
.
T
)
{
...
...
indexer/e2e_tests/setup.go
View file @
64361244
...
@@ -82,10 +82,8 @@ func createE2ETestSuite(t *testing.T) E2ETestSuite {
...
@@ -82,10 +82,8 @@ func createE2ETestSuite(t *testing.T) E2ETestSuite {
L1StandardBridgeProxy
:
opCfg
.
L1Deployments
.
L1StandardBridgeProxy
,
L1StandardBridgeProxy
:
opCfg
.
L1Deployments
.
L1StandardBridgeProxy
,
},
},
},
},
Metrics
:
config
.
MetricsConfig
{
HTTPServer
:
config
.
ServerConfig
{
Host
:
"127.0.0.1"
,
Port
:
0
},
Host
:
"127.0.0.1"
,
MetricsServer
:
config
.
ServerConfig
{
Host
:
"127.0.0.1"
,
Port
:
0
},
Port
:
0
,
},
}
}
db
,
err
:=
database
.
NewDB
(
indexerCfg
.
DB
)
db
,
err
:=
database
.
NewDB
(
indexerCfg
.
DB
)
...
@@ -93,7 +91,7 @@ func createE2ETestSuite(t *testing.T) E2ETestSuite {
...
@@ -93,7 +91,7 @@ func createE2ETestSuite(t *testing.T) E2ETestSuite {
t
.
Cleanup
(
func
()
{
db
.
Close
()
})
t
.
Cleanup
(
func
()
{
db
.
Close
()
})
indexerLog
:=
testlog
.
Logger
(
t
,
log
.
LvlInfo
)
.
New
(
"role"
,
"indexer"
)
indexerLog
:=
testlog
.
Logger
(
t
,
log
.
LvlInfo
)
.
New
(
"role"
,
"indexer"
)
indexer
,
err
:=
indexer
.
NewIndexer
(
indexerLog
,
db
,
indexerCfg
.
Chain
,
indexerCfg
.
RPCs
,
indexerCfg
.
Metrics
)
indexer
,
err
:=
indexer
.
NewIndexer
(
indexerLog
,
db
,
indexerCfg
.
Chain
,
indexerCfg
.
RPCs
,
indexerCfg
.
HTTPServer
,
indexerCfg
.
MetricsServer
)
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
indexerCtx
,
indexerStop
:=
context
.
WithCancel
(
context
.
Background
())
indexerCtx
,
indexerStop
:=
context
.
WithCancel
(
context
.
Background
())
...
...
indexer/indexer.go
View file @
64361244
...
@@ -4,10 +4,15 @@ import (
...
@@ -4,10 +4,15 @@ import (
"context"
"context"
"fmt"
"fmt"
"math/big"
"math/big"
"net/http"
"runtime/debug"
"runtime/debug"
"sync"
"sync"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/log"
"github.com/go-chi/chi/v5"
"github.com/go-chi/chi/v5/middleware"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus"
"github.com/ethereum-optimism/optimism/indexer/config"
"github.com/ethereum-optimism/optimism/indexer/config"
...
@@ -15,6 +20,7 @@ import (
...
@@ -15,6 +20,7 @@ import (
"github.com/ethereum-optimism/optimism/indexer/etl"
"github.com/ethereum-optimism/optimism/indexer/etl"
"github.com/ethereum-optimism/optimism/indexer/node"
"github.com/ethereum-optimism/optimism/indexer/node"
"github.com/ethereum-optimism/optimism/indexer/processors"
"github.com/ethereum-optimism/optimism/indexer/processors"
"github.com/ethereum-optimism/optimism/op-service/httputil"
"github.com/ethereum-optimism/optimism/op-service/metrics"
"github.com/ethereum-optimism/optimism/op-service/metrics"
)
)
...
@@ -24,7 +30,8 @@ type Indexer struct {
...
@@ -24,7 +30,8 @@ type Indexer struct {
log
log
.
Logger
log
log
.
Logger
db
*
database
.
DB
db
*
database
.
DB
metricsConfig
config
.
MetricsConfig
httpConfig
config
.
ServerConfig
metricsConfig
config
.
ServerConfig
metricsRegistry
*
prometheus
.
Registry
metricsRegistry
*
prometheus
.
Registry
L1ETL
*
etl
.
L1ETL
L1ETL
*
etl
.
L1ETL
...
@@ -33,7 +40,14 @@ type Indexer struct {
...
@@ -33,7 +40,14 @@ type Indexer struct {
}
}
// NewIndexer initializes an instance of the Indexer
// NewIndexer initializes an instance of the Indexer
func
NewIndexer
(
logger
log
.
Logger
,
db
*
database
.
DB
,
chainConfig
config
.
ChainConfig
,
rpcsConfig
config
.
RPCsConfig
,
metricsConfig
config
.
MetricsConfig
)
(
*
Indexer
,
error
)
{
func
NewIndexer
(
log
log
.
Logger
,
db
*
database
.
DB
,
chainConfig
config
.
ChainConfig
,
rpcsConfig
config
.
RPCsConfig
,
httpConfig
config
.
ServerConfig
,
metricsConfig
config
.
ServerConfig
,
)
(
*
Indexer
,
error
)
{
metricsRegistry
:=
metrics
.
NewRegistry
()
metricsRegistry
:=
metrics
.
NewRegistry
()
// L1
// L1
...
@@ -47,7 +61,7 @@ func NewIndexer(logger log.Logger, db *database.DB, chainConfig config.ChainConf
...
@@ -47,7 +61,7 @@ func NewIndexer(logger log.Logger, db *database.DB, chainConfig config.ChainConf
ConfirmationDepth
:
big
.
NewInt
(
int64
(
chainConfig
.
L1ConfirmationDepth
)),
ConfirmationDepth
:
big
.
NewInt
(
int64
(
chainConfig
.
L1ConfirmationDepth
)),
StartHeight
:
big
.
NewInt
(
int64
(
chainConfig
.
L1StartingHeight
)),
StartHeight
:
big
.
NewInt
(
int64
(
chainConfig
.
L1StartingHeight
)),
}
}
l1Etl
,
err
:=
etl
.
NewL1ETL
(
l1Cfg
,
log
ger
,
db
,
etl
.
NewMetrics
(
metricsRegistry
,
"l1"
),
l1EthClient
,
chainConfig
.
L1Contracts
)
l1Etl
,
err
:=
etl
.
NewL1ETL
(
l1Cfg
,
log
,
db
,
etl
.
NewMetrics
(
metricsRegistry
,
"l1"
),
l1EthClient
,
chainConfig
.
L1Contracts
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
...
@@ -62,21 +76,22 @@ func NewIndexer(logger log.Logger, db *database.DB, chainConfig config.ChainConf
...
@@ -62,21 +76,22 @@ func NewIndexer(logger log.Logger, db *database.DB, chainConfig config.ChainConf
HeaderBufferSize
:
chainConfig
.
L2HeaderBufferSize
,
HeaderBufferSize
:
chainConfig
.
L2HeaderBufferSize
,
ConfirmationDepth
:
big
.
NewInt
(
int64
(
chainConfig
.
L2ConfirmationDepth
)),
ConfirmationDepth
:
big
.
NewInt
(
int64
(
chainConfig
.
L2ConfirmationDepth
)),
}
}
l2Etl
,
err
:=
etl
.
NewL2ETL
(
l2Cfg
,
log
ger
,
db
,
etl
.
NewMetrics
(
metricsRegistry
,
"l2"
),
l2EthClient
)
l2Etl
,
err
:=
etl
.
NewL2ETL
(
l2Cfg
,
log
,
db
,
etl
.
NewMetrics
(
metricsRegistry
,
"l2"
),
l2EthClient
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
// Bridge
// Bridge
bridgeProcessor
,
err
:=
processors
.
NewBridgeProcessor
(
log
ger
,
db
,
l1Etl
,
chainConfig
)
bridgeProcessor
,
err
:=
processors
.
NewBridgeProcessor
(
log
,
db
,
l1Etl
,
chainConfig
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
indexer
:=
&
Indexer
{
indexer
:=
&
Indexer
{
log
:
log
ger
,
log
:
log
,
db
:
db
,
db
:
db
,
httpConfig
:
httpConfig
,
metricsConfig
:
metricsConfig
,
metricsConfig
:
metricsConfig
,
metricsRegistry
:
metricsRegistry
,
metricsRegistry
:
metricsRegistry
,
...
@@ -88,6 +103,23 @@ func NewIndexer(logger log.Logger, db *database.DB, chainConfig config.ChainConf
...
@@ -88,6 +103,23 @@ func NewIndexer(logger log.Logger, db *database.DB, chainConfig config.ChainConf
return
indexer
,
nil
return
indexer
,
nil
}
}
func
(
i
*
Indexer
)
startHttpServer
(
ctx
context
.
Context
)
error
{
i
.
log
.
Info
(
"starting http server..."
,
"port"
,
i
.
httpConfig
.
Host
)
r
:=
chi
.
NewRouter
()
r
.
Use
(
middleware
.
Heartbeat
(
"/healthz"
))
server
:=
http
.
Server
{
Addr
:
fmt
.
Sprintf
(
"%s:%d"
,
i
.
httpConfig
.
Host
,
i
.
httpConfig
.
Port
),
Handler
:
r
}
err
:=
httputil
.
ListenAndServeContext
(
ctx
,
&
server
)
if
err
!=
nil
{
i
.
log
.
Error
(
"http server stopped"
,
"err"
,
err
)
}
else
{
i
.
log
.
Info
(
"http server stopped"
)
}
return
err
}
func
(
i
*
Indexer
)
startMetricsServer
(
ctx
context
.
Context
)
error
{
func
(
i
*
Indexer
)
startMetricsServer
(
ctx
context
.
Context
)
error
{
i
.
log
.
Info
(
"starting metrics server..."
,
"port"
,
i
.
metricsConfig
.
Port
)
i
.
log
.
Info
(
"starting metrics server..."
,
"port"
,
i
.
metricsConfig
.
Port
)
err
:=
metrics
.
ListenAndServe
(
ctx
,
i
.
metricsRegistry
,
i
.
metricsConfig
.
Host
,
i
.
metricsConfig
.
Port
)
err
:=
metrics
.
ListenAndServe
(
ctx
,
i
.
metricsRegistry
,
i
.
metricsConfig
.
Host
,
i
.
metricsConfig
.
Port
)
...
@@ -103,7 +135,7 @@ func (i *Indexer) startMetricsServer(ctx context.Context) error {
...
@@ -103,7 +135,7 @@ func (i *Indexer) startMetricsServer(ctx context.Context) error {
// Start starts the indexing service on L1 and L2 chains
// Start starts the indexing service on L1 and L2 chains
func
(
i
*
Indexer
)
Run
(
ctx
context
.
Context
)
error
{
func
(
i
*
Indexer
)
Run
(
ctx
context
.
Context
)
error
{
var
wg
sync
.
WaitGroup
var
wg
sync
.
WaitGroup
errCh
:=
make
(
chan
error
,
4
)
errCh
:=
make
(
chan
error
,
5
)
// if any goroutine halts, we stop the entire indexer
// if any goroutine halts, we stop the entire indexer
processCtx
,
processCancel
:=
context
.
WithCancel
(
ctx
)
processCtx
,
processCancel
:=
context
.
WithCancel
(
ctx
)
...
@@ -130,6 +162,7 @@ func (i *Indexer) Run(ctx context.Context) error {
...
@@ -130,6 +162,7 @@ func (i *Indexer) Run(ctx context.Context) error {
runProcess
(
i
.
L2ETL
.
Start
)
runProcess
(
i
.
L2ETL
.
Start
)
runProcess
(
i
.
BridgeProcessor
.
Start
)
runProcess
(
i
.
BridgeProcessor
.
Start
)
runProcess
(
i
.
startMetricsServer
)
runProcess
(
i
.
startMetricsServer
)
runProcess
(
i
.
startHttpServer
)
wg
.
Wait
()
wg
.
Wait
()
err
:=
<-
errCh
err
:=
<-
errCh
...
...
indexer/indexer.toml
View file @
64361244
...
@@ -28,7 +28,7 @@ user = "db_username"
...
@@ -28,7 +28,7 @@ user = "db_username"
password
=
"db_password"
password
=
"db_password"
name
=
"db_name"
name
=
"db_name"
[
api
]
[
http
]
host
=
"127.0.0.1"
host
=
"127.0.0.1"
port
=
8080
port
=
8080
...
...
op-challenger/README.md
View file @
64361244
...
@@ -7,13 +7,18 @@ games, and validity games. To learn more about dispute games, visit the
...
@@ -7,13 +7,18 @@ games, and validity games. To learn more about dispute games, visit the
## Quickstart
## Quickstart
First, clone this repo. Then, run
`make`
, which will build all required targets.
First, clone this repo. Then run:
Alternatively, run
`make devnet`
to bring up the
[
devnet
](
../ops-bedrock/devnet-up.sh
)
which deploys the
[
mock dispute game contracts
](
./contracts
)
as well as an
`op-challenger`
instance.
Alternatively, you can build the
`op-challenger`
binary locally using the pre-configured
```
shell
[
Makefile
](
./Makefile
)
target by running
`make build`
, and then running
`./op-challenger --help`
cd
op-challenger
make alphabet
```
This creates a local devnet, starts a dispute game using the simple alphabet trace type and runs two op-challenger
instances with differing views of the correct alphabet to play the game.
Alternatively, you can build the
`op-challenger`
binary directly using the pre-configured
[
Makefile
](
./Makefile
)
target by running
`make build`
, and then running
`./bin/op-challenger --help`
to see a list of available options.
to see a list of available options.
## Usage
## Usage
...
@@ -21,6 +26,40 @@ to see a list of available options.
...
@@ -21,6 +26,40 @@ to see a list of available options.
`op-challenger`
is configurable via command line flags and environment variables. The help menu
`op-challenger`
is configurable via command line flags and environment variables. The help menu
shows the available config options and can be accessed by running
`./op-challenger --help`
.
shows the available config options and can be accessed by running
`./op-challenger --help`
.
### Running with Cannon on Local Devnet
To run
`op-challenger`
against the local devnet, first ensure the required components are built and the devnet is running.
From the top level of the repository run:
```
shell
make devnet-clean
make cannon-prestate op-challenger
make devnet-up
```
Then start
`op-challenger`
with:
```
shell
DISPUTE_GAME_FACTORY
=
$(
jq
-r
.DisputeGameFactoryProxy .devnet/addresses.json
)
./op-challenger/bin/op-challenger
\
--trace-type
cannon
\
--l1-eth-rpc
http://localhost:8545
\
--game-factory-address
$DISPUTE_GAME_FACTORY
\
--agree-with-proposed-output
=
true
\
--datadir
temp/challenger-data
\
--cannon-rollup-config
.devnet/rollup.json
\
--cannon-l2-genesis
.devnet/genesis-l2.json
\
--cannon-bin
./cannon/bin/cannon
\
--cannon-server
./op-program/bin/op-program
\
--cannon-prestate
./op-program/bin/prestate.json
\
--cannon-l2
http://localhost:9545
\
--mnemonic
"test test test test test test test test test test test junk"
\
--hd-path
"m/44'/60'/0'/0/8"
\
--num-confirmations
1
```
The mnemonic and hd-path above is a prefunded address on the devnet. The challenger respond to any created games by
posting the correct trace as the counter-claim. The scripts below can then be used to create and interact with games.
## Scripts
## Scripts
The
[
scripts
](
scripts
)
directory contains a collection of scripts to assist with manually creating and playing games.
The
[
scripts
](
scripts
)
directory contains a collection of scripts to assist with manually creating and playing games.
...
...
op-challenger/scripts/alphabet/init_game.sh
View file @
64361244
...
@@ -18,7 +18,7 @@ DEVNET_SPONSOR="ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
...
@@ -18,7 +18,7 @@ DEVNET_SPONSOR="ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
DISPUTE_GAME_FACTORY
=
$(
jq
-r
.DisputeGameFactoryProxy
$MONOREPO_DIR
/.devnet/addresses.json
)
DISPUTE_GAME_FACTORY
=
$(
jq
-r
.DisputeGameFactoryProxy
$MONOREPO_DIR
/.devnet/addresses.json
)
echo
"----------------------------------------------------------------"
echo
"----------------------------------------------------------------"
echo
" Dispute Game Factory at
$DISPUTE_GAME_
PROX
Y
"
echo
" Dispute Game Factory at
$DISPUTE_GAME_
FACTOR
Y
"
echo
"----------------------------------------------------------------"
echo
"----------------------------------------------------------------"
L2_OUTPUT_ORACLE_PROXY
=
$(
jq
-r
.L2OutputOracleProxy
$MONOREPO_DIR
/.devnet/addresses.json
)
L2_OUTPUT_ORACLE_PROXY
=
$(
jq
-r
.L2OutputOracleProxy
$MONOREPO_DIR
/.devnet/addresses.json
)
...
...
op-e2e/deposit_test.go
0 → 100644
View file @
64361244
package
op_e2e
import
(
"context"
"math/big"
"testing"
"time"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/vm"
"github.com/stretchr/testify/require"
)
func
TestMintOnRevertedDeposit
(
t
*
testing
.
T
)
{
InitParallel
(
t
)
cfg
:=
DefaultSystemConfig
(
t
)
sys
,
err
:=
cfg
.
Start
(
t
)
require
.
Nil
(
t
,
err
,
"Error starting up system"
)
defer
sys
.
Close
()
l1Client
:=
sys
.
Clients
[
"l1"
]
l2Verif
:=
sys
.
Clients
[
"verifier"
]
// create signer
aliceKey
:=
cfg
.
Secrets
.
Alice
opts
,
err
:=
bind
.
NewKeyedTransactorWithChainID
(
aliceKey
,
cfg
.
L1ChainIDBig
())
require
.
Nil
(
t
,
err
)
fromAddr
:=
opts
.
From
ctx
,
cancel
:=
context
.
WithTimeout
(
context
.
Background
(),
1
*
time
.
Second
)
startBalance
,
err
:=
l2Verif
.
BalanceAt
(
ctx
,
fromAddr
,
nil
)
cancel
()
require
.
Nil
(
t
,
err
)
ctx
,
cancel
=
context
.
WithTimeout
(
context
.
Background
(),
1
*
time
.
Second
)
startNonce
,
err
:=
l2Verif
.
NonceAt
(
ctx
,
fromAddr
,
nil
)
require
.
NoError
(
t
,
err
)
cancel
()
toAddr
:=
common
.
Address
{
0xff
,
0xff
}
mintAmount
:=
big
.
NewInt
(
9
_000_000
)
opts
.
Value
=
mintAmount
SendDepositTx
(
t
,
cfg
,
l1Client
,
l2Verif
,
opts
,
func
(
l2Opts
*
DepositTxOpts
)
{
l2Opts
.
ToAddr
=
toAddr
// trigger a revert by transferring more than we have available
l2Opts
.
Value
=
new
(
big
.
Int
)
.
Mul
(
common
.
Big2
,
startBalance
)
l2Opts
.
ExpectedStatus
=
types
.
ReceiptStatusFailed
})
// Confirm balance
ctx
,
cancel
=
context
.
WithTimeout
(
context
.
Background
(),
1
*
time
.
Second
)
endBalance
,
err
:=
l2Verif
.
BalanceAt
(
ctx
,
fromAddr
,
nil
)
cancel
()
require
.
Nil
(
t
,
err
)
ctx
,
cancel
=
context
.
WithTimeout
(
context
.
Background
(),
1
*
time
.
Second
)
toAddrBalance
,
err
:=
l2Verif
.
BalanceAt
(
ctx
,
toAddr
,
nil
)
require
.
NoError
(
t
,
err
)
cancel
()
diff
:=
new
(
big
.
Int
)
diff
=
diff
.
Sub
(
endBalance
,
startBalance
)
require
.
Equal
(
t
,
mintAmount
,
diff
,
"Did not get expected balance change"
)
require
.
Equal
(
t
,
common
.
Big0
.
Int64
(),
toAddrBalance
.
Int64
(),
"The recipient account balance should be zero"
)
ctx
,
cancel
=
context
.
WithTimeout
(
context
.
Background
(),
1
*
time
.
Second
)
endNonce
,
err
:=
l2Verif
.
NonceAt
(
ctx
,
fromAddr
,
nil
)
require
.
NoError
(
t
,
err
)
cancel
()
require
.
Equal
(
t
,
startNonce
+
1
,
endNonce
,
"Nonce of deposit sender should increment on L2, even if the deposit fails"
)
}
func
TestDepositTxCreateContract
(
t
*
testing
.
T
)
{
InitParallel
(
t
)
cfg
:=
DefaultSystemConfig
(
t
)
delete
(
cfg
.
Nodes
,
"verifier"
)
sys
,
err
:=
cfg
.
Start
(
t
)
require
.
Nil
(
t
,
err
,
"Error starting up system"
)
defer
sys
.
Close
()
l1Client
:=
sys
.
Clients
[
"l1"
]
l2Client
:=
sys
.
Clients
[
"sequencer"
]
opts
,
err
:=
bind
.
NewKeyedTransactorWithChainID
(
cfg
.
Secrets
.
Alice
,
cfg
.
L1ChainIDBig
())
require
.
Nil
(
t
,
err
)
// Simple constructor that is prefixed to the actual contract code
// Results in the contract code being returned as the code for the new contract
deployPrefixSize
:=
byte
(
16
)
deployPrefix
:=
[]
byte
{
// Copy input data after this prefix into memory starting at address 0x00
// CODECOPY arg size
byte
(
vm
.
PUSH1
),
deployPrefixSize
,
byte
(
vm
.
CODESIZE
),
byte
(
vm
.
SUB
),
// CODECOPY arg offset
byte
(
vm
.
PUSH1
),
deployPrefixSize
,
// CODECOPY arg destOffset
byte
(
vm
.
PUSH1
),
0x00
,
byte
(
vm
.
CODECOPY
),
// Return code from memory
// RETURN arg size
byte
(
vm
.
PUSH1
),
deployPrefixSize
,
byte
(
vm
.
CODESIZE
),
byte
(
vm
.
SUB
),
// RETURN arg offset
byte
(
vm
.
PUSH1
),
0x00
,
byte
(
vm
.
RETURN
),
}
// Stores the first word from call data code to storage slot 0
sstoreContract
:=
[]
byte
{
// Load first word from call data
byte
(
vm
.
PUSH1
),
0x00
,
byte
(
vm
.
CALLDATALOAD
),
// Store it to slot 0
byte
(
vm
.
PUSH1
),
0x00
,
byte
(
vm
.
SSTORE
),
}
deployData
:=
append
(
deployPrefix
,
sstoreContract
...
)
l2Receipt
:=
SendDepositTx
(
t
,
cfg
,
l1Client
,
l2Client
,
opts
,
func
(
l2Opts
*
DepositTxOpts
)
{
l2Opts
.
Data
=
deployData
l2Opts
.
Value
=
common
.
Big0
l2Opts
.
IsCreation
=
true
l2Opts
.
ToAddr
=
common
.
Address
{}
l2Opts
.
GasLimit
=
1
_000_000
})
require
.
NotEqual
(
t
,
common
.
Address
{},
l2Receipt
.
ContractAddress
,
"should not have zero address"
)
code
,
err
:=
l2Client
.
CodeAt
(
context
.
Background
(),
l2Receipt
.
ContractAddress
,
nil
)
require
.
NoError
(
t
,
err
,
"get deployed contract code"
)
require
.
Equal
(
t
,
sstoreContract
,
code
,
"should have deployed correct contract code"
)
}
op-e2e/e2eutils/geth/peers.go
0 → 100644
View file @
64361244
package
geth
import
(
"context"
"testing"
"time"
"github.com/ethereum-optimism/optimism/op-e2e/e2eutils/wait"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/eth/ethconfig"
"github.com/ethereum/go-ethereum/ethclient"
"github.com/ethereum/go-ethereum/node"
"github.com/ethereum/go-ethereum/p2p"
"github.com/stretchr/testify/require"
)
// ConnectP2P creates a p2p peer connection between node1 and node2.
func
ConnectP2P
(
t
*
testing
.
T
,
node1
*
ethclient
.
Client
,
node2
*
ethclient
.
Client
)
{
var
targetInfo
p2p
.
NodeInfo
require
.
NoError
(
t
,
node2
.
Client
()
.
Call
(
&
targetInfo
,
"admin_nodeInfo"
),
"get node info"
)
var
peerAdded
bool
require
.
NoError
(
t
,
node1
.
Client
()
.
Call
(
&
peerAdded
,
"admin_addPeer"
,
targetInfo
.
Enode
),
"add peer"
)
require
.
True
(
t
,
peerAdded
,
"should have added peer successfully"
)
ctx
,
cancel
:=
context
.
WithTimeout
(
context
.
Background
(),
30
*
time
.
Second
)
defer
cancel
()
err
:=
wait
.
For
(
ctx
,
time
.
Second
,
func
()
(
bool
,
error
)
{
var
peerCount
hexutil
.
Uint64
if
err
:=
node1
.
Client
()
.
Call
(
&
peerCount
,
"net_peerCount"
);
err
!=
nil
{
return
false
,
err
}
t
.
Logf
(
"Peer count %v"
,
uint64
(
peerCount
))
return
peerCount
>=
hexutil
.
Uint64
(
1
),
nil
})
require
.
NoError
(
t
,
err
,
"wait for a peer to be connected"
)
}
func
WithP2P
()
func
(
ethCfg
*
ethconfig
.
Config
,
nodeCfg
*
node
.
Config
)
error
{
return
func
(
ethCfg
*
ethconfig
.
Config
,
nodeCfg
*
node
.
Config
)
error
{
ethCfg
.
RollupDisableTxPoolGossip
=
false
nodeCfg
.
P2P
=
p2p
.
Config
{
NoDiscovery
:
true
,
ListenAddr
:
"127.0.0.1:0"
,
MaxPeers
:
10
,
}
return
nil
}
}
op-e2e/l2_gossip_test.go
0 → 100644
View file @
64361244
package
op_e2e
import
(
"testing"
"github.com/ethereum-optimism/optimism/op-e2e/e2eutils/geth"
"github.com/ethereum/go-ethereum/common"
"github.com/stretchr/testify/require"
)
func
TestTxGossip
(
t
*
testing
.
T
)
{
InitParallel
(
t
)
cfg
:=
DefaultSystemConfig
(
t
)
gethOpts
:=
[]
GethOption
{
geth
.
WithP2P
(),
}
cfg
.
GethOptions
[
"sequencer"
]
=
gethOpts
cfg
.
GethOptions
[
"verifier"
]
=
gethOpts
sys
,
err
:=
cfg
.
Start
(
t
)
require
.
NoError
(
t
,
err
,
"Start system"
)
seqClient
:=
sys
.
Clients
[
"sequencer"
]
verifClient
:=
sys
.
Clients
[
"verifier"
]
geth
.
ConnectP2P
(
t
,
seqClient
,
verifClient
)
// Send a transaction to the verifier and it should be gossiped to the sequencer and included in a block.
SendL2Tx
(
t
,
cfg
,
verifClient
,
cfg
.
Secrets
.
Alice
,
func
(
opts
*
TxOpts
)
{
opts
.
ToAddr
=
&
common
.
Address
{
0xaa
}
opts
.
Value
=
common
.
Big1
opts
.
VerifyOnClients
(
seqClient
,
verifClient
)
})
}
op-e2e/setup.go
View file @
64361244
...
@@ -84,7 +84,7 @@ func DefaultSystemConfig(t *testing.T) SystemConfig {
...
@@ -84,7 +84,7 @@ func DefaultSystemConfig(t *testing.T) SystemConfig {
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
deployConfig
:=
config
.
DeployConfig
.
Copy
()
deployConfig
:=
config
.
DeployConfig
.
Copy
()
deployConfig
.
L1GenesisBlockTimestamp
=
hexutil
.
Uint64
(
time
.
Now
()
.
Unix
())
deployConfig
.
L1GenesisBlockTimestamp
=
hexutil
.
Uint64
(
time
.
Now
()
.
Unix
())
require
.
NoError
(
t
,
deployConfig
.
Check
())
require
.
NoError
(
t
,
deployConfig
.
Check
()
,
"Deploy config is invalid, do you need to run make devnet-allocs?"
)
l1Deployments
:=
config
.
L1Deployments
.
Copy
()
l1Deployments
:=
config
.
L1Deployments
.
Copy
()
require
.
NoError
(
t
,
l1Deployments
.
Check
())
require
.
NoError
(
t
,
l1Deployments
.
Check
())
...
@@ -457,7 +457,7 @@ func (cfg SystemConfig) Start(t *testing.T, _opts ...SystemConfigOption) (*Syste
...
@@ -457,7 +457,7 @@ func (cfg SystemConfig) Start(t *testing.T, _opts ...SystemConfigOption) (*Syste
ethClient
=
gethInst
ethClient
=
gethInst
}
else
{
}
else
{
if
len
(
cfg
.
GethOptions
[
name
])
>
0
{
if
len
(
cfg
.
GethOptions
[
name
])
>
0
{
t
.
Errorf
(
"External L2 nodes do not support configuration through GethOptions"
)
t
.
Skip
(
"External L2 nodes do not support configuration through GethOptions"
)
}
}
ethClient
=
(
&
ExternalRunner
{
ethClient
=
(
&
ExternalRunner
{
Name
:
name
,
Name
:
name
,
...
...
op-e2e/system_test.go
View file @
64361244
...
@@ -11,7 +11,6 @@ import (
...
@@ -11,7 +11,6 @@ import (
"github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/accounts/keystore"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/types"
...
@@ -337,67 +336,6 @@ func TestFinalize(t *testing.T) {
...
@@ -337,67 +336,6 @@ func TestFinalize(t *testing.T) {
require
.
NotZerof
(
t
,
l2Finalized
.
NumberU64
(),
"must have finalized L2 block"
)
require
.
NotZerof
(
t
,
l2Finalized
.
NumberU64
(),
"must have finalized L2 block"
)
}
}
func
TestMintOnRevertedDeposit
(
t
*
testing
.
T
)
{
InitParallel
(
t
)
cfg
:=
DefaultSystemConfig
(
t
)
sys
,
err
:=
cfg
.
Start
(
t
)
require
.
Nil
(
t
,
err
,
"Error starting up system"
)
defer
sys
.
Close
()
l1Client
:=
sys
.
Clients
[
"l1"
]
l2Verif
:=
sys
.
Clients
[
"verifier"
]
l1Node
:=
sys
.
EthInstances
[
"l1"
]
.
(
*
GethInstance
)
.
Node
// create signer
ks
:=
l1Node
.
AccountManager
()
.
Backends
(
keystore
.
KeyStoreType
)[
0
]
.
(
*
keystore
.
KeyStore
)
opts
,
err
:=
bind
.
NewKeyStoreTransactorWithChainID
(
ks
,
ks
.
Accounts
()[
0
],
cfg
.
L1ChainIDBig
())
require
.
Nil
(
t
,
err
)
fromAddr
:=
opts
.
From
ctx
,
cancel
:=
context
.
WithTimeout
(
context
.
Background
(),
1
*
time
.
Second
)
startBalance
,
err
:=
l2Verif
.
BalanceAt
(
ctx
,
fromAddr
,
nil
)
cancel
()
require
.
Nil
(
t
,
err
)
ctx
,
cancel
=
context
.
WithTimeout
(
context
.
Background
(),
1
*
time
.
Second
)
startNonce
,
err
:=
l2Verif
.
NonceAt
(
ctx
,
fromAddr
,
nil
)
require
.
NoError
(
t
,
err
)
cancel
()
toAddr
:=
common
.
Address
{
0xff
,
0xff
}
mintAmount
:=
big
.
NewInt
(
9
_000_000
)
opts
.
Value
=
mintAmount
SendDepositTx
(
t
,
cfg
,
l1Client
,
l2Verif
,
opts
,
func
(
l2Opts
*
DepositTxOpts
)
{
l2Opts
.
ToAddr
=
toAddr
// trigger a revert by transferring more than we have available
l2Opts
.
Value
=
new
(
big
.
Int
)
.
Mul
(
common
.
Big2
,
startBalance
)
l2Opts
.
ExpectedStatus
=
types
.
ReceiptStatusFailed
})
// Confirm balance
ctx
,
cancel
=
context
.
WithTimeout
(
context
.
Background
(),
1
*
time
.
Second
)
endBalance
,
err
:=
l2Verif
.
BalanceAt
(
ctx
,
fromAddr
,
nil
)
cancel
()
require
.
Nil
(
t
,
err
)
ctx
,
cancel
=
context
.
WithTimeout
(
context
.
Background
(),
1
*
time
.
Second
)
toAddrBalance
,
err
:=
l2Verif
.
BalanceAt
(
ctx
,
toAddr
,
nil
)
require
.
NoError
(
t
,
err
)
cancel
()
diff
:=
new
(
big
.
Int
)
diff
=
diff
.
Sub
(
endBalance
,
startBalance
)
require
.
Equal
(
t
,
mintAmount
,
diff
,
"Did not get expected balance change"
)
require
.
Equal
(
t
,
common
.
Big0
.
Int64
(),
toAddrBalance
.
Int64
(),
"The recipient account balance should be zero"
)
ctx
,
cancel
=
context
.
WithTimeout
(
context
.
Background
(),
1
*
time
.
Second
)
endNonce
,
err
:=
l2Verif
.
NonceAt
(
ctx
,
fromAddr
,
nil
)
require
.
NoError
(
t
,
err
)
cancel
()
require
.
Equal
(
t
,
startNonce
+
1
,
endNonce
,
"Nonce of deposit sender should increment on L2, even if the deposit fails"
)
}
func
TestMissingBatchE2E
(
t
*
testing
.
T
)
{
func
TestMissingBatchE2E
(
t
*
testing
.
T
)
{
InitParallel
(
t
)
InitParallel
(
t
)
// Note this test zeroes the balance of the batch-submitter to make the batches unable to go into L1.
// Note this test zeroes the balance of the batch-submitter to make the batches unable to go into L1.
...
...
op-e2e/tx_helper.go
View file @
64361244
...
@@ -21,7 +21,8 @@ import (
...
@@ -21,7 +21,8 @@ import (
// The L1 transaction, including sender, is configured by the l1Opts param.
// The L1 transaction, including sender, is configured by the l1Opts param.
// The L2 transaction options can be configured by modifying the DepositTxOps value supplied to applyL2Opts
// The L2 transaction options can be configured by modifying the DepositTxOps value supplied to applyL2Opts
// Will verify that the transaction is included with the expected status on L1 and L2
// Will verify that the transaction is included with the expected status on L1 and L2
func
SendDepositTx
(
t
*
testing
.
T
,
cfg
SystemConfig
,
l1Client
*
ethclient
.
Client
,
l2Client
*
ethclient
.
Client
,
l1Opts
*
bind
.
TransactOpts
,
applyL2Opts
DepositTxOptsFn
)
{
// Returns the receipt of the L2 transaction
func
SendDepositTx
(
t
*
testing
.
T
,
cfg
SystemConfig
,
l1Client
*
ethclient
.
Client
,
l2Client
*
ethclient
.
Client
,
l1Opts
*
bind
.
TransactOpts
,
applyL2Opts
DepositTxOptsFn
)
*
types
.
Receipt
{
l2Opts
:=
defaultDepositTxOpts
(
l1Opts
)
l2Opts
:=
defaultDepositTxOpts
(
l1Opts
)
applyL2Opts
(
l2Opts
)
applyL2Opts
(
l2Opts
)
...
@@ -38,16 +39,17 @@ func SendDepositTx(t *testing.T, cfg SystemConfig, l1Client *ethclient.Client, l
...
@@ -38,16 +39,17 @@ func SendDepositTx(t *testing.T, cfg SystemConfig, l1Client *ethclient.Client, l
require
.
Nil
(
t
,
err
,
"with deposit tx"
)
require
.
Nil
(
t
,
err
,
"with deposit tx"
)
// Wait for transaction on L1
// Wait for transaction on L1
r
eceipt
,
err
:=
waitForTransaction
(
tx
.
Hash
(),
l1Client
,
10
*
time
.
Duration
(
cfg
.
DeployConfig
.
L1BlockTime
)
*
time
.
Second
)
l1R
eceipt
,
err
:=
waitForTransaction
(
tx
.
Hash
(),
l1Client
,
10
*
time
.
Duration
(
cfg
.
DeployConfig
.
L1BlockTime
)
*
time
.
Second
)
require
.
Nil
(
t
,
err
,
"Waiting for deposit tx on L1"
)
require
.
Nil
(
t
,
err
,
"Waiting for deposit tx on L1"
)
// Wait for transaction to be included on L2
// Wait for transaction to be included on L2
reconstructedDep
,
err
:=
derive
.
UnmarshalDepositLogEvent
(
r
eceipt
.
Logs
[
0
])
reconstructedDep
,
err
:=
derive
.
UnmarshalDepositLogEvent
(
l1R
eceipt
.
Logs
[
0
])
require
.
NoError
(
t
,
err
,
"Could not reconstruct L2 Deposit"
)
require
.
NoError
(
t
,
err
,
"Could not reconstruct L2 Deposit"
)
tx
=
types
.
NewTx
(
reconstructedDep
)
tx
=
types
.
NewTx
(
reconstructedDep
)
receipt
,
err
=
waitForTransaction
(
tx
.
Hash
(),
l2Client
,
10
*
time
.
Duration
(
cfg
.
DeployConfig
.
L2BlockTime
)
*
time
.
Second
)
l2Receipt
,
err
:
=
waitForTransaction
(
tx
.
Hash
(),
l2Client
,
10
*
time
.
Duration
(
cfg
.
DeployConfig
.
L2BlockTime
)
*
time
.
Second
)
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
require
.
Equal
(
t
,
l2Opts
.
ExpectedStatus
,
receipt
.
Status
,
"l2 transaction status"
)
require
.
Equal
(
t
,
l2Opts
.
ExpectedStatus
,
l2Receipt
.
Status
,
"l2 transaction status"
)
return
l2Receipt
}
}
type
DepositTxOptsFn
func
(
l2Opts
*
DepositTxOpts
)
type
DepositTxOptsFn
func
(
l2Opts
*
DepositTxOpts
)
...
@@ -91,16 +93,16 @@ func SendL2Tx(t *testing.T, cfg SystemConfig, l2Client *ethclient.Client, privKe
...
@@ -91,16 +93,16 @@ func SendL2Tx(t *testing.T, cfg SystemConfig, l2Client *ethclient.Client, privKe
ctx
,
cancel
:=
context
.
WithTimeout
(
context
.
Background
(),
30
*
time
.
Second
)
ctx
,
cancel
:=
context
.
WithTimeout
(
context
.
Background
(),
30
*
time
.
Second
)
defer
cancel
()
defer
cancel
()
err
:=
l2Client
.
SendTransaction
(
ctx
,
tx
)
err
:=
l2Client
.
SendTransaction
(
ctx
,
tx
)
require
.
N
il
(
t
,
err
,
"Sending L2 tx"
)
require
.
N
oError
(
t
,
err
,
"Sending L2 tx"
)
receipt
,
err
:=
waitForTransaction
(
tx
.
Hash
(),
l2Client
,
10
*
time
.
Duration
(
cfg
.
DeployConfig
.
L2BlockTime
)
*
time
.
Second
)
receipt
,
err
:=
waitForTransaction
(
tx
.
Hash
(),
l2Client
,
10
*
time
.
Duration
(
cfg
.
DeployConfig
.
L2BlockTime
)
*
time
.
Second
)
require
.
N
il
(
t
,
err
,
"Waiting for L2 tx"
)
require
.
N
oError
(
t
,
err
,
"Waiting for L2 tx"
)
require
.
Equal
(
t
,
opts
.
ExpectedStatus
,
receipt
.
Status
,
"TX should have expected status"
)
require
.
Equal
(
t
,
opts
.
ExpectedStatus
,
receipt
.
Status
,
"TX should have expected status"
)
for
i
,
client
:=
range
opts
.
VerifyClients
{
for
i
,
client
:=
range
opts
.
VerifyClients
{
t
.
Logf
(
"Waiting for tx %v on verification client %d"
,
tx
.
Hash
(),
i
)
t
.
Logf
(
"Waiting for tx %v on verification client %d"
,
tx
.
Hash
(),
i
)
receiptVerif
,
err
:=
waitForTransaction
(
tx
.
Hash
(),
client
,
10
*
time
.
Duration
(
cfg
.
DeployConfig
.
L2BlockTime
)
*
time
.
Second
)
receiptVerif
,
err
:=
waitForTransaction
(
tx
.
Hash
(),
client
,
10
*
time
.
Duration
(
cfg
.
DeployConfig
.
L2BlockTime
)
*
time
.
Second
)
require
.
N
il
f
(
t
,
err
,
"Waiting for L2 tx on verification client %d"
,
i
)
require
.
N
oError
f
(
t
,
err
,
"Waiting for L2 tx on verification client %d"
,
i
)
require
.
Equalf
(
t
,
receipt
,
receiptVerif
,
"Receipts should be the same on sequencer and verification client %d"
,
i
)
require
.
Equalf
(
t
,
receipt
,
receiptVerif
,
"Receipts should be the same on sequencer and verification client %d"
,
i
)
}
}
return
receipt
return
receipt
...
...
op-node/cmd/stateviz/main.go
View file @
64361244
...
@@ -18,8 +18,8 @@ import (
...
@@ -18,8 +18,8 @@ import (
"sync"
"sync"
"time"
"time"
ophttp
"github.com/ethereum-optimism/optimism/op-node/http"
"github.com/ethereum-optimism/optimism/op-service/eth"
"github.com/ethereum-optimism/optimism/op-service/eth"
ophttp
"github.com/ethereum-optimism/optimism/op-service/httputil"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/log"
)
)
...
...
op-node/flags/p2p_flags.go
View file @
64361244
...
@@ -156,7 +156,6 @@ var (
...
@@ -156,7 +156,6 @@ var (
Name
:
"p2p.netrestrict"
,
Name
:
"p2p.netrestrict"
,
Usage
:
"Comma-separated list of CIDR masks. P2P will only try to connect on these networks"
,
Usage
:
"Comma-separated list of CIDR masks. P2P will only try to connect on these networks"
,
Required
:
false
,
Required
:
false
,
Value
:
""
,
EnvVars
:
p2pEnv
(
"NETRESTRICT"
),
EnvVars
:
p2pEnv
(
"NETRESTRICT"
),
}
}
HostMux
=
&
cli
.
StringFlag
{
HostMux
=
&
cli
.
StringFlag
{
...
...
op-node/metrics/metrics.go
View file @
64361244
...
@@ -10,8 +10,8 @@ import (
...
@@ -10,8 +10,8 @@ import (
"strconv"
"strconv"
"time"
"time"
ophttp
"github.com/ethereum-optimism/optimism/op-node/http"
"github.com/ethereum-optimism/optimism/op-node/p2p/store"
"github.com/ethereum-optimism/optimism/op-node/p2p/store"
ophttp
"github.com/ethereum-optimism/optimism/op-service/httputil"
"github.com/ethereum-optimism/optimism/op-service/metrics"
"github.com/ethereum-optimism/optimism/op-service/metrics"
pb
"github.com/libp2p/go-libp2p-pubsub/pb"
pb
"github.com/libp2p/go-libp2p-pubsub/pb"
...
...
op-node/node/server.go
View file @
64361244
...
@@ -7,7 +7,7 @@ import (
...
@@ -7,7 +7,7 @@ import (
"net/http"
"net/http"
"strconv"
"strconv"
ophttp
"github.com/ethereum-optimism/optimism/op-
node/http
"
ophttp
"github.com/ethereum-optimism/optimism/op-
service/httputil
"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/node"
"github.com/ethereum/go-ethereum/node"
"github.com/ethereum/go-ethereum/rpc"
"github.com/ethereum/go-ethereum/rpc"
...
...
op-node/p2p/cli/load_config.go
View file @
64361244
...
@@ -194,12 +194,13 @@ func loadDiscoveryOpts(conf *p2p.Config, ctx *cli.Context) error {
...
@@ -194,12 +194,13 @@ func loadDiscoveryOpts(conf *p2p.Config, ctx *cli.Context) error {
conf
.
Bootnodes
=
p2p
.
DefaultBootnodes
conf
.
Bootnodes
=
p2p
.
DefaultBootnodes
}
}
if
ctx
.
IsSet
(
flags
.
NetRestrict
.
Name
)
{
netRestrict
,
err
:=
netutil
.
ParseNetlist
(
ctx
.
String
(
flags
.
NetRestrict
.
Name
))
netRestrict
,
err
:=
netutil
.
ParseNetlist
(
ctx
.
String
(
flags
.
NetRestrict
.
Name
))
if
err
!=
nil
{
if
err
!=
nil
{
return
fmt
.
Errorf
(
"failed to parse net list: %w"
,
err
)
return
fmt
.
Errorf
(
"failed to parse net list: %w"
,
err
)
}
}
conf
.
NetRestrict
=
netRestrict
conf
.
NetRestrict
=
netRestrict
}
return
nil
return
nil
}
}
...
...
op-program/host/kvstore/disk.go
View file @
64361244
...
@@ -37,7 +37,7 @@ func (d *DiskKV) pathKey(k common.Hash) string {
...
@@ -37,7 +37,7 @@ func (d *DiskKV) pathKey(k common.Hash) string {
func
(
d
*
DiskKV
)
Put
(
k
common
.
Hash
,
v
[]
byte
)
error
{
func
(
d
*
DiskKV
)
Put
(
k
common
.
Hash
,
v
[]
byte
)
error
{
d
.
Lock
()
d
.
Lock
()
defer
d
.
Unlock
()
defer
d
.
Unlock
()
f
,
err
:=
o
s
.
CreateTemp
(
d
.
path
,
k
.
String
()
+
".txt.*"
)
f
,
err
:=
o
penTempFile
(
d
.
path
,
k
.
String
()
+
".txt.*"
)
if
err
!=
nil
{
if
err
!=
nil
{
return
fmt
.
Errorf
(
"failed to open temp file for pre-image %s: %w"
,
k
,
err
)
return
fmt
.
Errorf
(
"failed to open temp file for pre-image %s: %w"
,
k
,
err
)
}
}
...
@@ -57,6 +57,21 @@ func (d *DiskKV) Put(k common.Hash, v []byte) error {
...
@@ -57,6 +57,21 @@ func (d *DiskKV) Put(k common.Hash, v []byte) error {
return
nil
return
nil
}
}
func
openTempFile
(
dir
string
,
nameTemplate
string
)
(
*
os
.
File
,
error
)
{
f
,
err
:=
os
.
CreateTemp
(
dir
,
nameTemplate
)
// Directory has been deleted out from underneath us. Recreate it.
if
errors
.
Is
(
err
,
os
.
ErrNotExist
)
{
if
mkdirErr
:=
os
.
MkdirAll
(
dir
,
0777
);
mkdirErr
!=
nil
{
return
nil
,
errors
.
Join
(
fmt
.
Errorf
(
"failed to create directory %v: %w"
,
dir
,
mkdirErr
),
err
)
}
f
,
err
=
os
.
CreateTemp
(
dir
,
nameTemplate
)
}
if
err
!=
nil
{
return
nil
,
err
}
return
f
,
nil
}
func
(
d
*
DiskKV
)
Get
(
k
common
.
Hash
)
([]
byte
,
error
)
{
func
(
d
*
DiskKV
)
Get
(
k
common
.
Hash
)
([]
byte
,
error
)
{
d
.
RLock
()
d
.
RLock
()
defer
d
.
RUnlock
()
defer
d
.
RUnlock
()
...
...
op-program/host/kvstore/disk_test.go
View file @
64361244
package
kvstore
package
kvstore
import
"testing"
import
(
"path/filepath"
"testing"
"github.com/ethereum/go-ethereum/crypto"
"github.com/stretchr/testify/require"
)
func
TestDiskKV
(
t
*
testing
.
T
)
{
func
TestDiskKV
(
t
*
testing
.
T
)
{
tmp
:=
t
.
TempDir
()
// automatically removed by testing cleanup
tmp
:=
t
.
TempDir
()
// automatically removed by testing cleanup
kv
:=
NewDiskKV
(
tmp
)
kv
:=
NewDiskKV
(
tmp
)
kvTest
(
t
,
kv
)
kvTest
(
t
,
kv
)
}
}
func
TestCreateMissingDirectory
(
t
*
testing
.
T
)
{
tmp
:=
t
.
TempDir
()
dir
:=
filepath
.
Join
(
tmp
,
"data"
)
kv
:=
NewDiskKV
(
dir
)
val
:=
[]
byte
{
1
,
2
,
3
,
4
}
key
:=
crypto
.
Keccak256Hash
(
val
)
require
.
NoError
(
t
,
kv
.
Put
(
key
,
val
))
}
op-
node/http
/http.go
→
op-
service/httputil
/http.go
View file @
64361244
package
http
package
http
util
import
(
import
(
"net/http"
"net/http"
...
...
op-service/httputil/server.go
View file @
64361244
...
@@ -3,9 +3,7 @@ package httputil
...
@@ -3,9 +3,7 @@ package httputil
import
(
import
(
"context"
"context"
"errors"
"errors"
"fmt"
"net/http"
"net/http"
"time"
)
)
func
ListenAndServeContext
(
ctx
context
.
Context
,
server
*
http
.
Server
)
error
{
func
ListenAndServeContext
(
ctx
context
.
Context
,
server
*
http
.
Server
)
error
{
...
@@ -14,15 +12,6 @@ func ListenAndServeContext(ctx context.Context, server *http.Server) error {
...
@@ -14,15 +12,6 @@ func ListenAndServeContext(ctx context.Context, server *http.Server) error {
errCh
<-
server
.
ListenAndServe
()
errCh
<-
server
.
ListenAndServe
()
}()
}()
// verify that the server comes up
tick
:=
time
.
NewTimer
(
10
*
time
.
Millisecond
)
select
{
case
err
:=
<-
errCh
:
return
fmt
.
Errorf
(
"http server failed: %w"
,
err
)
case
<-
tick
.
C
:
break
}
select
{
select
{
case
err
:=
<-
errCh
:
case
err
:=
<-
errCh
:
if
errors
.
Is
(
err
,
http
.
ErrServerClosed
)
{
if
errors
.
Is
(
err
,
http
.
ErrServerClosed
)
{
...
...
specs/challenger.md
View file @
64361244
...
@@ -73,7 +73,7 @@ to each of the different game types. For specification of dispute game types, se
...
@@ -73,7 +73,7 @@ to each of the different game types. For specification of dispute game types, se
created by the
`DisputeGameFactory`
is equal to the output root of their
`rollup-node`
at the game's
`l2BlockNumber`
.
created by the
`DisputeGameFactory`
is equal to the output root of their
`rollup-node`
at the game's
`l2BlockNumber`
.
-
If it is, the Challenger should sign the
[
EIP-712 typeHash
](
./dispute-game.md
)
of the struct containing the
-
If it is, the Challenger should sign the
[
EIP-712 typeHash
](
./dispute-game.md
)
of the struct containing the
`AttestationDisputeGame`
's
`rootClaim`
and
`l2BlockNumber`
. The Challenger should then submit the abi-encoded
`AttestationDisputeGame`
's
`rootClaim`
and
`l2BlockNumber`
. The Challenger should then submit the abi-encoded
signature to the
`AttetationDisputeGame`
's
`challenge`
function.
signature to the
`Atte
s
tationDisputeGame`
's
`challenge`
function.
-
If it is not, the Challenger should do nothing in support of this dispute game.
-
If it is not, the Challenger should do nothing in support of this dispute game.
!
[
Attestation `DisputeGameCreated` Diagram
](
./assets/challenger_attestation_dispute_game_created.png
)
!
[
Attestation `DisputeGameCreated` Diagram
](
./assets/challenger_attestation_dispute_game_created.png
)
...
...
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