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(gasless): wire the x/gasless module #102

Merged
merged 1 commit into from
Jul 16, 2024
Merged
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
13 changes: 7 additions & 6 deletions app/ante.go
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
package app

import (
errorsmod "cosmossdk.io/errors"
wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper"
wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/x/auth/ante"
conntypes "github.com/cosmos/ibc-go/v6/modules/core/03-connection/types"

ibcante "github.com/cosmos/ibc-go/v6/modules/core/ante"
ibckeeper "github.com/cosmos/ibc-go/v6/modules/core/keeper"

errorsmod "cosmossdk.io/errors"
wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper"
wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types"
"github.com/dymensionxyz/dymension-rdk/x/gasless"
gaslesskeeper "github.com/dymensionxyz/dymension-rdk/x/gasless/keeper"
cosmosante "github.com/evmos/evmos/v12/app/ante/cosmos"
)

Expand All @@ -23,6 +23,7 @@ type HandlerOptions struct {
IBCKeeper *ibckeeper.Keeper
WasmConfig *wasmtypes.WasmConfig
TxCounterStoreKey storetypes.StoreKey
GaslessKeeper gaslesskeeper.Keeper
}

func GetAnteDecorators(options HandlerOptions) []sdk.AnteDecorator {
Expand All @@ -47,7 +48,7 @@ func GetAnteDecorators(options HandlerOptions) []sdk.AnteDecorator {

ante.NewValidateMemoDecorator(options.AccountKeeper),
ante.NewConsumeGasForTxSizeDecorator(options.AccountKeeper),
ante.NewDeductFeeDecorator(options.AccountKeeper, options.BankKeeper, options.FeegrantKeeper, options.TxFeeChecker),
gasless.NewDeductFeeDecorator(options.AccountKeeper, options.BankKeeper, options.FeegrantKeeper, options.TxFeeChecker, options.GaslessKeeper),
ante.NewSetPubKeyDecorator(options.AccountKeeper), // SetPubKeyDecorator must be called before all signature verification decorators
ante.NewValidateSigCountDecorator(options.AccountKeeper),
ante.NewSigGasConsumeDecorator(options.AccountKeeper, sigGasConsumer),
Expand Down
34 changes: 31 additions & 3 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ import (
"github.com/cosmos/cosmos-sdk/x/authz"
authzkeeper "github.com/cosmos/cosmos-sdk/x/authz/keeper"
authzmodule "github.com/cosmos/cosmos-sdk/x/authz/module"
gaslessmodule "github.com/dymensionxyz/dymension-rdk/x/gasless"
gaslesskeeper "github.com/dymensionxyz/dymension-rdk/x/gasless/keeper"
gaslesstypes "github.com/dymensionxyz/dymension-rdk/x/gasless/types"
"github.com/gorilla/mux"
"github.com/rakyll/statik/fs"
abci "github.com/tendermint/tendermint/abci/types"
Expand Down Expand Up @@ -145,7 +148,7 @@ var (
ibchost.StoreKey, upgradetypes.StoreKey,
epochstypes.StoreKey, hubgentypes.StoreKey,
ibctransfertypes.StoreKey, capabilitytypes.StoreKey,
wasmtypes.StoreKey,
wasmtypes.StoreKey, gaslesstypes.StoreKey,
hubtypes.StoreKey,
}
)
Expand Down Expand Up @@ -185,6 +188,7 @@ var (
gov.NewAppModuleBasic(getGovProposalHandlers()),
params.AppModuleBasic{},
feegrantmodule.AppModuleBasic{},
gaslessmodule.AppModuleBasic{},
upgrade.AppModuleBasic{},
ibc.AppModuleBasic{},
ibctransfer.AppModuleBasic{},
Expand All @@ -206,6 +210,7 @@ var (
ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner},
wasmtypes.ModuleName: {authtypes.Burner},
hubgentypes.ModuleName: {authtypes.Minter},
gaslesstypes.ModuleName: nil,
}

// module accounts that are allowed to receive tokens
Expand Down Expand Up @@ -264,6 +269,7 @@ type App struct {
TransferKeeper ibctransferkeeper.Keeper
WasmKeeper wasmkeeper.Keeper
FeeGrantKeeper feegrantkeeper.Keeper
GaslessKeeper gaslesskeeper.Keeper

// make scoped keepers public for test purposes
ScopedIBCKeeper capabilitykeeper.ScopedKeeper
Expand Down Expand Up @@ -403,8 +409,15 @@ func NewRollapp(
)

app.DistrKeeper = distrkeeper.NewKeeper(
appCodec, keys[distrtypes.StoreKey], app.GetSubspace(distrtypes.ModuleName), app.AccountKeeper, app.BankKeeper,
&stakingKeeper, &app.SequencersKeeper, authtypes.FeeCollectorName, nil, // TODO: upgrade to https://github.com/dymensionxyz/dymension-rdk/pull/476
appCodec,
keys[distrtypes.StoreKey],
app.GetSubspace(distrtypes.ModuleName),
app.AccountKeeper,
app.BankKeeper,
&stakingKeeper,
&app.SequencersKeeper,
authtypes.FeeCollectorName,
// TODO: upgrade to https://github.com/dymensionxyz/dymension-rdk/pull/476
Copy link
Contributor

Choose a reason for hiding this comment

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

todo can be removed

)

app.FeeGrantKeeper = feegrantkeeper.NewKeeper(appCodec, keys[feegrant.StoreKey], app.AccountKeeper)
Expand Down Expand Up @@ -545,6 +558,15 @@ func NewRollapp(
wasmOpts...,
)

app.GaslessKeeper = gaslesskeeper.NewKeeper(
appCodec,
keys[gaslesstypes.StoreKey],
app.GetSubspace(gaslesstypes.ModuleName),
app.interfaceRegistry,
app.BankKeeper,
&app.WasmKeeper,
)

wasmStack := wasm.NewIBCHandler(app.WasmKeeper, app.IBCKeeper.ChannelKeeper, app.IBCKeeper.ChannelKeeper)

// Create static IBC router, add transfer route, then set and seal it
Expand All @@ -568,6 +590,7 @@ func NewRollapp(
bank.NewAppModule(appCodec, app.BankKeeper, app.AccountKeeper),
capability.NewAppModule(appCodec, *app.CapabilityKeeper),
feegrantmodule.NewAppModule(appCodec, app.AccountKeeper, app.BankKeeper, app.FeeGrantKeeper, app.interfaceRegistry),
gaslessmodule.NewAppModule(appCodec, app.GaslessKeeper),
gov.NewAppModule(appCodec, app.GovKeeper, app.AccountKeeper, app.BankKeeper),
mint.NewAppModule(appCodec, app.MintKeeper, app.AccountKeeper, app.BankKeeper),
distr.NewAppModule(appCodec, app.DistrKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper),
Expand Down Expand Up @@ -606,6 +629,7 @@ func NewRollapp(
govtypes.ModuleName,
genutiltypes.ModuleName,
feegrant.ModuleName,
gaslesstypes.ModuleName,
epochstypes.ModuleName,
paramstypes.ModuleName,
hubgentypes.ModuleName,
Expand All @@ -627,6 +651,7 @@ func NewRollapp(
minttypes.ModuleName,
genutiltypes.ModuleName,
feegrant.ModuleName,
gaslesstypes.ModuleName,
epochstypes.ModuleName,
paramstypes.ModuleName,
upgradetypes.ModuleName,
Expand Down Expand Up @@ -662,6 +687,7 @@ func NewRollapp(
upgradetypes.ModuleName,
ibctransfertypes.ModuleName,
feegrant.ModuleName,
gaslesstypes.ModuleName,
hubgentypes.ModuleName,
hubtypes.ModuleName,
wasm.ModuleName,
Expand Down Expand Up @@ -756,6 +782,7 @@ func (app *App) setAnteHandler(txConfig client.TxConfig, wasmConfig wasmtypes.Wa
IBCKeeper: app.IBCKeeper,
WasmConfig: &wasmConfig,
TxCounterStoreKey: app.keys[wasmtypes.StoreKey],
GaslessKeeper: app.GaslessKeeper,
},
)
if err != nil {
Expand Down Expand Up @@ -987,6 +1014,7 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino
paramsKeeper.Subspace(ibctransfertypes.ModuleName)
paramsKeeper.Subspace(ibchost.ModuleName)
paramsKeeper.Subspace(hubgentypes.ModuleName)
paramsKeeper.Subspace(gaslesstypes.ModuleName)

paramsKeeper.Subspace(wasmtypes.ModuleName)
return paramsKeeper
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ require (
github.com/bcdevtools/wasm-block-explorer-rpc-cosmos v1.1.1
github.com/cosmos/cosmos-sdk v0.46.16
github.com/cosmos/ibc-go/v6 v6.3.0
github.com/dymensionxyz/dymension-rdk v1.6.1-0.20240625180315-c98e3e67c156
github.com/dymensionxyz/dymension-rdk v1.6.1-0.20240708144829-21faaaf4ce25
github.com/dymensionxyz/dymint v1.1.3-rc04
github.com/ethereum/go-ethereum v1.12.0
github.com/evmos/evmos/v12 v12.1.6
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -557,8 +557,8 @@ github.com/dvsekhvalnov/jose2go v1.5.0 h1:3j8ya4Z4kMCwT5nXIKFSV84YS+HdqSSO0VsTQx
github.com/dvsekhvalnov/jose2go v1.5.0/go.mod h1:QsHjhyTlD/lAVqn/NSbVZmSCGeDehTB/mPZadG+mhXU=
github.com/dymensionxyz/cosmosclient v0.4.2-beta h1:sokBefcN1tIOlUKmB8Q2E9XMJ93LueqtFThiM/kA4DI=
github.com/dymensionxyz/cosmosclient v0.4.2-beta/go.mod h1:GQQu3ITEjWfi5ULR2B6X2i2YZNennY1yzcT5qdL4MGI=
github.com/dymensionxyz/dymension-rdk v1.6.1-0.20240625180315-c98e3e67c156 h1:GuMpR4LGwHVdBTZZ6+wMtJeq1EU06/JlD+B9QlRevqA=
github.com/dymensionxyz/dymension-rdk v1.6.1-0.20240625180315-c98e3e67c156/go.mod h1:M7YD1jsbAUYlnpfE0cj0MP0esKI3J6NsrVFAit+Rx+8=
github.com/dymensionxyz/dymension-rdk v1.6.1-0.20240708144829-21faaaf4ce25 h1:G0IDuzZGfWgl2mdvmsPTl+yCD5aaymnaG6N2XAB9t8A=
github.com/dymensionxyz/dymension-rdk v1.6.1-0.20240708144829-21faaaf4ce25/go.mod h1:M7YD1jsbAUYlnpfE0cj0MP0esKI3J6NsrVFAit+Rx+8=
github.com/dymensionxyz/dymension/v3 v3.1.0-rc03.0.20240411195658-f7cd96f53b56 h1:cmpJYdRviuUfmlJdHrcAND8Jd6JIY4rp63bWAQzPr54=
github.com/dymensionxyz/dymension/v3 v3.1.0-rc03.0.20240411195658-f7cd96f53b56/go.mod h1:3Pfrr8j/BR9ztNKztGfC5PqDiO6CcrzMLCJtFtPEVW4=
github.com/dymensionxyz/dymint v1.1.3-rc04 h1:RqDF8bxB73mYmxHKnVNGeTnTsZihAwV6AElIgIDL5Xw=
Expand Down
Loading