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(ante): whitelisted relayers #148

Merged
merged 4 commits into from
Oct 29, 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
16 changes: 12 additions & 4 deletions app/ante.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@ import (
"github.com/cosmos/cosmos-sdk/x/auth/ante"
conntypes "github.com/cosmos/ibc-go/v6/modules/core/03-connection/types"
ibckeeper "github.com/cosmos/ibc-go/v6/modules/core/keeper"
rdkante "github.com/dymensionxyz/dymension-rdk/server/ante"
distrkeeper "github.com/dymensionxyz/dymension-rdk/x/dist/keeper"
"github.com/dymensionxyz/dymension-rdk/x/gasless"
gaslesskeeper "github.com/dymensionxyz/dymension-rdk/x/gasless/keeper"
seqkeeper "github.com/dymensionxyz/dymension-rdk/x/sequencers/keeper"
cosmosante "github.com/evmos/evmos/v12/app/ante/cosmos"
evmostypes "github.com/evmos/evmos/v12/types"
evmtypes "github.com/evmos/evmos/v12/x/evm/types"
tmlog "github.com/tendermint/tendermint/libs/log"

"github.com/dymensionxyz/dymension-rdk/x/gasless"
gaslesskeeper "github.com/dymensionxyz/dymension-rdk/x/gasless/keeper"
)

// HandlerOptions are the options required for constructing a default SDK AnteHandler.
Expand All @@ -31,6 +33,8 @@ type HandlerOptions struct {
WasmConfig *wasmtypes.WasmConfig
TxCounterStoreKey storetypes.StoreKey
GaslessKeeper gaslesskeeper.Keeper
DistrKeeper distrkeeper.Keeper
SequencersKeeper seqkeeper.Keeper
}

// NewAnteHandler returns an AnteHandler that checks and increments sequence
Expand Down Expand Up @@ -117,7 +121,11 @@ func cosmosHandler(options HandlerOptions, sigChecker sdk.AnteDecorator) sdk.Ant
ante.NewValidateMemoDecorator(options.AccountKeeper),
NewCreateAccountDecorator(options.AccountKeeper.(accountKeeper)),
ante.NewConsumeGasForTxSizeDecorator(options.AccountKeeper),
NewBypassIBCFeeDecorator(gasless.NewDeductFeeDecorator(options.AccountKeeper, options.BankKeeper, options.FeegrantKeeper, options.TxFeeChecker, options.GaslessKeeper)),
rdkante.NewBypassIBCFeeDecorator(
gasless.NewDeductFeeDecorator(options.AccountKeeper, options.BankKeeper, options.FeegrantKeeper, options.TxFeeChecker, options.GaslessKeeper),
options.DistrKeeper,
options.SequencersKeeper,
),
ante.NewSetPubKeyDecorator(options.AccountKeeper), // SetPubKeyDecorator must be called before all signature verification decorators
ante.NewValidateSigCountDecorator(options.AccountKeeper),
ante.NewSigGasConsumeDecorator(options.AccountKeeper, sigGasConsumer),
Expand Down
8 changes: 6 additions & 2 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
authzkeeper "github.com/cosmos/cosmos-sdk/x/authz/keeper"
authzmodule "github.com/cosmos/cosmos-sdk/x/authz/module"
evmosante "github.com/evmos/evmos/v12/app/ante"
"github.com/gogo/protobuf/proto"
"github.com/gorilla/mux"
"github.com/rakyll/statik/fs"
abci "github.com/tendermint/tendermint/abci/types"
Expand Down Expand Up @@ -472,7 +473,10 @@ func NewRollapp(
)

app.SequencersKeeper = *seqkeeper.NewKeeper(
appCodec, keys[seqtypes.StoreKey], app.GetSubspace(seqtypes.ModuleName),
appCodec,
keys[seqtypes.StoreKey],
app.GetSubspace(seqtypes.ModuleName),
authtypes.NewModuleAddress(seqtypes.ModuleName).String(),
)

app.IBCKeeper = ibckeeper.NewKeeper(
Expand Down Expand Up @@ -840,7 +844,7 @@ func NewRollapp(

// Admission handler for consensus messages
app.setAdmissionHandler(consensus.AllowedMessagesHandler([]string{
// proto.MessageName(&banktypes.MsgSend{}), // Example of message allowed as consensus message
proto.MessageName(new(seqtypes.ConsensusMsgUpsertSequencer)),
}))

if loadLatest {
Expand Down
60 changes: 0 additions & 60 deletions app/bypass_ibc_fee_decorator.go

This file was deleted.

3 changes: 2 additions & 1 deletion app/create_account_decorator.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
authante "github.com/cosmos/cosmos-sdk/x/auth/ante"
authsigning "github.com/cosmos/cosmos-sdk/x/auth/signing"
"github.com/cosmos/cosmos-sdk/x/auth/types"
rdkante "github.com/dymensionxyz/dymension-rdk/server/ante"
)

type createAccountDecorator struct {
Expand Down Expand Up @@ -39,7 +40,7 @@ func (cad createAccountDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulat
return ctx, err
}

ibcRelayerMsg := isIBCRelayerMsg(tx.GetMsgs())
ibcRelayerMsg := rdkante.IsIBCRelayerMsg(tx.GetMsgs())

for i, pk := range pubkeys {
if pk == nil {
Expand Down
3 changes: 2 additions & 1 deletion app/sigcheck_decorator.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
authante "github.com/cosmos/cosmos-sdk/x/auth/ante"
authsigning "github.com/cosmos/cosmos-sdk/x/auth/signing"
rdkante "github.com/dymensionxyz/dymension-rdk/server/ante"
)

type sigCheckDecorator struct {
Expand Down Expand Up @@ -41,7 +42,7 @@ func (svd sigCheckDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate boo
return ctx, errorsmod.Wrapf(sdkerrors.ErrUnauthorized, "invalid number of signer; expected: %d, got %d", len(signerAddrs), len(sigs))
}

ibcRelayerMsg := isIBCRelayerMsg(tx.GetMsgs())
ibcRelayerMsg := rdkante.IsIBCRelayerMsg(tx.GetMsgs())

for i, sig := range sigs {
acc, err := authante.GetSignerAcc(ctx, svd.ak, signerAddrs[i])
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ require (
github.com/cosmos/gogoproto v1.5.0
github.com/cosmos/ibc-go/v6 v6.3.0
github.com/dvsekhvalnov/jose2go v1.5.0
github.com/dymensionxyz/dymension-rdk v1.6.1-0.20241020152926-b250db7af580
github.com/dymensionxyz/dymint v1.2.0-rc01.0.20241015102238-a827c3784461
github.com/dymensionxyz/dymension-rdk v1.6.1-0.20241029165002-545051749bc0
github.com/dymensionxyz/dymint v1.2.0-rc01.0.20241024144934-db109b2859b4
github.com/ethereum/go-ethereum v1.12.0
github.com/evmos/evmos/v12 v12.1.6
github.com/gogo/protobuf v1.3.3
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -573,10 +573,10 @@ github.com/dymensionxyz/cometbft v0.34.29-0.20241008141942-63af9d24107f h1:CclWJ
github.com/dymensionxyz/cometbft v0.34.29-0.20241008141942-63af9d24107f/go.mod h1:L9shMfbkZ8B+7JlwANEr+NZbBcn+hBpwdbeYvA5rLCw=
github.com/dymensionxyz/cosmosclient v0.4.2-beta.0.20240821081230-b4018b2bac13 h1:u5yeve5jZR6TdRjjR+vYT/8PWKbhwCZxUmAu+/Tnxyg=
github.com/dymensionxyz/cosmosclient v0.4.2-beta.0.20240821081230-b4018b2bac13/go.mod h1:jabDQYXrccscSE0fXkh7eQFYPWJCRiuWKonFGObVq6s=
github.com/dymensionxyz/dymension-rdk v1.6.1-0.20241020152926-b250db7af580 h1:bgECFCjc/8lVq9/UQ4qCTdD/znUgKEX7a0QBOcGuuNg=
github.com/dymensionxyz/dymension-rdk v1.6.1-0.20241020152926-b250db7af580/go.mod h1:m9D/CACMkMAXKFeuU+1lkUIPWpMFb0EvGl7M5vV0HoA=
github.com/dymensionxyz/dymint v1.2.0-rc01.0.20241015102238-a827c3784461 h1:ZNh5s2dmfcgPE9g6OlhHBFtygiAxCRr+wPKSgpSo/Bw=
github.com/dymensionxyz/dymint v1.2.0-rc01.0.20241015102238-a827c3784461/go.mod h1:FNVdsvVhveAOeL0Mj9VIfGkAUKhGskEr0iRnoM+MAkU=
github.com/dymensionxyz/dymension-rdk v1.6.1-0.20241029165002-545051749bc0 h1:Pshmw95Ej/RBg+ZTgMxpdGB/Bpis2tKEjSmqwVHgaXo=
github.com/dymensionxyz/dymension-rdk v1.6.1-0.20241029165002-545051749bc0/go.mod h1:HH7sGM/4MSI8OLces8axABf7K0ppXNok+G2nxC/l5YI=
github.com/dymensionxyz/dymint v1.2.0-rc01.0.20241024144934-db109b2859b4 h1:DpfHfiqNJ0QgnPNq/nx2fAUDWwLlWORQ605uQyPPODU=
github.com/dymensionxyz/dymint v1.2.0-rc01.0.20241024144934-db109b2859b4/go.mod h1:FNVdsvVhveAOeL0Mj9VIfGkAUKhGskEr0iRnoM+MAkU=
github.com/dymensionxyz/evmos/v12 v12.1.6-dymension-v0.4.2 h1:aVP3off7u2vsvRH7lHAUPTLdf9/AfnzC/rvvi0wC/co=
github.com/dymensionxyz/evmos/v12 v12.1.6-dymension-v0.4.2/go.mod h1:CI6D89pkoiIm4BjoMFNnEaCLdKBEobLuwvhS0c1zh7Y=
github.com/dymensionxyz/gerr-cosmos v1.0.0 h1:oi91rgOkpJWr41oX9JOyjvvBnhGY54tj513x8VlDAEc=
Expand Down
Loading