From 5b3162c563fa82236fe74171ce76469ab8f494e1 Mon Sep 17 00:00:00 2001 From: Ruaridh Date: Thu, 6 Apr 2023 12:59:02 +0100 Subject: [PATCH] Cosmos v0.46 upgrade follow ups (#1522) * ensure RewardIndexes.Mul method is called in test * remove deprecated line breaks, add new v0.46 keys cmd * register kava msg types on authz ModuleCdc --- client/keys.go | 3 +-- x/auction/types/codec.go | 6 +++++- x/bep3/types/codec.go | 5 +++++ x/cdp/types/codec.go | 6 +++++- x/committee/types/codec.go | 6 ++++++ x/community/types/codec.go | 11 +++++++---- x/earn/types/codec.go | 8 ++++++-- x/evmutil/types/codec.go | 5 +++++ x/hard/types/codec.go | 6 +++++- x/incentive/types/claims_test.go | 21 +++++++++++++++------ x/incentive/types/codec.go | 6 +++++- x/issuance/types/codec.go | 6 +++++- x/kavadist/types/codec.go | 5 +++++ x/liquid/types/codec.go | 9 ++++++--- x/pricefeed/types/codec.go | 7 +++++-- x/router/types/codec.go | 6 +++++- x/savings/types/codec.go | 7 +++++-- x/swap/types/codec.go | 6 +++++- 18 files changed, 101 insertions(+), 28 deletions(-) diff --git a/client/keys.go b/client/keys.go index 62ba114a..bbcc318d 100644 --- a/client/keys.go +++ b/client/keys.go @@ -61,11 +61,10 @@ The pass backend requires GnuPG: https://gnupg.org/ keys.ImportKeyCommand(), keys.ListKeysCmd(), keys.ShowKeysCmd(), - flags.LineBreak, keys.DeleteKeyCommand(), + keys.RenameKeyCommand(), keys.ParseKeyStringCommand(), keys.MigrateCommand(), - flags.LineBreak, ethclient.UnsafeExportEthKeyCommand(), ethclient.UnsafeImportKeyCommand(), ) diff --git a/x/auction/types/codec.go b/x/auction/types/codec.go index abe2b4c9..3e33b9ca 100644 --- a/x/auction/types/codec.go +++ b/x/auction/types/codec.go @@ -3,10 +3,10 @@ package types import ( "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/types" - cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/msgservice" + authzcodec "github.com/cosmos/cosmos-sdk/x/authz/codec" ) // RegisterLegacyAminoCodec registers all the necessary types and interfaces for the @@ -58,4 +58,8 @@ var ( func init() { RegisterLegacyAminoCodec(amino) cryptocodec.RegisterCrypto(amino) + + // Register all Amino interfaces and concrete types on the authz Amino codec so that this can later be + // used to properly serialize MsgGrant and MsgExec instances + RegisterLegacyAminoCodec(authzcodec.Amino) } diff --git a/x/bep3/types/codec.go b/x/bep3/types/codec.go index 6b4fabc5..dce4de11 100644 --- a/x/bep3/types/codec.go +++ b/x/bep3/types/codec.go @@ -6,6 +6,7 @@ import ( cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/msgservice" + authzcodec "github.com/cosmos/cosmos-sdk/x/authz/codec" ) // RegisterLegacyAminoCodec registers all the necessary types and interfaces for the @@ -41,4 +42,8 @@ var ( func init() { RegisterLegacyAminoCodec(amino) cryptocodec.RegisterCrypto(amino) + + // Register all Amino interfaces and concrete types on the authz Amino codec so that this can later be + // used to properly serialize MsgGrant and MsgExec instances + RegisterLegacyAminoCodec(authzcodec.Amino) } diff --git a/x/cdp/types/codec.go b/x/cdp/types/codec.go index 4119419c..08066e63 100644 --- a/x/cdp/types/codec.go +++ b/x/cdp/types/codec.go @@ -3,10 +3,10 @@ package types import ( "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/types" - cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/msgservice" + authzcodec "github.com/cosmos/cosmos-sdk/x/authz/codec" ) // RegisterLegacyAminoCodec registers all the necessary types and interfaces for the @@ -41,4 +41,8 @@ var ( func init() { RegisterLegacyAminoCodec(amino) cryptocodec.RegisterCrypto(amino) + + // Register all Amino interfaces and concrete types on the authz Amino codec so that this can later be + // used to properly serialize MsgGrant and MsgExec instances + RegisterLegacyAminoCodec(authzcodec.Amino) } diff --git a/x/committee/types/codec.go b/x/committee/types/codec.go index ef16146e..178e8230 100644 --- a/x/committee/types/codec.go +++ b/x/committee/types/codec.go @@ -7,6 +7,7 @@ import ( cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/msgservice" + authzcodec "github.com/cosmos/cosmos-sdk/x/authz/codec" distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types" govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" proposaltypes "github.com/cosmos/cosmos-sdk/x/params/types/proposal" @@ -31,6 +32,10 @@ func init() { cryptocodec.RegisterCrypto(amino) // amino is not sealed so that other modules can register their own pubproposal and/or permission types. + // Register all Amino interfaces and concrete types on the authz Amino codec so that this can later be + // used to properly serialize MsgGrant and MsgExec instances + RegisterLegacyAminoCodec(authzcodec.Amino) + // CommitteeChange/Delete proposals along with Permission types are // registered on gov's ModuleCdc RegisterLegacyAminoCodec(govv1beta1.ModuleCdc.LegacyAmino) @@ -42,6 +47,7 @@ func init() { RegisterProposalTypeCodec(govv1beta1.TextProposal{}, "cosmos-sdk/TextProposal") RegisterProposalTypeCodec(upgradetypes.SoftwareUpgradeProposal{}, "cosmos-sdk/SoftwareUpgradeProposal") RegisterProposalTypeCodec(upgradetypes.CancelSoftwareUpgradeProposal{}, "cosmos-sdk/CancelSoftwareUpgradeProposal") + } // RegisterLegacyAminoCodec registers all the necessary types and interfaces for the module. diff --git a/x/community/types/codec.go b/x/community/types/codec.go index a5a92c56..b86b1028 100644 --- a/x/community/types/codec.go +++ b/x/community/types/codec.go @@ -3,12 +3,11 @@ package types import ( "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/types" - "github.com/cosmos/cosmos-sdk/types/msgservice" - cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" - govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" - sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/msgservice" + authzcodec "github.com/cosmos/cosmos-sdk/x/authz/codec" + govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" ) // RegisterLegacyAminoCodec registers all the necessary types and interfaces for the module. @@ -40,4 +39,8 @@ var ( func init() { RegisterLegacyAminoCodec(amino) cryptocodec.RegisterCrypto(amino) + + // Register all Amino interfaces and concrete types on the authz Amino codec so that this can later be + // used to properly serialize MsgGrant and MsgExec instances + RegisterLegacyAminoCodec(authzcodec.Amino) } diff --git a/x/earn/types/codec.go b/x/earn/types/codec.go index 6cb3639f..8b773ff8 100644 --- a/x/earn/types/codec.go +++ b/x/earn/types/codec.go @@ -3,10 +3,10 @@ package types import ( "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/types" - "github.com/cosmos/cosmos-sdk/types/msgservice" - cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/msgservice" + authzcodec "github.com/cosmos/cosmos-sdk/x/authz/codec" govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" ) @@ -43,4 +43,8 @@ var ( func init() { RegisterLegacyAminoCodec(amino) cryptocodec.RegisterCrypto(amino) + + // Register all Amino interfaces and concrete types on the authz Amino codec so that this can later be + // used to properly serialize MsgGrant and MsgExec instances + RegisterLegacyAminoCodec(authzcodec.Amino) } diff --git a/x/evmutil/types/codec.go b/x/evmutil/types/codec.go index 766df8df..0e09ca51 100644 --- a/x/evmutil/types/codec.go +++ b/x/evmutil/types/codec.go @@ -6,6 +6,7 @@ import ( cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/msgservice" + authzcodec "github.com/cosmos/cosmos-sdk/x/authz/codec" ) // RegisterLegacyAminoCodec registers the necessary evmutil interfaces and concrete types @@ -33,4 +34,8 @@ func init() { RegisterLegacyAminoCodec(amino) cryptocodec.RegisterCrypto(amino) amino.Seal() + + // Register all Amino interfaces and concrete types on the authz Amino codec so that this can later be + // used to properly serialize MsgGrant and MsgExec instances + RegisterLegacyAminoCodec(authzcodec.Amino) } diff --git a/x/hard/types/codec.go b/x/hard/types/codec.go index aa8b4abc..44c19da4 100644 --- a/x/hard/types/codec.go +++ b/x/hard/types/codec.go @@ -3,10 +3,10 @@ package types import ( "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/types" - cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/msgservice" + authzcodec "github.com/cosmos/cosmos-sdk/x/authz/codec" ) func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { @@ -37,4 +37,8 @@ var ( func init() { RegisterLegacyAminoCodec(amino) cryptocodec.RegisterCrypto(amino) + + // Register all Amino interfaces and concrete types on the authz Amino codec so that this can later be + // used to properly serialize MsgGrant and MsgExec instances + RegisterLegacyAminoCodec(authzcodec.Amino) } diff --git a/x/incentive/types/claims_test.go b/x/incentive/types/claims_test.go index ae0fb588..b8cc8e35 100644 --- a/x/incentive/types/claims_test.go +++ b/x/incentive/types/claims_test.go @@ -5,6 +5,7 @@ import ( "testing" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/tendermint/tendermint/crypto" ) @@ -334,13 +335,21 @@ func TestRewardIndexes(t *testing.T) { for _, tc := range testcases { t.Run(tc.name, func(t *testing.T) { - // require.Equal() fails with zero values abs: and abs: {} + actual := tc.rewardIndexes.Mul(tc.multiplier) - for i := range tc.rewardIndexes { - require.True(t, - tc.expected[i].RewardFactor. - Equal(tc.rewardIndexes[i].RewardFactor.Mul(tc.multiplier)), - ) + if len(tc.expected) == 0 { + require.Equal(t, actual, tc.expected) + } else { + require.Len(t, actual, len(tc.expected)) + for i := range tc.expected { + assert.Equal(t, + actual[i].CollateralType, + tc.expected[i].CollateralType, + ) + assert.True(t, + actual[i].RewardFactor.Equal(tc.expected[i].RewardFactor), + ) + } } }) } diff --git a/x/incentive/types/codec.go b/x/incentive/types/codec.go index 5e606cd5..ccf56005 100644 --- a/x/incentive/types/codec.go +++ b/x/incentive/types/codec.go @@ -3,10 +3,10 @@ package types import ( "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/types" - cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/msgservice" + authzcodec "github.com/cosmos/cosmos-sdk/x/authz/codec" ) // RegisterLegacyAminoCodec registers all the necessary types and interfaces for the @@ -42,4 +42,8 @@ var ( func init() { RegisterLegacyAminoCodec(amino) cryptocodec.RegisterCrypto(amino) + + // Register all Amino interfaces and concrete types on the authz Amino codec so that this can later be + // used to properly serialize MsgGrant and MsgExec instances + RegisterLegacyAminoCodec(authzcodec.Amino) } diff --git a/x/issuance/types/codec.go b/x/issuance/types/codec.go index 17e5c0ac..e88e97f9 100644 --- a/x/issuance/types/codec.go +++ b/x/issuance/types/codec.go @@ -3,10 +3,10 @@ package types import ( "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/types" - cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/msgservice" + authzcodec "github.com/cosmos/cosmos-sdk/x/authz/codec" ) var ( @@ -39,4 +39,8 @@ func RegisterInterfaces(registry types.InterfaceRegistry) { func init() { RegisterLegacyAminoCodec(amino) cryptocodec.RegisterCrypto(amino) + + // Register all Amino interfaces and concrete types on the authz Amino codec so that this can later be + // used to properly serialize MsgGrant and MsgExec instances + RegisterLegacyAminoCodec(authzcodec.Amino) } diff --git a/x/kavadist/types/codec.go b/x/kavadist/types/codec.go index 2b878420..10685c24 100644 --- a/x/kavadist/types/codec.go +++ b/x/kavadist/types/codec.go @@ -4,6 +4,7 @@ import ( "github.com/cosmos/cosmos-sdk/codec" cdctypes "github.com/cosmos/cosmos-sdk/codec/types" cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" + authzcodec "github.com/cosmos/cosmos-sdk/x/authz/codec" govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" ) @@ -29,4 +30,8 @@ func init() { RegisterLegacyAminoCodec(amino) cryptocodec.RegisterCrypto(amino) amino.Seal() + + // Register all Amino interfaces and concrete types on the authz Amino codec so that this can later be + // used to properly serialize MsgGrant and MsgExec instances + RegisterLegacyAminoCodec(authzcodec.Amino) } diff --git a/x/liquid/types/codec.go b/x/liquid/types/codec.go index 9a6a1599..adaea192 100644 --- a/x/liquid/types/codec.go +++ b/x/liquid/types/codec.go @@ -3,11 +3,10 @@ package types import ( "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/types" - "github.com/cosmos/cosmos-sdk/types/msgservice" - cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" - sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/msgservice" + authzcodec "github.com/cosmos/cosmos-sdk/x/authz/codec" ) // RegisterLegacyAminoCodec registers all the necessary types and interfaces for the module. @@ -35,4 +34,8 @@ var ( func init() { RegisterLegacyAminoCodec(amino) cryptocodec.RegisterCrypto(amino) + + // Register all Amino interfaces and concrete types on the authz Amino codec so that this can later be + // used to properly serialize MsgGrant and MsgExec instances + RegisterLegacyAminoCodec(authzcodec.Amino) } diff --git a/x/pricefeed/types/codec.go b/x/pricefeed/types/codec.go index da1e3866..2ac8f712 100644 --- a/x/pricefeed/types/codec.go +++ b/x/pricefeed/types/codec.go @@ -3,11 +3,10 @@ package types import ( "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/types" - cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" - sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/msgservice" + authzcodec "github.com/cosmos/cosmos-sdk/x/authz/codec" ) // RegisterLegacyAminoCodec registers all the necessary types and interfaces for the @@ -32,4 +31,8 @@ var ( func init() { RegisterLegacyAminoCodec(amino) cryptocodec.RegisterCrypto(amino) + + // Register all Amino interfaces and concrete types on the authz Amino codec so that this can later be + // used to properly serialize MsgGrant and MsgExec instances + RegisterLegacyAminoCodec(authzcodec.Amino) } diff --git a/x/router/types/codec.go b/x/router/types/codec.go index 3bee22eb..dfd5046c 100644 --- a/x/router/types/codec.go +++ b/x/router/types/codec.go @@ -3,10 +3,10 @@ package types import ( "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/types" - cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/msgservice" + authzcodec "github.com/cosmos/cosmos-sdk/x/authz/codec" ) // RegisterLegacyAminoCodec registers all the necessary types and interfaces for the module. @@ -39,4 +39,8 @@ var ( func init() { RegisterLegacyAminoCodec(amino) cryptocodec.RegisterCrypto(amino) + + // Register all Amino interfaces and concrete types on the authz Amino codec so that this can later be + // used to properly serialize MsgGrant and MsgExec instances + RegisterLegacyAminoCodec(authzcodec.Amino) } diff --git a/x/savings/types/codec.go b/x/savings/types/codec.go index bec93907..44048a87 100644 --- a/x/savings/types/codec.go +++ b/x/savings/types/codec.go @@ -3,11 +3,10 @@ package types import ( "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/types" - cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" - sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/msgservice" + authzcodec "github.com/cosmos/cosmos-sdk/x/authz/codec" ) // RegisterLegacyAminoCodec registers all the necessary types and interfaces for the @@ -34,4 +33,8 @@ var ( func init() { RegisterLegacyAminoCodec(amino) cryptocodec.RegisterCrypto(amino) + + // Register all Amino interfaces and concrete types on the authz Amino codec so that this can later be + // used to properly serialize MsgGrant and MsgExec instances + RegisterLegacyAminoCodec(authzcodec.Amino) } diff --git a/x/swap/types/codec.go b/x/swap/types/codec.go index c7c214b7..2d1d5c12 100644 --- a/x/swap/types/codec.go +++ b/x/swap/types/codec.go @@ -3,10 +3,10 @@ package types import ( "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/types" - cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/msgservice" + authzcodec "github.com/cosmos/cosmos-sdk/x/authz/codec" ) // RegisterLegacyAminoCodec registers all the necessary types and interfaces for the @@ -40,4 +40,8 @@ var ( func init() { RegisterLegacyAminoCodec(amino) cryptocodec.RegisterCrypto(amino) + + // Register all Amino interfaces and concrete types on the authz Amino codec so that this can later be + // used to properly serialize MsgGrant and MsgExec instances + RegisterLegacyAminoCodec(authzcodec.Amino) }