From 9ece9cee46e8d4256f3a57f523f2eeb6dd2ea679 Mon Sep 17 00:00:00 2001 From: Alex Gartner Date: Tue, 10 Sep 2024 09:35:57 -0700 Subject: [PATCH 1/2] fix(zetaclient): use on-chain chain struct (#2834) --- zetaclient/chains/evm/observer/observer.go | 9 +++--- .../chains/evm/observer/observer_test.go | 28 ++++++++++++++++--- zetaclient/chains/evm/signer/signer_test.go | 10 +++---- zetaclient/orchestrator/bootstrap.go | 6 +++- 4 files changed, 38 insertions(+), 15 deletions(-) diff --git a/zetaclient/chains/evm/observer/observer.go b/zetaclient/chains/evm/observer/observer.go index afe116c95e..32952c28a2 100644 --- a/zetaclient/chains/evm/observer/observer.go +++ b/zetaclient/chains/evm/observer/observer.go @@ -21,11 +21,11 @@ import ( "github.com/zeta-chain/protocol-contracts/v2/pkg/gatewayevm.sol" "github.com/zeta-chain/node/pkg/bg" + "github.com/zeta-chain/node/pkg/chains" observertypes "github.com/zeta-chain/node/x/observer/types" "github.com/zeta-chain/node/zetaclient/chains/base" "github.com/zeta-chain/node/zetaclient/chains/evm" "github.com/zeta-chain/node/zetaclient/chains/interfaces" - "github.com/zeta-chain/node/zetaclient/config" "github.com/zeta-chain/node/zetaclient/db" "github.com/zeta-chain/node/zetaclient/metrics" ) @@ -61,8 +61,9 @@ type priorityFeeConfig struct { // NewObserver returns a new EVM chain observer func NewObserver( ctx context.Context, - evmCfg config.EVMConfig, + chain chains.Chain, evmClient interfaces.EVMRPCClient, + evmJSONRPC interfaces.EVMJSONRPCClient, chainParams observertypes.ChainParams, zetacoreClient interfaces.ZetacoreClient, tss interfaces.TSSSigner, @@ -72,7 +73,7 @@ func NewObserver( ) (*Observer, error) { // create base observer baseObserver, err := base.NewObserver( - evmCfg.Chain, + chain, chainParams, zetacoreClient, tss, @@ -90,7 +91,7 @@ func NewObserver( ob := &Observer{ Observer: *baseObserver, evmClient: evmClient, - evmJSONRPC: ethrpc.NewEthRPC(evmCfg.Endpoint), + evmJSONRPC: evmJSONRPC, outboundConfirmedReceipts: make(map[string]*ethtypes.Receipt), outboundConfirmedTransactions: make(map[string]*ethtypes.Transaction), priorityFeeConfig: priorityFeeConfig{}, diff --git a/zetaclient/chains/evm/observer/observer_test.go b/zetaclient/chains/evm/observer/observer_test.go index 61c1c25ecb..f89715022a 100644 --- a/zetaclient/chains/evm/observer/observer_test.go +++ b/zetaclient/chains/evm/observer/observer_test.go @@ -100,6 +100,11 @@ func MockEVMObserver( evmClient = mocks.NewMockEvmClient().WithBlockNumber(1000) } + // use default mock evm client if not provided + if evmJSONRPC == nil { + evmJSONRPC = mocks.NewMockJSONRPCClient() + } + // use default mock zetacore client if not provided if zetacoreClient == nil { zetacoreClient = mocks.NewZetacoreClient(t). @@ -113,7 +118,7 @@ func MockEVMObserver( tss = mocks.NewTSSMainnet() } // create AppContext - appContext, evmCfg := getAppContext(t, chain, "", ¶ms) + appContext, _ := getAppContext(t, chain, "", ¶ms) database, err := db.NewFromSqliteInMemory(true) require.NoError(t, err) @@ -122,9 +127,19 @@ func MockEVMObserver( logger := base.Logger{Std: testLogger, Compliance: testLogger} // create observer - ob, err := observer.NewObserver(ctx, evmCfg, evmClient, params, zetacoreClient, tss, database, logger, nil) + ob, err := observer.NewObserver( + ctx, + chain, + evmClient, + evmJSONRPC, + params, + zetacoreClient, + tss, + database, + logger, + nil, + ) require.NoError(t, err) - ob.WithEvmJSONRPC(evmJSONRPC) ob.WithLastBlock(lastBlock) return ob, appContext @@ -143,6 +158,7 @@ func Test_NewObserver(t *testing.T) { evmCfg config.EVMConfig chainParams observertypes.ChainParams evmClient interfaces.EVMRPCClient + evmJSONRPC interfaces.EVMJSONRPCClient tss interfaces.TSSSigner logger base.Logger before func() @@ -159,6 +175,7 @@ func Test_NewObserver(t *testing.T) { }, chainParams: params, evmClient: mocks.NewMockEvmClient().WithBlockNumber(1000), + evmJSONRPC: mocks.NewMockJSONRPCClient(), tss: mocks.NewTSSMainnet(), logger: base.Logger{}, ts: nil, @@ -172,6 +189,7 @@ func Test_NewObserver(t *testing.T) { }, chainParams: params, evmClient: mocks.NewMockEvmClient().WithError(fmt.Errorf("error RPC")), + evmJSONRPC: mocks.NewMockJSONRPCClient(), tss: mocks.NewTSSMainnet(), logger: base.Logger{}, ts: nil, @@ -186,6 +204,7 @@ func Test_NewObserver(t *testing.T) { }, chainParams: params, evmClient: mocks.NewMockEvmClient().WithBlockNumber(1000), + evmJSONRPC: mocks.NewMockJSONRPCClient(), tss: mocks.NewTSSMainnet(), before: func() { envVar := base.EnvVarLatestBlockByChain(chain) @@ -222,8 +241,9 @@ func Test_NewObserver(t *testing.T) { // create observer ob, err := observer.NewObserver( ctx, - tt.evmCfg, + chain, tt.evmClient, + tt.evmJSONRPC, tt.chainParams, zetacoreClient, tt.tss, diff --git a/zetaclient/chains/evm/signer/signer_test.go b/zetaclient/chains/evm/signer/signer_test.go index b954a4624c..807d6b7819 100644 --- a/zetaclient/chains/evm/signer/signer_test.go +++ b/zetaclient/chains/evm/signer/signer_test.go @@ -69,14 +69,11 @@ func getNewEvmChainObserver(t *testing.T, tss interfaces.TSSSigner) (*observer.O if tss == nil { tss = mocks.NewTSSMainnet() } - cfg := config.New(false) // prepare mock arguments to create observer - evmcfg := config.EVMConfig{Chain: chains.BscMainnet, Endpoint: "http://localhost:8545"} evmClient := mocks.NewMockEvmClient().WithBlockNumber(1000) - params := mocks.MockChainParams(evmcfg.Chain.ChainId, 10) - cfg.EVMChainConfigs[chains.BscMainnet.ChainId] = evmcfg - //appContext := context.New(cfg, zerolog.Nop()) + evmJSONRPCClient := mocks.NewMockJSONRPCClient() + params := mocks.MockChainParams(chains.BscMainnet.ChainId, 10) logger := base.Logger{} ts := &metrics.TelemetryServer{} @@ -85,8 +82,9 @@ func getNewEvmChainObserver(t *testing.T, tss interfaces.TSSSigner) (*observer.O return observer.NewObserver( ctx, - evmcfg, + chains.BscMainnet, evmClient, + evmJSONRPCClient, params, mocks.NewZetacoreClient(t), tss, diff --git a/zetaclient/orchestrator/bootstrap.go b/zetaclient/orchestrator/bootstrap.go index 9040133c35..7dd4344b29 100644 --- a/zetaclient/orchestrator/bootstrap.go +++ b/zetaclient/orchestrator/bootstrap.go @@ -7,6 +7,7 @@ import ( "github.com/ethereum/go-ethereum/ethclient" ethrpc "github.com/ethereum/go-ethereum/rpc" solrpc "github.com/gagliardetto/solana-go/rpc" + ethrpc2 "github.com/onrik/ethrpc" "github.com/pkg/errors" "github.com/zeta-chain/node/zetaclient/chains/base" @@ -298,11 +299,14 @@ func syncObserverMap( continue } + evmJSONRPCClient := ethrpc2.NewEthRPC(cfg.Endpoint, ethrpc2.WithHttpClient(httpClient)) + // create EVM chain observer observer, err := evmobserver.NewObserver( ctx, - cfg, + *rawChain, evmClient, + evmJSONRPCClient, *params, client, tss, From 9819129af8d27b09429e4d0965e90f1c6dd34116 Mon Sep 17 00:00:00 2001 From: Tanmay Date: Tue, 10 Sep 2024 15:03:15 -0400 Subject: [PATCH 2/2] refactor: remove unused functions from emissions module (#2826) * remove unused functions from emissions module * add fixed block rewards to params * add migration script * add unit test for migration v4 * generate files * update sample genesis doc * add unit tests under params test * refactor abci_test.go * regenerate using correct abigen * fix comments * revert unnessary changes --- changelog.md | 1 + docs/cli/zetacored/cli.md | 35 -- docs/openapi/openapi.swagger.yaml | 46 +- docs/releases/v20_breaking_changes.md | 9 + .../zetachain/zetacore/emissions/params.proto | 28 + .../zetachain/zetacore/emissions/query.proto | 15 - testutil/sample/genesis.go | 18 + testutil/sample/genesis.json | 561 ++++++++++++++++++ testutil/sample/sample.go | 10 - .../zetacore/emissions/params_pb.d.ts | 70 ++- .../zetacore/emissions/query_pb.d.ts | 53 -- x/emissions/abci.go | 14 +- x/emissions/abci_test.go | 100 ++-- x/emissions/client/cli/query.go | 2 - .../client/cli/query_get_emmisons_factors.go | 38 -- x/emissions/genesis_test.go | 3 +- .../keeper/block_rewards_components.go | 30 - .../keeper/block_rewards_components_test.go | 109 +--- .../keeper/grpc_query_get_emmisons_factors.go | 28 - .../grpc_query_get_emmisons_factors_test.go | 41 -- x/emissions/keeper/keeper.go | 8 + x/emissions/keeper/migrator.go | 6 + x/emissions/keeper/params_test.go | 170 ++---- x/emissions/migrations/v3/migrate.go | 19 +- x/emissions/migrations/v3/migrate_test.go | 18 +- x/emissions/migrations/v4/migrate.go | 73 +++ x/emissions/migrations/v4/migrate_test.go | 344 +++++++++++ x/emissions/module.go | 5 +- x/emissions/types/distributions.go | 10 +- x/emissions/types/distributions_test.go | 10 +- x/emissions/types/errors.go | 1 + x/emissions/types/keys.go | 18 +- x/emissions/types/legacy_params.go | 11 + x/emissions/types/legacy_params_test.go | 30 + .../types/message_update_params_test.go | 4 +- x/emissions/types/params.go | 138 +---- x/emissions/types/params.pb.go | 502 ++++++++++++++-- x/emissions/types/params_legacy.go | 9 - x/emissions/types/params_test.go | 143 +---- x/emissions/types/query.pb.go | 513 ++-------------- x/emissions/types/query.pb.gw.go | 65 -- x/emissions/types/types.go | 1 - 42 files changed, 1853 insertions(+), 1456 deletions(-) create mode 100644 docs/releases/v20_breaking_changes.md create mode 100644 testutil/sample/genesis.go create mode 100644 testutil/sample/genesis.json delete mode 100644 x/emissions/client/cli/query_get_emmisons_factors.go delete mode 100644 x/emissions/keeper/grpc_query_get_emmisons_factors.go delete mode 100644 x/emissions/keeper/grpc_query_get_emmisons_factors_test.go create mode 100644 x/emissions/migrations/v4/migrate.go create mode 100644 x/emissions/migrations/v4/migrate_test.go create mode 100644 x/emissions/types/legacy_params.go create mode 100644 x/emissions/types/legacy_params_test.go delete mode 100644 x/emissions/types/types.go diff --git a/changelog.md b/changelog.md index a597b8480a..091479dea1 100644 --- a/changelog.md +++ b/changelog.md @@ -25,6 +25,7 @@ * [2749](https://github.com/zeta-chain/node/pull/2749) - fix all lint errors from govet * [2725](https://github.com/zeta-chain/node/pull/2725) - refactor SetCctxAndNonceToCctxAndInboundHashToCctx to receive tsspubkey as an argument * [2802](https://github.com/zeta-chain/node/pull/2802) - set default liquidity cap for new ZRC20s +* [2826](https://github.com/zeta-chain/node/pull/2826) - remove unused code from emissions module and add new parameter for fixed block reward amount ### Tests diff --git a/docs/cli/zetacored/cli.md b/docs/cli/zetacored/cli.md index 6e8555c166..99fad7198c 100644 --- a/docs/cli/zetacored/cli.md +++ b/docs/cli/zetacored/cli.md @@ -3345,45 +3345,10 @@ zetacored query emissions [flags] ### SEE ALSO * [zetacored query](#zetacored-query) - Querying subcommands -* [zetacored query emissions get-emmisons-factors](#zetacored-query-emissions-get-emmisons-factors) - Query GetEmmisonsFactors * [zetacored query emissions list-pool-addresses](#zetacored-query-emissions-list-pool-addresses) - Query list-pool-addresses * [zetacored query emissions params](#zetacored-query-emissions-params) - shows the parameters of the module * [zetacored query emissions show-available-emissions](#zetacored-query-emissions-show-available-emissions) - Query show-available-emissions -## zetacored query emissions get-emmisons-factors - -Query GetEmmisonsFactors - -``` -zetacored query emissions get-emmisons-factors [flags] -``` - -### Options - -``` - --grpc-addr string the gRPC endpoint to use for this chain - --grpc-insecure allow gRPC over insecure channels, if not TLS the server must use TLS - --height int Use a specific height to query state at (this can error if the node is pruning state) - -h, --help help for get-emmisons-factors - --node string [host]:[port] to Tendermint RPC interface for this chain - -o, --output string Output format (text|json) -``` - -### Options inherited from parent commands - -``` - --chain-id string The network chain ID - --home string directory for config and data - --log_format string The logging format (json|plain) - --log_level string The logging level (trace|debug|info|warn|error|fatal|panic) - --log_no_color Disable colored logs - --trace print out full stack trace on errors -``` - -### SEE ALSO - -* [zetacored query emissions](#zetacored-query-emissions) - Querying commands for the emissions module - ## zetacored query emissions list-pool-addresses Query list-pool-addresses diff --git a/docs/openapi/openapi.swagger.yaml b/docs/openapi/openapi.swagger.yaml index fbbcfe6b18..819122175f 100644 --- a/docs/openapi/openapi.swagger.yaml +++ b/docs/openapi/openapi.swagger.yaml @@ -29498,21 +29498,6 @@ paths: $ref: '#/definitions/googlerpcStatus' tags: - Query - /zeta-chain/emissions/get_emissions_factors: - get: - summary: Queries a list of GetEmmisonsFactors items. - operationId: Query_GetEmissionsFactors - responses: - "200": - description: A successful response. - schema: - $ref: '#/definitions/emissionsQueryGetEmissionsFactorsResponse' - default: - description: An unexpected error response. - schema: - $ref: '#/definitions/googlerpcStatus' - tags: - - Query /zeta-chain/emissions/list_addresses: get: summary: Queries a list of ListBalances items. @@ -57609,15 +57594,6 @@ definitions: type: object emissionsMsgWithdrawEmissionResponse: type: object - emissionsQueryGetEmissionsFactorsResponse: - type: object - properties: - reservesFactor: - type: string - bondFactor: - type: string - durationFactor: - type: string emissionsQueryListPoolAddressesResponse: type: object properties: @@ -58468,28 +58444,28 @@ definitions: 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 ballot_maturity_blocks: type: string format: int64 - description: Params defines the parameters for the module. + block_reward_amount: + type: string + title: |- + Params defines the parameters for the module. + Sample values: + ValidatorEmissionPercentage: "00.50", + ObserverEmissionPercentage: "00.25", + TssSignerEmissionPercentage: "00.25", + ObserverSlashAmount: 100000000000000000, + BallotMaturityBlocks: 100, + BlockRewardAmount: 9620949074074074074.074070733466756687, ethermint.evm.v1.ChainConfig: type: object properties: diff --git a/docs/releases/v20_breaking_changes.md b/docs/releases/v20_breaking_changes.md new file mode 100644 index 0000000000..1519ccf8a6 --- /dev/null +++ b/docs/releases/v20_breaking_changes.md @@ -0,0 +1,9 @@ + +# V20 Breaking Changes + +### Emissions factors deprecated + +* `EmissionsFactors` have been deprecated and removed from the `emissions` module. + - This results in the removal of the query `/zeta-chain/emissions/get_emissions_factors`. + - The fixed block reward amount can now be queried via `/zeta-chain/emissions/params`. This is constant for every block and does not depend on any factors. + diff --git a/proto/zetachain/zetacore/emissions/params.proto b/proto/zetachain/zetacore/emissions/params.proto index 53aef8d9e0..0260604766 100644 --- a/proto/zetachain/zetacore/emissions/params.proto +++ b/proto/zetachain/zetacore/emissions/params.proto @@ -6,7 +6,35 @@ import "gogoproto/gogo.proto"; option go_package = "github.com/zeta-chain/node/x/emissions/types"; // Params defines the parameters for the module. +// Sample values: +// ValidatorEmissionPercentage: "00.50", +// ObserverEmissionPercentage: "00.25", +// TssSignerEmissionPercentage: "00.25", +// ObserverSlashAmount: 100000000000000000, +// BallotMaturityBlocks: 100, +// BlockRewardAmount: 9620949074074074074.074070733466756687, message Params { + option (gogoproto.goproto_stringer) = false; + string validator_emission_percentage = 5; + string observer_emission_percentage = 6; + string tss_signer_emission_percentage = 7; + string observer_slash_amount = 9 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false + ]; + int64 ballot_maturity_blocks = 10; + string block_reward_amount = 11 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; + + // not used. do not edit. + reserved 1 to 4; + reserved 8; +} + +// Deprecated (v20): Do not use. Use Params Instead +message LegacyParams { option (gogoproto.goproto_stringer) = false; string max_bond_factor = 1; string min_bond_factor = 2; diff --git a/proto/zetachain/zetacore/emissions/query.proto b/proto/zetachain/zetacore/emissions/query.proto index 4fc78af850..f2a3e4a5a6 100644 --- a/proto/zetachain/zetacore/emissions/query.proto +++ b/proto/zetachain/zetacore/emissions/query.proto @@ -20,13 +20,6 @@ service Query { option (google.api.http).get = "/zeta-chain/emissions/list_addresses"; } - // Queries a list of GetEmmisonsFactors items. - rpc GetEmissionsFactors(QueryGetEmissionsFactorsRequest) - returns (QueryGetEmissionsFactorsResponse) { - option (google.api.http).get = - "/zeta-chain/emissions/get_emissions_factors"; - } - // Queries a list of ShowAvailableEmissions items. rpc ShowAvailableEmissions(QueryShowAvailableEmissionsRequest) returns (QueryShowAvailableEmissionsResponse) { @@ -54,14 +47,6 @@ message QueryListPoolAddressesResponse { string emission_module_address = 3; } -message QueryGetEmissionsFactorsRequest {} - -message QueryGetEmissionsFactorsResponse { - string reservesFactor = 1; - string bondFactor = 2; - string durationFactor = 3; -} - message QueryShowAvailableEmissionsRequest { string address = 1; } message QueryShowAvailableEmissionsResponse { string amount = 1; } diff --git a/testutil/sample/genesis.go b/testutil/sample/genesis.go new file mode 100644 index 0000000000..7d5baa6573 --- /dev/null +++ b/testutil/sample/genesis.go @@ -0,0 +1,18 @@ +package sample + +import ( + _ "embed" + "testing" + + "github.com/cometbft/cometbft/types" + "github.com/stretchr/testify/require" +) + +//go:embed genesis.json +var genesisJSON []byte + +func GenDoc(t *testing.T) *types.GenesisDoc { + genDoc, err := types.GenesisDocFromJSON(genesisJSON) + require.NoError(t, err) + return genDoc +} diff --git a/testutil/sample/genesis.json b/testutil/sample/genesis.json new file mode 100644 index 0000000000..d44c701769 --- /dev/null +++ b/testutil/sample/genesis.json @@ -0,0 +1,561 @@ +{ + "genesis_time": "2024-04-12T05:07:56.004517Z", + "chain_id": "localnet_101-1", + "initial_height": "1", + "consensus_params": { + "block": { + "max_bytes": "22020096", + "max_gas": "10000000", + "time_iota_ms": "1000" + }, + "evidence": { + "max_age_num_blocks": "100000", + "max_age_duration": "172800000000000", + "max_bytes": "1048576" + }, + "validator": { + "pub_key_types": [ + "ed25519" + ] + }, + "version": {} + }, + "app_hash": "", + "app_state": { + "auth": { + "params": { + "max_memo_characters": "256", + "tx_sig_limit": "7", + "tx_size_cost_per_byte": "10", + "sig_verify_cost_ed25519": "590", + "sig_verify_cost_secp256k1": "1000" + }, + "accounts": [ + { + "@type": "/ethermint.types.v1.EthAccount", + "base_account": { + "address": "zeta13c7p3xrhd6q2rx3h235jpt8pjdwvacyw6twpax", + "pub_key": null, + "account_number": "0", + "sequence": "0" + }, + "code_hash": "0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470" + }, + { + "@type": "/ethermint.types.v1.EthAccount", + "base_account": { + "address": "zeta10up34mvwjhjd9xkq56fwsf0k75vtg287uav69n", + "pub_key": null, + "account_number": "0", + "sequence": "0" + }, + "code_hash": "0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470" + }, + { + "@type": "/ethermint.types.v1.EthAccount", + "base_account": { + "address": "zeta1f203dypqg5jh9hqfx0gfkmmnkdfuat3jr45ep2", + "pub_key": null, + "account_number": "0", + "sequence": "0" + }, + "code_hash": "0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470" + }, + { + "@type": "/ethermint.types.v1.EthAccount", + "base_account": { + "address": "zeta1unzpyll3tmutf0r8sqpxpnj46vtdr59mw8qepx", + "pub_key": null, + "account_number": "0", + "sequence": "0" + }, + "code_hash": "0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470" + } + ] + }, + "authority": { + "policies": { + "items": [ + { + "policy_type": "groupEmergency", + "address": "zeta1afk9zr2hn2jsac63h4hm60vl9z3e5u69gndzf7c99cqge3vzwjzsxn0x73" + }, + { + "policy_type": "groupOperational", + "address": "zeta1afk9zr2hn2jsac63h4hm60vl9z3e5u69gndzf7c99cqge3vzwjzsxn0x73" + }, + { + "policy_type": "groupAdmin", + "address": "zeta1afk9zr2hn2jsac63h4hm60vl9z3e5u69gndzf7c99cqge3vzwjzsxn0x73" + } + ] + } + }, + "authz": { + "authorization": [ + { + "granter": "zeta13c7p3xrhd6q2rx3h235jpt8pjdwvacyw6twpax", + "grantee": "zeta10up34mvwjhjd9xkq56fwsf0k75vtg287uav69n", + "authorization": { + "@type": "/cosmos.authz.v1beta1.GenericAuthorization", + "msg": "/zetachain.zetacore.crosschain.MsgGasPriceVoter" + }, + "expiration": null + }, + { + "granter": "zeta13c7p3xrhd6q2rx3h235jpt8pjdwvacyw6twpax", + "grantee": "zeta10up34mvwjhjd9xkq56fwsf0k75vtg287uav69n", + "authorization": { + "@type": "/cosmos.authz.v1beta1.GenericAuthorization", + "msg": "/zetachain.zetacore.crosschain.MsgVoteInbound" + }, + "expiration": null + }, + { + "granter": "zeta13c7p3xrhd6q2rx3h235jpt8pjdwvacyw6twpax", + "grantee": "zeta10up34mvwjhjd9xkq56fwsf0k75vtg287uav69n", + "authorization": { + "@type": "/cosmos.authz.v1beta1.GenericAuthorization", + "msg": "/zetachain.zetacore.crosschain.MsgVoteOutbound" + }, + "expiration": null + }, + { + "granter": "zeta13c7p3xrhd6q2rx3h235jpt8pjdwvacyw6twpax", + "grantee": "zeta10up34mvwjhjd9xkq56fwsf0k75vtg287uav69n", + "authorization": { + "@type": "/cosmos.authz.v1beta1.GenericAuthorization", + "msg": "/zetachain.zetacore.crosschain.MsgCreateTSSVoter" + }, + "expiration": null + }, + { + "granter": "zeta13c7p3xrhd6q2rx3h235jpt8pjdwvacyw6twpax", + "grantee": "zeta10up34mvwjhjd9xkq56fwsf0k75vtg287uav69n", + "authorization": { + "@type": "/cosmos.authz.v1beta1.GenericAuthorization", + "msg": "/zetachain.zetacore.crosschain.MsgAddOutboundTracker" + }, + "expiration": null + }, + { + "granter": "zeta13c7p3xrhd6q2rx3h235jpt8pjdwvacyw6twpax", + "grantee": "zeta10up34mvwjhjd9xkq56fwsf0k75vtg287uav69n", + "authorization": { + "@type": "/cosmos.authz.v1beta1.GenericAuthorization", + "msg": "/zetachain.zetacore.observer.MsgVoteBlame" + }, + "expiration": null + }, + { + "granter": "zeta13c7p3xrhd6q2rx3h235jpt8pjdwvacyw6twpax", + "grantee": "zeta10up34mvwjhjd9xkq56fwsf0k75vtg287uav69n", + "authorization": { + "@type": "/cosmos.authz.v1beta1.GenericAuthorization", + "msg": "/zetachain.zetacore.observer.MsgAddBlockHeader" + }, + "expiration": null + }, + { + "granter": "zeta1f203dypqg5jh9hqfx0gfkmmnkdfuat3jr45ep2", + "grantee": "zeta1unzpyll3tmutf0r8sqpxpnj46vtdr59mw8qepx", + "authorization": { + "@type": "/cosmos.authz.v1beta1.GenericAuthorization", + "msg": "/zetachain.zetacore.crosschain.MsgGasPriceVoter" + }, + "expiration": null + }, + { + "granter": "zeta1f203dypqg5jh9hqfx0gfkmmnkdfuat3jr45ep2", + "grantee": "zeta1unzpyll3tmutf0r8sqpxpnj46vtdr59mw8qepx", + "authorization": { + "@type": "/cosmos.authz.v1beta1.GenericAuthorization", + "msg": "/zetachain.zetacore.crosschain.MsgVoteInbound" + }, + "expiration": null + }, + { + "granter": "zeta1f203dypqg5jh9hqfx0gfkmmnkdfuat3jr45ep2", + "grantee": "zeta1unzpyll3tmutf0r8sqpxpnj46vtdr59mw8qepx", + "authorization": { + "@type": "/cosmos.authz.v1beta1.GenericAuthorization", + "msg": "/zetachain.zetacore.crosschain.MsgVoteOutbound" + }, + "expiration": null + }, + { + "granter": "zeta1f203dypqg5jh9hqfx0gfkmmnkdfuat3jr45ep2", + "grantee": "zeta1unzpyll3tmutf0r8sqpxpnj46vtdr59mw8qepx", + "authorization": { + "@type": "/cosmos.authz.v1beta1.GenericAuthorization", + "msg": "/zetachain.zetacore.crosschain.MsgCreateTSSVoter" + }, + "expiration": null + }, + { + "granter": "zeta1f203dypqg5jh9hqfx0gfkmmnkdfuat3jr45ep2", + "grantee": "zeta1unzpyll3tmutf0r8sqpxpnj46vtdr59mw8qepx", + "authorization": { + "@type": "/cosmos.authz.v1beta1.GenericAuthorization", + "msg": "/zetachain.zetacore.crosschain.MsgAddOutboundTracker" + }, + "expiration": null + }, + { + "granter": "zeta1f203dypqg5jh9hqfx0gfkmmnkdfuat3jr45ep2", + "grantee": "zeta1unzpyll3tmutf0r8sqpxpnj46vtdr59mw8qepx", + "authorization": { + "@type": "/cosmos.authz.v1beta1.GenericAuthorization", + "msg": "/zetachain.zetacore.observer.MsgVoteBlame" + }, + "expiration": null + }, + { + "granter": "zeta1f203dypqg5jh9hqfx0gfkmmnkdfuat3jr45ep2", + "grantee": "zeta1unzpyll3tmutf0r8sqpxpnj46vtdr59mw8qepx", + "authorization": { + "@type": "/cosmos.authz.v1beta1.GenericAuthorization", + "msg": "/zetachain.zetacore.observer.MsgAddBlockHeader" + }, + "expiration": null + } + ] + }, + "bank": { + "params": { + "send_enabled": [], + "default_send_enabled": true + }, + "balances": [ + { + "address": "zeta1f203dypqg5jh9hqfx0gfkmmnkdfuat3jr45ep2", + "coins": [ + { + "denom": "azeta", + "amount": "4200000000000000000000000" + } + ] + }, + { + "address": "zeta10up34mvwjhjd9xkq56fwsf0k75vtg287uav69n", + "coins": [ + { + "denom": "azeta", + "amount": "1000000000000000000000" + } + ] + }, + { + "address": "zeta13c7p3xrhd6q2rx3h235jpt8pjdwvacyw6twpax", + "coins": [ + { + "denom": "azeta", + "amount": "4200000000000000000000000" + } + ] + }, + { + "address": "zeta1unzpyll3tmutf0r8sqpxpnj46vtdr59mw8qepx", + "coins": [ + { + "denom": "azeta", + "amount": "1000000000000000000000" + } + ] + } + ], + "supply": [ + { + "denom": "azeta", + "amount": "8402000000000000000000000" + } + ], + "denom_metadata": [] + }, + "crisis": { + "constant_fee": { + "denom": "azeta", + "amount": "1000" + } + }, + "crosschain": { + "outboundTrackerList": [], + "inboundHashToCctxList": [], + "inbound_tracker_list": [], + "zeta_accounting": { + "aborted_zeta_amount": "0" + } + }, + "distribution": { + "params": { + "community_tax": "0.020000000000000000", + "base_proposer_reward": "0.010000000000000000", + "bonus_proposer_reward": "0.040000000000000000", + "withdraw_addr_enabled": true + }, + "fee_pool": { + "community_pool": [] + }, + "delegator_withdraw_infos": [], + "previous_proposer": "", + "outstanding_rewards": [], + "validator_accumulated_commissions": [], + "validator_historical_rewards": [], + "validator_current_rewards": [], + "delegator_starting_infos": [], + "validator_slash_events": [] + }, + "emissions": { + "params": { + "validator_emission_percentage": "00.50", + "observer_emission_percentage": "00.25", + "tss_signer_emission_percentage": "00.25", + "observer_slash_amount": "100000000000000000", + "ballot_maturity_blocks": "100", + "block_reward_amount": "9620949074074074074.074070733466756687" + }, + "withdrawableEmissions": [] + }, + "evidence": { + "evidence": [] + }, + "evm": { + "accounts": [], + "params": { + "evm_denom": "azeta", + "enable_create": true, + "enable_call": true, + "extra_eips": [], + "chain_config": { + "homestead_block": "0", + "dao_fork_block": "0", + "dao_fork_support": true, + "eip150_block": "0", + "eip150_hash": "0x0000000000000000000000000000000000000000000000000000000000000000", + "eip155_block": "0", + "eip158_block": "0", + "byzantium_block": "0", + "constantinople_block": "0", + "petersburg_block": "0", + "istanbul_block": "0", + "muir_glacier_block": "0", + "berlin_block": "0", + "london_block": "0", + "arrow_glacier_block": "0", + "gray_glacier_block": "0", + "merge_netsplit_block": "0", + "shanghai_block": "0", + "cancun_block": "0" + }, + "allow_unprotected_txs": false + } + }, + "feemarket": { + "params": { + "no_base_fee": false, + "base_fee_change_denominator": 8, + "elasticity_multiplier": 2, + "enable_height": "0", + "base_fee": "1000000000", + "min_gas_price": "0.000000000000000000", + "min_gas_multiplier": "0.500000000000000000" + }, + "block_gas": "0" + }, + "fungible": { + "params": {}, + "foreignCoinsList": [], + "systemContract": null + }, + "genutil": { + "gen_txs": [ + { + "body": { + "messages": [ + { + "@type": "/cosmos.staking.v1beta1.MsgCreateValidator", + "description": { + "moniker": "Zetanode-Localnet", + "identity": "", + "website": "", + "security_contact": "", + "details": "" + }, + "commission": { + "rate": "0.100000000000000000", + "max_rate": "0.200000000000000000", + "max_change_rate": "0.010000000000000000" + }, + "min_self_delegation": "1", + "delegator_address": "zeta13c7p3xrhd6q2rx3h235jpt8pjdwvacyw6twpax", + "validator_address": "zetavaloper13c7p3xrhd6q2rx3h235jpt8pjdwvacyw7tkass", + "pubkey": { + "@type": "/cosmos.crypto.ed25519.PubKey", + "key": "sBSs5r1vQn1idTp4uRTbdUK0jjmEscI3pn88LUXI4CQ=" + }, + "value": { + "denom": "azeta", + "amount": "1000000000000000000000" + } + } + ], + "memo": "1db4f4185e68c1c17d508294de2592616dad37a5@192.168.2.12:26656", + "timeout_height": "0", + "extension_options": [], + "non_critical_extension_options": [] + }, + "auth_info": { + "signer_infos": [ + { + "public_key": { + "@type": "/cosmos.crypto.secp256k1.PubKey", + "key": "A05F6QuFVpb/5KrIPvlHr209ZsD22gW0omhLSXWAtQrh" + }, + "mode_info": { + "single": { + "mode": "SIGN_MODE_DIRECT" + } + }, + "sequence": "0" + } + ], + "fee": { + "amount": [], + "gas_limit": "200000", + "payer": "", + "granter": "" + }, + "tip": null + }, + "signatures": [ + "y5YROwZmV0jcgv5BgRJCDE+Kq5OsX8+88or1ogekPLBw3ecPt8GsCeEbPQ24JONLzNwQEIUDNYTeSQnXnCfzyg==" + ] + } + ] + }, + "gov": { + "starting_proposal_id": "1", + "deposits": [], + "votes": [], + "proposals": [], + "deposit_params": { + "min_deposit": [ + { + "denom": "azeta", + "amount": "10000000" + } + ], + "max_deposit_period": "172800s" + }, + "voting_params": { + "voting_period": "10s" + }, + "tally_params": { + "quorum": "0.334000000000000000", + "threshold": "0.500000000000000000", + "veto_threshold": "0.334000000000000000" + } + }, + "group": { + "group_seq": "0", + "groups": [], + "group_members": [], + "group_policy_seq": "0", + "group_policies": [], + "proposal_seq": "0", + "proposals": [], + "votes": [] + }, + "mint": { + "params": { + "mint_denom": "azeta" + } + }, + "observer": { + "observers": { + "observer_list": [ + "zeta13c7p3xrhd6q2rx3h235jpt8pjdwvacyw6twpax", + "zeta1f203dypqg5jh9hqfx0gfkmmnkdfuat3jr45ep2" + ] + }, + "nodeAccountList": [ + { + "operator": "zeta13c7p3xrhd6q2rx3h235jpt8pjdwvacyw6twpax", + "granteeAddress": "zeta10up34mvwjhjd9xkq56fwsf0k75vtg287uav69n", + "granteePubkey": { + "secp256k1": "zetapub1addwnpepqtlu7fykuh875xjckz4mn4x0mzc25rrqk5qne7mrwxqmatgllv3nx6lrkdp" + }, + "nodeStatus": 4 + }, + { + "operator": "zeta1f203dypqg5jh9hqfx0gfkmmnkdfuat3jr45ep2", + "granteeAddress": "zeta1unzpyll3tmutf0r8sqpxpnj46vtdr59mw8qepx", + "granteePubkey": { + "secp256k1": "zetapub1addwnpepqwy5pmg39regpq0gkggxehmfm8hwmxxw94sch7qzh4smava0szs07kk5045" + }, + "nodeStatus": 4 + } + ], + "crosschain_flags": { + "isInboundEnabled": true, + "isOutboundEnabled": true + }, + "keygen": { + "status": 1, + "granteePubkeys": [ + "zetapub1addwnpepqtlu7fykuh875xjckz4mn4x0mzc25rrqk5qne7mrwxqmatgllv3nx6lrkdp", + "zetapub1addwnpepqwy5pmg39regpq0gkggxehmfm8hwmxxw94sch7qzh4smava0szs07kk5045" + ] + }, + "chain_params_list": {}, + "tss": { + "tss_pubkey": "zetapub1addwnpepq28c57cvcs0a2htsem5zxr6qnlvq9mzhmm76z3jncsnzz32rclangr2g35p", + "tss_participant_list": [ + "zetapub1addwnpepqtlu7fykuh875xjckz4mn4x0mzc25rrqk5qne7mrwxqmatgllv3nx6lrkdp", + "zetapub1addwnpepqwy5pmg39regpq0gkggxehmfm8hwmxxw94sch7qzh4smava0szs07kk5045" + ], + "operator_address_list": [ + "zeta13c7p3xrhd6q2rx3h235jpt8pjdwvacyw6twpax", + "zeta1f203dypqg5jh9hqfx0gfkmmnkdfuat3jr45ep2" + ] + }, + "tss_history": [], + "tss_fund_migrators": [], + "blame_list": [], + "pending_nonces": [], + "chain_nonces": [], + "nonce_to_cctx": [] + }, + "params": null, + "slashing": { + "params": { + "signed_blocks_window": "100", + "min_signed_per_window": "0.500000000000000000", + "downtime_jail_duration": "600s", + "slash_fraction_double_sign": "0.050000000000000000", + "slash_fraction_downtime": "0.010000000000000000" + }, + "signing_infos": [], + "missed_blocks": [] + }, + "staking": { + "params": { + "unbonding_time": "1814400s", + "max_validators": 100, + "max_entries": 7, + "historical_entries": 10000, + "bond_denom": "azeta", + "min_commission_rate": "0.000000000000000000" + }, + "last_total_power": "0", + "last_validator_powers": [], + "validators": [], + "delegations": [], + "unbonding_delegations": [], + "redelegations": [], + "exported": false + }, + "upgrade": {}, + "vesting": {} + } +} \ No newline at end of file diff --git a/testutil/sample/sample.go b/testutil/sample/sample.go index e07b118ba8..365d1c7e85 100644 --- a/testutil/sample/sample.go +++ b/testutil/sample/sample.go @@ -9,7 +9,6 @@ import ( "testing" sdkmath "cosmossdk.io/math" - "github.com/cometbft/cometbft/types" "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" sdk "github.com/cosmos/cosmos-sdk/types" genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" @@ -109,15 +108,6 @@ func AppState(t *testing.T) map[string]json.RawMessage { return appState } -func GenDoc(t *testing.T) *types.GenesisDoc { - jsonBlob := []byte( - "{\n \"genesis_time\": \"2024-04-12T05:07:56.004517Z\",\n \"chain_id\": \"localnet_101-1\",\n \"initial_height\": \"1\",\n \"consensus_params\": {\n \"block\": {\n \"max_bytes\": \"22020096\",\n \"max_gas\": \"10000000\",\n \"time_iota_ms\": \"1000\"\n },\n \"evidence\": {\n \"max_age_num_blocks\": \"100000\",\n \"max_age_duration\": \"172800000000000\",\n \"max_bytes\": \"1048576\"\n },\n \"validator\": {\n \"pub_key_types\": [\n \"ed25519\"\n ]\n },\n \"version\": {}\n },\n \"app_hash\": \"\",\n \"app_state\": {\n \"auth\": {\n \"params\": {\n \"max_memo_characters\": \"256\",\n \"tx_sig_limit\": \"7\",\n \"tx_size_cost_per_byte\": \"10\",\n \"sig_verify_cost_ed25519\": \"590\",\n \"sig_verify_cost_secp256k1\": \"1000\"\n },\n \"accounts\": [\n {\n \"@type\": \"/ethermint.types.v1.EthAccount\",\n \"base_account\": {\n \"address\": \"zeta13c7p3xrhd6q2rx3h235jpt8pjdwvacyw6twpax\",\n \"pub_key\": null,\n \"account_number\": \"0\",\n \"sequence\": \"0\"\n },\n \"code_hash\": \"0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470\"\n },\n {\n \"@type\": \"/ethermint.types.v1.EthAccount\",\n \"base_account\": {\n \"address\": \"zeta10up34mvwjhjd9xkq56fwsf0k75vtg287uav69n\",\n \"pub_key\": null,\n \"account_number\": \"0\",\n \"sequence\": \"0\"\n },\n \"code_hash\": \"0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470\"\n },\n {\n \"@type\": \"/ethermint.types.v1.EthAccount\",\n \"base_account\": {\n \"address\": \"zeta1f203dypqg5jh9hqfx0gfkmmnkdfuat3jr45ep2\",\n \"pub_key\": null,\n \"account_number\": \"0\",\n \"sequence\": \"0\"\n },\n \"code_hash\": \"0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470\"\n },\n {\n \"@type\": \"/ethermint.types.v1.EthAccount\",\n \"base_account\": {\n \"address\": \"zeta1unzpyll3tmutf0r8sqpxpnj46vtdr59mw8qepx\",\n \"pub_key\": null,\n \"account_number\": \"0\",\n \"sequence\": \"0\"\n },\n \"code_hash\": \"0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470\"\n }\n ]\n },\n \"authority\": {\n \"policies\": {\n \"items\": [\n {\n \"policy_type\": \"groupEmergency\",\n \"address\": \"zeta1afk9zr2hn2jsac63h4hm60vl9z3e5u69gndzf7c99cqge3vzwjzsxn0x73\"\n },\n {\n \"policy_type\": \"groupOperational\",\n \"address\": \"zeta1afk9zr2hn2jsac63h4hm60vl9z3e5u69gndzf7c99cqge3vzwjzsxn0x73\"\n },\n {\n \"policy_type\": \"groupAdmin\",\n \"address\": \"zeta1afk9zr2hn2jsac63h4hm60vl9z3e5u69gndzf7c99cqge3vzwjzsxn0x73\"\n }\n ]\n }\n },\n \"authz\": {\n \"authorization\": [\n {\n \"granter\": \"zeta13c7p3xrhd6q2rx3h235jpt8pjdwvacyw6twpax\",\n \"grantee\": \"zeta10up34mvwjhjd9xkq56fwsf0k75vtg287uav69n\",\n \"authorization\": {\n \"@type\": \"/cosmos.authz.v1beta1.GenericAuthorization\",\n \"msg\": \"/zetachain.zetacore.crosschain.MsgGasPriceVoter\"\n },\n \"expiration\": null\n },\n {\n \"granter\": \"zeta13c7p3xrhd6q2rx3h235jpt8pjdwvacyw6twpax\",\n \"grantee\": \"zeta10up34mvwjhjd9xkq56fwsf0k75vtg287uav69n\",\n \"authorization\": {\n \"@type\": \"/cosmos.authz.v1beta1.GenericAuthorization\",\n \"msg\": \"/zetachain.zetacore.crosschain.MsgVoteInbound\"\n },\n \"expiration\": null\n },\n {\n \"granter\": \"zeta13c7p3xrhd6q2rx3h235jpt8pjdwvacyw6twpax\",\n \"grantee\": \"zeta10up34mvwjhjd9xkq56fwsf0k75vtg287uav69n\",\n \"authorization\": {\n \"@type\": \"/cosmos.authz.v1beta1.GenericAuthorization\",\n \"msg\": \"/zetachain.zetacore.crosschain.MsgVoteOutbound\"\n },\n \"expiration\": null\n },\n {\n \"granter\": \"zeta13c7p3xrhd6q2rx3h235jpt8pjdwvacyw6twpax\",\n \"grantee\": \"zeta10up34mvwjhjd9xkq56fwsf0k75vtg287uav69n\",\n \"authorization\": {\n \"@type\": \"/cosmos.authz.v1beta1.GenericAuthorization\",\n \"msg\": \"/zetachain.zetacore.crosschain.MsgCreateTSSVoter\"\n },\n \"expiration\": null\n },\n {\n \"granter\": \"zeta13c7p3xrhd6q2rx3h235jpt8pjdwvacyw6twpax\",\n \"grantee\": \"zeta10up34mvwjhjd9xkq56fwsf0k75vtg287uav69n\",\n \"authorization\": {\n \"@type\": \"/cosmos.authz.v1beta1.GenericAuthorization\",\n \"msg\": \"/zetachain.zetacore.crosschain.MsgAddOutboundTracker\"\n },\n \"expiration\": null\n },\n {\n \"granter\": \"zeta13c7p3xrhd6q2rx3h235jpt8pjdwvacyw6twpax\",\n \"grantee\": \"zeta10up34mvwjhjd9xkq56fwsf0k75vtg287uav69n\",\n \"authorization\": {\n \"@type\": \"/cosmos.authz.v1beta1.GenericAuthorization\",\n \"msg\": \"/zetachain.zetacore.observer.MsgVoteBlame\"\n },\n \"expiration\": null\n },\n {\n \"granter\": \"zeta13c7p3xrhd6q2rx3h235jpt8pjdwvacyw6twpax\",\n \"grantee\": \"zeta10up34mvwjhjd9xkq56fwsf0k75vtg287uav69n\",\n \"authorization\": {\n \"@type\": \"/cosmos.authz.v1beta1.GenericAuthorization\",\n \"msg\": \"/zetachain.zetacore.observer.MsgAddBlockHeader\"\n },\n \"expiration\": null\n },\n {\n \"granter\": \"zeta1f203dypqg5jh9hqfx0gfkmmnkdfuat3jr45ep2\",\n \"grantee\": \"zeta1unzpyll3tmutf0r8sqpxpnj46vtdr59mw8qepx\",\n \"authorization\": {\n \"@type\": \"/cosmos.authz.v1beta1.GenericAuthorization\",\n \"msg\": \"/zetachain.zetacore.crosschain.MsgGasPriceVoter\"\n },\n \"expiration\": null\n },\n {\n \"granter\": \"zeta1f203dypqg5jh9hqfx0gfkmmnkdfuat3jr45ep2\",\n \"grantee\": \"zeta1unzpyll3tmutf0r8sqpxpnj46vtdr59mw8qepx\",\n \"authorization\": {\n \"@type\": \"/cosmos.authz.v1beta1.GenericAuthorization\",\n \"msg\": \"/zetachain.zetacore.crosschain.MsgVoteInbound\"\n },\n \"expiration\": null\n },\n {\n \"granter\": \"zeta1f203dypqg5jh9hqfx0gfkmmnkdfuat3jr45ep2\",\n \"grantee\": \"zeta1unzpyll3tmutf0r8sqpxpnj46vtdr59mw8qepx\",\n \"authorization\": {\n \"@type\": \"/cosmos.authz.v1beta1.GenericAuthorization\",\n \"msg\": \"/zetachain.zetacore.crosschain.MsgVoteOutbound\"\n },\n \"expiration\": null\n },\n {\n \"granter\": \"zeta1f203dypqg5jh9hqfx0gfkmmnkdfuat3jr45ep2\",\n \"grantee\": \"zeta1unzpyll3tmutf0r8sqpxpnj46vtdr59mw8qepx\",\n \"authorization\": {\n \"@type\": \"/cosmos.authz.v1beta1.GenericAuthorization\",\n \"msg\": \"/zetachain.zetacore.crosschain.MsgCreateTSSVoter\"\n },\n \"expiration\": null\n },\n {\n \"granter\": \"zeta1f203dypqg5jh9hqfx0gfkmmnkdfuat3jr45ep2\",\n \"grantee\": \"zeta1unzpyll3tmutf0r8sqpxpnj46vtdr59mw8qepx\",\n \"authorization\": {\n \"@type\": \"/cosmos.authz.v1beta1.GenericAuthorization\",\n \"msg\": \"/zetachain.zetacore.crosschain.MsgAddOutboundTracker\"\n },\n \"expiration\": null\n },\n {\n \"granter\": \"zeta1f203dypqg5jh9hqfx0gfkmmnkdfuat3jr45ep2\",\n \"grantee\": \"zeta1unzpyll3tmutf0r8sqpxpnj46vtdr59mw8qepx\",\n \"authorization\": {\n \"@type\": \"/cosmos.authz.v1beta1.GenericAuthorization\",\n \"msg\": \"/zetachain.zetacore.observer.MsgVoteBlame\"\n },\n \"expiration\": null\n },\n {\n \"granter\": \"zeta1f203dypqg5jh9hqfx0gfkmmnkdfuat3jr45ep2\",\n \"grantee\": \"zeta1unzpyll3tmutf0r8sqpxpnj46vtdr59mw8qepx\",\n \"authorization\": {\n \"@type\": \"/cosmos.authz.v1beta1.GenericAuthorization\",\n \"msg\": \"/zetachain.zetacore.observer.MsgAddBlockHeader\"\n },\n \"expiration\": null\n }\n ]\n },\n \"bank\": {\n \"params\": {\n \"send_enabled\": [],\n \"default_send_enabled\": true\n },\n \"balances\": [\n {\n \"address\": \"zeta1f203dypqg5jh9hqfx0gfkmmnkdfuat3jr45ep2\",\n \"coins\": [\n {\n \"denom\": \"azeta\",\n \"amount\": \"4200000000000000000000000\"\n }\n ]\n },\n {\n \"address\": \"zeta10up34mvwjhjd9xkq56fwsf0k75vtg287uav69n\",\n \"coins\": [\n {\n \"denom\": \"azeta\",\n \"amount\": \"1000000000000000000000\"\n }\n ]\n },\n {\n \"address\": \"zeta13c7p3xrhd6q2rx3h235jpt8pjdwvacyw6twpax\",\n \"coins\": [\n {\n \"denom\": \"azeta\",\n \"amount\": \"4200000000000000000000000\"\n }\n ]\n },\n {\n \"address\": \"zeta1unzpyll3tmutf0r8sqpxpnj46vtdr59mw8qepx\",\n \"coins\": [\n {\n \"denom\": \"azeta\",\n \"amount\": \"1000000000000000000000\"\n }\n ]\n }\n ],\n \"supply\": [\n {\n \"denom\": \"azeta\",\n \"amount\": \"8402000000000000000000000\"\n }\n ],\n \"denom_metadata\": []\n },\n \"crisis\": {\n \"constant_fee\": {\n \"denom\": \"azeta\",\n \"amount\": \"1000\"\n }\n },\n \"crosschain\": {\n \"outboundTrackerList\": [],\n \"inboundHashToCctxList\": [],\n \"inbound_tracker_list\": [],\n \"zeta_accounting\": {\n \"aborted_zeta_amount\": \"0\"\n }\n },\n \"distribution\": {\n \"params\": {\n \"community_tax\": \"0.020000000000000000\",\n \"base_proposer_reward\": \"0.010000000000000000\",\n \"bonus_proposer_reward\": \"0.040000000000000000\",\n \"withdraw_addr_enabled\": true\n },\n \"fee_pool\": {\n \"community_pool\": []\n },\n \"delegator_withdraw_infos\": [],\n \"previous_proposer\": \"\",\n \"outstanding_rewards\": [],\n \"validator_accumulated_commissions\": [],\n \"validator_historical_rewards\": [],\n \"validator_current_rewards\": [],\n \"delegator_starting_infos\": [],\n \"validator_slash_events\": []\n },\n \"emissions\": {\n \"params\": {\n \"max_bond_factor\": \"1.25\",\n \"min_bond_factor\": \"0.75\",\n \"avg_block_time\": \"6.00\",\n \"target_bond_ratio\": \"00.67\",\n \"validator_emission_percentage\": \"00.50\",\n \"observer_emission_percentage\": \"00.25\",\n \"tss_signer_emission_percentage\": \"00.25\",\n \"duration_factor_constant\": \"0.001877876953694702\",\n \"observer_slash_amount\": \"0\"\n },\n \"withdrawableEmissions\": []\n },\n \"evidence\": {\n \"evidence\": []\n },\n \"evm\": {\n \"accounts\": [],\n \"params\": {\n \"evm_denom\": \"azeta\",\n \"enable_create\": true,\n \"enable_call\": true,\n \"extra_eips\": [],\n \"chain_config\": {\n \"homestead_block\": \"0\",\n \"dao_fork_block\": \"0\",\n \"dao_fork_support\": true,\n \"eip150_block\": \"0\",\n \"eip150_hash\": \"0x0000000000000000000000000000000000000000000000000000000000000000\",\n \"eip155_block\": \"0\",\n \"eip158_block\": \"0\",\n \"byzantium_block\": \"0\",\n \"constantinople_block\": \"0\",\n \"petersburg_block\": \"0\",\n \"istanbul_block\": \"0\",\n \"muir_glacier_block\": \"0\",\n \"berlin_block\": \"0\",\n \"london_block\": \"0\",\n \"arrow_glacier_block\": \"0\",\n \"gray_glacier_block\": \"0\",\n \"merge_netsplit_block\": \"0\",\n \"shanghai_block\": \"0\",\n \"cancun_block\": \"0\"\n },\n \"allow_unprotected_txs\": false\n }\n },\n \"feemarket\": {\n \"params\": {\n \"no_base_fee\": false,\n \"base_fee_change_denominator\": 8,\n \"elasticity_multiplier\": 2,\n \"enable_height\": \"0\",\n \"base_fee\": \"1000000000\",\n \"min_gas_price\": \"0.000000000000000000\",\n \"min_gas_multiplier\": \"0.500000000000000000\"\n },\n \"block_gas\": \"0\"\n },\n \"fungible\": {\n \"params\": {},\n \"foreignCoinsList\": [],\n \"systemContract\": null\n },\n \"genutil\": {\n \"gen_txs\": [\n {\n \"body\": {\n \"messages\": [\n {\n \"@type\": \"/cosmos.staking.v1beta1.MsgCreateValidator\",\n \"description\": {\n \"moniker\": \"Zetanode-Localnet\",\n \"identity\": \"\",\n \"website\": \"\",\n \"security_contact\": \"\",\n \"details\": \"\"\n },\n \"commission\": {\n \"rate\": \"0.100000000000000000\",\n \"max_rate\": \"0.200000000000000000\",\n \"max_change_rate\": \"0.010000000000000000\"\n },\n \"min_self_delegation\": \"1\",\n \"delegator_address\": \"zeta13c7p3xrhd6q2rx3h235jpt8pjdwvacyw6twpax\",\n \"validator_address\": \"zetavaloper13c7p3xrhd6q2rx3h235jpt8pjdwvacyw7tkass\",\n \"pubkey\": {\n \"@type\": \"/cosmos.crypto.ed25519.PubKey\",\n \"key\": \"sBSs5r1vQn1idTp4uRTbdUK0jjmEscI3pn88LUXI4CQ=\"\n },\n \"value\": {\n \"denom\": \"azeta\",\n \"amount\": \"1000000000000000000000\"\n }\n }\n ],\n \"memo\": \"1db4f4185e68c1c17d508294de2592616dad37a5@192.168.2.12:26656\",\n \"timeout_height\": \"0\",\n \"extension_options\": [],\n \"non_critical_extension_options\": []\n },\n \"auth_info\": {\n \"signer_infos\": [\n {\n \"public_key\": {\n \"@type\": \"/cosmos.crypto.secp256k1.PubKey\",\n \"key\": \"A05F6QuFVpb/5KrIPvlHr209ZsD22gW0omhLSXWAtQrh\"\n },\n \"mode_info\": {\n \"single\": {\n \"mode\": \"SIGN_MODE_DIRECT\"\n }\n },\n \"sequence\": \"0\"\n }\n ],\n \"fee\": {\n \"amount\": [],\n \"gas_limit\": \"200000\",\n \"payer\": \"\",\n \"granter\": \"\"\n },\n \"tip\": null\n },\n \"signatures\": [\n \"y5YROwZmV0jcgv5BgRJCDE+Kq5OsX8+88or1ogekPLBw3ecPt8GsCeEbPQ24JONLzNwQEIUDNYTeSQnXnCfzyg==\"\n ]\n }\n ]\n },\n \"gov\": {\n \"starting_proposal_id\": \"1\",\n \"deposits\": [],\n \"votes\": [],\n \"proposals\": [],\n \"deposit_params\": {\n \"min_deposit\": [\n {\n \"denom\": \"azeta\",\n \"amount\": \"10000000\"\n }\n ],\n \"max_deposit_period\": \"172800s\"\n },\n \"voting_params\": {\n \"voting_period\": \"10s\"\n },\n \"tally_params\": {\n \"quorum\": \"0.334000000000000000\",\n \"threshold\": \"0.500000000000000000\",\n \"veto_threshold\": \"0.334000000000000000\"\n }\n },\n \"group\": {\n \"group_seq\": \"0\",\n \"groups\": [],\n \"group_members\": [],\n \"group_policy_seq\": \"0\",\n \"group_policies\": [],\n \"proposal_seq\": \"0\",\n \"proposals\": [],\n \"votes\": []\n },\n \"mint\": {\n \"params\": {\n \"mint_denom\": \"azeta\"\n }\n },\n \"observer\": {\n \"observers\": {\n \"observer_list\": [\n \"zeta13c7p3xrhd6q2rx3h235jpt8pjdwvacyw6twpax\",\n \"zeta1f203dypqg5jh9hqfx0gfkmmnkdfuat3jr45ep2\"\n ]\n },\n \"nodeAccountList\": [\n {\n \"operator\": \"zeta13c7p3xrhd6q2rx3h235jpt8pjdwvacyw6twpax\",\n \"granteeAddress\": \"zeta10up34mvwjhjd9xkq56fwsf0k75vtg287uav69n\",\n \"granteePubkey\": {\n \"secp256k1\": \"zetapub1addwnpepqtlu7fykuh875xjckz4mn4x0mzc25rrqk5qne7mrwxqmatgllv3nx6lrkdp\"\n },\n \"nodeStatus\": 4\n },\n {\n \"operator\": \"zeta1f203dypqg5jh9hqfx0gfkmmnkdfuat3jr45ep2\",\n \"granteeAddress\": \"zeta1unzpyll3tmutf0r8sqpxpnj46vtdr59mw8qepx\",\n \"granteePubkey\": {\n \"secp256k1\": \"zetapub1addwnpepqwy5pmg39regpq0gkggxehmfm8hwmxxw94sch7qzh4smava0szs07kk5045\"\n },\n \"nodeStatus\": 4\n }\n ],\n \"crosschain_flags\": {\n \"isInboundEnabled\": true,\n \"isOutboundEnabled\": true\n },\n \"keygen\": {\n \"status\": 1,\n \"granteePubkeys\": [\n \"zetapub1addwnpepqtlu7fykuh875xjckz4mn4x0mzc25rrqk5qne7mrwxqmatgllv3nx6lrkdp\",\n \"zetapub1addwnpepqwy5pmg39regpq0gkggxehmfm8hwmxxw94sch7qzh4smava0szs07kk5045\"\n ]\n },\n \"chain_params_list\": {},\n \"tss\": {\n \"tss_pubkey\": \"zetapub1addwnpepq28c57cvcs0a2htsem5zxr6qnlvq9mzhmm76z3jncsnzz32rclangr2g35p\",\n \"tss_participant_list\": [\n \"zetapub1addwnpepqtlu7fykuh875xjckz4mn4x0mzc25rrqk5qne7mrwxqmatgllv3nx6lrkdp\",\n \"zetapub1addwnpepqwy5pmg39regpq0gkggxehmfm8hwmxxw94sch7qzh4smava0szs07kk5045\"\n ],\n \"operator_address_list\": [\n \"zeta13c7p3xrhd6q2rx3h235jpt8pjdwvacyw6twpax\",\n \"zeta1f203dypqg5jh9hqfx0gfkmmnkdfuat3jr45ep2\"\n ]\n },\n \"tss_history\": [],\n \"tss_fund_migrators\": [],\n \"blame_list\": [],\n \"pending_nonces\": [],\n \"chain_nonces\": [],\n \"nonce_to_cctx\": []\n },\n \"params\": null,\n \"slashing\": {\n \"params\": {\n \"signed_blocks_window\": \"100\",\n \"min_signed_per_window\": \"0.500000000000000000\",\n \"downtime_jail_duration\": \"600s\",\n \"slash_fraction_double_sign\": \"0.050000000000000000\",\n \"slash_fraction_downtime\": \"0.010000000000000000\"\n },\n \"signing_infos\": [],\n \"missed_blocks\": []\n },\n \"staking\": {\n \"params\": {\n \"unbonding_time\": \"1814400s\",\n \"max_validators\": 100,\n \"max_entries\": 7,\n \"historical_entries\": 10000,\n \"bond_denom\": \"azeta\",\n \"min_commission_rate\": \"0.000000000000000000\"\n },\n \"last_total_power\": \"0\",\n \"last_validator_powers\": [],\n \"validators\": [],\n \"delegations\": [],\n \"unbonding_delegations\": [],\n \"redelegations\": [],\n \"exported\": false\n },\n \"upgrade\": {},\n \"vesting\": {}\n }\n }", - ) - genDoc, err := types.GenesisDocFromJSON(jsonBlob) - require.NoError(t, err) - return genDoc -} - func Chain(chainID int64) chains.Chain { r := newRandFromSeed(chainID) diff --git a/typescript/zetachain/zetacore/emissions/params_pb.d.ts b/typescript/zetachain/zetacore/emissions/params_pb.d.ts index ce4b4e9d78..c532176f6b 100644 --- a/typescript/zetachain/zetacore/emissions/params_pb.d.ts +++ b/typescript/zetachain/zetacore/emissions/params_pb.d.ts @@ -8,10 +8,68 @@ import { Message, proto3 } from "@bufbuild/protobuf"; /** * Params defines the parameters for the module. + * Sample values: + * ValidatorEmissionPercentage: "00.50", + * ObserverEmissionPercentage: "00.25", + * TssSignerEmissionPercentage: "00.25", + * ObserverSlashAmount: 100000000000000000, + * BallotMaturityBlocks: 100, + * BlockRewardAmount: 9620949074074074074.074070733466756687, * * @generated from message zetachain.zetacore.emissions.Params */ export declare class Params extends Message { + /** + * @generated from field: string validator_emission_percentage = 5; + */ + validatorEmissionPercentage: string; + + /** + * @generated from field: string observer_emission_percentage = 6; + */ + observerEmissionPercentage: string; + + /** + * @generated from field: string tss_signer_emission_percentage = 7; + */ + tssSignerEmissionPercentage: string; + + /** + * @generated from field: string observer_slash_amount = 9; + */ + observerSlashAmount: string; + + /** + * @generated from field: int64 ballot_maturity_blocks = 10; + */ + ballotMaturityBlocks: bigint; + + /** + * @generated from field: string block_reward_amount = 11; + */ + blockRewardAmount: string; + + constructor(data?: PartialMessage); + + static readonly runtime: typeof proto3; + static readonly typeName = "zetachain.zetacore.emissions.Params"; + static readonly fields: FieldList; + + static fromBinary(bytes: Uint8Array, options?: Partial): Params; + + static fromJson(jsonValue: JsonValue, options?: Partial): Params; + + static fromJsonString(jsonString: string, options?: Partial): Params; + + static equals(a: Params | PlainMessage | undefined, b: Params | PlainMessage | undefined): boolean; +} + +/** + * Deprecated (v20): Do not use. Use Params Instead + * + * @generated from message zetachain.zetacore.emissions.LegacyParams + */ +export declare class LegacyParams extends Message { /** * @generated from field: string max_bond_factor = 1; */ @@ -62,18 +120,18 @@ export declare class Params extends Message { */ ballotMaturityBlocks: bigint; - constructor(data?: PartialMessage); + constructor(data?: PartialMessage); static readonly runtime: typeof proto3; - static readonly typeName = "zetachain.zetacore.emissions.Params"; + static readonly typeName = "zetachain.zetacore.emissions.LegacyParams"; static readonly fields: FieldList; - static fromBinary(bytes: Uint8Array, options?: Partial): Params; + static fromBinary(bytes: Uint8Array, options?: Partial): LegacyParams; - static fromJson(jsonValue: JsonValue, options?: Partial): Params; + static fromJson(jsonValue: JsonValue, options?: Partial): LegacyParams; - static fromJsonString(jsonString: string, options?: Partial): Params; + static fromJsonString(jsonString: string, options?: Partial): LegacyParams; - static equals(a: Params | PlainMessage | undefined, b: Params | PlainMessage | undefined): boolean; + static equals(a: LegacyParams | PlainMessage | undefined, b: LegacyParams | PlainMessage | undefined): boolean; } diff --git a/typescript/zetachain/zetacore/emissions/query_pb.d.ts b/typescript/zetachain/zetacore/emissions/query_pb.d.ts index 3f1d07a6d1..6f5107d403 100644 --- a/typescript/zetachain/zetacore/emissions/query_pb.d.ts +++ b/typescript/zetachain/zetacore/emissions/query_pb.d.ts @@ -109,59 +109,6 @@ export declare class QueryListPoolAddressesResponse extends Message | undefined, b: QueryListPoolAddressesResponse | PlainMessage | undefined): boolean; } -/** - * @generated from message zetachain.zetacore.emissions.QueryGetEmissionsFactorsRequest - */ -export declare class QueryGetEmissionsFactorsRequest extends Message { - constructor(data?: PartialMessage); - - static readonly runtime: typeof proto3; - static readonly typeName = "zetachain.zetacore.emissions.QueryGetEmissionsFactorsRequest"; - static readonly fields: FieldList; - - static fromBinary(bytes: Uint8Array, options?: Partial): QueryGetEmissionsFactorsRequest; - - static fromJson(jsonValue: JsonValue, options?: Partial): QueryGetEmissionsFactorsRequest; - - static fromJsonString(jsonString: string, options?: Partial): QueryGetEmissionsFactorsRequest; - - static equals(a: QueryGetEmissionsFactorsRequest | PlainMessage | undefined, b: QueryGetEmissionsFactorsRequest | PlainMessage | undefined): boolean; -} - -/** - * @generated from message zetachain.zetacore.emissions.QueryGetEmissionsFactorsResponse - */ -export declare class QueryGetEmissionsFactorsResponse extends Message { - /** - * @generated from field: string reservesFactor = 1; - */ - reservesFactor: string; - - /** - * @generated from field: string bondFactor = 2; - */ - bondFactor: string; - - /** - * @generated from field: string durationFactor = 3; - */ - durationFactor: string; - - constructor(data?: PartialMessage); - - static readonly runtime: typeof proto3; - static readonly typeName = "zetachain.zetacore.emissions.QueryGetEmissionsFactorsResponse"; - static readonly fields: FieldList; - - static fromBinary(bytes: Uint8Array, options?: Partial): QueryGetEmissionsFactorsResponse; - - static fromJson(jsonValue: JsonValue, options?: Partial): QueryGetEmissionsFactorsResponse; - - static fromJsonString(jsonString: string, options?: Partial): QueryGetEmissionsFactorsResponse; - - static equals(a: QueryGetEmissionsFactorsResponse | PlainMessage | undefined, b: QueryGetEmissionsFactorsResponse | PlainMessage | undefined): boolean; -} - /** * @generated from message zetachain.zetacore.emissions.QueryShowAvailableEmissionsRequest */ diff --git a/x/emissions/abci.go b/x/emissions/abci.go index 25f6705e79..b4b75562ff 100644 --- a/x/emissions/abci.go +++ b/x/emissions/abci.go @@ -14,7 +14,14 @@ import ( func BeginBlocker(ctx sdk.Context, keeper keeper.Keeper) { emissionPoolBalance := keeper.GetReservesFactor(ctx) - blockRewards := types.BlockReward + + // Get the block rewards from the params + params, found := keeper.GetParams(ctx) + if !found { + ctx.Logger().Error("Params not found") + return + } + blockRewards := params.BlockRewardAmount if blockRewards.GT(emissionPoolBalance) { ctx.Logger(). Info(fmt.Sprintf("Block rewards %s are greater than emission pool balance %s", blockRewards.String(), emissionPoolBalance.String())) @@ -22,11 +29,6 @@ func BeginBlocker(ctx sdk.Context, keeper keeper.Keeper) { } // Get the distribution of rewards - params, found := keeper.GetParams(ctx) - if !found { - return - } - validatorRewards, observerRewards, tssSignerRewards := types.GetRewardsDistributions(params) // Use a tmpCtx, which is a cache-wrapped context to avoid writing to the store diff --git a/x/emissions/abci_test.go b/x/emissions/abci_test.go index 34a2ba41f1..2ef62ed7b5 100644 --- a/x/emissions/abci_test.go +++ b/x/emissions/abci_test.go @@ -10,7 +10,6 @@ import ( "github.com/stretchr/testify/require" "github.com/zeta-chain/node/cmd/zetacored/config" - "github.com/zeta-chain/node/pkg/coin" keepertest "github.com/zeta-chain/node/testutil/keeper" "github.com/zeta-chain/node/testutil/sample" emissionsModule "github.com/zeta-chain/node/x/emissions" @@ -19,6 +18,39 @@ import ( ) func TestBeginBlocker(t *testing.T) { + t.Run("no distribution happens if params are not found", func(t *testing.T) { + //Arrange + k, ctx, _, zk := keepertest.EmissionsKeeper(t) + _, found := k.GetParams(ctx) + require.True(t, found) + store := ctx.KVStore(k.GetStoreKey()) + store.Delete(emissionstypes.KeyPrefix(emissionstypes.ParamsKey)) + + var ballotIdentifiers []string + observerSet := sample.ObserverSet(10) + zk.ObserverKeeper.SetObserverSet(ctx, observerSet) + ballotList := sample.BallotList(10, observerSet.ObserverList) + for _, ballot := range ballotList { + zk.ObserverKeeper.SetBallot(ctx, &ballot) + ballotIdentifiers = append(ballotIdentifiers, ballot.BallotIdentifier) + } + zk.ObserverKeeper.SetBallotList(ctx, &observerTypes.BallotListForHeight{ + Height: 0, + BallotsIndexList: ballotIdentifiers, + }) + + //Act + for i := 0; i < 100; i++ { + emissionsModule.BeginBlocker(ctx, *k) + ctx = ctx.WithBlockHeight(ctx.BlockHeight() + 1) + } + + //Assert + for _, observer := range observerSet.ObserverList { + _, found := k.GetWithdrawableEmission(ctx, observer) + require.False(t, found) + } + }) t.Run("no observer distribution happens if emissions module account is empty", func(t *testing.T) { k, ctx, _, zk := keepertest.EmissionsKeeper(t) var ballotIdentifiers []string @@ -44,6 +76,7 @@ func TestBeginBlocker(t *testing.T) { require.False(t, found) } }) + t.Run("no validator distribution happens if emissions module account is empty", func(t *testing.T) { k, ctx, sk, _ := keepertest.EmissionsKeeper(t) feeCollectorAddress := sk.AuthKeeper.GetModuleAccount(ctx, types.FeeCollectorName).GetAddress() @@ -53,13 +86,15 @@ func TestBeginBlocker(t *testing.T) { } require.True(t, sk.BankKeeper.GetBalance(ctx, feeCollectorAddress, config.BaseDenom).Amount.IsZero()) }) + t.Run("tmp ctx is not committed if any of the distribution fails", func(t *testing.T) { k, ctx, sk, _ := keepertest.EmissionsKeeper(t) // Fund the emission pool to start the emission process + blockRewards := emissionstypes.BlockReward err := sk.BankKeeper.MintCoins( ctx, emissionstypes.ModuleName, - sdk.NewCoins(sdk.NewCoin(config.BaseDenom, sdk.NewInt(1000000000000))), + sdk.NewCoins(sdk.NewCoin(config.BaseDenom, blockRewards.TruncateInt())), ) require.NoError(t, err) // Setup module accounts for emission pools except for observer pool , so that the observer distribution fails @@ -80,19 +115,19 @@ func TestBeginBlocker(t *testing.T) { emissionstypes.EmissionsModuleAddress, config.BaseDenom, ).Amount.Equal( - sdk.NewInt(1000000000000), + blockRewards.TruncateInt(), ), ) }) + t.Run("begin blocker returns early if validator distribution fails", func(t *testing.T) { k, ctx, _, _ := keepertest.EmissionKeeperWithMockOptions(t, keepertest.EmissionMockOptions{ UseBankMock: true, }) - // Total block rewards is the fixed amount of rewards that are distributed - totalBlockRewards, err := coin.GetAzetaDecFromAmountInZeta(emissionstypes.BlockRewardsInZeta) - totalRewardCoins := sdk.NewCoins(sdk.NewCoin(config.BaseDenom, totalBlockRewards.TruncateInt())) - require.NoError(t, err) - + // Over funding the emission pool to avoid any errors due to truncated values + blockRewards := emissionstypes.BlockReward + totalRewardAmount := blockRewards.TruncateInt().Mul(sdk.NewInt(2)) + totalRewardCoins := sdk.NewCoins(sdk.NewCoin(config.BaseDenom, totalRewardAmount)) bankMock := keepertest.GetEmissionsBankMock(t, k) bankMock.On("GetBalance", ctx, mock.Anything, config.BaseDenom). @@ -111,11 +146,10 @@ func TestBeginBlocker(t *testing.T) { k, ctx, _, _ := keepertest.EmissionKeeperWithMockOptions(t, keepertest.EmissionMockOptions{ UseBankMock: true, }) - // Total block rewards is the fixed amount of rewards that are distributed - totalBlockRewards, err := coin.GetAzetaDecFromAmountInZeta(emissionstypes.BlockRewardsInZeta) - totalRewardCoins := sdk.NewCoins(sdk.NewCoin(config.BaseDenom, totalBlockRewards.TruncateInt())) - require.NoError(t, err) - + // Over funding the emission pool to avoid any errors due to truncated values + blockRewards := emissionstypes.BlockReward + totalRewardAmount := blockRewards.TruncateInt().Mul(sdk.NewInt(2)) + totalRewardCoins := sdk.NewCoins(sdk.NewCoin(config.BaseDenom, totalRewardAmount)) bankMock := keepertest.GetEmissionsBankMock(t, k) bankMock.On("GetBalance", ctx, mock.Anything, config.BaseDenom). @@ -139,11 +173,11 @@ func TestBeginBlocker(t *testing.T) { k, ctx, _, _ := keepertest.EmissionKeeperWithMockOptions(t, keepertest.EmissionMockOptions{ UseBankMock: true, }) - // Total block rewards is the fixed amount of rewards that are distributed - totalBlockRewards, err := coin.GetAzetaDecFromAmountInZeta(emissionstypes.BlockRewardsInZeta) - totalRewardCoins := sdk.NewCoins(sdk.NewCoin(config.BaseDenom, totalBlockRewards.TruncateInt())) - require.NoError(t, err) + // Over funding the emission pool to avoid any errors due to truncated values + blockRewards := emissionstypes.BlockReward + totalRewardAmount := blockRewards.TruncateInt().Mul(sdk.NewInt(2)) + totalRewardCoins := sdk.NewCoins(sdk.NewCoin(config.BaseDenom, totalRewardAmount)) bankMock := keepertest.GetEmissionsBankMock(t, k) bankMock.On("GetBalance", ctx, mock.Anything, config.BaseDenom). @@ -186,12 +220,12 @@ func TestBeginBlocker(t *testing.T) { BallotsIndexList: ballotIdentifiers, }) - // Total block rewards is the fixed amount of rewards that are distributed - totalBlockRewards, err := coin.GetAzetaDecFromAmountInZeta(emissionstypes.BlockRewardsInZeta) - totalRewardCoins := sdk.NewCoins(sdk.NewCoin(config.BaseDenom, totalBlockRewards.TruncateInt())) - require.NoError(t, err) // Fund the emission pool to start the emission process - err = sk.BankKeeper.MintCoins(ctx, emissionstypes.ModuleName, totalRewardCoins) + blockRewards := emissionstypes.BlockReward + totalRewardAmount := blockRewards.TruncateInt().Mul(sdk.NewInt(int64(numberOfTestBlocks))) + totalRewardCoins := sdk.NewCoins(sdk.NewCoin(config.BaseDenom, totalRewardAmount)) + + err := sk.BankKeeper.MintCoins(ctx, emissionstypes.ModuleName, totalRewardCoins) require.NoError(t, err) // Setup module accounts for emission pools @@ -204,15 +238,13 @@ func TestBeginBlocker(t *testing.T) { params, found := k.GetParams(ctx) require.True(t, found) - blockRewards := emissionstypes.BlockReward - observerRewardsForABlock := blockRewards.Mul(sdk.MustNewDecFromStr(params.ObserverEmissionPercentage)). - TruncateInt() - validatorRewardsForABlock := blockRewards.Mul(sdk.MustNewDecFromStr(params.ValidatorEmissionPercentage)). - TruncateInt() - tssSignerRewardsForABlock := blockRewards.Mul(sdk.MustNewDecFromStr(params.TssSignerEmissionPercentage)). - TruncateInt() - distributedRewards := observerRewardsForABlock.Add(validatorRewardsForABlock).Add(tssSignerRewardsForABlock) + // Get the rewards distribution, this is a fixed amount based on total block rewards and distribution percentages + validatorRewardsForABlock, observerRewardsForABlock, tssSignerRewardsForABlock := emissionstypes.GetRewardsDistributions( + params, + ) + + distributedRewards := observerRewardsForABlock.Add(validatorRewardsForABlock).Add(tssSignerRewardsForABlock) require.True(t, blockRewards.TruncateInt().GT(distributedRewards)) for i := 0; i < numberOfTestBlocks; i++ { @@ -226,6 +258,7 @@ func TestBeginBlocker(t *testing.T) { emissionPool, config.BaseDenom, ).Amount + require.True( t, emissionPoolBeforeBlockDistribution.Sub(emissionPoolBalanceAfterBlockDistribution). @@ -416,12 +449,11 @@ func TestDistributeObserverRewards(t *testing.T) { zk.ObserverKeeper.SetObserverSet(ctx, observerSet) // Total block rewards is the fixed amount of rewards that are distributed - totalBlockRewards, err := coin.GetAzetaDecFromAmountInZeta(emissionstypes.BlockRewardsInZeta) - totalRewardCoins := sdk.NewCoins(sdk.NewCoin(config.BaseDenom, totalBlockRewards.TruncateInt())) - require.NoError(t, err) + totalBlockRewards := emissionstypes.BlockReward.TruncateInt() + totalRewardCoins := sdk.NewCoins(sdk.NewCoin(config.BaseDenom, totalBlockRewards)) // Fund the emission pool to start the emission process - err = sk.BankKeeper.MintCoins(ctx, emissionstypes.ModuleName, totalRewardCoins) + err := sk.BankKeeper.MintCoins(ctx, emissionstypes.ModuleName, totalRewardCoins) require.NoError(t, err) // Set starting emission for all observers to 100 so that we can calculate the rewards and slashes diff --git a/x/emissions/client/cli/query.go b/x/emissions/client/cli/query.go index 066381d930..eb82b7604f 100644 --- a/x/emissions/client/cli/query.go +++ b/x/emissions/client/cli/query.go @@ -22,8 +22,6 @@ func GetQueryCmd(_ string) *cobra.Command { cmd.AddCommand(CmdQueryParams(), CmdListPoolAddresses(), - CmdGetEmmisonsFactors(), CmdShowAvailableEmissions()) - // this line is used by starport scaffolding # 1 return cmd } diff --git a/x/emissions/client/cli/query_get_emmisons_factors.go b/x/emissions/client/cli/query_get_emmisons_factors.go deleted file mode 100644 index c100c91cd1..0000000000 --- a/x/emissions/client/cli/query_get_emmisons_factors.go +++ /dev/null @@ -1,38 +0,0 @@ -package cli - -import ( - "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/client/flags" - "github.com/spf13/cobra" - - "github.com/zeta-chain/node/x/emissions/types" -) - -func CmdGetEmmisonsFactors() *cobra.Command { - cmd := &cobra.Command{ - Use: "get-emmisons-factors", - Short: "Query GetEmmisonsFactors", - Args: cobra.NoArgs, - RunE: func(cmd *cobra.Command, _ []string) (err error) { - clientCtx, err := client.GetClientTxContext(cmd) - if err != nil { - return err - } - - queryClient := types.NewQueryClient(clientCtx) - - params := &types.QueryGetEmissionsFactorsRequest{} - - res, err := queryClient.GetEmissionsFactors(cmd.Context(), params) - if err != nil { - return err - } - - return clientCtx.PrintProto(res) - }, - } - - flags.AddQueryFlagsToCmd(cmd) - - return cmd -} diff --git a/x/emissions/genesis_test.go b/x/emissions/genesis_test.go index 42d945f5e6..325331b587 100644 --- a/x/emissions/genesis_test.go +++ b/x/emissions/genesis_test.go @@ -3,6 +3,7 @@ package emissions_test import ( "testing" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" keepertest "github.com/zeta-chain/node/testutil/keeper" @@ -39,7 +40,7 @@ func TestGenesis(t *testing.T) { t.Run("should error for invalid params", func(t *testing.T) { params := types.DefaultParams() - params.MinBondFactor = "0.50" + params.ObserverSlashAmount = sdk.NewInt(-1) genesisState := types.GenesisState{ Params: params, diff --git a/x/emissions/keeper/block_rewards_components.go b/x/emissions/keeper/block_rewards_components.go index 213f467b15..1d41415efe 100644 --- a/x/emissions/keeper/block_rewards_components.go +++ b/x/emissions/keeper/block_rewards_components.go @@ -4,40 +4,10 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/zeta-chain/node/cmd/zetacored/config" - "github.com/zeta-chain/node/pkg/coin" "github.com/zeta-chain/node/x/emissions/types" ) -func (k Keeper) GetBlockRewardComponents(ctx sdk.Context, params types.Params) (sdk.Dec, sdk.Dec, sdk.Dec) { - reservesFactor := k.GetReservesFactor(ctx) - if reservesFactor.LTE(sdk.ZeroDec()) { - return sdk.ZeroDec(), sdk.ZeroDec(), sdk.ZeroDec() - } - bondFactor := params.GetBondFactor(k.stakingKeeper.BondedRatio(ctx)) - durationFactor := params.GetDurationFactor(ctx.BlockHeight()) - return reservesFactor, bondFactor, durationFactor -} - func (k Keeper) GetReservesFactor(ctx sdk.Context) sdk.Dec { reserveAmount := k.GetBankKeeper().GetBalance(ctx, types.EmissionsModuleAddress, config.BaseDenom) return sdk.NewDecFromInt(reserveAmount.Amount) } - -func (k Keeper) GetFixedBlockRewards() (sdk.Dec, error) { - return CalculateFixedValidatorRewards(types.AvgBlockTime) -} - -func CalculateFixedValidatorRewards(avgBlockTimeString string) (sdk.Dec, error) { - azetaAmountTotalRewards, err := coin.GetAzetaDecFromAmountInZeta(types.BlockRewardsInZeta) - if err != nil { - return sdk.ZeroDec(), err - } - avgBlockTime, err := sdk.NewDecFromStr(avgBlockTimeString) - if err != nil { - return sdk.ZeroDec(), err - } - numberOfBlocksInAMonth := sdk.NewDec(types.SecsInMonth).Quo(avgBlockTime) - numberOfBlocksTotal := numberOfBlocksInAMonth.Mul(sdk.NewDec(12)).Mul(sdk.NewDec(types.EmissionScheduledYears)) - constantRewardPerBlock := azetaAmountTotalRewards.Quo(numberOfBlocksTotal) - return constantRewardPerBlock, nil -} diff --git a/x/emissions/keeper/block_rewards_components_test.go b/x/emissions/keeper/block_rewards_components_test.go index 9027aee58c..4694b7df4a 100644 --- a/x/emissions/keeper/block_rewards_components_test.go +++ b/x/emissions/keeper/block_rewards_components_test.go @@ -3,108 +3,23 @@ package keeper_test import ( "testing" - "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" - "github.com/zeta-chain/node/cmd/zetacored/config" keepertest "github.com/zeta-chain/node/testutil/keeper" - emissionskeeper "github.com/zeta-chain/node/x/emissions/keeper" - emissionstypes "github.com/zeta-chain/node/x/emissions/types" + "github.com/zeta-chain/node/x/emissions/types" ) -func TestKeeper_CalculateFixedValidatorRewards(t *testing.T) { - tt := []struct { - name string - blockTimeInSecs string - expectedBlockRewards sdk.Dec - wantErr bool - }{ - { - name: "Invalid block time", - blockTimeInSecs: "", - wantErr: true, - }, - { - name: "Block Time 5.7", - blockTimeInSecs: "5.7", - expectedBlockRewards: sdk.MustNewDecFromStr("9620949074074074074.074070733466756687"), - }, - { - name: "Block Time 6", - blockTimeInSecs: "6", - expectedBlockRewards: sdk.MustNewDecFromStr("10127314814814814814.814814814814814815"), - }, - { - name: "Block Time 3", - blockTimeInSecs: "3", - expectedBlockRewards: sdk.MustNewDecFromStr("5063657407407407407.407407407407407407"), - }, - { - name: "Block Time 2", - blockTimeInSecs: "2", - expectedBlockRewards: sdk.MustNewDecFromStr("3375771604938271604.938271604938271605"), - }, - { - name: "Block Time 8", - blockTimeInSecs: "8", - expectedBlockRewards: sdk.MustNewDecFromStr("13503086419753086419.753086419753086420"), - }, - } - for _, tc := range tt { - t.Run(tc.name, func(t *testing.T) { - blockRewards, err := emissionskeeper.CalculateFixedValidatorRewards(tc.blockTimeInSecs) - if tc.wantErr { - require.Error(t, err) - return - } - require.NoError(t, err) - require.Equal(t, tc.expectedBlockRewards, blockRewards) - }) - } -} - -func TestKeeper_GetFixedBlockRewards(t *testing.T) { - k, _, _, _ := keepertest.EmissionsKeeper(t) - fixedBlockRewards, err := k.GetFixedBlockRewards() - require.NoError(t, err) - require.Equal(t, emissionstypes.BlockReward, fixedBlockRewards) -} - -func TestKeeper_GetBlockRewardComponent(t *testing.T) { - t.Run("should return all 0s if reserves factor is 0", func(t *testing.T) { - k, ctx, _, _ := keepertest.EmissionKeeperWithMockOptions(t, keepertest.EmissionMockOptions{ - UseBankMock: true, - }) - - bankMock := keepertest.GetEmissionsBankMock(t, k) - bankMock.On("GetBalance", - ctx, mock.Anything, config.BaseDenom). - Return(sdk.NewCoin(config.BaseDenom, math.NewInt(0)), nil).Once() - - reservesFactor, bondFactor, durationFactor := k.GetBlockRewardComponents(ctx, emissionstypes.DefaultParams()) - require.Equal(t, sdk.ZeroDec(), reservesFactor) - require.Equal(t, sdk.ZeroDec(), bondFactor) - require.Equal(t, sdk.ZeroDec(), durationFactor) - }) - - t.Run("should return if reserves factor is not 0", func(t *testing.T) { - k, ctx, _, _ := keepertest.EmissionKeeperWithMockOptions(t, keepertest.EmissionMockOptions{ - UseBankMock: true, - }) - - bankMock := keepertest.GetEmissionsBankMock(t, k) - bankMock.On("GetBalance", - ctx, mock.Anything, config.BaseDenom). - Return(sdk.NewCoin(config.BaseDenom, math.NewInt(1)), nil).Once() - - reservesFactor, bondFactor, durationFactor := k.GetBlockRewardComponents(ctx, emissionstypes.DefaultParams()) - require.Equal(t, sdk.OneDec(), reservesFactor) - // bonded ratio is 0 - require.Equal(t, sdk.ZeroDec(), bondFactor) - // non 0 value returned - require.NotEqual(t, sdk.ZeroDec(), durationFactor) - require.Positive(t, durationFactor.BigInt().Int64()) +func TestKeeper_GetReservesFactor(t *testing.T) { + t.Run("successfully get reserves factor", func(t *testing.T) { + //Arrange + k, ctx, sdkK, _ := keepertest.EmissionsKeeper(t) + amount := sdk.NewInt(100000000000000000) + err := sdkK.BankKeeper.MintCoins(ctx, types.ModuleName, sdk.NewCoins(sdk.NewCoin(config.BaseDenom, amount))) + require.NoError(t, err) + //Act + reserveAmount := k.GetReservesFactor(ctx) + //Assert + require.Equal(t, amount.ToLegacyDec(), reserveAmount) }) } diff --git a/x/emissions/keeper/grpc_query_get_emmisons_factors.go b/x/emissions/keeper/grpc_query_get_emmisons_factors.go deleted file mode 100644 index aedb21f654..0000000000 --- a/x/emissions/keeper/grpc_query_get_emmisons_factors.go +++ /dev/null @@ -1,28 +0,0 @@ -package keeper - -import ( - "context" - - sdk "github.com/cosmos/cosmos-sdk/types" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/status" - - "github.com/zeta-chain/node/x/emissions/types" -) - -func (k Keeper) GetEmissionsFactors( - goCtx context.Context, - _ *types.QueryGetEmissionsFactorsRequest, -) (*types.QueryGetEmissionsFactorsResponse, error) { - ctx := sdk.UnwrapSDKContext(goCtx) - params, found := k.GetParams(ctx) - if !found { - return nil, status.Error(codes.Internal, "params not found") - } - reservesFactor, bondFactor, durationFactor := k.GetBlockRewardComponents(ctx, params) - return &types.QueryGetEmissionsFactorsResponse{ - ReservesFactor: reservesFactor.String(), - BondFactor: bondFactor.String(), - DurationFactor: durationFactor.String(), - }, nil -} diff --git a/x/emissions/keeper/grpc_query_get_emmisons_factors_test.go b/x/emissions/keeper/grpc_query_get_emmisons_factors_test.go deleted file mode 100644 index 57b92ccfa3..0000000000 --- a/x/emissions/keeper/grpc_query_get_emmisons_factors_test.go +++ /dev/null @@ -1,41 +0,0 @@ -package keeper_test - -import ( - "testing" - - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/stretchr/testify/require" - - keepertest "github.com/zeta-chain/node/testutil/keeper" - "github.com/zeta-chain/node/x/emissions/types" -) - -func TestKeeper_GetEmissionsFactors(t *testing.T) { - t.Run("should return emissions factor", func(t *testing.T) { - k, ctx, _, _ := keepertest.EmissionsKeeper(t) - wctx := sdk.WrapSDKContext(ctx) - - res, err := k.GetEmissionsFactors(wctx, nil) - require.NoError(t, err) - - reservesFactor, bondFactor, durationFactor := k.GetBlockRewardComponents(ctx, types.DefaultParams()) - expectedRes := &types.QueryGetEmissionsFactorsResponse{ - ReservesFactor: reservesFactor.String(), - BondFactor: bondFactor.String(), - DurationFactor: durationFactor.String(), - } - require.Equal(t, expectedRes, res) - }) - - t.Run("should fail if params not found", func(t *testing.T) { - k, ctx, _, _ := keepertest.EmissionKeeperWithMockOptions( - t, - keepertest.EmissionMockOptions{SkipSettingParams: true}, - ) - wctx := sdk.WrapSDKContext(ctx) - - res, err := k.GetEmissionsFactors(wctx, nil) - require.Nil(t, res) - require.Error(t, err) - }) -} diff --git a/x/emissions/keeper/keeper.go b/x/emissions/keeper/keeper.go index 39c1f19a22..529fde9e83 100644 --- a/x/emissions/keeper/keeper.go +++ b/x/emissions/keeper/keeper.go @@ -55,6 +55,14 @@ func NewKeeper( } } +func (k Keeper) GetCodec() codec.BinaryCodec { + return k.cdc +} + +func (k Keeper) GetStoreKey() storetypes.StoreKey { + return k.storeKey +} + func (k Keeper) Logger(ctx sdk.Context) log.Logger { return ctx.Logger().With("module", fmt.Sprintf("x/%s", types.ModuleName)) } diff --git a/x/emissions/keeper/migrator.go b/x/emissions/keeper/migrator.go index c111e3e20c..794bdbd536 100644 --- a/x/emissions/keeper/migrator.go +++ b/x/emissions/keeper/migrator.go @@ -5,6 +5,7 @@ import ( "github.com/zeta-chain/node/x/emissions/exported" v3 "github.com/zeta-chain/node/x/emissions/migrations/v3" + v4 "github.com/zeta-chain/node/x/emissions/migrations/v4" ) // Migrator is a struct for handling in-place store migrations. @@ -25,3 +26,8 @@ func NewMigrator(k Keeper, ss exported.Subspace) Migrator { func (m Migrator) Migrate2to3(ctx sdk.Context) error { return v3.MigrateStore(ctx, m.keeper, m.legacySubspace) } + +// Migrate3to4 migrates the store from consensus version 3 to 4 +func (m Migrator) Migrate3to4(ctx sdk.Context) error { + return v4.MigrateStore(ctx, m.keeper) +} diff --git a/x/emissions/keeper/params_test.go b/x/emissions/keeper/params_test.go index 84ad58a9b4..72c752c3ad 100644 --- a/x/emissions/keeper/params_test.go +++ b/x/emissions/keeper/params_test.go @@ -19,213 +19,123 @@ func TestKeeper_GetParams(t *testing.T) { { name: "Successfully set params", params: emissionstypes.Params{ - MaxBondFactor: "1.25", - MinBondFactor: "0.75", - AvgBlockTime: "6.00", - TargetBondRatio: "00.67", ValidatorEmissionPercentage: "00.50", ObserverEmissionPercentage: "00.25", TssSignerEmissionPercentage: "00.25", - DurationFactorConstant: "0.001877876953694702", ObserverSlashAmount: sdkmath.NewInt(100000000000000000), + BallotMaturityBlocks: int64(emissionstypes.BallotMaturityBlocks), + BlockRewardAmount: emissionstypes.BlockReward, }, constainsErr: "", }, { name: "negative observer slashed amount", params: emissionstypes.Params{ - MaxBondFactor: "1.25", - MinBondFactor: "0.75", - AvgBlockTime: "6.00", - TargetBondRatio: "00.67", ValidatorEmissionPercentage: "00.50", ObserverEmissionPercentage: "00.25", TssSignerEmissionPercentage: "00.25", - DurationFactorConstant: "0.001877876953694702", ObserverSlashAmount: sdkmath.NewInt(-100000000000000000), + BallotMaturityBlocks: int64(emissionstypes.BallotMaturityBlocks), + BlockRewardAmount: emissionstypes.BlockReward, }, constainsErr: "slash amount cannot be less than 0", }, - { - name: "MaxBondFactor too high", - params: emissionstypes.Params{ - MaxBondFactor: "1.35", - MinBondFactor: "0.85", - AvgBlockTime: "6.00", - TargetBondRatio: "00.67", - ValidatorEmissionPercentage: "00.50", - ObserverEmissionPercentage: "00.25", - TssSignerEmissionPercentage: "00.25", - DurationFactorConstant: "0.001877876953694702", - ObserverSlashAmount: sdkmath.NewInt(100000000000000000), - }, - constainsErr: "max bond factor cannot be higher that 1.25", - }, - { - name: "MinBondFactor too low", - params: emissionstypes.Params{ - MaxBondFactor: "1.25", - MinBondFactor: "0.35", - AvgBlockTime: "6.00", - TargetBondRatio: "00.67", - ValidatorEmissionPercentage: "00.50", - ObserverEmissionPercentage: "00.25", - TssSignerEmissionPercentage: "00.25", - DurationFactorConstant: "0.001877876953694702", - ObserverSlashAmount: sdkmath.NewInt(100000000000000000), - }, - constainsErr: "min bond factor cannot be lower that 0.75", - }, - { - name: "invalid block time", - params: emissionstypes.Params{ - MaxBondFactor: "1.25", - MinBondFactor: "0.75", - AvgBlockTime: "invalidTime", - TargetBondRatio: "00.67", - ValidatorEmissionPercentage: "00.50", - ObserverEmissionPercentage: "00.25", - TssSignerEmissionPercentage: "00.25", - DurationFactorConstant: "0.001877876953694702", - ObserverSlashAmount: sdkmath.NewInt(100000000000000000), - }, - constainsErr: "invalid block time", - }, - { - name: "invalid block time less than 0", - params: emissionstypes.Params{ - MaxBondFactor: "1.25", - MinBondFactor: "0.75", - AvgBlockTime: "-2", - TargetBondRatio: "00.67", - ValidatorEmissionPercentage: "00.50", - ObserverEmissionPercentage: "00.25", - TssSignerEmissionPercentage: "00.25", - DurationFactorConstant: "0.001877876953694702", - ObserverSlashAmount: sdkmath.NewInt(100000000000000000), - }, - constainsErr: "block time cannot be less than or equal to 0", - }, - { - name: "bond ratio too high", - params: emissionstypes.Params{ - MaxBondFactor: "1.25", - MinBondFactor: "0.75", - AvgBlockTime: "6.00", - TargetBondRatio: "2.67", - ValidatorEmissionPercentage: "00.50", - ObserverEmissionPercentage: "00.25", - TssSignerEmissionPercentage: "00.25", - DurationFactorConstant: "0.001877876953694702", - ObserverSlashAmount: sdkmath.NewInt(100000000000000000), - }, - constainsErr: "target bond ratio cannot be more than 100 percent", - }, - { - name: "bond ratio too low", - params: emissionstypes.Params{ - MaxBondFactor: "1.25", - MinBondFactor: "0.75", - AvgBlockTime: "6.00", - TargetBondRatio: "-1.00", - ValidatorEmissionPercentage: "00.50", - ObserverEmissionPercentage: "00.25", - TssSignerEmissionPercentage: "00.25", - DurationFactorConstant: "0.001877876953694702", - ObserverSlashAmount: sdkmath.NewInt(100000000000000000), - }, - constainsErr: "target bond ratio cannot be less than 0 percent", - }, { name: "validator emission percentage too high", params: emissionstypes.Params{ - MaxBondFactor: "1.25", - MinBondFactor: "0.75", - AvgBlockTime: "6.00", - TargetBondRatio: "00.67", ValidatorEmissionPercentage: "1.50", ObserverEmissionPercentage: "00.25", TssSignerEmissionPercentage: "00.25", - DurationFactorConstant: "0.001877876953694702", ObserverSlashAmount: sdkmath.NewInt(100000000000000000), + BallotMaturityBlocks: int64(emissionstypes.BallotMaturityBlocks), + BlockRewardAmount: emissionstypes.BlockReward, }, constainsErr: "validator emission percentage cannot be more than 100 percent", }, { name: "validator emission percentage too low", params: emissionstypes.Params{ - MaxBondFactor: "1.25", - MinBondFactor: "0.75", - AvgBlockTime: "6.00", - TargetBondRatio: "00.67", ValidatorEmissionPercentage: "-1.50", ObserverEmissionPercentage: "00.25", TssSignerEmissionPercentage: "00.25", - DurationFactorConstant: "0.001877876953694702", ObserverSlashAmount: sdkmath.NewInt(100000000000000000), + BallotMaturityBlocks: int64(emissionstypes.BallotMaturityBlocks), + BlockRewardAmount: emissionstypes.BlockReward, }, constainsErr: "validator emission percentage cannot be less than 0 percent", }, { name: "observer percentage too low", params: emissionstypes.Params{ - MaxBondFactor: "1.25", - MinBondFactor: "0.75", - AvgBlockTime: "6.00", - TargetBondRatio: "00.67", ValidatorEmissionPercentage: "00.50", ObserverEmissionPercentage: "-00.25", TssSignerEmissionPercentage: "00.25", - DurationFactorConstant: "0.001877876953694702", ObserverSlashAmount: sdkmath.NewInt(100000000000000000), + BallotMaturityBlocks: int64(emissionstypes.BallotMaturityBlocks), + BlockRewardAmount: emissionstypes.BlockReward, }, constainsErr: "observer emission percentage cannot be less than 0 percent", }, { name: "observer percentage too high", params: emissionstypes.Params{ - MaxBondFactor: "1.25", - MinBondFactor: "0.75", - AvgBlockTime: "6.00", - TargetBondRatio: "00.67", ValidatorEmissionPercentage: "00.50", ObserverEmissionPercentage: "150.25", TssSignerEmissionPercentage: "00.25", - DurationFactorConstant: "0.001877876953694702", ObserverSlashAmount: sdkmath.NewInt(100000000000000000), + BallotMaturityBlocks: int64(emissionstypes.BallotMaturityBlocks), + BlockRewardAmount: emissionstypes.BlockReward, }, constainsErr: "observer emission percentage cannot be more than 100 percent", }, { name: "tss signer percentage too high", params: emissionstypes.Params{ - MaxBondFactor: "1.25", - MinBondFactor: "0.75", - AvgBlockTime: "6.00", - TargetBondRatio: "00.67", ValidatorEmissionPercentage: "00.50", ObserverEmissionPercentage: "00.25", TssSignerEmissionPercentage: "102.22", - DurationFactorConstant: "0.001877876953694702", ObserverSlashAmount: sdkmath.NewInt(100000000000000000), + BallotMaturityBlocks: int64(emissionstypes.BallotMaturityBlocks), + BlockRewardAmount: emissionstypes.BlockReward, }, constainsErr: "tss emission percentage cannot be more than 100 percent", }, { name: "tss signer percentage too low", params: emissionstypes.Params{ - MaxBondFactor: "1.25", - MinBondFactor: "0.75", - AvgBlockTime: "6.00", - TargetBondRatio: "00.67", ValidatorEmissionPercentage: "00.50", ObserverEmissionPercentage: "00.25", TssSignerEmissionPercentage: "-102.22", - DurationFactorConstant: "0.001877876953694702", ObserverSlashAmount: sdkmath.NewInt(100000000000000000), + BallotMaturityBlocks: int64(emissionstypes.BallotMaturityBlocks), + BlockRewardAmount: emissionstypes.BlockReward, }, constainsErr: "tss emission percentage cannot be less than 0 percent", }, + { + name: "ballot maturity blocks too low", + params: emissionstypes.Params{ + ValidatorEmissionPercentage: "00.50", + ObserverEmissionPercentage: "00.25", + TssSignerEmissionPercentage: "00.25", + ObserverSlashAmount: sdkmath.NewInt(100000000000000000), + BallotMaturityBlocks: -100, + BlockRewardAmount: emissionstypes.BlockReward, + }, + constainsErr: "ballot maturity types must be gte 0", + }, + { + name: "block reward amount too low", + params: emissionstypes.Params{ + ValidatorEmissionPercentage: "00.50", + ObserverEmissionPercentage: "00.25", + TssSignerEmissionPercentage: "00.25", + ObserverSlashAmount: sdkmath.NewInt(100000000000000000), + BallotMaturityBlocks: int64(emissionstypes.BallotMaturityBlocks), + BlockRewardAmount: sdkmath.LegacyMustNewDecFromStr("-10.00"), + }, + constainsErr: "block reward amount cannot be less than 0", + }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { diff --git a/x/emissions/migrations/v3/migrate.go b/x/emissions/migrations/v3/migrate.go index 5c38378f26..5430ee2bbd 100644 --- a/x/emissions/migrations/v3/migrate.go +++ b/x/emissions/migrations/v3/migrate.go @@ -26,19 +26,6 @@ func MigrateStore( defaultParams := types.NewParams() - // ensure params are set with default values if not present in legacy params - if currParams.AvgBlockTime == "" { - currParams.AvgBlockTime = defaultParams.AvgBlockTime - } - if currParams.MaxBondFactor == "" { - currParams.MaxBondFactor = defaultParams.MaxBondFactor - } - if currParams.MinBondFactor == "" { - currParams.MinBondFactor = defaultParams.MinBondFactor - } - if currParams.TargetBondRatio == "" { - currParams.TargetBondRatio = defaultParams.TargetBondRatio - } if currParams.ValidatorEmissionPercentage == "" { currParams.ValidatorEmissionPercentage = defaultParams.ValidatorEmissionPercentage } @@ -48,12 +35,12 @@ func MigrateStore( if currParams.TssSignerEmissionPercentage == "" { currParams.TssSignerEmissionPercentage = defaultParams.TssSignerEmissionPercentage } - if currParams.DurationFactorConstant == "" { - currParams.DurationFactorConstant = defaultParams.DurationFactorConstant - } currParams.ObserverSlashAmount = types.ObserverSlashAmount currParams.BallotMaturityBlocks = int64(types.BallotMaturityBlocks) + + // BlockRewardAmount is a new parameter introduced in version 4 + currParams.BlockRewardAmount = types.BlockReward err := currParams.Validate() if err != nil { return err diff --git a/x/emissions/migrations/v3/migrate_test.go b/x/emissions/migrations/v3/migrate_test.go index f47d8d7b02..2f18b7d375 100644 --- a/x/emissions/migrations/v3/migrate_test.go +++ b/x/emissions/migrations/v3/migrate_test.go @@ -9,8 +9,9 @@ import ( keepertest "github.com/zeta-chain/node/testutil/keeper" "github.com/zeta-chain/node/x/emissions/exported" - v3 "github.com/zeta-chain/node/x/emissions/migrations/v3" "github.com/zeta-chain/node/x/emissions/types" + + v3 "github.com/zeta-chain/node/x/emissions/migrations/v3" ) type mockSubspace struct { @@ -30,14 +31,9 @@ func TestMigrate(t *testing.T) { k, ctx, _, _ := keepertest.EmissionsKeeper(t) legacyParams := types.Params{ - MaxBondFactor: "1", - MinBondFactor: "0.75", - AvgBlockTime: "5.00", - TargetBondRatio: "00.50", ValidatorEmissionPercentage: "00.50", ObserverEmissionPercentage: "00.35", TssSignerEmissionPercentage: "00.15", - DurationFactorConstant: "0.001877876953694702", ObserverSlashAmount: sdk.ZeroInt(), } legacySubspace := newMockSubspace(legacyParams) @@ -48,6 +44,7 @@ func TestMigrate(t *testing.T) { require.True(t, found) legacyParams.ObserverSlashAmount = sdkmath.NewInt(100000000000000000) legacyParams.BallotMaturityBlocks = 100 + legacyParams.BlockRewardAmount = types.BlockReward require.Equal(t, legacyParams, params) }) @@ -71,19 +68,14 @@ func TestMigrate(t *testing.T) { k, ctx, _, _ := keepertest.EmissionsKeeper(t) legacyParams := types.Params{ - MaxBondFactor: "1", - MinBondFactor: "0.50", - AvgBlockTime: "5.00", - TargetBondRatio: "00.50", - ValidatorEmissionPercentage: "00.50", + ValidatorEmissionPercentage: "-00.50", ObserverEmissionPercentage: "00.35", TssSignerEmissionPercentage: "00.15", - DurationFactorConstant: "0.001877876953694702", ObserverSlashAmount: sdk.ZeroInt(), } legacySubspace := newMockSubspace(legacyParams) err := v3.MigrateStore(ctx, k, legacySubspace) - require.ErrorContains(t, err, "min bond factor cannot be lower that 0.75") + require.ErrorContains(t, err, "validator emission percentage cannot be less than 0 percent") }) } diff --git a/x/emissions/migrations/v4/migrate.go b/x/emissions/migrations/v4/migrate.go new file mode 100644 index 0000000000..a5aaba21b6 --- /dev/null +++ b/x/emissions/migrations/v4/migrate.go @@ -0,0 +1,73 @@ +package v4 + +import ( + errorsmod "cosmossdk.io/errors" + sdkmath "cosmossdk.io/math" + "github.com/cosmos/cosmos-sdk/codec" + storetypes "github.com/cosmos/cosmos-sdk/store/types" + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/zeta-chain/node/x/emissions/types" +) + +type EmissionsKeeper interface { + SetParams(ctx sdk.Context, params types.Params) error + GetCodec() codec.BinaryCodec + GetStoreKey() storetypes.StoreKey +} + +// MigrateStore migrates the store from v3 to v4 +// The v3 params are copied to the v4 params, and the v4 params are set in the store +// v4 params removes unused parameters from v3; these values are discarded. +// v4 introduces a new parameter, BlockRewardAmount, which is set to the default value +func MigrateStore( + ctx sdk.Context, + emissionsKeeper EmissionsKeeper, +) error { + v3Params, found := GetParamsLegacy(ctx, emissionsKeeper.GetStoreKey(), emissionsKeeper.GetCodec()) + if !found { + return errorsmod.Wrap(types.ErrMigrationFailed, "failed to get legacy params") + } + + // New params initializes v4 params with default values + v4Params := types.NewParams() + if v3Params.ValidatorEmissionPercentage != "" { + v4Params.ValidatorEmissionPercentage = v3Params.ValidatorEmissionPercentage + } + if v3Params.ObserverEmissionPercentage != "" { + v4Params.ObserverEmissionPercentage = v3Params.ObserverEmissionPercentage + } + if v3Params.TssSignerEmissionPercentage != "" { + v4Params.TssSignerEmissionPercentage = v3Params.TssSignerEmissionPercentage + } + if v3Params.ObserverSlashAmount.GTE(sdkmath.ZeroInt()) { + v4Params.ObserverSlashAmount = v3Params.ObserverSlashAmount + } + if v3Params.BallotMaturityBlocks > 0 { + v4Params.BallotMaturityBlocks = v3Params.BallotMaturityBlocks + } + + err := emissionsKeeper.SetParams(ctx, v4Params) + if err != nil { + return errorsmod.Wrap(types.ErrMigrationFailed, err.Error()) + } + return nil +} + +func GetParamsLegacy( + ctx sdk.Context, + storeKey storetypes.StoreKey, + cdc codec.BinaryCodec, +) (params types.LegacyParams, found bool) { + store := ctx.KVStore(storeKey) + bz := store.Get(types.KeyPrefix(types.ParamsKey)) + if bz == nil { + return types.LegacyParams{}, false + } + err := cdc.Unmarshal(bz, ¶ms) + if err != nil { + return types.LegacyParams{}, false + } + + return params, true +} diff --git a/x/emissions/migrations/v4/migrate_test.go b/x/emissions/migrations/v4/migrate_test.go new file mode 100644 index 0000000000..29332d3d89 --- /dev/null +++ b/x/emissions/migrations/v4/migrate_test.go @@ -0,0 +1,344 @@ +package v4_test + +import ( + "testing" + + sdkmath "cosmossdk.io/math" + "github.com/cosmos/cosmos-sdk/codec" + storetypes "github.com/cosmos/cosmos-sdk/store/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/require" + keepertest "github.com/zeta-chain/node/testutil/keeper" + v4 "github.com/zeta-chain/node/x/emissions/migrations/v4" + "github.com/zeta-chain/node/x/emissions/types" +) + +func TestMigrateStore(t *testing.T) { + t.Run("should successfully migrate to new params in mainnet", func(t *testing.T) { + //Arrange + k, ctx, _, _ := keepertest.EmissionsKeeper(t) + cdc := k.GetCodec() + emissionsStoreKey := k.GetStoreKey() + mainnetParams := LegacyMainnetParams() + err := SetLegacyParams(ctx, emissionsStoreKey, cdc, mainnetParams) + require.NoError(t, err) + + //Act + err = v4.MigrateStore(ctx, k) + require.NoError(t, err) + + //Assert + params, found := k.GetParams(ctx) + require.True(t, found) + require.Equal(t, mainnetParams.ValidatorEmissionPercentage, params.ValidatorEmissionPercentage) + require.Equal(t, mainnetParams.ObserverEmissionPercentage, params.ObserverEmissionPercentage) + require.Equal(t, mainnetParams.TssSignerEmissionPercentage, params.TssSignerEmissionPercentage) + require.Equal(t, mainnetParams.ObserverSlashAmount, params.ObserverSlashAmount) + require.Equal(t, mainnetParams.BallotMaturityBlocks, params.BallotMaturityBlocks) + require.Equal(t, types.BlockReward, params.BlockRewardAmount) + }) + + t.Run("should successfully migrate to new params in testnet", func(t *testing.T) { + //Arrange + k, ctx, _, _ := keepertest.EmissionsKeeper(t) + cdc := k.GetCodec() + emissionsStoreKey := k.GetStoreKey() + testNetParams := LegacyTestNetParams() + err := SetLegacyParams(ctx, emissionsStoreKey, cdc, testNetParams) + require.NoError(t, err) + + //Act + err = v4.MigrateStore(ctx, k) + require.NoError(t, err) + + //Assert + params, found := k.GetParams(ctx) + require.True(t, found) + require.Equal(t, testNetParams.ValidatorEmissionPercentage, params.ValidatorEmissionPercentage) + require.Equal(t, testNetParams.ObserverEmissionPercentage, params.ObserverEmissionPercentage) + require.Equal(t, testNetParams.TssSignerEmissionPercentage, params.TssSignerEmissionPercentage) + require.Equal(t, testNetParams.ObserverSlashAmount, params.ObserverSlashAmount) + require.Equal(t, testNetParams.BallotMaturityBlocks, params.BallotMaturityBlocks) + require.Equal(t, types.BlockReward, params.BlockRewardAmount) + }) + + t.Run( + "should successfully migrate using default values if legacy param for ValidatorEmissionPercentage is not available", + func(t *testing.T) { + //Arrange + k, ctx, _, _ := keepertest.EmissionsKeeper(t) + cdc := k.GetCodec() + emissionsStoreKey := k.GetStoreKey() + + mainnetParams := LegacyMainnetParams() + mainnetParams.ValidatorEmissionPercentage = "" + err := SetLegacyParams(ctx, emissionsStoreKey, cdc, mainnetParams) + require.NoError(t, err) + + //Act + err = v4.MigrateStore(ctx, k) + require.NoError(t, err) + + //Assert + defaultParams := types.DefaultParams() + params, found := k.GetParams(ctx) + require.True(t, found) + require.Equal(t, defaultParams.ValidatorEmissionPercentage, params.ValidatorEmissionPercentage) + require.Equal(t, mainnetParams.ObserverEmissionPercentage, params.ObserverEmissionPercentage) + require.Equal(t, mainnetParams.TssSignerEmissionPercentage, params.TssSignerEmissionPercentage) + require.Equal(t, mainnetParams.ObserverSlashAmount, params.ObserverSlashAmount) + require.Equal(t, mainnetParams.BallotMaturityBlocks, params.BallotMaturityBlocks) + require.Equal(t, types.BlockReward, params.BlockRewardAmount) + }, + ) + + t.Run( + "should successfully migrate using default values if legacy param for ObserverEmissionPercentage is not available", + func(t *testing.T) { + //Arrange + k, ctx, _, _ := keepertest.EmissionsKeeper(t) + cdc := k.GetCodec() + emissionsStoreKey := k.GetStoreKey() + + mainnetParams := LegacyMainnetParams() + mainnetParams.ObserverEmissionPercentage = "" + err := SetLegacyParams(ctx, emissionsStoreKey, cdc, mainnetParams) + require.NoError(t, err) + + //Act + err = v4.MigrateStore(ctx, k) + require.NoError(t, err) + + //Assert + defaultParams := types.DefaultParams() + params, found := k.GetParams(ctx) + require.True(t, found) + require.Equal(t, mainnetParams.ValidatorEmissionPercentage, params.ValidatorEmissionPercentage) + require.Equal(t, defaultParams.ObserverEmissionPercentage, params.ObserverEmissionPercentage) + require.Equal(t, mainnetParams.TssSignerEmissionPercentage, params.TssSignerEmissionPercentage) + require.Equal(t, mainnetParams.ObserverSlashAmount, params.ObserverSlashAmount) + require.Equal(t, mainnetParams.BallotMaturityBlocks, params.BallotMaturityBlocks) + require.Equal(t, types.BlockReward, params.BlockRewardAmount) + }, + ) + + t.Run( + "should successfully migrate using default values if legacy param for TssSignerEmissionPercentage is not available", + func(t *testing.T) { + //Arrange + k, ctx, _, _ := keepertest.EmissionsKeeper(t) + cdc := k.GetCodec() + emissionsStoreKey := k.GetStoreKey() + + mainnetParams := LegacyMainnetParams() + mainnetParams.TssSignerEmissionPercentage = "" + err := SetLegacyParams(ctx, emissionsStoreKey, cdc, mainnetParams) + require.NoError(t, err) + + //Act + err = v4.MigrateStore(ctx, k) + require.NoError(t, err) + + //Assert + defaultParams := types.DefaultParams() + params, found := k.GetParams(ctx) + require.True(t, found) + require.Equal(t, mainnetParams.ValidatorEmissionPercentage, params.ValidatorEmissionPercentage) + require.Equal(t, mainnetParams.ObserverEmissionPercentage, params.ObserverEmissionPercentage) + require.Equal(t, defaultParams.TssSignerEmissionPercentage, params.TssSignerEmissionPercentage) + require.Equal(t, mainnetParams.ObserverSlashAmount, params.ObserverSlashAmount) + require.Equal(t, mainnetParams.BallotMaturityBlocks, params.BallotMaturityBlocks) + require.Equal(t, types.BlockReward, params.BlockRewardAmount) + }, + ) + + t.Run( + "should successfully migrate using default values if legacy param for ObserverSlashAmount is not available", + func(t *testing.T) { + //Arrange + k, ctx, _, _ := keepertest.EmissionsKeeper(t) + cdc := k.GetCodec() + emissionsStoreKey := k.GetStoreKey() + + mainnetParams := LegacyMainnetParams() + mainnetParams.ObserverSlashAmount = sdkmath.NewInt(-1) + err := SetLegacyParams(ctx, emissionsStoreKey, cdc, mainnetParams) + require.NoError(t, err) + + //Act + err = v4.MigrateStore(ctx, k) + require.NoError(t, err) + + //Assert + defaultParams := types.DefaultParams() + params, found := k.GetParams(ctx) + require.True(t, found) + require.Equal(t, mainnetParams.ValidatorEmissionPercentage, params.ValidatorEmissionPercentage) + require.Equal(t, mainnetParams.ObserverEmissionPercentage, params.ObserverEmissionPercentage) + require.Equal(t, mainnetParams.TssSignerEmissionPercentage, params.TssSignerEmissionPercentage) + require.Equal(t, defaultParams.ObserverSlashAmount.String(), params.ObserverSlashAmount.String()) + require.Equal(t, mainnetParams.BallotMaturityBlocks, params.BallotMaturityBlocks) + require.Equal(t, types.BlockReward, params.BlockRewardAmount) + }, + ) + + t.Run( + "should successfully migrate using default values if legacy param for BallotMaturityBlocks is not available", + func(t *testing.T) { + //Arrange + k, ctx, _, _ := keepertest.EmissionsKeeper(t) + cdc := k.GetCodec() + emissionsStoreKey := k.GetStoreKey() + + mainnetParams := LegacyMainnetParams() + mainnetParams.BallotMaturityBlocks = -1 + err := SetLegacyParams(ctx, emissionsStoreKey, cdc, mainnetParams) + require.NoError(t, err) + + //Act + err = v4.MigrateStore(ctx, k) + require.NoError(t, err) + + //Assert + defaultParams := types.DefaultParams() + params, found := k.GetParams(ctx) + require.True(t, found) + require.Equal(t, mainnetParams.ValidatorEmissionPercentage, params.ValidatorEmissionPercentage) + require.Equal(t, mainnetParams.ObserverEmissionPercentage, params.ObserverEmissionPercentage) + require.Equal(t, mainnetParams.TssSignerEmissionPercentage, params.TssSignerEmissionPercentage) + require.Equal(t, mainnetParams.ObserverSlashAmount, params.ObserverSlashAmount) + require.Equal(t, defaultParams.BallotMaturityBlocks, params.BallotMaturityBlocks) + require.Equal(t, types.BlockReward, params.BlockRewardAmount) + }, + ) + + t.Run("fail to migrate if legacy params are not found", func(t *testing.T) { + //Arrange + k, ctx, _, _ := keepertest.EmissionsKeeper(t) + store := ctx.KVStore(k.GetStoreKey()) + store.Delete(types.KeyPrefix(types.ParamsKey)) + + //Act + err := v4.MigrateStore(ctx, k) + + //Assert + require.ErrorIs(t, err, types.ErrMigrationFailed) + require.ErrorContains(t, err, "failed to get legacy params") + }) + + // This scenario is hypothetical as the legacy params have valid values. + t.Run("fail to migrate if params are not valid", func(t *testing.T) { + //Arrange + k, ctx, _, _ := keepertest.EmissionsKeeper(t) + cdc := k.GetCodec() + emissionsStoreKey := k.GetStoreKey() + mainnetParams := LegacyMainnetParams() + mainnetParams.TssSignerEmissionPercentage = "2.0" + err := SetLegacyParams(ctx, emissionsStoreKey, cdc, mainnetParams) + require.NoError(t, err) + + //Act + err = v4.MigrateStore(ctx, k) + + //Assert + require.ErrorIs(t, err, types.ErrMigrationFailed) + require.ErrorContains(t, err, "tss emission percentage cannot be more than 100 percent") + }) +} + +func TestGetParamsLegacy(t *testing.T) { + t.Run("should successfully get legacy params", func(t *testing.T) { + //Arrange + k, ctx, _, _ := keepertest.EmissionsKeeper(t) + cdc := k.GetCodec() + emissionsStoreKey := k.GetStoreKey() + mainnetParams := LegacyMainnetParams() + err := SetLegacyParams(ctx, emissionsStoreKey, cdc, mainnetParams) + require.NoError(t, err) + + //Act + params, found := v4.GetParamsLegacy(ctx, emissionsStoreKey, cdc) + + //Assert + require.True(t, found) + require.Equal(t, mainnetParams, params) + }) + + t.Run("should return false if legacy params are not found", func(t *testing.T) { + //Arrange + k, ctx, _, _ := keepertest.EmissionsKeeper(t) + store := ctx.KVStore(k.GetStoreKey()) + store.Delete(types.KeyPrefix(types.ParamsKey)) + + //Act + params, found := v4.GetParamsLegacy(ctx, k.GetStoreKey(), k.GetCodec()) + + //Assert + require.False(t, found) + require.Equal(t, types.LegacyParams{}, params) + }) + + t.Run("should return false if unable to unmarshal legacy params", func(t *testing.T) { + //Arrange + k, ctx, _, _ := keepertest.EmissionsKeeper(t) + cdc := k.GetCodec() + emissionsStoreKey := k.GetStoreKey() + store := ctx.KVStore(emissionsStoreKey) + store.Set(types.KeyPrefix(types.ParamsKey), []byte{0x00}) + + //Act + params, found := v4.GetParamsLegacy(ctx, emissionsStoreKey, cdc) + + //Assert + require.False(t, found) + require.Equal(t, types.LegacyParams{}, params) + }) +} + +func SetLegacyParams( + ctx sdk.Context, + storeKey storetypes.StoreKey, + cdc codec.BinaryCodec, + params types.LegacyParams, +) error { + store := ctx.KVStore(storeKey) + bz, err := cdc.Marshal(¶ms) + if err != nil { + return err + } + + store.Set(types.KeyPrefix(types.ParamsKey), bz) + return nil +} + +// https://zetachain-api.lavenderfive.com/zeta-chain/emissions/params +func LegacyMainnetParams() types.LegacyParams { + return types.LegacyParams{ + MaxBondFactor: "1.25", + MinBondFactor: "0.75", + AvgBlockTime: "6.00", + TargetBondRatio: "0.67", + ObserverEmissionPercentage: "0.125", + ValidatorEmissionPercentage: "0.75", + TssSignerEmissionPercentage: "0.125", + DurationFactorConstant: "0.001877876953694702", + ObserverSlashAmount: sdkmath.NewIntFromUint64(100000000000000000), + BallotMaturityBlocks: 100, + } +} + +// https://zetachain-testnet-api.itrocket.net/zeta-chain/emissions/params +func LegacyTestNetParams() types.LegacyParams { + return types.LegacyParams{ + MaxBondFactor: "1.25", + MinBondFactor: "0.75", + AvgBlockTime: "6.00", + TargetBondRatio: "0.67", + ObserverEmissionPercentage: "0.05", + ValidatorEmissionPercentage: "0.90", + TssSignerEmissionPercentage: "0.05", + DurationFactorConstant: "0.001877876953694702", + ObserverSlashAmount: sdkmath.NewIntFromUint64(100000000000000000), + BallotMaturityBlocks: 100, + } +} diff --git a/x/emissions/module.go b/x/emissions/module.go index ee739b615f..08676efb54 100644 --- a/x/emissions/module.go +++ b/x/emissions/module.go @@ -132,6 +132,9 @@ func (am AppModule) RegisterServices(cfg module.Configurator) { if err := cfg.RegisterMigration(types.ModuleName, 2, m.Migrate2to3); err != nil { panic(err) } + if err := cfg.RegisterMigration(types.ModuleName, 3, m.Migrate3to4); err != nil { + panic(err) + } } // RegisterInvariants registers the emissions module's invariants. @@ -160,7 +163,7 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw } // ConsensusVersion implements ConsensusVersion. -func (AppModule) ConsensusVersion() uint64 { return 3 } +func (AppModule) ConsensusVersion() uint64 { return 4 } // BeginBlock executes all ABCI BeginBlock logic respective to the emissions module. func (am AppModule) BeginBlock(ctx sdk.Context, _ abci.RequestBeginBlock) { diff --git a/x/emissions/types/distributions.go b/x/emissions/types/distributions.go index fb67135ea9..a370fd8e2e 100644 --- a/x/emissions/types/distributions.go +++ b/x/emissions/types/distributions.go @@ -9,25 +9,29 @@ import ( // for validators, observers and TSS signers // If the percentage is not set, it returns 0 func GetRewardsDistributions(params Params) (sdkmath.Int, sdkmath.Int, sdkmath.Int) { + // We do not need to validate params here, + // as we can assume that the params have been validated before setting the values. + blockReward := params.BlockRewardAmount + // Fetch the validator rewards, use 0 if the percentage is not set validatorRewards := sdk.NewInt(0) validatorRewardsDec, err := sdk.NewDecFromStr(params.ValidatorEmissionPercentage) if err == nil { - validatorRewards = validatorRewardsDec.Mul(BlockReward).TruncateInt() + validatorRewards = validatorRewardsDec.Mul(blockReward).TruncateInt() } // Fetch the observer rewards, use 0 if the percentage is not set observerRewards := sdk.NewInt(0) observerRewardsDec, err := sdk.NewDecFromStr(params.ObserverEmissionPercentage) if err == nil { - observerRewards = observerRewardsDec.Mul(BlockReward).TruncateInt() + observerRewards = observerRewardsDec.Mul(blockReward).TruncateInt() } // Fetch the TSS signer rewards, use 0 if the percentage is not set tssSignerRewards := sdk.NewInt(0) tssSignerRewardsDec, err := sdk.NewDecFromStr(params.TssSignerEmissionPercentage) if err == nil { - tssSignerRewards = tssSignerRewardsDec.Mul(BlockReward).TruncateInt() + tssSignerRewards = tssSignerRewardsDec.Mul(blockReward).TruncateInt() } return validatorRewards, observerRewards, tssSignerRewards diff --git a/x/emissions/types/distributions_test.go b/x/emissions/types/distributions_test.go index 1ab6649b8a..7d46012da2 100644 --- a/x/emissions/types/distributions_test.go +++ b/x/emissions/types/distributions_test.go @@ -10,11 +10,11 @@ import ( func TestKeeper_GetRewardsDistributions(t *testing.T) { t.Run("Return fractions of block reward", func(t *testing.T) { - val, obs, tss := types.GetRewardsDistributions(types.Params{ - ValidatorEmissionPercentage: "0.5", - ObserverEmissionPercentage: "0.25", - TssSignerEmissionPercentage: "0.25", - }) + params := types.NewParams() + params.ValidatorEmissionPercentage = "0.5" + params.ObserverEmissionPercentage = "0.25" + params.TssSignerEmissionPercentage = "0.25" + val, obs, tss := types.GetRewardsDistributions(params) require.EqualValues(t, "4810474537037037037", val.String()) // 0.5 * block reward require.EqualValues(t, "2405237268518518518", obs.String()) // 0.25 * block reward diff --git a/x/emissions/types/errors.go b/x/emissions/types/errors.go index 2c7174b94a..3107f8b8b5 100644 --- a/x/emissions/types/errors.go +++ b/x/emissions/types/errors.go @@ -13,4 +13,5 @@ var ( ) ErrInvalidAmount = errorsmod.Register(ModuleName, 1005, "invalid amount") ErrUnableToSetParams = errorsmod.Register(ModuleName, 1006, "unable to set params") + ErrMigrationFailed = errorsmod.Register(ModuleName, 1007, "migration failed") ) diff --git a/x/emissions/types/keys.go b/x/emissions/types/keys.go index bcf602b6c8..0c71be1284 100644 --- a/x/emissions/types/keys.go +++ b/x/emissions/types/keys.go @@ -24,14 +24,7 @@ const ( // MemStoreKey defines the in-memory store key MemStoreKey = "mem_emissions" WithdrawableEmissionsKey = "WithdrawableEmissions-value-" - - SecsInMonth = 30 * 24 * 60 * 60 - BlockRewardsInZeta = "210000000" - - EmissionScheduledYears = 4 - AvgBlockTime = "5.7" - - ParamsKey = "Params-value-" + ParamsKey = "Params-value-" ) func KeyPrefix(p string) []byte { @@ -40,14 +33,9 @@ func KeyPrefix(p string) []byte { const ( EmissionsTrackerKey = "EmissionsTracker-value-" - ParamMaxBondFactor = "MaxBondFactor" - ParamMinBondFactor = "MinBondFactor" - ParamAvgBlockTime = "AvgBlockTime" - ParamTargetBondRatio = "TargetBondRation" ParamValidatorEmissionPercentage = "ValidatorEmissionPercentage" ParamObserverEmissionPercentage = "ObserverEmissionPercentage" ParamTssSignerEmissionPercentage = "SignerEmissionPercentage" - ParamDurationFactorConstant = "DurationFactorConstant" ParamObserverSlashAmount = "ObserverSlashAmount" ) @@ -55,7 +43,9 @@ var ( EmissionsModuleAddress = authtypes.NewModuleAddress(ModuleName) UndistributedObserverRewardsPoolAddress = authtypes.NewModuleAddress(UndistributedObserverRewardsPool) UndistributedTssRewardsPoolAddress = authtypes.NewModuleAddress(UndistributedTssRewardsPool) - BlockReward = sdk.MustNewDecFromStr("9620949074074074074.074070733466756687") + // BlockReward is an initial block reward amount when emissions module was initialized. + // The current value can be obtained from by querying the params + BlockReward = sdk.MustNewDecFromStr("9620949074074074074.074070733466756687") // ObserverSlashAmount is the amount of tokens to be slashed from observer in case of incorrect vote // by default it is set to 0.1 ZETA ObserverSlashAmount = sdkmath.NewInt(100000000000000000) diff --git a/x/emissions/types/legacy_params.go b/x/emissions/types/legacy_params.go new file mode 100644 index 0000000000..3e9f52629c --- /dev/null +++ b/x/emissions/types/legacy_params.go @@ -0,0 +1,11 @@ +package types + +import "gopkg.in/yaml.v2" + +func (m *LegacyParams) String() string { + out, err := yaml.Marshal(m) + if err != nil { + return "" + } + return string(out) +} diff --git a/x/emissions/types/legacy_params_test.go b/x/emissions/types/legacy_params_test.go new file mode 100644 index 0000000000..8f5689ae30 --- /dev/null +++ b/x/emissions/types/legacy_params_test.go @@ -0,0 +1,30 @@ +package types_test + +import ( + "testing" + + sdkmath "cosmossdk.io/math" + "github.com/stretchr/testify/require" + "github.com/zeta-chain/node/x/emissions/types" + "gopkg.in/yaml.v2" +) + +func TestLegacyString(t *testing.T) { + t.Run("should return correct string representation of legacy params", func(t *testing.T) { + params := types.LegacyParams{ + MaxBondFactor: "1.25", + MinBondFactor: "0.75", + AvgBlockTime: "6.00", + TargetBondRatio: "0.67", + ObserverEmissionPercentage: "0.125", + ValidatorEmissionPercentage: "0.75", + TssSignerEmissionPercentage: "0.125", + DurationFactorConstant: "0.001877876953694702", + ObserverSlashAmount: sdkmath.NewIntFromUint64(100000000000000000), + BallotMaturityBlocks: 100, + } + out, err := yaml.Marshal(params) + require.NoError(t, err) + require.Equal(t, string(out), params.String()) + }) +} diff --git a/x/emissions/types/message_update_params_test.go b/x/emissions/types/message_update_params_test.go index 44b37e8fa2..cf02f19000 100644 --- a/x/emissions/types/message_update_params_test.go +++ b/x/emissions/types/message_update_params_test.go @@ -23,13 +23,13 @@ func TestMsgUpdateParams_ValidateBasic(t *testing.T) { t.Run("invalid if params are invalid", func(t *testing.T) { params := types.NewParams() - params.MaxBondFactor = "1.50" + params.BlockRewardAmount = sdk.MustNewDecFromStr("-10.0") msg := types.MsgUpdateParams{ Authority: sample.AccAddress(), Params: params, } err := msg.ValidateBasic() - require.ErrorContains(t, err, "max bond factor cannot be higher that 1.25") + require.ErrorContains(t, err, "block reward amount cannot be less than 0") }) t.Run("valid", func(t *testing.T) { diff --git a/x/emissions/types/params.go b/x/emissions/types/params.go index 23899a4d5c..715c615b9d 100644 --- a/x/emissions/types/params.go +++ b/x/emissions/types/params.go @@ -2,7 +2,6 @@ package types import ( "fmt" - "strconv" sdkmath "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" @@ -12,16 +11,12 @@ import ( // NewParams creates a new Params instance func NewParams() Params { return Params{ - MaxBondFactor: "1.25", - MinBondFactor: "0.75", - AvgBlockTime: "6.00", - TargetBondRatio: "00.67", ValidatorEmissionPercentage: "00.50", ObserverEmissionPercentage: "00.25", TssSignerEmissionPercentage: "00.25", - DurationFactorConstant: "0.001877876953694702", - ObserverSlashAmount: sdkmath.NewInt(100000000000000000), - BallotMaturityBlocks: 100, + ObserverSlashAmount: ObserverSlashAmount, + BallotMaturityBlocks: int64(BallotMaturityBlocks), + BlockRewardAmount: BlockReward, } } @@ -32,18 +27,6 @@ func DefaultParams() Params { // Validate validates the set of params func (p Params) Validate() error { - if err := validateMaxBondFactor(p.MaxBondFactor); err != nil { - return err - } - if err := validateMinBondFactor(p.MinBondFactor); err != nil { - return err - } - if err := validateAvgBlockTime(p.AvgBlockTime); err != nil { - return err - } - if err := validateTargetBondRatio(p.TargetBondRatio); err != nil { - return err - } if err := validateValidatorEmissionPercentage(p.ValidatorEmissionPercentage); err != nil { return err } @@ -56,46 +39,10 @@ func (p Params) Validate() error { if err := validateBallotMaturityBlocks(p.BallotMaturityBlocks); err != nil { return err } - return validateObserverSlashAmount(p.ObserverSlashAmount) -} - -func (p Params) GetBondFactor(currentBondedRatio sdk.Dec) sdk.Dec { - targetBondRatio := sdk.MustNewDecFromStr(p.TargetBondRatio) - maxBondFactor := sdk.MustNewDecFromStr(p.MaxBondFactor) - minBondFactor := sdk.MustNewDecFromStr(p.MinBondFactor) - - // Bond factor ranges between minBondFactor (0.75) to maxBondFactor (1.25) - if currentBondedRatio.IsZero() { - return sdk.ZeroDec() - } - bondFactor := targetBondRatio.Quo(currentBondedRatio) - if bondFactor.GT(maxBondFactor) { - return maxBondFactor - } - if bondFactor.LT(minBondFactor) { - return minBondFactor - } - return bondFactor -} - -func (p Params) GetDurationFactor(blockHeight int64) sdk.Dec { - avgBlockTime := sdk.MustNewDecFromStr(p.AvgBlockTime) - NumberOfBlocksInAMonth := sdk.NewDec(SecsInMonth).Quo(avgBlockTime) - monthFactor := sdk.NewDec(blockHeight).Quo(NumberOfBlocksInAMonth) - logValueDec := sdk.MustNewDecFromStr(p.DurationFactorConstant) - // month * log(1 + 0.02 / 12) - fractionNumerator := monthFactor.Mul(logValueDec) - // (month * log(1 + 0.02 / 12) ) + 1 - fractionDenominator := fractionNumerator.Add(sdk.OneDec()) - - // (month * log(1 + 0.02 / 12)) / (month * log(1 + 0.02 / 12) ) + 1 - if fractionDenominator.IsZero() { - return sdk.OneDec() - } - if fractionNumerator.IsZero() { - return sdk.ZeroDec() + if err := validateBlockRewardsAmount(p.BlockRewardAmount); err != nil { + return err } - return fractionNumerator.Quo(fractionDenominator) + return validateObserverSlashAmount(p.ObserverSlashAmount) } // String implements the Stringer interface. @@ -107,68 +54,6 @@ func (p Params) String() string { return string(out) } -func validateDurationFactorConstant(i interface{}) error { - _, ok := i.(string) - if !ok { - return fmt.Errorf("invalid parameter type: %T", i) - } - return nil -} - -func validateMaxBondFactor(i interface{}) error { - v, ok := i.(string) - if !ok { - return fmt.Errorf("invalid parameter type: %T", i) - } - decMaxBond := sdk.MustNewDecFromStr(v) - if decMaxBond.GT(sdk.MustNewDecFromStr("1.25")) { - return fmt.Errorf("max bond factor cannot be higher that 1.25") - } - return nil -} - -func validateMinBondFactor(i interface{}) error { - v, ok := i.(string) - if !ok { - return fmt.Errorf("invalid parameter type: %T", i) - } - decMaxBond := sdk.MustNewDecFromStr(v) - if decMaxBond.LT(sdk.MustNewDecFromStr("0.75")) { - return fmt.Errorf("min bond factor cannot be lower that 0.75") - } - return nil -} - -func validateAvgBlockTime(i interface{}) error { - v, ok := i.(string) - if !ok { - return fmt.Errorf("invalid parameter type: %T", i) - } - blocktime, err := strconv.ParseFloat(v, 64) - if err != nil { - return fmt.Errorf("invalid block time: %T", i) - } - if blocktime <= 0 { - return fmt.Errorf("block time cannot be less than or equal to 0") - } - return nil -} - -func validateTargetBondRatio(i interface{}) error { - v, ok := i.(string) - if !ok { - return fmt.Errorf("invalid parameter type: %T", i) - } - decMaxBond := sdk.MustNewDecFromStr(v) - if decMaxBond.GT(sdk.OneDec()) { - return fmt.Errorf("target bond ratio cannot be more than 100 percent") - } - if decMaxBond.LT(sdk.ZeroDec()) { - return fmt.Errorf("target bond ratio cannot be less than 0 percent") - } - return nil -} - func validateValidatorEmissionPercentage(i interface{}) error { v, ok := i.(string) if !ok { @@ -237,3 +122,14 @@ func validateBallotMaturityBlocks(i interface{}) error { return nil } + +func validateBlockRewardsAmount(i interface{}) error { + v, ok := i.(sdkmath.LegacyDec) + if !ok { + return fmt.Errorf("invalid parameter type: %T", i) + } + if v.LT(sdkmath.LegacyZeroDec()) { + return fmt.Errorf("block reward amount cannot be less than 0") + } + return nil +} diff --git a/x/emissions/types/params.pb.go b/x/emissions/types/params.pb.go index 5d73389603..dbd7ee3ad3 100644 --- a/x/emissions/types/params.pb.go +++ b/x/emissions/types/params.pb.go @@ -25,17 +25,21 @@ var _ = math.Inf const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // Params defines the parameters for the module. +// Sample values: +// +// ValidatorEmissionPercentage: "00.50", +// ObserverEmissionPercentage: "00.25", +// TssSignerEmissionPercentage: "00.25", +// ObserverSlashAmount: 100000000000000000, +// BallotMaturityBlocks: 100, +// BlockRewardAmount: 9620949074074074074.074070733466756687, type Params struct { - MaxBondFactor string `protobuf:"bytes,1,opt,name=max_bond_factor,json=maxBondFactor,proto3" json:"max_bond_factor,omitempty"` - MinBondFactor string `protobuf:"bytes,2,opt,name=min_bond_factor,json=minBondFactor,proto3" json:"min_bond_factor,omitempty"` - AvgBlockTime string `protobuf:"bytes,3,opt,name=avg_block_time,json=avgBlockTime,proto3" json:"avg_block_time,omitempty"` - TargetBondRatio string `protobuf:"bytes,4,opt,name=target_bond_ratio,json=targetBondRatio,proto3" json:"target_bond_ratio,omitempty"` ValidatorEmissionPercentage string `protobuf:"bytes,5,opt,name=validator_emission_percentage,json=validatorEmissionPercentage,proto3" json:"validator_emission_percentage,omitempty"` ObserverEmissionPercentage string `protobuf:"bytes,6,opt,name=observer_emission_percentage,json=observerEmissionPercentage,proto3" json:"observer_emission_percentage,omitempty"` TssSignerEmissionPercentage string `protobuf:"bytes,7,opt,name=tss_signer_emission_percentage,json=tssSignerEmissionPercentage,proto3" json:"tss_signer_emission_percentage,omitempty"` - DurationFactorConstant string `protobuf:"bytes,8,opt,name=duration_factor_constant,json=durationFactorConstant,proto3" json:"duration_factor_constant,omitempty"` ObserverSlashAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,9,opt,name=observer_slash_amount,json=observerSlashAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"observer_slash_amount"` BallotMaturityBlocks int64 `protobuf:"varint,10,opt,name=ballot_maturity_blocks,json=ballotMaturityBlocks,proto3" json:"ballot_maturity_blocks,omitempty"` + BlockRewardAmount github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,11,opt,name=block_reward_amount,json=blockRewardAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"block_reward_amount"` } func (m *Params) Reset() { *m = Params{} } @@ -70,63 +74,137 @@ func (m *Params) XXX_DiscardUnknown() { var xxx_messageInfo_Params proto.InternalMessageInfo -func (m *Params) GetMaxBondFactor() string { +func (m *Params) GetValidatorEmissionPercentage() string { + if m != nil { + return m.ValidatorEmissionPercentage + } + return "" +} + +func (m *Params) GetObserverEmissionPercentage() string { + if m != nil { + return m.ObserverEmissionPercentage + } + return "" +} + +func (m *Params) GetTssSignerEmissionPercentage() string { + if m != nil { + return m.TssSignerEmissionPercentage + } + return "" +} + +func (m *Params) GetBallotMaturityBlocks() int64 { + if m != nil { + return m.BallotMaturityBlocks + } + return 0 +} + +// Deprecated (v20): Do not use. Use Params Instead +type LegacyParams struct { + MaxBondFactor string `protobuf:"bytes,1,opt,name=max_bond_factor,json=maxBondFactor,proto3" json:"max_bond_factor,omitempty"` + MinBondFactor string `protobuf:"bytes,2,opt,name=min_bond_factor,json=minBondFactor,proto3" json:"min_bond_factor,omitempty"` + AvgBlockTime string `protobuf:"bytes,3,opt,name=avg_block_time,json=avgBlockTime,proto3" json:"avg_block_time,omitempty"` + TargetBondRatio string `protobuf:"bytes,4,opt,name=target_bond_ratio,json=targetBondRatio,proto3" json:"target_bond_ratio,omitempty"` + ValidatorEmissionPercentage string `protobuf:"bytes,5,opt,name=validator_emission_percentage,json=validatorEmissionPercentage,proto3" json:"validator_emission_percentage,omitempty"` + ObserverEmissionPercentage string `protobuf:"bytes,6,opt,name=observer_emission_percentage,json=observerEmissionPercentage,proto3" json:"observer_emission_percentage,omitempty"` + TssSignerEmissionPercentage string `protobuf:"bytes,7,opt,name=tss_signer_emission_percentage,json=tssSignerEmissionPercentage,proto3" json:"tss_signer_emission_percentage,omitempty"` + DurationFactorConstant string `protobuf:"bytes,8,opt,name=duration_factor_constant,json=durationFactorConstant,proto3" json:"duration_factor_constant,omitempty"` + ObserverSlashAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,9,opt,name=observer_slash_amount,json=observerSlashAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"observer_slash_amount"` + BallotMaturityBlocks int64 `protobuf:"varint,10,opt,name=ballot_maturity_blocks,json=ballotMaturityBlocks,proto3" json:"ballot_maturity_blocks,omitempty"` +} + +func (m *LegacyParams) Reset() { *m = LegacyParams{} } +func (*LegacyParams) ProtoMessage() {} +func (*LegacyParams) Descriptor() ([]byte, []int) { + return fileDescriptor_259272924aec0acf, []int{1} +} +func (m *LegacyParams) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *LegacyParams) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_LegacyParams.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *LegacyParams) XXX_Merge(src proto.Message) { + xxx_messageInfo_LegacyParams.Merge(m, src) +} +func (m *LegacyParams) XXX_Size() int { + return m.Size() +} +func (m *LegacyParams) XXX_DiscardUnknown() { + xxx_messageInfo_LegacyParams.DiscardUnknown(m) +} + +var xxx_messageInfo_LegacyParams proto.InternalMessageInfo + +func (m *LegacyParams) GetMaxBondFactor() string { if m != nil { return m.MaxBondFactor } return "" } -func (m *Params) GetMinBondFactor() string { +func (m *LegacyParams) GetMinBondFactor() string { if m != nil { return m.MinBondFactor } return "" } -func (m *Params) GetAvgBlockTime() string { +func (m *LegacyParams) GetAvgBlockTime() string { if m != nil { return m.AvgBlockTime } return "" } -func (m *Params) GetTargetBondRatio() string { +func (m *LegacyParams) GetTargetBondRatio() string { if m != nil { return m.TargetBondRatio } return "" } -func (m *Params) GetValidatorEmissionPercentage() string { +func (m *LegacyParams) GetValidatorEmissionPercentage() string { if m != nil { return m.ValidatorEmissionPercentage } return "" } -func (m *Params) GetObserverEmissionPercentage() string { +func (m *LegacyParams) GetObserverEmissionPercentage() string { if m != nil { return m.ObserverEmissionPercentage } return "" } -func (m *Params) GetTssSignerEmissionPercentage() string { +func (m *LegacyParams) GetTssSignerEmissionPercentage() string { if m != nil { return m.TssSignerEmissionPercentage } return "" } -func (m *Params) GetDurationFactorConstant() string { +func (m *LegacyParams) GetDurationFactorConstant() string { if m != nil { return m.DurationFactorConstant } return "" } -func (m *Params) GetBallotMaturityBlocks() int64 { +func (m *LegacyParams) GetBallotMaturityBlocks() int64 { if m != nil { return m.BallotMaturityBlocks } @@ -135,6 +213,7 @@ func (m *Params) GetBallotMaturityBlocks() int64 { func init() { proto.RegisterType((*Params)(nil), "zetachain.zetacore.emissions.Params") + proto.RegisterType((*LegacyParams)(nil), "zetachain.zetacore.emissions.LegacyParams") } func init() { @@ -142,37 +221,40 @@ func init() { } var fileDescriptor_259272924aec0acf = []byte{ - // 465 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x92, 0xcd, 0x6a, 0x14, 0x41, - 0x10, 0x80, 0x77, 0xcc, 0xba, 0x9a, 0x46, 0x0d, 0x8e, 0x31, 0x0c, 0x31, 0xce, 0x06, 0x91, 0x10, - 0xc5, 0xcc, 0x1c, 0xf4, 0x20, 0x9e, 0x74, 0x82, 0x01, 0x0f, 0x42, 0xd8, 0x78, 0xf2, 0xd2, 0xf4, - 0xcc, 0xb4, 0xb3, 0x4d, 0xa6, 0xbb, 0x96, 0xae, 0xda, 0x65, 0xe3, 0x53, 0x78, 0xf4, 0xe8, 0xe3, - 0xe4, 0x66, 0x8e, 0xe2, 0x21, 0xc8, 0xee, 0x8b, 0xc8, 0xf4, 0xfc, 0xb0, 0xc2, 0x7a, 0xea, 0xa6, - 0xea, 0xab, 0x8f, 0xaa, 0xee, 0x62, 0xcf, 0xbe, 0x4a, 0x12, 0xd9, 0x58, 0x28, 0x13, 0xbb, 0x1b, - 0x58, 0x19, 0x4b, 0xad, 0x10, 0x15, 0x18, 0x8c, 0x27, 0xc2, 0x0a, 0x8d, 0xd1, 0xc4, 0x02, 0x81, - 0xbf, 0xd7, 0xa1, 0x51, 0x8b, 0x46, 0x1d, 0xba, 0xbb, 0x5d, 0x40, 0x01, 0x0e, 0x8c, 0xab, 0x5b, - 0x5d, 0xf3, 0xe4, 0x67, 0x9f, 0x0d, 0x4e, 0x9d, 0xc4, 0x3f, 0x60, 0x5b, 0x5a, 0xcc, 0x79, 0x0a, - 0x26, 0xe7, 0x5f, 0x44, 0x46, 0x60, 0x03, 0x6f, 0xdf, 0x3b, 0xdc, 0x1c, 0xdd, 0xd5, 0x62, 0x9e, - 0x80, 0xc9, 0x4f, 0x5c, 0xd0, 0x71, 0xca, 0xfc, 0xc3, 0xdd, 0x68, 0x38, 0x65, 0x56, 0xb8, 0xa7, - 0xec, 0x9e, 0x98, 0x15, 0x3c, 0x2d, 0x21, 0x3b, 0xe7, 0xa4, 0xb4, 0x0c, 0x36, 0x1c, 0x76, 0x47, - 0xcc, 0x8a, 0xa4, 0x0a, 0x7e, 0x52, 0x5a, 0xfa, 0xcf, 0xd9, 0x7d, 0x12, 0xb6, 0x90, 0x54, 0x0b, - 0xad, 0x20, 0x05, 0x41, 0xdf, 0x81, 0x5b, 0x75, 0xa2, 0x52, 0x8e, 0xaa, 0xb0, 0x9f, 0xb0, 0xc7, - 0x33, 0x51, 0xaa, 0x5c, 0x10, 0x58, 0xde, 0x4e, 0xc6, 0x27, 0xd2, 0x66, 0xd2, 0x90, 0x28, 0x64, - 0x70, 0xd3, 0xd5, 0x3d, 0xea, 0xa0, 0xf7, 0x0d, 0x73, 0xda, 0x21, 0xfe, 0x5b, 0xb6, 0x07, 0x29, - 0x4a, 0x3b, 0x93, 0xeb, 0x15, 0x03, 0xa7, 0xd8, 0x6d, 0x99, 0x35, 0x86, 0x63, 0x16, 0x12, 0x22, - 0x47, 0x55, 0x98, 0xff, 0x38, 0x6e, 0xd5, 0x6d, 0x10, 0xe2, 0x99, 0x83, 0xd6, 0x48, 0x5e, 0xb3, - 0x20, 0x9f, 0xba, 0x61, 0x4d, 0xf3, 0x88, 0x3c, 0x03, 0x83, 0x24, 0x0c, 0x05, 0xb7, 0x5d, 0xf9, - 0x4e, 0x9b, 0xaf, 0x9f, 0xf3, 0xb8, 0xc9, 0xfa, 0x29, 0x7b, 0xd8, 0x0d, 0x80, 0xa5, 0xc0, 0x31, - 0x17, 0x1a, 0xa6, 0x86, 0x82, 0xcd, 0xaa, 0x2c, 0x89, 0x2e, 0xaf, 0x87, 0xbd, 0xdf, 0xd7, 0xc3, - 0x83, 0x42, 0xd1, 0x78, 0x9a, 0x46, 0x19, 0xe8, 0x38, 0x03, 0xd4, 0x80, 0xcd, 0x71, 0x84, 0xf9, - 0x79, 0x4c, 0x17, 0x13, 0x89, 0xd1, 0x07, 0x43, 0xa3, 0x07, 0xad, 0xec, 0xac, 0x72, 0xbd, 0x73, - 0x2a, 0xff, 0x15, 0xdb, 0x49, 0x45, 0x59, 0x02, 0x71, 0x2d, 0x68, 0x6a, 0x15, 0x5d, 0xd4, 0xdf, - 0x88, 0x01, 0xdb, 0xf7, 0x0e, 0x37, 0x46, 0xdb, 0x75, 0xf6, 0x63, 0x93, 0x74, 0xbf, 0x89, 0x6f, - 0xfa, 0xdf, 0x7f, 0x0c, 0x7b, 0xc9, 0xc9, 0xe5, 0x22, 0xf4, 0xae, 0x16, 0xa1, 0xf7, 0x67, 0x11, - 0x7a, 0xdf, 0x96, 0x61, 0xef, 0x6a, 0x19, 0xf6, 0x7e, 0x2d, 0xc3, 0xde, 0xe7, 0x17, 0x2b, 0x2d, - 0x55, 0x0b, 0x7a, 0x54, 0xaf, 0xb5, 0x81, 0x5c, 0xc6, 0xf3, 0x95, 0xa5, 0x76, 0xcd, 0xa5, 0x03, - 0xb7, 0xa0, 0x2f, 0xff, 0x06, 0x00, 0x00, 0xff, 0xff, 0xee, 0x18, 0x01, 0xa3, 0x01, 0x03, 0x00, - 0x00, + // 528 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xdc, 0x94, 0xcf, 0x6f, 0xd3, 0x30, + 0x14, 0xc7, 0x1b, 0xda, 0x95, 0xd6, 0x0c, 0xb6, 0x65, 0x63, 0x8a, 0xc6, 0x48, 0xa7, 0x09, 0x4d, + 0x03, 0xb1, 0xe4, 0x00, 0x07, 0xc4, 0x09, 0x3a, 0x98, 0xc4, 0x04, 0xd2, 0x94, 0x71, 0xe2, 0x80, + 0xf5, 0x92, 0x98, 0xd4, 0x5a, 0x63, 0x57, 0xb6, 0x5b, 0x5a, 0xfe, 0x0a, 0x8e, 0x1c, 0xf9, 0x73, + 0x76, 0xdc, 0x05, 0x09, 0x71, 0x18, 0xa8, 0xfd, 0x47, 0x50, 0x5e, 0x7e, 0xa8, 0x48, 0xe5, 0xc0, + 0x0d, 0xed, 0x14, 0xcb, 0xef, 0xf3, 0x3e, 0xfa, 0xda, 0xb1, 0x1e, 0xb9, 0xff, 0x89, 0x19, 0x88, + 0x7a, 0xc0, 0x85, 0x8f, 0x2b, 0xa9, 0x98, 0xcf, 0x52, 0xae, 0x35, 0x97, 0x42, 0xfb, 0x03, 0x50, + 0x90, 0x6a, 0x6f, 0xa0, 0xa4, 0x91, 0xf6, 0x76, 0x85, 0x7a, 0x25, 0xea, 0x55, 0xe8, 0xd6, 0x46, + 0x22, 0x13, 0x89, 0xa0, 0x9f, 0xad, 0xf2, 0x9e, 0xdd, 0x9f, 0x75, 0xd2, 0x3c, 0x41, 0x89, 0xdd, + 0x25, 0x77, 0x47, 0xd0, 0xe7, 0x31, 0x18, 0xa9, 0x68, 0xd9, 0x47, 0x07, 0x4c, 0x45, 0x4c, 0x18, + 0x48, 0x98, 0xb3, 0xb4, 0x63, 0xed, 0xb7, 0x83, 0x3b, 0x15, 0xf4, 0xb2, 0x60, 0x4e, 0x2a, 0xc4, + 0x7e, 0x46, 0xb6, 0x65, 0xa8, 0x99, 0x1a, 0xb1, 0xc5, 0x8a, 0x26, 0x2a, 0xb6, 0x4a, 0x66, 0x81, + 0xe1, 0x90, 0xb8, 0x46, 0x6b, 0xaa, 0x79, 0x22, 0xfe, 0xe2, 0xb8, 0x9e, 0xc7, 0x30, 0x5a, 0x9f, + 0x22, 0xb4, 0x40, 0x12, 0x92, 0xdb, 0x55, 0x0c, 0xdd, 0x07, 0xdd, 0xa3, 0x90, 0xca, 0xa1, 0x30, + 0x4e, 0x3b, 0xeb, 0xed, 0x7a, 0xe7, 0x97, 0x9d, 0xda, 0x8f, 0xcb, 0xce, 0x5e, 0xc2, 0x4d, 0x6f, + 0x18, 0x7a, 0x91, 0x4c, 0xfd, 0x48, 0xea, 0x54, 0xea, 0xe2, 0x73, 0xa0, 0xe3, 0x33, 0xdf, 0x4c, + 0x06, 0x4c, 0x7b, 0xaf, 0x84, 0x09, 0xd6, 0x4b, 0xd9, 0x69, 0xe6, 0x7a, 0x8e, 0x2a, 0xfb, 0x31, + 0xd9, 0x0c, 0xa1, 0xdf, 0x97, 0x86, 0xa6, 0x60, 0x86, 0x8a, 0x9b, 0x09, 0x0d, 0xfb, 0x32, 0x3a, + 0xd3, 0x0e, 0xd9, 0xb1, 0xf6, 0xeb, 0xc1, 0x46, 0x5e, 0x7d, 0x53, 0x14, 0xbb, 0x58, 0xb3, 0xdf, + 0x93, 0x75, 0xa4, 0xa8, 0x62, 0x1f, 0x41, 0xc5, 0x65, 0xae, 0x1b, 0xff, 0x9c, 0xeb, 0x05, 0x8b, + 0x82, 0x35, 0x54, 0x05, 0x68, 0xca, 0x53, 0x3d, 0x6d, 0x7c, 0xf9, 0xda, 0xa9, 0x1d, 0x37, 0x5a, + 0xd6, 0xea, 0xd2, 0x71, 0xa3, 0xd5, 0x5a, 0x6d, 0xef, 0x7e, 0x6b, 0x90, 0xe5, 0xd7, 0x2c, 0x81, + 0x68, 0x52, 0xfc, 0xe7, 0x3d, 0xb2, 0x92, 0xc2, 0x98, 0x86, 0x52, 0xc4, 0xf4, 0x03, 0x44, 0x46, + 0x2a, 0xc7, 0xc2, 0x2b, 0xbd, 0x99, 0xc2, 0xb8, 0x2b, 0x45, 0x7c, 0x84, 0x9b, 0xc8, 0x71, 0xf1, + 0x07, 0x77, 0xad, 0xe0, 0xb8, 0x98, 0xe3, 0xee, 0x91, 0x5b, 0x30, 0x4a, 0xf2, 0xc3, 0x53, 0xc3, + 0x53, 0xe6, 0xd4, 0x11, 0x5b, 0x86, 0x51, 0x82, 0xa7, 0x7e, 0xcb, 0x53, 0x66, 0x3f, 0x20, 0x6b, + 0x06, 0x54, 0xc2, 0x4c, 0x2e, 0x54, 0x60, 0xb8, 0x74, 0x1a, 0x08, 0xae, 0xe4, 0x85, 0x4c, 0x19, + 0x64, 0xdb, 0x57, 0xe9, 0x25, 0x3e, 0x21, 0x4e, 0x3c, 0xc4, 0xc3, 0x8a, 0xe2, 0x12, 0x69, 0x24, + 0x85, 0x36, 0x20, 0x8c, 0xd3, 0xc2, 0xf6, 0xcd, 0xb2, 0x9e, 0x5f, 0xe7, 0x61, 0x51, 0xfd, 0x7f, + 0xdf, 0x70, 0xfe, 0xc6, 0xba, 0x47, 0xe7, 0x53, 0xd7, 0xba, 0x98, 0xba, 0xd6, 0xaf, 0xa9, 0x6b, + 0x7d, 0x9e, 0xb9, 0xb5, 0x8b, 0x99, 0x5b, 0xfb, 0x3e, 0x73, 0x6b, 0xef, 0x1e, 0xce, 0x45, 0xca, + 0x06, 0xd1, 0x41, 0x3e, 0xbe, 0x84, 0x8c, 0x99, 0x3f, 0x9e, 0x1b, 0x5e, 0x18, 0x2e, 0x6c, 0xe2, + 0x20, 0x7a, 0xf4, 0x3b, 0x00, 0x00, 0xff, 0xff, 0xea, 0x36, 0x06, 0xa1, 0xe9, 0x04, 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -191,6 +273,75 @@ func (m *Params) MarshalTo(dAtA []byte) (int, error) { } func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size := m.BlockRewardAmount.Size() + i -= size + if _, err := m.BlockRewardAmount.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintParams(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x5a + if m.BallotMaturityBlocks != 0 { + i = encodeVarintParams(dAtA, i, uint64(m.BallotMaturityBlocks)) + i-- + dAtA[i] = 0x50 + } + { + size := m.ObserverSlashAmount.Size() + i -= size + if _, err := m.ObserverSlashAmount.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintParams(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x4a + if len(m.TssSignerEmissionPercentage) > 0 { + i -= len(m.TssSignerEmissionPercentage) + copy(dAtA[i:], m.TssSignerEmissionPercentage) + i = encodeVarintParams(dAtA, i, uint64(len(m.TssSignerEmissionPercentage))) + i-- + dAtA[i] = 0x3a + } + if len(m.ObserverEmissionPercentage) > 0 { + i -= len(m.ObserverEmissionPercentage) + copy(dAtA[i:], m.ObserverEmissionPercentage) + i = encodeVarintParams(dAtA, i, uint64(len(m.ObserverEmissionPercentage))) + i-- + dAtA[i] = 0x32 + } + if len(m.ValidatorEmissionPercentage) > 0 { + i -= len(m.ValidatorEmissionPercentage) + copy(dAtA[i:], m.ValidatorEmissionPercentage) + i = encodeVarintParams(dAtA, i, uint64(len(m.ValidatorEmissionPercentage))) + i-- + dAtA[i] = 0x2a + } + return len(dAtA) - i, nil +} + +func (m *LegacyParams) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *LegacyParams) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *LegacyParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -281,6 +432,34 @@ func encodeVarintParams(dAtA []byte, offset int, v uint64) int { return base } func (m *Params) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ValidatorEmissionPercentage) + if l > 0 { + n += 1 + l + sovParams(uint64(l)) + } + l = len(m.ObserverEmissionPercentage) + if l > 0 { + n += 1 + l + sovParams(uint64(l)) + } + l = len(m.TssSignerEmissionPercentage) + if l > 0 { + n += 1 + l + sovParams(uint64(l)) + } + l = m.ObserverSlashAmount.Size() + n += 1 + l + sovParams(uint64(l)) + if m.BallotMaturityBlocks != 0 { + n += 1 + sovParams(uint64(m.BallotMaturityBlocks)) + } + l = m.BlockRewardAmount.Size() + n += 1 + l + sovParams(uint64(l)) + return n +} + +func (m *LegacyParams) Size() (n int) { if m == nil { return 0 } @@ -361,6 +540,239 @@ func (m *Params) Unmarshal(dAtA []byte) error { return fmt.Errorf("proto: Params: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ValidatorEmissionPercentage", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthParams + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ValidatorEmissionPercentage = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ObserverEmissionPercentage", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthParams + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ObserverEmissionPercentage = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TssSignerEmissionPercentage", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthParams + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.TssSignerEmissionPercentage = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 9: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ObserverSlashAmount", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthParams + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.ObserverSlashAmount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 10: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field BallotMaturityBlocks", wireType) + } + m.BallotMaturityBlocks = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.BallotMaturityBlocks |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 11: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BlockRewardAmount", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthParams + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.BlockRewardAmount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipParams(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthParams + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *LegacyParams) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: LegacyParams: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: LegacyParams: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { case 1: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field MaxBondFactor", wireType) diff --git a/x/emissions/types/params_legacy.go b/x/emissions/types/params_legacy.go index 09565233a5..6dae3c3c5d 100644 --- a/x/emissions/types/params_legacy.go +++ b/x/emissions/types/params_legacy.go @@ -17,10 +17,6 @@ func ParamKeyTable() paramtypes.KeyTable { // ParamSetPairs get the params.ParamSet func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { return paramtypes.ParamSetPairs{ - paramtypes.NewParamSetPair(KeyPrefix(ParamMaxBondFactor), &p.MaxBondFactor, validateMaxBondFactor), - paramtypes.NewParamSetPair(KeyPrefix(ParamMinBondFactor), &p.MinBondFactor, validateMinBondFactor), - paramtypes.NewParamSetPair(KeyPrefix(ParamAvgBlockTime), &p.AvgBlockTime, validateAvgBlockTime), - paramtypes.NewParamSetPair(KeyPrefix(ParamTargetBondRatio), &p.TargetBondRatio, validateTargetBondRatio), paramtypes.NewParamSetPair( KeyPrefix(ParamValidatorEmissionPercentage), &p.ValidatorEmissionPercentage, @@ -36,10 +32,5 @@ func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { &p.TssSignerEmissionPercentage, validateTssEmissionPercentage, ), - paramtypes.NewParamSetPair( - KeyPrefix(ParamDurationFactorConstant), - &p.DurationFactorConstant, - validateDurationFactorConstant, - ), } } diff --git a/x/emissions/types/params_test.go b/x/emissions/types/params_test.go index a132744031..6a8e90a98b 100644 --- a/x/emissions/types/params_test.go +++ b/x/emissions/types/params_test.go @@ -4,7 +4,6 @@ import ( "testing" sdkmath "cosmossdk.io/math" - sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" "gopkg.in/yaml.v2" ) @@ -12,27 +11,17 @@ import ( func TestNewParams(t *testing.T) { params := NewParams() - // Verifying all parameters to ensure they are set correctly. - require.Equal(t, "1.25", params.MaxBondFactor, "MaxBondFactor should be set to 1.25") - require.Equal(t, "0.75", params.MinBondFactor, "MinBondFactor should be set to 0.75") - require.Equal(t, "6.00", params.AvgBlockTime, "AvgBlockTime should be set to 6.00") - require.Equal(t, "00.67", params.TargetBondRatio, "TargetBondRatio should be set to 00.67") require.Equal(t, "00.50", params.ValidatorEmissionPercentage, "ValidatorEmissionPercentage should be set to 00.50") require.Equal(t, "00.25", params.ObserverEmissionPercentage, "ObserverEmissionPercentage should be set to 00.25") require.Equal(t, "00.25", params.TssSignerEmissionPercentage, "TssSignerEmissionPercentage should be set to 00.25") - require.Equal( - t, - "0.001877876953694702", - params.DurationFactorConstant, - "DurationFactorConstant should be set to 0.001877876953694702", - ) - require.Equal( t, sdkmath.NewInt(100000000000000000), params.ObserverSlashAmount, "ObserverSlashAmount should be set to 100000000000000000", ) + require.Equal(t, int64(100), params.BallotMaturityBlocks, "BallotMaturityBlocks should be set to 100") + require.Equal(t, BlockReward, params.BlockRewardAmount, "BlockRewardAmount should be set to 0") } func TestDefaultParams(t *testing.T) { @@ -42,39 +31,6 @@ func TestDefaultParams(t *testing.T) { require.Equal(t, NewParams(), params) } -func TestValidateDurationFactorConstant(t *testing.T) { - require.NoError(t, validateDurationFactorConstant("1")) - require.Error(t, validateDurationFactorConstant(1)) -} - -func TestValidateMaxBondFactor(t *testing.T) { - require.Error(t, validateMaxBondFactor(1)) - require.NoError(t, validateMaxBondFactor("1.00")) - require.NoError(t, validateMaxBondFactor("1.25")) - require.Error(t, validateMaxBondFactor("1.30")) // Should fail as it's higher than 1.25 -} - -func TestValidateMinBondFactor(t *testing.T) { - require.Error(t, validateMinBondFactor(1)) - require.NoError(t, validateMinBondFactor("0.75")) - require.Error(t, validateMinBondFactor("0.50")) // Should fail as it's lower than 0.75 -} - -func TestValidateAvgBlockTime(t *testing.T) { - require.Error(t, validateAvgBlockTime(6)) - require.Error(t, validateAvgBlockTime("invalid")) - require.NoError(t, validateAvgBlockTime("6.00")) - require.Error(t, validateAvgBlockTime("-1")) // Negative time should fail - require.Error(t, validateAvgBlockTime("0")) // Zero should also fail -} - -func TestValidateTargetBondRatio(t *testing.T) { - require.Error(t, validateTargetBondRatio(0.5)) - require.NoError(t, validateTargetBondRatio("0.50")) - require.Error(t, validateTargetBondRatio("-0.01")) // Less than 0 percent should fail - require.Error(t, validateTargetBondRatio("1.01")) // More than 100 percent should fail -} - func TestValidateValidatorEmissionPercentage(t *testing.T) { require.Error(t, validateValidatorEmissionPercentage(0.5)) require.NoError(t, validateValidatorEmissionPercentage("0.50")) @@ -109,36 +65,21 @@ func TestValidateBallotMaturityBlocks(t *testing.T) { require.NoError(t, validateBallotMaturityBlocks(int64(100))) } +func TestValidateBlockRewardAmount(t *testing.T) { + require.Error(t, validateBlockRewardsAmount("0.50")) + require.Error(t, validateBlockRewardsAmount("-0.50")) + require.Error(t, validateBlockRewardsAmount(sdkmath.LegacyMustNewDecFromStr("-0.50"))) + require.NoError(t, validateBlockRewardsAmount(sdkmath.LegacyMustNewDecFromStr("0.50"))) + require.NoError(t, validateBlockRewardsAmount(sdkmath.LegacyZeroDec())) + require.NoError(t, validateBlockRewardsAmount(BlockReward)) +} + func TestValidate(t *testing.T) { t.Run("should validate", func(t *testing.T) { params := NewParams() require.NoError(t, params.Validate()) }) - t.Run("should error for invalid max bond factor", func(t *testing.T) { - params := NewParams() - params.MaxBondFactor = "1.30" - require.Error(t, params.Validate()) - }) - - t.Run("should error for invalid min bond factor", func(t *testing.T) { - params := NewParams() - params.MinBondFactor = "0.50" - require.Error(t, params.Validate()) - }) - - t.Run("should error for invalid avg block time", func(t *testing.T) { - params := NewParams() - params.AvgBlockTime = "-1.30" - require.Error(t, params.Validate()) - }) - - t.Run("should error for invalid target bond ratio", func(t *testing.T) { - params := NewParams() - params.TargetBondRatio = "-1.30" - require.Error(t, params.Validate()) - }) - t.Run("should error for invalid validator emissions percentage", func(t *testing.T) { params := NewParams() params.ValidatorEmissionPercentage = "-1.30" @@ -168,66 +109,16 @@ func TestValidate(t *testing.T) { params.BallotMaturityBlocks = -100 require.Error(t, params.Validate()) }) -} + t.Run("should error for negative block reward amount", func(t *testing.T) { + params := NewParams() + params.BlockRewardAmount = sdkmath.LegacyMustNewDecFromStr("-1.30") + require.ErrorContains(t, params.Validate(), "block reward amount cannot be less than 0") + }) +} func TestParamsString(t *testing.T) { params := DefaultParams() out, err := yaml.Marshal(params) require.NoError(t, err) require.Equal(t, string(out), params.String()) } - -func TestParams_GetDurationFactor(t *testing.T) { - t.Run("should return duration factor 0 if duration factor constant is 0", func(t *testing.T) { - params := DefaultParams() - params.DurationFactorConstant = "0" - - duractionFactor := params.GetDurationFactor(1) - require.Equal(t, sdk.ZeroDec(), duractionFactor) - }) - - t.Run("should return duration factor for default params", func(t *testing.T) { - params := DefaultParams() - duractionFactor := params.GetDurationFactor(1) - // hardcoding actual expected value for default params, it will change if logic changes - require.Equal(t, sdk.MustNewDecFromStr("0.000000004346937374"), duractionFactor) - }) -} - -func TestParams_GetBondFactor(t *testing.T) { - t.Run("should return 0 if current bond ratio is 0", func(t *testing.T) { - params := DefaultParams() - bondFactor := params.GetBondFactor(sdk.ZeroDec()) - require.Equal(t, sdk.ZeroDec(), bondFactor) - }) - - t.Run("should return max bond factor if bond factor exceeds max bond factor", func(t *testing.T) { - params := DefaultParams() - params.TargetBondRatio = "0.5" - params.MaxBondFactor = "1.1" - params.MinBondFactor = "0.9" - - bondFactor := params.GetBondFactor(sdk.MustNewDecFromStr("0.25")) - require.Equal(t, sdk.MustNewDecFromStr(params.MaxBondFactor), bondFactor) - }) - - t.Run("should return min bond factor if bond factor below min bond factor", func(t *testing.T) { - params := DefaultParams() - params.TargetBondRatio = "0.5" - params.MaxBondFactor = "1.1" - params.MinBondFactor = "0.9" - - bondFactor := params.GetBondFactor(sdk.MustNewDecFromStr("0.75")) - require.Equal(t, sdk.MustNewDecFromStr(params.MinBondFactor), bondFactor) - }) - - t.Run("should return calculated bond factor if bond factor in range", func(t *testing.T) { - params := DefaultParams() - params.TargetBondRatio = "0.5" - params.MaxBondFactor = "1.1" - params.MinBondFactor = "0.9" - - bondFactor := params.GetBondFactor(sdk.MustNewDecFromStr("0.5")) - require.Equal(t, sdk.OneDec(), bondFactor) - }) -} diff --git a/x/emissions/types/query.pb.go b/x/emissions/types/query.pb.go index 4da7a2ed0d..d6dab4091e 100644 --- a/x/emissions/types/query.pb.go +++ b/x/emissions/types/query.pb.go @@ -209,102 +209,6 @@ func (m *QueryListPoolAddressesResponse) GetEmissionModuleAddress() string { return "" } -type QueryGetEmissionsFactorsRequest struct { -} - -func (m *QueryGetEmissionsFactorsRequest) Reset() { *m = QueryGetEmissionsFactorsRequest{} } -func (m *QueryGetEmissionsFactorsRequest) String() string { return proto.CompactTextString(m) } -func (*QueryGetEmissionsFactorsRequest) ProtoMessage() {} -func (*QueryGetEmissionsFactorsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_cb9c0dfe78e2fb82, []int{4} -} -func (m *QueryGetEmissionsFactorsRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryGetEmissionsFactorsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryGetEmissionsFactorsRequest.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *QueryGetEmissionsFactorsRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryGetEmissionsFactorsRequest.Merge(m, src) -} -func (m *QueryGetEmissionsFactorsRequest) XXX_Size() int { - return m.Size() -} -func (m *QueryGetEmissionsFactorsRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryGetEmissionsFactorsRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryGetEmissionsFactorsRequest proto.InternalMessageInfo - -type QueryGetEmissionsFactorsResponse struct { - ReservesFactor string `protobuf:"bytes,1,opt,name=reservesFactor,proto3" json:"reservesFactor,omitempty"` - BondFactor string `protobuf:"bytes,2,opt,name=bondFactor,proto3" json:"bondFactor,omitempty"` - DurationFactor string `protobuf:"bytes,3,opt,name=durationFactor,proto3" json:"durationFactor,omitempty"` -} - -func (m *QueryGetEmissionsFactorsResponse) Reset() { *m = QueryGetEmissionsFactorsResponse{} } -func (m *QueryGetEmissionsFactorsResponse) String() string { return proto.CompactTextString(m) } -func (*QueryGetEmissionsFactorsResponse) ProtoMessage() {} -func (*QueryGetEmissionsFactorsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_cb9c0dfe78e2fb82, []int{5} -} -func (m *QueryGetEmissionsFactorsResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryGetEmissionsFactorsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryGetEmissionsFactorsResponse.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *QueryGetEmissionsFactorsResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryGetEmissionsFactorsResponse.Merge(m, src) -} -func (m *QueryGetEmissionsFactorsResponse) XXX_Size() int { - return m.Size() -} -func (m *QueryGetEmissionsFactorsResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryGetEmissionsFactorsResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryGetEmissionsFactorsResponse proto.InternalMessageInfo - -func (m *QueryGetEmissionsFactorsResponse) GetReservesFactor() string { - if m != nil { - return m.ReservesFactor - } - return "" -} - -func (m *QueryGetEmissionsFactorsResponse) GetBondFactor() string { - if m != nil { - return m.BondFactor - } - return "" -} - -func (m *QueryGetEmissionsFactorsResponse) GetDurationFactor() string { - if m != nil { - return m.DurationFactor - } - return "" -} - type QueryShowAvailableEmissionsRequest struct { Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` } @@ -313,7 +217,7 @@ func (m *QueryShowAvailableEmissionsRequest) Reset() { *m = QueryShowAva func (m *QueryShowAvailableEmissionsRequest) String() string { return proto.CompactTextString(m) } func (*QueryShowAvailableEmissionsRequest) ProtoMessage() {} func (*QueryShowAvailableEmissionsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_cb9c0dfe78e2fb82, []int{6} + return fileDescriptor_cb9c0dfe78e2fb82, []int{4} } func (m *QueryShowAvailableEmissionsRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -357,7 +261,7 @@ func (m *QueryShowAvailableEmissionsResponse) Reset() { *m = QueryShowAv func (m *QueryShowAvailableEmissionsResponse) String() string { return proto.CompactTextString(m) } func (*QueryShowAvailableEmissionsResponse) ProtoMessage() {} func (*QueryShowAvailableEmissionsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_cb9c0dfe78e2fb82, []int{7} + return fileDescriptor_cb9c0dfe78e2fb82, []int{5} } func (m *QueryShowAvailableEmissionsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -398,8 +302,6 @@ func init() { proto.RegisterType((*QueryParamsResponse)(nil), "zetachain.zetacore.emissions.QueryParamsResponse") proto.RegisterType((*QueryListPoolAddressesRequest)(nil), "zetachain.zetacore.emissions.QueryListPoolAddressesRequest") proto.RegisterType((*QueryListPoolAddressesResponse)(nil), "zetachain.zetacore.emissions.QueryListPoolAddressesResponse") - proto.RegisterType((*QueryGetEmissionsFactorsRequest)(nil), "zetachain.zetacore.emissions.QueryGetEmissionsFactorsRequest") - proto.RegisterType((*QueryGetEmissionsFactorsResponse)(nil), "zetachain.zetacore.emissions.QueryGetEmissionsFactorsResponse") proto.RegisterType((*QueryShowAvailableEmissionsRequest)(nil), "zetachain.zetacore.emissions.QueryShowAvailableEmissionsRequest") proto.RegisterType((*QueryShowAvailableEmissionsResponse)(nil), "zetachain.zetacore.emissions.QueryShowAvailableEmissionsResponse") } @@ -409,49 +311,43 @@ func init() { } var fileDescriptor_cb9c0dfe78e2fb82 = []byte{ - // 663 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x55, 0x4f, 0x4f, 0xd4, 0x5e, - 0x14, 0x9d, 0xf2, 0xfb, 0x39, 0xc6, 0x67, 0x62, 0xe2, 0x03, 0x91, 0x4c, 0xb0, 0x83, 0x75, 0x82, - 0xa8, 0x30, 0x15, 0x48, 0x8c, 0x51, 0x21, 0x30, 0x89, 0xb8, 0x50, 0x23, 0xa2, 0x2e, 0x74, 0xd3, - 0xbc, 0x4e, 0xaf, 0x9d, 0x26, 0x9d, 0xde, 0xa1, 0xf7, 0x15, 0x44, 0xe3, 0xc6, 0xa5, 0x2b, 0x23, - 0x5f, 0xc7, 0x0f, 0x80, 0x3b, 0x12, 0x37, 0xae, 0xd4, 0x80, 0x1f, 0xc3, 0x85, 0xe1, 0xf5, 0xb5, - 0x32, 0xc3, 0xcc, 0x64, 0xc4, 0xdd, 0xfb, 0x73, 0xce, 0xb9, 0xe7, 0xdc, 0xde, 0x97, 0xb2, 0xa9, - 0xd7, 0x20, 0x45, 0xbd, 0x21, 0x82, 0xc8, 0x56, 0x2b, 0x8c, 0xc1, 0x86, 0x66, 0x40, 0x14, 0x60, - 0x44, 0xf6, 0x7a, 0x02, 0xf1, 0x56, 0xb5, 0x15, 0xa3, 0x44, 0x3e, 0x9e, 0x23, 0xab, 0x19, 0xb2, - 0x9a, 0x23, 0x4b, 0x57, 0xeb, 0x48, 0x4d, 0x24, 0xdb, 0x15, 0x04, 0x29, 0xcd, 0xde, 0x98, 0x75, - 0x41, 0x8a, 0x59, 0xbb, 0x25, 0xfc, 0x20, 0x12, 0x32, 0xc0, 0x28, 0x55, 0x2a, 0x5d, 0xe9, 0x5b, - 0xb3, 0x25, 0x62, 0xd1, 0x24, 0x0d, 0x1d, 0xf1, 0xd1, 0x47, 0xb5, 0xb4, 0x0f, 0x56, 0xfa, 0x74, - 0xdc, 0x47, 0xf4, 0x43, 0xb0, 0x45, 0x2b, 0xb0, 0x45, 0x14, 0xa1, 0x54, 0xea, 0x9a, 0x63, 0x8d, - 0x30, 0xfe, 0xf8, 0xc0, 0xc0, 0xaa, 0x12, 0x5a, 0x83, 0xf5, 0x04, 0x48, 0x5a, 0xcf, 0xd9, 0x70, - 0xdb, 0x29, 0xb5, 0x30, 0x22, 0xe0, 0x35, 0x56, 0x4c, 0x0b, 0x8e, 0x19, 0x13, 0xc6, 0xd4, 0xe9, - 0xb9, 0x4a, 0xb5, 0x5f, 0xcc, 0x6a, 0xca, 0xae, 0xfd, 0xbf, 0xf3, 0xad, 0x5c, 0x58, 0xd3, 0x4c, - 0xab, 0xcc, 0x2e, 0x28, 0xe9, 0x07, 0x01, 0xc9, 0x55, 0xc4, 0x70, 0xd9, 0xf3, 0x62, 0x20, 0x82, - 0xbc, 0xf6, 0x2f, 0x83, 0x99, 0xbd, 0x10, 0xda, 0xc7, 0x33, 0x76, 0x39, 0x89, 0xbc, 0x80, 0x64, - 0x1c, 0xb8, 0x89, 0x04, 0xcf, 0x41, 0x97, 0x20, 0xde, 0x80, 0xd8, 0x71, 0x45, 0x28, 0xa2, 0x3a, - 0x90, 0x23, 0x52, 0x92, 0x32, 0x7a, 0x6a, 0xad, 0xd2, 0x06, 0x7f, 0xa4, 0xd1, 0x35, 0x0d, 0xd6, - 0x05, 0xf8, 0x7d, 0x66, 0xb5, 0xcb, 0x4a, 0xa2, 0xa3, 0x8a, 0x43, 0x4a, 0xb1, 0xdc, 0x86, 0x7c, - 0x4a, 0xd4, 0x29, 0x76, 0x83, 0x9d, 0xcf, 0x3a, 0xe1, 0x34, 0xd1, 0x4b, 0x42, 0xc8, 0x15, 0xfe, - 0x53, 0x0a, 0xe7, 0xb2, 0xeb, 0x87, 0xea, 0x56, 0xf3, 0xac, 0x8b, 0xac, 0xac, 0xd2, 0xdf, 0x03, - 0x79, 0x37, 0xeb, 0xe4, 0x8a, 0xa8, 0x4b, 0x8c, 0xf3, 0x0e, 0x7d, 0x34, 0xd8, 0x44, 0x6f, 0x8c, - 0xee, 0xd1, 0x24, 0x3b, 0x13, 0x83, 0xca, 0xa9, 0xaf, 0x74, 0x2b, 0x3a, 0x4e, 0xb9, 0xc9, 0x98, - 0x8b, 0x91, 0xa7, 0x31, 0x69, 0xb8, 0x43, 0x27, 0x07, 0x3a, 0x5e, 0x12, 0xab, 0x99, 0xd1, 0x98, - 0xd4, 0x7e, 0xc7, 0xa9, 0xb5, 0xc8, 0x2c, 0xe5, 0xe9, 0x49, 0x03, 0x37, 0x97, 0x37, 0x44, 0x10, - 0x0a, 0x37, 0x84, 0xdc, 0x9d, 0xb6, 0xce, 0xc7, 0xd8, 0xc9, 0xf6, 0x2f, 0x93, 0x6d, 0xad, 0x05, - 0x76, 0xa9, 0x2f, 0x5f, 0xc7, 0x1a, 0x65, 0x45, 0xd1, 0xc4, 0x24, 0x92, 0x9a, 0xaf, 0x77, 0x73, - 0xef, 0x8b, 0xec, 0x84, 0xe2, 0xf3, 0x6d, 0x83, 0x15, 0xd3, 0xc9, 0xe3, 0xd7, 0xfb, 0xcf, 0xe7, - 0xd1, 0xc1, 0x2f, 0xcd, 0xfe, 0x05, 0x23, 0x75, 0x64, 0x55, 0xde, 0x7d, 0xf9, 0xb9, 0x3d, 0x64, - 0xf2, 0x71, 0xf5, 0x3e, 0x67, 0xd2, 0xa7, 0xda, 0xf9, 0x42, 0xf9, 0x27, 0x83, 0x9d, 0x3d, 0x32, - 0xd0, 0xfc, 0xf6, 0x00, 0xe5, 0x7a, 0x3d, 0x94, 0xd2, 0x9d, 0xe3, 0x91, 0xb5, 0xed, 0x69, 0x65, - 0x7b, 0x92, 0x57, 0xba, 0xdb, 0x0e, 0x03, 0x92, 0xd9, 0xc0, 0x02, 0xf1, 0xcf, 0x06, 0x1b, 0xee, - 0x32, 0x6d, 0x7c, 0x61, 0x00, 0x0f, 0xbd, 0x27, 0xb9, 0xb4, 0x78, 0x5c, 0xba, 0x0e, 0x31, 0xaf, - 0x42, 0xcc, 0xf0, 0x6b, 0xdd, 0x43, 0xf8, 0x20, 0x9d, 0x7c, 0xe7, 0xbc, 0xd4, 0x9e, 0xbf, 0x1b, - 0x6c, 0xb4, 0xfb, 0x94, 0xf1, 0xa5, 0x01, 0xfc, 0xf4, 0x1d, 0xf0, 0xd2, 0xf2, 0x3f, 0x28, 0xe8, - 0x50, 0x4b, 0x2a, 0xd4, 0x2d, 0x7e, 0xb3, 0x7b, 0x28, 0x6a, 0xe0, 0xa6, 0x23, 0x32, 0xfa, 0x9f, - 0x7c, 0xf6, 0x1b, 0xfd, 0xb9, 0xde, 0xd6, 0x56, 0x76, 0xf6, 0x4c, 0x63, 0x77, 0xcf, 0x34, 0x7e, - 0xec, 0x99, 0xc6, 0x87, 0x7d, 0xb3, 0xb0, 0xbb, 0x6f, 0x16, 0xbe, 0xee, 0x9b, 0x85, 0x17, 0xd3, - 0x7e, 0x20, 0x1b, 0x89, 0x5b, 0xad, 0x63, 0xf3, 0xb0, 0x7a, 0x84, 0x1e, 0xd8, 0xaf, 0x0e, 0x15, - 0x91, 0x5b, 0x2d, 0x20, 0xb7, 0xa8, 0xfe, 0x11, 0xf3, 0xbf, 0x03, 0x00, 0x00, 0xff, 0xff, 0x0f, - 0x1e, 0xc8, 0x24, 0xf8, 0x06, 0x00, 0x00, + // 564 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x54, 0x4d, 0x6f, 0xd3, 0x40, + 0x10, 0x8d, 0x4b, 0x09, 0x62, 0x39, 0xb1, 0x94, 0x52, 0x45, 0xc5, 0x45, 0x26, 0x82, 0x82, 0x8a, + 0x4d, 0x8a, 0x84, 0x10, 0x5f, 0x6a, 0x22, 0xc1, 0x05, 0x10, 0x25, 0xc0, 0x01, 0x2e, 0xd6, 0x3a, + 0x5e, 0x39, 0x2b, 0xd9, 0x3b, 0xae, 0x67, 0x9d, 0x52, 0x10, 0x17, 0x7e, 0x01, 0x52, 0xff, 0x0e, + 0xe2, 0xdc, 0x63, 0x25, 0x2e, 0x9c, 0x00, 0x25, 0xfc, 0x0c, 0x0e, 0xa8, 0xeb, 0x75, 0x68, 0x9a, + 0x34, 0x2a, 0x70, 0x5b, 0xef, 0xbe, 0xf7, 0xe6, 0xcd, 0xcc, 0x93, 0xc9, 0xf2, 0x5b, 0xae, 0x58, + 0xa7, 0xcb, 0x84, 0xf4, 0xf4, 0x09, 0x32, 0xee, 0xf1, 0x44, 0x20, 0x0a, 0x90, 0xe8, 0x6d, 0xe4, + 0x3c, 0xdb, 0x72, 0xd3, 0x0c, 0x14, 0xd0, 0xc5, 0x21, 0xd2, 0x2d, 0x91, 0xee, 0x10, 0x59, 0xbb, + 0xda, 0x01, 0x4c, 0x00, 0xbd, 0x80, 0x21, 0x2f, 0x68, 0x5e, 0xaf, 0x11, 0x70, 0xc5, 0x1a, 0x5e, + 0xca, 0x22, 0x21, 0x99, 0x12, 0x20, 0x0b, 0xa5, 0xda, 0x95, 0xa9, 0x35, 0x53, 0x96, 0xb1, 0x04, + 0x0d, 0x74, 0x2e, 0x82, 0x08, 0xf4, 0xd1, 0xdb, 0x3b, 0x99, 0xdb, 0xc5, 0x08, 0x20, 0x8a, 0xb9, + 0xc7, 0x52, 0xe1, 0x31, 0x29, 0x41, 0x69, 0x75, 0xc3, 0x71, 0xe6, 0x08, 0x7d, 0xb6, 0x67, 0x60, + 0x5d, 0x0b, 0xb5, 0xf9, 0x46, 0xce, 0x51, 0x39, 0xaf, 0xc8, 0x99, 0x91, 0x5b, 0x4c, 0x41, 0x22, + 0xa7, 0x2d, 0x52, 0x2d, 0x0a, 0x2e, 0x58, 0x17, 0xac, 0xe5, 0x53, 0xab, 0x75, 0x77, 0x5a, 0x9b, + 0x6e, 0xc1, 0x6e, 0xcd, 0xee, 0x7c, 0x5b, 0xaa, 0xb4, 0x0d, 0xd3, 0x59, 0x22, 0xe7, 0xb5, 0xf4, + 0x63, 0x81, 0x6a, 0x1d, 0x20, 0x6e, 0x86, 0x61, 0xc6, 0x11, 0xf9, 0xb0, 0xf6, 0x2f, 0x8b, 0xd8, + 0x87, 0x21, 0x8c, 0x8f, 0x97, 0xe4, 0x72, 0x2e, 0x43, 0x81, 0x2a, 0x13, 0x41, 0xae, 0x78, 0xe8, + 0x43, 0x80, 0x3c, 0xeb, 0xf1, 0xcc, 0x0f, 0x58, 0xcc, 0x64, 0x87, 0xa3, 0xcf, 0x0a, 0x92, 0x36, + 0x7a, 0xb2, 0x5d, 0x1f, 0x81, 0x3f, 0x35, 0xe8, 0x96, 0x01, 0x9b, 0x02, 0xf4, 0x11, 0x71, 0x46, + 0x65, 0x15, 0xe2, 0xb8, 0xe2, 0x8c, 0x56, 0x5c, 0x1a, 0x41, 0xbe, 0x40, 0x3c, 0x28, 0x76, 0x93, + 0x9c, 0x2b, 0x27, 0xe1, 0x27, 0x10, 0xe6, 0x31, 0x1f, 0x2a, 0x1c, 0xd3, 0x0a, 0x67, 0xcb, 0xe7, + 0x27, 0xfa, 0xd5, 0xf0, 0x9c, 0xfb, 0xc4, 0xd1, 0xdd, 0x3f, 0xef, 0xc2, 0x66, 0xb3, 0xc7, 0x44, + 0xcc, 0x82, 0x98, 0x3f, 0x28, 0x67, 0x6a, 0x86, 0x44, 0x17, 0xc8, 0x89, 0xd1, 0x0e, 0xcb, 0x4f, + 0xe7, 0x1e, 0xb9, 0x38, 0x95, 0x6f, 0x46, 0x38, 0x4f, 0xaa, 0x2c, 0x81, 0x5c, 0x2a, 0xc3, 0x37, + 0x5f, 0xab, 0x9f, 0x67, 0xc9, 0x71, 0xcd, 0xa7, 0xdb, 0x16, 0xa9, 0x16, 0x1b, 0xa4, 0xd7, 0xa7, + 0xef, 0x79, 0x3c, 0x40, 0xb5, 0xc6, 0x5f, 0x30, 0x0a, 0x47, 0x4e, 0xfd, 0xc3, 0x97, 0x9f, 0xdb, + 0x33, 0x36, 0x5d, 0xd4, 0x39, 0xbf, 0x56, 0x44, 0xfe, 0x60, 0xd2, 0xe9, 0x27, 0x8b, 0x9c, 0x1e, + 0x0b, 0x06, 0xbd, 0x73, 0x84, 0x72, 0x87, 0x05, 0xae, 0x76, 0xf7, 0xdf, 0xc8, 0xc6, 0xf6, 0x8a, + 0xb6, 0x7d, 0x89, 0xd6, 0x27, 0xdb, 0x8e, 0x05, 0xaa, 0x72, 0xf1, 0x1c, 0xe9, 0x77, 0x8b, 0xcc, + 0x4f, 0xde, 0x0c, 0x5d, 0x3b, 0x82, 0x8d, 0xa9, 0xa1, 0xa8, 0x35, 0xff, 0x43, 0xc1, 0x74, 0xb3, + 0xa6, 0xbb, 0xb9, 0x4d, 0x6f, 0x4d, 0xee, 0x06, 0xbb, 0xb0, 0xe9, 0xb3, 0x92, 0xee, 0xff, 0x79, + 0x78, 0x67, 0x5a, 0x7c, 0xdf, 0x7a, 0xb8, 0xd3, 0xb7, 0xad, 0xdd, 0xbe, 0x6d, 0xfd, 0xe8, 0xdb, + 0xd6, 0xc7, 0x81, 0x5d, 0xd9, 0x1d, 0xd8, 0x95, 0xaf, 0x03, 0xbb, 0xf2, 0x7a, 0x25, 0x12, 0xaa, + 0x9b, 0x07, 0x6e, 0x07, 0x92, 0xfd, 0xea, 0x12, 0x42, 0xee, 0xbd, 0xd9, 0x57, 0x44, 0x6d, 0xa5, + 0x1c, 0x83, 0xaa, 0xfe, 0x3f, 0xdd, 0xf8, 0x1d, 0x00, 0x00, 0xff, 0xff, 0x10, 0x7c, 0x2f, 0xf2, + 0x74, 0x05, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -470,8 +366,6 @@ type QueryClient interface { Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) // Queries a list of ListBalances items. ListPoolAddresses(ctx context.Context, in *QueryListPoolAddressesRequest, opts ...grpc.CallOption) (*QueryListPoolAddressesResponse, error) - // Queries a list of GetEmmisonsFactors items. - GetEmissionsFactors(ctx context.Context, in *QueryGetEmissionsFactorsRequest, opts ...grpc.CallOption) (*QueryGetEmissionsFactorsResponse, error) // Queries a list of ShowAvailableEmissions items. ShowAvailableEmissions(ctx context.Context, in *QueryShowAvailableEmissionsRequest, opts ...grpc.CallOption) (*QueryShowAvailableEmissionsResponse, error) } @@ -502,15 +396,6 @@ func (c *queryClient) ListPoolAddresses(ctx context.Context, in *QueryListPoolAd return out, nil } -func (c *queryClient) GetEmissionsFactors(ctx context.Context, in *QueryGetEmissionsFactorsRequest, opts ...grpc.CallOption) (*QueryGetEmissionsFactorsResponse, error) { - out := new(QueryGetEmissionsFactorsResponse) - err := c.cc.Invoke(ctx, "/zetachain.zetacore.emissions.Query/GetEmissionsFactors", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - func (c *queryClient) ShowAvailableEmissions(ctx context.Context, in *QueryShowAvailableEmissionsRequest, opts ...grpc.CallOption) (*QueryShowAvailableEmissionsResponse, error) { out := new(QueryShowAvailableEmissionsResponse) err := c.cc.Invoke(ctx, "/zetachain.zetacore.emissions.Query/ShowAvailableEmissions", in, out, opts...) @@ -526,8 +411,6 @@ type QueryServer interface { Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) // Queries a list of ListBalances items. ListPoolAddresses(context.Context, *QueryListPoolAddressesRequest) (*QueryListPoolAddressesResponse, error) - // Queries a list of GetEmmisonsFactors items. - GetEmissionsFactors(context.Context, *QueryGetEmissionsFactorsRequest) (*QueryGetEmissionsFactorsResponse, error) // Queries a list of ShowAvailableEmissions items. ShowAvailableEmissions(context.Context, *QueryShowAvailableEmissionsRequest) (*QueryShowAvailableEmissionsResponse, error) } @@ -542,9 +425,6 @@ func (*UnimplementedQueryServer) Params(ctx context.Context, req *QueryParamsReq func (*UnimplementedQueryServer) ListPoolAddresses(ctx context.Context, req *QueryListPoolAddressesRequest) (*QueryListPoolAddressesResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method ListPoolAddresses not implemented") } -func (*UnimplementedQueryServer) GetEmissionsFactors(ctx context.Context, req *QueryGetEmissionsFactorsRequest) (*QueryGetEmissionsFactorsResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method GetEmissionsFactors not implemented") -} func (*UnimplementedQueryServer) ShowAvailableEmissions(ctx context.Context, req *QueryShowAvailableEmissionsRequest) (*QueryShowAvailableEmissionsResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method ShowAvailableEmissions not implemented") } @@ -589,24 +469,6 @@ func _Query_ListPoolAddresses_Handler(srv interface{}, ctx context.Context, dec return interceptor(ctx, in, info, handler) } -func _Query_GetEmissionsFactors_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryGetEmissionsFactorsRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).GetEmissionsFactors(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/zetachain.zetacore.emissions.Query/GetEmissionsFactors", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).GetEmissionsFactors(ctx, req.(*QueryGetEmissionsFactorsRequest)) - } - return interceptor(ctx, in, info, handler) -} - func _Query_ShowAvailableEmissions_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(QueryShowAvailableEmissionsRequest) if err := dec(in); err != nil { @@ -637,10 +499,6 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "ListPoolAddresses", Handler: _Query_ListPoolAddresses_Handler, }, - { - MethodName: "GetEmissionsFactors", - Handler: _Query_GetEmissionsFactors_Handler, - }, { MethodName: "ShowAvailableEmissions", Handler: _Query_ShowAvailableEmissions_Handler, @@ -773,73 +631,6 @@ func (m *QueryListPoolAddressesResponse) MarshalToSizedBuffer(dAtA []byte) (int, return len(dAtA) - i, nil } -func (m *QueryGetEmissionsFactorsRequest) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *QueryGetEmissionsFactorsRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryGetEmissionsFactorsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - return len(dAtA) - i, nil -} - -func (m *QueryGetEmissionsFactorsResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *QueryGetEmissionsFactorsResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryGetEmissionsFactorsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.DurationFactor) > 0 { - i -= len(m.DurationFactor) - copy(dAtA[i:], m.DurationFactor) - i = encodeVarintQuery(dAtA, i, uint64(len(m.DurationFactor))) - i-- - dAtA[i] = 0x1a - } - if len(m.BondFactor) > 0 { - i -= len(m.BondFactor) - copy(dAtA[i:], m.BondFactor) - i = encodeVarintQuery(dAtA, i, uint64(len(m.BondFactor))) - i-- - dAtA[i] = 0x12 - } - if len(m.ReservesFactor) > 0 { - i -= len(m.ReservesFactor) - copy(dAtA[i:], m.ReservesFactor) - i = encodeVarintQuery(dAtA, i, uint64(len(m.ReservesFactor))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - func (m *QueryShowAvailableEmissionsRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -961,36 +752,6 @@ func (m *QueryListPoolAddressesResponse) Size() (n int) { return n } -func (m *QueryGetEmissionsFactorsRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - return n -} - -func (m *QueryGetEmissionsFactorsResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.ReservesFactor) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } - l = len(m.BondFactor) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } - l = len(m.DurationFactor) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } - return n -} - func (m *QueryShowAvailableEmissionsRequest) Size() (n int) { if m == nil { return 0 @@ -1352,202 +1113,6 @@ func (m *QueryListPoolAddressesResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryGetEmissionsFactorsRequest) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: QueryGetEmissionsFactorsRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryGetEmissionsFactorsRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *QueryGetEmissionsFactorsResponse) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: QueryGetEmissionsFactorsResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryGetEmissionsFactorsResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ReservesFactor", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ReservesFactor = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field BondFactor", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.BondFactor = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field DurationFactor", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.DurationFactor = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} func (m *QueryShowAvailableEmissionsRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 diff --git a/x/emissions/types/query.pb.gw.go b/x/emissions/types/query.pb.gw.go index 05b5ad7f8b..51f7a69d78 100644 --- a/x/emissions/types/query.pb.gw.go +++ b/x/emissions/types/query.pb.gw.go @@ -69,24 +69,6 @@ func local_request_Query_ListPoolAddresses_0(ctx context.Context, marshaler runt } -func request_Query_GetEmissionsFactors_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryGetEmissionsFactorsRequest - var metadata runtime.ServerMetadata - - msg, err := client.GetEmissionsFactors(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_GetEmissionsFactors_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryGetEmissionsFactorsRequest - var metadata runtime.ServerMetadata - - msg, err := server.GetEmissionsFactors(ctx, &protoReq) - return msg, metadata, err - -} - func request_Query_ShowAvailableEmissions_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryShowAvailableEmissionsRequest var metadata runtime.ServerMetadata @@ -193,29 +175,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) - mux.Handle("GET", pattern_Query_GetEmissionsFactors_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_Query_GetEmissionsFactors_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_GetEmissionsFactors_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - mux.Handle("GET", pattern_Query_ShowAvailableEmissions_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -320,26 +279,6 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) - mux.Handle("GET", pattern_Query_GetEmissionsFactors_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_Query_GetEmissionsFactors_0(rctx, inboundMarshaler, client, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_GetEmissionsFactors_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - mux.Handle("GET", pattern_Query_ShowAvailableEmissions_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -368,8 +307,6 @@ var ( pattern_Query_ListPoolAddresses_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"zeta-chain", "emissions", "list_addresses"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_GetEmissionsFactors_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"zeta-chain", "emissions", "get_emissions_factors"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_ShowAvailableEmissions_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"zeta-chain", "emissions", "show_available_emissions", "address"}, "", runtime.AssumeColonVerbOpt(false))) ) @@ -378,7 +315,5 @@ var ( forward_Query_ListPoolAddresses_0 = runtime.ForwardResponseMessage - forward_Query_GetEmissionsFactors_0 = runtime.ForwardResponseMessage - forward_Query_ShowAvailableEmissions_0 = runtime.ForwardResponseMessage ) diff --git a/x/emissions/types/types.go b/x/emissions/types/types.go deleted file mode 100644 index ab1254f4c2..0000000000 --- a/x/emissions/types/types.go +++ /dev/null @@ -1 +0,0 @@ -package types