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: integrate x/feemarket #250

Merged
merged 18 commits into from
Jul 5, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
3 changes: 3 additions & 0 deletions app/ante.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/cosmos/ibc-go/v8/modules/core/keeper"
feeabsante "github.com/osmosis-labs/fee-abstraction/v8/x/feeabs/ante"
feeabskeeper "github.com/osmosis-labs/fee-abstraction/v8/x/feeabs/keeper"
feemarketante "github.com/skip-mev/feemarket/x/feemarket/ante"

corestoretypes "cosmossdk.io/core/store"
circuitante "cosmossdk.io/x/circuit/ante"
Expand All @@ -30,6 +31,8 @@ type HandlerOptions struct {
TXCounterStoreService corestoretypes.KVStoreService
CircuitKeeper *circuitkeeper.Keeper
FeeAbskeeper feeabskeeper.Keeper
FeeMarketKeeper feemarketante.FeeMarketKeeper
AccountKeeper feemarketante.AccountKeeper
}

// NewAnteHandler constructor
Expand Down
66 changes: 58 additions & 8 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ import (
"github.com/osmosis-labs/tokenfactory/bindings"
tokenfactorykeeper "github.com/osmosis-labs/tokenfactory/keeper"
tokenfactorytypes "github.com/osmosis-labs/tokenfactory/types"
feemarketapp "github.com/skip-mev/feemarket/tests/app"
"github.com/skip-mev/feemarket/x/feemarket"
feemarketkeeper "github.com/skip-mev/feemarket/x/feemarket/keeper"
feemarketpost "github.com/skip-mev/feemarket/x/feemarket/post"
feemarkettypes "github.com/skip-mev/feemarket/x/feemarket/types"
"github.com/spf13/cast"
bank "github.com/terra-money/alliance/custom/bank"
bankkeeper "github.com/terra-money/alliance/custom/bank/keeper"
Expand All @@ -62,6 +67,7 @@ import (
reflectionv1 "cosmossdk.io/api/cosmos/reflection/v1"
"cosmossdk.io/client/v2/autocli"
"cosmossdk.io/core/appmodule"
errorsmod "cosmossdk.io/errors"
"cosmossdk.io/log"
storetypes "cosmossdk.io/store/types"
"cosmossdk.io/x/circuit"
Expand Down Expand Up @@ -97,14 +103,14 @@ import (
servertypes "github.com/cosmos/cosmos-sdk/server/types"
"github.com/cosmos/cosmos-sdk/std"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/types/module"
"github.com/cosmos/cosmos-sdk/types/msgservice"
"github.com/cosmos/cosmos-sdk/version"
"github.com/cosmos/cosmos-sdk/x/auth"
"github.com/cosmos/cosmos-sdk/x/auth/ante"
authcodec "github.com/cosmos/cosmos-sdk/x/auth/codec"
authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper"
"github.com/cosmos/cosmos-sdk/x/auth/posthandler"
authsims "github.com/cosmos/cosmos-sdk/x/auth/simulation"
authtx "github.com/cosmos/cosmos-sdk/x/auth/tx"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
Expand Down Expand Up @@ -206,6 +212,8 @@ var maccPerms = map[string][]string{
alliancemoduletypes.ModuleName: {authtypes.Minter, authtypes.Burner},
alliancemoduletypes.RewardsPoolName: nil,
feeabstypes.ModuleName: nil,
feemarkettypes.ModuleName: {authtypes.Burner},
feemarkettypes.FeeCollectorName: {authtypes.Burner},
}

var (
Expand Down Expand Up @@ -246,6 +254,7 @@ type EveApp struct {
ConsensusParamsKeeper consensusparamkeeper.Keeper
CircuitKeeper circuitkeeper.Keeper
FeeabsKeeper feeabskeeper.Keeper
FeeMarketKeeper *feemarketkeeper.Keeper

IBCKeeper *ibckeeper.Keeper // IBC Keeper must be a pointer in the app, so we can SetRouter on it correctly
IBCFeeKeeper ibcfeekeeper.Keeper
Expand Down Expand Up @@ -332,7 +341,7 @@ func NewEveApp(
icacontrollertypes.StoreKey, tokenfactorytypes.StoreKey,
ibchookstypes.StoreKey,
alliancemoduletypes.StoreKey,
feeabstypes.StoreKey,
feeabstypes.StoreKey, feemarkettypes.StoreKey,
)

tkeys := storetypes.NewTransientStoreKeys(paramstypes.TStoreKey)
Expand Down Expand Up @@ -595,6 +604,8 @@ func NewEveApp(
),
)

app.FeeMarketKeeper = feemarketkeeper.NewKeeper(appCodec, keys[feemarkettypes.StoreKey], app.AccountKeeper, &feemarkettypes.TestDenomResolver{}, authtypes.NewModuleAddress(govtypes.ModuleName).String())

app.IBCHooksKeeper = ibchookskeeper.NewKeeper(
keys[ibchookstypes.StoreKey],
)
Expand Down Expand Up @@ -795,6 +806,7 @@ func NewEveApp(
crisis.NewAppModule(app.CrisisKeeper, skipGenesisInvariants, app.GetSubspace(crisistypes.ModuleName)), // always be last to make sure that it checks for all invariants and not only part of them,
tokenfactory.NewAppModule(app.TokenFactoryKeeper, app.AccountKeeper, app.BankKeeper, app.GetSubspace(tokenfactorytypes.ModuleName)),
feeabsmodule.NewAppModule(appCodec, app.FeeabsKeeper),
feemarket.NewAppModule(appCodec, *app.FeeMarketKeeper),
)

// BasicModuleManager defines the module BasicManager is in charge of setting up basic,
Expand Down Expand Up @@ -831,6 +843,7 @@ func NewEveApp(
// NOTE: capability module's beginblocker must come before any modules using capabilities (e.g. IBC)
app.ModuleManager.SetOrderBeginBlockers(
minttypes.ModuleName,
feemarkettypes.ModuleName,
distrtypes.ModuleName,
slashingtypes.ModuleName,
evidencetypes.ModuleName,
Expand All @@ -855,6 +868,7 @@ func NewEveApp(

app.ModuleManager.SetOrderEndBlockers(
crisistypes.ModuleName,
feemarkettypes.ModuleName,
govtypes.ModuleName,
stakingtypes.ModuleName,
genutiltypes.ModuleName,
Expand Down Expand Up @@ -917,6 +931,7 @@ func NewEveApp(
tokenfactorytypes.ModuleName,
alliancemoduletypes.ModuleName,

feemarkettypes.ModuleName,
feeabstypes.ModuleName,
}
app.ModuleManager.SetOrderInitGenesis(genesisModuleOrder...)
Expand Down Expand Up @@ -968,6 +983,9 @@ func NewEveApp(
app.SetPreBlocker(app.PreBlocker)
app.SetBeginBlocker(app.BeginBlocker)
app.SetEndBlocker(app.EndBlocker)

// set denom resolver to test variant.
app.FeeMarketKeeper.SetDenomResolver(&feemarkettypes.TestDenomResolver{})
app.setAnteHandler(txConfig, wasmConfig, keys[wasmtypes.StoreKey])

// must be before Loading version
Expand Down Expand Up @@ -1062,6 +1080,8 @@ func (app *EveApp) setAnteHandler(txConfig client.TxConfig, wasmConfig wasmtypes
WasmKeeper: &app.WasmKeeper,
TXCounterStoreService: runtime.NewKVStoreService(txCounterStoreKey),
CircuitKeeper: &app.CircuitKeeper,
FeeMarketKeeper: app.FeeMarketKeeper,
AccountKeeper: app.AccountKeeper,
},
)
if err != nil {
Expand All @@ -1073,14 +1093,18 @@ func (app *EveApp) setAnteHandler(txConfig client.TxConfig, wasmConfig wasmtypes
}

func (app *EveApp) setPostHandler() {
postHandler, err := posthandler.NewPostHandler(
posthandler.HandlerOptions{},
)
postHandler := feemarketapp.PostHandlerOptions{
AccountKeeper: app.AccountKeeper,
BankKeeper: app.BankKeeper,
FeeGrantKeeper: app.FeeGrantKeeper,
FeeMarketKeeper: app.FeeMarketKeeper,
}
// Set the PostHandler for the app
sdkPostHandler, err := feemarketapp.NewPostHandler(postHandler)
if err != nil {
panic(err)
panic(fmt.Errorf("failed to create PostHandler: %s", err))
}

app.SetPostHandler(postHandler)
app.SetPostHandler(sdkPostHandler)
}

// Name returns the name of the App
Expand Down Expand Up @@ -1318,3 +1342,29 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino

return paramsKeeper
}

// NewPostHandler returns a PostHandler chain with the fee deduct decorator.
func NewPostHandler(options feemarketapp.PostHandlerOptions) (sdk.PostHandler, error) {
if options.AccountKeeper == nil {
return nil, errorsmod.Wrap(sdkerrors.ErrLogic, "account keeper is required for post builder")
}

if options.BankKeeper == nil {
return nil, errorsmod.Wrap(sdkerrors.ErrLogic, "bank keeper is required for post builder")
}

if options.FeeMarketKeeper == nil {
return nil, errorsmod.Wrap(sdkerrors.ErrLogic, "feemarket keeper is required for post builder")
}

postDecorators := []sdk.PostDecorator{
feemarketpost.NewFeeMarketDeductDecorator(
options.AccountKeeper,
options.BankKeeper,
options.FeeGrantKeeper,
options.FeeMarketKeeper,
),
}

return sdk.ChainPostDecorators(postDecorators...), nil
}
4 changes: 2 additions & 2 deletions app/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@
case authtypes.ModuleName:
keyTable = authtypes.ParamKeyTable() //nolint:staticcheck
case banktypes.ModuleName:
keyTable = banktypes.ParamKeyTable() //nolint:staticcheck
keyTable = banktypes.ParamKeyTable()

Check failure on line 83 in app/upgrades.go

View workflow job for this annotation

GitHub Actions / lint

SA1019: banktypes.ParamKeyTable is deprecated: ParamKeyTable for bank module. (staticcheck)
Copy link
Contributor

Choose a reason for hiding this comment

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

Avoid using deprecated banktypes.ParamKeyTable.

The method banktypes.ParamKeyTable is deprecated. Consider using the recommended alternatives.

- keyTable = banktypes.ParamKeyTable()
+ // Use the recommended alternative for banktypes.ParamKeyTable
+ keyTable = banktypes.NewParamKeyTable()

Committable suggestion was skipped due to low confidence.

Tools
golangci-lint

83-83: SA1019: banktypes.ParamKeyTable is deprecated: ParamKeyTable for bank module.

(staticcheck)

GitHub Check: lint

[failure] 83-83:
SA1019: banktypes.ParamKeyTable is deprecated: ParamKeyTable for bank module. (staticcheck)

case stakingtypes.ModuleName:
keyTable = stakingtypes.ParamKeyTable() //nolint:staticcheck
keyTable = stakingtypes.ParamKeyTable()

Check failure on line 85 in app/upgrades.go

View workflow job for this annotation

GitHub Actions / lint

SA1019: stakingtypes.ParamKeyTable is deprecated: now params can be accessed on key `0x51` on the staking store. ParamTable for staking module (staticcheck)
Copy link
Contributor

Choose a reason for hiding this comment

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

Avoid using deprecated stakingtypes.ParamKeyTable.

The method stakingtypes.ParamKeyTable is deprecated. Consider using the recommended alternatives.

- keyTable = stakingtypes.ParamKeyTable()
+ // Use the recommended alternative for stakingtypes.ParamKeyTable
+ keyTable = stakingtypes.NewParamKeyTable()
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
keyTable = stakingtypes.ParamKeyTable()
// Use the recommended alternative for stakingtypes.ParamKeyTable
keyTable = stakingtypes.NewParamKeyTable()
Tools
golangci-lint

85-85: SA1019: stakingtypes.ParamKeyTable is deprecated: now params can be accessed on key 0x51 on the staking store. ParamTable for staking module

(staticcheck)

GitHub Check: lint

[failure] 85-85:
SA1019: stakingtypes.ParamKeyTable is deprecated: now params can be accessed on key 0x51 on the staking store. ParamTable for staking module (staticcheck)

case minttypes.ModuleName:
keyTable = minttypes.ParamKeyTable() //nolint:staticcheck
case distrtypes.ModuleName:
Expand Down
57 changes: 29 additions & 28 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ require (
github.com/cosmos/gogoproto v1.5.0
github.com/cosmos/iavl v1.1.2 // indirect
github.com/cosmos/ics23/go v0.10.0 // indirect
github.com/dvsekhvalnov/jose2go v1.6.0 // indirect
github.com/dvsekhvalnov/jose2go v1.7.0 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/gorilla/mux v1.8.1 // indirect
Expand All @@ -27,7 +27,7 @@ require (
github.com/spf13/viper v1.19.0
github.com/stretchr/testify v1.9.0
github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d // indirect
google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de // indirect
google.golang.org/genproto v0.0.0-20240401170217-c3f982113cda // indirect
google.golang.org/grpc v1.64.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
)
Expand All @@ -53,19 +53,21 @@ require (
github.com/cosmos/ibc-go/modules/light-clients/08-wasm v0.0.0-20240522213438-180501e6389d
github.com/cosmos/ibc-go/v8 v8.2.1
github.com/osmosis-labs/tokenfactory v0.0.0-20240310155926-981fbeb0fe42
github.com/skip-mev/feemarket v1.0.3
github.com/terra-money/alliance v0.4.3
)

require (
cloud.google.com/go v0.112.1 // indirect
cloud.google.com/go/compute v1.25.1 // indirect
cloud.google.com/go/compute/metadata v0.2.3 // indirect
cloud.google.com/go/iam v1.1.6 // indirect
cloud.google.com/go/storage v1.38.0 // indirect
cloud.google.com/go v0.114.0 // indirect
cloud.google.com/go/auth v0.5.1 // indirect
cloud.google.com/go/auth/oauth2adapt v0.2.2 // indirect
cloud.google.com/go/compute/metadata v0.3.0 // indirect
cloud.google.com/go/iam v1.1.8 // indirect
cloud.google.com/go/storage v1.41.0 // indirect
cosmossdk.io/collections v0.4.0 // indirect
cosmossdk.io/depinject v1.0.0-alpha.4 // indirect
cosmossdk.io/errors v1.0.1 // indirect
filippo.io/edwards25519 v1.0.0 // indirect
filippo.io/edwards25519 v1.1.0 // indirect
github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect
github.com/99designs/keyring v1.2.2 // indirect
github.com/CosmWasm/wasmvm v1.5.2 // indirect
Expand All @@ -91,8 +93,8 @@ require (
github.com/cosmos/btcutil v1.0.5 // indirect
github.com/cosmos/go-bip39 v1.0.0 // indirect
github.com/cosmos/ledger-cosmos-go v0.13.3 // indirect
github.com/creachadair/atomicfile v0.3.1 // indirect
github.com/creachadair/tomledit v0.0.24 // indirect
github.com/creachadair/atomicfile v0.3.3 // indirect
github.com/creachadair/tomledit v0.0.26 // indirect
github.com/danieljoos/wincred v1.1.2 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect
Expand All @@ -102,20 +104,20 @@ require (
github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 // indirect
github.com/distribution/reference v0.5.0 // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/emicklei/dot v1.6.1 // indirect
github.com/fatih/color v1.15.0 // indirect
github.com/emicklei/dot v1.6.2 // indirect
github.com/fatih/color v1.17.0 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/getsentry/sentry-go v0.27.0 // indirect
github.com/go-kit/kit v0.12.0 // indirect
github.com/go-kit/log v0.2.1 // indirect
github.com/go-logfmt/logfmt v0.6.0 // indirect
github.com/go-logr/logr v1.4.1 // indirect
github.com/go-logr/logr v1.4.2 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect
github.com/gogo/googleapis v1.4.1 // indirect
github.com/gogo/protobuf v1.3.3 // indirect
github.com/golang/glog v1.2.0 // indirect
github.com/golang/glog v1.2.1 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/mock v1.6.0 // indirect
github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb // indirect
Expand All @@ -125,7 +127,7 @@ require (
github.com/google/s2a-go v0.1.7 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.3.2 // indirect
github.com/googleapis/gax-go/v2 v2.12.3 // indirect
github.com/googleapis/gax-go/v2 v2.12.4 // indirect
github.com/gorilla/handlers v1.5.2 // indirect
github.com/gorilla/websocket v1.5.0 // indirect
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 // indirect
Expand All @@ -137,7 +139,7 @@ require (
github.com/hashicorp/go-metrics v0.5.3 // indirect
github.com/hashicorp/go-plugin v1.5.2 // indirect
github.com/hashicorp/go-safetemp v1.0.0 // indirect
github.com/hashicorp/go-version v1.6.0 // indirect
github.com/hashicorp/go-version v1.7.0 // indirect
github.com/hashicorp/golang-lru v1.0.2 // indirect
github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
Expand All @@ -152,7 +154,7 @@ require (
github.com/klauspost/compress v1.17.7 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/lib/pq v1.10.7 // indirect
github.com/lib/pq v1.10.9 // indirect
github.com/libp2p/go-buffer-pool v0.1.0 // indirect
github.com/linxGnu/grocksdb v1.8.14 // indirect
github.com/magiconair/properties v1.8.7 // indirect
Expand Down Expand Up @@ -196,20 +198,19 @@ require (
go.opentelemetry.io/otel/metric v1.24.0 // indirect
go.opentelemetry.io/otel/trace v1.24.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/crypto v0.23.0 // indirect
golang.org/x/crypto v0.24.0 // indirect
golang.org/x/exp v0.0.0-20240404231335-c0f41cb1a7a0 // indirect
golang.org/x/net v0.25.0 // indirect
golang.org/x/oauth2 v0.18.0 // indirect
golang.org/x/net v0.26.0 // indirect
golang.org/x/oauth2 v0.20.0 // indirect
golang.org/x/sync v0.7.0 // indirect
golang.org/x/sys v0.20.0 // indirect
golang.org/x/term v0.20.0 // indirect
golang.org/x/text v0.15.0 // indirect
golang.org/x/sys v0.21.0 // indirect
golang.org/x/term v0.21.0 // indirect
golang.org/x/text v0.16.0 // indirect
golang.org/x/time v0.5.0 // indirect
google.golang.org/api v0.171.0 // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240318140521-94a12d6c2237 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240515191416-fc5f0ca64291 // indirect
google.golang.org/protobuf v1.34.1 // indirect
google.golang.org/api v0.180.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240610135401-a8a62080eff3 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240604185151-ef581f913117 // indirect
google.golang.org/protobuf v1.34.2 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
gotest.tools/v3 v3.5.1 // indirect
Expand Down
Loading
Loading