Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(observer): isSupported to isActive #1545

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions proto/observer/params.proto
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ message ChainParams {
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
bool is_supported = 16;
bool is_active = 16;
}

// Deprecated: Use ChainParamsList
Expand All @@ -44,7 +44,7 @@ message ObserverParams {
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
bool is_supported = 5;
bool is_active = 5;
}

enum Policy_Type {
Expand Down
2 changes: 1 addition & 1 deletion testutil/network/genesis_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ func AddObserverData(t *testing.T, n int, genesisState map[string]json.RawMessag
// set chain params with chains all enabled
state.ChainParamsList = observertypes.GetDefaultChainParams()
for i := range state.ChainParamsList.ChainParams {
state.ChainParamsList.ChainParams[i].IsSupported = true
state.ChainParamsList.ChainParams[i].IsActive = true
}

// set params
Expand Down
4 changes: 2 additions & 2 deletions testutil/sample/observer.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,13 @@ func ChainParams(chainID int64) *types.ChainParams {
OutboundTxScheduleLookahead: Int64InRange(r, 1, 500),
BallotThreshold: fiftyPercent,
MinObserverDelegation: sdk.NewDec(r.Int63()),
IsSupported: false,
IsActive: false,
}
}

func ChainParamsSupported(chainID int64) *types.ChainParams {
cp := ChainParams(chainID)
cp.IsSupported = true
cp.IsActive = true
return cp
}

Expand Down
8 changes: 4 additions & 4 deletions typescript/observer/params_pb.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,9 @@ export declare class ChainParams extends Message<ChainParams> {
minObserverDelegation: string;

/**
* @generated from field: bool is_supported = 16;
* @generated from field: bool is_active = 16;
*/
isSupported: boolean;
isActive: boolean;

constructor(data?: PartialMessage<ChainParams>);

Expand Down Expand Up @@ -157,9 +157,9 @@ export declare class ObserverParams extends Message<ObserverParams> {
minObserverDelegation: string;

/**
* @generated from field: bool is_supported = 5;
* @generated from field: bool is_active = 5;
*/
isSupported: boolean;
isActive: boolean;

constructor(data?: PartialMessage<ObserverParams>);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ func setupVerificationParams(zk keepertest.ZetaKeepers, ctx sdk.Context, tx_inde
ConnectorContractAddress: block.Transactions()[tx_index].To().Hex(),
BallotThreshold: sdk.OneDec(),
MinObserverDelegation: sdk.OneDec(),
IsSupported: true,
IsActive: true,
},
}})
zk.ObserverKeeper.SetCrosschainFlags(ctx, observertypes.CrosschainFlags{
Expand Down
2 changes: 1 addition & 1 deletion x/crosschain/keeper/msg_server_migrate_tss_funds_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ func setupTssMigrationParams(
ChainId: chain.ChainId,
BallotThreshold: sdk.NewDec(0),
MinObserverDelegation: sdk.OneDec(),
IsSupported: true,
IsActive: true,
},
},
})
Expand Down
2 changes: 1 addition & 1 deletion x/crosschain/keeper/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ func setSupportedChain(ctx sdk.Context, zk testkeeper.ZetaKeepers, chainIDs ...i
chainParamsList := make([]*observertypes.ChainParams, len(chainIDs))
for i, chainID := range chainIDs {
chainParams := sample.ChainParams(chainID)
chainParams.IsSupported = true
chainParams.IsActive = true
chainParamsList[i] = chainParams
}
zk.ObserverKeeper.SetChainParamsList(ctx, observertypes.ChainParamsList{
Expand Down
6 changes: 3 additions & 3 deletions x/observer/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState)
} else {
// if no chain params are defined, set localnet chains for test purposes
btcChainParams := types.GetDefaultBtcRegtestChainParams()
btcChainParams.IsSupported = true
btcChainParams.IsActive = true
goerliChainParams := types.GetDefaultGoerliLocalnetChainParams()
goerliChainParams.IsSupported = true
goerliChainParams.IsActive = true
zetaPrivnetChainParams := types.GetDefaultZetaPrivnetChainParams()
zetaPrivnetChainParams.IsSupported = true
zetaPrivnetChainParams.IsActive = true
k.SetChainParamsList(ctx, types.ChainParamsList{
ChainParams: []*types.ChainParams{
btcChainParams,
Expand Down
4 changes: 2 additions & 2 deletions x/observer/keeper/chain_params.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func (k Keeper) GetSupportedChainFromChainID(ctx sdk.Context, chainID int64) *co
}

for _, cp := range cpl.ChainParams {
if cp.ChainId == chainID && cp.IsSupported {
if cp.ChainId == chainID && cp.IsActive {
return common.GetChainFromChainID(chainID)
}
}
Expand All @@ -65,7 +65,7 @@ func (k Keeper) GetSupportedChains(ctx sdk.Context) []*common.Chain {

var chains []*common.Chain
for _, cp := range cpl.ChainParams {
if cp.IsSupported {
if cp.IsActive {
chains = append(chains, common.GetChainFromChainID(cp.ChainId))
}
}
Expand Down
2 changes: 1 addition & 1 deletion x/observer/keeper/chain_params_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func TestKeeper_GetSupportedChainFromChainID(t *testing.T) {

// chain params list but chain not supported
chainParams := sample.ChainParams(getValidEthChainIDWithIndex(t, 0))
chainParams.IsSupported = false
chainParams.IsActive = false
k.SetChainParamsList(ctx, types.ChainParamsList{
ChainParams: []*types.ChainParams{chainParams},
})
Expand Down
2 changes: 1 addition & 1 deletion x/observer/keeper/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func (k Keeper) FindBallot(
observerSet, _ := k.GetObserverSet(ctx)

cp, found := k.GetChainParamsByChainID(ctx, chain.ChainId)
if !found || cp == nil || !cp.IsSupported {
if !found || cp == nil || !cp.IsActive {
err = types.ErrSupportedChains
return
}
Expand Down
2 changes: 1 addition & 1 deletion x/observer/keeper/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func setSupportedChain(ctx sdk.Context, observerKeeper keeper.Keeper, chainIDs .
chainParamsList := make([]*types.ChainParams, len(chainIDs))
for i, chainID := range chainIDs {
chainParams := sample.ChainParams(chainID)
chainParams.IsSupported = true
chainParams.IsActive = true
chainParamsList[i] = chainParams
}
observerKeeper.SetChainParamsList(ctx, types.ChainParamsList{
Expand Down
2 changes: 1 addition & 1 deletion x/observer/migrations/v4/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func MigrateObserverParams(ctx sdk.Context, observerKeeper observerKeeper) error
if chainParamsList.ChainParams[i].ChainId == observerParam.Chain.ChainId {
chainParamsList.ChainParams[i].MinObserverDelegation = observerParam.MinObserverDelegation
chainParamsList.ChainParams[i].BallotThreshold = observerParam.BallotThreshold
chainParamsList.ChainParams[i].IsSupported = observerParam.IsSupported
chainParamsList.ChainParams[i].IsActive = observerParam.IsActive
break
}
}
Expand Down
12 changes: 6 additions & 6 deletions x/observer/migrations/v4/migrate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,13 @@ func TestMigrateObserverParams(t *testing.T) {
Chain: &common.Chain{ChainId: 2},
BallotThreshold: dec42,
MinObserverDelegation: dec1000,
IsSupported: true,
IsActive: true,
},
{
Chain: &common.Chain{ChainId: 3},
BallotThreshold: dec43,
MinObserverDelegation: dec1001,
IsSupported: true,
IsActive: true,
},
},
}
Expand All @@ -92,16 +92,16 @@ func TestMigrateObserverParams(t *testing.T) {
require.EqualValues(t, dec1000, newChainParamsList.ChainParams[1].MinObserverDelegation)
require.EqualValues(t, dec43, newChainParamsList.ChainParams[2].BallotThreshold)
require.EqualValues(t, dec1001, newChainParamsList.ChainParams[2].MinObserverDelegation)
require.True(t, newChainParamsList.ChainParams[1].IsSupported)
require.True(t, newChainParamsList.ChainParams[2].IsSupported)
require.True(t, newChainParamsList.ChainParams[1].IsActive)
require.True(t, newChainParamsList.ChainParams[2].IsActive)

// check remaining values are unchanged
previousChainParamsList.ChainParams[1].BallotThreshold = dec42
previousChainParamsList.ChainParams[2].BallotThreshold = dec43
previousChainParamsList.ChainParams[1].MinObserverDelegation = dec1000
previousChainParamsList.ChainParams[2].MinObserverDelegation = dec1001
previousChainParamsList.ChainParams[1].IsSupported = true
previousChainParamsList.ChainParams[2].IsSupported = true
previousChainParamsList.ChainParams[1].IsActive = true
previousChainParamsList.ChainParams[2].IsActive = true
require.EqualValues(t, previousChainParamsList.ChainParams[1], newChainParamsList.ChainParams[1])
require.EqualValues(t, previousChainParamsList.ChainParams[2], newChainParamsList.ChainParams[2])
}
20 changes: 10 additions & 10 deletions x/observer/types/chain_params.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ func GetDefaultEthMainnetChainParams() *ChainParams {
OutboundTxScheduleLookahead: 60,
BallotThreshold: DefaultBallotThreshold,
MinObserverDelegation: DefaultMinObserverDelegation,
IsSupported: false,
IsActive: false,
}
}
func GetDefaultBscMainnetChainParams() *ChainParams {
Expand All @@ -171,7 +171,7 @@ func GetDefaultBscMainnetChainParams() *ChainParams {
OutboundTxScheduleLookahead: 60,
BallotThreshold: DefaultBallotThreshold,
MinObserverDelegation: DefaultMinObserverDelegation,
IsSupported: false,
IsActive: false,
}
}
func GetDefaultBtcMainnetChainParams() *ChainParams {
Expand All @@ -189,7 +189,7 @@ func GetDefaultBtcMainnetChainParams() *ChainParams {
OutboundTxScheduleLookahead: 60,
BallotThreshold: DefaultBallotThreshold,
MinObserverDelegation: DefaultMinObserverDelegation,
IsSupported: false,
IsActive: false,
}
}
func GetDefaultGoerliTestnetChainParams() *ChainParams {
Expand All @@ -208,7 +208,7 @@ func GetDefaultGoerliTestnetChainParams() *ChainParams {
OutboundTxScheduleLookahead: 60,
BallotThreshold: DefaultBallotThreshold,
MinObserverDelegation: DefaultMinObserverDelegation,
IsSupported: false,
IsActive: false,
}
}
func GetDefaultBscTestnetChainParams() *ChainParams {
Expand All @@ -226,7 +226,7 @@ func GetDefaultBscTestnetChainParams() *ChainParams {
OutboundTxScheduleLookahead: 60,
BallotThreshold: DefaultBallotThreshold,
MinObserverDelegation: DefaultMinObserverDelegation,
IsSupported: false,
IsActive: false,
}
}
func GetDefaultMumbaiTestnetChainParams() *ChainParams {
Expand All @@ -244,7 +244,7 @@ func GetDefaultMumbaiTestnetChainParams() *ChainParams {
OutboundTxScheduleLookahead: 60,
BallotThreshold: DefaultBallotThreshold,
MinObserverDelegation: DefaultMinObserverDelegation,
IsSupported: false,
IsActive: false,
}
}
func GetDefaultBtcTestnetChainParams() *ChainParams {
Expand All @@ -262,7 +262,7 @@ func GetDefaultBtcTestnetChainParams() *ChainParams {
OutboundTxScheduleLookahead: 100,
BallotThreshold: DefaultBallotThreshold,
MinObserverDelegation: DefaultMinObserverDelegation,
IsSupported: false,
IsActive: false,
}
}
func GetDefaultBtcRegtestChainParams() *ChainParams {
Expand All @@ -280,7 +280,7 @@ func GetDefaultBtcRegtestChainParams() *ChainParams {
OutboundTxScheduleLookahead: 5,
BallotThreshold: DefaultBallotThreshold,
MinObserverDelegation: DefaultMinObserverDelegation,
IsSupported: false,
IsActive: false,
}
}
func GetDefaultGoerliLocalnetChainParams() *ChainParams {
Expand All @@ -298,7 +298,7 @@ func GetDefaultGoerliLocalnetChainParams() *ChainParams {
OutboundTxScheduleLookahead: 5,
BallotThreshold: DefaultBallotThreshold,
MinObserverDelegation: DefaultMinObserverDelegation,
IsSupported: false,
IsActive: false,
}
}
func GetDefaultZetaPrivnetChainParams() *ChainParams {
Expand All @@ -316,6 +316,6 @@ func GetDefaultZetaPrivnetChainParams() *ChainParams {
OutboundTxScheduleLookahead: 0,
BallotThreshold: DefaultBallotThreshold,
MinObserverDelegation: DefaultMinObserverDelegation,
IsSupported: false,
IsActive: false,
}
}
4 changes: 2 additions & 2 deletions x/observer/types/chain_params_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func (s *UpdateChainParamsSuite) SetupTest() {
OutboundTxScheduleLookahead: 1,
BallotThreshold: types.DefaultBallotThreshold,
MinObserverDelegation: types.DefaultMinObserverDelegation,
IsSupported: false,
IsActive: false,
}
s.btcParams = &types.ChainParams{
ConfirmationCount: 1,
Expand All @@ -75,7 +75,7 @@ func (s *UpdateChainParamsSuite) SetupTest() {
OutboundTxScheduleLookahead: 1,
BallotThreshold: types.DefaultBallotThreshold,
MinObserverDelegation: types.DefaultMinObserverDelegation,
IsSupported: false,
IsActive: false,
}
}

Expand Down
2 changes: 1 addition & 1 deletion x/observer/types/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func DefaultParams() Params {
observerParams := make([]*ObserverParams, len(chains))
for i, chain := range chains {
observerParams[i] = &ObserverParams{
IsSupported: true,
IsActive: true,
Chain: chain,
BallotThreshold: sdk.MustNewDecFromStr("0.66"),
MinObserverDelegation: sdk.MustNewDecFromStr("1000000000000000000000"), // 1000 ZETA
Expand Down
Loading
Loading