diff --git a/app/app.go b/app/app.go index 1795601f6..532d21582 100644 --- a/app/app.go +++ b/app/app.go @@ -1,17 +1,19 @@ package app import ( + "fmt" "io" "os" "path/filepath" + "strings" nodeservice "github.com/cosmos/cosmos-sdk/client/grpc/node" authante "github.com/cosmos/cosmos-sdk/x/auth/ante" authsims "github.com/cosmos/cosmos-sdk/x/auth/simulation" "github.com/cosmos/cosmos-sdk/x/consensus" tendermint "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint" - wasm "github.com/cosmos/ibc-go/v7/modules/light-clients/08-wasm" - wasmtypes "github.com/cosmos/ibc-go/v7/modules/light-clients/08-wasm/types" + wasm08 "github.com/cosmos/ibc-go/v7/modules/light-clients/08-wasm" + wasm08types "github.com/cosmos/ibc-go/v7/modules/light-clients/08-wasm/types" "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/client" @@ -98,6 +100,10 @@ import ( minttypes "github.com/notional-labs/centauri/v3/x/mint/types" ibctestingtypes "github.com/cosmos/ibc-go/v7/testing/types" + + "github.com/CosmWasm/wasmd/x/wasm" + wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper" + wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" ) const ( @@ -106,6 +112,33 @@ const ( ForkHeight = 244008 ) +var ( + // If EnabledSpecificProposals is "", and this is "true", then enable all x/wasm proposals. + // If EnabledSpecificProposals is "", and this is not "true", then disable all x/wasm proposals. + ProposalsEnabled = "false" + // If set to non-empty string it must be comma-separated list of values that are all a subset + // of "EnableAllProposals" (takes precedence over ProposalsEnabled) + // https://github.com/CosmWasm/wasmd/blob/02a54d33ff2c064f3539ae12d75d027d9c665f05/x/wasm/internal/types/proposal.go#L28-L34 + EnableSpecificProposals = "" +) + +// GetEnabledProposals parses the ProposalsEnabled / EnableSpecificProposals values to +// produce a list of enabled proposals to pass into wasmd app. +func GetEnabledProposals() []wasm.ProposalType { + if EnableSpecificProposals == "" { + if ProposalsEnabled == "true" { + return wasm.EnableAllProposals + } + return wasm.DisableAllProposals + } + chunks := strings.Split(EnableSpecificProposals, ",") + proposals, err := wasm.ConvertToProposals(chunks) + if err != nil { + panic(err) + } + return proposals +} + // this line is used by starport scaffolding # stargate/wasm/app/enabledProposals func getGovProposalHandlers() []govclient.ProposalHandler { @@ -155,6 +188,7 @@ var ( vesting.AppModuleBasic{}, tendermint.AppModuleBasic{}, mint.AppModuleBasic{}, + wasm08.AppModuleBasic{}, wasm.AppModuleBasic{}, router.AppModuleBasic{}, transfermiddleware.AppModuleBasic{}, @@ -218,11 +252,13 @@ func NewCentauriApp( db dbm.DB, traceStore io.Writer, loadLatest bool, + enabledProposals []wasm.ProposalType, skipUpgradeHeights map[int64]bool, homePath string, invCheckPeriod uint, encodingConfig EncodingConfig, appOpts servertypes.AppOptions, + wasmOpts []wasm.Option, baseAppOptions ...func(*baseapp.BaseApp), ) *CentauriApp { appCodec := encodingConfig.Marshaler @@ -299,7 +335,8 @@ func NewCentauriApp( transferModule, icqModule, consensus.NewAppModule(appCodec, app.ConsensusParamsKeeper), - wasm.NewAppModule(app.Wasm08Keeper), + wasm08.NewAppModule(app.Wasm08Keeper), + wasm.NewAppModule(appCodec, &app.WasmKeeper, app.StakingKeeper, app.AccountKeeper, app.BankKeeper, app.MsgServiceRouter(), app.GetSubspace(wasmtypes.ModuleName)), routerModule, transfermiddlewareModule, alliancemodule.NewAppModule(appCodec, app.AllianceKeeper, app.StakingKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry), @@ -333,7 +370,8 @@ func NewCentauriApp( group.ModuleName, paramstypes.ModuleName, consensusparamtypes.ModuleName, - wasmtypes.ModuleName, + wasm08types.ModuleName, + wasm.ModuleName, alliancemoduletypes.ModuleName, // this line is used by starport scaffolding # stargate/app/beginBlockers ) @@ -361,7 +399,8 @@ func NewCentauriApp( ibctransfertypes.ModuleName, icqtypes.ModuleName, consensusparamtypes.ModuleName, - wasmtypes.ModuleName, + wasm08types.ModuleName, + wasm.ModuleName, alliancemoduletypes.ModuleName, ) @@ -393,7 +432,8 @@ func NewCentauriApp( feegrant.ModuleName, group.ModuleName, consensusparamtypes.ModuleName, - wasmtypes.ModuleName, + wasm08types.ModuleName, + wasm.ModuleName, alliancemoduletypes.ModuleName, // this line is used by starport scaffolding # stargate/app/initGenesis ) @@ -447,6 +487,15 @@ func NewCentauriApp( )) app.SetEndBlocker(app.EndBlocker) + if manager := app.SnapshotManager(); manager != nil { + err := manager.RegisterExtensions( + wasmkeeper.NewWasmSnapshotter(app.CommitMultiStore(), &app.WasmKeeper), + ) + if err != nil { + panic(fmt.Errorf("failed to register snapshot extension: %s", err)) + } + } + if loadLatest { if err := app.LoadLatestVersion(); err != nil { tmos.Exit(err.Error()) diff --git a/app/helpers/test_helpers.go b/app/helpers/test_helpers.go index 4a0eed076..49d5ba954 100644 --- a/app/helpers/test_helpers.go +++ b/app/helpers/test_helpers.go @@ -6,6 +6,8 @@ import ( "testing" "time" + "github.com/CosmWasm/wasmd/x/wasm" + wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" dbm "github.com/cometbft/cometbft-db" abci "github.com/cometbft/cometbft/abci/types" "github.com/cometbft/cometbft/libs/log" @@ -61,7 +63,6 @@ func NewContextForApp(app centauri.CentauriApp) sdk.Context { func Setup(t *testing.T, isCheckTx bool, invCheckPeriod uint) *centauri.CentauriApp { t.Helper() - app, genesisState := setup(!isCheckTx, invCheckPeriod) if !isCheckTx { // InitChain must be called to stop deliverState from being nil @@ -81,7 +82,7 @@ func Setup(t *testing.T, isCheckTx bool, invCheckPeriod uint) *centauri.Centauri return app } -func setup(withGenesis bool, invCheckPeriod uint) (*centauri.CentauriApp, centauri.GenesisState) { +func setup(withGenesis bool, invCheckPeriod uint, opts ...wasm.Option) (*centauri.CentauriApp, centauri.GenesisState) { db := dbm.NewMemDB() encCdc := centauri.MakeEncodingConfig() app := centauri.NewCentauriApp( @@ -89,11 +90,13 @@ func setup(withGenesis bool, invCheckPeriod uint) (*centauri.CentauriApp, centau db, nil, true, + wasmtypes.EnableAllProposals, map[int64]bool{}, centauri.DefaultNodeHome, invCheckPeriod, encCdc, EmptyAppOptions{}, + opts, ) if withGenesis { return app, centauri.NewDefaultGenesisState() diff --git a/app/test_helpers.go b/app/test_helpers.go index 4bdec5ade..f9a593a1d 100644 --- a/app/test_helpers.go +++ b/app/test_helpers.go @@ -36,6 +36,9 @@ import ( banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" minttypes "github.com/notional-labs/centauri/v3/x/mint/types" + + "github.com/CosmWasm/wasmd/x/wasm" + wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" ) // DefaultConsensusParams defines the default Tendermint consensus params used in @@ -68,14 +71,18 @@ func setup(tb testing.TB, withGenesis bool, invCheckPeriod uint) (*CentauriApp, baseAppOpts := []func(*baseapp.BaseApp){baseapp.SetSnapshot(snapshotStore, types.SnapshotOptions{ KeepRecent: 2, })} + var wasmOpts []wasm.Option db := dbm.NewMemDB() app := NewCentauriApp( log.NewNopLogger(), - db, nil, true, map[int64]bool{}, + db, nil, true, + wasmtypes.EnableAllProposals, + map[int64]bool{}, nodeHome, invCheckPeriod, MakeEncodingConfig(), EmptyBaseAppOptions{}, + wasmOpts, baseAppOpts...) if withGenesis { return app, NewDefaultGenesisState() diff --git a/app/wasm.go b/app/wasm.go new file mode 100644 index 000000000..a01074f9e --- /dev/null +++ b/app/wasm.go @@ -0,0 +1,14 @@ +package app + +// AllCapabilities returns all capabilities available with the current wasmvm +// See https://github.com/CosmWasm/cosmwasm/blob/main/docs/CAPABILITIES-BUILT-IN.md +// This functionality is going to be moved upstream: https://github.com/CosmWasm/wasmvm/issues/425 +func AllCapabilities() []string { + return []string{ + "iterator", + "staking", + "stargate", + "cosmwasm_1_1", + "cosmwasm_1_2", + } +} diff --git a/cmd/centaurid/cmd/bech32_convert.go b/cmd/centaurid/cmd/bech32_convert.go new file mode 100644 index 000000000..35c4e9599 --- /dev/null +++ b/cmd/centaurid/cmd/bech32_convert.go @@ -0,0 +1,55 @@ +package cmd + +import ( + "github.com/cosmos/cosmos-sdk/types/bech32" + + "github.com/spf13/cobra" +) + +var flagBech32Prefix = "prefix" + +// AddBech32ConvertCommand returns bech32-convert cobra Command. +func AddBech32ConvertCommand() *cobra.Command { + cmd := &cobra.Command{ + Use: "bech32-convert [address]", + Short: "Convert any bech32 string to the centauri prefix", + Long: `Convert any bech32 string to the centauri prefix + +Example: + centaurid debug bech32-convert akash1a6zlyvpnksx8wr6wz8wemur2xe8zyh0ytz6d88 + + centaurid debug bech32-convert stride1673f0t8p893rqyqe420mgwwz92ac4qv6synvx2 --prefix osmo + `, + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + bech32prefix, err := cmd.Flags().GetString(flagBech32Prefix) + if err != nil { + return err + } + + _, bz, err := bech32.DecodeAndConvert(args[0]) + if err != nil { + return err + } + + bech32Addr, err := bech32.ConvertAndEncode(bech32prefix, bz) + if err != nil { + panic(err) + } + + cmd.Println(bech32Addr) + + return nil + }, + } + + cmd.Flags().StringP(flagBech32Prefix, "p", "centauri", "Bech32 Prefix to encode to") + + return cmd +} + +// addDebugCommands injects custom debug commands into another command as children. +func addDebugCommands(cmd *cobra.Command) *cobra.Command { + cmd.AddCommand(AddBech32ConvertCommand()) + return cmd +} diff --git a/cmd/centaurid/cmd/root.go b/cmd/centaurid/cmd/root.go index 955afcb44..50f53fb2c 100644 --- a/cmd/centaurid/cmd/root.go +++ b/cmd/centaurid/cmd/root.go @@ -5,6 +5,7 @@ import ( "io" "os" + "github.com/CosmWasm/wasmd/x/wasm" dbm "github.com/cometbft/cometbft-db" tmcli "github.com/cometbft/cometbft/libs/cli" "github.com/cometbft/cometbft/libs/log" @@ -176,6 +177,7 @@ func initRootCmd(rootCmd *cobra.Command, encodingConfig app.EncodingConfig) { genutilcli.ValidateGenesisCmd(app.ModuleBasics), AddGenesisAccountCmd(app.DefaultNodeHome), tmcli.NewCompletionCmd(rootCmd, true), + addDebugCommands(debug.Cmd()), debug.Cmd(), config.Cmd(), CovertPrefixAddr(), @@ -267,13 +269,17 @@ func (a appCreator) newApp(logger log.Logger, db dbm.DB, traceStore io.Writer, a baseappOptions := server.DefaultBaseappOptions(appOpts) + var emptyWasmOpts []wasm.Option newApp := app.NewCentauriApp( - logger, db, traceStore, true, skipUpgradeHeights, + logger, db, traceStore, true, + app.GetEnabledProposals(), + skipUpgradeHeights, cast.ToString(appOpts.Get(flags.FlagHome)), cast.ToUint(appOpts.Get(server.FlagInvCheckPeriod)), a.encCfg, // this line is used by starport scaffolding # stargate/root/appArgument appOpts, + emptyWasmOpts, baseappOptions..., ) @@ -291,6 +297,7 @@ func (a appCreator) appExport( if !ok || homePath == "" { return servertypes.ExportedApp{}, errors.New("application home not set") } + var emptyWasmOpts []wasm.Option if height != -1 { anApp = app.NewCentauriApp( @@ -298,11 +305,13 @@ func (a appCreator) appExport( db, traceStore, false, + app.GetEnabledProposals(), map[int64]bool{}, homePath, uint(1), a.encCfg, appOpts, + emptyWasmOpts, ) if err := anApp.LoadHeight(height); err != nil { @@ -314,11 +323,13 @@ func (a appCreator) appExport( db, traceStore, true, + app.GetEnabledProposals(), map[int64]bool{}, homePath, uint(1), a.encCfg, appOpts, + emptyWasmOpts, ) } diff --git a/custom/bank/bank_test.go b/custom/bank/bank_test.go new file mode 100644 index 000000000..84333f210 --- /dev/null +++ b/custom/bank/bank_test.go @@ -0,0 +1,133 @@ +package bank_test + +import ( + "testing" + + sdk "github.com/cosmos/cosmos-sdk/types" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + ibctransfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" + clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" + customibctesting "github.com/notional-labs/centauri/v3/app/ibctesting" + "github.com/stretchr/testify/suite" +) + +type CustomBankTestSuite struct { + suite.Suite + + coordinator *customibctesting.Coordinator + + // testing chains used for convenience and readability + chainA *customibctesting.TestChain + chainB *customibctesting.TestChain + chainC *customibctesting.TestChain +} + +func NewTransferPath(chainA, chainB *customibctesting.TestChain) *customibctesting.Path { + path := customibctesting.NewPath(chainA, chainB) + path.EndpointA.ChannelConfig.PortID = customibctesting.TransferPort + path.EndpointB.ChannelConfig.PortID = customibctesting.TransferPort + path.EndpointA.ChannelConfig.Version = ibctransfertypes.Version + path.EndpointB.ChannelConfig.Version = ibctransfertypes.Version + + return path +} + +func (suite *CustomBankTestSuite) SetupTest() { + suite.coordinator = customibctesting.NewCoordinator(suite.T(), 4) + suite.chainA = suite.coordinator.GetChain(customibctesting.GetChainID(1)) + suite.chainB = suite.coordinator.GetChain(customibctesting.GetChainID(2)) + suite.chainC = suite.coordinator.GetChain(customibctesting.GetChainID(3)) +} + +func TestBankTestSuite(t *testing.T) { + suite.Run(t, new(CustomBankTestSuite)) +} + +// TODO: use testsuite here. +func (suite *CustomBankTestSuite) TestTotalSupply() { + var ( + transferAmount = sdk.NewInt(1000000000) + // when transfer via sdk transfer from A (module) -> B (contract) + coinToSendToB = sdk.NewCoin(sdk.DefaultBondDenom, transferAmount) + timeoutHeight = clienttypes.NewHeight(1, 110) + ) + var ( + expChainBBalanceDiff sdk.Coin + path = NewTransferPath(suite.chainA, suite.chainB) + ) + + testCases := []struct { + name string + expChainABalanceDiff sdk.Coin + expTotalSupplyDiff sdk.Coins + malleate func() + }{ + { + "Total supply with no transfermiddleware setup", + sdk.NewCoin(sdk.DefaultBondDenom, transferAmount), + sdk.Coins{sdk.NewCoin("ibc/C053D637CCA2A2BA030E2C5EE1B28A16F71CCB0E45E8BE52766DC1B241B77878", transferAmount)}, + func() { + expChainBBalanceDiff = ibctransfertypes.GetTransferCoin(path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, coinToSendToB.Denom, transferAmount) + }, + }, + { + "Total supply with transfermiddleware setup", + sdk.NewCoin(sdk.DefaultBondDenom, transferAmount), + sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, transferAmount)), + func() { + // Add parachain token info + chainBtransMiddleware := suite.chainB.TransferMiddleware() + expChainBBalanceDiff = sdk.NewCoin(sdk.DefaultBondDenom, transferAmount) + err := chainBtransMiddleware.AddParachainIBCInfo(suite.chainB.GetContext(), "ibc/C053D637CCA2A2BA030E2C5EE1B28A16F71CCB0E45E8BE52766DC1B241B77878", "channel-0", sdk.DefaultBondDenom, sdk.DefaultBondDenom) + suite.Require().NoError(err) + }, + }, + } + for _, tc := range testCases { + suite.Run(tc.name, func() { + suite.SetupTest() // reset + + path = NewTransferPath(suite.chainA, suite.chainB) + suite.coordinator.Setup(path) + + tc.malleate() + + originalChainABalance := suite.chainA.AllBalances(suite.chainA.SenderAccount.GetAddress()) + // chainB.SenderAccount: 10000000000000000000stake + originalChainBBalance := suite.chainB.AllBalances(suite.chainB.SenderAccount.GetAddress()) + originalChainBTotalSupply, err := suite.chainB.GetBankKeeper().TotalSupply(suite.chainB.GetContext(), &banktypes.QueryTotalSupplyRequest{}) + suite.Require().NoError(err) + + msg := ibctransfertypes.NewMsgTransfer(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, coinToSendToB, suite.chainA.SenderAccount.GetAddress().String(), suite.chainB.SenderAccount.GetAddress().String(), timeoutHeight, 0, "") + _, err = suite.chainA.SendMsgs(msg) + suite.Require().NoError(err) + suite.Require().NoError(err, path.EndpointB.UpdateClient()) + + // then + suite.Require().Equal(1, len(suite.chainA.PendingSendPackets)) + suite.Require().Equal(0, len(suite.chainB.PendingSendPackets)) + + // and when relay to chain B and handle Ack on chain A + err = suite.coordinator.RelayAndAckPendingPackets(path) + suite.Require().NoError(err) + + // then + suite.Require().Equal(0, len(suite.chainA.PendingSendPackets)) + suite.Require().Equal(0, len(suite.chainB.PendingSendPackets)) + + // and source chain balance was decreased + newChainABalance := suite.chainA.AllBalances(suite.chainA.SenderAccount.GetAddress()) + suite.Require().Equal(originalChainABalance.Sub(tc.expChainABalanceDiff), newChainABalance) + + // and dest chain balance contains voucher + expBalance := originalChainBBalance.Add(expChainBBalanceDiff) + gotBalance := suite.chainB.AllBalances(suite.chainB.SenderAccount.GetAddress()) + suite.Require().Equal(expBalance, gotBalance) + suite.Require().NoError(err) + + totalSupply, err := suite.chainB.GetBankKeeper().TotalSupply(suite.chainB.GetContext(), &banktypes.QueryTotalSupplyRequest{}) + suite.Require().NoError(err) + suite.Require().Equal(totalSupply.Supply, originalChainBTotalSupply.Supply.Add(tc.expTotalSupplyDiff...)) + }) + } +} diff --git a/custom/bank/keeper/keeper.go b/custom/bank/keeper/keeper.go index 8bcf18014..f5a6c8392 100644 --- a/custom/bank/keeper/keeper.go +++ b/custom/bank/keeper/keeper.go @@ -23,7 +23,7 @@ import ( type Keeper struct { bankkeeper.BaseKeeper - tfmk transfermiddlewarekeeper.Keeper + tfmk banktypes.TransferMiddlewareKeeper ak alliancekeeper.Keeper sk banktypes.StakingKeeper acck accountkeeper.AccountKeeper @@ -36,12 +36,14 @@ func NewBaseKeeper( storeKey storetypes.StoreKey, ak accountkeeper.AccountKeeper, blockedAddrs map[string]bool, + tfmk *transfermiddlewarekeeper.Keeper, authority string, ) Keeper { keeper := Keeper{ BaseKeeper: bankkeeper.NewBaseKeeper(cdc, storeKey, ak, blockedAddrs, authority), // TODO: how to set authority? ak: alliancekeeper.Keeper{}, sk: stakingkeeper.Keeper{}, + tfmk: tfmk, acck: ak, } return keeper diff --git a/custom/bank/types/keeper_interfaces.go b/custom/bank/types/keeper_interfaces.go index 4fc751558..3dbd094aa 100644 --- a/custom/bank/types/keeper_interfaces.go +++ b/custom/bank/types/keeper_interfaces.go @@ -5,3 +5,7 @@ import sdk "github.com/cosmos/cosmos-sdk/types" type StakingKeeper interface { BondDenom(ctx sdk.Context) (res string) } + +type TransferMiddlewareKeeper interface { + GetTotalEscrowedToken(ctx sdk.Context) (coins sdk.Coins) +} diff --git a/go.mod b/go.mod index 67a8926d9..b62f8a844 100644 --- a/go.mod +++ b/go.mod @@ -5,8 +5,9 @@ go 1.19 require ( cosmossdk.io/math v1.0.1 cosmossdk.io/simapp v0.0.0-20230608160436-666c345ad23d + github.com/CosmWasm/wasmd v0.40.1 github.com/cometbft/cometbft v0.37.1 - github.com/cometbft/cometbft-db v0.7.0 + github.com/cometbft/cometbft-db v0.8.0 github.com/cosmos/cosmos-proto v1.0.0-beta.2 github.com/cosmos/cosmos-sdk v0.47.3 github.com/cosmos/gogoproto v1.4.10 @@ -25,6 +26,8 @@ require ( gotest.tools/v3 v3.4.0 ) +require github.com/linxGnu/grocksdb v1.7.16 // indirect + require ( cloud.google.com/go v0.110.0 // indirect cloud.google.com/go/compute v1.18.0 // indirect @@ -32,16 +35,18 @@ require ( cloud.google.com/go/iam v0.12.0 // indirect cloud.google.com/go/storage v1.29.0 // indirect cosmossdk.io/log v1.1.0 // indirect - github.com/CosmWasm/wasmvm v1.2.1 // indirect + github.com/CosmWasm/wasmvm v1.2.4 // indirect; indirect // safe because we're using permissioned cosmwasm github.com/aws/aws-sdk-go v1.44.203 // indirect github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect github.com/chzyer/readline v1.5.1 // indirect github.com/cockroachdb/apd/v2 v2.0.2 // indirect github.com/coinbase/rosetta-sdk-go/types v1.0.0 // indirect github.com/cosmos/ics23/go v0.9.1-0.20221207100636-b1abd8678aab // indirect + github.com/docker/distribution v2.8.2+incompatible // indirect github.com/go-playground/locales v0.14.0 // indirect github.com/gogo/protobuf v1.3.2 // indirect github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect + github.com/google/gofuzz v1.2.0 // indirect github.com/google/uuid v1.3.0 // indirect github.com/googleapis/enterprise-certificate-proxy v0.2.3 // indirect github.com/googleapis/gax-go/v2 v2.7.0 // indirect @@ -55,9 +60,9 @@ require ( github.com/mattn/go-colorable v0.1.13 // indirect github.com/mitchellh/go-homedir v1.1.0 // indirect github.com/mitchellh/go-testing-interface v1.14.1 // indirect + github.com/opencontainers/go-digest v1.0.0 // indirect github.com/rs/zerolog v1.29.1 // indirect github.com/spf13/pflag v1.0.5 // indirect - github.com/tecbot/gorocksdb v0.0.0-20191217155057-f0fad39f321c // indirect github.com/ugorji/go/codec v1.2.7 // indirect github.com/ulikunitz/xz v0.5.11 // indirect go.opencensus.io v0.24.0 // indirect @@ -178,6 +183,8 @@ require ( replace ( // Use the keyring specified by the cosmos-sdk github.com/99designs/keyring => github.com/cosmos/keyring v1.1.7-0.20210622111912-ef00f8ac3d76 + // lock wasmvm so we do not break the grandpa contract + github.com/CosmWasm/wasmvm => github.com/CosmWasm/wasmvm v1.2.2 // ibc-go with wasm client github.com/cosmos/ibc-go/v7 => github.com/notional-labs/ibc-go/v7 v7.0.0-wasm-client diff --git a/go.sum b/go.sum index 2da11e04d..2c21732b5 100644 --- a/go.sum +++ b/go.sum @@ -212,8 +212,10 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03 github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d h1:nalkkPQcITbvhmL4+C4cKA87NW0tfm3Kl9VXRoPywFg= github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d/go.mod h1:URdX5+vg25ts3aCh8H5IFZybJYKWhJHYMTnf+ULtoC4= -github.com/CosmWasm/wasmvm v1.2.1 h1:si0tRsRDdUShV0k51Wn6zRKlmj3/WWP9Yr4cLmDTf+8= -github.com/CosmWasm/wasmvm v1.2.1/go.mod h1:vW/E3h8j9xBQs9bCoijDuawKo9kCtxOaS8N8J7KFtkc= +github.com/CosmWasm/wasmd v0.40.1 h1:LxbO78t/6S8TkeQlUrJ0m5O87HtAwLx4RGHq3rdrOEU= +github.com/CosmWasm/wasmd v0.40.1/go.mod h1:6EOwnv7MpuFaEqxcUOdFV9i4yvrdOciaY6VQ1o7A3yg= +github.com/CosmWasm/wasmvm v1.2.2 h1:F1lTaMRYxk91V9ufV8gYhzLea7sd6AG/GvY1h2JtZsY= +github.com/CosmWasm/wasmvm v1.2.2/go.mod h1:vW/E3h8j9xBQs9bCoijDuawKo9kCtxOaS8N8J7KFtkc= github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0= github.com/Microsoft/go-winio v0.6.0 h1:slsWYD/zyx7lCXoZVlvQrj0hPTM1HI4+v1sIda2yDvg= @@ -306,8 +308,8 @@ github.com/coinbase/rosetta-sdk-go/types v1.0.0 h1:jpVIwLcPoOeCR6o1tU+Xv7r5bMONN github.com/coinbase/rosetta-sdk-go/types v1.0.0/go.mod h1:eq7W2TMRH22GTW0N0beDnN931DW0/WOI1R2sdHNHG4c= github.com/cometbft/cometbft v0.37.1 h1:KLxkQTK2hICXYq21U2hn1W5hOVYUdQgDQ1uB+90xPIg= github.com/cometbft/cometbft v0.37.1/go.mod h1:Y2MMMN//O5K4YKd8ze4r9jmk4Y7h0ajqILXbH5JQFVs= -github.com/cometbft/cometbft-db v0.7.0 h1:uBjbrBx4QzU0zOEnU8KxoDl18dMNgDh+zZRUE0ucsbo= -github.com/cometbft/cometbft-db v0.7.0/go.mod h1:yiKJIm2WKrt6x8Cyxtq9YTEcIMPcEe4XPxhgX59Fzf0= +github.com/cometbft/cometbft-db v0.8.0 h1:vUMDaH3ApkX8m0KZvOFFy9b5DZHBAjsnEuo9AKVZpjo= +github.com/cometbft/cometbft-db v0.8.0/go.mod h1:6ASCP4pfhmrCBpfk01/9E1SI29nD3HfVHrY4PG8x5c0= github.com/confio/ics23/go v0.9.0 h1:cWs+wdbS2KRPZezoaaj+qBleXgUk5WOQFMP3CQFGTr4= github.com/confio/ics23/go v0.9.0/go.mod h1:4LPZ2NYqnYIVRklaozjNR1FScgDJ2s5Xrp+e/mYVRak= github.com/containerd/continuity v0.3.0 h1:nisirsYROK15TAMVukJOUyGJjz4BNQJBVsNvAXZJ/eg= @@ -369,6 +371,8 @@ github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZm github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 h1:fAjc9m62+UWV/WAFKLNi6ZS0675eEUC9y3AlwSbQu1Y= github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= +github.com/docker/distribution v2.8.2+incompatible h1:T3de5rq0dB1j30rp0sA2rER+m322EBzniBPB6ZIzuh8= +github.com/docker/distribution v2.8.2+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ= github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4= github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= @@ -393,9 +397,6 @@ github.com/envoyproxy/go-control-plane v0.9.9-0.20210512163311-63b5d3c536b0/go.m github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go.mod h1:AFq3mo9L8Lqqiid3OhADV3RfLJnjiw63cSpi+fDTRC0= github.com/envoyproxy/go-control-plane v0.10.2-0.20220325020618-49ff273808a1/go.mod h1:KJwIaB5Mv44NWtYuAOFCVOjcI94vtpEz2JU/D2v6IjE= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= -github.com/facebookgo/ensure v0.0.0-20200202191622-63f1cf65ac4c h1:8ISkoahWXwZR41ois5lSJBSVw4D0OV19Ht/JSTzvSv0= -github.com/facebookgo/stack v0.0.0-20160209184415-751773369052 h1:JWuenKqqX8nojtoVVWjGfOF9635RETekkoH6Cc9SX0A= -github.com/facebookgo/subset v0.0.0-20200203212716-c811ad88dec4 h1:7HZCaLC5+BZpmbhCOZJ293Lz68O7PYrF2EzeiFMwCLk= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/felixge/httpsnoop v1.0.1/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= github.com/felixge/httpsnoop v1.0.2 h1:+nS9g82KMXccJ/wp0zyRW9ZBHFETmMGtkk+2CTTrW4o= @@ -525,6 +526,7 @@ github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeN github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf/go.mod h1:HP5RmnzzSNb993RKQDq4+1A4ia9nllfqcQFTQJedwGI= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= +github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/martian v2.1.0+incompatible h1:/CP5g8u/VJHijgedC/Legn3BAbAaWPgecwXBIDzw5no= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= @@ -703,6 +705,8 @@ github.com/libp2p/go-buffer-pool v0.1.0 h1:oK4mSFcQz7cTQIfqbe4MIj9gLW+mnanjyFtc6 github.com/libp2p/go-buffer-pool v0.1.0/go.mod h1:N+vh8gMqimBzdKkSMVuydVDq+UV5QTWy5HSiZacSbPg= github.com/lightstep/lightstep-tracer-common/golang/gogo v0.0.0-20190605223551-bc2310a04743/go.mod h1:qklhhLq1aX+mtWk9cPHPzaBjWImj5ULL6C7HFJtXQMM= github.com/lightstep/lightstep-tracer-go v0.18.1/go.mod h1:jlF1pusYV4pidLvZ+XD0UBX0ZE6WURAspgAczcDHrL4= +github.com/linxGnu/grocksdb v1.7.16 h1:Q2co1xrpdkr5Hx3Fp+f+f7fRGhQFQhvi/+226dtLmA8= +github.com/linxGnu/grocksdb v1.7.16/go.mod h1:JkS7pl5qWpGpuVb3bPqTz8nC12X3YtPZT+Xq7+QfQo4= github.com/lyft/protoc-gen-validate v0.0.13/go.mod h1:XbGvPuh87YZc5TdIa2/I4pLk0QoUACkjt2znoq26NVQ= github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY= @@ -786,6 +790,7 @@ github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1y github.com/onsi/gomega v1.20.0 h1:8W0cWlwFkflGPLltQvLRB7ZVD5HuP6ng320w2IS245Q= github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk= github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= +github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= github.com/opencontainers/image-spec v1.1.0-rc2 h1:2zx/Stx4Wc5pIPDvIxHXvXtQFW/7XWJGmnM7r3wg034= github.com/opencontainers/runc v1.1.3 h1:vIXrkId+0/J2Ymu2m7VjGvbSlAId9XNRPhn2p4b+d8w= github.com/opentracing-contrib/go-observer v0.0.0-20170622124052-a52f23424492/go.mod h1:Ngi6UdF0k5OKD5t5wlmGhe/EDKPoUM3BXZSSfIuJbis= @@ -935,8 +940,6 @@ github.com/subosito/gotenv v1.4.2 h1:X1TuBLAMDFbaTAChgCBLu3DU3UPyELpnF2jjJ2cz/S8 github.com/subosito/gotenv v1.4.2/go.mod h1:ayKnFf/c6rvx/2iiLrJUk1e6plDbT3edrFNGqEflhK0= github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 h1:epCh84lMvA70Z7CTTCmYQn2CKbY8j86K7/FAIr141uY= github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45IWZaF22tdD+VEXcAWRA037jwmWEB5VWYORlTpc= -github.com/tecbot/gorocksdb v0.0.0-20191217155057-f0fad39f321c h1:g+WoO5jjkqGAzHWCjJB1zZfXPIAaDpzXIEJ0eS6B5Ok= -github.com/tecbot/gorocksdb v0.0.0-20191217155057-f0fad39f321c/go.mod h1:ahpPrc7HpcfEWDQRZEmnXMzHY03mLDYMCxeDzy46i+8= github.com/tendermint/go-amino v0.16.0 h1:GyhmgQKvqF82e2oZeuMSp9JTN0N09emoSZlb2lyGa2E= github.com/tendermint/go-amino v0.16.0/go.mod h1:TQU0M1i/ImAo+tYpZi73AU3V/dKeCoMC9Sphe2ZwGME= github.com/tidwall/btree v1.6.0 h1:LDZfKfQIBHGHWSwckhXI0RPSXzlo+KYdjK7FWSqOzzg= diff --git a/x/transfermiddleware/keeper/keeper.go b/x/transfermiddleware/keeper/keeper.go index 73993caa7..2765ffb1b 100644 --- a/x/transfermiddleware/keeper/keeper.go +++ b/x/transfermiddleware/keeper/keeper.go @@ -150,12 +150,12 @@ func (keeper Keeper) GetNativeDenomByIBCDenomSecondaryIndex(ctx sdk.Context, ibc func (keeper Keeper) GetTotalEscrowedToken(ctx sdk.Context) (coins sdk.Coins) { keeper.IterateParaTokenInfos(ctx, func(index int64, info types.ParachainIBCTokenInfo) (stop bool) { - escrowCoin := keeper.bankKeeper.GetBalance(ctx, transfertypes.GetEscrowAddress(transfertypes.PortID, info.ChannelId), info.NativeDenom) - coins.Add(escrowCoin) + escrowCoin := keeper.bankKeeper.GetBalance(ctx, transfertypes.GetEscrowAddress(transfertypes.PortID, info.ChannelId), info.IbcDenom) + coins = append(coins, escrowCoin) return false }) - return + return coins } func (keeper Keeper) Logger(ctx sdk.Context) log.Logger {