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
b752b9e8
Commit
b752b9e8
authored
Sep 14, 2023
by
Andreas Bigger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes
parent
2ebc5d8c
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
51 additions
and
9 deletions
+51
-9
main_test.go
op-challenger/cmd/main_test.go
+20
-0
service.go
op-challenger/game/service.go
+7
-6
rpc.go
op-node/client/rpc.go
+9
-3
dial.go
op-service/client/dial.go
+15
-0
No files found.
op-challenger/cmd/main_test.go
View file @
b752b9e8
...
@@ -169,6 +169,26 @@ func TestMaxConcurrency(t *testing.T) {
...
@@ -169,6 +169,26 @@ func TestMaxConcurrency(t *testing.T) {
})
})
}
}
func
TestPollInterval
(
t
*
testing
.
T
)
{
t
.
Run
(
"UsesDefault"
,
func
(
t
*
testing
.
T
)
{
cfg
:=
configForArgs
(
t
,
addRequiredArgs
(
config
.
TraceTypeCannon
))
require
.
Equal
(
t
,
config
.
DefaultPollInterval
,
cfg
.
PollInterval
)
})
t
.
Run
(
"Valid"
,
func
(
t
*
testing
.
T
)
{
expected
:=
100
*
time
.
Second
cfg
:=
configForArgs
(
t
,
addRequiredArgs
(
config
.
TraceTypeAlphabet
,
"--http-poll-interval"
,
"100s"
))
require
.
Equal
(
t
,
expected
,
cfg
.
PollInterval
)
})
t
.
Run
(
"Invalid"
,
func
(
t
*
testing
.
T
)
{
verifyArgsInvalid
(
t
,
"invalid value
\"
abc
\"
for flag -http-poll-interval"
,
addRequiredArgs
(
config
.
TraceTypeAlphabet
,
"--http-poll-interval"
,
"abc"
))
})
}
func
TestCannonBin
(
t
*
testing
.
T
)
{
func
TestCannonBin
(
t
*
testing
.
T
)
{
t
.
Run
(
"NotRequiredForAlphabetTrace"
,
func
(
t
*
testing
.
T
)
{
t
.
Run
(
"NotRequiredForAlphabetTrace"
,
func
(
t
*
testing
.
T
)
{
configForArgs
(
t
,
addRequiredArgsExcept
(
config
.
TraceTypeAlphabet
,
"--cannon-bin"
))
configForArgs
(
t
,
addRequiredArgsExcept
(
config
.
TraceTypeAlphabet
,
"--cannon-bin"
))
...
...
op-challenger/game/service.go
View file @
b752b9e8
...
@@ -3,7 +3,6 @@ package game
...
@@ -3,7 +3,6 @@ package game
import
(
import
(
"context"
"context"
"fmt"
"fmt"
"regexp"
"github.com/ethereum-optimism/optimism/op-bindings/bindings"
"github.com/ethereum-optimism/optimism/op-bindings/bindings"
"github.com/ethereum-optimism/optimism/op-challenger/config"
"github.com/ethereum-optimism/optimism/op-challenger/config"
...
@@ -17,6 +16,7 @@ import (
...
@@ -17,6 +16,7 @@ import (
oppprof
"github.com/ethereum-optimism/optimism/op-service/pprof"
oppprof
"github.com/ethereum-optimism/optimism/op-service/pprof"
"github.com/ethereum-optimism/optimism/op-service/txmgr"
"github.com/ethereum-optimism/optimism/op-service/txmgr"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/ethclient"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/log"
)
)
...
@@ -36,10 +36,11 @@ func NewService(ctx context.Context, logger log.Logger, cfg *config.Config) (*Se
...
@@ -36,10 +36,11 @@ func NewService(ctx context.Context, logger log.Logger, cfg *config.Config) (*Se
return
nil
,
fmt
.
Errorf
(
"failed to create the transaction manager: %w"
,
err
)
return
nil
,
fmt
.
Errorf
(
"failed to create the transaction manager: %w"
,
err
)
}
}
l1Client
,
err
:=
client
.
DialEth
ClientWithTimeout
(
client
.
DefaultDialTimeout
,
logger
,
cfg
.
L1EthRpc
)
rpcClient
,
err
:=
client
.
DialRPC
ClientWithTimeout
(
client
.
DefaultDialTimeout
,
logger
,
cfg
.
L1EthRpc
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"failed to dial L1: %w"
,
err
)
return
nil
,
fmt
.
Errorf
(
"failed to dial L1: %w"
,
err
)
}
}
l1Client
:=
ethclient
.
NewClient
(
rpcClient
)
pprofConfig
:=
cfg
.
PprofConfig
pprofConfig
:=
cfg
.
PprofConfig
if
pprofConfig
.
Enabled
{
if
pprofConfig
.
Enabled
{
...
@@ -78,11 +79,11 @@ func NewService(ctx context.Context, logger log.Logger, cfg *config.Config) (*Se
...
@@ -78,11 +79,11 @@ func NewService(ctx context.Context, logger log.Logger, cfg *config.Config) (*Se
return
fault
.
NewGamePlayer
(
ctx
,
logger
,
m
,
cfg
,
dir
,
addr
,
txMgr
,
l1Client
)
return
fault
.
NewGamePlayer
(
ctx
,
logger
,
m
,
cfg
,
dir
,
addr
,
txMgr
,
l1Client
)
})
})
var
rpcClient
opClient
.
RPC
=
opClient
.
NewBaseRPCClient
(
l1Client
.
Client
()
)
pollClient
,
err
:=
opClient
.
NewRPCWithClient
(
ctx
,
logger
,
cfg
.
L1EthRpc
,
opClient
.
NewBaseRPCClient
(
rpcClient
),
cfg
.
PollInterval
)
if
regexp
.
MustCompile
(
"^http(s)?://"
)
.
MatchString
(
cfg
.
L1EthRpc
)
{
if
err
!=
nil
{
r
pcClient
=
opClient
.
NewPollingClient
(
ctx
,
logger
,
rpcClient
,
opClient
.
WithPollRate
(
cfg
.
PollInterval
)
)
r
eturn
nil
,
fmt
.
Errorf
(
"failed to create RPC client: %w"
,
err
)
}
}
monitor
:=
newGameMonitor
(
logger
,
cl
,
loader
,
sched
,
cfg
.
GameWindow
,
l1Client
.
BlockNumber
,
cfg
.
GameAllowlist
,
rpc
Client
)
monitor
:=
newGameMonitor
(
logger
,
cl
,
loader
,
sched
,
cfg
.
GameWindow
,
l1Client
.
BlockNumber
,
cfg
.
GameAllowlist
,
poll
Client
)
m
.
RecordInfo
(
version
.
SimpleWithMeta
)
m
.
RecordInfo
(
version
.
SimpleWithMeta
)
m
.
RecordUp
()
m
.
RecordUp
()
...
...
op-node/client/rpc.go
View file @
b752b9e8
...
@@ -80,9 +80,11 @@ func NewRPC(ctx context.Context, lgr log.Logger, addr string, opts ...RPCOption)
...
@@ -80,9 +80,11 @@ func NewRPC(ctx context.Context, lgr log.Logger, addr string, opts ...RPCOption)
return
nil
,
fmt
.
Errorf
(
"rpc option %d failed to apply to RPC config: %w"
,
i
,
err
)
return
nil
,
fmt
.
Errorf
(
"rpc option %d failed to apply to RPC config: %w"
,
i
,
err
)
}
}
}
}
if
cfg
.
backoffAttempts
<
1
{
// default to at least 1 attempt, or it always fails to dial.
if
cfg
.
backoffAttempts
<
1
{
// default to at least 1 attempt, or it always fails to dial.
cfg
.
backoffAttempts
=
1
cfg
.
backoffAttempts
=
1
}
}
underlying
,
err
:=
dialRPCClientWithBackoff
(
ctx
,
lgr
,
addr
,
cfg
.
backoffAttempts
,
cfg
.
gethRPCOptions
...
)
underlying
,
err
:=
dialRPCClientWithBackoff
(
ctx
,
lgr
,
addr
,
cfg
.
backoffAttempts
,
cfg
.
gethRPCOptions
...
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
...
@@ -94,11 +96,15 @@ func NewRPC(ctx context.Context, lgr log.Logger, addr string, opts ...RPCOption)
...
@@ -94,11 +96,15 @@ func NewRPC(ctx context.Context, lgr log.Logger, addr string, opts ...RPCOption)
wrapped
=
NewRateLimitingClient
(
wrapped
,
rate
.
Limit
(
cfg
.
limit
),
cfg
.
burst
)
wrapped
=
NewRateLimitingClient
(
wrapped
,
rate
.
Limit
(
cfg
.
limit
),
cfg
.
burst
)
}
}
return
NewRPCWithClient
(
ctx
,
lgr
,
addr
,
wrapped
,
cfg
.
httpPollInterval
)
}
// NewRPCWithClient builds a new polling client with the given underlying RPC client.
func
NewRPCWithClient
(
ctx
context
.
Context
,
lgr
log
.
Logger
,
addr
string
,
underlying
RPC
,
pollInterval
time
.
Duration
)
(
RPC
,
error
)
{
if
httpRegex
.
MatchString
(
addr
)
{
if
httpRegex
.
MatchString
(
addr
)
{
wrapped
=
NewPollingClient
(
ctx
,
lgr
,
wrapped
,
WithPollRate
(
cfg
.
httpP
ollInterval
))
underlying
=
NewPollingClient
(
ctx
,
lgr
,
underlying
,
WithPollRate
(
p
ollInterval
))
}
}
return
underlying
,
nil
return
wrapped
,
nil
}
}
// Dials a JSON-RPC endpoint repeatedly, with a backoff, until a client connection is established. Auth is optional.
// Dials a JSON-RPC endpoint repeatedly, with a backoff, until a client connection is established. Auth is optional.
...
...
op-service/client/dial.go
View file @
b752b9e8
...
@@ -33,6 +33,21 @@ func DialEthClientWithTimeout(timeout time.Duration, log log.Logger, url string)
...
@@ -33,6 +33,21 @@ func DialEthClientWithTimeout(timeout time.Duration, log log.Logger, url string)
return
ethclient
.
NewClient
(
c
),
nil
return
ethclient
.
NewClient
(
c
),
nil
}
}
// DialRPCClientWithTimeout attempts to dial the L1 provider using the provided
// URL. If the dial doesn't complete within defaultDialTimeout seconds, this
// method will return an error.
func
DialRPCClientWithTimeout
(
timeout
time
.
Duration
,
log
log
.
Logger
,
url
string
)
(
*
rpc
.
Client
,
error
)
{
ctx
,
cancel
:=
context
.
WithTimeout
(
context
.
Background
(),
timeout
)
defer
cancel
()
c
,
err
:=
dialRPCClientWithBackoff
(
ctx
,
log
,
url
)
if
err
!=
nil
{
return
nil
,
err
}
return
c
,
nil
}
// DialRollupClientWithTimeout attempts to dial the RPC provider using the provided URL.
// DialRollupClientWithTimeout attempts to dial the RPC provider using the provided URL.
// If the dial doesn't complete within timeout seconds, this method will return an error.
// If the dial doesn't complete within timeout seconds, this method will return an error.
func
DialRollupClientWithTimeout
(
timeout
time
.
Duration
,
log
log
.
Logger
,
url
string
)
(
*
sources
.
RollupClient
,
error
)
{
func
DialRollupClientWithTimeout
(
timeout
time
.
Duration
,
log
log
.
Logger
,
url
string
)
(
*
sources
.
RollupClient
,
error
)
{
...
...
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