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: deprecate x/params #2014

Merged
merged 31 commits into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
faf57e9
Remove unused params from fungible module
skosito Apr 9, 2024
39d8eeb
Make generate
skosito Apr 9, 2024
ec1cbec
Changelog
skosito Apr 9, 2024
697395e
Lint fix
skosito Apr 9, 2024
3ad1bc3
Lint fix
skosito Apr 9, 2024
5b7e6ca
Migrate emissions params to store
skosito Apr 10, 2024
c4a7328
Migrate observer params to its own store
skosito Apr 11, 2024
59326cb
Merge branch 'remove-broadcastmode-block' into params-upgrade
skosito Apr 11, 2024
c3e0ce6
Make generate
skosito Apr 11, 2024
5c311a8
Changelog
skosito Apr 11, 2024
cdbd412
Lint fixes
skosito Apr 11, 2024
c185179
Add observer slash amount param to migrate script
skosito Apr 11, 2024
d32aa34
Fix tests
skosito Apr 11, 2024
dbfb052
Lint fixes
skosito Apr 11, 2024
6aad8db
Fixes
skosito Apr 11, 2024
90d99d3
Lint fixes
skosito Apr 11, 2024
e146fc5
Fixes
skosito Apr 11, 2024
6eb076b
Tests
skosito Apr 11, 2024
4edfbd0
Small cleanup
skosito Apr 11, 2024
dc97a25
Remove not needed params store mock
skosito Apr 12, 2024
d04c043
Merge branch 'remove-broadcastmode-block' into params-upgrade
skosito Apr 17, 2024
5666209
Merge branch 'feat-cosmos-sdk-0.47.10-upgrade' into params-upgrade
skosito Apr 18, 2024
2c84db6
Fixes after merge
skosito Apr 18, 2024
575a12c
Add found flag to get params method
skosito Apr 18, 2024
e63b4c0
Move ballot maturity blocks param to emissions module
skosito Apr 18, 2024
69aaadc
Remove params from observer module
skosito Apr 19, 2024
8231e45
Fix build
skosito Apr 19, 2024
1d706fc
PR comments
skosito Apr 19, 2024
309745d
PR comment
skosito Apr 22, 2024
700fb8d
PR comments
skosito Apr 22, 2024
2b5a681
PR comments
skosito Apr 23, 2024
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
8 changes: 3 additions & 5 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -382,11 +382,11 @@ func New(
appCodec,
keys[observertypes.StoreKey],
keys[observertypes.MemStoreKey],
app.GetSubspace(observertypes.ModuleName),
&stakingKeeper,
app.SlashingKeeper,
app.AuthorityKeeper,
app.LightclientKeeper,
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
)

// register the staking hooks
Expand All @@ -406,12 +406,12 @@ func New(
appCodec,
keys[emissionstypes.StoreKey],
keys[emissionstypes.MemStoreKey],
app.GetSubspace(emissionstypes.ModuleName),
authtypes.FeeCollectorName,
app.BankKeeper,
app.StakingKeeper,
app.ObserverKeeper,
app.AccountKeeper,
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
)

// Create Ethermint keepers
Expand Down Expand Up @@ -527,7 +527,7 @@ func New(
crosschainmodule.NewAppModule(appCodec, app.CrosschainKeeper),
observermodule.NewAppModule(appCodec, *app.ObserverKeeper),
fungiblemodule.NewAppModule(appCodec, app.FungibleKeeper),
emissionsmodule.NewAppModule(appCodec, app.EmissionsKeeper),
emissionsmodule.NewAppModule(appCodec, app.EmissionsKeeper, app.GetSubspace(emissionstypes.ModuleName)),
authzmodule.NewAppModule(appCodec, app.AuthzKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry),
)

Expand Down Expand Up @@ -821,9 +821,7 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino
paramsKeeper.Subspace(evmtypes.ModuleName)
paramsKeeper.Subspace(feemarkettypes.ModuleName)
paramsKeeper.Subspace(group.ModuleName)
paramsKeeper.Subspace(crosschaintypes.ModuleName)
paramsKeeper.Subspace(observertypes.ModuleName)
paramsKeeper.Subspace(fungibletypes.ModuleName)
paramsKeeper.Subspace(emissionstypes.ModuleName)
return paramsKeeper
}
Expand Down
14 changes: 12 additions & 2 deletions app/setup_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,30 @@ import (
"github.com/cosmos/cosmos-sdk/types/module"
"github.com/cosmos/cosmos-sdk/x/upgrade/types"
authoritytypes "github.com/zeta-chain/zetacore/x/authority/types"
emissionstypes "github.com/zeta-chain/zetacore/x/emissions/types"
lightclienttypes "github.com/zeta-chain/zetacore/x/lightclient/types"
observertypes "github.com/zeta-chain/zetacore/x/observer/types"
)

const releaseVersion = "v15"

func SetupHandlers(app *App) {
// Set param key table for params module migration
for _, subspace := range app.ParamsKeeper.GetSubspaces() {
subspace := subspace

switch subspace.Name() {
// TODO: add all modules when cosmos-sdk is updated
case emissionstypes.ModuleName:
subspace.WithKeyTable(emissionstypes.ParamKeyTable())
}
}
app.UpgradeKeeper.SetUpgradeHandler(releaseVersion, func(ctx sdk.Context, plan types.Plan, vm module.VersionMap) (module.VersionMap, error) {
app.Logger().Info("Running upgrade handler for " + releaseVersion)
// Updated version map to the latest consensus versions from each module
for m, mb := range app.mm.Modules {
vm[m] = mb.ConsensusVersion()
}
VersionMigrator{v: vm}.TriggerMigration(observertypes.ModuleName)
VersionMigrator{v: vm}.TriggerMigration(emissionstypes.ModuleName)

return app.mm.RunMigrations(ctx, app.configurator, vm)
})
Expand Down
5 changes: 5 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# CHANGELOG

## Unreleased

### Refactor
* [2014](https://github.com/zeta-chain/node/pull/2014) - remove params module

## Unreleased
### Breaking Changes

Expand Down
1 change: 1 addition & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ ignore:
- "**/*.yaml"
- "**/*.pb.go"
- "**/*.pb.gw.go"
- "**/*_legacy.go"
- "**/*.json"
- ".github/**/*"
- "app/**/*"
Expand Down
2 changes: 0 additions & 2 deletions contrib/localnet/scripts/start-zetacored.sh
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,6 @@ then
cat $HOME/.zetacored/config/genesis.json | jq '.app_state["authority"]["policies"]["items"][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"]["items"][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["authority"]["policies"]["items"][2]["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
kingpinXD marked this conversation as resolved.
Show resolved Hide resolved

# give balance to runner accounts to deploy contracts directly on zEVM
# deployer
Expand Down
1 change: 0 additions & 1 deletion docs/cli/zetacored/zetacored_query_observer.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ zetacored query observer [flags]
* [zetacored query observer list-observer-set](zetacored_query_observer_list-observer-set.md) - Query observer set
* [zetacored query observer list-pending-nonces](zetacored_query_observer_list-pending-nonces.md) - shows a chainNonces
* [zetacored query observer list-tss-history](zetacored_query_observer_list-tss-history.md) - show historical list of TSS
* [zetacored query observer params](zetacored_query_observer_params.md) - shows the parameters of the module
* [zetacored query observer show-ballot](zetacored_query_observer_show-ballot.md) - Query BallotByIdentifier
* [zetacored query observer show-blame](zetacored_query_observer_show-blame.md) - Query BlameByIdentifier
* [zetacored query observer show-chain-nonces](zetacored_query_observer_show-chain-nonces.md) - shows a chainNonces
Expand Down
33 changes: 0 additions & 33 deletions docs/cli/zetacored/zetacored_query_observer_params.md

This file was deleted.

133 changes: 35 additions & 98 deletions docs/openapi/openapi.swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27239,7 +27239,7 @@ paths:
"200":
description: A successful response.
schema:
$ref: '#/definitions/zetacoreemissionsQueryParamsResponse'
$ref: '#/definitions/emissionsQueryParamsResponse'
default:
description: An unexpected error response.
schema:
Expand Down Expand Up @@ -28098,21 +28098,6 @@ paths:
$ref: '#/definitions/googlerpcStatus'
tags:
- Query
/zeta-chain/observer/params:
get:
summary: Parameters queries the parameters of the module.
operationId: Query_Params
responses:
"200":
description: A successful response.
schema:
$ref: '#/definitions/zetacoreobserverQueryParamsResponse'
default:
description: An unexpected error response.
schema:
$ref: '#/definitions/googlerpcStatus'
tags:
- Query
/zeta-chain/observer/pendingNonces:
get:
operationId: Query_PendingNoncesAll
Expand Down Expand Up @@ -53995,8 +53980,35 @@ definitions:
ed25519:
type: string
title: PubKeySet contains two pub keys , secp256k1 and ed25519
emissionsMsgUpdateParamsResponse:
type: object
emissionsMsgWithdrawEmissionResponse:
type: object
emissionsParams:
type: object
properties:
max_bond_factor:
type: string
min_bond_factor:
type: string
avg_block_time:
type: string
target_bond_ratio:
type: string
validator_emission_percentage:
type: string
observer_emission_percentage:
type: string
tss_signer_emission_percentage:
type: string
duration_factor_constant:
type: string
observer_slash_amount:
type: string
ballot_maturity_blocks:
type: string
format: int64
description: Params defines the parameters for the module.
emissionsQueryGetEmissionsFactorsResponse:
type: object
properties:
Expand All @@ -54015,6 +54027,13 @@ definitions:
type: string
emission_module_address:
type: string
emissionsQueryParamsResponse:
type: object
properties:
params:
$ref: '#/definitions/emissionsParams'
description: params holds all the parameters of this module.
description: QueryParamsResponse is response type for the Query/Params RPC method.
emissionsQueryShowAvailableEmissionsResponse:
type: object
properties:
Expand Down Expand Up @@ -54228,14 +54247,6 @@ definitions:
btcTypeChainEnabled:
type: boolean
title: VerificationFlags is a structure containing information which chain types are enabled for block header verification
observerAdmin_Policy:
type: object
properties:
policy_type:
$ref: '#/definitions/observerPolicy_Type'
address:
type: string
title: Deprecated(v14):Moved into the authority module
observerBallotStatus:
type: string
enum:
Expand Down Expand Up @@ -54466,18 +54477,6 @@ definitions:
- TSSKeyGen
- TSSKeySign
default: EmptyObserverType
observerObserverParams:
type: object
properties:
chain:
$ref: '#/definitions/chainsChain'
ballot_threshold:
type: string
min_observer_delegation:
type: string
is_supported:
type: boolean
title: 'Deprecated(v13): Use ChainParamsList'
observerObserverUpdateReason:
type: string
enum:
Expand All @@ -54500,13 +54499,6 @@ definitions:
tss:
type: string
title: store key is tss+chainid
observerPolicy_Type:
type: string
enum:
- group1
- group2
default: group1
title: Deprecated(v14):Moved into the authority module
observerQueryAllBlameRecordsResponse:
type: object
properties:
Expand Down Expand Up @@ -54819,61 +54811,6 @@ definitions:
format: int64
isAbortRefunded:
type: boolean
zetacoreemissionsParams:
type: object
properties:
max_bond_factor:
type: string
min_bond_factor:
type: string
avg_block_time:
type: string
target_bond_ratio:
type: string
validator_emission_percentage:
type: string
observer_emission_percentage:
type: string
tss_signer_emission_percentage:
type: string
duration_factor_constant:
type: string
observer_slash_amount:
type: string
description: Params defines the parameters for the module.
zetacoreemissionsQueryParamsResponse:
type: object
properties:
params:
$ref: '#/definitions/zetacoreemissionsParams'
description: params holds all the parameters of this module.
description: QueryParamsResponse is response type for the Query/Params RPC method.
zetacoreobserverParams:
type: object
properties:
observer_params:
type: array
items:
type: object
$ref: '#/definitions/observerObserverParams'
title: 'Deprecated(v13): Use ChainParamsList'
admin_policy:
type: array
items:
type: object
$ref: '#/definitions/observerAdmin_Policy'
title: Deprecated(v14):Moved into the authority module
ballot_maturity_blocks:
type: string
format: int64
description: Params defines the parameters for the module.
zetacoreobserverQueryParamsResponse:
type: object
properties:
params:
$ref: '#/definitions/zetacoreobserverParams'
description: params holds all the parameters of this module.
description: QueryParamsResponse is response type for the Query/Params RPC method.
ethermint.evm.v1.ChainConfig:
type: object
properties:
Expand Down
9 changes: 9 additions & 0 deletions docs/spec/emissions/messages.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Messages

## MsgUpdateParams

```proto
message MsgUpdateParams {
string authority = 1;
Params params = 2;
}
```

## MsgWithdrawEmission

WithdrawEmission allows the user to withdraw from their withdrawable emissions.
Expand Down
1 change: 1 addition & 0 deletions proto/emissions/params.proto
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ message Params {
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.nullable) = false
];
int64 ballot_maturity_blocks = 10;
}
9 changes: 9 additions & 0 deletions proto/emissions/tx.proto
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
syntax = "proto3";
package zetachain.zetacore.emissions;

import "emissions/params.proto";
import "gogoproto/gogo.proto";

option go_package = "github.com/zeta-chain/zetacore/x/emissions/types";

// Msg defines the Msg service.
service Msg {
rpc UpdateParams(MsgUpdateParams) returns (MsgUpdateParamsResponse);
rpc WithdrawEmission(MsgWithdrawEmission) returns (MsgWithdrawEmissionResponse);
}

Expand All @@ -19,3 +21,10 @@ message MsgWithdrawEmission {
}

message MsgWithdrawEmissionResponse {}

message MsgUpdateParams {
string authority = 1;
Params params = 2 [(gogoproto.nullable) = false];
}

message MsgUpdateParamsResponse {}
1 change: 0 additions & 1 deletion proto/observer/genesis.proto
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ message GenesisState {
ObserverSet observers = 2 [(gogoproto.nullable) = false];
repeated NodeAccount nodeAccountList = 3;
CrosschainFlags crosschain_flags = 4;
Params params = 5;
Keygen keygen = 6;
LastObserverCount last_observer_count = 7;
ChainParamsList chain_params_list = 8 [(gogoproto.nullable) = false];
Expand Down
Loading
Loading