Skip to content

Commit

Permalink
feat: introduce DefaultMinGasPrice to appconsts (#1642)
Browse files Browse the repository at this point in the history
Uses a constant in th `appconsts` package for the `DefaultMinGasPrice`
that users can import.
  • Loading branch information
cmwaters committed Apr 23, 2023
1 parent 3767e3e commit 8c1fcb5
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion cmd/celestia-appd/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ func initAppConfig() (string, interface{}) {
// snapshots to nodes that state sync
srvCfg.StateSync.SnapshotInterval = 1500
srvCfg.StateSync.SnapshotKeepRecent = 2
srvCfg.MinGasPrices = fmt.Sprintf("0.001%s", app.BondDenom)
srvCfg.MinGasPrices = fmt.Sprintf("%v%s", appconsts.DefaultMinGasPrice, app.BondDenom)

CelestiaAppCfg := CustomAppConfig{Config: *srvCfg}

Expand Down
5 changes: 5 additions & 0 deletions pkg/appconsts/appconsts.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ const (
// NOTE: Currently this value is set at roughly the number of PFBs that
// would fill one quarter of the max square size.
TransactionsPerBlockLimit = 5090

// DefaultMinGasPrice is the default min gas price that gets set in the app.toml file.
// The min gas price acts as a filter. Transactions below that limit will not pass
// a nodes `CheckTx` and thus not be proposed by that node.
DefaultMinGasPrice = 0.001
)

var (
Expand Down
5 changes: 3 additions & 2 deletions testing/txsim/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"sync"

"github.com/celestiaorg/celestia-app/app"
"github.com/celestiaorg/celestia-app/pkg/appconsts"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/crypto/hd"
"github.com/cosmos/cosmos-sdk/crypto/keyring"
Expand All @@ -19,7 +20,7 @@ import (
"github.com/rs/zerolog/log"
)

const defaultFee = DefaultGasLimit * DefaultGasPrice
const defaultFee = DefaultGasLimit * appconsts.DefaultMinGasPrice

type AccountManager struct {
keys keyring.Keyring
Expand Down Expand Up @@ -184,7 +185,7 @@ func (am *AccountManager) Submit(ctx context.Context, op Operation) error {
if op.GasPrice > 0 {
builder.SetFeeAmount(types.NewCoins(types.NewInt64Coin(app.BondDenom, int64(float64(op.GasLimit)*op.GasPrice))))
} else {
builder.SetFeeAmount(types.NewCoins(types.NewInt64Coin(app.BondDenom, int64(float64(op.GasLimit)*DefaultGasPrice))))
builder.SetFeeAmount(types.NewCoins(types.NewInt64Coin(app.BondDenom, int64(float64(op.GasLimit)*appconsts.DefaultMinGasPrice))))
}
}

Expand Down
3 changes: 2 additions & 1 deletion testing/txsim/send.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"math/rand"

"github.com/celestiaorg/celestia-app/app"
"github.com/celestiaorg/celestia-app/pkg/appconsts"
"github.com/cosmos/cosmos-sdk/types"
bank "github.com/cosmos/cosmos-sdk/x/bank/types"
"github.com/gogo/protobuf/grpc"
Expand All @@ -14,7 +15,7 @@ var _ Sequence = &SendSequence{}

const (
sendGasLimit = 100000
sendFee = sendGasLimit * DefaultGasPrice
sendFee = sendGasLimit * appconsts.DefaultMinGasPrice
)

// SendSequence sets up an endless sequence of send transactions, moving tokens
Expand Down
1 change: 0 additions & 1 deletion testing/txsim/sequence.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ const (
// set default gas limit to cover the costs of most transactions
// At 0.001 utia per gas, this equates to 1000utia per transaction
DefaultGasLimit = 1000000
DefaultGasPrice = 0.001
)

// EndOfSequence is a special error which indicates that the sequence has been terminated
Expand Down

0 comments on commit 8c1fcb5

Please sign in to comment.