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
996230de
Unverified
Commit
996230de
authored
Nov 22, 2021
by
Conner Fromknecht
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: switch L2 provider to use l2geth/ethclient
parent
2fe9b9ee
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
6 deletions
+19
-6
batch_submitter.go
go/batch-submitter/batch_submitter.go
+19
-6
No files found.
go/batch-submitter/batch_submitter.go
View file @
996230de
...
...
@@ -9,6 +9,7 @@ import (
"strconv"
"time"
l2ethclient
"github.com/ethereum-optimism/optimism/l2geth/ethclient"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/ethclient"
...
...
@@ -57,7 +58,7 @@ type BatchSubmitter struct {
ctx
context
.
Context
cfg
Config
l1Client
*
ethclient
.
Client
l2Client
*
ethclient
.
Client
l2Client
*
l2
ethclient
.
Client
sequencerPrivKey
*
ecdsa
.
PrivateKey
proposerPrivKey
*
ecdsa
.
PrivateKey
ctcAddress
common
.
Address
...
...
@@ -118,14 +119,14 @@ func NewBatchSubmitter(cfg Config, gitVersion string) (*BatchSubmitter, error) {
return
nil
,
err
}
// Connect to L1 and L2 providers. Perform these lastsince they are the
// Connect to L1 and L2 providers. Perform these last
since they are the
// most expensive.
l1Client
,
err
:=
dialEthClientWithTimeout
(
ctx
,
cfg
.
L1EthRpc
)
l1Client
,
err
:=
dial
L1
EthClientWithTimeout
(
ctx
,
cfg
.
L1EthRpc
)
if
err
!=
nil
{
return
nil
,
err
}
l2Client
,
err
:=
dialEthClientWithTimeout
(
ctx
,
cfg
.
L2EthRpc
)
l2Client
,
err
:=
dial
L2
EthClientWithTimeout
(
ctx
,
cfg
.
L2EthRpc
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -191,10 +192,10 @@ func runMetricsServer(hostname string, port uint64) {
_
=
http
.
ListenAndServe
(
metricsAddr
,
nil
)
}
// dial
EthClientWithTimeout attempts to dial the L1 or L2
provider using the
// dial
L1EthClientWithTimeout 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
dialEthClientWithTimeout
(
ctx
context
.
Context
,
url
string
)
(
func
dial
L1
EthClientWithTimeout
(
ctx
context
.
Context
,
url
string
)
(
*
ethclient
.
Client
,
error
)
{
ctxt
,
cancel
:=
context
.
WithTimeout
(
ctx
,
defaultDialTimeout
)
...
...
@@ -203,6 +204,18 @@ func dialEthClientWithTimeout(ctx context.Context, url string) (
return
ethclient
.
DialContext
(
ctxt
,
url
)
}
// dialL2EthClientWithTimeout attempts to dial the L2 provider using the
// provided URL. If the dial doesn't complete within defaultDialTimeout seconds,
// this method will return an error.
func
dialL2EthClientWithTimeout
(
ctx
context
.
Context
,
url
string
)
(
*
l2ethclient
.
Client
,
error
)
{
ctxt
,
cancel
:=
context
.
WithTimeout
(
ctx
,
defaultDialTimeout
)
defer
cancel
()
return
l2ethclient
.
DialContext
(
ctxt
,
url
)
}
// traceRateToFloat64 converts a time.Duration into a valid float64 for the
// Sentry client. The client only accepts values between 0.0 and 1.0, so this
// method clamps anything greater than 1 second to 1.0.
...
...
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