Skip to content

Commit

Permalink
remove getParams in observer
Browse files Browse the repository at this point in the history
  • Loading branch information
lumtis committed Mar 8, 2024
1 parent f8e8565 commit 2625443
Show file tree
Hide file tree
Showing 14 changed files with 11 additions and 59 deletions.
18 changes: 0 additions & 18 deletions testutil/keeper/mocks/crosschain/observer.go

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

20 changes: 0 additions & 20 deletions testutil/keeper/mocks/fungible/observer.go

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

2 changes: 1 addition & 1 deletion x/crosschain/keeper/msg_server_add_to_intx_tracker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
)

func setupVerificationParams(zk keepertest.ZetaKeepers, ctx sdk.Context, tx_index int64, chainID int64, header ethtypes.Header, headerRLP []byte, block *ethtypes.Block) {
params := zk.ObserverKeeper.GetParams(ctx)
params := zk.ObserverKeeper.GetParamsIfExists(ctx)
zk.ObserverKeeper.SetParams(ctx, params)
zk.ObserverKeeper.SetBlockHeader(ctx, common.BlockHeader{
Height: block.Number().Int64(),
Expand Down
1 change: 0 additions & 1 deletion x/crosschain/types/expected_keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ type BankKeeper interface {
type ObserverKeeper interface {
GetObserverSet(ctx sdk.Context) (val observertypes.ObserverSet, found bool)
GetBallot(ctx sdk.Context, index string) (val observertypes.Ballot, found bool)
GetParams(ctx sdk.Context) (params observertypes.Params)
GetChainParamsByChainID(ctx sdk.Context, chainID int64) (params *observertypes.ChainParams, found bool)
GetNodeAccount(ctx sdk.Context, address string) (nodeAccount observertypes.NodeAccount, found bool)
GetAllNodeAccount(ctx sdk.Context) (nodeAccounts []observertypes.NodeAccount)
Expand Down
2 changes: 0 additions & 2 deletions x/fungible/types/expected_keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
evmtypes "github.com/evmos/ethermint/x/evm/types"
"github.com/zeta-chain/zetacore/common"
authoritytypes "github.com/zeta-chain/zetacore/x/authority/types"
observertypes "github.com/zeta-chain/zetacore/x/observer/types"
)

// AccountKeeper defines the expected account keeper used for simulations (noalias)
Expand All @@ -32,7 +31,6 @@ type BankKeeper interface {
}

type ObserverKeeper interface {
GetParams(ctx sdk.Context) (params observertypes.Params)
GetSupportedChains(ctx sdk.Context) []*common.Chain
}

Expand Down
2 changes: 1 addition & 1 deletion x/observer/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState)

// ExportGenesis returns the observer module's exported genesis.
func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState {
params := k.GetParams(ctx)
params := k.GetParamsIfExists(ctx)

chainParams, found := k.GetChainParamsList(ctx)
if !found {
Expand Down
2 changes: 1 addition & 1 deletion x/observer/keeper/ballot.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func (k Keeper) AddBallotToList(ctx sdk.Context, ballot types.Ballot) {

// GetMaturedBallotList Returns a list of ballots which are matured at current height
func (k Keeper) GetMaturedBallotList(ctx sdk.Context) []string {
maturityBlocks := k.GetParams(ctx).BallotMaturityBlocks
maturityBlocks := k.GetParamsIfExists(ctx).BallotMaturityBlocks
list, found := k.GetBallotList(ctx, ctx.BlockHeight()-maturityBlocks)
if !found {
return []string{}
Expand Down
2 changes: 1 addition & 1 deletion x/observer/keeper/grpc_query_params.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ func (k Keeper) Params(c context.Context, req *types.QueryParamsRequest) (*types
}
ctx := sdk.UnwrapSDKContext(c)
return &types.QueryParamsResponse{
Params: k.GetParams(ctx)}, nil
Params: k.GetParamsIfExists(ctx)}, nil
}
6 changes: 0 additions & 6 deletions x/observer/keeper/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,6 @@ import (
"github.com/zeta-chain/zetacore/x/observer/types"
)

// GetParams get all parameters as types.Params
func (k Keeper) GetParams(ctx sdk.Context) (params types.Params) {
k.paramstore.GetParamSet(ctx, &params)
return
}

func (k Keeper) GetParamsIfExists(ctx sdk.Context) (params types.Params) {
k.paramstore.GetParamSetIfExists(ctx, &params)
return
Expand Down
2 changes: 1 addition & 1 deletion x/observer/keeper/params_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func TestGetParams(t *testing.T) {

k.SetParams(ctx, params)

require.EqualValues(t, params, k.GetParams(ctx))
require.EqualValues(t, params, k.GetParamsIfExists(ctx))
}

func TestGenerateAddress(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions x/observer/migrations/v3/migrate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func TestMigrateStore(t *testing.T) {
k.SetParams(ctx, params)
err := v3.MigrateStore(ctx, k)
require.NoError(t, err)
params = k.GetParams(ctx)
params = k.GetParamsIfExists(ctx)
require.Len(t, params.AdminPolicy, 0)

// update admin policy
Expand All @@ -42,7 +42,7 @@ func TestMigrateStore(t *testing.T) {
k.SetParams(ctx, params)
err = v3.MigrateStore(ctx, k)
require.NoError(t, err)
params = k.GetParams(ctx)
params = k.GetParamsIfExists(ctx)
require.Len(t, params.AdminPolicy, 2)
require.Equal(t, params.AdminPolicy[0].PolicyType, types.Policy_Type_group1)
require.Equal(t, params.AdminPolicy[1].PolicyType, types.Policy_Type_group2)
Expand Down
1 change: 0 additions & 1 deletion x/observer/migrations/v4/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (

// observerKeeper prevents circular dependency
type observerKeeper interface {
GetParams(ctx sdk.Context) types.Params
SetParams(ctx sdk.Context, params types.Params)
GetChainParamsList(ctx sdk.Context) (params types.ChainParamsList, found bool)
SetChainParamsList(ctx sdk.Context, params types.ChainParamsList)
Expand Down
4 changes: 2 additions & 2 deletions x/observer/migrations/v5/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (

// observerKeeper prevents circular dependency
type observerKeeper interface {
GetParams(ctx sdk.Context) types.Params
GetParamsIfExists(ctx sdk.Context) types.Params
SetParams(ctx sdk.Context, params types.Params)
GetChainParamsList(ctx sdk.Context) (params types.ChainParamsList, found bool)
SetChainParamsList(ctx sdk.Context, params types.ChainParamsList)
Expand Down Expand Up @@ -64,7 +64,7 @@ func MigrateObserverParams(ctx sdk.Context, observerKeeper observerKeeper) error
}

// search for the observer params with chain params entry
observerParams := observerKeeper.GetParams(ctx).ObserverParams
observerParams := observerKeeper.GetParamsIfExists(ctx).ObserverParams
for _, observerParam := range observerParams {
for i := range chainParamsList.ChainParams {
// if the chain is found, update the chain params with the observer params
Expand Down
4 changes: 2 additions & 2 deletions x/observer/migrations/v7/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

// observerKeeper prevents circular dependency
type observerKeeper interface {
GetParams(ctx sdk.Context) (params types.Params)
GetParamsIfExists(ctx sdk.Context) (params types.Params)
GetAuthorityKeeper() types.AuthorityKeeper
}

Expand All @@ -19,7 +19,7 @@ func MigrateStore(ctx sdk.Context, observerKeeper observerKeeper) error {

// MigratePolicies migrates policies from observer to authority
func MigratePolicies(ctx sdk.Context, observerKeeper observerKeeper) error {
params := observerKeeper.GetParams(ctx)
params := observerKeeper.GetParamsIfExists(ctx)
authorityKeeper := observerKeeper.GetAuthorityKeeper()

var policies authoritytypes.Policies
Expand Down

0 comments on commit 2625443

Please sign in to comment.