Skip to content

Commit a4b72ab

Browse files
Merge pull request OffchainLabs#3342 from OffchainLabs/das-aggregator-http2-offbydefault
Disable HTTP/2 for das aggregator by default
2 parents 4207726 + 5feafee commit a4b72ab

File tree

4 files changed

+22
-4
lines changed

4 files changed

+22
-4
lines changed

cmd/datool/datool.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ type ClientStoreConfig struct {
9393
SigningWalletPassword string `koanf:"signing-wallet-password"`
9494
MaxStoreChunkBodySize int `koanf:"max-store-chunk-body-size"`
9595
EnableChunkedStore bool `koanf:"enable-chunked-store"`
96+
EnableHTTP2 bool `koanf:"enable-http2"`
9697
}
9798

9899
func parseClientStoreConfig(args []string) (*ClientStoreConfig, error) {
@@ -106,6 +107,7 @@ func parseClientStoreConfig(args []string) (*ClientStoreConfig, error) {
106107
f.Duration("das-retention-period", 24*time.Hour, "The period which DASes are requested to retain the stored batches.")
107108
f.Int("max-store-chunk-body-size", 512*1024, "The maximum HTTP POST body size for a chunked store request")
108109
f.Bool("enable-chunked-store", true, "enable data to be sent to DAS in chunks instead of all at once")
110+
f.Bool("enable-http2", true, "enable HTTP/2 for DAS connections")
109111

110112
k, err := confighelpers.BeginCommonParse(f, args)
111113
if err != nil {
@@ -154,7 +156,7 @@ func startClientStore(args []string) error {
154156
}
155157
}
156158

157-
client, err := das.NewDASRPCClient(config.URL, signer, config.MaxStoreChunkBodySize, config.EnableChunkedStore)
159+
client, err := das.NewDASRPCClient(config.URL, signer, config.MaxStoreChunkBodySize, config.EnableChunkedStore, config.EnableHTTP2)
158160
if err != nil {
159161
return err
160162
}

daprovider/das/aggregator.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,15 @@ type AggregatorConfig struct {
4242
Backends BackendConfigList `koanf:"backends"`
4343
MaxStoreChunkBodySize int `koanf:"max-store-chunk-body-size"`
4444
EnableChunkedStore bool `koanf:"enable-chunked-store"`
45+
EnableHTTP2 bool `koanf:"enable-http2"`
4546
}
4647

4748
var DefaultAggregatorConfig = AggregatorConfig{
4849
AssumedHonest: 0,
4950
Backends: nil,
5051
MaxStoreChunkBodySize: 512 * 1024,
5152
EnableChunkedStore: true,
53+
EnableHTTP2: false,
5254
}
5355

5456
var parsedBackendsConf BackendConfigList
@@ -59,6 +61,7 @@ func AggregatorConfigAddOptions(prefix string, f *flag.FlagSet) {
5961
f.Var(&parsedBackendsConf, prefix+".backends", "JSON RPC backend configuration. This can be specified on the command line as a JSON array, eg: [{\"url\": \"...\", \"pubkey\": \"...\"},...], or as a JSON array in the config file.")
6062
f.Int(prefix+".max-store-chunk-body-size", DefaultAggregatorConfig.MaxStoreChunkBodySize, "maximum HTTP POST body size to use for individual batch chunks, including JSON RPC overhead and an estimated overhead of 512B of headers")
6163
f.Bool(prefix+".enable-chunked-store", DefaultAggregatorConfig.EnableChunkedStore, "enable data to be sent to DAS in chunks instead of all at once")
64+
f.Bool(prefix+".enable-http2", DefaultAggregatorConfig.EnableHTTP2, "enable HTTP/2 for backend connections (default is HTTP/1.1)")
6265
}
6366

6467
type Aggregator struct {

daprovider/das/dasRpcClient.go

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ package das
66
import (
77
"context"
88
"fmt"
9+
"net/http"
910
"strings"
1011
"time"
1112

@@ -48,8 +49,20 @@ func nilSigner(_ []byte) ([]byte, error) {
4849

4950
const sendChunkJSONBoilerplate = "{\"jsonrpc\":\"2.0\",\"id\":4294967295,\"method\":\"das_sendChunked\",\"params\":[\"\"]}"
5051

51-
func NewDASRPCClient(target string, signer signature.DataSignerFunc, maxStoreChunkBodySize int, enableChunkedStore bool) (*DASRPCClient, error) {
52-
clnt, err := rpc.Dial(target)
52+
func NewDASRPCClient(target string, signer signature.DataSignerFunc, maxStoreChunkBodySize int, enableChunkedStore bool, enableHTTP2 bool) (*DASRPCClient, error) {
53+
// Always create a custom transport based on the default
54+
httpTransport, ok := http.DefaultTransport.(*http.Transport)
55+
if !ok {
56+
panic("Failed conversion from DefaultTransport to http.Transport")
57+
}
58+
transport := httpTransport.Clone()
59+
transport.ForceAttemptHTTP2 = enableHTTP2
60+
61+
httpClient := &http.Client{
62+
Transport: transport,
63+
}
64+
65+
clnt, err := rpc.DialOptions(context.Background(), target, rpc.WithHTTPClient(httpClient))
5366
if err != nil {
5467
return nil, err
5568
}

daprovider/das/rpc_aggregator.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ func ParseServices(config AggregatorConfig, signer signature.DataSignerFunc) ([]
110110
}
111111
metricName := metricsutil.CanonicalizeMetricName(url.Hostname())
112112

113-
service, err := NewDASRPCClient(b.URL, signer, config.MaxStoreChunkBodySize, config.EnableChunkedStore)
113+
service, err := NewDASRPCClient(b.URL, signer, config.MaxStoreChunkBodySize, config.EnableChunkedStore, config.EnableHTTP2)
114114
if err != nil {
115115
return nil, err
116116
}

0 commit comments

Comments
 (0)