Skip to content

Commit

Permalink
da: add gas price flag (#451)
Browse files Browse the repository at this point in the history
  • Loading branch information
tuxcanfly committed Oct 3, 2024
1 parent ac7b23a commit ce660d0
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 4 deletions.
2 changes: 1 addition & 1 deletion op-batcher/batcher/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -729,7 +729,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 @@ -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
}
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

0 comments on commit ce660d0

Please sign in to comment.