From 2bb548c7d8ffa2419b4b29712e96232217d7cb87 Mon Sep 17 00:00:00 2001 From: Javed Khan Date: Tue, 27 Aug 2024 06:32:29 -0700 Subject: [PATCH] da: add gas price flag --- op-batcher/batcher/driver.go | 2 +- op-batcher/batcher/service.go | 2 +- op-celestia/cli.go | 13 +++++++++++++ op-celestia/da_client.go | 4 +++- op-node/rollup/driver/da.go | 2 +- 5 files changed, 19 insertions(+), 4 deletions(-) diff --git a/op-batcher/batcher/driver.go b/op-batcher/batcher/driver.go index 2131785e077f..383ec6bb4666 100644 --- a/op-batcher/batcher/driver.go +++ b/op-batcher/batcher/driver.go @@ -654,7 +654,7 @@ func (l *BatchSubmitter) calldataTxCandidate(data []byte) *txmgr.TxCandidate { func (l *BatchSubmitter) celestiaTxCandidate(data []byte) (*txmgr.TxCandidate, error) { l.Log.Info("Building Celestia transaction candidate", "size", len(data)) ctx, cancel := context.WithTimeout(context.Background(), 30*time.Duration(l.RollupConfig.BlockTime)*time.Second) - ids, err := l.DAClient.Client.Submit(ctx, [][]byte{data}, -1, l.DAClient.Namespace) + ids, err := l.DAClient.Client.Submit(ctx, [][]byte{data}, l.DAClient.GasPrice, l.DAClient.Namespace) cancel() if err != nil { return nil, err diff --git a/op-batcher/batcher/service.go b/op-batcher/batcher/service.go index 650031610e85..fa973f2f3717 100644 --- a/op-batcher/batcher/service.go +++ b/op-batcher/batcher/service.go @@ -373,7 +373,7 @@ func (bs *BatcherService) initPlasmaDA(cfg *CLIConfig) error { } func (bs *BatcherService) initDA(cfg *CLIConfig) error { - client, err := celestia.NewDAClient(cfg.DaConfig.Rpc, cfg.DaConfig.AuthToken, cfg.DaConfig.Namespace, cfg.DaConfig.FallbackMode) + client, err := celestia.NewDAClient(cfg.DaConfig.Rpc, cfg.DaConfig.AuthToken, cfg.DaConfig.Namespace, cfg.DaConfig.FallbackMode, cfg.DaConfig.GasPrice) if err != nil { return err } diff --git a/op-celestia/cli.go b/op-celestia/cli.go index c0ab92606c44..33b2f1767552 100644 --- a/op-celestia/cli.go +++ b/op-celestia/cli.go @@ -28,12 +28,17 @@ const ( EthFallbackDisabledFlagName = "da.eth_fallback_disabled" // FallbackModeFlagName defines the flag for fallback mode FallbackModeFlagName = "da.fallback_mode" + // GasPriceFlagName defines the flag for gas price + GasPriceFlagName = "da.gas_price" // NamespaceSize is the size of the hex encoded namespace string NamespaceSize = 58 // defaultRPC is the default rpc dial address defaultRPC = "grpc://localhost:26650" + + // defaultGasPrice is the default gas price + defaultGasPrice = -1 ) func CLIFlags(envPrefix string) []cli.Flag { @@ -77,6 +82,12 @@ func CLIFlags(envPrefix string) []cli.Flag { return nil }, }, + &cli.Float64Flag{ + Name: GasPriceFlagName, + Usage: "gas price of the data availability client", + Value: defaultGasPrice, + EnvVars: opservice.PrefixEnvVar(envPrefix, "DA_GAS_PRICE"), + }, } } @@ -85,6 +96,7 @@ type CLIConfig struct { AuthToken string Namespace string FallbackMode string + GasPrice float64 } func (c CLIConfig) Check() error { @@ -103,5 +115,6 @@ func ReadCLIConfig(ctx *cli.Context) CLIConfig { AuthToken: ctx.String(AuthTokenFlagName), Namespace: ctx.String(NamespaceFlagName), FallbackMode: ctx.String(FallbackModeFlagName), + GasPrice: ctx.Float64(GasPriceFlagName), } } diff --git a/op-celestia/da_client.go b/op-celestia/da_client.go index f5c14fe50377..b15940ca335d 100644 --- a/op-celestia/da_client.go +++ b/op-celestia/da_client.go @@ -14,9 +14,10 @@ type DAClient struct { GetTimeout time.Duration Namespace da.Namespace FallbackMode string + GasPrice float64 } -func NewDAClient(rpc, token, namespace, fallbackMode string) (*DAClient, error) { +func NewDAClient(rpc, token, namespace, fallbackMode string, gasPrice float64) (*DAClient, error) { client, err := proxy.NewClient(rpc, token) if err != nil { return nil, err @@ -33,5 +34,6 @@ func NewDAClient(rpc, token, namespace, fallbackMode string) (*DAClient, error) GetTimeout: time.Minute, Namespace: ns, FallbackMode: fallbackMode, + GasPrice: gasPrice, }, nil } diff --git a/op-node/rollup/driver/da.go b/op-node/rollup/driver/da.go index a8e29000e714..6fa2cd750456 100644 --- a/op-node/rollup/driver/da.go +++ b/op-node/rollup/driver/da.go @@ -17,7 +17,7 @@ func SetDAClient(cfg celestia.CLIConfig) error { // The read path always operates in the most permissive mode and is // independent of the fallback mode. // Therefore the configuration value for FallbackMode passed here does not matter. - client, err := celestia.NewDAClient(cfg.Rpc, cfg.AuthToken, cfg.Namespace, cfg.FallbackMode) + client, err := celestia.NewDAClient(cfg.Rpc, cfg.AuthToken, cfg.Namespace, cfg.FallbackMode, cfg.GasPrice) if err != nil { return err }