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

feat(x/minfee): extract go module #4003

Closed
Closed
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 app/ante/fee_checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"cosmossdk.io/math"
"github.com/celestiaorg/celestia-app/v3/pkg/appconsts"
v1 "github.com/celestiaorg/celestia-app/v3/pkg/appconsts/v1"
"github.com/celestiaorg/celestia-app/v3/x/minfee"
"github.com/celestiaorg/celestia-app/x/minfee"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerror "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/x/auth/ante"
Expand Down
15 changes: 6 additions & 9 deletions app/ante/min_fee_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/celestiaorg/celestia-app/v3/app/encoding"
"github.com/celestiaorg/celestia-app/v3/pkg/appconsts"
"github.com/celestiaorg/celestia-app/v3/test/util/testnode"
"github.com/celestiaorg/celestia-app/v3/x/minfee"
"github.com/celestiaorg/celestia-app/x/minfee"
"github.com/cosmos/cosmos-sdk/codec"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/store"
Expand Down Expand Up @@ -57,31 +57,31 @@ func TestValidateTxFee(t *testing.T) {
{
name: "bad tx; fee below required minimum",
fee: sdk.NewCoins(sdk.NewInt64Coin(appconsts.BondDenom, feeAmount-1)),
gasLimit: uint64(float64(feeAmount) / appconsts.DefaultNetworkMinGasPrice),
gasLimit: uint64(float64(feeAmount) / minfee.DefaultNetworkMinGasPrice),
appVersion: uint64(2),
isCheckTx: false,
expErr: true,
},
{
name: "good tx; fee equal to required minimum",
fee: sdk.NewCoins(sdk.NewInt64Coin(appconsts.BondDenom, feeAmount)),
gasLimit: uint64(float64(feeAmount) / appconsts.DefaultNetworkMinGasPrice),
gasLimit: uint64(float64(feeAmount) / minfee.DefaultNetworkMinGasPrice),
appVersion: uint64(2),
isCheckTx: false,
expErr: false,
},
{
name: "good tx; fee above required minimum",
fee: sdk.NewCoins(sdk.NewInt64Coin(appconsts.BondDenom, feeAmount+1)),
gasLimit: uint64(float64(feeAmount) / appconsts.DefaultNetworkMinGasPrice),
gasLimit: uint64(float64(feeAmount) / minfee.DefaultNetworkMinGasPrice),
appVersion: uint64(2),
isCheckTx: false,
expErr: false,
},
{
name: "good tx; with no fee (v1)",
fee: sdk.NewCoins(sdk.NewInt64Coin(appconsts.BondDenom, feeAmount)),
gasLimit: uint64(float64(feeAmount) / appconsts.DefaultNetworkMinGasPrice),
gasLimit: uint64(float64(feeAmount) / minfee.DefaultNetworkMinGasPrice),
appVersion: uint64(1),
isCheckTx: false,
expErr: false,
Expand Down Expand Up @@ -142,12 +142,9 @@ func TestValidateTxFee(t *testing.T) {

ctx = ctx.WithMinGasPrices(sdk.DecCoins{validatorMinGasPriceCoin})

networkMinGasPriceDec, err := sdk.NewDecFromStr(fmt.Sprintf("%f", appconsts.DefaultNetworkMinGasPrice))
require.NoError(t, err)

subspace, _ := paramsKeeper.GetSubspace(minfee.ModuleName)
subspace = minfee.RegisterMinFeeParamTable(subspace)
subspace.Set(ctx, minfee.KeyNetworkMinGasPrice, networkMinGasPriceDec)
subspace.Set(ctx, minfee.KeyNetworkMinGasPrice, minfee.DefaultNetworkMinGasPriceAsDec())

_, _, err = ante.ValidateTxFee(ctx, tx, paramsKeeper)
if tc.expErr {
Expand Down
2 changes: 1 addition & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ import (
blobtypes "github.com/celestiaorg/celestia-app/v3/x/blob/types"
blobstreamkeeper "github.com/celestiaorg/celestia-app/v3/x/blobstream/keeper"
blobstreamtypes "github.com/celestiaorg/celestia-app/v3/x/blobstream/types"
"github.com/celestiaorg/celestia-app/v3/x/minfee"
mintkeeper "github.com/celestiaorg/celestia-app/v3/x/mint/keeper"
minttypes "github.com/celestiaorg/celestia-app/v3/x/mint/types"
"github.com/celestiaorg/celestia-app/v3/x/paramfilter"
"github.com/celestiaorg/celestia-app/v3/x/signal"
signaltypes "github.com/celestiaorg/celestia-app/v3/x/signal/types"
"github.com/celestiaorg/celestia-app/v3/x/tokenfilter"
"github.com/celestiaorg/celestia-app/x/minfee"
"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/client"
nodeservice "github.com/cosmos/cosmos-sdk/client/grpc/node"
Expand Down
2 changes: 1 addition & 1 deletion app/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/celestiaorg/celestia-app/v3/app/encoding"
"github.com/celestiaorg/celestia-app/v3/test/util"
"github.com/celestiaorg/celestia-app/v3/test/util/testnode"
"github.com/celestiaorg/celestia-app/v3/x/minfee"
"github.com/celestiaorg/celestia-app/x/minfee"
"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/snapshots"
snapshottypes "github.com/cosmos/cosmos-sdk/snapshots/types"
Expand Down
2 changes: 1 addition & 1 deletion app/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import (
blobtypes "github.com/celestiaorg/celestia-app/v3/x/blob/types"
"github.com/celestiaorg/celestia-app/v3/x/blobstream"
blobstreamtypes "github.com/celestiaorg/celestia-app/v3/x/blobstream/types"
"github.com/celestiaorg/celestia-app/v3/x/minfee"
"github.com/celestiaorg/celestia-app/v3/x/mint"
minttypes "github.com/celestiaorg/celestia-app/v3/x/mint/types"
"github.com/celestiaorg/celestia-app/v3/x/signal"
signaltypes "github.com/celestiaorg/celestia-app/v3/x/signal/types"
"github.com/celestiaorg/celestia-app/x/minfee"
sdkmodule "github.com/cosmos/cosmos-sdk/types/module"
"github.com/cosmos/cosmos-sdk/x/auth"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
Expand Down
7 changes: 3 additions & 4 deletions x/minfee/grpc_query_test.go → app/test/query_test.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
package minfee_test
package app_test

import (
"testing"

"github.com/celestiaorg/celestia-app/v3/app"
"github.com/celestiaorg/celestia-app/v3/pkg/appconsts"
testutil "github.com/celestiaorg/celestia-app/v3/test/util"
"github.com/celestiaorg/celestia-app/v3/x/minfee"
"github.com/celestiaorg/celestia-app/x/minfee"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/stretchr/testify/require"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
Expand All @@ -24,5 +23,5 @@ func TestQueryNetworkMinGasPrice(t *testing.T) {
require.NoError(t, err)

// Check the response
require.Equal(t, appconsts.DefaultNetworkMinGasPrice, resp.NetworkMinGasPrice.MustFloat64())
require.Equal(t, minfee.DefaultNetworkMinGasPriceAsDec(), resp.NetworkMinGasPrice)
}
4 changes: 2 additions & 2 deletions app/test/std_sdk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import (
"github.com/celestiaorg/celestia-app/v3/test/util/blobfactory"
"github.com/celestiaorg/celestia-app/v3/test/util/testfactory"
"github.com/celestiaorg/celestia-app/v3/test/util/testnode"
"github.com/celestiaorg/celestia-app/v3/x/minfee"
signal "github.com/celestiaorg/celestia-app/v3/x/signal/types"
"github.com/celestiaorg/celestia-app/x/minfee"
"github.com/celestiaorg/go-square/v2/share"
nodeservice "github.com/cosmos/cosmos-sdk/client/grpc/node"
"github.com/cosmos/cosmos-sdk/crypto/hd"
Expand Down Expand Up @@ -349,7 +349,7 @@ func (s *StandardSDKIntegrationTestSuite) TestGRPCQueries() {
require.NoError(t, err)
got, err := resp.NetworkMinGasPrice.Float64()
require.NoError(t, err)
assert.Equal(t, appconsts.DefaultNetworkMinGasPrice, got)
assert.Equal(t, minfee.DefaultNetworkMinGasPrice, got)
})
t.Run("testnode can query local min gas price", func(t *testing.T) {
serviceClient := nodeservice.NewServiceClient(s.cctx.GRPCClient)
Expand Down
8 changes: 2 additions & 6 deletions app/test/upgrade_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package app_test

import (
"fmt"
"strings"
"testing"

Expand All @@ -16,8 +15,8 @@ import (
"github.com/celestiaorg/celestia-app/v3/test/util/genesis"
"github.com/celestiaorg/celestia-app/v3/test/util/testnode"
blobstreamtypes "github.com/celestiaorg/celestia-app/v3/x/blobstream/types"
"github.com/celestiaorg/celestia-app/v3/x/minfee"
signaltypes "github.com/celestiaorg/celestia-app/v3/x/signal/types"
"github.com/celestiaorg/celestia-app/x/minfee"
"github.com/celestiaorg/go-square/v2/share"
"github.com/celestiaorg/go-square/v2/tx"
sdk "github.com/cosmos/cosmos-sdk/types"
Expand Down Expand Up @@ -160,9 +159,6 @@ func TestAppUpgradeV3(t *testing.T) {
// TestAppUpgradeV2 verifies that the all module's params are overridden during an
// upgrade from v1 -> v2 and the app version changes correctly.
func TestAppUpgradeV2(t *testing.T) {
NetworkMinGasPriceDec, err := sdk.NewDecFromStr(fmt.Sprintf("%f", appconsts.DefaultNetworkMinGasPrice))
require.NoError(t, err)

tests := []struct {
module string
subspace string
Expand All @@ -173,7 +169,7 @@ func TestAppUpgradeV2(t *testing.T) {
module: "MinFee",
subspace: minfee.ModuleName,
key: string(minfee.KeyNetworkMinGasPrice),
expectedValue: NetworkMinGasPriceDec.String(),
expectedValue: minfee.DefaultNetworkMinGasPriceAsDec().String(),
},
{
module: "ICA",
Expand Down
10 changes: 7 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ require (
cosmossdk.io/errors v1.0.1
cosmossdk.io/math v1.3.0
github.com/celestiaorg/blobstream-contracts/v3 v3.1.0
github.com/celestiaorg/celestia-app/x/minfee v0.0.0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Consider using a valid semantic version for x/minfee

The dependency version v0.0.0 might cause issues with Go module resolution. Consider using a proper semantic version (e.g., v0.1.0) for the initial release.

-	github.com/celestiaorg/celestia-app/x/minfee v0.0.0
+	github.com/celestiaorg/celestia-app/x/minfee v0.1.0
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
github.com/celestiaorg/celestia-app/x/minfee v0.0.0
github.com/celestiaorg/celestia-app/x/minfee v0.1.0

github.com/celestiaorg/go-square v1.1.1
github.com/celestiaorg/go-square/v2 v2.0.0
github.com/celestiaorg/knuu v0.16.1
Expand All @@ -32,7 +33,7 @@ require (
github.com/tendermint/tendermint v0.34.29
github.com/tendermint/tm-db v0.6.7
golang.org/x/exp v0.0.0-20240904232852-e7e105dedf7e
google.golang.org/genproto/googleapis/api v0.0.0-20240903143218-8af14fe29dc1
google.golang.org/genproto/googleapis/api v0.0.0-20241021214115-324edc3d5d38
google.golang.org/grpc v1.68.0
google.golang.org/protobuf v1.35.1
gopkg.in/yaml.v2 v2.4.0
Expand Down Expand Up @@ -183,7 +184,7 @@ require (
github.com/mtibben/percent v0.2.1 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f // indirect
github.com/onsi/ginkgo v1.16.5 // indirect
github.com/nxadm/tail v1.4.8 // indirect
github.com/opencontainers/image-spec v1.1.0 // indirect
github.com/pelletier/go-toml/v2 v2.2.3 // indirect
github.com/petermattis/goid v0.0.0-20230317030725-371a4b8eda08 // indirect
Expand Down Expand Up @@ -237,7 +238,7 @@ require (
golang.org/x/time v0.5.0 // indirect
google.golang.org/api v0.169.0 // indirect
google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20241015192408-796eee8c2d53 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
Expand All @@ -254,6 +255,9 @@ require (
)

replace (
// Replace this import until there's an official release of x/minfee.
// After this PR merges, we can create a release of x/minfee v1.0.0
rach-id marked this conversation as resolved.
Show resolved Hide resolved
github.com/celestiaorg/celestia-app/x/minfee => ./x/minfee
github.com/cosmos/cosmos-sdk => github.com/celestiaorg/cosmos-sdk v1.25.0-sdk-v0.46.16
// Pin to ledger-cosmos-go v0.12.4 to avoid a breaking change introduced in v0.13.0
// The following replace statement can be removed when we upgrade to cosmos-sdk >= v0.50.0
Expand Down
12 changes: 4 additions & 8 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -606,8 +606,6 @@ github.com/go-sourcemap/sourcemap v2.1.3+incompatible/go.mod h1:F8jJfvm2KbVjc5Nq
github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w=
github.com/go-sql-driver/mysql v1.4.1/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w=
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0 h1:p104kn46Q8WdvHunIJ9dAyjPVtrBPhSr3KT2yUst43I=
github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE=
github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1vB6EwHI=
github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZiAzKg9hl15HA8=
github.com/gobwas/httphead v0.0.0-20180130184737-2c6c146eadee/go.mod h1:L0fX3K22YWvt/FAX9NnzrNzcI4wNYi9Yku4O0LKYflo=
Expand Down Expand Up @@ -1622,7 +1620,6 @@ golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201201145000-ef89a241ccb3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210104204734-6f8348627aad/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210220050731-9a76102bfb43/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
Expand Down Expand Up @@ -1756,7 +1753,6 @@ golang.org/x/tools v0.0.0-20201022035929-9cf592e881e9/go.mod h1:emZCQorbCU4vsT4f
golang.org/x/tools v0.0.0-20201110124207-079ba7bd75cd/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/tools v0.0.0-20201201161351-ac6f37ff4c2a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/tools v0.0.0-20201208233053-a543418bbed2/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/tools v0.0.0-20210105154028-b0ab187a4818/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0=
Expand Down Expand Up @@ -1953,10 +1949,10 @@ google.golang.org/genproto v0.0.0-20221014213838-99cd37c6964a/go.mod h1:1vXfmgAz
google.golang.org/genproto v0.0.0-20221025140454-527a21cfbd71/go.mod h1:9qHF0xnpdSfF6knlcsnpzUu5y+rpwgbvsyGAZPBMg4s=
google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de h1:F6qOa9AZTYJXOUEr4jDysRDLrm4PHePlge4v4TGAlxY=
google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de/go.mod h1:VUhTRKeHn9wwcdrk73nvdC9gF178Tzhmt/qyaFcPLSo=
google.golang.org/genproto/googleapis/api v0.0.0-20240903143218-8af14fe29dc1 h1:hjSy6tcFQZ171igDaN5QHOw2n6vx40juYbC/x67CEhc=
google.golang.org/genproto/googleapis/api v0.0.0-20240903143218-8af14fe29dc1/go.mod h1:qpvKtACPCQhAdu3PyQgV4l3LMXZEtft7y8QcarRsp9I=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1 h1:pPJltXNxVzT4pK9yD8vR9X75DaWYYmLGMsEvBfFQZzQ=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1/go.mod h1:UqMtugtsSgubUsoxbuAoiCXvqvErP7Gf0so0mK9tHxU=
google.golang.org/genproto/googleapis/api v0.0.0-20241021214115-324edc3d5d38 h1:2oV8dfuIkM1Ti7DwXc0BJfnwr9csz4TDXI9EmiI+Rbw=
google.golang.org/genproto/googleapis/api v0.0.0-20241021214115-324edc3d5d38/go.mod h1:vuAjtvlwkDKF6L1GQ0SokiRLCGFfeBUXWr/aFFkHACc=
google.golang.org/genproto/googleapis/rpc v0.0.0-20241015192408-796eee8c2d53 h1:X58yt85/IXCx0Y3ZwN6sEIKZzQtDEYaBWrDvErdXrRE=
google.golang.org/genproto/googleapis/rpc v0.0.0-20241015192408-796eee8c2d53/go.mod h1:GX3210XPVPUjJbTUbvwI8f2IpZDMZuPJWDzDuebbviI=
google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs=
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
google.golang.org/grpc v1.19.1/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
Expand Down
3 changes: 3 additions & 0 deletions pkg/appconsts/initial_consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ const (
// DefaultNetworkMinGasPrice is used by x/minfee to prevent transactions from being
// included in a block if they specify a gas price lower than this.
// Only applies to app version >= 2
//
// Deprecated: Import this constant from x/minfee instead.
// TODO: Remove this constant in v4.
DefaultNetworkMinGasPrice = 0.000001 // utia
)

Expand Down
2 changes: 1 addition & 1 deletion pkg/user/tx_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
"github.com/celestiaorg/celestia-app/v3/app/grpc/tx"
"github.com/celestiaorg/celestia-app/v3/pkg/appconsts"
"github.com/celestiaorg/celestia-app/v3/x/blob/types"
"github.com/celestiaorg/celestia-app/v3/x/minfee"
"github.com/celestiaorg/celestia-app/x/minfee"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion test/tokenfilter/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/celestiaorg/celestia-app/v3/app/encoding"
"github.com/celestiaorg/celestia-app/v3/pkg/appconsts"
"github.com/celestiaorg/celestia-app/v3/test/util/testnode"
"github.com/celestiaorg/celestia-app/v3/x/minfee"
"github.com/celestiaorg/celestia-app/x/minfee"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
Expand Down
18 changes: 18 additions & 0 deletions x/minfee/constants.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package minfee

import sdk "github.com/cosmos/cosmos-sdk/types"

const (
// DefaultNetworkMinGasPrice is used by x/minfee to prevent transactions from being
// included in a block if they specify a gas price lower than this.
// Only applies to app version >= 2
DefaultNetworkMinGasPrice = 0.000001 // utia
)

var (
defaultNetworkMinGasPriceAsDec = sdk.NewDecWithPrec(1, 6)
)

func DefaultNetworkMinGasPriceAsDec() sdk.Dec {
return defaultNetworkMinGasPriceAsDec
}
16 changes: 16 additions & 0 deletions x/minfee/constants_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package minfee

import (
"testing"

sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/stretchr/testify/assert"
)

func TestDefaultNetworkMinGasPriceAsDec(t *testing.T) {
want, err := sdk.NewDecFromStr("0.000001")
assert.NoError(t, err)

got := DefaultNetworkMinGasPriceAsDec()
assert.Equal(t, want, got)
}
2 changes: 1 addition & 1 deletion x/minfee/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
// DefaultGenesis returns the default genesis state.
func DefaultGenesis() *GenesisState {
return &GenesisState{
NetworkMinGasPrice: DefaultNetworkMinGasPrice,
NetworkMinGasPrice: DefaultNetworkMinGasPriceAsDec(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

Duplicate constant definition and inconsistent type usage needs attention

The verification reveals several issues that need to be addressed:

  • The DefaultNetworkMinGasPrice constant is duplicated in both x/minfee/constants.go and pkg/appconsts/initial_consts.go
  • The codebase mixes usage between the float constant and the decimal function:
    • Test files (min_fee_test.go, std_sdk_test.go) use the float constant for gas calculations
    • Genesis and query code uses the decimal function
  • The decimal version is actually stored as a package variable defaultNetworkMinGasPriceAsDec initialized with sdk.NewDecWithPrec(1, 6)

Recommendations:

  1. Remove the duplicate constant from pkg/appconsts/initial_consts.go
  2. Update test files to use DefaultNetworkMinGasPriceAsDec() for consistency
  3. Consider deprecating the float constant in favor of the decimal version
🔗 Analysis chain

LGTM! Improved type safety in genesis state initialization.

The change to use DefaultNetworkMinGasPriceAsDec() ensures consistent decimal type handling and better type safety.

Let's verify the consistent usage of this new function across the codebase:


Inconsistent usage of DefaultNetworkMinGasPrice detected across the codebase

The verification reveals mixed usage of both the old constant DefaultNetworkMinGasPrice and the new function DefaultNetworkMinGasPriceAsDec(). Let's verify the implementation details to understand if this is intentional:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any remaining usage of the old DefaultNetworkMinGasPrice
# and verify the new function is used consistently

# Search for any remaining direct usage of DefaultNetworkMinGasPrice
rg "DefaultNetworkMinGasPrice[^A]" 

# Search for usage of the new function
rg "DefaultNetworkMinGasPriceAsDec"

Length of output: 1550


Script:

#!/bin/bash
# Check the implementation and relationship between both versions
ast-grep --pattern 'func DefaultNetworkMinGasPriceAsDec'

# Check the constant declaration
rg "DefaultNetworkMinGasPrice = " -A 2

Length of output: 362


Script:

#!/bin/bash
# Let's check the implementation of DefaultNetworkMinGasPriceAsDec
cat x/minfee/constants.go

# Check if there are any imports of the old constant from pkg/appconsts
rg -p "appconsts.*DefaultNetworkMinGasPrice"

Length of output: 544

}
}

Expand Down
Loading
Loading