diff --git a/contrib/localnet/scripts/start-zetacored.sh b/contrib/localnet/scripts/start-zetacored.sh index 882443919b..fb5d8a1255 100755 --- a/contrib/localnet/scripts/start-zetacored.sh +++ b/contrib/localnet/scripts/start-zetacored.sh @@ -120,6 +120,8 @@ then zetacored add-genesis-account zeta1n0rn6sne54hv7w2uu93fl48ncyqz97d3kty6sh 100000000000000000000000000azeta # Funds the localnet_gov_admin account cat $HOME/.zetacored/config/genesis.json | jq '.app_state["authority"]["policies"]["policy_addresses"][0]["address"]="zeta1srsq755t654agc0grpxj4y3w0znktrpr9tcdgk"' > $HOME/.zetacored/config/tmp_genesis.json && mv $HOME/.zetacored/config/tmp_genesis.json $HOME/.zetacored/config/genesis.json cat $HOME/.zetacored/config/genesis.json | jq '.app_state["authority"]["policies"]["policy_addresses"][1]["address"]="zeta1srsq755t654agc0grpxj4y3w0znktrpr9tcdgk"' > $HOME/.zetacored/config/tmp_genesis.json && mv $HOME/.zetacored/config/tmp_genesis.json $HOME/.zetacored/config/genesis.json + cat $HOME/.zetacored/config/genesis.json | jq '.app_state["observer"]["params"]["admin_policy"][0]["address"]="zeta1srsq755t654agc0grpxj4y3w0znktrpr9tcdgk"' > $HOME/.zetacored/config/tmp_genesis.json && mv $HOME/.zetacored/config/tmp_genesis.json $HOME/.zetacored/config/genesis.json + cat $HOME/.zetacored/config/genesis.json | jq '.app_state["observer"]["params"]["admin_policy"][1]["address"]="zeta1srsq755t654agc0grpxj4y3w0znktrpr9tcdgk"' > $HOME/.zetacored/config/tmp_genesis.json && mv $HOME/.zetacored/config/tmp_genesis.json $HOME/.zetacored/config/genesis.json # give balance to runner accounts to deploy contracts directly on zEVM # deployer diff --git a/testutil/keeper/mocks/crosschain/account.go b/testutil/keeper/mocks/crosschain/account.go index 99b7f1cf5b..fbd7c0377b 100644 --- a/testutil/keeper/mocks/crosschain/account.go +++ b/testutil/keeper/mocks/crosschain/account.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.39.1. DO NOT EDIT. +// Code generated by mockery v2.38.0. DO NOT EDIT. package mocks diff --git a/testutil/keeper/mocks/crosschain/authority.go b/testutil/keeper/mocks/crosschain/authority.go index fd6ceefa47..9f08c9d673 100644 --- a/testutil/keeper/mocks/crosschain/authority.go +++ b/testutil/keeper/mocks/crosschain/authority.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.39.1. DO NOT EDIT. +// Code generated by mockery v2.38.0. DO NOT EDIT. package mocks diff --git a/testutil/keeper/mocks/crosschain/bank.go b/testutil/keeper/mocks/crosschain/bank.go index 267f2b45b4..90f4e17e29 100644 --- a/testutil/keeper/mocks/crosschain/bank.go +++ b/testutil/keeper/mocks/crosschain/bank.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.39.1. DO NOT EDIT. +// Code generated by mockery v2.38.0. DO NOT EDIT. package mocks diff --git a/testutil/keeper/mocks/crosschain/fungible.go b/testutil/keeper/mocks/crosschain/fungible.go index a720711b79..7a0a40a6de 100644 --- a/testutil/keeper/mocks/crosschain/fungible.go +++ b/testutil/keeper/mocks/crosschain/fungible.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.39.1. DO NOT EDIT. +// Code generated by mockery v2.38.0. DO NOT EDIT. package mocks diff --git a/testutil/keeper/mocks/crosschain/observer.go b/testutil/keeper/mocks/crosschain/observer.go index 58281c92fc..8e2a40b9cb 100644 --- a/testutil/keeper/mocks/crosschain/observer.go +++ b/testutil/keeper/mocks/crosschain/observer.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.39.1. DO NOT EDIT. +// Code generated by mockery v2.38.0. DO NOT EDIT. package mocks diff --git a/testutil/keeper/mocks/crosschain/staking.go b/testutil/keeper/mocks/crosschain/staking.go index 64bbe0fed6..5b7d3c501f 100644 --- a/testutil/keeper/mocks/crosschain/staking.go +++ b/testutil/keeper/mocks/crosschain/staking.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.39.1. DO NOT EDIT. +// Code generated by mockery v2.38.0. DO NOT EDIT. package mocks diff --git a/testutil/keeper/mocks/emissions/account.go b/testutil/keeper/mocks/emissions/account.go index 265c291e1b..a660d40e72 100644 --- a/testutil/keeper/mocks/emissions/account.go +++ b/testutil/keeper/mocks/emissions/account.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.39.1. DO NOT EDIT. +// Code generated by mockery v2.38.0. DO NOT EDIT. package mocks diff --git a/testutil/keeper/mocks/emissions/bank.go b/testutil/keeper/mocks/emissions/bank.go index 0edc51d5e5..2e3d6a702e 100644 --- a/testutil/keeper/mocks/emissions/bank.go +++ b/testutil/keeper/mocks/emissions/bank.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.39.1. DO NOT EDIT. +// Code generated by mockery v2.38.0. DO NOT EDIT. package mocks diff --git a/testutil/keeper/mocks/emissions/observer.go b/testutil/keeper/mocks/emissions/observer.go index ce36c71f69..7c2cfb3c48 100644 --- a/testutil/keeper/mocks/emissions/observer.go +++ b/testutil/keeper/mocks/emissions/observer.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.39.1. DO NOT EDIT. +// Code generated by mockery v2.38.0. DO NOT EDIT. package mocks diff --git a/testutil/keeper/mocks/emissions/staking.go b/testutil/keeper/mocks/emissions/staking.go index bcfff21c40..7c58333bb5 100644 --- a/testutil/keeper/mocks/emissions/staking.go +++ b/testutil/keeper/mocks/emissions/staking.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.39.1. DO NOT EDIT. +// Code generated by mockery v2.38.0. DO NOT EDIT. package mocks diff --git a/testutil/keeper/mocks/fungible/account.go b/testutil/keeper/mocks/fungible/account.go index 94b7a84d75..0522e833b4 100644 --- a/testutil/keeper/mocks/fungible/account.go +++ b/testutil/keeper/mocks/fungible/account.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.39.1. DO NOT EDIT. +// Code generated by mockery v2.38.0. DO NOT EDIT. package mocks diff --git a/testutil/keeper/mocks/fungible/authority.go b/testutil/keeper/mocks/fungible/authority.go index b87791c784..929a99021c 100644 --- a/testutil/keeper/mocks/fungible/authority.go +++ b/testutil/keeper/mocks/fungible/authority.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.39.1. DO NOT EDIT. +// Code generated by mockery v2.38.0. DO NOT EDIT. package mocks diff --git a/testutil/keeper/mocks/fungible/bank.go b/testutil/keeper/mocks/fungible/bank.go index 20a2590911..db14226310 100644 --- a/testutil/keeper/mocks/fungible/bank.go +++ b/testutil/keeper/mocks/fungible/bank.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.39.1. DO NOT EDIT. +// Code generated by mockery v2.38.0. DO NOT EDIT. package mocks diff --git a/testutil/keeper/mocks/fungible/evm.go b/testutil/keeper/mocks/fungible/evm.go index f0dcd01094..28fd46e25c 100644 --- a/testutil/keeper/mocks/fungible/evm.go +++ b/testutil/keeper/mocks/fungible/evm.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.39.1. DO NOT EDIT. +// Code generated by mockery v2.38.0. DO NOT EDIT. package mocks diff --git a/testutil/keeper/mocks/fungible/observer.go b/testutil/keeper/mocks/fungible/observer.go index 3a4685f3b2..3010f8faaf 100644 --- a/testutil/keeper/mocks/fungible/observer.go +++ b/testutil/keeper/mocks/fungible/observer.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.39.1. DO NOT EDIT. +// Code generated by mockery v2.38.0. DO NOT EDIT. package mocks diff --git a/testutil/keeper/mocks/observer/authority.go b/testutil/keeper/mocks/observer/authority.go index ad287fd3ed..76e5e0566c 100644 --- a/testutil/keeper/mocks/observer/authority.go +++ b/testutil/keeper/mocks/observer/authority.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.39.1. DO NOT EDIT. +// Code generated by mockery v2.38.0. DO NOT EDIT. package mocks @@ -32,6 +32,11 @@ func (_m *ObserverAuthorityKeeper) IsAuthorized(ctx types.Context, address strin return r0 } +// SetPolicies provides a mock function with given fields: ctx, policies +func (_m *ObserverAuthorityKeeper) SetPolicies(ctx types.Context, policies authoritytypes.Policies) { + _m.Called(ctx, policies) +} + // NewObserverAuthorityKeeper creates a new instance of ObserverAuthorityKeeper. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. // The first argument is typically a *testing.T value. func NewObserverAuthorityKeeper(t interface { diff --git a/testutil/keeper/mocks/observer/slashing.go b/testutil/keeper/mocks/observer/slashing.go index d3f64ff726..a7793ef8dc 100644 --- a/testutil/keeper/mocks/observer/slashing.go +++ b/testutil/keeper/mocks/observer/slashing.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.39.1. DO NOT EDIT. +// Code generated by mockery v2.38.0. DO NOT EDIT. package mocks diff --git a/testutil/keeper/mocks/observer/staking.go b/testutil/keeper/mocks/observer/staking.go index 72fe2be116..90007b6c35 100644 --- a/testutil/keeper/mocks/observer/staking.go +++ b/testutil/keeper/mocks/observer/staking.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.39.1. DO NOT EDIT. +// Code generated by mockery v2.38.0. DO NOT EDIT. package mocks diff --git a/testutil/keeper/observer.go b/testutil/keeper/observer.go index f4d2d9531a..c747df0218 100644 --- a/testutil/keeper/observer.go +++ b/testutil/keeper/observer.go @@ -61,7 +61,7 @@ func initObserverKeeper( } // ObserverKeeperWithMocks instantiates an observer keeper for testing purposes with the option to mock specific keepers -func ObserverKeeperWithMocks(t testing.TB, mockOptions ObserverMockOptions) (*keeper.Keeper, sdk.Context, SDKKeepers) { +func ObserverKeeperWithMocks(t testing.TB, mockOptions ObserverMockOptions) (*keeper.Keeper, sdk.Context, SDKKeepers, ZetaKeepers) { storeKey := sdk.NewKVStoreKey(types.StoreKey) memStoreKey := storetypes.NewMemoryStoreKey(types.MemStoreKey) @@ -114,11 +114,13 @@ func ObserverKeeperWithMocks(t testing.TB, mockOptions ObserverMockOptions) (*ke k.SetParams(ctx, types.DefaultParams()) - return k, ctx, sdkKeepers + return k, ctx, sdkKeepers, ZetaKeepers{ + AuthorityKeeper: &authorityKeeperTmp, + } } // ObserverKeeper instantiates an observer keeper for testing purposes -func ObserverKeeper(t testing.TB) (*keeper.Keeper, sdk.Context, SDKKeepers) { +func ObserverKeeper(t testing.TB) (*keeper.Keeper, sdk.Context, SDKKeepers, ZetaKeepers) { return ObserverKeeperWithMocks(t, ObserverNoMocks) } diff --git a/x/observer/genesis_test.go b/x/observer/genesis_test.go index 73193de928..7482f24f95 100644 --- a/x/observer/genesis_test.go +++ b/x/observer/genesis_test.go @@ -44,7 +44,7 @@ func TestGenesis(t *testing.T) { } // Init and export - k, ctx, _ := keepertest.ObserverKeeper(t) + k, ctx, _, _ := keepertest.ObserverKeeper(t) observer.InitGenesis(ctx, *k, genesisState) got := observer.ExportGenesis(ctx, *k) require.NotNil(t, got) diff --git a/x/observer/keeper/chain_nonces_test.go b/x/observer/keeper/chain_nonces_test.go index d133c7fc53..e0b12aedec 100644 --- a/x/observer/keeper/chain_nonces_test.go +++ b/x/observer/keeper/chain_nonces_test.go @@ -10,7 +10,7 @@ import ( func TestKeeper_GetChainNonces(t *testing.T) { t.Run("Get chain nonces", func(t *testing.T) { - k, ctx, _ := keepertest.ObserverKeeper(t) + k, ctx, _, _ := keepertest.ObserverKeeper(t) chainNoncesList := sample.ChainNoncesList(t, 10) for _, n := range chainNoncesList { k.SetChainNonces(ctx, n) @@ -22,7 +22,7 @@ func TestKeeper_GetChainNonces(t *testing.T) { } }) t.Run("Get chain nonces not found", func(t *testing.T) { - k, ctx, _ := keepertest.ObserverKeeper(t) + k, ctx, _, _ := keepertest.ObserverKeeper(t) chainNoncesList := sample.ChainNoncesList(t, 10) for _, n := range chainNoncesList { k.SetChainNonces(ctx, n) @@ -31,7 +31,7 @@ func TestKeeper_GetChainNonces(t *testing.T) { require.False(t, found) }) t.Run("Get all chain nonces", func(t *testing.T) { - k, ctx, _ := keepertest.ObserverKeeper(t) + k, ctx, _, _ := keepertest.ObserverKeeper(t) chainNoncesList := sample.ChainNoncesList(t, 10) for _, n := range chainNoncesList { k.SetChainNonces(ctx, n) diff --git a/x/observer/keeper/chain_params_test.go b/x/observer/keeper/chain_params_test.go index 9bf63cd65b..2d63265122 100644 --- a/x/observer/keeper/chain_params_test.go +++ b/x/observer/keeper/chain_params_test.go @@ -12,7 +12,7 @@ import ( func TestKeeper_GetSupportedChainFromChainID(t *testing.T) { t.Run("return nil if chain not found", func(t *testing.T) { - k, ctx, _ := keepertest.ObserverKeeper(t) + k, ctx, _, _ := keepertest.ObserverKeeper(t) // no core params list require.Nil(t, k.GetSupportedChainFromChainID(ctx, getValidEthChainIDWithIndex(t, 0))) @@ -31,7 +31,7 @@ func TestKeeper_GetSupportedChainFromChainID(t *testing.T) { }) t.Run("return chain if chain found", func(t *testing.T) { - k, ctx, _ := keepertest.ObserverKeeper(t) + k, ctx, _, _ := keepertest.ObserverKeeper(t) chainID := getValidEthChainIDWithIndex(t, 0) setSupportedChain(ctx, *k, getValidEthChainIDWithIndex(t, 1), chainID) chain := k.GetSupportedChainFromChainID(ctx, chainID) @@ -42,12 +42,12 @@ func TestKeeper_GetSupportedChainFromChainID(t *testing.T) { func TestKeeper_GetSupportedChains(t *testing.T) { t.Run("return empty list if no core params list", func(t *testing.T) { - k, ctx, _ := keepertest.ObserverKeeper(t) + k, ctx, _, _ := keepertest.ObserverKeeper(t) require.Empty(t, k.GetSupportedChains(ctx)) }) t.Run("return list containing supported chains", func(t *testing.T) { - k, ctx, _ := keepertest.ObserverKeeper(t) + k, ctx, _, _ := keepertest.ObserverKeeper(t) require.Greater(t, len(common.ExternalChainList()), 5) supported1 := common.ExternalChainList()[0] diff --git a/x/observer/keeper/grpc_query_blame_test.go b/x/observer/keeper/grpc_query_blame_test.go index 141246af47..36d95ed23e 100644 --- a/x/observer/keeper/grpc_query_blame_test.go +++ b/x/observer/keeper/grpc_query_blame_test.go @@ -12,7 +12,7 @@ import ( ) func TestKeeper_BlameByIdentifier(t *testing.T) { - k, ctx, _ := keepertest.ObserverKeeper(t) + k, ctx, _, _ := keepertest.ObserverKeeper(t) var chainId int64 = 97 var nonce uint64 = 101 digest := "85f5e10431f69bc2a14046a13aabaefc660103b6de7a84f75c4b96181d03f0b5" @@ -31,7 +31,7 @@ func TestKeeper_BlameByIdentifier(t *testing.T) { } func TestKeeper_BlameByChainAndNonce(t *testing.T) { - k, ctx, _ := keepertest.ObserverKeeper(t) + k, ctx, _, _ := keepertest.ObserverKeeper(t) var chainId int64 = 97 var nonce uint64 = 101 digest := "85f5e10431f69bc2a14046a13aabaefc660103b6de7a84f75c4b96181d03f0b5" @@ -52,7 +52,7 @@ func TestKeeper_BlameByChainAndNonce(t *testing.T) { func TestKeeper_BlameAll(t *testing.T) { t.Run("GetBlameRecord by limit ", func(t *testing.T) { - k, ctx, _ := keepertest.ObserverKeeper(t) + k, ctx, _, _ := keepertest.ObserverKeeper(t) blameList := sample.BlameRecordsList(t, 10) for _, record := range blameList { k.SetBlame(ctx, record) @@ -69,7 +69,7 @@ func TestKeeper_BlameAll(t *testing.T) { require.Equal(t, len(blameList), int(pageRes.Total)) }) t.Run("GetBlameRecord by offset ", func(t *testing.T) { - k, ctx, _ := keepertest.ObserverKeeper(t) + k, ctx, _, _ := keepertest.ObserverKeeper(t) blameList := sample.BlameRecordsList(t, 20) offset := 10 for _, record := range blameList { @@ -88,7 +88,7 @@ func TestKeeper_BlameAll(t *testing.T) { require.Equal(t, len(blameList), int(pageRes.Total)) }) t.Run("GetAllBlameRecord", func(t *testing.T) { - k, ctx, _ := keepertest.ObserverKeeper(t) + k, ctx, _, _ := keepertest.ObserverKeeper(t) blameList := sample.BlameRecordsList(t, 100) for _, record := range blameList { k.SetBlame(ctx, record) @@ -103,7 +103,7 @@ func TestKeeper_BlameAll(t *testing.T) { require.Equal(t, blameList, rst) }) t.Run("Get no records if nothing is set", func(t *testing.T) { - k, ctx, _ := keepertest.ObserverKeeper(t) + k, ctx, _, _ := keepertest.ObserverKeeper(t) rst := k.GetAllBlame(ctx) require.Len(t, rst, 0) }) diff --git a/x/observer/keeper/grpc_query_nonces_test.go b/x/observer/keeper/grpc_query_nonces_test.go index 74f4777b5d..657eb59008 100644 --- a/x/observer/keeper/grpc_query_nonces_test.go +++ b/x/observer/keeper/grpc_query_nonces_test.go @@ -14,7 +14,7 @@ import ( ) func TestChainNoncesQuerySingle(t *testing.T) { - k, ctx, _ := keepertest.ObserverKeeper(t) + k, ctx, _, _ := keepertest.ObserverKeeper(t) wctx := sdk.WrapSDKContext(ctx) chainNonces := sample.ChainNoncesList(t, 2) for _, nonce := range chainNonces { @@ -59,7 +59,7 @@ func TestChainNoncesQuerySingle(t *testing.T) { } func TestChainNoncesQueryPaginated(t *testing.T) { - k, ctx, _ := keepertest.ObserverKeeper(t) + k, ctx, _, _ := keepertest.ObserverKeeper(t) wctx := sdk.WrapSDKContext(ctx) chainNonces := sample.ChainNoncesList(t, 5) for _, nonce := range chainNonces { diff --git a/x/observer/keeper/migrator.go b/x/observer/keeper/migrator.go index 0cee0ed183..c4b676884c 100644 --- a/x/observer/keeper/migrator.go +++ b/x/observer/keeper/migrator.go @@ -7,6 +7,7 @@ import ( v4 "github.com/zeta-chain/zetacore/x/observer/migrations/v4" v5 "github.com/zeta-chain/zetacore/x/observer/migrations/v5" v6 "github.com/zeta-chain/zetacore/x/observer/migrations/v6" + v7 "github.com/zeta-chain/zetacore/x/observer/migrations/v7" ) // Migrator is a struct for handling in-place store migrations. @@ -42,3 +43,8 @@ func (m Migrator) Migrate4to5(ctx sdk.Context) error { func (m Migrator) Migrate5to6(ctx sdk.Context) error { return v6.MigrateStore(ctx, m.observerKeeper) } + +// Migrate6to7 migrates the store from consensus version 6 to 7 +func (m Migrator) Migrate6to7(ctx sdk.Context) error { + return v7.MigrateStore(ctx, m.observerKeeper) +} diff --git a/x/observer/keeper/msg_server_add_block_header_test.go b/x/observer/keeper/msg_server_add_block_header_test.go index 85a7ec505b..d50b9bf861 100644 --- a/x/observer/keeper/msg_server_add_block_header_test.go +++ b/x/observer/keeper/msg_server_add_block_header_test.go @@ -149,7 +149,7 @@ func TestMsgServer_AddBlockHeader(t *testing.T) { } for _, tc := range tt { t.Run(tc.name, func(t *testing.T) { - k, ctx, _ := keepertest.ObserverKeeper(t) + k, ctx, _, _ := keepertest.ObserverKeeper(t) srv := keeper.NewMsgServerImpl(*k) k.SetObserverSet(ctx, types.ObserverSet{ ObserverList: []string{observerAddress.String()}, diff --git a/x/observer/keeper/msg_server_remove_chain_params_test.go b/x/observer/keeper/msg_server_remove_chain_params_test.go index e65f035e71..3eae032746 100644 --- a/x/observer/keeper/msg_server_remove_chain_params_test.go +++ b/x/observer/keeper/msg_server_remove_chain_params_test.go @@ -15,7 +15,7 @@ import ( func TestMsgServer_RemoveChainParams(t *testing.T) { t.Run("can update chain params", func(t *testing.T) { - k, ctx, _ := keepertest.ObserverKeeperWithMocks(t, keepertest.ObserverMockOptions{ + k, ctx, _, _ := keepertest.ObserverKeeperWithMocks(t, keepertest.ObserverMockOptions{ UseAuthorityMock: true, }) srv := keeper.NewMsgServerImpl(*k) @@ -82,7 +82,7 @@ func TestMsgServer_RemoveChainParams(t *testing.T) { }) t.Run("cannot remove chain params if not authorized", func(t *testing.T) { - k, ctx, _ := keepertest.ObserverKeeperWithMocks(t, keepertest.ObserverMockOptions{ + k, ctx, _, _ := keepertest.ObserverKeeperWithMocks(t, keepertest.ObserverMockOptions{ UseAuthorityMock: true, }) srv := keeper.NewMsgServerImpl(*k) @@ -99,7 +99,7 @@ func TestMsgServer_RemoveChainParams(t *testing.T) { }) t.Run("cannot remove if chain ID not found", func(t *testing.T) { - k, ctx, _ := keepertest.ObserverKeeperWithMocks(t, keepertest.ObserverMockOptions{ + k, ctx, _, _ := keepertest.ObserverKeeperWithMocks(t, keepertest.ObserverMockOptions{ UseAuthorityMock: true, }) srv := keeper.NewMsgServerImpl(*k) diff --git a/x/observer/keeper/msg_server_update_chain_params_test.go b/x/observer/keeper/msg_server_update_chain_params_test.go index cbaf6f39dd..2a14a752b4 100644 --- a/x/observer/keeper/msg_server_update_chain_params_test.go +++ b/x/observer/keeper/msg_server_update_chain_params_test.go @@ -16,7 +16,7 @@ import ( func TestMsgServer_UpdateChainParams(t *testing.T) { t.Run("can update chain params", func(t *testing.T) { - k, ctx, _ := keepertest.ObserverKeeperWithMocks(t, keepertest.ObserverMockOptions{ + k, ctx, _, _ := keepertest.ObserverKeeperWithMocks(t, keepertest.ObserverMockOptions{ UseAuthorityMock: true, }) srv := keeper.NewMsgServerImpl(*k) @@ -104,7 +104,7 @@ func TestMsgServer_UpdateChainParams(t *testing.T) { }) t.Run("cannot update chain params if not authorized", func(t *testing.T) { - k, ctx, _ := keepertest.ObserverKeeperWithMocks(t, keepertest.ObserverMockOptions{ + k, ctx, _, _ := keepertest.ObserverKeeperWithMocks(t, keepertest.ObserverMockOptions{ UseAuthorityMock: true, }) srv := keeper.NewMsgServerImpl(*k) diff --git a/x/observer/keeper/msg_server_update_crosschain_flags_test.go b/x/observer/keeper/msg_server_update_crosschain_flags_test.go index 7972f9f1b7..4eb779191a 100644 --- a/x/observer/keeper/msg_server_update_crosschain_flags_test.go +++ b/x/observer/keeper/msg_server_update_crosschain_flags_test.go @@ -15,7 +15,7 @@ import ( func TestMsgServer_UpdateCrosschainFlags(t *testing.T) { t.Run("can update crosschain flags", func(t *testing.T) { - k, ctx, _ := keepertest.ObserverKeeperWithMocks(t, keepertest.ObserverMockOptions{ + k, ctx, _, _ := keepertest.ObserverKeeperWithMocks(t, keepertest.ObserverMockOptions{ UseAuthorityMock: true, }) srv := keeper.NewMsgServerImpl(*k) @@ -150,7 +150,7 @@ func TestMsgServer_UpdateCrosschainFlags(t *testing.T) { }) t.Run("cannot update crosschain flags if not authorized", func(t *testing.T) { - k, ctx, _ := keepertest.ObserverKeeperWithMocks(t, keepertest.ObserverMockOptions{ + k, ctx, _, _ := keepertest.ObserverKeeperWithMocks(t, keepertest.ObserverMockOptions{ UseAuthorityMock: true, }) srv := keeper.NewMsgServerImpl(*k) diff --git a/x/observer/keeper/msg_server_update_observer_test.go b/x/observer/keeper/msg_server_update_observer_test.go index dc5e6e748c..1d6123dab9 100644 --- a/x/observer/keeper/msg_server_update_observer_test.go +++ b/x/observer/keeper/msg_server_update_observer_test.go @@ -18,7 +18,7 @@ import ( func TestMsgServer_UpdateObserver(t *testing.T) { t.Run("successfully update tombstoned observer", func(t *testing.T) { - k, ctx, _ := keepertest.ObserverKeeper(t) + k, ctx, _, _ := keepertest.ObserverKeeper(t) srv := keeper.NewMsgServerImpl(*k) // #nosec G404 test purpose - weak randomness is not an issue here r := rand.New(rand.NewSource(9)) @@ -74,7 +74,7 @@ func TestMsgServer_UpdateObserver(t *testing.T) { }) t.Run("unable to update to a non validator address", func(t *testing.T) { - k, ctx, _ := keepertest.ObserverKeeper(t) + k, ctx, _, _ := keepertest.ObserverKeeper(t) srv := keeper.NewMsgServerImpl(*k) // #nosec G404 test purpose - weak randomness is not an issue here r := rand.New(rand.NewSource(9)) @@ -123,7 +123,7 @@ func TestMsgServer_UpdateObserver(t *testing.T) { }) t.Run("unable to update tombstoned validator with with non operator account", func(t *testing.T) { - k, ctx, _ := keepertest.ObserverKeeper(t) + k, ctx, _, _ := keepertest.ObserverKeeper(t) srv := keeper.NewMsgServerImpl(*k) // #nosec G404 test purpose - weak randomness is not an issue here r := rand.New(rand.NewSource(9)) @@ -175,7 +175,7 @@ func TestMsgServer_UpdateObserver(t *testing.T) { }) t.Run("unable to update non-tombstoned observer with update reason tombstoned", func(t *testing.T) { - k, ctx, _ := keepertest.ObserverKeeper(t) + k, ctx, _, _ := keepertest.ObserverKeeper(t) srv := keeper.NewMsgServerImpl(*k) // #nosec G404 test purpose - weak randomness is not an issue here r := rand.New(rand.NewSource(9)) @@ -226,7 +226,7 @@ func TestMsgServer_UpdateObserver(t *testing.T) { }) t.Run("unable to update observer with no node account", func(t *testing.T) { - k, ctx, _ := keepertest.ObserverKeeper(t) + k, ctx, _, _ := keepertest.ObserverKeeper(t) srv := keeper.NewMsgServerImpl(*k) // #nosec G404 test purpose - weak randomness is not an issue here r := rand.New(rand.NewSource(9)) @@ -273,7 +273,7 @@ func TestMsgServer_UpdateObserver(t *testing.T) { }) t.Run("unable to update observer when last observer count is missing", func(t *testing.T) { - k, ctx, _ := keepertest.ObserverKeeper(t) + k, ctx, _, _ := keepertest.ObserverKeeper(t) srv := keeper.NewMsgServerImpl(*k) // #nosec G404 test purpose - weak randomness is not an issue here r := rand.New(rand.NewSource(9)) @@ -319,7 +319,7 @@ func TestMsgServer_UpdateObserver(t *testing.T) { }) t.Run("update observer using admin policy", func(t *testing.T) { - k, ctx, _ := keepertest.ObserverKeeperWithMocks(t, keepertest.ObserverMockOptions{ + k, ctx, _, _ := keepertest.ObserverKeeperWithMocks(t, keepertest.ObserverMockOptions{ UseAuthorityMock: true, }) srv := keeper.NewMsgServerImpl(*k) @@ -379,7 +379,7 @@ func TestMsgServer_UpdateObserver(t *testing.T) { }) t.Run("fail to update observer using regular account and update type admin", func(t *testing.T) { - k, ctx, _ := keepertest.ObserverKeeper(t) + k, ctx, _, _ := keepertest.ObserverKeeper(t) srv := keeper.NewMsgServerImpl(*k) // #nosec G404 test purpose - weak randomness is not an issue here diff --git a/x/observer/keeper/vote_inbound_test.go b/x/observer/keeper/vote_inbound_test.go index e1391c051f..94b9ed4105 100644 --- a/x/observer/keeper/vote_inbound_test.go +++ b/x/observer/keeper/vote_inbound_test.go @@ -14,7 +14,7 @@ import ( func TestKeeper_VoteOnInboundBallot(t *testing.T) { t.Run("fail if inbound not enabled", func(t *testing.T) { - k, ctx, _ := keepertest.ObserverKeeper(t) + k, ctx, _, _ := keepertest.ObserverKeeper(t) k.SetCrosschainFlags(ctx, types.CrosschainFlags{ IsInboundEnabled: false, @@ -35,7 +35,7 @@ func TestKeeper_VoteOnInboundBallot(t *testing.T) { }) t.Run("fail if sender chain not supported", func(t *testing.T) { - k, ctx, _ := keepertest.ObserverKeeper(t) + k, ctx, _, _ := keepertest.ObserverKeeper(t) k.SetCrosschainFlags(ctx, types.CrosschainFlags{ IsInboundEnabled: true, @@ -78,7 +78,7 @@ func TestKeeper_VoteOnInboundBallot(t *testing.T) { }) t.Run("fail if not authorized", func(t *testing.T) { - k, ctx, _ := keepertest.ObserverKeeper(t) + k, ctx, _, _ := keepertest.ObserverKeeper(t) k.SetCrosschainFlags(ctx, types.CrosschainFlags{ IsInboundEnabled: true, @@ -107,7 +107,7 @@ func TestKeeper_VoteOnInboundBallot(t *testing.T) { }) t.Run("fail if receiver chain not supported", func(t *testing.T) { - k, ctx, _ := keepertest.ObserverKeeperWithMocks(t, keepertest.ObserverMocksAll) + k, ctx, _, _ := keepertest.ObserverKeeperWithMocks(t, keepertest.ObserverMocksAll) observer := sample.AccAddress() stakingMock := keepertest.GetObserverStakingMock(t, k) @@ -172,7 +172,7 @@ func TestKeeper_VoteOnInboundBallot(t *testing.T) { }) t.Run("fail if inbound contain ZETA but receiver chain doesn't support ZETA", func(t *testing.T) { - k, ctx, _ := keepertest.ObserverKeeperWithMocks(t, keepertest.ObserverMocksAll) + k, ctx, _, _ := keepertest.ObserverKeeperWithMocks(t, keepertest.ObserverMocksAll) observer := sample.AccAddress() stakingMock := keepertest.GetObserverStakingMock(t, k) @@ -214,7 +214,7 @@ func TestKeeper_VoteOnInboundBallot(t *testing.T) { }) t.Run("can add vote and create ballot", func(t *testing.T) { - k, ctx, _ := keepertest.ObserverKeeperWithMocks(t, keepertest.ObserverMocksAll) + k, ctx, _, _ := keepertest.ObserverKeeperWithMocks(t, keepertest.ObserverMocksAll) observer := sample.AccAddress() stakingMock := keepertest.GetObserverStakingMock(t, k) @@ -258,7 +258,7 @@ func TestKeeper_VoteOnInboundBallot(t *testing.T) { }) t.Run("can add vote and create ballot without finalizing ballot", func(t *testing.T) { - k, ctx, _ := keepertest.ObserverKeeperWithMocks(t, keepertest.ObserverMocksAll) + k, ctx, _, _ := keepertest.ObserverKeeperWithMocks(t, keepertest.ObserverMocksAll) observer := sample.AccAddress() stakingMock := keepertest.GetObserverStakingMock(t, k) @@ -311,7 +311,7 @@ func TestKeeper_VoteOnInboundBallot(t *testing.T) { }) t.Run("can add vote to an existing ballot", func(t *testing.T) { - k, ctx, _ := keepertest.ObserverKeeperWithMocks(t, keepertest.ObserverMocksAll) + k, ctx, _, _ := keepertest.ObserverKeeperWithMocks(t, keepertest.ObserverMocksAll) observer := sample.AccAddress() stakingMock := keepertest.GetObserverStakingMock(t, k) @@ -375,7 +375,7 @@ func TestKeeper_VoteOnInboundBallot(t *testing.T) { }) t.Run("can add vote to an existing ballot and finalize ballot", func(t *testing.T) { - k, ctx, _ := keepertest.ObserverKeeperWithMocks(t, keepertest.ObserverMocksAll) + k, ctx, _, _ := keepertest.ObserverKeeperWithMocks(t, keepertest.ObserverMocksAll) observer := sample.AccAddress() stakingMock := keepertest.GetObserverStakingMock(t, k) diff --git a/x/observer/keeper/vote_outbound_test.go b/x/observer/keeper/vote_outbound_test.go index 0e087bac1f..ad84672d4f 100644 --- a/x/observer/keeper/vote_outbound_test.go +++ b/x/observer/keeper/vote_outbound_test.go @@ -13,7 +13,7 @@ import ( func TestKeeper_VoteOnOutboundBallot(t *testing.T) { t.Run("fail if chain is not supported", func(t *testing.T) { - k, ctx, _ := keepertest.ObserverKeeper(t) + k, ctx, _, _ := keepertest.ObserverKeeper(t) k.SetChainParamsList(ctx, types.ChainParamsList{}) @@ -49,7 +49,7 @@ func TestKeeper_VoteOnOutboundBallot(t *testing.T) { }) t.Run("fail if receive status is invalid", func(t *testing.T) { - k, ctx, _ := keepertest.ObserverKeeper(t) + k, ctx, _, _ := keepertest.ObserverKeeper(t) k.SetChainParamsList(ctx, types.ChainParamsList{ ChainParams: []*types.ChainParams{ @@ -72,7 +72,7 @@ func TestKeeper_VoteOnOutboundBallot(t *testing.T) { }) t.Run("fail if sender is not authorized", func(t *testing.T) { - k, ctx, _ := keepertest.ObserverKeeper(t) + k, ctx, _, _ := keepertest.ObserverKeeper(t) k.SetChainParamsList(ctx, types.ChainParamsList{ ChainParams: []*types.ChainParams{ @@ -96,7 +96,7 @@ func TestKeeper_VoteOnOutboundBallot(t *testing.T) { }) t.Run("can add vote and create ballot", func(t *testing.T) { - k, ctx, _ := keepertest.ObserverKeeperWithMocks(t, keepertest.ObserverMocksAll) + k, ctx, _, _ := keepertest.ObserverKeeperWithMocks(t, keepertest.ObserverMocksAll) observer := sample.AccAddress() stakingMock := keepertest.GetObserverStakingMock(t, k) @@ -134,7 +134,7 @@ func TestKeeper_VoteOnOutboundBallot(t *testing.T) { }) t.Run("can add vote and create ballot without finalizing ballot", func(t *testing.T) { - k, ctx, _ := keepertest.ObserverKeeperWithMocks(t, keepertest.ObserverMocksAll) + k, ctx, _, _ := keepertest.ObserverKeeperWithMocks(t, keepertest.ObserverMocksAll) observer := sample.AccAddress() stakingMock := keepertest.GetObserverStakingMock(t, k) @@ -180,7 +180,7 @@ func TestKeeper_VoteOnOutboundBallot(t *testing.T) { }) t.Run("can add vote to an existing ballot", func(t *testing.T) { - k, ctx, _ := keepertest.ObserverKeeperWithMocks(t, keepertest.ObserverMocksAll) + k, ctx, _, _ := keepertest.ObserverKeeperWithMocks(t, keepertest.ObserverMocksAll) observer := sample.AccAddress() stakingMock := keepertest.GetObserverStakingMock(t, k) @@ -238,7 +238,7 @@ func TestKeeper_VoteOnOutboundBallot(t *testing.T) { }) t.Run("can add vote to an existing ballot and finalize ballot", func(t *testing.T) { - k, ctx, _ := keepertest.ObserverKeeperWithMocks(t, keepertest.ObserverMocksAll) + k, ctx, _, _ := keepertest.ObserverKeeperWithMocks(t, keepertest.ObserverMocksAll) observer := sample.AccAddress() stakingMock := keepertest.GetObserverStakingMock(t, k) diff --git a/x/observer/migrations/v3/migrate_test.go b/x/observer/migrations/v3/migrate_test.go index ce580cbf42..81e3747517 100644 --- a/x/observer/migrations/v3/migrate_test.go +++ b/x/observer/migrations/v3/migrate_test.go @@ -11,7 +11,7 @@ import ( ) func TestMigrateStore(t *testing.T) { - k, ctx, _ := keepertest.ObserverKeeper(t) + k, ctx, _, _ := keepertest.ObserverKeeper(t) // nothing if no admin policy params := types.DefaultParams() diff --git a/x/observer/migrations/v4/migrate_test.go b/x/observer/migrations/v4/migrate_test.go index 55c87d6541..64cbeaedef 100644 --- a/x/observer/migrations/v4/migrate_test.go +++ b/x/observer/migrations/v4/migrate_test.go @@ -11,7 +11,7 @@ import ( ) func TestMigrateCrosschainFlags(t *testing.T) { - k, ctx, _ := keepertest.ObserverKeeper(t) + k, ctx, _, _ := keepertest.ObserverKeeper(t) store := prefix.NewStore(ctx.KVStore(k.StoreKey()), types.KeyPrefix(types.CrosschainFlagsKey)) legacyFlags := types.LegacyCrosschainFlags{ IsInboundEnabled: false, diff --git a/x/observer/migrations/v5/migrate_test.go b/x/observer/migrations/v5/migrate_test.go index f5aa035414..1ba3d77eff 100644 --- a/x/observer/migrations/v5/migrate_test.go +++ b/x/observer/migrations/v5/migrate_test.go @@ -15,7 +15,7 @@ import ( func TestMigrateObserverMapper(t *testing.T) { t.Run("TestMigrateStore", func(t *testing.T) { - k, ctx, _ := keepertest.ObserverKeeper(t) + k, ctx, _, _ := keepertest.ObserverKeeper(t) legacyObserverMapperStore := prefix.NewStore(ctx.KVStore(k.StoreKey()), types.KeyPrefix(types.ObserverMapperKey)) legacyObserverMapperList := sample.LegacyObserverMapperList(t, 12, "sample") for _, legacyObserverMapper := range legacyObserverMapperList { @@ -43,7 +43,7 @@ func TestMigrateObserverMapper(t *testing.T) { } func TestMigrateObserverParams(t *testing.T) { - k, ctx, _ := keepertest.ObserverKeeper(t) + k, ctx, _, _ := keepertest.ObserverKeeper(t) // set chain params previousChainParamsList := types.ChainParamsList{ diff --git a/x/observer/migrations/v6/migrate_test.go b/x/observer/migrations/v6/migrate_test.go index b99242aabc..a9159aefc4 100644 --- a/x/observer/migrations/v6/migrate_test.go +++ b/x/observer/migrations/v6/migrate_test.go @@ -12,7 +12,7 @@ import ( func TestMigrateObserverParams(t *testing.T) { t.Run("Migrate when keygen is Pending", func(t *testing.T) { - k, ctx, _ := keepertest.ObserverKeeper(t) + k, ctx, _, _ := keepertest.ObserverKeeper(t) k.SetKeygen(ctx, types.Keygen{ Status: types.KeygenStatus_PendingKeygen, BlockNumber: math.MaxInt64, @@ -57,7 +57,7 @@ func TestMigrateObserverParams(t *testing.T) { require.Equal(t, participantList, participantList) }) t.Run("Migrate when keygen is not Pending", func(t *testing.T) { - k, ctx, _ := keepertest.ObserverKeeper(t) + k, ctx, _, _ := keepertest.ObserverKeeper(t) participantList := []string{ "zetapub1addwnpepqglunjrgl3qg08duxq9pf28jmvrer3crwnnfzp6m0u0yh9jk9mnn5p76utc", "zetapub1addwnpepqwwpjwwnes7cywfkr0afme7ymk8rf5jzhn8pfr6qqvfm9v342486qsrh4f5", diff --git a/x/observer/migrations/v7/migrate.go b/x/observer/migrations/v7/migrate.go new file mode 100644 index 0000000000..71490adfab --- /dev/null +++ b/x/observer/migrations/v7/migrate.go @@ -0,0 +1,52 @@ +package v7 + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + authoritytypes "github.com/zeta-chain/zetacore/x/authority/types" + "github.com/zeta-chain/zetacore/x/observer/types" +) + +// observerKeeper prevents circular dependency +type observerKeeper interface { + GetParams(ctx sdk.Context) (params types.Params) + GetAuthorityKeeper() types.AuthorityKeeper +} + +// MigrateStore performs in-place store migrations from v6 to v7 +func MigrateStore(ctx sdk.Context, observerKeeper observerKeeper) error { + return MigratePolicies(ctx, observerKeeper) +} + +// MigratePolicies migrates policies from observer to authority +func MigratePolicies(ctx sdk.Context, observerKeeper observerKeeper) error { + params := observerKeeper.GetParams(ctx) + authorityKeeper := observerKeeper.GetAuthorityKeeper() + + var policies authoritytypes.Policies + + // convert observer policies to authority policies + for _, adminPolicy := range params.AdminPolicy { + if adminPolicy != nil { + + // Convert group1 -> emergency and group2 -> admin + policyType := authoritytypes.PolicyType_groupAdmin + if adminPolicy.PolicyType == types.Policy_Type_group1 { + policyType = authoritytypes.PolicyType_groupEmergency + } + + policies.PolicyAddresses = append(policies.PolicyAddresses, &authoritytypes.PolicyAddress{ + Address: adminPolicy.Address, + PolicyType: policyType, + }) + } + } + + // ensure policies are valid + if err := policies.Validate(); err != nil { + return err + } + + // set policies in authority + authorityKeeper.SetPolicies(ctx, policies) + return nil +} diff --git a/x/observer/migrations/v7/migrate_test.go b/x/observer/migrations/v7/migrate_test.go new file mode 100644 index 0000000000..32fc0617d2 --- /dev/null +++ b/x/observer/migrations/v7/migrate_test.go @@ -0,0 +1,134 @@ +package v7_test + +import ( + "github.com/stretchr/testify/require" + keepertest "github.com/zeta-chain/zetacore/testutil/keeper" + "github.com/zeta-chain/zetacore/testutil/sample" + authoritytypes "github.com/zeta-chain/zetacore/x/authority/types" + v7 "github.com/zeta-chain/zetacore/x/observer/migrations/v7" + "github.com/zeta-chain/zetacore/x/observer/types" + "testing" +) + +func TestMigratePolicies(t *testing.T) { + t.Run("Migrate policies from observer to authority with 2 types", func(t *testing.T) { + k, ctx, _, zk := keepertest.ObserverKeeper(t) + + addr1 := sample.AccAddress() + addr2 := sample.AccAddress() + + k.SetParams(ctx, types.Params{ + AdminPolicy: []*types.Admin_Policy{ + { + PolicyType: types.Policy_Type_group1, + Address: addr1, + }, + { + PolicyType: types.Policy_Type_group2, + Address: addr2, + }, + }, + }) + + // Migrate policies + err := v7.MigratePolicies(ctx, k) + + // Check if policies are migrated + require.NoError(t, err) + policies, found := zk.AuthorityKeeper.GetPolicies(ctx) + require.True(t, found) + policyAddresses := policies.PolicyAddresses + require.Len(t, policyAddresses, 2) + require.EqualValues(t, addr1, policyAddresses[0].Address) + require.EqualValues(t, addr2, policyAddresses[1].Address) + require.EqualValues(t, authoritytypes.PolicyType_groupEmergency, policyAddresses[0].PolicyType) + require.EqualValues(t, authoritytypes.PolicyType_groupAdmin, policyAddresses[1].PolicyType) + }) + + t.Run("Can migrate with just emergency policy", func(t *testing.T) { + k, ctx, _, zk := keepertest.ObserverKeeper(t) + + addr := sample.AccAddress() + + k.SetParams(ctx, types.Params{ + AdminPolicy: []*types.Admin_Policy{ + { + PolicyType: types.Policy_Type_group1, + Address: addr, + }, + }, + }) + + // Migrate policies + err := v7.MigratePolicies(ctx, k) + + // Check if policies are migrated + require.NoError(t, err) + policies, found := zk.AuthorityKeeper.GetPolicies(ctx) + require.True(t, found) + policyAddresses := policies.PolicyAddresses + require.Len(t, policyAddresses, 1) + require.EqualValues(t, addr, policyAddresses[0].Address) + require.EqualValues(t, authoritytypes.PolicyType_groupEmergency, policyAddresses[0].PolicyType) + }) + + t.Run("Can migrate with just admin policy", func(t *testing.T) { + k, ctx, _, zk := keepertest.ObserverKeeper(t) + + addr := sample.AccAddress() + + k.SetParams(ctx, types.Params{ + AdminPolicy: []*types.Admin_Policy{ + { + PolicyType: types.Policy_Type_group2, + Address: addr, + }, + }, + }) + + // Migrate policies + err := v7.MigratePolicies(ctx, k) + + // Check if policies are migrated + require.NoError(t, err) + policies, found := zk.AuthorityKeeper.GetPolicies(ctx) + require.True(t, found) + policyAddresses := policies.PolicyAddresses + require.Len(t, policyAddresses, 1) + require.EqualValues(t, addr, policyAddresses[0].Address) + require.EqualValues(t, authoritytypes.PolicyType_groupAdmin, policyAddresses[0].PolicyType) + }) + + t.Run("Can migrate with no policies", func(t *testing.T) { + k, ctx, _, zk := keepertest.ObserverKeeper(t) + + k.SetParams(ctx, types.Params{}) + + // Migrate policies + err := v7.MigratePolicies(ctx, k) + + // Check if policies are migrated + require.NoError(t, err) + policies, found := zk.AuthorityKeeper.GetPolicies(ctx) + require.True(t, found) + policyAddresses := policies.PolicyAddresses + require.Len(t, policyAddresses, 0) + }) + + t.Run("Fail to migrate if invalid policy", func(t *testing.T) { + k, ctx, _, _ := keepertest.ObserverKeeper(t) + + k.SetParams(ctx, types.Params{ + AdminPolicy: []*types.Admin_Policy{ + { + PolicyType: types.Policy_Type_group1, + Address: "invalid", + }, + }, + }) + + // Migrate policies + err := v7.MigratePolicies(ctx, k) + require.Error(t, err) + }) +} diff --git a/x/observer/module.go b/x/observer/module.go index efb851964d..d6f9ba1d11 100644 --- a/x/observer/module.go +++ b/x/observer/module.go @@ -153,6 +153,9 @@ func (am AppModule) RegisterServices(cfg module.Configurator) { if err := cfg.RegisterMigration(types.ModuleName, 5, m.Migrate5to6); err != nil { panic(err) } + if err := cfg.RegisterMigration(types.ModuleName, 6, m.Migrate6to7); err != nil { + panic(err) + } } // RegisterInvariants registers the observer module's invariants. @@ -177,7 +180,7 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw } // ConsensusVersion implements ConsensusVersion. -func (AppModule) ConsensusVersion() uint64 { return 6 } +func (AppModule) ConsensusVersion() uint64 { return 7 } // BeginBlock executes all ABCI BeginBlock logic respective to the observer module. func (am AppModule) BeginBlock(ctx sdk.Context, _ abci.RequestBeginBlock) { diff --git a/x/observer/types/expected_keepers.go b/x/observer/types/expected_keepers.go index e05583077f..ba1c9ab9c2 100644 --- a/x/observer/types/expected_keepers.go +++ b/x/observer/types/expected_keepers.go @@ -27,4 +27,7 @@ type StakingHooks interface { type AuthorityKeeper interface { IsAuthorized(ctx sdk.Context, address string, policyType authoritytypes.PolicyType) bool + + // SetPolicies is solely used for the migration of policies from observer to authority + SetPolicies(ctx sdk.Context, policies authoritytypes.Policies) }