Skip to content

Commit

Permalink
feat: gas adjustmnet parsable for celestia config (#425)
Browse files Browse the repository at this point in the history
  • Loading branch information
mtsitrin authored Jul 30, 2023
1 parent e5a48aa commit 91cebf7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
6 changes: 5 additions & 1 deletion da/celestia/celestia.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ func (c *DataAvailabilityLayerClient) Init(config []byte, pubsubServer *pubsub.S
return errors.New("fee or gas prices must be set")
}

if c.config.GasAdjustment == 0 {
c.config.GasAdjustment = defaultGasAdjustment
}

c.pubsubServer = pubsubServer
// Set defaults
c.txPollingRetryDelay = defaultTxPollingRetryDelay
Expand Down Expand Up @@ -168,7 +172,7 @@ func (c *DataAvailabilityLayerClient) SubmitBatch(batch *types.Batch) da.ResultS
return da.ResultSubmitBatch{}
default:
estimatedGas := EstimateGas(len(blob))
gasWanted := uint64(float64(estimatedGas) * gasAdjustment)
gasWanted := uint64(float64(estimatedGas) * c.config.GasAdjustment)
fees := c.calculateFees(gasWanted)

//SubmitPFB sets an error if the txResponse has error, so we check check the txResponse for error
Expand Down
14 changes: 8 additions & 6 deletions da/celestia/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ import (
)

const (
defaultTxPollingRetryDelay = 20 * time.Second
defaultSubmitRetryDelay = 10 * time.Second
defaultTxPollingAttempts = 5
namespaceVersion = 0
defaultGasPrices = 0.1
gasAdjustment = 1.3
defaultTxPollingRetryDelay = 20 * time.Second
defaultSubmitRetryDelay = 10 * time.Second
defaultTxPollingAttempts = 5
namespaceVersion = 0
defaultGasPrices = 0.1
defaultGasAdjustment float64 = 1.3
)

// Config stores Celestia DALC configuration parameters.
Expand All @@ -23,6 +23,7 @@ type Config struct {
Timeout time.Duration `json:"timeout"`
Fee int64 `json:"fee"`
GasPrices float64 `json:"gas_prices"`
GasAdjustment float64 `json:"gas_adjustment"`
GasLimit uint64 `json:"gas_limit"`
NamespaceIDStr string `json:"namespace_id"`
NamespaceID cnc.Namespace `json:"-"`
Expand All @@ -35,6 +36,7 @@ var CelestiaDefaultConfig = Config{
Fee: 0,
GasLimit: 20000000,
GasPrices: defaultGasPrices,
GasAdjustment: defaultGasAdjustment,
NamespaceIDStr: "000000000000ffff",
NamespaceID: cnc.Namespace{Version: namespaceVersion, ID: []byte{0, 0, 0, 0, 0, 0, 255, 255}},
}
Expand Down

0 comments on commit 91cebf7

Please sign in to comment.