Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

da: add gas price flag #451

Merged
merged 1 commit into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion op-batcher/batcher/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion op-batcher/batcher/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
13 changes: 13 additions & 0 deletions op-celestia/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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"),
},
}
}

Expand All @@ -85,6 +96,7 @@ type CLIConfig struct {
AuthToken string
Namespace string
FallbackMode string
GasPrice float64
}

func (c CLIConfig) Check() error {
Expand All @@ -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),
}
}
4 changes: 3 additions & 1 deletion op-celestia/da_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -33,5 +34,6 @@ func NewDAClient(rpc, token, namespace, fallbackMode string) (*DAClient, error)
GetTimeout: time.Minute,
Namespace: ns,
FallbackMode: fallbackMode,
GasPrice: gasPrice,
}, nil
}
2 changes: 1 addition & 1 deletion op-node/rollup/driver/da.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down