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
a6afe971
Unverified
Commit
a6afe971
authored
Jan 31, 2022
by
Matthew Slipper
Committed by
GitHub
Jan 31, 2022
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2078 from mslipper/fix/go-bss-go-version
go/batch-submitter: HTTP/2 fixes
parents
dc1ed3c9
f0c3f937
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
59 additions
and
6 deletions
+59
-6
empty-coats-beam.md
.changeset/empty-coats-beam.md
+5
-0
batch_submitter.go
go/batch-submitter/batch_submitter.go
+42
-4
config.go
go/batch-submitter/config.go
+4
-0
flags.go
go/batch-submitter/flags/flags.go
+6
-0
Dockerfile.batch-submitter-service
ops/docker/Dockerfile.batch-submitter-service
+2
-2
No files found.
.changeset/empty-coats-beam.md
0 → 100644
View file @
a6afe971
---
'
@eth-optimism/batch-submitter-service'
:
patch
---
Update golang version to support HTTP/2
go/batch-submitter/batch_submitter.go
View file @
a6afe971
...
...
@@ -3,16 +3,20 @@ package batchsubmitter
import
(
"context"
"crypto/ecdsa"
"crypto/tls"
"fmt"
"github.com/ethereum/go-ethereum/rpc"
"net/http"
"os"
"strconv"
"strings"
"time"
"github.com/ethereum-optimism/optimism/go/batch-submitter/drivers/proposer"
"github.com/ethereum-optimism/optimism/go/batch-submitter/drivers/sequencer"
"github.com/ethereum-optimism/optimism/go/batch-submitter/txmgr"
l2ethclient
"github.com/ethereum-optimism/optimism/l2geth/ethclient"
l2rpc
"github.com/ethereum-optimism/optimism/l2geth/rpc"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/ethclient"
...
...
@@ -138,12 +142,12 @@ func NewBatchSubmitter(cfg Config, gitVersion string) (*BatchSubmitter, error) {
// Connect to L1 and L2 providers. Perform these last since they are the
// most expensive.
l1Client
,
err
:=
dialL1EthClientWithTimeout
(
ctx
,
cfg
.
L1EthRpc
)
l1Client
,
err
:=
dialL1EthClientWithTimeout
(
ctx
,
cfg
.
L1EthRpc
,
cfg
.
DisableHTTP2
)
if
err
!=
nil
{
return
nil
,
err
}
l2Client
,
err
:=
dialL2EthClientWithTimeout
(
ctx
,
cfg
.
L2EthRpc
)
l2Client
,
err
:=
dialL2EthClientWithTimeout
(
ctx
,
cfg
.
L2EthRpc
,
cfg
.
DisableHTTP2
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -301,24 +305,58 @@ func runMetricsServer(hostname string, port uint64) {
// dialL1EthClientWithTimeout 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
dialL1EthClientWithTimeout
(
ctx
context
.
Context
,
url
string
)
(
func
dialL1EthClientWithTimeout
(
ctx
context
.
Context
,
url
string
,
disableHTTP2
bool
)
(
*
ethclient
.
Client
,
error
)
{
ctxt
,
cancel
:=
context
.
WithTimeout
(
ctx
,
defaultDialTimeout
)
defer
cancel
()
if
strings
.
HasPrefix
(
url
,
"http"
)
{
httpClient
:=
new
(
http
.
Client
)
if
disableHTTP2
{
log
.
Info
(
"Disabled HTTP/2 support in L1 eth client"
)
httpClient
.
Transport
=
&
http
.
Transport
{
TLSNextProto
:
make
(
map
[
string
]
func
(
authority
string
,
c
*
tls
.
Conn
)
http
.
RoundTripper
),
}
}
rpcClient
,
err
:=
rpc
.
DialHTTPWithClient
(
url
,
httpClient
)
if
err
!=
nil
{
return
nil
,
err
}
return
ethclient
.
NewClient
(
rpcClient
),
nil
}
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
)
(
func
dialL2EthClientWithTimeout
(
ctx
context
.
Context
,
url
string
,
disableHTTP2
bool
)
(
*
l2ethclient
.
Client
,
error
)
{
ctxt
,
cancel
:=
context
.
WithTimeout
(
ctx
,
defaultDialTimeout
)
defer
cancel
()
if
strings
.
HasPrefix
(
url
,
"http"
)
{
httpClient
:=
new
(
http
.
Client
)
if
disableHTTP2
{
log
.
Info
(
"Disabled HTTP/2 support in L2 eth client"
)
httpClient
.
Transport
=
&
http
.
Transport
{
TLSNextProto
:
make
(
map
[
string
]
func
(
authority
string
,
c
*
tls
.
Conn
)
http
.
RoundTripper
),
}
}
rpcClient
,
err
:=
l2rpc
.
DialHTTPWithClient
(
url
,
httpClient
)
if
err
!=
nil
{
return
nil
,
err
}
return
l2ethclient
.
NewClient
(
rpcClient
),
nil
}
return
l2ethclient
.
DialContext
(
ctxt
,
url
)
}
...
...
go/batch-submitter/config.go
View file @
a6afe971
...
...
@@ -163,6 +163,9 @@ type Config struct {
// MetricsPort is the port at which the metrics server is running.
MetricsPort
uint64
// DisableHTTP2 disables HTTP2 support.
DisableHTTP2
bool
}
// NewConfig parses the Config from the provided flags or environment variables.
...
...
@@ -199,6 +202,7 @@ func NewConfig(ctx *cli.Context) (Config, error) {
MetricsServerEnable
:
ctx
.
GlobalBool
(
flags
.
MetricsServerEnableFlag
.
Name
),
MetricsHostname
:
ctx
.
GlobalString
(
flags
.
MetricsHostnameFlag
.
Name
),
MetricsPort
:
ctx
.
GlobalUint64
(
flags
.
MetricsPortFlag
.
Name
),
DisableHTTP2
:
ctx
.
GlobalBool
(
flags
.
HTTP2DisableFlag
.
Name
),
}
err
:=
ValidateConfig
(
&
cfg
)
...
...
go/batch-submitter/flags/flags.go
View file @
a6afe971
...
...
@@ -196,6 +196,11 @@ var (
Value
:
7300
,
EnvVar
:
prefixEnvVar
(
"METRICS_PORT"
),
}
HTTP2DisableFlag
=
cli
.
BoolFlag
{
Name
:
"http2-disable"
,
Usage
:
"Whether or not to disable HTTP/2 support."
,
EnvVar
:
prefixEnvVar
(
"HTTP2_DISABLE"
),
}
)
var
requiredFlags
=
[]
cli
.
Flag
{
...
...
@@ -231,6 +236,7 @@ var optionalFlags = []cli.Flag{
MetricsServerEnableFlag
,
MetricsHostnameFlag
,
MetricsPortFlag
,
HTTP2DisableFlag
,
}
// Flags contains the list of configuration options available to the binary.
...
...
ops/docker/Dockerfile.batch-submitter-service
View file @
a6afe971
FROM golang:1.1
5-alpine3.13
as builder
FROM golang:1.1
7.6-alpine3.15
as builder
RUN apk add --no-cache make gcc musl-dev linux-headers git jq bash
...
...
@@ -9,7 +9,7 @@ RUN go mod graph | grep -v l2geth | awk '{if ($1 !~ "@") print $2}' | xargs -n 1
COPY ./go/batch-submitter/ ./
RUN make
FROM alpine:3.1
3
FROM alpine:3.1
5
RUN apk add --no-cache ca-certificates jq curl
COPY --from=builder /go/batch-submitter/batch-submitter /usr/local/bin/
...
...
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