From 1b944c7086b9ee4b7353452412e91cdf021b9430 Mon Sep 17 00:00:00 2001 From: Javed Khan Date: Wed, 4 Sep 2024 09:05:05 -0700 Subject: [PATCH] da: add gas price flag (#451) --- 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 155f4c66165fc..00a8231441e3e 100644 --- a/op-batcher/batcher/driver.go +++ b/op-batcher/batcher/driver.go @@ -728,7 +728,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 20ccea9851af6..f23ecc17a4860 100644 --- a/op-batcher/batcher/service.go +++ b/op-batcher/batcher/service.go @@ -383,7 +383,7 @@ func (bs *BatcherService) initAltDA(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 c0ab92606c44d..33b2f1767552c 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 f5c14fe50377f..b15940ca335da 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 a8e29000e714c..6fa2cd7504562 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 }