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: interachain sudo callback refactoring #313

Merged
merged 7 commits into from
Sep 19, 2023
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
11 changes: 8 additions & 3 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ func New(
app.BankKeeper,
scopedTransferKeeper,
app.FeeKeeper,
app.ContractManagerKeeper,
contractmanager.NewSudoLimitWrapper(app.ContractManagerKeeper, &app.WasmKeeper),
)

app.RouterKeeper.SetTransferKeeper(app.TransferKeeper.Keeper)
Expand Down Expand Up @@ -660,8 +660,10 @@ func New(
memKeys[interchaintxstypes.MemStoreKey],
app.IBCKeeper.ChannelKeeper,
app.ICAControllerKeeper,
app.ContractManagerKeeper,
contractmanager.NewSudoLimitWrapper(app.ContractManagerKeeper, &app.WasmKeeper),
app.FeeKeeper,
app.BankKeeper,
app.FeeBurnerKeeper,
)

app.CronKeeper = *cronkeeper.NewKeeper(appCodec, keys[crontypes.StoreKey], keys[crontypes.MemStoreKey], app.AccountKeeper)
Expand Down Expand Up @@ -699,7 +701,10 @@ func New(
if len(enabledProposals) != 0 {
app.AdminmoduleKeeper.Router().AddRoute(wasm.RouterKey, wasm.NewWasmProposalHandler(app.WasmKeeper, enabledProposals))
}
transferIBCModule := transferSudo.NewIBCModule(app.TransferKeeper)
transferIBCModule := transferSudo.NewIBCModule(
app.TransferKeeper,
contractmanager.NewSudoLimitWrapper(app.ContractManagerKeeper, &app.WasmKeeper),
)
// receive call order: wasmHooks#OnRecvPacketOverride(transferIbcModule#OnRecvPacket())
ibcHooksMiddleware := ibchooks.NewIBCMiddleware(&transferIBCModule, &app.HooksICS4Wrapper)
app.HooksTransferIBCModule = &ibcHooksMiddleware
Expand Down
3 changes: 2 additions & 1 deletion app/upgrades/sdk47/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ func migrateCronParams(ctx sdk.Context, paramsKeepers paramskeeper.Keeper, store
func migrateFeeRefunderParams(ctx sdk.Context, paramsKeepers paramskeeper.Keeper, storeKey storetypes.StoreKey, codec codec.Codec) error {
store := ctx.KVStore(storeKey)
var currParams feerefundertypes.Params
subspace, _ := paramsKeepers.GetSubspace(crontypes.StoreKey)
subspace, _ := paramsKeepers.GetSubspace(feerefundertypes.StoreKey)
subspace.GetParamSet(ctx, &currParams)

if err := currParams.Validate(); err != nil {
Expand Down Expand Up @@ -197,6 +197,7 @@ func migrateInterchainTxsParams(ctx sdk.Context, paramsKeepers paramskeeper.Keep
var currParams interchaintxstypes.Params
subspace, _ := paramsKeepers.GetSubspace(interchaintxstypes.StoreKey)
subspace.GetParamSet(ctx, &currParams)
currParams.RegisterFee = interchaintxstypes.DefaultRegisterFee

if err := currParams.Validate(); err != nil {
return err
Expand Down
21 changes: 0 additions & 21 deletions neutronutils/errors/errors.go

This file was deleted.

11 changes: 0 additions & 11 deletions neutronutils/utils.go

This file was deleted.

8 changes: 2 additions & 6 deletions proto/neutron/contractmanager/failure.proto
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ message Failure {
string address = 1;
// Id of the failure under specific address
uint64 id = 2;
// Acknowledgement type
string ack_type = 3;
// IBC Packet
ibc.core.channel.v1.Packet packet = 4;
// Acknowledgement
ibc.core.channel.v1.Acknowledgement ack = 5;
// Serialized MessageSudoCallback with Packet and Ack(if exists)
bytes sudo_payload = 3;
}
3 changes: 3 additions & 0 deletions proto/neutron/interchaintxs/v1/params.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ syntax = "proto3";
package neutron.interchaintxs;

import "gogoproto/gogo.proto";
import "cosmos/base/v1beta1/coin.proto";

option go_package = "github.com/neutron-org/neutron/x/interchaintxs/types";

Expand All @@ -10,4 +11,6 @@ message Params {
option (gogoproto.goproto_stringer) = false;
// Defines maximum amount of messages to be passed in MsgSubmitTx
uint64 msg_submit_tx_max_messages = 1;
// Defines a minimum fee required to register interchain account
repeated cosmos.base.v1beta1.Coin register_fee = 2 [ (gogoproto.nullable) = false ];
}
5 changes: 5 additions & 0 deletions proto/neutron/interchaintxs/v1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package neutron.interchaintxs.v1;
option go_package = "github.com/neutron-org/neutron/x/interchaintxs/types";

import "cosmos_proto/cosmos.proto";
import "cosmos/base/v1beta1/coin.proto";
import "gogoproto/gogo.proto";
import "google/api/http.proto";
import "google/api/annotations.proto";
Expand All @@ -26,6 +27,10 @@ message MsgRegisterInterchainAccount {
string connection_id = 2 [ (gogoproto.moretags) = "yaml:\"connection_id\"" ];
string interchain_account_id = 3
[ (gogoproto.moretags) = "yaml:\"interchain_account_id\"" ];
repeated cosmos.base.v1beta1.Coin register_fee = 4 [
(gogoproto.nullable) = false,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];
sotnikov-s marked this conversation as resolved.
Show resolved Hide resolved
}

// MsgRegisterInterchainAccountResponse is the response type for
Expand Down
13 changes: 11 additions & 2 deletions testutil/interchaintxs/keeper/interchaintxs.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,14 @@ import (
"github.com/neutron-org/neutron/x/interchaintxs/types"
)

func InterchainTxsKeeper(t testing.TB, managerKeeper types.ContractManagerKeeper, refunderKeeper types.FeeRefunderKeeper, icaControllerKeeper types.ICAControllerKeeper, channelKeeper types.ChannelKeeper) (*keeper.Keeper, sdk.Context, *storetypes.KVStoreKey) {
func InterchainTxsKeeper(
t testing.TB,
managerKeeper types.WasmKeeper,
refunderKeeper types.FeeRefunderKeeper,
icaControllerKeeper types.ICAControllerKeeper,
channelKeeper types.ChannelKeeper,
bankKeeper types.BankKeeper,
feeburnerKeeper types.FeeBurnerKeeper) (*keeper.Keeper, sdk.Context) {
storeKey := sdk.NewKVStoreKey(types.StoreKey)
memStoreKey := storetypes.NewMemoryStoreKey(types.MemStoreKey)

Expand All @@ -38,6 +45,8 @@ func InterchainTxsKeeper(t testing.TB, managerKeeper types.ContractManagerKeeper
icaControllerKeeper,
managerKeeper,
refunderKeeper,
bankKeeper,
feeburnerKeeper,
)

ctx := sdk.NewContext(stateStore, tmproto.Header{}, false, log.NewNopLogger())
Expand All @@ -46,5 +55,5 @@ func InterchainTxsKeeper(t testing.TB, managerKeeper types.ContractManagerKeeper
err := k.SetParams(ctx, types.DefaultParams())
require.NoError(t, err)

return k, ctx, storeKey
return k, ctx
}
27 changes: 27 additions & 0 deletions testutil/interchaintxs/keeper/sudo_middleware.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package keeper

import (
tmdb "github.com/cometbft/cometbft-db"
"github.com/cometbft/cometbft/libs/log"
tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
"github.com/cosmos/cosmos-sdk/store"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/neutron-org/neutron/x/contractmanager"
"github.com/neutron-org/neutron/x/contractmanager/types"
"github.com/stretchr/testify/require"
"testing"
)

func NewSudoLimitWrapper(t testing.TB, cmKeeper types.ContractManagerKeeper, wasmKeeper types.WasmKeeper) (types.WasmKeeper, sdk.Context, *storetypes.KVStoreKey) {
storeKey := sdk.NewKVStoreKey(types.StoreKey)
db := tmdb.NewMemDB()
stateStore := store.NewCommitMultiStore(db)
stateStore.MountStoreWithDB(storeKey, storetypes.StoreTypeIAVL, db)
require.NoError(t, stateStore.LoadLatestVersion())

limitWrapper := contractmanager.NewSudoLimitWrapper(cmKeeper, wasmKeeper)
ctx := sdk.NewContext(stateStore, tmproto.Header{}, false, log.NewNopLogger())

return limitWrapper, ctx, storeKey
}
50 changes: 50 additions & 0 deletions testutil/mocks/contractmanager/types/expected_keepers.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

46 changes: 0 additions & 46 deletions testutil/mocks/interchainqueries/types/expected_keepers.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading