From 8c1fcb5118db90ed6e618dd2d48a3b34335d9a2d Mon Sep 17 00:00:00 2001 From: Callum Waters Date: Sun, 23 Apr 2023 21:26:14 +0200 Subject: [PATCH] feat: introduce DefaultMinGasPrice to appconsts (#1642) Uses a constant in th `appconsts` package for the `DefaultMinGasPrice` that users can import. --- cmd/celestia-appd/cmd/root.go | 2 +- pkg/appconsts/appconsts.go | 5 +++++ testing/txsim/account.go | 5 +++-- testing/txsim/send.go | 3 ++- testing/txsim/sequence.go | 1 - 5 files changed, 11 insertions(+), 5 deletions(-) diff --git a/cmd/celestia-appd/cmd/root.go b/cmd/celestia-appd/cmd/root.go index 90efad8462..6c22612497 100644 --- a/cmd/celestia-appd/cmd/root.go +++ b/cmd/celestia-appd/cmd/root.go @@ -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} diff --git a/pkg/appconsts/appconsts.go b/pkg/appconsts/appconsts.go index ec072e3c89..76eab7db18 100644 --- a/pkg/appconsts/appconsts.go +++ b/pkg/appconsts/appconsts.go @@ -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 ( diff --git a/testing/txsim/account.go b/testing/txsim/account.go index 97528a769f..227e844ed1 100644 --- a/testing/txsim/account.go +++ b/testing/txsim/account.go @@ -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" @@ -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 @@ -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)))) } } diff --git a/testing/txsim/send.go b/testing/txsim/send.go index 04c7477941..0983ab1834 100644 --- a/testing/txsim/send.go +++ b/testing/txsim/send.go @@ -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" @@ -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 diff --git a/testing/txsim/sequence.go b/testing/txsim/sequence.go index 3f088fb00e..b22c6b9cbd 100644 --- a/testing/txsim/sequence.go +++ b/testing/txsim/sequence.go @@ -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