From a5d5461426bfc22f2ef2347a9d95e66dcd2ee688 Mon Sep 17 00:00:00 2001 From: Julien Robert Date: Thu, 21 Jul 2022 00:58:15 +0200 Subject: [PATCH] feat: deprecate x/params usage in `x/bank` (#12630) --- CHANGELOG.md | 1 + api/cosmos/bank/v1beta1/bank.pulsar.go | 81 +- api/cosmos/bank/v1beta1/tx.pulsar.go | 1071 ++++++++++++++++- api/cosmos/bank/v1beta1/tx_grpc.pb.go | 44 + .../adr-041-in-place-store-migrations.md | 2 +- docs/architecture/adr-046-module-params.md | 2 +- docs/building-modules/upgrade.md | 6 +- proto/cosmos/bank/v1beta1/bank.proto | 2 +- proto/cosmos/bank/v1beta1/tx.proto | 27 + simapp/app_legacy.go | 6 +- x/auth/keeper/keeper.go | 2 +- x/bank/exported/exported.go | 13 + x/bank/keeper/genesis.go | 4 +- x/bank/keeper/genesis_test.go | 3 +- x/bank/keeper/grpc_query.go | 2 +- x/bank/keeper/grpc_query_test.go | 22 +- x/bank/keeper/keeper.go | 12 +- x/bank/keeper/keeper_test.go | 114 +- x/bank/keeper/migrations.go | 23 +- x/bank/keeper/msg_server.go | 27 +- x/bank/keeper/msg_service_test.go | 61 + x/bank/keeper/send.go | 62 +- x/bank/migrations/{v042 => v1}/types.go | 4 +- x/bank/migrations/{v043 => v2}/json.go | 2 +- x/bank/migrations/{v043 => v2}/json_test.go | 6 +- x/bank/migrations/{v043 => v2}/keys.go | 2 +- x/bank/migrations/{v043 => v2}/store.go | 14 +- x/bank/migrations/{v043 => v2}/store_test.go | 20 +- x/bank/migrations/{v046 => v3}/keys.go | 2 +- x/bank/migrations/{v046 => v3}/store.go | 10 +- x/bank/migrations/{v046 => v3}/store_test.go | 20 +- x/bank/migrations/{v047 => v4}/gen_state.go | 2 +- .../migrations/{v047 => v4}/gen_state_test.go | 37 +- x/bank/migrations/v4/store.go | 36 + x/bank/migrations/v4/store_test.go | 44 + x/bank/module.go | 60 +- x/bank/spec/02_keepers.md | 4 +- x/bank/spec/03_messages.md | 10 + x/bank/types/authority.go | 11 + x/bank/types/bank.pb.go | 83 +- x/bank/types/codec.go | 4 + x/bank/types/{key.go => keys.go} | 3 + x/bank/types/{key_test.go => keys_test.go} | 0 x/bank/types/msgs.go | 30 +- x/bank/types/params.go | 22 - x/bank/types/params_legacy.go | 23 + x/bank/types/tx.pb.go | 462 ++++++- x/crisis/keeper/keeper.go | 9 +- x/crisis/module.go | 18 +- x/distribution/module.go | 8 +- x/genutil/migrations/v043/migrate.go | 12 +- x/genutil/migrations/v047/migrate.go | 4 +- 52 files changed, 2156 insertions(+), 393 deletions(-) create mode 100644 x/bank/keeper/msg_service_test.go rename x/bank/migrations/{v042 => v1}/types.go (95%) rename x/bank/migrations/{v043 => v2}/json.go (98%) rename x/bank/migrations/{v043 => v2}/json_test.go (93%) rename x/bank/migrations/{v043 => v2}/keys.go (98%) rename x/bank/migrations/{v043 => v2}/store.go (90%) rename x/bank/migrations/{v043 => v2}/store_test.go (84%) rename x/bank/migrations/{v046 => v3}/keys.go (97%) rename x/bank/migrations/{v046 => v3}/store.go (90%) rename x/bank/migrations/{v046 => v3}/store_test.go (84%) rename x/bank/migrations/{v047 => v4}/gen_state.go (97%) rename x/bank/migrations/{v047 => v4}/gen_state_test.go (79%) create mode 100644 x/bank/migrations/v4/store.go create mode 100644 x/bank/migrations/v4/store_test.go create mode 100644 x/bank/types/authority.go rename x/bank/types/{key.go => keys.go} (97%) rename x/bank/types/{key_test.go => keys_test.go} (100%) create mode 100644 x/bank/types/params_legacy.go diff --git a/CHANGELOG.md b/CHANGELOG.md index ab38502ea013..4603f10f827c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -61,6 +61,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### State Machine Breaking * (x/bank) [#12610](https://github.com/cosmos/cosmos-sdk/pull/12610) `MsgMultiSend` now allows only a single input. +* (x/bank) [#12630](https://github.com/cosmos/cosmos-sdk/pull/12630) Migrate `x/bank` to self-managed parameters and deprecate its usage of `x/params`. * (x/auth) [#12475](https://github.com/cosmos/cosmos-sdk/pull/12475) Migrate `x/auth` to self-managed parameters and deprecate its usage of `x/params`. * (x/slashing) [#12399](https://github.com/cosmos/cosmos-sdk/pull/12399) Migrate `x/slashing` to self-managed parameters and deprecate its usage of `x/params`. * (x/mint) [#12363](https://github.com/cosmos/cosmos-sdk/pull/12363) Migrate `x/mint` to self-managed parameters and deprecate it's usage of `x/params`. diff --git a/api/cosmos/bank/v1beta1/bank.pulsar.go b/api/cosmos/bank/v1beta1/bank.pulsar.go index 72b7c7b11127..556580ca0a39 100644 --- a/api/cosmos/bank/v1beta1/bank.pulsar.go +++ b/api/cosmos/bank/v1beta1/bank.pulsar.go @@ -4639,54 +4639,51 @@ var file_cosmos_bank_v1beta1_bank_proto_rawDesc = []byte{ 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x43, 0x6f, 0x69, 0x6e, 0x73, 0x52, 0x05, 0x63, 0x6f, 0x69, 0x6e, 0x73, 0x3a, 0x08, 0x88, - 0xa0, 0x1f, 0x00, 0xe8, 0xa0, 0x1f, 0x00, 0x22, 0xb7, 0x01, 0x0a, 0x06, 0x53, 0x75, 0x70, 0x70, + 0xa0, 0x1f, 0x00, 0xe8, 0xa0, 0x1f, 0x00, 0x22, 0x82, 0x01, 0x0a, 0x06, 0x53, 0x75, 0x70, 0x70, 0x6c, 0x79, 0x12, 0x61, 0x0a, 0x05, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x43, 0x6f, 0x69, 0x6e, 0x42, 0x30, 0xc8, 0xde, 0x1f, 0x00, 0xaa, 0xdf, 0x1f, 0x28, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x43, 0x6f, 0x69, 0x6e, 0x73, 0x52, 0x05, - 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x3a, 0x4a, 0x18, 0x01, 0x88, 0xa0, 0x1f, 0x00, 0xe8, 0xa0, 0x1f, - 0x01, 0xca, 0xb4, 0x2d, 0x3c, 0x2a, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, - 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, - 0x64, 0x6b, 0x2f, 0x78, 0x2f, 0x62, 0x61, 0x6e, 0x6b, 0x2f, 0x6d, 0x69, 0x67, 0x72, 0x61, 0x74, - 0x69, 0x6f, 0x6e, 0x73, 0x2f, 0x76, 0x30, 0x34, 0x30, 0x2e, 0x53, 0x75, 0x70, 0x70, 0x6c, 0x79, - 0x49, 0x22, 0x57, 0x0a, 0x09, 0x44, 0x65, 0x6e, 0x6f, 0x6d, 0x55, 0x6e, 0x69, 0x74, 0x12, 0x14, - 0x0a, 0x05, 0x64, 0x65, 0x6e, 0x6f, 0x6d, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x64, - 0x65, 0x6e, 0x6f, 0x6d, 0x12, 0x1a, 0x0a, 0x08, 0x65, 0x78, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x08, 0x65, 0x78, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, - 0x12, 0x18, 0x0a, 0x07, 0x61, 0x6c, 0x69, 0x61, 0x73, 0x65, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, - 0x09, 0x52, 0x07, 0x61, 0x6c, 0x69, 0x61, 0x73, 0x65, 0x73, 0x22, 0x8a, 0x02, 0x0a, 0x08, 0x4d, - 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, - 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, - 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x3f, 0x0a, 0x0b, 0x64, 0x65, 0x6e, - 0x6f, 0x6d, 0x5f, 0x75, 0x6e, 0x69, 0x74, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1e, - 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x6e, 0x6b, 0x2e, 0x76, 0x31, 0x62, - 0x65, 0x74, 0x61, 0x31, 0x2e, 0x44, 0x65, 0x6e, 0x6f, 0x6d, 0x55, 0x6e, 0x69, 0x74, 0x52, 0x0a, - 0x64, 0x65, 0x6e, 0x6f, 0x6d, 0x55, 0x6e, 0x69, 0x74, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x62, 0x61, - 0x73, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x62, 0x61, 0x73, 0x65, 0x12, 0x18, - 0x0a, 0x07, 0x64, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x07, 0x64, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, - 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x16, 0x0a, 0x06, - 0x73, 0x79, 0x6d, 0x62, 0x6f, 0x6c, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x79, - 0x6d, 0x62, 0x6f, 0x6c, 0x12, 0x19, 0x0a, 0x03, 0x75, 0x72, 0x69, 0x18, 0x07, 0x20, 0x01, 0x28, - 0x09, 0x42, 0x07, 0xe2, 0xde, 0x1f, 0x03, 0x55, 0x52, 0x49, 0x52, 0x03, 0x75, 0x72, 0x69, 0x12, - 0x26, 0x0a, 0x08, 0x75, 0x72, 0x69, 0x5f, 0x68, 0x61, 0x73, 0x68, 0x18, 0x08, 0x20, 0x01, 0x28, - 0x09, 0x42, 0x0b, 0xe2, 0xde, 0x1f, 0x07, 0x55, 0x52, 0x49, 0x48, 0x61, 0x73, 0x68, 0x52, 0x07, - 0x75, 0x72, 0x69, 0x48, 0x61, 0x73, 0x68, 0x42, 0xc4, 0x01, 0x0a, 0x17, 0x63, 0x6f, 0x6d, 0x2e, - 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x6e, 0x6b, 0x2e, 0x76, 0x31, 0x62, 0x65, - 0x74, 0x61, 0x31, 0x42, 0x09, 0x42, 0x61, 0x6e, 0x6b, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, - 0x5a, 0x30, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, - 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x62, 0x61, 0x6e, 0x6b, 0x2f, 0x76, - 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x3b, 0x62, 0x61, 0x6e, 0x6b, 0x76, 0x31, 0x62, 0x65, 0x74, - 0x61, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x42, 0x58, 0xaa, 0x02, 0x13, 0x43, 0x6f, 0x73, 0x6d, 0x6f, - 0x73, 0x2e, 0x42, 0x61, 0x6e, 0x6b, 0x2e, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xca, 0x02, - 0x13, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x42, 0x61, 0x6e, 0x6b, 0x5c, 0x56, 0x31, 0x62, - 0x65, 0x74, 0x61, 0x31, 0xe2, 0x02, 0x1f, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x42, 0x61, - 0x6e, 0x6b, 0x5c, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, - 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x15, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x3a, - 0x3a, 0x42, 0x61, 0x6e, 0x6b, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x62, 0x06, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x3a, 0x15, 0x18, 0x01, 0x88, 0xa0, 0x1f, 0x00, 0xe8, 0xa0, 0x1f, + 0x01, 0xca, 0xb4, 0x2d, 0x07, 0x53, 0x75, 0x70, 0x70, 0x6c, 0x79, 0x49, 0x22, 0x57, 0x0a, 0x09, + 0x44, 0x65, 0x6e, 0x6f, 0x6d, 0x55, 0x6e, 0x69, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x64, 0x65, 0x6e, + 0x6f, 0x6d, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x64, 0x65, 0x6e, 0x6f, 0x6d, 0x12, + 0x1a, 0x0a, 0x08, 0x65, 0x78, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x0d, 0x52, 0x08, 0x65, 0x78, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x61, + 0x6c, 0x69, 0x61, 0x73, 0x65, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x07, 0x61, 0x6c, + 0x69, 0x61, 0x73, 0x65, 0x73, 0x22, 0x8a, 0x02, 0x0a, 0x08, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, + 0x74, 0x61, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, + 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, + 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x3f, 0x0a, 0x0b, 0x64, 0x65, 0x6e, 0x6f, 0x6d, 0x5f, 0x75, 0x6e, + 0x69, 0x74, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x63, 0x6f, 0x73, 0x6d, + 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x6e, 0x6b, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, + 0x44, 0x65, 0x6e, 0x6f, 0x6d, 0x55, 0x6e, 0x69, 0x74, 0x52, 0x0a, 0x64, 0x65, 0x6e, 0x6f, 0x6d, + 0x55, 0x6e, 0x69, 0x74, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x62, 0x61, 0x73, 0x65, 0x18, 0x03, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x04, 0x62, 0x61, 0x73, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x64, 0x69, 0x73, + 0x70, 0x6c, 0x61, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x64, 0x69, 0x73, 0x70, + 0x6c, 0x61, 0x79, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x79, 0x6d, 0x62, 0x6f, + 0x6c, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x79, 0x6d, 0x62, 0x6f, 0x6c, 0x12, + 0x19, 0x0a, 0x03, 0x75, 0x72, 0x69, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x42, 0x07, 0xe2, 0xde, + 0x1f, 0x03, 0x55, 0x52, 0x49, 0x52, 0x03, 0x75, 0x72, 0x69, 0x12, 0x26, 0x0a, 0x08, 0x75, 0x72, + 0x69, 0x5f, 0x68, 0x61, 0x73, 0x68, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x42, 0x0b, 0xe2, 0xde, + 0x1f, 0x07, 0x55, 0x52, 0x49, 0x48, 0x61, 0x73, 0x68, 0x52, 0x07, 0x75, 0x72, 0x69, 0x48, 0x61, + 0x73, 0x68, 0x42, 0xc4, 0x01, 0x0a, 0x17, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, + 0x73, 0x2e, 0x62, 0x61, 0x6e, 0x6b, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x42, 0x09, + 0x42, 0x61, 0x6e, 0x6b, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x30, 0x63, 0x6f, 0x73, + 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, + 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x62, 0x61, 0x6e, 0x6b, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, + 0x31, 0x3b, 0x62, 0x61, 0x6e, 0x6b, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xa2, 0x02, 0x03, + 0x43, 0x42, 0x58, 0xaa, 0x02, 0x13, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x42, 0x61, 0x6e, + 0x6b, 0x2e, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xca, 0x02, 0x13, 0x43, 0x6f, 0x73, 0x6d, + 0x6f, 0x73, 0x5c, 0x42, 0x61, 0x6e, 0x6b, 0x5c, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xe2, + 0x02, 0x1f, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x42, 0x61, 0x6e, 0x6b, 0x5c, 0x56, 0x31, + 0x62, 0x65, 0x74, 0x61, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, + 0x61, 0xea, 0x02, 0x15, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x3a, 0x3a, 0x42, 0x61, 0x6e, 0x6b, + 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x33, } var ( diff --git a/api/cosmos/bank/v1beta1/tx.pulsar.go b/api/cosmos/bank/v1beta1/tx.pulsar.go index e59dd39670da..78c894e60b8f 100644 --- a/api/cosmos/bank/v1beta1/tx.pulsar.go +++ b/api/cosmos/bank/v1beta1/tx.pulsar.go @@ -1923,6 +1923,861 @@ func (x *fastReflection_MsgMultiSendResponse) ProtoMethods() *protoiface.Methods } } +var ( + md_MsgUpdateParams protoreflect.MessageDescriptor + fd_MsgUpdateParams_authority protoreflect.FieldDescriptor + fd_MsgUpdateParams_params protoreflect.FieldDescriptor +) + +func init() { + file_cosmos_bank_v1beta1_tx_proto_init() + md_MsgUpdateParams = File_cosmos_bank_v1beta1_tx_proto.Messages().ByName("MsgUpdateParams") + fd_MsgUpdateParams_authority = md_MsgUpdateParams.Fields().ByName("authority") + fd_MsgUpdateParams_params = md_MsgUpdateParams.Fields().ByName("params") +} + +var _ protoreflect.Message = (*fastReflection_MsgUpdateParams)(nil) + +type fastReflection_MsgUpdateParams MsgUpdateParams + +func (x *MsgUpdateParams) ProtoReflect() protoreflect.Message { + return (*fastReflection_MsgUpdateParams)(x) +} + +func (x *MsgUpdateParams) slowProtoReflect() protoreflect.Message { + mi := &file_cosmos_bank_v1beta1_tx_proto_msgTypes[4] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +var _fastReflection_MsgUpdateParams_messageType fastReflection_MsgUpdateParams_messageType +var _ protoreflect.MessageType = fastReflection_MsgUpdateParams_messageType{} + +type fastReflection_MsgUpdateParams_messageType struct{} + +func (x fastReflection_MsgUpdateParams_messageType) Zero() protoreflect.Message { + return (*fastReflection_MsgUpdateParams)(nil) +} +func (x fastReflection_MsgUpdateParams_messageType) New() protoreflect.Message { + return new(fastReflection_MsgUpdateParams) +} +func (x fastReflection_MsgUpdateParams_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_MsgUpdateParams +} + +// Descriptor returns message descriptor, which contains only the protobuf +// type information for the message. +func (x *fastReflection_MsgUpdateParams) Descriptor() protoreflect.MessageDescriptor { + return md_MsgUpdateParams +} + +// Type returns the message type, which encapsulates both Go and protobuf +// type information. If the Go type information is not needed, +// it is recommended that the message descriptor be used instead. +func (x *fastReflection_MsgUpdateParams) Type() protoreflect.MessageType { + return _fastReflection_MsgUpdateParams_messageType +} + +// New returns a newly allocated and mutable empty message. +func (x *fastReflection_MsgUpdateParams) New() protoreflect.Message { + return new(fastReflection_MsgUpdateParams) +} + +// Interface unwraps the message reflection interface and +// returns the underlying ProtoMessage interface. +func (x *fastReflection_MsgUpdateParams) Interface() protoreflect.ProtoMessage { + return (*MsgUpdateParams)(x) +} + +// Range iterates over every populated field in an undefined order, +// calling f for each field descriptor and value encountered. +// Range returns immediately if f returns false. +// While iterating, mutating operations may only be performed +// on the current field descriptor. +func (x *fastReflection_MsgUpdateParams) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { + if x.Authority != "" { + value := protoreflect.ValueOfString(x.Authority) + if !f(fd_MsgUpdateParams_authority, value) { + return + } + } + if x.Params != nil { + value := protoreflect.ValueOfMessage(x.Params.ProtoReflect()) + if !f(fd_MsgUpdateParams_params, value) { + return + } + } +} + +// Has reports whether a field is populated. +// +// Some fields have the property of nullability where it is possible to +// distinguish between the default value of a field and whether the field +// was explicitly populated with the default value. Singular message fields, +// member fields of a oneof, and proto2 scalar fields are nullable. Such +// fields are populated only if explicitly set. +// +// In other cases (aside from the nullable cases above), +// a proto3 scalar field is populated if it contains a non-zero value, and +// a repeated field is populated if it is non-empty. +func (x *fastReflection_MsgUpdateParams) Has(fd protoreflect.FieldDescriptor) bool { + switch fd.FullName() { + case "cosmos.bank.v1beta1.MsgUpdateParams.authority": + return x.Authority != "" + case "cosmos.bank.v1beta1.MsgUpdateParams.params": + return x.Params != nil + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.bank.v1beta1.MsgUpdateParams")) + } + panic(fmt.Errorf("message cosmos.bank.v1beta1.MsgUpdateParams does not contain field %s", fd.FullName())) + } +} + +// Clear clears the field such that a subsequent Has call reports false. +// +// Clearing an extension field clears both the extension type and value +// associated with the given field number. +// +// Clear is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_MsgUpdateParams) Clear(fd protoreflect.FieldDescriptor) { + switch fd.FullName() { + case "cosmos.bank.v1beta1.MsgUpdateParams.authority": + x.Authority = "" + case "cosmos.bank.v1beta1.MsgUpdateParams.params": + x.Params = nil + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.bank.v1beta1.MsgUpdateParams")) + } + panic(fmt.Errorf("message cosmos.bank.v1beta1.MsgUpdateParams does not contain field %s", fd.FullName())) + } +} + +// Get retrieves the value for a field. +// +// For unpopulated scalars, it returns the default value, where +// the default value of a bytes scalar is guaranteed to be a copy. +// For unpopulated composite types, it returns an empty, read-only view +// of the value; to obtain a mutable reference, use Mutable. +func (x *fastReflection_MsgUpdateParams) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { + switch descriptor.FullName() { + case "cosmos.bank.v1beta1.MsgUpdateParams.authority": + value := x.Authority + return protoreflect.ValueOfString(value) + case "cosmos.bank.v1beta1.MsgUpdateParams.params": + value := x.Params + return protoreflect.ValueOfMessage(value.ProtoReflect()) + default: + if descriptor.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.bank.v1beta1.MsgUpdateParams")) + } + panic(fmt.Errorf("message cosmos.bank.v1beta1.MsgUpdateParams does not contain field %s", descriptor.FullName())) + } +} + +// Set stores the value for a field. +// +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType. +// When setting a composite type, it is unspecified whether the stored value +// aliases the source's memory in any way. If the composite value is an +// empty, read-only value, then it panics. +// +// Set is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_MsgUpdateParams) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { + switch fd.FullName() { + case "cosmos.bank.v1beta1.MsgUpdateParams.authority": + x.Authority = value.Interface().(string) + case "cosmos.bank.v1beta1.MsgUpdateParams.params": + x.Params = value.Message().Interface().(*Params) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.bank.v1beta1.MsgUpdateParams")) + } + panic(fmt.Errorf("message cosmos.bank.v1beta1.MsgUpdateParams does not contain field %s", fd.FullName())) + } +} + +// Mutable returns a mutable reference to a composite type. +// +// If the field is unpopulated, it may allocate a composite value. +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType +// if not already stored. +// It panics if the field does not contain a composite type. +// +// Mutable is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_MsgUpdateParams) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "cosmos.bank.v1beta1.MsgUpdateParams.params": + if x.Params == nil { + x.Params = new(Params) + } + return protoreflect.ValueOfMessage(x.Params.ProtoReflect()) + case "cosmos.bank.v1beta1.MsgUpdateParams.authority": + panic(fmt.Errorf("field authority of message cosmos.bank.v1beta1.MsgUpdateParams is not mutable")) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.bank.v1beta1.MsgUpdateParams")) + } + panic(fmt.Errorf("message cosmos.bank.v1beta1.MsgUpdateParams does not contain field %s", fd.FullName())) + } +} + +// NewField returns a new value that is assignable to the field +// for the given descriptor. For scalars, this returns the default value. +// For lists, maps, and messages, this returns a new, empty, mutable value. +func (x *fastReflection_MsgUpdateParams) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "cosmos.bank.v1beta1.MsgUpdateParams.authority": + return protoreflect.ValueOfString("") + case "cosmos.bank.v1beta1.MsgUpdateParams.params": + m := new(Params) + return protoreflect.ValueOfMessage(m.ProtoReflect()) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.bank.v1beta1.MsgUpdateParams")) + } + panic(fmt.Errorf("message cosmos.bank.v1beta1.MsgUpdateParams does not contain field %s", fd.FullName())) + } +} + +// WhichOneof reports which field within the oneof is populated, +// returning nil if none are populated. +// It panics if the oneof descriptor does not belong to this message. +func (x *fastReflection_MsgUpdateParams) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { + switch d.FullName() { + default: + panic(fmt.Errorf("%s is not a oneof field in cosmos.bank.v1beta1.MsgUpdateParams", d.FullName())) + } + panic("unreachable") +} + +// GetUnknown retrieves the entire list of unknown fields. +// The caller may only mutate the contents of the RawFields +// if the mutated bytes are stored back into the message with SetUnknown. +func (x *fastReflection_MsgUpdateParams) GetUnknown() protoreflect.RawFields { + return x.unknownFields +} + +// SetUnknown stores an entire list of unknown fields. +// The raw fields must be syntactically valid according to the wire format. +// An implementation may panic if this is not the case. +// Once stored, the caller must not mutate the content of the RawFields. +// An empty RawFields may be passed to clear the fields. +// +// SetUnknown is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_MsgUpdateParams) SetUnknown(fields protoreflect.RawFields) { + x.unknownFields = fields +} + +// IsValid reports whether the message is valid. +// +// An invalid message is an empty, read-only value. +// +// An invalid message often corresponds to a nil pointer of the concrete +// message type, but the details are implementation dependent. +// Validity is not part of the protobuf data model, and may not +// be preserved in marshaling or other operations. +func (x *fastReflection_MsgUpdateParams) IsValid() bool { + return x != nil +} + +// ProtoMethods returns optional fastReflectionFeature-path implementations of various operations. +// This method may return nil. +// +// The returned methods type is identical to +// "google.golang.org/protobuf/runtime/protoiface".Methods. +// Consult the protoiface package documentation for details. +func (x *fastReflection_MsgUpdateParams) ProtoMethods() *protoiface.Methods { + size := func(input protoiface.SizeInput) protoiface.SizeOutput { + x := input.Message.Interface().(*MsgUpdateParams) + if x == nil { + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: 0, + } + } + options := runtime.SizeInputToOptions(input) + _ = options + var n int + var l int + _ = l + l = len(x.Authority) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + if x.Params != nil { + l = options.Size(x.Params) + n += 1 + l + runtime.Sov(uint64(l)) + } + if x.unknownFields != nil { + n += len(x.unknownFields) + } + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: n, + } + } + + marshal := func(input protoiface.MarshalInput) (protoiface.MarshalOutput, error) { + x := input.Message.Interface().(*MsgUpdateParams) + if x == nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + options := runtime.MarshalInputToOptions(input) + _ = options + size := options.Size(x) + dAtA := make([]byte, size) + i := len(dAtA) + _ = i + var l int + _ = l + if x.unknownFields != nil { + i -= len(x.unknownFields) + copy(dAtA[i:], x.unknownFields) + } + if x.Params != nil { + encoded, err := options.Marshal(x.Params) + if err != nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, err + } + i -= len(encoded) + copy(dAtA[i:], encoded) + i = runtime.EncodeVarint(dAtA, i, uint64(len(encoded))) + i-- + dAtA[i] = 0x12 + } + if len(x.Authority) > 0 { + i -= len(x.Authority) + copy(dAtA[i:], x.Authority) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Authority))) + i-- + dAtA[i] = 0xa + } + if input.Buf != nil { + input.Buf = append(input.Buf, dAtA...) + } else { + input.Buf = dAtA + } + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + unmarshal := func(input protoiface.UnmarshalInput) (protoiface.UnmarshalOutput, error) { + x := input.Message.Interface().(*MsgUpdateParams) + if x == nil { + return protoiface.UnmarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Flags: input.Flags, + }, nil + } + options := runtime.UnmarshalInputToOptions(input) + _ = options + dAtA := input.Buf + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: MsgUpdateParams: wiretype end group for non-group") + } + if fieldNum <= 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: MsgUpdateParams: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Authority", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.Authority = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + if x.Params == nil { + x.Params = &Params{} + } + if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.Params); err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := runtime.Skip(dAtA[iNdEx:]) + if err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + if !options.DiscardUnknown { + x.unknownFields = append(x.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + } + iNdEx += skippy + } + } + + if iNdEx > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, nil + } + return &protoiface.Methods{ + NoUnkeyedLiterals: struct{}{}, + Flags: protoiface.SupportMarshalDeterministic | protoiface.SupportUnmarshalDiscardUnknown, + Size: size, + Marshal: marshal, + Unmarshal: unmarshal, + Merge: nil, + CheckInitialized: nil, + } +} + +var ( + md_MsgUpdateParamsResponse protoreflect.MessageDescriptor +) + +func init() { + file_cosmos_bank_v1beta1_tx_proto_init() + md_MsgUpdateParamsResponse = File_cosmos_bank_v1beta1_tx_proto.Messages().ByName("MsgUpdateParamsResponse") +} + +var _ protoreflect.Message = (*fastReflection_MsgUpdateParamsResponse)(nil) + +type fastReflection_MsgUpdateParamsResponse MsgUpdateParamsResponse + +func (x *MsgUpdateParamsResponse) ProtoReflect() protoreflect.Message { + return (*fastReflection_MsgUpdateParamsResponse)(x) +} + +func (x *MsgUpdateParamsResponse) slowProtoReflect() protoreflect.Message { + mi := &file_cosmos_bank_v1beta1_tx_proto_msgTypes[5] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +var _fastReflection_MsgUpdateParamsResponse_messageType fastReflection_MsgUpdateParamsResponse_messageType +var _ protoreflect.MessageType = fastReflection_MsgUpdateParamsResponse_messageType{} + +type fastReflection_MsgUpdateParamsResponse_messageType struct{} + +func (x fastReflection_MsgUpdateParamsResponse_messageType) Zero() protoreflect.Message { + return (*fastReflection_MsgUpdateParamsResponse)(nil) +} +func (x fastReflection_MsgUpdateParamsResponse_messageType) New() protoreflect.Message { + return new(fastReflection_MsgUpdateParamsResponse) +} +func (x fastReflection_MsgUpdateParamsResponse_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_MsgUpdateParamsResponse +} + +// Descriptor returns message descriptor, which contains only the protobuf +// type information for the message. +func (x *fastReflection_MsgUpdateParamsResponse) Descriptor() protoreflect.MessageDescriptor { + return md_MsgUpdateParamsResponse +} + +// Type returns the message type, which encapsulates both Go and protobuf +// type information. If the Go type information is not needed, +// it is recommended that the message descriptor be used instead. +func (x *fastReflection_MsgUpdateParamsResponse) Type() protoreflect.MessageType { + return _fastReflection_MsgUpdateParamsResponse_messageType +} + +// New returns a newly allocated and mutable empty message. +func (x *fastReflection_MsgUpdateParamsResponse) New() protoreflect.Message { + return new(fastReflection_MsgUpdateParamsResponse) +} + +// Interface unwraps the message reflection interface and +// returns the underlying ProtoMessage interface. +func (x *fastReflection_MsgUpdateParamsResponse) Interface() protoreflect.ProtoMessage { + return (*MsgUpdateParamsResponse)(x) +} + +// Range iterates over every populated field in an undefined order, +// calling f for each field descriptor and value encountered. +// Range returns immediately if f returns false. +// While iterating, mutating operations may only be performed +// on the current field descriptor. +func (x *fastReflection_MsgUpdateParamsResponse) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { +} + +// Has reports whether a field is populated. +// +// Some fields have the property of nullability where it is possible to +// distinguish between the default value of a field and whether the field +// was explicitly populated with the default value. Singular message fields, +// member fields of a oneof, and proto2 scalar fields are nullable. Such +// fields are populated only if explicitly set. +// +// In other cases (aside from the nullable cases above), +// a proto3 scalar field is populated if it contains a non-zero value, and +// a repeated field is populated if it is non-empty. +func (x *fastReflection_MsgUpdateParamsResponse) Has(fd protoreflect.FieldDescriptor) bool { + switch fd.FullName() { + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.bank.v1beta1.MsgUpdateParamsResponse")) + } + panic(fmt.Errorf("message cosmos.bank.v1beta1.MsgUpdateParamsResponse does not contain field %s", fd.FullName())) + } +} + +// Clear clears the field such that a subsequent Has call reports false. +// +// Clearing an extension field clears both the extension type and value +// associated with the given field number. +// +// Clear is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_MsgUpdateParamsResponse) Clear(fd protoreflect.FieldDescriptor) { + switch fd.FullName() { + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.bank.v1beta1.MsgUpdateParamsResponse")) + } + panic(fmt.Errorf("message cosmos.bank.v1beta1.MsgUpdateParamsResponse does not contain field %s", fd.FullName())) + } +} + +// Get retrieves the value for a field. +// +// For unpopulated scalars, it returns the default value, where +// the default value of a bytes scalar is guaranteed to be a copy. +// For unpopulated composite types, it returns an empty, read-only view +// of the value; to obtain a mutable reference, use Mutable. +func (x *fastReflection_MsgUpdateParamsResponse) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { + switch descriptor.FullName() { + default: + if descriptor.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.bank.v1beta1.MsgUpdateParamsResponse")) + } + panic(fmt.Errorf("message cosmos.bank.v1beta1.MsgUpdateParamsResponse does not contain field %s", descriptor.FullName())) + } +} + +// Set stores the value for a field. +// +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType. +// When setting a composite type, it is unspecified whether the stored value +// aliases the source's memory in any way. If the composite value is an +// empty, read-only value, then it panics. +// +// Set is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_MsgUpdateParamsResponse) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { + switch fd.FullName() { + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.bank.v1beta1.MsgUpdateParamsResponse")) + } + panic(fmt.Errorf("message cosmos.bank.v1beta1.MsgUpdateParamsResponse does not contain field %s", fd.FullName())) + } +} + +// Mutable returns a mutable reference to a composite type. +// +// If the field is unpopulated, it may allocate a composite value. +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType +// if not already stored. +// It panics if the field does not contain a composite type. +// +// Mutable is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_MsgUpdateParamsResponse) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.bank.v1beta1.MsgUpdateParamsResponse")) + } + panic(fmt.Errorf("message cosmos.bank.v1beta1.MsgUpdateParamsResponse does not contain field %s", fd.FullName())) + } +} + +// NewField returns a new value that is assignable to the field +// for the given descriptor. For scalars, this returns the default value. +// For lists, maps, and messages, this returns a new, empty, mutable value. +func (x *fastReflection_MsgUpdateParamsResponse) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.bank.v1beta1.MsgUpdateParamsResponse")) + } + panic(fmt.Errorf("message cosmos.bank.v1beta1.MsgUpdateParamsResponse does not contain field %s", fd.FullName())) + } +} + +// WhichOneof reports which field within the oneof is populated, +// returning nil if none are populated. +// It panics if the oneof descriptor does not belong to this message. +func (x *fastReflection_MsgUpdateParamsResponse) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { + switch d.FullName() { + default: + panic(fmt.Errorf("%s is not a oneof field in cosmos.bank.v1beta1.MsgUpdateParamsResponse", d.FullName())) + } + panic("unreachable") +} + +// GetUnknown retrieves the entire list of unknown fields. +// The caller may only mutate the contents of the RawFields +// if the mutated bytes are stored back into the message with SetUnknown. +func (x *fastReflection_MsgUpdateParamsResponse) GetUnknown() protoreflect.RawFields { + return x.unknownFields +} + +// SetUnknown stores an entire list of unknown fields. +// The raw fields must be syntactically valid according to the wire format. +// An implementation may panic if this is not the case. +// Once stored, the caller must not mutate the content of the RawFields. +// An empty RawFields may be passed to clear the fields. +// +// SetUnknown is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_MsgUpdateParamsResponse) SetUnknown(fields protoreflect.RawFields) { + x.unknownFields = fields +} + +// IsValid reports whether the message is valid. +// +// An invalid message is an empty, read-only value. +// +// An invalid message often corresponds to a nil pointer of the concrete +// message type, but the details are implementation dependent. +// Validity is not part of the protobuf data model, and may not +// be preserved in marshaling or other operations. +func (x *fastReflection_MsgUpdateParamsResponse) IsValid() bool { + return x != nil +} + +// ProtoMethods returns optional fastReflectionFeature-path implementations of various operations. +// This method may return nil. +// +// The returned methods type is identical to +// "google.golang.org/protobuf/runtime/protoiface".Methods. +// Consult the protoiface package documentation for details. +func (x *fastReflection_MsgUpdateParamsResponse) ProtoMethods() *protoiface.Methods { + size := func(input protoiface.SizeInput) protoiface.SizeOutput { + x := input.Message.Interface().(*MsgUpdateParamsResponse) + if x == nil { + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: 0, + } + } + options := runtime.SizeInputToOptions(input) + _ = options + var n int + var l int + _ = l + if x.unknownFields != nil { + n += len(x.unknownFields) + } + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: n, + } + } + + marshal := func(input protoiface.MarshalInput) (protoiface.MarshalOutput, error) { + x := input.Message.Interface().(*MsgUpdateParamsResponse) + if x == nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + options := runtime.MarshalInputToOptions(input) + _ = options + size := options.Size(x) + dAtA := make([]byte, size) + i := len(dAtA) + _ = i + var l int + _ = l + if x.unknownFields != nil { + i -= len(x.unknownFields) + copy(dAtA[i:], x.unknownFields) + } + if input.Buf != nil { + input.Buf = append(input.Buf, dAtA...) + } else { + input.Buf = dAtA + } + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + unmarshal := func(input protoiface.UnmarshalInput) (protoiface.UnmarshalOutput, error) { + x := input.Message.Interface().(*MsgUpdateParamsResponse) + if x == nil { + return protoiface.UnmarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Flags: input.Flags, + }, nil + } + options := runtime.UnmarshalInputToOptions(input) + _ = options + dAtA := input.Buf + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: MsgUpdateParamsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: MsgUpdateParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := runtime.Skip(dAtA[iNdEx:]) + if err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + if !options.DiscardUnknown { + x.unknownFields = append(x.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + } + iNdEx += skippy + } + } + + if iNdEx > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, nil + } + return &protoiface.Methods{ + NoUnkeyedLiterals: struct{}{}, + Flags: protoiface.SupportMarshalDeterministic | protoiface.SupportUnmarshalDiscardUnknown, + Size: size, + Marshal: marshal, + Unmarshal: unmarshal, + Merge: nil, + CheckInitialized: nil, + } +} + // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.27.0 @@ -2086,6 +2941,86 @@ func (*MsgMultiSendResponse) Descriptor() ([]byte, []int) { return file_cosmos_bank_v1beta1_tx_proto_rawDescGZIP(), []int{3} } +// MsgUpdateParams is the Msg/UpdateParams request type. +// +// Since: cosmos-sdk 0.47 +type MsgUpdateParams struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // authority is the address of the governance account. + Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"` + // params defines the x/bank parameters to update. + // + // NOTE: All parameters must be supplied. + Params *Params `protobuf:"bytes,2,opt,name=params,proto3" json:"params,omitempty"` +} + +func (x *MsgUpdateParams) Reset() { + *x = MsgUpdateParams{} + if protoimpl.UnsafeEnabled { + mi := &file_cosmos_bank_v1beta1_tx_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *MsgUpdateParams) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*MsgUpdateParams) ProtoMessage() {} + +// Deprecated: Use MsgUpdateParams.ProtoReflect.Descriptor instead. +func (*MsgUpdateParams) Descriptor() ([]byte, []int) { + return file_cosmos_bank_v1beta1_tx_proto_rawDescGZIP(), []int{4} +} + +func (x *MsgUpdateParams) GetAuthority() string { + if x != nil { + return x.Authority + } + return "" +} + +func (x *MsgUpdateParams) GetParams() *Params { + if x != nil { + return x.Params + } + return nil +} + +// MsgUpdateParamsResponse defines the response structure for executing a +// MsgUpdateParams message. +// +// Since: cosmos-sdk 0.47 +type MsgUpdateParamsResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *MsgUpdateParamsResponse) Reset() { + *x = MsgUpdateParamsResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_cosmos_bank_v1beta1_tx_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *MsgUpdateParamsResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*MsgUpdateParamsResponse) ProtoMessage() {} + +// Deprecated: Use MsgUpdateParamsResponse.ProtoReflect.Descriptor instead. +func (*MsgUpdateParamsResponse) Descriptor() ([]byte, []int) { + return file_cosmos_bank_v1beta1_tx_proto_rawDescGZIP(), []int{5} +} + var File_cosmos_bank_v1beta1_tx_proto protoreflect.FileDescriptor var file_cosmos_bank_v1beta1_tx_proto_rawDesc = []byte{ @@ -2129,30 +3064,48 @@ var file_cosmos_bank_v1beta1_tx_proto_rawDesc = []byte{ 0x07, 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x73, 0x3a, 0x0e, 0xe8, 0xa0, 0x1f, 0x00, 0x82, 0xe7, 0xb0, 0x2a, 0x05, 0x69, 0x6e, 0x70, 0x75, 0x74, 0x22, 0x16, 0x0a, 0x14, 0x4d, 0x73, 0x67, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x53, 0x65, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x32, 0xac, 0x01, 0x0a, 0x03, 0x4d, 0x73, 0x67, 0x12, 0x4a, 0x0a, 0x04, 0x53, 0x65, 0x6e, 0x64, - 0x12, 0x1c, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x6e, 0x6b, 0x2e, 0x76, - 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x4d, 0x73, 0x67, 0x53, 0x65, 0x6e, 0x64, 0x1a, 0x24, - 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x6e, 0x6b, 0x2e, 0x76, 0x31, 0x62, - 0x65, 0x74, 0x61, 0x31, 0x2e, 0x4d, 0x73, 0x67, 0x53, 0x65, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x59, 0x0a, 0x09, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x53, 0x65, 0x6e, - 0x64, 0x12, 0x21, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x6e, 0x6b, 0x2e, - 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x4d, 0x73, 0x67, 0x4d, 0x75, 0x6c, 0x74, 0x69, - 0x53, 0x65, 0x6e, 0x64, 0x1a, 0x29, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, - 0x6e, 0x6b, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x4d, 0x73, 0x67, 0x4d, 0x75, - 0x6c, 0x74, 0x69, 0x53, 0x65, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, - 0xc2, 0x01, 0x0a, 0x17, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, - 0x61, 0x6e, 0x6b, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x42, 0x07, 0x54, 0x78, 0x50, - 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x30, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, - 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, - 0x62, 0x61, 0x6e, 0x6b, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x3b, 0x62, 0x61, 0x6e, - 0x6b, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x42, 0x58, 0xaa, 0x02, - 0x13, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x42, 0x61, 0x6e, 0x6b, 0x2e, 0x56, 0x31, 0x62, - 0x65, 0x74, 0x61, 0x31, 0xca, 0x02, 0x13, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x42, 0x61, - 0x6e, 0x6b, 0x5c, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xe2, 0x02, 0x1f, 0x43, 0x6f, 0x73, + 0x22, 0x94, 0x01, 0x0a, 0x0f, 0x4d, 0x73, 0x67, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x61, + 0x72, 0x61, 0x6d, 0x73, 0x12, 0x36, 0x0a, 0x09, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x74, + 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x18, 0xd2, 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73, + 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, + 0x67, 0x52, 0x09, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x12, 0x39, 0x0a, 0x06, + 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x63, + 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x6e, 0x6b, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, + 0x61, 0x31, 0x2e, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x42, 0x04, 0xc8, 0xde, 0x1f, 0x00, 0x52, + 0x06, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x3a, 0x0e, 0x82, 0xe7, 0xb0, 0x2a, 0x09, 0x61, 0x75, + 0x74, 0x68, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x22, 0x19, 0x0a, 0x17, 0x4d, 0x73, 0x67, 0x55, 0x70, + 0x64, 0x61, 0x74, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x32, 0x90, 0x02, 0x0a, 0x03, 0x4d, 0x73, 0x67, 0x12, 0x4a, 0x0a, 0x04, 0x53, 0x65, + 0x6e, 0x64, 0x12, 0x1c, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x6e, 0x6b, + 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x4d, 0x73, 0x67, 0x53, 0x65, 0x6e, 0x64, + 0x1a, 0x24, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x6e, 0x6b, 0x2e, 0x76, + 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x4d, 0x73, 0x67, 0x53, 0x65, 0x6e, 0x64, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x59, 0x0a, 0x09, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x53, + 0x65, 0x6e, 0x64, 0x12, 0x21, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x6e, + 0x6b, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x4d, 0x73, 0x67, 0x4d, 0x75, 0x6c, + 0x74, 0x69, 0x53, 0x65, 0x6e, 0x64, 0x1a, 0x29, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, + 0x62, 0x61, 0x6e, 0x6b, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x4d, 0x73, 0x67, + 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x53, 0x65, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x12, 0x62, 0x0a, 0x0c, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, + 0x73, 0x12, 0x24, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x6e, 0x6b, 0x2e, + 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x4d, 0x73, 0x67, 0x55, 0x70, 0x64, 0x61, 0x74, + 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x1a, 0x2c, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, + 0x2e, 0x62, 0x61, 0x6e, 0x6b, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x4d, 0x73, + 0x67, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0xc2, 0x01, 0x0a, 0x17, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, + 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x6e, 0x6b, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, + 0x31, 0x42, 0x07, 0x54, 0x78, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x30, 0x63, 0x6f, + 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, + 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x62, 0x61, 0x6e, 0x6b, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, + 0x61, 0x31, 0x3b, 0x62, 0x61, 0x6e, 0x6b, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xa2, 0x02, + 0x03, 0x43, 0x42, 0x58, 0xaa, 0x02, 0x13, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x42, 0x61, + 0x6e, 0x6b, 0x2e, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xca, 0x02, 0x13, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x42, 0x61, 0x6e, 0x6b, 0x5c, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, - 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x15, 0x43, - 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x3a, 0x3a, 0x42, 0x61, 0x6e, 0x6b, 0x3a, 0x3a, 0x56, 0x31, 0x62, - 0x65, 0x74, 0x61, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0xe2, 0x02, 0x1f, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x42, 0x61, 0x6e, 0x6b, 0x5c, 0x56, + 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, + 0x74, 0x61, 0xea, 0x02, 0x15, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x3a, 0x3a, 0x42, 0x61, 0x6e, + 0x6b, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x33, } var ( @@ -2167,29 +3120,35 @@ func file_cosmos_bank_v1beta1_tx_proto_rawDescGZIP() []byte { return file_cosmos_bank_v1beta1_tx_proto_rawDescData } -var file_cosmos_bank_v1beta1_tx_proto_msgTypes = make([]protoimpl.MessageInfo, 4) +var file_cosmos_bank_v1beta1_tx_proto_msgTypes = make([]protoimpl.MessageInfo, 6) var file_cosmos_bank_v1beta1_tx_proto_goTypes = []interface{}{ - (*MsgSend)(nil), // 0: cosmos.bank.v1beta1.MsgSend - (*MsgSendResponse)(nil), // 1: cosmos.bank.v1beta1.MsgSendResponse - (*MsgMultiSend)(nil), // 2: cosmos.bank.v1beta1.MsgMultiSend - (*MsgMultiSendResponse)(nil), // 3: cosmos.bank.v1beta1.MsgMultiSendResponse - (*v1beta1.Coin)(nil), // 4: cosmos.base.v1beta1.Coin - (*Input)(nil), // 5: cosmos.bank.v1beta1.Input - (*Output)(nil), // 6: cosmos.bank.v1beta1.Output + (*MsgSend)(nil), // 0: cosmos.bank.v1beta1.MsgSend + (*MsgSendResponse)(nil), // 1: cosmos.bank.v1beta1.MsgSendResponse + (*MsgMultiSend)(nil), // 2: cosmos.bank.v1beta1.MsgMultiSend + (*MsgMultiSendResponse)(nil), // 3: cosmos.bank.v1beta1.MsgMultiSendResponse + (*MsgUpdateParams)(nil), // 4: cosmos.bank.v1beta1.MsgUpdateParams + (*MsgUpdateParamsResponse)(nil), // 5: cosmos.bank.v1beta1.MsgUpdateParamsResponse + (*v1beta1.Coin)(nil), // 6: cosmos.base.v1beta1.Coin + (*Input)(nil), // 7: cosmos.bank.v1beta1.Input + (*Output)(nil), // 8: cosmos.bank.v1beta1.Output + (*Params)(nil), // 9: cosmos.bank.v1beta1.Params } var file_cosmos_bank_v1beta1_tx_proto_depIdxs = []int32{ - 4, // 0: cosmos.bank.v1beta1.MsgSend.amount:type_name -> cosmos.base.v1beta1.Coin - 5, // 1: cosmos.bank.v1beta1.MsgMultiSend.input:type_name -> cosmos.bank.v1beta1.Input - 6, // 2: cosmos.bank.v1beta1.MsgMultiSend.outputs:type_name -> cosmos.bank.v1beta1.Output - 0, // 3: cosmos.bank.v1beta1.Msg.Send:input_type -> cosmos.bank.v1beta1.MsgSend - 2, // 4: cosmos.bank.v1beta1.Msg.MultiSend:input_type -> cosmos.bank.v1beta1.MsgMultiSend - 1, // 5: cosmos.bank.v1beta1.Msg.Send:output_type -> cosmos.bank.v1beta1.MsgSendResponse - 3, // 6: cosmos.bank.v1beta1.Msg.MultiSend:output_type -> cosmos.bank.v1beta1.MsgMultiSendResponse - 5, // [5:7] is the sub-list for method output_type - 3, // [3:5] is the sub-list for method input_type - 3, // [3:3] is the sub-list for extension type_name - 3, // [3:3] is the sub-list for extension extendee - 0, // [0:3] is the sub-list for field type_name + 6, // 0: cosmos.bank.v1beta1.MsgSend.amount:type_name -> cosmos.base.v1beta1.Coin + 7, // 1: cosmos.bank.v1beta1.MsgMultiSend.input:type_name -> cosmos.bank.v1beta1.Input + 8, // 2: cosmos.bank.v1beta1.MsgMultiSend.outputs:type_name -> cosmos.bank.v1beta1.Output + 9, // 3: cosmos.bank.v1beta1.MsgUpdateParams.params:type_name -> cosmos.bank.v1beta1.Params + 0, // 4: cosmos.bank.v1beta1.Msg.Send:input_type -> cosmos.bank.v1beta1.MsgSend + 2, // 5: cosmos.bank.v1beta1.Msg.MultiSend:input_type -> cosmos.bank.v1beta1.MsgMultiSend + 4, // 6: cosmos.bank.v1beta1.Msg.UpdateParams:input_type -> cosmos.bank.v1beta1.MsgUpdateParams + 1, // 7: cosmos.bank.v1beta1.Msg.Send:output_type -> cosmos.bank.v1beta1.MsgSendResponse + 3, // 8: cosmos.bank.v1beta1.Msg.MultiSend:output_type -> cosmos.bank.v1beta1.MsgMultiSendResponse + 5, // 9: cosmos.bank.v1beta1.Msg.UpdateParams:output_type -> cosmos.bank.v1beta1.MsgUpdateParamsResponse + 7, // [7:10] is the sub-list for method output_type + 4, // [4:7] is the sub-list for method input_type + 4, // [4:4] is the sub-list for extension type_name + 4, // [4:4] is the sub-list for extension extendee + 0, // [0:4] is the sub-list for field type_name } func init() { file_cosmos_bank_v1beta1_tx_proto_init() } @@ -2247,6 +3206,30 @@ func file_cosmos_bank_v1beta1_tx_proto_init() { return nil } } + file_cosmos_bank_v1beta1_tx_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*MsgUpdateParams); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_cosmos_bank_v1beta1_tx_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*MsgUpdateParamsResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } } type x struct{} out := protoimpl.TypeBuilder{ @@ -2254,7 +3237,7 @@ func file_cosmos_bank_v1beta1_tx_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_cosmos_bank_v1beta1_tx_proto_rawDesc, NumEnums: 0, - NumMessages: 4, + NumMessages: 6, NumExtensions: 0, NumServices: 1, }, diff --git a/api/cosmos/bank/v1beta1/tx_grpc.pb.go b/api/cosmos/bank/v1beta1/tx_grpc.pb.go index 6c02583a1da0..de5738bfa470 100644 --- a/api/cosmos/bank/v1beta1/tx_grpc.pb.go +++ b/api/cosmos/bank/v1beta1/tx_grpc.pb.go @@ -26,6 +26,11 @@ type MsgClient interface { Send(ctx context.Context, in *MsgSend, opts ...grpc.CallOption) (*MsgSendResponse, error) // MultiSend defines a method for sending coins from some accounts to other accounts. MultiSend(ctx context.Context, in *MsgMultiSend, opts ...grpc.CallOption) (*MsgMultiSendResponse, error) + // UpdateParams defines a governance operation for updating the x/bank module parameters. + // The authority is defined in the keeper. + // + // Since: cosmos-sdk 0.47 + UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error) } type msgClient struct { @@ -54,6 +59,15 @@ func (c *msgClient) MultiSend(ctx context.Context, in *MsgMultiSend, opts ...grp return out, nil } +func (c *msgClient) UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error) { + out := new(MsgUpdateParamsResponse) + err := c.cc.Invoke(ctx, "/cosmos.bank.v1beta1.Msg/UpdateParams", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // MsgServer is the server API for Msg service. // All implementations must embed UnimplementedMsgServer // for forward compatibility @@ -62,6 +76,11 @@ type MsgServer interface { Send(context.Context, *MsgSend) (*MsgSendResponse, error) // MultiSend defines a method for sending coins from some accounts to other accounts. MultiSend(context.Context, *MsgMultiSend) (*MsgMultiSendResponse, error) + // UpdateParams defines a governance operation for updating the x/bank module parameters. + // The authority is defined in the keeper. + // + // Since: cosmos-sdk 0.47 + UpdateParams(context.Context, *MsgUpdateParams) (*MsgUpdateParamsResponse, error) mustEmbedUnimplementedMsgServer() } @@ -75,6 +94,9 @@ func (UnimplementedMsgServer) Send(context.Context, *MsgSend) (*MsgSendResponse, func (UnimplementedMsgServer) MultiSend(context.Context, *MsgMultiSend) (*MsgMultiSendResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method MultiSend not implemented") } +func (UnimplementedMsgServer) UpdateParams(context.Context, *MsgUpdateParams) (*MsgUpdateParamsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdateParams not implemented") +} func (UnimplementedMsgServer) mustEmbedUnimplementedMsgServer() {} // UnsafeMsgServer may be embedded to opt out of forward compatibility for this service. @@ -124,6 +146,24 @@ func _Msg_MultiSend_Handler(srv interface{}, ctx context.Context, dec func(inter return interceptor(ctx, in, info, handler) } +func _Msg_UpdateParams_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgUpdateParams) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).UpdateParams(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/cosmos.bank.v1beta1.Msg/UpdateParams", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).UpdateParams(ctx, req.(*MsgUpdateParams)) + } + return interceptor(ctx, in, info, handler) +} + // Msg_ServiceDesc is the grpc.ServiceDesc for Msg service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) @@ -139,6 +179,10 @@ var Msg_ServiceDesc = grpc.ServiceDesc{ MethodName: "MultiSend", Handler: _Msg_MultiSend_Handler, }, + { + MethodName: "UpdateParams", + Handler: _Msg_UpdateParams_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "cosmos/bank/v1beta1/tx.proto", diff --git a/docs/architecture/adr-041-in-place-store-migrations.md b/docs/architecture/adr-041-in-place-store-migrations.md index b0ff8e4e711c..41dfa1520a31 100644 --- a/docs/architecture/adr-041-in-place-store-migrations.md +++ b/docs/architecture/adr-041-in-place-store-migrations.md @@ -71,7 +71,7 @@ Migration functions should live inside the `migrations/` folder of each module, ```go // Migrate1to2 migrates from version 1 to 2. func (m Migrator) Migrate1to2(ctx sdk.Context) error { - return v043bank.MigrateStore(ctx, m.keeper.storeKey) // v043bank is package `x/bank/migrations/v043`. + return v2bank.MigrateStore(ctx, m.keeper.storeKey) // v043bank is package `x/bank/migrations/v2`. } ``` diff --git a/docs/architecture/adr-046-module-params.md b/docs/architecture/adr-046-module-params.md index 6c068e4e0107..369cd043d7e3 100644 --- a/docs/architecture/adr-046-module-params.md +++ b/docs/architecture/adr-046-module-params.md @@ -135,7 +135,7 @@ message QueryParamsResponse { As a result of implementing the module parameter methodology, we gain the ability for module parameter changes to be stateful and extensible to fit nearly every application's use case. We will be able to emit events (and trigger hooks registered -to that events using the work proposed in [even hooks](https://github.com/cosmos/cosmos-sdk/discussions/9656)), +to that events using the work proposed in [event hooks](https://github.com/cosmos/cosmos-sdk/discussions/9656)), call other Msg service methods or perform migration. In addition, there will be significant gains in performance when it comes to reading and writing parameters from and to state, especially if a specific set of parameters diff --git a/docs/building-modules/upgrade.md b/docs/building-modules/upgrade.md index 863066ca798d..c99b86102fdc 100644 --- a/docs/building-modules/upgrade.md +++ b/docs/building-modules/upgrade.md @@ -45,13 +45,13 @@ Since these migrations are functions that need access to a Keeper's store, use a ## Writing Migration Scripts -To define the functionality that takes place during an upgrade, write a migration script and place the functions in a `migrations/` directory. For example, to write migration scripts for the bank module, place the functions in `x/bank/migrations/`. Use the recommended naming convention for these functions. For example, `v043bank` is the script that migrates the package `x/bank/migrations/v043`: +To define the functionality that takes place during an upgrade, write a migration script and place the functions in a `migrations/` directory. For example, to write migration scripts for the bank module, place the functions in `x/bank/migrations/`. Use the recommended naming convention for these functions. For example, `v2bank` is the script that migrates the package `x/bank/migrations/v2`: ```golang // Migrating bank module from version 1 to 2 func (m Migrator) Migrate1to2(ctx sdk.Context) error { - return v043bank.MigrateStore(ctx, m.keeper.storeKey) // v043bank is package `x/bank/migrations/v043`. + return v2bank.MigrateStore(ctx, m.keeper.storeKey) // v2bank is package `x/bank/migrations/v2`. } ``` -To see example code of changes that were implemented in a migration of balance keys, check out [migrateBalanceKeys](https://github.com/cosmos/cosmos-sdk/blob/v0.46.0-rc1/x/bank/migrations/v043/store.go#L50-L71). For context, this code introduced migrations of the bank store that updated addresses to be prefixed by their length in bytes as outlined in [ADR-028](../architecture/adr-028-public-key-addresses.md). +To see example code of changes that were implemented in a migration of balance keys, check out [migrateBalanceKeys](https://github.com/cosmos/cosmos-sdk/blob/v0.46.0-rc1/x/bank/migrations/v2/store.go#L50-L71). For context, this code introduced migrations of the bank store that updated addresses to be prefixed by their length in bytes as outlined in [ADR-028](../architecture/adr-028-public-key-addresses.md). diff --git a/proto/cosmos/bank/v1beta1/bank.proto b/proto/cosmos/bank/v1beta1/bank.proto index 0856398440f4..587dc8e691c4 100644 --- a/proto/cosmos/bank/v1beta1/bank.proto +++ b/proto/cosmos/bank/v1beta1/bank.proto @@ -60,7 +60,7 @@ message Supply { option (gogoproto.equal) = true; option (gogoproto.goproto_getters) = false; - option (cosmos_proto.implements_interface) = "*github.com/cosmos/cosmos-sdk/x/bank/migrations/v040.SupplyI"; + option (cosmos_proto.implements_interface) = "SupplyI"; repeated cosmos.base.v1beta1.Coin total = 1 [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"]; diff --git a/proto/cosmos/bank/v1beta1/tx.proto b/proto/cosmos/bank/v1beta1/tx.proto index 0eda48179297..9cd92426d953 100644 --- a/proto/cosmos/bank/v1beta1/tx.proto +++ b/proto/cosmos/bank/v1beta1/tx.proto @@ -16,6 +16,12 @@ service Msg { // MultiSend defines a method for sending coins from some accounts to other accounts. rpc MultiSend(MsgMultiSend) returns (MsgMultiSendResponse); + + // UpdateParams defines a governance operation for updating the x/bank module parameters. + // The authority is defined in the keeper. + // + // Since: cosmos-sdk 0.47 + rpc UpdateParams(MsgUpdateParams) returns (MsgUpdateParamsResponse); } // MsgSend represents a message to send coins from one account to another. @@ -46,3 +52,24 @@ message MsgMultiSend { // MsgMultiSendResponse defines the Msg/MultiSend response type. message MsgMultiSendResponse {} + +// MsgUpdateParams is the Msg/UpdateParams request type. +// +// Since: cosmos-sdk 0.47 +message MsgUpdateParams { + option (cosmos.msg.v1.signer) = "authority"; + + // authority is the address of the governance account. + string authority = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + + // params defines the x/bank parameters to update. + // + // NOTE: All parameters must be supplied. + Params params = 2 [(gogoproto.nullable) = false]; +} + +// MsgUpdateParamsResponse defines the response structure for executing a +// MsgUpdateParams message. +// +// Since: cosmos-sdk 0.47 +message MsgUpdateParamsResponse {} diff --git a/simapp/app_legacy.go b/simapp/app_legacy.go index 0bc5655c805e..71bb73cc1907 100644 --- a/simapp/app_legacy.go +++ b/simapp/app_legacy.go @@ -258,7 +258,7 @@ func NewSimApp( app.AccountKeeper = authkeeper.NewAccountKeeper(appCodec, keys[authtypes.StoreKey], authtypes.ProtoBaseAccount, maccPerms, sdk.Bech32MainPrefix, authtypes.NewModuleAddress(govtypes.ModuleName).String()) app.BankKeeper = bankkeeper.NewBaseKeeper( - appCodec, keys[banktypes.StoreKey], app.AccountKeeper, app.GetSubspace(banktypes.ModuleName), app.ModuleAccountAddrs(), + appCodec, keys[banktypes.StoreKey], app.AccountKeeper, app.ModuleAccountAddrs(), authtypes.NewModuleAddress(govtypes.ModuleName).String(), ) app.StakingKeeper = stakingkeeper.NewKeeper( appCodec, keys[stakingtypes.StoreKey], app.AccountKeeper, app.BankKeeper, app.GetSubspace(stakingtypes.ModuleName), @@ -353,7 +353,7 @@ func NewSimApp( ), auth.NewAppModule(appCodec, app.AccountKeeper, authsims.RandomGenesisAccounts, app.GetSubspace(authtypes.ModuleName)), vesting.NewAppModule(app.AccountKeeper, app.BankKeeper), - bank.NewAppModule(appCodec, app.BankKeeper, app.AccountKeeper), + bank.NewAppModule(appCodec, app.BankKeeper, app.AccountKeeper, app.GetSubspace(banktypes.ModuleName)), capability.NewAppModule(appCodec, *app.CapabilityKeeper, false), crisis.NewAppModule(app.CrisisKeeper, skipGenesisInvariants, app.GetSubspace(crisistypes.ModuleName)), feegrantmodule.NewAppModule(appCodec, app.AccountKeeper, app.BankKeeper, app.FeeGrantKeeper, app.interfaceRegistry), @@ -422,7 +422,7 @@ func NewSimApp( // transactions app.sm = module.NewSimulationManager( auth.NewAppModule(appCodec, app.AccountKeeper, authsims.RandomGenesisAccounts, app.GetSubspace(authtypes.ModuleName)), - bank.NewAppModule(appCodec, app.BankKeeper, app.AccountKeeper), + bank.NewAppModule(appCodec, app.BankKeeper, app.AccountKeeper, app.GetSubspace(banktypes.ModuleName)), capability.NewAppModule(appCodec, *app.CapabilityKeeper, false), feegrantmodule.NewAppModule(appCodec, app.AccountKeeper, app.BankKeeper, app.FeeGrantKeeper, app.interfaceRegistry), gov.NewAppModule(appCodec, &app.GovKeeper, app.AccountKeeper, app.BankKeeper), diff --git a/x/auth/keeper/keeper.go b/x/auth/keeper/keeper.go index 5be67b2ba95e..ab1778bd24cd 100644 --- a/x/auth/keeper/keeper.go +++ b/x/auth/keeper/keeper.go @@ -96,7 +96,7 @@ func NewAccountKeeper( } } -// GetAuthority returns the x/mint module's authority. +// GetAuthority returns the x/auth module's authority. func (ak AccountKeeper) GetAuthority() string { return ak.authority } diff --git a/x/bank/exported/exported.go b/x/bank/exported/exported.go index c4f2e9f6da09..7ab9136e896d 100644 --- a/x/bank/exported/exported.go +++ b/x/bank/exported/exported.go @@ -2,6 +2,7 @@ package exported import ( sdk "github.com/cosmos/cosmos-sdk/types" + paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" ) // GenesisBalance defines a genesis balance interface that allows for account @@ -10,3 +11,15 @@ type GenesisBalance interface { GetAddress() sdk.AccAddress GetCoins() sdk.Coins } + +type ( + ParamSet = paramtypes.ParamSet + + // Subspace defines an interface that implements the legacy x/params Subspace + // type. + // + // NOTE: This is used solely for migration of x/params managed parameters. + Subspace interface { + GetParamSet(ctx sdk.Context, ps ParamSet) + } +) diff --git a/x/bank/keeper/genesis.go b/x/bank/keeper/genesis.go index 6cdb09d6d18f..b934430c4d16 100644 --- a/x/bank/keeper/genesis.go +++ b/x/bank/keeper/genesis.go @@ -10,7 +10,9 @@ import ( // InitGenesis initializes the bank module's state from a given genesis state. func (k BaseKeeper) InitGenesis(ctx sdk.Context, genState *types.GenesisState) { - k.SetParams(ctx, genState.Params) + if err := k.SetParams(ctx, genState.Params); err != nil { + panic(err) + } for _, se := range genState.GetAllSendEnabled() { k.SetSendEnabled(ctx, se.Denom, se.Enabled) diff --git a/x/bank/keeper/genesis_test.go b/x/bank/keeper/genesis_test.go index 2d1359deb50e..0b70cfaac8db 100644 --- a/x/bank/keeper/genesis_test.go +++ b/x/bank/keeper/genesis_test.go @@ -32,7 +32,8 @@ func (suite *IntegrationTestSuite) TestExportGenesis() { Require(). NoError(app.BankKeeper.SendCoinsFromModuleToAccount(ctx, minttypes.ModuleName, accAddr, expectedBalances[i].Coins)) } - app.BankKeeper.SetParams(ctx, types.DefaultParams()) + + suite.Require().NoError(app.BankKeeper.SetParams(ctx, types.DefaultParams())) exportGenesis := app.BankKeeper.ExportGenesis(ctx) diff --git a/x/bank/keeper/grpc_query.go b/x/bank/keeper/grpc_query.go index 3edd6ebf1f6b..8c7d3f6d51ed 100644 --- a/x/bank/keeper/grpc_query.go +++ b/x/bank/keeper/grpc_query.go @@ -94,7 +94,7 @@ func (k BaseKeeper) SpendableBalances(ctx context.Context, req *types.QuerySpend accountStore := k.getAccountStore(sdkCtx, addr) zeroAmt := sdk.ZeroInt() - pageRes, err := query.Paginate(accountStore, req.Pagination, func(key, value []byte) error { + pageRes, err := query.Paginate(accountStore, req.Pagination, func(key, _ []byte) error { balances = append(balances, sdk.NewCoin(string(key), zeroAmt)) return nil }) diff --git a/x/bank/keeper/grpc_query_test.go b/x/bank/keeper/grpc_query_test.go index 4c84877194df..a67cf0401e18 100644 --- a/x/bank/keeper/grpc_query_test.go +++ b/x/bank/keeper/grpc_query_test.go @@ -470,8 +470,8 @@ func (suite *IntegrationTestSuite) TestQuerySendEnabled() { req: &types.QuerySendEnabledRequest{Denoms: []string{}}, exp: &types.QuerySendEnabledResponse{ SendEnabled: []*types.SendEnabled{ - {"falsestcoin", false}, - {"truestcoin", true}, + {Denom: "falsestcoin", Enabled: false}, + {Denom: "truestcoin", Enabled: true}, }, Pagination: &query.PageResponse{ NextKey: nil, @@ -484,8 +484,8 @@ func (suite *IntegrationTestSuite) TestQuerySendEnabled() { req: &types.QuerySendEnabledRequest{Denoms: []string{}}, exp: &types.QuerySendEnabledResponse{ SendEnabled: []*types.SendEnabled{ - {"falsestcoin", false}, - {"truestcoin", true}, + {Denom: "falsestcoin", Enabled: false}, + {Denom: "truestcoin", Enabled: true}, }, Pagination: &query.PageResponse{ NextKey: nil, @@ -503,7 +503,7 @@ func (suite *IntegrationTestSuite) TestQuerySendEnabled() { }, exp: &types.QuerySendEnabledResponse{ SendEnabled: []*types.SendEnabled{ - {"falsestcoin", false}, + {Denom: "falsestcoin", Enabled: false}, }, Pagination: &query.PageResponse{ NextKey: []byte("truestcoin"), @@ -516,7 +516,7 @@ func (suite *IntegrationTestSuite) TestQuerySendEnabled() { req: &types.QuerySendEnabledRequest{Denoms: []string{"truestcoin"}}, exp: &types.QuerySendEnabledResponse{ SendEnabled: []*types.SendEnabled{ - {"truestcoin", true}, + {Denom: "truestcoin", Enabled: true}, }, Pagination: nil, }, @@ -526,7 +526,7 @@ func (suite *IntegrationTestSuite) TestQuerySendEnabled() { req: &types.QuerySendEnabledRequest{Denoms: []string{"falsestcoin"}}, exp: &types.QuerySendEnabledResponse{ SendEnabled: []*types.SendEnabled{ - {"falsestcoin", false}, + {Denom: "falsestcoin", Enabled: false}, }, Pagination: nil, }, @@ -544,8 +544,8 @@ func (suite *IntegrationTestSuite) TestQuerySendEnabled() { req: &types.QuerySendEnabledRequest{Denoms: []string{"truestcoin", "falsestcoin"}}, exp: &types.QuerySendEnabledResponse{ SendEnabled: []*types.SendEnabled{ - {"truestcoin", true}, - {"falsestcoin", false}, + {Denom: "truestcoin", Enabled: true}, + {Denom: "falsestcoin", Enabled: false}, }, Pagination: nil, }, @@ -555,8 +555,8 @@ func (suite *IntegrationTestSuite) TestQuerySendEnabled() { req: &types.QuerySendEnabledRequest{Denoms: []string{"truestcoin", "falsestcoin", "unknownestcoin"}}, exp: &types.QuerySendEnabledResponse{ SendEnabled: []*types.SendEnabled{ - {"truestcoin", true}, - {"falsestcoin", false}, + {Denom: "truestcoin", Enabled: true}, + {Denom: "falsestcoin", Enabled: false}, }, Pagination: nil, }, diff --git a/x/bank/keeper/keeper.go b/x/bank/keeper/keeper.go index c7f308d8c54d..520861526869 100644 --- a/x/bank/keeper/keeper.go +++ b/x/bank/keeper/keeper.go @@ -13,7 +13,6 @@ import ( "github.com/cosmos/cosmos-sdk/types/query" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/cosmos/cosmos-sdk/x/bank/types" - paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" ) var _ Keeper = (*BaseKeeper)(nil) @@ -57,7 +56,6 @@ type BaseKeeper struct { ak types.AccountKeeper cdc codec.BinaryCodec storeKey storetypes.StoreKey - paramSpace paramtypes.Subspace mintCoinsRestrictionFn MintingRestrictionFn } @@ -98,20 +96,18 @@ func NewBaseKeeper( cdc codec.BinaryCodec, storeKey storetypes.StoreKey, ak types.AccountKeeper, - paramSpace paramtypes.Subspace, blockedAddrs map[string]bool, + authority string, ) BaseKeeper { - // set KeyTable if it has not already been set - if !paramSpace.HasKeyTable() { - paramSpace = paramSpace.WithKeyTable(types.ParamKeyTable()) + if _, err := sdk.AccAddressFromBech32(authority); err != nil { + panic(fmt.Errorf("invalid bank authority address: %w", err)) } return BaseKeeper{ - BaseSendKeeper: NewBaseSendKeeper(cdc, storeKey, ak, paramSpace, blockedAddrs), + BaseSendKeeper: NewBaseSendKeeper(cdc, storeKey, ak, blockedAddrs, authority), ak: ak, cdc: cdc, storeKey: storeKey, - paramSpace: paramSpace, mintCoinsRestrictionFn: func(ctx sdk.Context, coins sdk.Coins) error { return nil }, } } diff --git a/x/bank/keeper/keeper_test.go b/x/bank/keeper/keeper_test.go index ddeef73ca7e7..fd49dc2d51c9 100644 --- a/x/bank/keeper/keeper_test.go +++ b/x/bank/keeper/keeper_test.go @@ -21,9 +21,11 @@ import ( authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" vesting "github.com/cosmos/cosmos-sdk/x/auth/vesting/types" + "github.com/cosmos/cosmos-sdk/x/bank/exported" "github.com/cosmos/cosmos-sdk/x/bank/keeper" "github.com/cosmos/cosmos-sdk/x/bank/testutil" "github.com/cosmos/cosmos-sdk/x/bank/types" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" ) @@ -74,6 +76,7 @@ type IntegrationTestSuite struct { app *simapp.SimApp ctx sdk.Context queryClient types.QueryClient + msgServer types.MsgServer } func (suite *IntegrationTestSuite) initKeepersWithmAccPerms(blockedAddrs map[string]bool) (authkeeper.AccountKeeper, keeper.BaseKeeper) { @@ -91,27 +94,26 @@ func (suite *IntegrationTestSuite) initKeepersWithmAccPerms(blockedAddrs map[str maccPerms, sdk.Bech32MainPrefix, authtypes.NewModuleAddress(govtypes.ModuleName).String(), ) keeper := keeper.NewBaseKeeper( - appCodec, app.GetKey(types.StoreKey), authKeeper, - app.GetSubspace(types.ModuleName), blockedAddrs, + appCodec, app.GetKey(types.StoreKey), authKeeper, blockedAddrs, authtypes.NewModuleAddress(govtypes.ModuleName).String(), ) return authKeeper, keeper } func (suite *IntegrationTestSuite) SetupTest() { - app := simapp.Setup(suite.T(), false) - ctx := app.BaseApp.NewContext(false, tmproto.Header{Time: time.Now()}) + suite.app = simapp.Setup(suite.T(), false) + suite.ctx = suite.app.BaseApp.NewContext(false, tmproto.Header{Time: time.Now()}) - app.AccountKeeper.SetParams(ctx, authtypes.DefaultParams()) - app.BankKeeper.SetParams(ctx, types.DefaultParams()) + suite.Require().NoError(suite.app.AccountKeeper.SetParams(suite.ctx, authtypes.DefaultParams())) + suite.Require().NoError(suite.app.BankKeeper.SetParams(suite.ctx, types.DefaultParams())) - queryHelper := baseapp.NewQueryServerTestHelper(ctx, app.InterfaceRegistry()) - types.RegisterQueryServer(queryHelper, app.BankKeeper) + queryHelper := baseapp.NewQueryServerTestHelper(suite.ctx, suite.app.InterfaceRegistry()) + types.RegisterQueryServer(queryHelper, suite.app.BankKeeper) queryClient := types.NewQueryClient(queryHelper) + types.RegisterInterfaces(suite.app.InterfaceRegistry()) - suite.app = app - suite.ctx = ctx suite.queryClient = queryClient + suite.msgServer = keeper.NewMsgServerImpl(suite.app.BankKeeper) } func (suite *IntegrationTestSuite) TestSupply() { @@ -496,7 +498,7 @@ func (suite *IntegrationTestSuite) TestSendEnabled() { params := types.DefaultParams() suite.Require().Equal(enabled, params.DefaultSendEnabled) - app.BankKeeper.SetParams(ctx, params) + suite.Require().NoError(app.BankKeeper.SetParams(ctx, params)) bondCoin := sdk.NewCoin(sdk.DefaultBondDenom, sdk.OneInt()) fooCoin := sdk.NewCoin("foocoin", sdk.OneInt()) @@ -512,7 +514,7 @@ func (suite *IntegrationTestSuite) TestSendEnabled() { // Set default send_enabled to !enabled, add a foodenom that overrides default as enabled params.DefaultSendEnabled = !enabled - app.BankKeeper.SetParams(ctx, params) + suite.Require().NoError(app.BankKeeper.SetParams(ctx, params)) app.BankKeeper.SetSendEnabled(ctx, fooCoin.Denom, enabled) // Expect our specific override to be enabled, others to be !enabled. @@ -596,7 +598,7 @@ func (suite *IntegrationTestSuite) TestMsgSendEvents() { func (suite *IntegrationTestSuite) TestMsgMultiSendEvents() { app, ctx := suite.app, suite.ctx - app.BankKeeper.SetParams(ctx, types.DefaultParams()) + suite.Require().NoError(app.BankKeeper.SetParams(ctx, types.DefaultParams())) addr := sdk.AccAddress([]byte("addr1_______________")) addr2 := sdk.AccAddress([]byte("addr2_______________")) @@ -1055,7 +1057,7 @@ func (suite *IntegrationTestSuite) TestBalanceTrackingEvents() { ) suite.app.BankKeeper = keeper.NewBaseKeeper(suite.app.AppCodec(), suite.app.GetKey(types.StoreKey), - suite.app.AccountKeeper, suite.app.GetSubspace(types.ModuleName), nil, + suite.app.AccountKeeper, nil, authtypes.NewModuleAddress(govtypes.ModuleName).String(), ) // set account with multiple permissions @@ -1148,9 +1150,9 @@ func (suite *IntegrationTestSuite) getTestMetadata() []types.Metadata { Symbol: "ATOM", Description: "The native staking token of the Cosmos Hub.", DenomUnits: []*types.DenomUnit{ - {"uatom", uint32(0), []string{"microatom"}}, - {"matom", uint32(3), []string{"milliatom"}}, - {"atom", uint32(6), nil}, + {Denom: "uatom", Exponent: uint32(0), Aliases: []string{"microatom"}}, + {Denom: "matom", Exponent: uint32(3), Aliases: []string{"milliatom"}}, + {Denom: "atom", Exponent: uint32(6), Aliases: nil}, }, Base: "uatom", Display: "atom", @@ -1160,9 +1162,9 @@ func (suite *IntegrationTestSuite) getTestMetadata() []types.Metadata { Symbol: "TOKEN", Description: "The native staking token of the Token Hub.", DenomUnits: []*types.DenomUnit{ - {"1token", uint32(5), []string{"decitoken"}}, - {"2token", uint32(4), []string{"centitoken"}}, - {"3token", uint32(7), []string{"dekatoken"}}, + {Denom: "1token", Exponent: uint32(5), Aliases: []string{"decitoken"}}, + {Denom: "2token", Exponent: uint32(4), Aliases: []string{"centitoken"}}, + {Denom: "3token", Exponent: uint32(7), Aliases: []string{"dekatoken"}}, }, Base: "utoken", Display: "token", @@ -1195,7 +1197,7 @@ func (suite *IntegrationTestSuite) TestMintCoinRestrictions() { }{ { "restriction", - func(ctx sdk.Context, coins sdk.Coins) error { + func(_ sdk.Context, coins sdk.Coins) error { for _, coin := range coins { if coin.Denom != fooDenom { return fmt.Errorf("Module %s only has perms for minting %s coins, tried minting %s coins", types.ModuleName, fooDenom, coin.Denom) @@ -1218,7 +1220,7 @@ func (suite *IntegrationTestSuite) TestMintCoinRestrictions() { for _, test := range tests { suite.app.BankKeeper = keeper.NewBaseKeeper(suite.app.AppCodec(), suite.app.GetKey(types.StoreKey), - suite.app.AccountKeeper, suite.app.GetSubspace(types.ModuleName), nil, + suite.app.AccountKeeper, nil, authtypes.NewModuleAddress(govtypes.ModuleName).String(), ).WithMintCoinsRestriction(keeper.MintingRestrictionFn(test.restrictionFn)) for _, testCase := range test.testCases { if testCase.expectPass { @@ -1273,7 +1275,7 @@ func (suite *IntegrationTestSuite) TestIsSendEnabledDenom() { for _, def := range []bool{true, false} { params := types.Params{DefaultSendEnabled: def} - bankKeeper.SetParams(ctx, params) + suite.Require().NoError(bankKeeper.SetParams(ctx, params)) for _, tc := range tests { suite.T().Run(fmt.Sprintf("%s default %t", tc.denom, def), func(t *testing.T) { actual := suite.app.BankKeeper.IsSendEnabledDenom(suite.ctx, tc.denom) @@ -1378,7 +1380,7 @@ func (suite *IntegrationTestSuite) TestSetSendEnabled() { for _, def := range []bool{true, false} { params := types.Params{DefaultSendEnabled: def} - bankKeeper.SetParams(ctx, params) + suite.Require().NoError(bankKeeper.SetParams(ctx, params)) for _, tc := range tests { suite.T().Run(fmt.Sprintf("%s default %t", tc.name, def), func(t *testing.T) { bankKeeper.SetSendEnabled(ctx, tc.denom, tc.value) @@ -1407,48 +1409,48 @@ func (suite *IntegrationTestSuite) TestSetAllSendEnabled() { { name: "one true", sendEnableds: []*types.SendEnabled{ - {"aonecoin", true}, + {Denom: "aonecoin", Enabled: true}, }, }, { name: "one false", sendEnableds: []*types.SendEnabled{ - {"bonecoin", false}, + {Denom: "bonecoin", Enabled: false}, }, }, { name: "two true", sendEnableds: []*types.SendEnabled{ - {"conecoin", true}, - {"ctwocoin", true}, + {Denom: "conecoin", Enabled: true}, + {Denom: "ctwocoin", Enabled: true}, }, }, { name: "two true false", sendEnableds: []*types.SendEnabled{ - {"donecoin", true}, - {"dtwocoin", false}, + {Denom: "donecoin", Enabled: true}, + {Denom: "dtwocoin", Enabled: false}, }, }, { name: "two false true", sendEnableds: []*types.SendEnabled{ - {"eonecoin", false}, - {"etwocoin", true}, + {Denom: "eonecoin", Enabled: false}, + {Denom: "etwocoin", Enabled: true}, }, }, { name: "two false", sendEnableds: []*types.SendEnabled{ - {"fonecoin", false}, - {"ftwocoin", false}, + {Denom: "fonecoin", Enabled: false}, + {Denom: "ftwocoin", Enabled: false}, }, }, } for _, def := range []bool{true, false} { params := types.Params{DefaultSendEnabled: def} - bankKeeper.SetParams(ctx, params) + suite.Require().NoError(bankKeeper.SetParams(ctx, params)) for _, tc := range tests { suite.T().Run(fmt.Sprintf("%s default %t", tc.name, def), func(t *testing.T) { bankKeeper.SetAllSendEnabled(ctx, tc.sendEnableds) @@ -1466,7 +1468,7 @@ func (suite *IntegrationTestSuite) TestDeleteSendEnabled() { for _, def := range []bool{true, false} { params := types.Params{DefaultSendEnabled: def} - bankKeeper.SetParams(ctx, params) + suite.Require().NoError(bankKeeper.SetParams(ctx, params)) suite.T().Run(fmt.Sprintf("default %t", def), func(t *testing.T) { denom := fmt.Sprintf("somerand%tcoin", !def) bankKeeper.SetSendEnabled(ctx, denom, !def) @@ -1482,7 +1484,7 @@ func (suite *IntegrationTestSuite) TestIterateSendEnabledEntries() { suite.T().Run("no entries to iterate", func(t *testing.T) { count := 0 - bankKeeper.IterateSendEnabledEntries(ctx, func(denom string, sendEnabled bool) (stop bool) { + bankKeeper.IterateSendEnabledEntries(ctx, func(_ string, _ bool) (stop bool) { count++ return false }) @@ -1500,7 +1502,7 @@ func (suite *IntegrationTestSuite) TestIterateSendEnabledEntries() { for _, def := range []bool{true, false} { params := types.Params{DefaultSendEnabled: def} - bankKeeper.SetParams(ctx, params) + suite.Require().NoError(bankKeeper.SetParams(ctx, params)) var seen []string suite.T().Run(fmt.Sprintf("all denoms have expected values default %t", def), func(t *testing.T) { bankKeeper.IterateSendEnabledEntries(ctx, func(denom string, sendEnabled bool) (stop bool) { @@ -1524,7 +1526,7 @@ func (suite *IntegrationTestSuite) TestIterateSendEnabledEntries() { suite.T().Run("no entries to iterate again after deleting all of them", func(t *testing.T) { count := 0 - bankKeeper.IterateSendEnabledEntries(ctx, func(denom string, sendEnabled bool) (stop bool) { + bankKeeper.IterateSendEnabledEntries(ctx, func(_ string, _ bool) (stop bool) { count++ return false }) @@ -1551,7 +1553,7 @@ func (suite *IntegrationTestSuite) TestGetAllSendEnabledEntries() { for _, def := range []bool{true, false} { params := types.Params{DefaultSendEnabled: def} - bankKeeper.SetParams(ctx, params) + suite.Require().NoError(bankKeeper.SetParams(ctx, params)) var seen []string suite.T().Run(fmt.Sprintf("all denoms have expected values default %t", def), func(t *testing.T) { actual := bankKeeper.GetAllSendEnabledEntries(ctx) @@ -1579,14 +1581,25 @@ func (suite *IntegrationTestSuite) TestGetAllSendEnabledEntries() { }) } +type mockSubspace struct { + ps banktypes.Params +} + +func (ms mockSubspace) GetParamSet(ctx sdk.Context, ps exported.ParamSet) { + *ps.(*banktypes.Params) = ms.ps +} + func (suite *IntegrationTestSuite) TestMigrator_Migrate3to4() { ctx, bankKeeper := suite.ctx, suite.app.BankKeeper for _, def := range []bool{true, false} { params := types.Params{DefaultSendEnabled: def} - bankKeeper.SetParams(ctx, params) + suite.Require().NoError(bankKeeper.SetParams(ctx, params)) suite.T().Run(fmt.Sprintf("default %t does not change", def), func(t *testing.T) { - migrator := keeper.NewMigrator(bankKeeper.(keeper.BaseKeeper)) + legacySubspace := func(ps types.Params) mockSubspace { + return mockSubspace{ps: ps} + }(banktypes.NewParams(def)) + migrator := keeper.NewMigrator(bankKeeper.(keeper.BaseKeeper), legacySubspace) require.NoError(t, migrator.Migrate3to4(ctx)) actual := bankKeeper.GetParams(ctx) assert.Equal(t, params.DefaultSendEnabled, actual.DefaultSendEnabled) @@ -1596,13 +1609,16 @@ func (suite *IntegrationTestSuite) TestMigrator_Migrate3to4() { for _, def := range []bool{true, false} { params := types.Params{ SendEnabled: []*types.SendEnabled{ - {fmt.Sprintf("truecoin%t", def), true}, - {fmt.Sprintf("falsecoin%t", def), false}, + {Denom: fmt.Sprintf("truecoin%t", def), Enabled: true}, + {Denom: fmt.Sprintf("falsecoin%t", def), Enabled: false}, }, } - bankKeeper.SetParams(ctx, params) + suite.Require().NoError(bankKeeper.SetParams(ctx, params)) suite.T().Run(fmt.Sprintf("default %t send enabled info moved to store", def), func(t *testing.T) { - migrator := keeper.NewMigrator(bankKeeper.(keeper.BaseKeeper)) + legacySubspace := func(ps types.Params) mockSubspace { + return mockSubspace{ps: ps} + }(banktypes.NewParams(def)) + migrator := keeper.NewMigrator(bankKeeper.(keeper.BaseKeeper), legacySubspace) require.NoError(t, migrator.Migrate3to4(ctx)) newParams := bankKeeper.GetParams(ctx) assert.Len(t, newParams.SendEnabled, 0) @@ -1618,10 +1634,10 @@ func (suite *IntegrationTestSuite) TestSetParams() { ctx, bankKeeper := suite.ctx, suite.app.BankKeeper params := types.NewParams(true) params.SendEnabled = []*types.SendEnabled{ - {"paramscointrue", true}, - {"paramscoinfalse", false}, + {Denom: "paramscointrue", Enabled: true}, + {Denom: "paramscoinfalse", Enabled: false}, } - bankKeeper.SetParams(ctx, params) + suite.Require().NoError(bankKeeper.SetParams(ctx, params)) suite.Run("stored params are as expected", func() { actual := bankKeeper.GetParams(ctx) diff --git a/x/bank/keeper/migrations.go b/x/bank/keeper/migrations.go index 88ea12c7392a..2e2d0ee7ad7a 100644 --- a/x/bank/keeper/migrations.go +++ b/x/bank/keeper/migrations.go @@ -2,35 +2,34 @@ package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" - v043 "github.com/cosmos/cosmos-sdk/x/bank/migrations/v043" - v046 "github.com/cosmos/cosmos-sdk/x/bank/migrations/v046" - banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + "github.com/cosmos/cosmos-sdk/x/bank/exported" + v2 "github.com/cosmos/cosmos-sdk/x/bank/migrations/v2" + v3 "github.com/cosmos/cosmos-sdk/x/bank/migrations/v3" + v4 "github.com/cosmos/cosmos-sdk/x/bank/migrations/v4" ) // Migrator is a struct for handling in-place store migrations. type Migrator struct { - keeper BaseKeeper + keeper BaseKeeper + legacySubspace exported.Subspace } // NewMigrator returns a new Migrator. -func NewMigrator(keeper BaseKeeper) Migrator { - return Migrator{keeper: keeper} +func NewMigrator(keeper BaseKeeper, legacySubspace exported.Subspace) Migrator { + return Migrator{keeper: keeper, legacySubspace: legacySubspace} } // Migrate1to2 migrates from version 1 to 2. func (m Migrator) Migrate1to2(ctx sdk.Context) error { - return v043.MigrateStore(ctx, m.keeper.storeKey, m.keeper.cdc) + return v2.MigrateStore(ctx, m.keeper.storeKey, m.keeper.cdc) } // Migrate2to3 migrates x/bank storage from version 2 to 3. func (m Migrator) Migrate2to3(ctx sdk.Context) error { - return v046.MigrateStore(ctx, m.keeper.storeKey, m.keeper.cdc) + return v3.MigrateStore(ctx, m.keeper.storeKey, m.keeper.cdc) } // Migrate3to4 migrates x/bank storage from version 3 to 4. func (m Migrator) Migrate3to4(ctx sdk.Context) error { - oldParams := m.keeper.GetParams(ctx) - m.keeper.SetAllSendEnabled(ctx, oldParams.GetSendEnabled()) - m.keeper.SetParams(ctx, banktypes.NewParams(oldParams.DefaultSendEnabled)) - return nil + return v4.MigrateStore(ctx, m.keeper.storeKey, m.legacySubspace, m.keeper.cdc) } diff --git a/x/bank/keeper/msg_server.go b/x/bank/keeper/msg_server.go index b21559c2f3f1..b33e3394f49b 100644 --- a/x/bank/keeper/msg_server.go +++ b/x/bank/keeper/msg_server.go @@ -7,22 +7,24 @@ import ( "github.com/cosmos/cosmos-sdk/telemetry" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/errors" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/x/bank/types" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" ) type msgServer struct { Keeper } +var _ types.MsgServer = msgServer{} + // NewMsgServerImpl returns an implementation of the bank MsgServer interface // for the provided Keeper. func NewMsgServerImpl(keeper Keeper) types.MsgServer { return &msgServer{Keeper: keeper} } -var _ types.MsgServer = msgServer{} - func (k msgServer) Send(goCtx context.Context, msg *types.MsgSend) (*types.MsgSendResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) @@ -100,3 +102,24 @@ func (k msgServer) MultiSend(goCtx context.Context, msg *types.MsgMultiSend) (*t return &types.MsgMultiSendResponse{}, nil } + +func (k msgServer) UpdateParams(goCtx context.Context, req *types.MsgUpdateParams) (*types.MsgUpdateParamsResponse, error) { + if k.GetAuthority() != req.Authority { + return nil, errors.Wrapf(govtypes.ErrInvalidSigner, "invalid authority; expected %s, got %s", k.GetAuthority(), req.Authority) + } + + ctx := sdk.UnwrapSDKContext(goCtx) + if err := k.SetParams(ctx, req.Params); err != nil { + return nil, err + } + + ctx.EventManager().EmitEvent( + sdk.NewEvent( + sdk.EventTypeMessage, + sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + sdk.NewAttribute(sdk.AttributeKeySender, req.Authority), + ), + ) + + return &types.MsgUpdateParamsResponse{}, nil +} diff --git a/x/bank/keeper/msg_service_test.go b/x/bank/keeper/msg_service_test.go new file mode 100644 index 000000000000..633c62a16d64 --- /dev/null +++ b/x/bank/keeper/msg_service_test.go @@ -0,0 +1,61 @@ +package keeper_test + +import ( + "github.com/cosmos/cosmos-sdk/x/bank/types" +) + +func (suite *IntegrationTestSuite) TestMsgUpdateParams() { + // default params + params := types.DefaultParams() + + testCases := []struct { + name string + input *types.MsgUpdateParams + expErr bool + expErrMsg string + }{ + { + name: "invalid authority", + input: &types.MsgUpdateParams{ + Authority: "invalid", + Params: params, + }, + expErr: true, + expErrMsg: "invalid authority", + }, + { + name: "send enabled param", + input: &types.MsgUpdateParams{ + Authority: suite.app.BankKeeper.GetAuthority(), + Params: types.Params{ + SendEnabled: []*types.SendEnabled{ + {Denom: "foo", Enabled: true}, + }, + }, + }, + expErr: false, + }, + { + name: "all good", + input: &types.MsgUpdateParams{ + Authority: suite.app.BankKeeper.GetAuthority(), + Params: params, + }, + expErr: false, + }, + } + + for _, tc := range testCases { + tc := tc + suite.Run(tc.name, func() { + _, err := suite.msgServer.UpdateParams(suite.ctx, tc.input) + + if tc.expErr { + suite.Require().Error(err) + suite.Require().Contains(err.Error(), tc.expErrMsg) + } else { + suite.Require().NoError(err) + } + }) + } +} diff --git a/x/bank/keeper/send.go b/x/bank/keeper/send.go index aff745fd1888..16bd31e661ec 100644 --- a/x/bank/keeper/send.go +++ b/x/bank/keeper/send.go @@ -1,6 +1,8 @@ package keeper import ( + "fmt" + "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/store/prefix" storetypes "github.com/cosmos/cosmos-sdk/store/types" @@ -9,7 +11,6 @@ import ( "github.com/cosmos/cosmos-sdk/types/address" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/x/bank/types" - paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" ) // SendKeeper defines a module interface that facilitates the transfer of coins @@ -17,11 +18,11 @@ import ( type SendKeeper interface { ViewKeeper - InputOutputCoins(ctx sdk.Context, inputs types.Input, outputs []types.Output) error + InputOutputCoins(ctx sdk.Context, input types.Input, outputs []types.Output) error SendCoins(ctx sdk.Context, fromAddr sdk.AccAddress, toAddr sdk.AccAddress, amt sdk.Coins) error GetParams(ctx sdk.Context) types.Params - SetParams(ctx sdk.Context, params types.Params) + SetParams(ctx sdk.Context, params types.Params) error IsSendEnabledDenom(ctx sdk.Context, denom string) bool GetSendEnabledEntry(ctx sdk.Context, denom string) (types.SendEnabled, bool) @@ -36,6 +37,8 @@ type SendKeeper interface { BlockedAddr(addr sdk.AccAddress) bool GetBlockedAddresses() map[string]bool + + GetAuthority() string } var _ SendKeeper = (*BaseSendKeeper)(nil) @@ -45,44 +48,73 @@ var _ SendKeeper = (*BaseSendKeeper)(nil) type BaseSendKeeper struct { BaseViewKeeper - cdc codec.BinaryCodec - ak types.AccountKeeper - storeKey storetypes.StoreKey - paramSpace paramtypes.Subspace + cdc codec.BinaryCodec + ak types.AccountKeeper + storeKey storetypes.StoreKey // list of addresses that are restricted from receiving transactions blockedAddrs map[string]bool + + // the address capable of executing a MsgUpdateParams message. Typically, this + // should be the x/gov module account. + authority string } func NewBaseSendKeeper( - cdc codec.BinaryCodec, storeKey storetypes.StoreKey, ak types.AccountKeeper, paramSpace paramtypes.Subspace, blockedAddrs map[string]bool, + cdc codec.BinaryCodec, + storeKey storetypes.StoreKey, + ak types.AccountKeeper, + blockedAddrs map[string]bool, + authority string, ) BaseSendKeeper { + if _, err := sdk.AccAddressFromBech32(authority); err != nil { + panic(fmt.Errorf("invalid bank authority address: %w", err)) + } + return BaseSendKeeper{ BaseViewKeeper: NewBaseViewKeeper(cdc, storeKey, ak), cdc: cdc, ak: ak, storeKey: storeKey, - paramSpace: paramSpace, blockedAddrs: blockedAddrs, + authority: authority, } } +// GetAuthority returns the x/bank module's authority. +func (k BaseSendKeeper) GetAuthority() string { + return k.authority +} + // GetParams returns the total set of bank parameters. func (k BaseSendKeeper) GetParams(ctx sdk.Context) (params types.Params) { - k.paramSpace.GetParamSet(ctx, ¶ms) + store := ctx.KVStore(k.storeKey) + bz := store.Get(types.ParamsKey) + if bz == nil { + return params + } + + k.cdc.MustUnmarshal(bz, ¶ms) return params } // SetParams sets the total set of bank parameters. -// -// nolint:staticcheck -func (k BaseSendKeeper) SetParams(ctx sdk.Context, params types.Params) { +func (k BaseSendKeeper) SetParams(ctx sdk.Context, params types.Params) error { + // normally SendEnabled is deprecated but we still support it for backwards compatibility + // using params.Validate() would fail due to the SendEnabled deprecation if len(params.SendEnabled) > 0 { k.SetAllSendEnabled(ctx, params.SendEnabled) + // override params without SendEnabled + params = types.NewParams(params.DefaultSendEnabled) } - p := types.NewParams(params.DefaultSendEnabled) - k.paramSpace.SetParamSet(ctx, &p) + store := ctx.KVStore(k.storeKey) + bz, err := k.cdc.Marshal(¶ms) + if err != nil { + return err + } + store.Set(types.ParamsKey, bz) + return nil } // InputOutputCoins performs multi-send functionality. It accepts a series of diff --git a/x/bank/migrations/v042/types.go b/x/bank/migrations/v1/types.go similarity index 95% rename from x/bank/migrations/v042/types.go rename to x/bank/migrations/v1/types.go index ae24a0ebe9f4..18607758964d 100644 --- a/x/bank/migrations/v042/types.go +++ b/x/bank/migrations/v1/types.go @@ -1,4 +1,4 @@ -package v042 +package v1 import ( codectypes "github.com/cosmos/cosmos-sdk/codec/types" @@ -60,7 +60,7 @@ type SupplyI interface { proto.Message } -// RegisterInterfaces registers interfaces required for the v0.40 migrations. +// RegisterInterfaces registers interfaces required for the v1 migrations. func RegisterInterfaces(registry codectypes.InterfaceRegistry) { registry.RegisterInterface( "cosmos.bank.v1beta1.SupplyI", diff --git a/x/bank/migrations/v043/json.go b/x/bank/migrations/v2/json.go similarity index 98% rename from x/bank/migrations/v043/json.go rename to x/bank/migrations/v2/json.go index 7b5ce62593bd..0c128db21d3c 100644 --- a/x/bank/migrations/v043/json.go +++ b/x/bank/migrations/v2/json.go @@ -1,4 +1,4 @@ -package v043 +package v2 import ( sdk "github.com/cosmos/cosmos-sdk/types" diff --git a/x/bank/migrations/v043/json_test.go b/x/bank/migrations/v2/json_test.go similarity index 93% rename from x/bank/migrations/v043/json_test.go rename to x/bank/migrations/v2/json_test.go index c3aee43c85f8..677a211fb8e9 100644 --- a/x/bank/migrations/v043/json_test.go +++ b/x/bank/migrations/v2/json_test.go @@ -1,4 +1,4 @@ -package v043_test +package v2_test import ( "encoding/json" @@ -9,7 +9,7 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" - v043bank "github.com/cosmos/cosmos-sdk/x/bank/migrations/v043" + v2bank "github.com/cosmos/cosmos-sdk/x/bank/migrations/v2" "github.com/cosmos/cosmos-sdk/x/bank/types" ) @@ -41,7 +41,7 @@ func TestMigrateJSON(t *testing.T) { }, } - migrated := v043bank.MigrateJSON(bankGenState) + migrated := v2bank.MigrateJSON(bankGenState) bz, err := clientCtx.Codec.MarshalJSON(migrated) require.NoError(t, err) diff --git a/x/bank/migrations/v043/keys.go b/x/bank/migrations/v2/keys.go similarity index 98% rename from x/bank/migrations/v043/keys.go rename to x/bank/migrations/v2/keys.go index ef24217ef0f3..eadb02e9d8d8 100644 --- a/x/bank/migrations/v043/keys.go +++ b/x/bank/migrations/v2/keys.go @@ -1,4 +1,4 @@ -package v043 +package v2 import ( "errors" diff --git a/x/bank/migrations/v043/store.go b/x/bank/migrations/v2/store.go similarity index 90% rename from x/bank/migrations/v043/store.go rename to x/bank/migrations/v2/store.go index d745f7807cf6..5431e7afa330 100644 --- a/x/bank/migrations/v043/store.go +++ b/x/bank/migrations/v2/store.go @@ -1,4 +1,4 @@ -package v043 +package v2 import ( "github.com/cosmos/cosmos-sdk/codec" @@ -6,7 +6,7 @@ import ( storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" v042auth "github.com/cosmos/cosmos-sdk/x/auth/migrations/v042" - v042bank "github.com/cosmos/cosmos-sdk/x/bank/migrations/v042" + v1 "github.com/cosmos/cosmos-sdk/x/bank/migrations/v1" "github.com/cosmos/cosmos-sdk/x/bank/types" ) @@ -15,14 +15,14 @@ import ( // ref: https://github.com/cosmos/cosmos-sdk/issues/7092 func migrateSupply(store sdk.KVStore, cdc codec.BinaryCodec) error { // Old supply was stored as a single blob under the SupplyKey. - var oldSupplyI v042bank.SupplyI - err := cdc.UnmarshalInterface(store.Get(v042bank.SupplyKey), &oldSupplyI) + var oldSupplyI v1.SupplyI + err := cdc.UnmarshalInterface(store.Get(v1.SupplyKey), &oldSupplyI) if err != nil { return err } // We delete the single key holding the whole blob. - store.Delete(v042bank.SupplyKey) + store.Delete(v1.SupplyKey) if oldSupplyI == nil { return nil @@ -54,13 +54,13 @@ func migrateBalanceKeys(store sdk.KVStore) { // prefix ("balances") || addrBytes (20 bytes) || denomBytes // new key is of format // prefix (0x02) || addrLen (1 byte) || addrBytes || denomBytes - oldStore := prefix.NewStore(store, v042bank.BalancesPrefix) + oldStore := prefix.NewStore(store, v1.BalancesPrefix) oldStoreIter := oldStore.Iterator(nil, nil) defer oldStoreIter.Close() for ; oldStoreIter.Valid(); oldStoreIter.Next() { - addr := v042bank.AddressFromBalancesStore(oldStoreIter.Key()) + addr := v1.AddressFromBalancesStore(oldStoreIter.Key()) denom := oldStoreIter.Key()[v042auth.AddrLen:] newStoreKey := append(CreateAccountBalancesPrefix(addr), denom...) diff --git a/x/bank/migrations/v043/store_test.go b/x/bank/migrations/v2/store_test.go similarity index 84% rename from x/bank/migrations/v043/store_test.go rename to x/bank/migrations/v2/store_test.go index 04117b3c3b32..a142f2a516ad 100644 --- a/x/bank/migrations/v043/store_test.go +++ b/x/bank/migrations/v2/store_test.go @@ -1,4 +1,4 @@ -package v043_test +package v2_test import ( "testing" @@ -10,8 +10,8 @@ import ( "github.com/cosmos/cosmos-sdk/testutil" "github.com/cosmos/cosmos-sdk/testutil/testdata" sdk "github.com/cosmos/cosmos-sdk/types" - v042bank "github.com/cosmos/cosmos-sdk/x/bank/migrations/v042" - v043bank "github.com/cosmos/cosmos-sdk/x/bank/migrations/v043" + v1bank "github.com/cosmos/cosmos-sdk/x/bank/migrations/v1" + v2bank "github.com/cosmos/cosmos-sdk/x/bank/migrations/v2" "github.com/cosmos/cosmos-sdk/x/bank/types" ) @@ -21,19 +21,21 @@ func TestSupplyMigration(t *testing.T) { ctx := testutil.DefaultContext(bankKey, sdk.NewTransientStoreKey("transient_test")) store := ctx.KVStore(bankKey) + v1bank.RegisterInterfaces(encCfg.InterfaceRegistry) + oldFooCoin := sdk.NewCoin("foo", sdk.NewInt(100)) oldBarCoin := sdk.NewCoin("bar", sdk.NewInt(200)) oldFooBarCoin := sdk.NewCoin("foobar", sdk.NewInt(0)) // to ensure the zero denom coins pruned. // Old supply was stored as a single blob under the `SupplyKey`. - var oldSupply v042bank.SupplyI + var oldSupply v1bank.SupplyI oldSupply = &types.Supply{Total: sdk.Coins{oldFooCoin, oldBarCoin, oldFooBarCoin}} oldSupplyBz, err := encCfg.Codec.MarshalInterface(oldSupply) require.NoError(t, err) - store.Set(v042bank.SupplyKey, oldSupplyBz) + store.Set(v1bank.SupplyKey, oldSupplyBz) // Run migration. - err = v043bank.MigrateStore(ctx, bankKey, encCfg.Codec) + err = v2bank.MigrateStore(ctx, bankKey, encCfg.Codec) require.NoError(t, err) // New supply is indexed by denom. @@ -74,20 +76,20 @@ func TestBalanceKeysMigration(t *testing.T) { // set 10 foo coin fooCoin := sdk.NewCoin("foo", sdk.NewInt(10)) - oldFooKey := append(append(v042bank.BalancesPrefix, addr...), []byte(fooCoin.Denom)...) + oldFooKey := append(append(v1bank.BalancesPrefix, addr...), []byte(fooCoin.Denom)...) fooBz, err := encCfg.Codec.Marshal(&fooCoin) require.NoError(t, err) store.Set(oldFooKey, fooBz) // set 0 foobar coin fooBarCoin := sdk.NewCoin("foobar", sdk.NewInt(0)) - oldKeyFooBar := append(append(v042bank.BalancesPrefix, addr...), []byte(fooBarCoin.Denom)...) + oldKeyFooBar := append(append(v1bank.BalancesPrefix, addr...), []byte(fooBarCoin.Denom)...) fooBarBz, err := encCfg.Codec.Marshal(&fooBarCoin) require.NoError(t, err) store.Set(oldKeyFooBar, fooBarBz) require.NotNil(t, store.Get(oldKeyFooBar)) // before store migation zero values can also exist in store. - err = v043bank.MigrateStore(ctx, bankKey, encCfg.Codec) + err = v2bank.MigrateStore(ctx, bankKey, encCfg.Codec) require.NoError(t, err) newKey := append(types.CreateAccountBalancesPrefix(addr), []byte(fooCoin.Denom)...) diff --git a/x/bank/migrations/v046/keys.go b/x/bank/migrations/v3/keys.go similarity index 97% rename from x/bank/migrations/v046/keys.go rename to x/bank/migrations/v3/keys.go index c86aae935805..1b7afe3f9e64 100644 --- a/x/bank/migrations/v046/keys.go +++ b/x/bank/migrations/v3/keys.go @@ -1,4 +1,4 @@ -package v046 +package v3 var DenomAddressPrefix = []byte{0x03} diff --git a/x/bank/migrations/v046/store.go b/x/bank/migrations/v3/store.go similarity index 90% rename from x/bank/migrations/v046/store.go rename to x/bank/migrations/v3/store.go index 8f4e628a11ea..1ac18373f5c8 100644 --- a/x/bank/migrations/v046/store.go +++ b/x/bank/migrations/v3/store.go @@ -1,4 +1,4 @@ -package v046 +package v3 import ( "github.com/cosmos/cosmos-sdk/codec" @@ -6,7 +6,7 @@ import ( storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/address" - v043 "github.com/cosmos/cosmos-sdk/x/bank/migrations/v043" + v2 "github.com/cosmos/cosmos-sdk/x/bank/migrations/v2" "github.com/cosmos/cosmos-sdk/x/bank/types" ) @@ -27,7 +27,7 @@ func MigrateStore(ctx sdk.Context, storeKey storetypes.StoreKey, cdc codec.Binar } func addDenomReverseIndex(store sdk.KVStore, cdc codec.BinaryCodec) error { - oldBalancesStore := prefix.NewStore(store, v043.BalancesPrefix) + oldBalancesStore := prefix.NewStore(store, v2.BalancesPrefix) oldBalancesIter := oldBalancesStore.Iterator(nil, nil) defer oldBalancesIter.Close() @@ -40,7 +40,7 @@ func addDenomReverseIndex(store sdk.KVStore, cdc codec.BinaryCodec) error { return err } - addr, err := v043.AddressFromBalancesStore(oldBalancesIter.Key()) + addr, err := v2.AddressFromBalancesStore(oldBalancesIter.Key()) if err != nil { return err } @@ -73,7 +73,7 @@ func addDenomReverseIndex(store sdk.KVStore, cdc codec.BinaryCodec) error { } func migrateDenomMetadata(store sdk.KVStore) error { - oldDenomMetaDataStore := prefix.NewStore(store, v043.DenomMetadataPrefix) + oldDenomMetaDataStore := prefix.NewStore(store, v2.DenomMetadataPrefix) oldDenomMetaDataIter := oldDenomMetaDataStore.Iterator(nil, nil) defer oldDenomMetaDataIter.Close() diff --git a/x/bank/migrations/v046/store_test.go b/x/bank/migrations/v3/store_test.go similarity index 84% rename from x/bank/migrations/v046/store_test.go rename to x/bank/migrations/v3/store_test.go index db44f2591fdc..88a411ef9029 100644 --- a/x/bank/migrations/v046/store_test.go +++ b/x/bank/migrations/v3/store_test.go @@ -1,4 +1,4 @@ -package v046_test +package v3_test import ( "testing" @@ -10,8 +10,8 @@ import ( "github.com/cosmos/cosmos-sdk/testutil" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/address" - v043 "github.com/cosmos/cosmos-sdk/x/bank/migrations/v043" - v046 "github.com/cosmos/cosmos-sdk/x/bank/migrations/v046" + v2 "github.com/cosmos/cosmos-sdk/x/bank/migrations/v2" + v3 "github.com/cosmos/cosmos-sdk/x/bank/migrations/v3" "github.com/cosmos/cosmos-sdk/x/bank/types" ) @@ -22,7 +22,7 @@ func TestMigrateStore(t *testing.T) { store := ctx.KVStore(bankKey) addr := sdk.AccAddress([]byte("addr________________")) - prefixAccStore := prefix.NewStore(store, v043.CreateAccountBalancesPrefix(addr)) + prefixAccStore := prefix.NewStore(store, v2.CreateAccountBalancesPrefix(addr)) balances := sdk.NewCoins( sdk.NewCoin("foo", sdk.NewInt(10000)), @@ -36,7 +36,7 @@ func TestMigrateStore(t *testing.T) { prefixAccStore.Set([]byte(b.Denom), bz) } - require.NoError(t, v046.MigrateStore(ctx, bankKey, encCfg.Codec)) + require.NoError(t, v3.MigrateStore(ctx, bankKey, encCfg.Codec)) for _, b := range balances { addrPrefixStore := prefix.NewStore(store, types.CreateAccountBalancesPrefix(addr)) @@ -47,7 +47,7 @@ func TestMigrateStore(t *testing.T) { } for _, b := range balances { - denomPrefixStore := prefix.NewStore(store, v046.CreateDenomAddressPrefix(b.Denom)) + denomPrefixStore := prefix.NewStore(store, v3.CreateDenomAddressPrefix(b.Denom)) bz := denomPrefixStore.Get(address.MustLengthPrefix(addr)) require.NotNil(t, bz) } @@ -84,10 +84,10 @@ func TestMigrateDenomMetaData(t *testing.T) { Display: "token", }, } - denomMetadataStore := prefix.NewStore(store, v043.DenomMetadataPrefix) + denomMetadataStore := prefix.NewStore(store, v2.DenomMetadataPrefix) for i := range []int{0, 1} { - key := append(v043.DenomMetadataPrefix, []byte(metaData[i].Base)...) + key := append(v2.DenomMetadataPrefix, []byte(metaData[i].Base)...) // keys before 0.45 had denom two times in the key key = append(key, []byte(metaData[i].Base)...) bz, err := encCfg.Codec.Marshal(&metaData[i]) @@ -95,9 +95,9 @@ func TestMigrateDenomMetaData(t *testing.T) { denomMetadataStore.Set(key, bz) } - require.NoError(t, v046.MigrateStore(ctx, bankKey, encCfg.Codec)) + require.NoError(t, v3.MigrateStore(ctx, bankKey, encCfg.Codec)) - denomMetadataStore = prefix.NewStore(store, v043.DenomMetadataPrefix) + denomMetadataStore = prefix.NewStore(store, v2.DenomMetadataPrefix) denomMetadataIter := denomMetadataStore.Iterator(nil, nil) defer denomMetadataIter.Close() for i := 0; denomMetadataIter.Valid(); denomMetadataIter.Next() { diff --git a/x/bank/migrations/v047/gen_state.go b/x/bank/migrations/v4/gen_state.go similarity index 97% rename from x/bank/migrations/v047/gen_state.go rename to x/bank/migrations/v4/gen_state.go index a5c8157d7714..f81f3b6728ec 100644 --- a/x/bank/migrations/v047/gen_state.go +++ b/x/bank/migrations/v4/gen_state.go @@ -1,4 +1,4 @@ -package v047 +package v4 import ( "github.com/cosmos/cosmos-sdk/x/bank/types" diff --git a/x/bank/migrations/v047/gen_state_test.go b/x/bank/migrations/v4/gen_state_test.go similarity index 79% rename from x/bank/migrations/v047/gen_state_test.go rename to x/bank/migrations/v4/gen_state_test.go index 661275066a65..19b15e5a137b 100644 --- a/x/bank/migrations/v047/gen_state_test.go +++ b/x/bank/migrations/v4/gen_state_test.go @@ -1,4 +1,4 @@ -package v047 +package v4_test import ( "testing" @@ -6,6 +6,7 @@ import ( "github.com/stretchr/testify/assert" sdk "github.com/cosmos/cosmos-sdk/types" + v4 "github.com/cosmos/cosmos-sdk/x/bank/migrations/v4" "github.com/cosmos/cosmos-sdk/x/bank/types" ) @@ -80,16 +81,16 @@ func TestMigrateGenState(t *testing.T) { oldState: &types.GenesisState{ Params: types.Params{ SendEnabled: []*types.SendEnabled{ - {"movecointrue", true}, - {"movecoinfalse", false}, + {Denom: "movecointrue", Enabled: true}, + {Denom: "movecoinfalse", Enabled: false}, }, }, }, newState: &types.GenesisState{ Params: types.Params{}, SendEnabled: []types.SendEnabled{ - {"movecointrue", true}, - {"movecoinfalse", false}, + {Denom: "movecointrue", Enabled: true}, + {Denom: "movecoinfalse", Enabled: false}, }, }, }, @@ -98,20 +99,20 @@ func TestMigrateGenState(t *testing.T) { oldState: &types.GenesisState{ Params: types.Params{ SendEnabled: []*types.SendEnabled{ - {"movecointrue", true}, - {"movecoinfalse", false}, + {Denom: "movecointrue", Enabled: true}, + {Denom: "movecoinfalse", Enabled: false}, }, }, SendEnabled: []types.SendEnabled{ - {"staycoin", true}, + {Denom: "staycoin", Enabled: true}, }, }, newState: &types.GenesisState{ Params: types.Params{}, SendEnabled: []types.SendEnabled{ - {"staycoin", true}, - {"movecointrue", true}, - {"movecoinfalse", false}, + {Denom: "staycoin", Enabled: true}, + {Denom: "movecointrue", Enabled: true}, + {Denom: "movecoinfalse", Enabled: false}, }, }, }, @@ -120,17 +121,17 @@ func TestMigrateGenState(t *testing.T) { oldState: &types.GenesisState{ Params: types.Params{ SendEnabled: []*types.SendEnabled{ - {"staycoin", false}, + {Denom: "staycoin", Enabled: false}, }, }, SendEnabled: []types.SendEnabled{ - {"staycoin", true}, + {Denom: "staycoin", Enabled: true}, }, }, newState: &types.GenesisState{ Params: types.Params{}, SendEnabled: []types.SendEnabled{ - {"staycoin", true}, + {Denom: "staycoin", Enabled: true}, }, }, }, @@ -138,7 +139,7 @@ func TestMigrateGenState(t *testing.T) { for _, tc := range tests { t.Run(tc.name, func(t *testing.T) { - actual := MigrateGenState(tc.oldState) + actual := v4.MigrateGenState(tc.oldState) assert.Equal(t, tc.newState, actual) }) } @@ -147,12 +148,12 @@ func TestMigrateGenState(t *testing.T) { origState := types.GenesisState{ Params: types.Params{ SendEnabled: []*types.SendEnabled{ - {"movecointrue", true}, - {"movecoinfalse", false}, + {Denom: "movecointrue", Enabled: true}, + {Denom: "movecoinfalse", Enabled: false}, }, }, } - _ = MigrateGenState(&origState) + _ = v4.MigrateGenState(&origState) assert.Len(t, origState.Params.SendEnabled, 2) }) } diff --git a/x/bank/migrations/v4/store.go b/x/bank/migrations/v4/store.go new file mode 100644 index 000000000000..03c5b02f43bc --- /dev/null +++ b/x/bank/migrations/v4/store.go @@ -0,0 +1,36 @@ +package v4 + +import ( + "github.com/cosmos/cosmos-sdk/codec" + storetypes "github.com/cosmos/cosmos-sdk/store/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/bank/exported" + "github.com/cosmos/cosmos-sdk/x/bank/types" +) + +const ModuleName = "bank" + +var ParamsKey = []byte{0x05} + +// MigrateStore migrates the x/bank module state from the consensus version 3 to +// version 4. Specifically, it takes the parameters that are currently stored +// and managed by the x/params module and stores them directly into the x/bank +// module state. +func MigrateStore(ctx sdk.Context, storeKey storetypes.StoreKey, legacySubspace exported.Subspace, cdc codec.BinaryCodec) error { + store := ctx.KVStore(storeKey) + var currParams types.Params + legacySubspace.GetParamSet(ctx, &currParams) + + if err := currParams.Validate(); err != nil { + return err + } + + bz, err := cdc.Marshal(&currParams) + if err != nil { + return err + } + + store.Set(ParamsKey, bz) + + return nil +} diff --git a/x/bank/migrations/v4/store_test.go b/x/bank/migrations/v4/store_test.go new file mode 100644 index 000000000000..b9d2c035c25b --- /dev/null +++ b/x/bank/migrations/v4/store_test.go @@ -0,0 +1,44 @@ +package v4_test + +import ( + "testing" + + "github.com/cosmos/cosmos-sdk/testutil" + sdk "github.com/cosmos/cosmos-sdk/types" + moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" + "github.com/cosmos/cosmos-sdk/x/bank" + "github.com/cosmos/cosmos-sdk/x/bank/exported" + v4 "github.com/cosmos/cosmos-sdk/x/bank/migrations/v4" + "github.com/cosmos/cosmos-sdk/x/bank/types" + "github.com/stretchr/testify/require" +) + +type mockSubspace struct { + ps types.Params +} + +func newMockSubspace(ps types.Params) mockSubspace { + return mockSubspace{ps: ps} +} + +func (ms mockSubspace) GetParamSet(ctx sdk.Context, ps exported.ParamSet) { + *ps.(*types.Params) = ms.ps +} + +func TestMigrate(t *testing.T) { + encCfg := moduletestutil.MakeTestEncodingConfig(bank.AppModuleBasic{}) + cdc := encCfg.Codec + + storeKey := sdk.NewKVStoreKey(v4.ModuleName) + tKey := sdk.NewTransientStoreKey("transient_test") + ctx := testutil.DefaultContext(storeKey, tKey) + store := ctx.KVStore(storeKey) + + legacySubspace := newMockSubspace(types.DefaultParams()) + require.NoError(t, v4.MigrateStore(ctx, storeKey, legacySubspace, cdc)) + + var res types.Params + bz := store.Get(v4.ParamsKey) + require.NoError(t, cdc.Unmarshal(bz, &res)) + require.Equal(t, legacySubspace.ps, res) +} diff --git a/x/bank/module.go b/x/bank/module.go index 1e8b1c094e8d..647671b39205 100644 --- a/x/bank/module.go +++ b/x/bank/module.go @@ -10,7 +10,6 @@ import ( modulev1 "cosmossdk.io/api/cosmos/bank/module/v1" "cosmossdk.io/depinject" store "github.com/cosmos/cosmos-sdk/store/types" - paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" "github.com/tendermint/tendermint/crypto" "cosmossdk.io/core/appmodule" @@ -26,13 +25,19 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/cosmos/cosmos-sdk/x/bank/client/cli" + "github.com/cosmos/cosmos-sdk/x/bank/exported" "github.com/cosmos/cosmos-sdk/x/bank/keeper" - v040 "github.com/cosmos/cosmos-sdk/x/bank/migrations/v042" + v1bank "github.com/cosmos/cosmos-sdk/x/bank/migrations/v1" "github.com/cosmos/cosmos-sdk/x/bank/simulation" "github.com/cosmos/cosmos-sdk/x/bank/types" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" ) +// ConsensusVersion defines the current x/bank module consensus version. +const ConsensusVersion = 4 + var ( _ module.AppModule = AppModule{} _ module.AppModuleBasic = AppModuleBasic{} @@ -90,7 +95,7 @@ func (AppModuleBasic) RegisterInterfaces(registry codectypes.InterfaceRegistry) types.RegisterInterfaces(registry) // Register legacy interfaces for migration scripts. - v040.RegisterInterfaces(registry) + v1bank.RegisterInterfaces(registry) } // AppModule implements an application module for the bank module. @@ -99,6 +104,9 @@ type AppModule struct { keeper keeper.Keeper accountKeeper types.AccountKeeper + + // legacySubspace is used solely for migration of x/params managed parameters + legacySubspace exported.Subspace } // RegisterServices registers module services. @@ -106,7 +114,7 @@ func (am AppModule) RegisterServices(cfg module.Configurator) { types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper)) types.RegisterQueryServer(cfg.QueryServer(), am.keeper) - m := keeper.NewMigrator(am.keeper.(keeper.BaseKeeper)) + m := keeper.NewMigrator(am.keeper.(keeper.BaseKeeper), am.legacySubspace) if err := cfg.RegisterMigration(types.ModuleName, 1, m.Migrate1to2); err != nil { panic(fmt.Sprintf("failed to migrate x/bank from version 1 to 2: %v", err)) } @@ -121,11 +129,12 @@ func (am AppModule) RegisterServices(cfg module.Configurator) { } // NewAppModule creates a new AppModule object -func NewAppModule(cdc codec.Codec, keeper keeper.Keeper, accountKeeper types.AccountKeeper) AppModule { +func NewAppModule(cdc codec.Codec, keeper keeper.Keeper, accountKeeper types.AccountKeeper, ss exported.Subspace) AppModule { return AppModule{ AppModuleBasic: AppModuleBasic{cdc: cdc}, keeper: keeper, accountKeeper: accountKeeper, + legacySubspace: ss, } } @@ -170,7 +179,7 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw } // ConsensusVersion implements AppModule/ConsensusVersion. -func (AppModule) ConsensusVersion() uint64 { return 4 } +func (AppModule) ConsensusVersion() uint64 { return ConsensusVersion } // AppModuleSimulation functions @@ -184,9 +193,13 @@ func (AppModule) ProposalContents(_ module.SimulationState) []simtypes.WeightedP return nil } -// RandomizedParams creates randomized bank param changes for the simulator. -func (AppModule) RandomizedParams(r *rand.Rand) []simtypes.ParamChange { - return simulation.ParamChanges(r) +// RandomizedParams creates randomized distribution param changes for the simulator. + +// TODO: Returns an empty slice which will make parameter changes a no-op during +// simulations. Once all modules are migrated, remove RandomizedParams from +// the simulation interface. +func (AppModule) RandomizedParams(_ *rand.Rand) []simtypes.ParamChange { + return []simtypes.ParamChange{} } // RegisterStoreDecoder registers a decoder for supply module's types @@ -215,11 +228,15 @@ func provideModuleBasic() runtime.AppModuleBasicWrapper { type bankInputs struct { depinject.In - Config *modulev1.Module + Config *modulev1.Module + Cdc codec.Codec + Key *store.KVStoreKey + AccountKeeper types.AccountKeeper - Cdc codec.Codec - Subspace paramtypes.Subspace - Key *store.KVStoreKey + Authority types.BankAuthority `optional:"true"` + + // LegacySubspace is used solely for migration of x/params managed parameters + LegacySubspace exported.Subspace } type bankOutputs struct { @@ -246,7 +263,20 @@ func provideModule(in bankInputs) bankOutputs { } } - bankKeeper := keeper.NewBaseKeeper(in.Cdc, in.Key, in.AccountKeeper, in.Subspace, blockedAddresses) - m := NewAppModule(in.Cdc, bankKeeper, in.AccountKeeper) + authority := in.Authority + if authority == nil || len(authority) == 0 { + // default to governance authority if not provided + authority = types.BankAuthority(authtypes.NewModuleAddress(govtypes.ModuleName)) + } + + bankKeeper := keeper.NewBaseKeeper( + in.Cdc, + in.Key, + in.AccountKeeper, + blockedAddresses, + authority.String(), + ) + m := NewAppModule(in.Cdc, bankKeeper, in.AccountKeeper, in.LegacySubspace) + return bankOutputs{BankKeeper: bankKeeper, Module: runtime.WrapAppModule(m)} } diff --git a/x/bank/spec/02_keepers.md b/x/bank/spec/02_keepers.md index ef65aaebfc0b..7ccd03675eb7 100644 --- a/x/bank/spec/02_keepers.md +++ b/x/bank/spec/02_keepers.md @@ -86,7 +86,7 @@ type Keeper interface { DelegateCoins(ctx sdk.Context, delegatorAddr, moduleAccAddr sdk.AccAddress, amt sdk.Coins) error UndelegateCoins(ctx sdk.Context, moduleAccAddr, delegatorAddr sdk.AccAddress, amt sdk.Coins) error - // GetAuthority Gets the address capable of executing governance proposal messages. Usually the gov module account. + // GetAuthority gets the address capable of executing governance proposal messages. Usually the gov module account. GetAuthority() string types.QueryServer @@ -108,7 +108,7 @@ type SendKeeper interface { SendCoins(ctx sdk.Context, fromAddr sdk.AccAddress, toAddr sdk.AccAddress, amt sdk.Coins) error GetParams(ctx sdk.Context) types.Params - SetParams(ctx sdk.Context, params types.Params) + SetParams(ctx sdk.Context, params types.Params) error IsSendEnabledDenom(ctx sdk.Context, denom string) bool SetSendEnabled(ctx sdk.Context, denom string, value bool) diff --git a/x/bank/spec/03_messages.md b/x/bank/spec/03_messages.md index a6d2379458cf..5b3ec664bd96 100644 --- a/x/bank/spec/03_messages.md +++ b/x/bank/spec/03_messages.md @@ -26,3 +26,13 @@ The message will fail under the following conditions: * Any of the `to` addresses are restricted * Any of the coins are locked * The inputs and outputs do not correctly correspond to one another + +## MsgUpdateParams + +The `bank` module params can be updated through `MsgUpdateParams`, which can be done using governance proposal. The signer will always be the `gov` module account address. + ++++ https://github.com/cosmos/cosmos-sdk/blob/e167855c9b99c4e58c1455533c6f88af5ff78ae1/proto/cosmos/bank/v1beta1/tx.proto#L56-L69 + +The message handling can fail if: + +* signer is not the gov module account address. diff --git a/x/bank/types/authority.go b/x/bank/types/authority.go new file mode 100644 index 000000000000..0be891346263 --- /dev/null +++ b/x/bank/types/authority.go @@ -0,0 +1,11 @@ +package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" +) + +type BankAuthority sdk.AccAddress + +func (a BankAuthority) String() string { + return sdk.AccAddress(a).String() +} diff --git a/x/bank/types/bank.pb.go b/x/bank/types/bank.pb.go index 70beec6e4248..dd2c5f8c1df0 100644 --- a/x/bank/types/bank.pb.go +++ b/x/bank/types/bank.pb.go @@ -460,48 +460,47 @@ func init() { func init() { proto.RegisterFile("cosmos/bank/v1beta1/bank.proto", fileDescriptor_dd052eee12edf988) } var fileDescriptor_dd052eee12edf988 = []byte{ - // 655 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x54, 0x31, 0x6f, 0x13, 0x49, - 0x14, 0xf6, 0xd8, 0xb1, 0xbd, 0x19, 0xdf, 0x35, 0x73, 0xd6, 0xdd, 0x24, 0xc5, 0xda, 0xda, 0xe2, - 0x64, 0x22, 0xc5, 0x76, 0x02, 0x95, 0x85, 0x84, 0x70, 0x40, 0xc1, 0x48, 0x08, 0xb4, 0x51, 0x84, - 0x44, 0x63, 0x8d, 0xbd, 0x83, 0x3d, 0xca, 0xee, 0xcc, 0x6a, 0x67, 0x36, 0x8a, 0x5b, 0x2a, 0xa0, - 0xa2, 0xa4, 0x4c, 0x0b, 0x15, 0x45, 0x24, 0xfe, 0x42, 0x44, 0x15, 0x51, 0x51, 0x05, 0xe4, 0x14, - 0xf0, 0x33, 0xd0, 0xcc, 0xec, 0x3a, 0x89, 0x14, 0x10, 0x05, 0x05, 0xd5, 0xbe, 0xf7, 0xbe, 0x37, - 0xdf, 0xfb, 0xfc, 0xe6, 0x1b, 0x43, 0x77, 0x2c, 0x64, 0x24, 0x64, 0x67, 0x44, 0xf8, 0x5e, 0x67, - 0x7f, 0x63, 0x44, 0x15, 0xd9, 0x30, 0x49, 0x3b, 0x4e, 0x84, 0x12, 0xe8, 0x1f, 0x8b, 0xb7, 0x4d, - 0x29, 0xc3, 0x57, 0xeb, 0x13, 0x31, 0x11, 0x06, 0xef, 0xe8, 0xc8, 0xb6, 0xae, 0xae, 0xd8, 0xd6, - 0xa1, 0x05, 0xb2, 0x73, 0x16, 0x3a, 0x9f, 0x22, 0xe9, 0x62, 0xca, 0x58, 0x30, 0x9e, 0xe1, 0xff, - 0x65, 0x78, 0x24, 0x27, 0x9d, 0xfd, 0x0d, 0xfd, 0xb1, 0x80, 0xf7, 0x02, 0xc0, 0xca, 0x23, 0x92, - 0x90, 0x48, 0xa2, 0x6d, 0xf8, 0x97, 0xa4, 0x3c, 0x18, 0x52, 0x4e, 0x46, 0x21, 0x0d, 0x30, 0x68, - 0x96, 0x5a, 0xb5, 0xcd, 0x66, 0xfb, 0x0a, 0x81, 0xed, 0x1d, 0xca, 0x83, 0xbb, 0xb6, 0xaf, 0x5f, - 0xc4, 0xc0, 0xaf, 0xc9, 0xf3, 0x02, 0xea, 0xc2, 0x7a, 0x40, 0x9f, 0x92, 0x34, 0x54, 0xc3, 0x4b, - 0x84, 0xc5, 0x26, 0x68, 0x39, 0x3e, 0xca, 0xb0, 0x0b, 0x14, 0xbd, 0xa5, 0xd7, 0x87, 0x8d, 0x82, - 0xb7, 0x0d, 0x6b, 0x17, 0x8a, 0xa8, 0x0e, 0xcb, 0x01, 0xe5, 0x22, 0xc2, 0xa0, 0x09, 0x5a, 0xcb, - 0xbe, 0x4d, 0x10, 0x86, 0xd5, 0xcb, 0x7c, 0x79, 0xda, 0x73, 0x34, 0xc9, 0xb7, 0xc3, 0x06, 0xf0, - 0x8e, 0x00, 0x2c, 0x0f, 0x78, 0x9c, 0x2a, 0xb4, 0x09, 0xab, 0x24, 0x08, 0x12, 0x2a, 0xa5, 0x65, - 0xe9, 0xe3, 0x8f, 0x47, 0xeb, 0xf5, 0xec, 0x17, 0xdd, 0xb6, 0xc8, 0x8e, 0x4a, 0x18, 0x9f, 0xf8, - 0x79, 0x23, 0x22, 0xb0, 0xac, 0x37, 0x27, 0x71, 0xd1, 0x2c, 0x60, 0xe5, 0x7c, 0x01, 0x92, 0x2e, - 0x16, 0xb0, 0x25, 0x18, 0xef, 0x77, 0x8f, 0x4f, 0x1b, 0x85, 0xb7, 0x9f, 0x1b, 0xad, 0x09, 0x53, - 0xd3, 0x74, 0xd4, 0x1e, 0x8b, 0x28, 0xbb, 0x96, 0xec, 0xb3, 0x2e, 0x83, 0xbd, 0x8e, 0x9a, 0xc5, - 0x54, 0x9a, 0x03, 0xd2, 0xb7, 0xcc, 0xbd, 0xfa, 0x73, 0x2b, 0xb5, 0xf0, 0xec, 0xeb, 0xbb, 0xb5, - 0x7c, 0xb0, 0xf7, 0x06, 0xc0, 0xca, 0xc3, 0x54, 0xfd, 0xc1, 0xba, 0x9d, 0x5c, 0xb7, 0xf7, 0x1e, - 0xc0, 0xca, 0x4e, 0x1a, 0xc7, 0xe1, 0x4c, 0xcf, 0x55, 0x42, 0x91, 0x30, 0x33, 0xcc, 0xef, 0x9d, - 0x6b, 0x98, 0x7b, 0xf7, 0xb3, 0xb9, 0xe0, 0xc3, 0xd1, 0xfa, 0xcd, 0xb5, 0x9f, 0x9e, 0x3e, 0xb0, - 0x2f, 0x2d, 0x62, 0x93, 0x84, 0x28, 0x26, 0xb8, 0xec, 0xec, 0x77, 0x6f, 0x74, 0xdb, 0x56, 0xeb, - 0x00, 0x03, 0xef, 0x31, 0x5c, 0xbe, 0xa3, 0x9d, 0xb4, 0xcb, 0x99, 0xfa, 0x81, 0xc7, 0x56, 0xa1, - 0x43, 0x0f, 0x62, 0xc1, 0x29, 0x57, 0xc6, 0x64, 0x7f, 0xfb, 0x8b, 0x5c, 0xfb, 0x8f, 0x84, 0x8c, - 0x48, 0x2a, 0x71, 0xa9, 0x59, 0x6a, 0x2d, 0xfb, 0x79, 0xea, 0xbd, 0x2c, 0x42, 0xe7, 0x01, 0x55, - 0x24, 0x20, 0x8a, 0xa0, 0x26, 0xac, 0x05, 0x54, 0x8e, 0x13, 0x16, 0x6b, 0x11, 0x19, 0xfd, 0xc5, - 0x12, 0xba, 0xa5, 0x3b, 0xb8, 0x88, 0x86, 0x29, 0x67, 0x2a, 0xbf, 0x34, 0xf7, 0xca, 0xd7, 0xb6, - 0xd0, 0xeb, 0xc3, 0x20, 0x0f, 0x25, 0x42, 0x70, 0x49, 0xaf, 0x18, 0x97, 0x0c, 0xb7, 0x89, 0xb5, - 0xba, 0x80, 0xc9, 0x38, 0x24, 0x33, 0xbc, 0x64, 0xca, 0x79, 0xaa, 0xbb, 0x39, 0x89, 0x28, 0x2e, - 0xdb, 0x6e, 0x1d, 0xa3, 0x7f, 0x61, 0x45, 0xce, 0xa2, 0x91, 0x08, 0x71, 0xc5, 0x54, 0xb3, 0x0c, - 0xad, 0xc0, 0x52, 0x9a, 0x30, 0x5c, 0x35, 0xce, 0xab, 0xce, 0x4f, 0x1b, 0xa5, 0x5d, 0x7f, 0xe0, - 0xeb, 0x1a, 0xfa, 0x1f, 0x3a, 0x69, 0xc2, 0x86, 0x53, 0x22, 0xa7, 0xd8, 0x31, 0x78, 0x6d, 0x7e, - 0xda, 0xa8, 0xee, 0xfa, 0x83, 0x7b, 0x44, 0x4e, 0xfd, 0x6a, 0x9a, 0x30, 0x1d, 0xf4, 0xb7, 0x8e, - 0xe7, 0x2e, 0x38, 0x99, 0xbb, 0xe0, 0xcb, 0xdc, 0x05, 0xaf, 0xce, 0xdc, 0xc2, 0xc9, 0x99, 0x5b, - 0xf8, 0x74, 0xe6, 0x16, 0x9e, 0x5c, 0xfb, 0x95, 0xeb, 0x33, 0x1e, 0x18, 0x55, 0xcc, 0x7f, 0xd4, - 0xf5, 0xef, 0x01, 0x00, 0x00, 0xff, 0xff, 0xec, 0xf7, 0xce, 0x43, 0x44, 0x05, 0x00, 0x00, + // 633 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x54, 0xb1, 0x6f, 0x13, 0x3f, + 0x14, 0x8e, 0x93, 0x26, 0x77, 0x75, 0x7e, 0xbf, 0xc5, 0x04, 0x70, 0x3b, 0x5c, 0xa2, 0x1b, 0x50, + 0x40, 0x6a, 0xd2, 0x96, 0x2d, 0x0b, 0x22, 0x05, 0x95, 0x0c, 0x08, 0x74, 0x55, 0x85, 0xc4, 0x12, + 0x39, 0x39, 0x93, 0x58, 0xbd, 0xb3, 0x4f, 0x67, 0x5f, 0xd5, 0xac, 0x9d, 0x80, 0x89, 0x91, 0xb1, + 0x2b, 0x4c, 0x0c, 0xfd, 0x23, 0x2a, 0xa6, 0x8a, 0x89, 0xa9, 0xa0, 0x74, 0x80, 0x3f, 0x03, 0xd9, + 0xbe, 0x4b, 0x5b, 0xa9, 0x30, 0x31, 0x30, 0xdd, 0x7b, 0xef, 0xfb, 0xfc, 0x7d, 0x2f, 0xcf, 0x2f, + 0x86, 0xde, 0x58, 0xc8, 0x58, 0xc8, 0xee, 0x88, 0xf0, 0xbd, 0xee, 0xfe, 0xc6, 0x88, 0x2a, 0xb2, + 0x61, 0x92, 0x4e, 0x92, 0x0a, 0x25, 0xd0, 0x0d, 0x8b, 0x77, 0x4c, 0x29, 0xc7, 0x57, 0x1b, 0x13, + 0x31, 0x11, 0x06, 0xef, 0xea, 0xc8, 0x52, 0x57, 0x57, 0x2c, 0x75, 0x68, 0x81, 0xfc, 0x9c, 0x85, + 0x2e, 0x5c, 0x24, 0x5d, 0xb8, 0x8c, 0x05, 0xe3, 0x39, 0x7e, 0x3b, 0xc7, 0x63, 0x39, 0xe9, 0xee, + 0x6f, 0xe8, 0x8f, 0x05, 0xfc, 0x37, 0x00, 0xd6, 0x9e, 0x93, 0x94, 0xc4, 0x12, 0x6d, 0xc3, 0xff, + 0x24, 0xe5, 0xe1, 0x90, 0x72, 0x32, 0x8a, 0x68, 0x88, 0x41, 0xab, 0xd2, 0xae, 0x6f, 0xb6, 0x3a, + 0xd7, 0x34, 0xd8, 0xd9, 0xa1, 0x3c, 0x7c, 0x6c, 0x79, 0xfd, 0x32, 0x06, 0x41, 0x5d, 0x5e, 0x14, + 0xd0, 0x3a, 0x6c, 0x84, 0xf4, 0x15, 0xc9, 0x22, 0x35, 0xbc, 0x22, 0x58, 0x6e, 0x81, 0xb6, 0x1b, + 0xa0, 0x1c, 0xbb, 0x24, 0xd1, 0x5b, 0x7a, 0x7f, 0xd4, 0x2c, 0xf9, 0xdb, 0xb0, 0x7e, 0xa9, 0x88, + 0x1a, 0xb0, 0x1a, 0x52, 0x2e, 0x62, 0x0c, 0x5a, 0xa0, 0xbd, 0x1c, 0xd8, 0x04, 0x61, 0xe8, 0x5c, + 0xd5, 0x2b, 0xd2, 0x9e, 0xab, 0x45, 0x7e, 0x1e, 0x35, 0x81, 0x7f, 0x0c, 0x60, 0x75, 0xc0, 0x93, + 0x4c, 0xa1, 0x4d, 0xe8, 0x90, 0x30, 0x4c, 0xa9, 0x94, 0x56, 0xa5, 0x8f, 0xbf, 0x1c, 0xaf, 0x35, + 0xf2, 0x5f, 0xf4, 0xd0, 0x22, 0x3b, 0x2a, 0x65, 0x7c, 0x12, 0x14, 0x44, 0x44, 0x60, 0x55, 0x4f, + 0x4e, 0xe2, 0xb2, 0x19, 0xc0, 0xca, 0xc5, 0x00, 0x24, 0x5d, 0x0c, 0x60, 0x4b, 0x30, 0xde, 0x5f, + 0x3f, 0x39, 0x6b, 0x96, 0x3e, 0x7e, 0x6b, 0xb6, 0x27, 0x4c, 0x4d, 0xb3, 0x51, 0x67, 0x2c, 0xe2, + 0xfc, 0x5a, 0xf2, 0xcf, 0x9a, 0x0c, 0xf7, 0xba, 0x6a, 0x96, 0x50, 0x69, 0x0e, 0xc8, 0xc0, 0x2a, + 0xf7, 0x1a, 0xaf, 0x6d, 0xab, 0xa5, 0xc3, 0x1f, 0x9f, 0xee, 0x15, 0xc6, 0xfe, 0x07, 0x00, 0x6b, + 0xcf, 0x32, 0xf5, 0x0f, 0xf7, 0xed, 0x16, 0x7d, 0xfb, 0x87, 0x00, 0xd6, 0x76, 0xb2, 0x24, 0x89, + 0x66, 0xda, 0x57, 0x09, 0x45, 0xa2, 0x7c, 0x61, 0xfe, 0xae, 0xaf, 0x51, 0xee, 0xdd, 0xcc, 0x7d, + 0xc1, 0xe7, 0xe3, 0x35, 0xc7, 0xda, 0x0e, 0x30, 0xf0, 0x5f, 0xc0, 0xe5, 0x47, 0x7a, 0x29, 0x76, + 0x39, 0x53, 0xbf, 0x59, 0x97, 0x55, 0xe8, 0xd2, 0x83, 0x44, 0x70, 0xca, 0x95, 0xd9, 0x97, 0xff, + 0x83, 0x45, 0xae, 0x57, 0x89, 0x44, 0x8c, 0x48, 0x2a, 0x71, 0xa5, 0x55, 0x69, 0x2f, 0x07, 0x45, + 0xea, 0xbf, 0x2d, 0x43, 0xf7, 0x29, 0x55, 0x24, 0x24, 0x8a, 0xa0, 0x16, 0xac, 0x87, 0x54, 0x8e, + 0x53, 0x96, 0x28, 0x26, 0x78, 0x2e, 0x7f, 0xb9, 0x84, 0x1e, 0x68, 0x06, 0x17, 0xf1, 0x30, 0xe3, + 0x4c, 0x15, 0xf3, 0xf7, 0xae, 0xfd, 0xe3, 0x2c, 0xfa, 0x0d, 0x60, 0x58, 0x84, 0x12, 0x21, 0xb8, + 0xa4, 0xa7, 0x85, 0x2b, 0x46, 0xdb, 0xc4, 0xba, 0xbb, 0x90, 0xc9, 0x24, 0x22, 0x33, 0xbc, 0x64, + 0xca, 0x45, 0xaa, 0xd9, 0x9c, 0xc4, 0x14, 0x57, 0x2d, 0x5b, 0xc7, 0xe8, 0x16, 0xac, 0xc9, 0x59, + 0x3c, 0x12, 0x11, 0xae, 0x99, 0x6a, 0x9e, 0xa1, 0x15, 0x58, 0xc9, 0x52, 0x86, 0x1d, 0xb3, 0x44, + 0xce, 0xfc, 0xac, 0x59, 0xd9, 0x0d, 0x06, 0x81, 0xae, 0xa1, 0x3b, 0xd0, 0xcd, 0x52, 0x36, 0x9c, + 0x12, 0x39, 0xc5, 0xae, 0xc1, 0xeb, 0xf3, 0xb3, 0xa6, 0xb3, 0x1b, 0x0c, 0x9e, 0x10, 0x39, 0x0d, + 0x9c, 0x2c, 0x65, 0x3a, 0xe8, 0x6f, 0x9d, 0xcc, 0x3d, 0x70, 0x3a, 0xf7, 0xc0, 0xf7, 0xb9, 0x07, + 0xde, 0x9d, 0x7b, 0xa5, 0xd3, 0x73, 0xaf, 0xf4, 0xf5, 0xdc, 0x2b, 0xbd, 0xbc, 0xfb, 0xc7, 0x7b, + 0x3c, 0xb0, 0x6f, 0x9e, 0xb9, 0xce, 0x51, 0xcd, 0x3c, 0x37, 0xf7, 0x7f, 0x05, 0x00, 0x00, 0xff, + 0xff, 0xea, 0x9e, 0xe2, 0x05, 0x0f, 0x05, 0x00, 0x00, } func (this *SendEnabled) Equal(that interface{}) bool { diff --git a/x/bank/types/codec.go b/x/bank/types/codec.go index a4107c1cfdb6..7ad20f741608 100644 --- a/x/bank/types/codec.go +++ b/x/bank/types/codec.go @@ -16,13 +16,17 @@ import ( func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { legacy.RegisterAminoMsg(cdc, &MsgSend{}, "cosmos-sdk/MsgSend") legacy.RegisterAminoMsg(cdc, &MsgMultiSend{}, "cosmos-sdk/MsgMultiSend") + legacy.RegisterAminoMsg(cdc, &MsgUpdateParams{}, "cosmos-sdk/x/bank/MsgUpdateParams") + cdc.RegisterConcrete(&SendAuthorization{}, "cosmos-sdk/SendAuthorization", nil) + cdc.RegisterConcrete(&Params{}, "cosmos-sdk/x/bank/Params", nil) } func RegisterInterfaces(registry types.InterfaceRegistry) { registry.RegisterImplementations((*sdk.Msg)(nil), &MsgSend{}, &MsgMultiSend{}, + &MsgUpdateParams{}, ) registry.RegisterImplementations( (*authz.Authorization)(nil), diff --git a/x/bank/types/key.go b/x/bank/types/keys.go similarity index 97% rename from x/bank/types/key.go rename to x/bank/types/keys.go index a8b76017f572..4c95fe87cf94 100644 --- a/x/bank/types/key.go +++ b/x/bank/types/keys.go @@ -32,6 +32,9 @@ var ( // SendEnabledPrefix is the prefix for the SendDisabled flags for a Denom. SendEnabledPrefix = []byte{0x04} + + // ParamsKey is the prefix for x/bank parameters + ParamsKey = []byte{0x05} ) const ( diff --git a/x/bank/types/key_test.go b/x/bank/types/keys_test.go similarity index 100% rename from x/bank/types/key_test.go rename to x/bank/types/keys_test.go diff --git a/x/bank/types/msgs.go b/x/bank/types/msgs.go index 584001d08c5e..dedcf151392f 100644 --- a/x/bank/types/msgs.go +++ b/x/bank/types/msgs.go @@ -10,9 +10,14 @@ const ( TypeMsgSend = "send" TypeMsgMultiSend = "multisend" TypeMsgSetSendEnabled = "set-send-enabled" + TypeMsgUpdateParams = "update_params" ) -var _ sdk.Msg = &MsgSend{} +var ( + _ sdk.Msg = &MsgSend{} + _ sdk.Msg = &MsgMultiSend{} + _ sdk.Msg = &MsgUpdateParams{} +) // NewMsgSend - construct a msg to send coins from one account to another. //nolint:interfacer @@ -58,8 +63,6 @@ func (msg MsgSend) GetSigners() []sdk.AccAddress { return []sdk.AccAddress{fromAddress} } -var _ sdk.Msg = &MsgMultiSend{} - // NewMsgMultiSend - construct arbitrary multi-in, multi-out send msg. func NewMsgMultiSend(in Input, out []Output) *MsgMultiSend { return &MsgMultiSend{Input: in, Outputs: out} @@ -73,7 +76,7 @@ func (msg MsgMultiSend) Type() string { return TypeMsgMultiSend } // ValidateBasic Implements Msg. func (msg MsgMultiSend) ValidateBasic() error { - // this just makes sure all the inputs and outputs are properly formatted, + // this just makes sure the input and all the outputs are properly formatted, // not that they actually have the money inside if err := msg.Input.ValidateBasic(); err != nil { @@ -176,3 +179,22 @@ func ValidateInputsOutputs(input Input, outputs []Output) error { return nil } + +// GetSigners returns the signer addresses that are expected to sign the result +// of GetSignBytes. +func (msg MsgUpdateParams) GetSigners() []sdk.AccAddress { + authority, _ := sdk.AccAddressFromBech32(msg.Authority) + return []sdk.AccAddress{authority} +} + +// GetSignBytes returns the raw bytes for a MsgUpdateParams message that +// the expected signer needs to sign. +func (msg MsgUpdateParams) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(&msg) + return sdk.MustSortJSON(bz) +} + +// ValidateBasic performs basic MsgUpdateParams message validation. +func (msg MsgUpdateParams) ValidateBasic() error { + return msg.Params.Validate() +} diff --git a/x/bank/types/params.go b/x/bank/types/params.go index 531daa8b2848..d38dd8eae309 100644 --- a/x/bank/types/params.go +++ b/x/bank/types/params.go @@ -7,25 +7,11 @@ import ( "sigs.k8s.io/yaml" sdk "github.com/cosmos/cosmos-sdk/types" - paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" ) // DefaultDefaultSendEnabled is the value that DefaultSendEnabled will have from DefaultParams(). var DefaultDefaultSendEnabled = true -var ( - // KeySendEnabled is store's key for SendEnabled Params - // Deprecated: Use the SendEnabled functionality in the keeper. - KeySendEnabled = []byte("SendEnabled") - // KeyDefaultSendEnabled is store's key for the DefaultSendEnabled option - KeyDefaultSendEnabled = []byte("DefaultSendEnabled") -) - -// ParamKeyTable for bank module. -func ParamKeyTable() paramtypes.KeyTable { - return paramtypes.NewKeyTable().RegisterParamSet(&Params{}) -} - // NewParams creates a new parameter configuration for the bank module func NewParams(defaultSendEnabled bool) Params { return Params{ @@ -60,14 +46,6 @@ func (p Params) String() string { return fmt.Sprintf("default_send_enabled: %t\nsend_enabled:%s%s", p.DefaultSendEnabled, d, sendEnabled) } -// ParamSetPairs implements params.ParamSet -func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { - return paramtypes.ParamSetPairs{ - paramtypes.NewParamSetPair(KeySendEnabled, &p.SendEnabled, validateSendEnabledParams), - paramtypes.NewParamSetPair(KeyDefaultSendEnabled, &p.DefaultSendEnabled, validateIsBool), - } -} - // Validate gets any errors with this SendEnabled entry. func (se SendEnabled) Validate() error { return sdk.ValidateDenom(se.Denom) diff --git a/x/bank/types/params_legacy.go b/x/bank/types/params_legacy.go new file mode 100644 index 000000000000..c6831e634b70 --- /dev/null +++ b/x/bank/types/params_legacy.go @@ -0,0 +1,23 @@ +package types + +import paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" + +var ( + // KeySendEnabled is store's key for SendEnabled Params + // DEPRECATED: Use the SendEnabled functionality in the keeper. + KeySendEnabled = []byte("SendEnabled") + // KeyDefaultSendEnabled is store's key for the DefaultSendEnabled option + KeyDefaultSendEnabled = []byte("DefaultSendEnabled") +) + +// DEPRECATED: ParamKeyTable for bank module. +func ParamKeyTable() paramtypes.KeyTable { + return paramtypes.NewKeyTable().RegisterParamSet(&Params{}) +} + +// DEPRECATED: ParamSetPairs implements params.ParamSet +func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { + return paramtypes.ParamSetPairs{ + paramtypes.NewParamSetPair(KeyDefaultSendEnabled, &p.DefaultSendEnabled, validateIsBool), + } +} diff --git a/x/bank/types/tx.pb.go b/x/bank/types/tx.pb.go index dddc40586b00..dc9b81020149 100644 --- a/x/bank/types/tx.pb.go +++ b/x/bank/types/tx.pb.go @@ -199,46 +199,152 @@ func (m *MsgMultiSendResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgMultiSendResponse proto.InternalMessageInfo +// MsgUpdateParams is the Msg/UpdateParams request type. +// +// Since: cosmos-sdk 0.47 +type MsgUpdateParams struct { + // authority is the address of the governance account. + Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"` + // params defines the x/bank parameters to update. + // + // NOTE: All parameters must be supplied. + Params Params `protobuf:"bytes,2,opt,name=params,proto3" json:"params"` +} + +func (m *MsgUpdateParams) Reset() { *m = MsgUpdateParams{} } +func (m *MsgUpdateParams) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateParams) ProtoMessage() {} +func (*MsgUpdateParams) Descriptor() ([]byte, []int) { + return fileDescriptor_1d8cb1613481f5b7, []int{4} +} +func (m *MsgUpdateParams) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateParams) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateParams.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgUpdateParams) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateParams.Merge(m, src) +} +func (m *MsgUpdateParams) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateParams) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateParams.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateParams proto.InternalMessageInfo + +func (m *MsgUpdateParams) GetAuthority() string { + if m != nil { + return m.Authority + } + return "" +} + +func (m *MsgUpdateParams) GetParams() Params { + if m != nil { + return m.Params + } + return Params{} +} + +// MsgUpdateParamsResponse defines the response structure for executing a +// MsgUpdateParams message. +// +// Since: cosmos-sdk 0.47 +type MsgUpdateParamsResponse struct { +} + +func (m *MsgUpdateParamsResponse) Reset() { *m = MsgUpdateParamsResponse{} } +func (m *MsgUpdateParamsResponse) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateParamsResponse) ProtoMessage() {} +func (*MsgUpdateParamsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_1d8cb1613481f5b7, []int{5} +} +func (m *MsgUpdateParamsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateParamsResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgUpdateParamsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateParamsResponse.Merge(m, src) +} +func (m *MsgUpdateParamsResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateParamsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateParamsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateParamsResponse proto.InternalMessageInfo + func init() { proto.RegisterType((*MsgSend)(nil), "cosmos.bank.v1beta1.MsgSend") proto.RegisterType((*MsgSendResponse)(nil), "cosmos.bank.v1beta1.MsgSendResponse") proto.RegisterType((*MsgMultiSend)(nil), "cosmos.bank.v1beta1.MsgMultiSend") proto.RegisterType((*MsgMultiSendResponse)(nil), "cosmos.bank.v1beta1.MsgMultiSendResponse") + proto.RegisterType((*MsgUpdateParams)(nil), "cosmos.bank.v1beta1.MsgUpdateParams") + proto.RegisterType((*MsgUpdateParamsResponse)(nil), "cosmos.bank.v1beta1.MsgUpdateParamsResponse") } func init() { proto.RegisterFile("cosmos/bank/v1beta1/tx.proto", fileDescriptor_1d8cb1613481f5b7) } var fileDescriptor_1d8cb1613481f5b7 = []byte{ - // 464 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x92, 0x4d, 0x6b, 0xd4, 0x40, - 0x1c, 0xc6, 0x33, 0x6e, 0x6d, 0xd9, 0xd9, 0xa2, 0x18, 0x17, 0xdd, 0x8d, 0x25, 0x5b, 0x83, 0x87, - 0xad, 0xd0, 0x89, 0xbb, 0x82, 0x42, 0x7b, 0x32, 0x3d, 0x29, 0x04, 0x21, 0x3d, 0xe9, 0xa5, 0xe4, - 0x65, 0x1c, 0x43, 0xcd, 0x4c, 0xc8, 0x4c, 0x4a, 0xbd, 0x7a, 0xf2, 0x28, 0xf8, 0x05, 0x7a, 0x16, - 0x0f, 0x1e, 0xfc, 0x10, 0x3d, 0x16, 0x4f, 0x9e, 0x54, 0x76, 0x0f, 0xfa, 0x2d, 0x94, 0x79, 0x49, - 0xac, 0xb8, 0x6d, 0x4f, 0x13, 0xf2, 0x7b, 0x9e, 0x67, 0xfe, 0x2f, 0x03, 0xd7, 0x52, 0xc6, 0x0b, - 0xc6, 0xfd, 0x24, 0xa6, 0xfb, 0xfe, 0xc1, 0x24, 0xc1, 0x22, 0x9e, 0xf8, 0xe2, 0x10, 0x95, 0x15, - 0x13, 0xcc, 0xbe, 0xae, 0x29, 0x92, 0x14, 0x19, 0xea, 0xf4, 0x09, 0x23, 0x4c, 0x71, 0x5f, 0x7e, - 0x69, 0xa9, 0xe3, 0xb6, 0x41, 0x1c, 0xb7, 0x41, 0x29, 0xcb, 0xe9, 0x7f, 0xfc, 0xd4, 0x45, 0x2a, - 0x57, 0xf3, 0xa1, 0xe6, 0x7b, 0x3a, 0xd8, 0xdc, 0xab, 0xd1, 0x4d, 0x63, 0x2d, 0x38, 0xf1, 0x0f, - 0x26, 0xf2, 0xd0, 0xc0, 0xfb, 0x0d, 0xe0, 0x4a, 0xc8, 0xc9, 0x2e, 0xa6, 0x99, 0xbd, 0x0d, 0x57, - 0x5f, 0x54, 0xac, 0xd8, 0x8b, 0xb3, 0xac, 0xc2, 0x9c, 0x0f, 0xc0, 0x3a, 0x18, 0x77, 0x83, 0xc1, - 0x97, 0xcf, 0x9b, 0x7d, 0x13, 0xf6, 0x48, 0x93, 0x5d, 0x51, 0xe5, 0x94, 0x44, 0x3d, 0xa9, 0x36, - 0xbf, 0xec, 0x87, 0x10, 0x0a, 0xd6, 0x5a, 0x2f, 0x5d, 0x60, 0xed, 0x0a, 0xd6, 0x18, 0x53, 0xb8, - 0x1c, 0x17, 0xac, 0xa6, 0x62, 0xd0, 0x59, 0xef, 0x8c, 0x7b, 0xd3, 0x21, 0x6a, 0x27, 0xc6, 0x71, - 0x33, 0x31, 0xb4, 0xc3, 0x72, 0x1a, 0xdc, 0x3b, 0xfe, 0x36, 0xb2, 0x3e, 0x7c, 0x1f, 0x8d, 0x49, - 0x2e, 0x5e, 0xd6, 0x09, 0x4a, 0x59, 0x61, 0xda, 0x34, 0xc7, 0x26, 0xcf, 0xf6, 0x7d, 0xf1, 0xba, - 0xc4, 0x5c, 0x19, 0x78, 0x64, 0xa2, 0xb7, 0x86, 0x6f, 0x8f, 0x46, 0xd6, 0xaf, 0xa3, 0x91, 0xf5, - 0xe6, 0xe7, 0xa7, 0xbb, 0xff, 0x74, 0xe9, 0x5d, 0x83, 0x57, 0xcd, 0x00, 0x22, 0xcc, 0x4b, 0x46, - 0x39, 0xf6, 0xde, 0x03, 0xb8, 0x1a, 0x72, 0x12, 0xd6, 0xaf, 0x44, 0xae, 0x26, 0xf3, 0x00, 0x5e, - 0xce, 0x69, 0x59, 0x0b, 0x35, 0x92, 0xde, 0xd4, 0x41, 0x0b, 0x96, 0x8a, 0x1e, 0x4b, 0x45, 0xb0, - 0x24, 0x6b, 0x8c, 0xb4, 0xdc, 0xde, 0x86, 0x2b, 0xac, 0x16, 0x65, 0x2d, 0xe4, 0x44, 0x64, 0x73, - 0xb7, 0x16, 0x3a, 0x9f, 0x2a, 0x8d, 0xb1, 0x36, 0x8e, 0xad, 0x2b, 0x4d, 0xbd, 0x3a, 0xcc, 0xbb, - 0x01, 0xfb, 0xa7, 0x8b, 0x6a, 0xaa, 0x9d, 0x7e, 0x04, 0xb0, 0x13, 0x72, 0x62, 0x3f, 0x81, 0x4b, - 0xaa, 0xd8, 0xb5, 0x85, 0x77, 0x98, 0x1e, 0x9d, 0x3b, 0xe7, 0xd1, 0x26, 0xd3, 0x7e, 0x06, 0xbb, - 0x7f, 0xbb, 0xbf, 0x7d, 0x96, 0xa5, 0x95, 0x38, 0x1b, 0x17, 0x4a, 0x9a, 0xe8, 0x60, 0xe7, 0x78, - 0xe6, 0x82, 0x93, 0x99, 0x0b, 0x7e, 0xcc, 0x5c, 0xf0, 0x6e, 0xee, 0x5a, 0x27, 0x73, 0xd7, 0xfa, - 0x3a, 0x77, 0xad, 0xe7, 0x1b, 0xe7, 0xae, 0xf5, 0x50, 0xbf, 0x7b, 0xb5, 0xdd, 0x64, 0x59, 0xbd, - 0xde, 0xfb, 0x7f, 0x02, 0x00, 0x00, 0xff, 0xff, 0x51, 0xb7, 0xdd, 0x56, 0x7c, 0x03, 0x00, 0x00, + // 538 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x54, 0xbd, 0x6e, 0xd3, 0x50, + 0x14, 0xb6, 0x9b, 0x92, 0x2a, 0x27, 0x51, 0x11, 0x26, 0xa2, 0x89, 0xa9, 0x9c, 0x62, 0x31, 0xa4, + 0x88, 0xda, 0x24, 0x48, 0x45, 0xa4, 0x13, 0xe9, 0x04, 0x52, 0x04, 0x4a, 0xc5, 0x00, 0x4b, 0x65, + 0xc7, 0x17, 0xd7, 0x2a, 0xf6, 0xb5, 0x7c, 0xaf, 0xab, 0x76, 0x65, 0x62, 0xac, 0x04, 0x0f, 0xd0, + 0x99, 0x89, 0x81, 0x87, 0xe8, 0x58, 0x31, 0x31, 0x01, 0x4a, 0x06, 0x78, 0x0b, 0xd0, 0xfd, 0xb1, + 0x93, 0x42, 0x7e, 0x3a, 0x39, 0xca, 0xf7, 0x73, 0xbe, 0xf3, 0x1d, 0x27, 0xb0, 0x3e, 0xc0, 0x24, + 0xc4, 0xc4, 0x76, 0x9d, 0xe8, 0xd0, 0x3e, 0x6a, 0xb9, 0x88, 0x3a, 0x2d, 0x9b, 0x1e, 0x5b, 0x71, + 0x82, 0x29, 0xd6, 0x6e, 0x0a, 0xd4, 0x62, 0xa8, 0x25, 0x51, 0xbd, 0xea, 0x63, 0x1f, 0x73, 0xdc, + 0x66, 0x9f, 0x04, 0x55, 0x37, 0x72, 0x23, 0x82, 0x72, 0xa3, 0x01, 0x0e, 0xa2, 0xff, 0xf0, 0x89, + 0x41, 0xdc, 0x57, 0xe0, 0x75, 0x81, 0xef, 0x0b, 0x63, 0x39, 0x57, 0x40, 0x6b, 0x52, 0x1a, 0x12, + 0xdf, 0x3e, 0x6a, 0xb1, 0x87, 0x00, 0xcc, 0x3f, 0x2a, 0xac, 0xf4, 0x88, 0xbf, 0x87, 0x22, 0x4f, + 0xdb, 0x81, 0xca, 0x9b, 0x04, 0x87, 0xfb, 0x8e, 0xe7, 0x25, 0x88, 0x90, 0x9a, 0xba, 0xa1, 0x36, + 0x4b, 0xdd, 0xda, 0xd7, 0x2f, 0x5b, 0x55, 0x69, 0xf6, 0x44, 0x20, 0x7b, 0x34, 0x09, 0x22, 0xbf, + 0x5f, 0x66, 0x6c, 0xf9, 0x95, 0xf6, 0x08, 0x80, 0xe2, 0x5c, 0xba, 0xb4, 0x40, 0x5a, 0xa2, 0x38, + 0x13, 0x0e, 0xa0, 0xe8, 0x84, 0x38, 0x8d, 0x68, 0xad, 0xb0, 0x51, 0x68, 0x96, 0xdb, 0x75, 0x2b, + 0x6f, 0x8c, 0xa0, 0xac, 0x31, 0x6b, 0x17, 0x07, 0x51, 0xf7, 0xc1, 0xf9, 0xf7, 0x86, 0xf2, 0xe9, + 0x47, 0xa3, 0xe9, 0x07, 0xf4, 0x20, 0x75, 0xad, 0x01, 0x0e, 0xe5, 0x9a, 0xf2, 0xb1, 0x45, 0xbc, + 0x43, 0x9b, 0x9e, 0xc4, 0x88, 0x70, 0x01, 0xe9, 0x4b, 0xeb, 0x4e, 0xfd, 0xfd, 0x59, 0x43, 0xf9, + 0x7d, 0xd6, 0x50, 0xde, 0xfd, 0xfa, 0x7c, 0xef, 0xd2, 0x96, 0xe6, 0x0d, 0xb8, 0x2e, 0x0b, 0xe8, + 0x23, 0x12, 0xe3, 0x88, 0x20, 0xf3, 0x83, 0x0a, 0x95, 0x1e, 0xf1, 0x7b, 0xe9, 0x5b, 0x1a, 0xf0, + 0x66, 0xb6, 0xe1, 0x5a, 0x10, 0xc5, 0x29, 0xe5, 0x95, 0x94, 0xdb, 0xba, 0x35, 0xe5, 0xa8, 0xd6, + 0x53, 0xc6, 0xe8, 0x2e, 0xb3, 0x8c, 0x7d, 0x41, 0xd7, 0x76, 0x60, 0x05, 0xa7, 0x34, 0x4e, 0x29, + 0x6b, 0x84, 0x2d, 0x77, 0x7b, 0xaa, 0xf2, 0x39, 0xe7, 0x48, 0x69, 0xa6, 0xe8, 0xac, 0x66, 0x79, + 0x85, 0x99, 0x79, 0x0b, 0xaa, 0x93, 0xa1, 0xf2, 0xb4, 0x1f, 0x55, 0xbe, 0xc1, 0xcb, 0xd8, 0x73, + 0x28, 0x7a, 0xe1, 0x24, 0x4e, 0x48, 0xb4, 0x6d, 0x28, 0x39, 0x29, 0x3d, 0xc0, 0x49, 0x40, 0x4f, + 0x16, 0xde, 0x71, 0x4c, 0xd5, 0x1e, 0x43, 0x31, 0xe6, 0x0e, 0xfc, 0x82, 0xb3, 0xf2, 0x8a, 0x21, + 0x32, 0xaf, 0x14, 0x74, 0x56, 0x59, 0xd4, 0xb1, 0x95, 0x59, 0x87, 0xb5, 0x7f, 0x52, 0x65, 0x89, + 0xdb, 0xa7, 0x4b, 0x50, 0xe8, 0x11, 0x5f, 0x7b, 0x06, 0xcb, 0xbc, 0xde, 0xf5, 0xa9, 0x53, 0xe4, + 0x55, 0xf4, 0xbb, 0xf3, 0xd0, 0xcc, 0x53, 0x7b, 0x05, 0xa5, 0xf1, 0xbd, 0xee, 0xcc, 0x92, 0xe4, + 0x14, 0x7d, 0x73, 0x21, 0x25, 0xb7, 0x76, 0xa1, 0x72, 0xa9, 0xdc, 0x99, 0x81, 0x26, 0x59, 0xfa, + 0xfd, 0xab, 0xb0, 0xb2, 0x19, 0xdd, 0xdd, 0xf3, 0xa1, 0xa1, 0x5e, 0x0c, 0x0d, 0xf5, 0xe7, 0xd0, + 0x50, 0x4f, 0x47, 0x86, 0x72, 0x31, 0x32, 0x94, 0x6f, 0x23, 0x43, 0x79, 0xbd, 0x39, 0xf7, 0x65, + 0x3f, 0x16, 0xff, 0x06, 0xfc, 0x9d, 0x77, 0x8b, 0xfc, 0x37, 0xfd, 0xf0, 0x6f, 0x00, 0x00, 0x00, + 0xff, 0xff, 0x8a, 0x36, 0x66, 0x7a, 0x92, 0x04, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -257,6 +363,11 @@ type MsgClient interface { Send(ctx context.Context, in *MsgSend, opts ...grpc.CallOption) (*MsgSendResponse, error) // MultiSend defines a method for sending coins from some accounts to other accounts. MultiSend(ctx context.Context, in *MsgMultiSend, opts ...grpc.CallOption) (*MsgMultiSendResponse, error) + // UpdateParams defines a governance operation for updating the x/bank module parameters. + // The authority is defined in the keeper. + // + // Since: cosmos-sdk 0.47 + UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error) } type msgClient struct { @@ -285,12 +396,26 @@ func (c *msgClient) MultiSend(ctx context.Context, in *MsgMultiSend, opts ...grp return out, nil } +func (c *msgClient) UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error) { + out := new(MsgUpdateParamsResponse) + err := c.cc.Invoke(ctx, "/cosmos.bank.v1beta1.Msg/UpdateParams", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // MsgServer is the server API for Msg service. type MsgServer interface { // Send defines a method for sending coins from one account to another account. Send(context.Context, *MsgSend) (*MsgSendResponse, error) // MultiSend defines a method for sending coins from some accounts to other accounts. MultiSend(context.Context, *MsgMultiSend) (*MsgMultiSendResponse, error) + // UpdateParams defines a governance operation for updating the x/bank module parameters. + // The authority is defined in the keeper. + // + // Since: cosmos-sdk 0.47 + UpdateParams(context.Context, *MsgUpdateParams) (*MsgUpdateParamsResponse, error) } // UnimplementedMsgServer can be embedded to have forward compatible implementations. @@ -303,6 +428,9 @@ func (*UnimplementedMsgServer) Send(ctx context.Context, req *MsgSend) (*MsgSend func (*UnimplementedMsgServer) MultiSend(ctx context.Context, req *MsgMultiSend) (*MsgMultiSendResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method MultiSend not implemented") } +func (*UnimplementedMsgServer) UpdateParams(ctx context.Context, req *MsgUpdateParams) (*MsgUpdateParamsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdateParams not implemented") +} func RegisterMsgServer(s grpc1.Server, srv MsgServer) { s.RegisterService(&_Msg_serviceDesc, srv) @@ -344,6 +472,24 @@ func _Msg_MultiSend_Handler(srv interface{}, ctx context.Context, dec func(inter return interceptor(ctx, in, info, handler) } +func _Msg_UpdateParams_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgUpdateParams) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).UpdateParams(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/cosmos.bank.v1beta1.Msg/UpdateParams", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).UpdateParams(ctx, req.(*MsgUpdateParams)) + } + return interceptor(ctx, in, info, handler) +} + var _Msg_serviceDesc = grpc.ServiceDesc{ ServiceName: "cosmos.bank.v1beta1.Msg", HandlerType: (*MsgServer)(nil), @@ -356,6 +502,10 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ MethodName: "MultiSend", Handler: _Msg_MultiSend_Handler, }, + { + MethodName: "UpdateParams", + Handler: _Msg_UpdateParams_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "cosmos/bank/v1beta1/tx.proto", @@ -505,6 +655,69 @@ func (m *MsgMultiSendResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *MsgUpdateParams) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgUpdateParams) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if len(m.Authority) > 0 { + i -= len(m.Authority) + copy(dAtA[i:], m.Authority) + i = encodeVarintTx(dAtA, i, uint64(len(m.Authority))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgUpdateParamsResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgUpdateParamsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + func encodeVarintTx(dAtA []byte, offset int, v uint64) int { offset -= sovTx(v) base := offset @@ -574,6 +787,30 @@ func (m *MsgMultiSendResponse) Size() (n int) { return n } +func (m *MsgUpdateParams) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Authority) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = m.Params.Size() + n += 1 + l + sovTx(uint64(l)) + return n +} + +func (m *MsgUpdateParamsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + func sovTx(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -945,6 +1182,171 @@ func (m *MsgMultiSendResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *MsgUpdateParams) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgUpdateParams: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateParams: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Authority", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Authority = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgUpdateParamsResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgUpdateParamsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipTx(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/crisis/keeper/keeper.go b/x/crisis/keeper/keeper.go index 3c191e11c19d..e7e85c3683ff 100644 --- a/x/crisis/keeper/keeper.go +++ b/x/crisis/keeper/keeper.go @@ -28,10 +28,6 @@ type Keeper struct { feeCollectorName string // name of the FeeCollector ModuleAccount } -func (k *Keeper) GetAuthority() string { - return k.authority -} - // NewKeeper creates a new Keeper object func NewKeeper( cdc codec.BinaryCodec, storeKey storetypes.StoreKey, invCheckPeriod uint, @@ -48,6 +44,11 @@ func NewKeeper( } } +// GetAuthority returns the x/crisis module's authority. +func (k *Keeper) GetAuthority() string { + return k.authority +} + // Logger returns a module-specific logger. func (k *Keeper) Logger(ctx sdk.Context) log.Logger { return ctx.Logger().With("module", "x/"+types.ModuleName) diff --git a/x/crisis/module.go b/x/crisis/module.go index ee3fec22194d..0df2d64d900c 100644 --- a/x/crisis/module.go +++ b/x/crisis/module.go @@ -29,10 +29,9 @@ import ( "github.com/cosmos/cosmos-sdk/x/crisis/keeper" "github.com/cosmos/cosmos-sdk/x/crisis/types" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" - paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" ) -// ConsensusVersion defines the current x/params module consensus version. +// ConsensusVersion defines the current x/crisis module consensus version. const ConsensusVersion = 2 var ( @@ -198,12 +197,15 @@ func init() { type crisisInputs struct { depinject.In - Config *modulev1.Module - Key *store.KVStoreKey - Cdc codec.Codec - AppOpts servertypes.AppOptions `optional:"true"` - Subspace paramstypes.Subspace + Config *modulev1.Module + Key *store.KVStoreKey + Cdc codec.Codec + AppOpts servertypes.AppOptions `optional:"true"` + BankKeeper types.SupplyKeeper + + // LegacySubspace is used solely for migration of x/params managed parameters + LegacySubspace exported.Subspace } type crisisOutputs struct { @@ -236,7 +238,7 @@ func provideModule(in crisisInputs) crisisOutputs { skipGenesisInvariants := cast.ToBool(in.AppOpts.Get(FlagSkipGenesisInvariants)) - m := NewAppModule(k, skipGenesisInvariants, in.Subspace) + m := NewAppModule(k, skipGenesisInvariants, in.LegacySubspace) return crisisOutputs{CrisisKeeper: k, Module: runtime.WrapAppModule(m)} } diff --git a/x/distribution/module.go b/x/distribution/module.go index d9a9b1b813f0..6f4b9f84aec4 100644 --- a/x/distribution/module.go +++ b/x/distribution/module.go @@ -23,12 +23,12 @@ import ( simtypes "github.com/cosmos/cosmos-sdk/types/simulation" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/cosmos/cosmos-sdk/x/distribution/client/cli" + "github.com/cosmos/cosmos-sdk/x/distribution/exported" "github.com/cosmos/cosmos-sdk/x/distribution/keeper" "github.com/cosmos/cosmos-sdk/x/distribution/simulation" "github.com/cosmos/cosmos-sdk/x/distribution/types" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" - paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" staking "github.com/cosmos/cosmos-sdk/x/staking/types" ) @@ -104,13 +104,13 @@ type AppModule struct { stakingKeeper types.StakingKeeper // legacySubspace is used solely for migration of x/params managed parameters - legacySubspace paramstypes.Subspace + legacySubspace exported.Subspace } // NewAppModule creates a new AppModule object func NewAppModule( cdc codec.Codec, keeper keeper.Keeper, accountKeeper types.AccountKeeper, - bankKeeper types.BankKeeper, stakingKeeper types.StakingKeeper, ss paramstypes.Subspace, + bankKeeper types.BankKeeper, stakingKeeper types.StakingKeeper, ss exported.Subspace, ) AppModule { return AppModule{ AppModuleBasic: AppModuleBasic{cdc: cdc}, @@ -246,7 +246,7 @@ type distrInputs struct { StakingKeeper types.StakingKeeper // LegacySubspace is used solely for migration of x/params managed parameters - LegacySubspace paramstypes.Subspace + LegacySubspace exported.Subspace } type distrOutputs struct { diff --git a/x/genutil/migrations/v043/migrate.go b/x/genutil/migrations/v043/migrate.go index 76676494443d..16a433c9efb9 100644 --- a/x/genutil/migrations/v043/migrate.go +++ b/x/genutil/migrations/v043/migrate.go @@ -2,8 +2,8 @@ package v043 import ( "github.com/cosmos/cosmos-sdk/client" - v042bank "github.com/cosmos/cosmos-sdk/x/bank/migrations/v042" - v043bank "github.com/cosmos/cosmos-sdk/x/bank/migrations/v043" + v1bank "github.com/cosmos/cosmos-sdk/x/bank/migrations/v1" + v2bank "github.com/cosmos/cosmos-sdk/x/bank/migrations/v2" bank "github.com/cosmos/cosmos-sdk/x/bank/types" "github.com/cosmos/cosmos-sdk/x/genutil/types" v042gov "github.com/cosmos/cosmos-sdk/x/gov/migrations/v042" @@ -27,17 +27,17 @@ func Migrate(appState types.AppMap, clientCtx client.Context) types.AppMap { appState[v043gov.ModuleName] = clientCtx.Codec.MustMarshalJSON(v043gov.MigrateJSON(&oldGovState)) } - if appState[v042bank.ModuleName] != nil { + if appState[v1bank.ModuleName] != nil { // unmarshal relative source genesis application state var oldBankState bank.GenesisState - clientCtx.Codec.MustUnmarshalJSON(appState[v042bank.ModuleName], &oldBankState) + clientCtx.Codec.MustUnmarshalJSON(appState[v1bank.ModuleName], &oldBankState) // delete deprecated x/bank genesis state - delete(appState, v042bank.ModuleName) + delete(appState, v1bank.ModuleName) // Migrate relative source genesis application state and marshal it into // the respective key. - appState[v043bank.ModuleName] = clientCtx.Codec.MustMarshalJSON(v043bank.MigrateJSON(&oldBankState)) + appState[v2bank.ModuleName] = clientCtx.Codec.MustMarshalJSON(v2bank.MigrateJSON(&oldBankState)) } return appState diff --git a/x/genutil/migrations/v047/migrate.go b/x/genutil/migrations/v047/migrate.go index 67bd6e903331..2d322fb6174b 100644 --- a/x/genutil/migrations/v047/migrate.go +++ b/x/genutil/migrations/v047/migrate.go @@ -2,7 +2,7 @@ package v047 import ( "github.com/cosmos/cosmos-sdk/client" - bankv047 "github.com/cosmos/cosmos-sdk/x/bank/migrations/v047" + bankv4 "github.com/cosmos/cosmos-sdk/x/bank/migrations/v4" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" "github.com/cosmos/cosmos-sdk/x/genutil/types" ) @@ -14,7 +14,7 @@ func Migrate(appState types.AppMap, clientCtx client.Context) types.AppMap { if len(bankState) > 0 { var oldBankState *banktypes.GenesisState clientCtx.Codec.MustUnmarshalJSON(bankState, oldBankState) - newBankState := bankv047.MigrateGenState(oldBankState) + newBankState := bankv4.MigrateGenState(oldBankState) appState[banktypes.ModuleName] = clientCtx.Codec.MustMarshalJSON(newBankState) } return appState