Skip to content

Commit

Permalink
Merge pull request #49 from rootulp/rp/extract-minfee
Browse files Browse the repository at this point in the history
Rp/extract minfee
  • Loading branch information
rootulp authored Oct 23, 2024
2 parents 312def6 + 308cca1 commit 9079673
Show file tree
Hide file tree
Showing 21 changed files with 1,567 additions and 38 deletions.
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
2 changes: 1 addition & 1 deletion 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
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)
}
2 changes: 1 addition & 1 deletion 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
2 changes: 1 addition & 1 deletion app/test/upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,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
9 changes: 6 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
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-20240814211410-ddb44dafa142
google.golang.org/genproto/googleapis/api v0.0.0-20241021214115-324edc3d5d38
google.golang.org/grpc v1.67.1
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,8 @@ require (
)

replace (
// Replace this import until there's an official release of x/minfee
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-20240814211410-ddb44dafa142 h1:wKguEg1hsxI2/L3hUYrpo1RVi48K+uTyzKqprwLXsb8=
google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142/go.mod h1:d6be+8HhtEtucleCbxpPW9PA9XwISACu8nvpPqF0BVo=
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
20 changes: 20 additions & 0 deletions x/minfee/constants.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
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
//
// Deprecated: use DefaultNetworkMinGasPriceAsDec() instead.
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(),
}
}

Expand Down
Loading

0 comments on commit 9079673

Please sign in to comment.