diff --git a/app/encoding.go b/app/encoding.go index fed40e3286..2e8c728b0f 100644 --- a/app/encoding.go +++ b/app/encoding.go @@ -1,17 +1,51 @@ package app import ( + cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + "github.com/cosmos/cosmos-sdk/x/authz" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types" + distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types" + evidencetypes "github.com/cosmos/cosmos-sdk/x/evidence/types" + slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" evmenc "github.com/zeta-chain/ethermint/encoding" ethermint "github.com/zeta-chain/ethermint/types" + evmtypes "github.com/zeta-chain/ethermint/x/evm/types" + + authoritytypes "github.com/zeta-chain/node/x/authority/types" + crosschaintypes "github.com/zeta-chain/node/x/crosschain/types" + emissionstypes "github.com/zeta-chain/node/x/emissions/types" + fungibletypes "github.com/zeta-chain/node/x/fungible/types" + lightclienttypes "github.com/zeta-chain/node/x/lightclient/types" + observertypes "github.com/zeta-chain/node/x/observer/types" ) // MakeEncodingConfig creates an EncodingConfig for testing func MakeEncodingConfig() ethermint.EncodingConfig { - //encodingConfig := params.MakeEncodingConfig() encodingConfig := evmenc.MakeConfig(ModuleBasics) - //std.RegisterLegacyAminoCodec(encodingConfig.Amino) - //std.RegisterInterfaces(encodingConfig.InterfaceRegistry) - //ModuleBasics.RegisterLegacyAminoCodec(encodingConfig.Amino) - //ModuleBasics.RegisterInterfaces(encodingConfig.InterfaceRegistry) + registry := encodingConfig.InterfaceRegistry + + cryptocodec.RegisterInterfaces(registry) + authtypes.RegisterInterfaces(registry) + authz.RegisterInterfaces(registry) + banktypes.RegisterInterfaces(registry) + stakingtypes.RegisterInterfaces(registry) + slashingtypes.RegisterInterfaces(registry) + upgradetypes.RegisterInterfaces(registry) + distrtypes.RegisterInterfaces(registry) + evidencetypes.RegisterInterfaces(registry) + crisistypes.RegisterInterfaces(registry) + evmtypes.RegisterInterfaces(registry) + ethermint.RegisterInterfaces(registry) + authoritytypes.RegisterInterfaces(registry) + crosschaintypes.RegisterInterfaces(registry) + emissionstypes.RegisterInterfaces(registry) + fungibletypes.RegisterInterfaces(registry) + observertypes.RegisterInterfaces(registry) + lightclienttypes.RegisterInterfaces(registry) + return encodingConfig } diff --git a/changelog.md b/changelog.md index 9d76404a15..93fc9eead8 100644 --- a/changelog.md +++ b/changelog.md @@ -24,6 +24,8 @@ * [2615](https://github.com/zeta-chain/node/pull/2615) - Refactor cleanup of outbound trackers * [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 @@ -40,6 +42,8 @@ * [2672](https://github.com/zeta-chain/node/pull/2672) - check observer set for duplicates when adding a new observer or updating an existing one * [2735](https://github.com/zeta-chain/node/pull/2735) - fix the outbound tracker blocking confirmation and outbound processing on EVM chains by locally index outbound txs in zetaclient * [2787](https://github.com/zeta-chain/node/pull/2787) - ask for 3 accounts (signer, pda, system_program) on solana gateway deposit +* [2842](https://github.com/zeta-chain/node/pull/2842) - fix: move interval assignment out of cctx loop in EVM outbound tx scheduler +* [2853](https://github.com/zeta-chain/node/pull/2853) - calling precompile through sc with sc state update ## v19.0.0 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/e2e/contracts/teststaking/TestStaking.abi b/e2e/contracts/teststaking/TestStaking.abi index 1dc4f1592e..69003af87f 100644 --- a/e2e/contracts/teststaking/TestStaking.abi +++ b/e2e/contracts/teststaking/TestStaking.abi @@ -14,6 +14,19 @@ "stateMutability": "payable", "type": "fallback" }, + { + "inputs": [], + "name": "counter", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, { "inputs": [], "name": "depositWZETA", @@ -143,6 +156,64 @@ "stateMutability": "nonpayable", "type": "function" }, + { + "inputs": [ + { + "internalType": "address", + "name": "staker", + "type": "address" + }, + { + "internalType": "string", + "name": "validator", + "type": "string" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "stakeAndRevert", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "staker", + "type": "address" + }, + { + "internalType": "string", + "name": "validator", + "type": "string" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "stakeWithStateUpdate", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, { "inputs": [ { diff --git a/e2e/contracts/teststaking/TestStaking.bin b/e2e/contracts/teststaking/TestStaking.bin index f2b883adb0..35c4198862 100644 --- a/e2e/contracts/teststaking/TestStaking.bin +++ b/e2e/contracts/teststaking/TestStaking.bin @@ -1 +1 @@ -608060405260666000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055503480156200005257600080fd5b50604051620014d3380380620014d383398181016040528101906200007891906200016b565b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555033600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550506200019d565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000620001338262000106565b9050919050565b620001458162000126565b81146200015157600080fd5b50565b60008151905062000165816200013a565b92915050565b60006020828403121562000184576200018362000101565b5b6000620001948482850162000154565b91505092915050565b61132680620001ad6000396000f3fe6080604052600436106100745760003560e01c806390b8436f1161004e57806390b8436f146101015780639a0fb6731461013e578063d11a93d014610167578063f3513a37146101a45761007b565b80630d1b3daf1461007d5780632c5d24ae146100ba57806357c6ea3e146100c45761007b565b3661007b57005b005b34801561008957600080fd5b506100a4600480360381019061009f91906109a4565b6101cf565b6040516100b19190610a19565b60405180910390f35b6100c2610276565b005b3480156100d057600080fd5b506100eb60048036038101906100e69190610a60565b610355565b6040516100f89190610aeb565b60405180910390f35b34801561010d57600080fd5b5061012860048036038101906101239190610a60565b61045a565b6040516101359190610b21565b60405180910390f35b34801561014a57600080fd5b5061016560048036038101906101609190610b3c565b61055f565b005b34801561017357600080fd5b5061018e60048036038101906101899190610b69565b610649565b60405161019b9190610aeb565b60405180910390f35b3480156101b057600080fd5b506101b9610751565b6040516101c69190610e42565b60405180910390f35b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16630d1b3daf84846040518363ffffffff1660e01b815260040161022d929190610ebd565b602060405180830381865afa15801561024a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061026e9190610f02565b905092915050565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146102d057600080fd5b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663d0e30db0346040518263ffffffff1660e01b81526004016000604051808303818588803b15801561033a57600080fd5b505af115801561034e573d6000803e3d6000fd5b5050505050565b6000600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146103b157600080fd5b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166357c6ea3e8585856040518463ffffffff1660e01b815260040161040e93929190610f2f565b6020604051808303816000875af115801561042d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104519190610f99565b90509392505050565b6000600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146104b657600080fd5b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166390b8436f8585856040518463ffffffff1660e01b815260040161051393929190610f2f565b6020604051808303816000875af1158015610532573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105569190610ff2565b90509392505050565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146105b957600080fd5b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16632e1a7d4d826040518263ffffffff1660e01b81526004016106149190610a19565b600060405180830381600087803b15801561062e57600080fd5b505af1158015610642573d6000803e3d6000fd5b5050505050565b6000600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146106a557600080fd5b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663d11a93d0868686866040518563ffffffff1660e01b8152600401610704949392919061101f565b6020604051808303816000875af1158015610723573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107479190610f99565b9050949350505050565b606060008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663f3513a376040518163ffffffff1660e01b8152600401600060405180830381865afa1580156107be573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f820116820180604052508101906107e791906112a7565b905090565b6000604051905090565b600080fd5b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061082b82610800565b9050919050565b61083b81610820565b811461084657600080fd5b50565b60008135905061085881610832565b92915050565b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6108b182610868565b810181811067ffffffffffffffff821117156108d0576108cf610879565b5b80604052505050565b60006108e36107ec565b90506108ef82826108a8565b919050565b600067ffffffffffffffff82111561090f5761090e610879565b5b61091882610868565b9050602081019050919050565b82818337600083830152505050565b6000610947610942846108f4565b6108d9565b90508281526020810184848401111561096357610962610863565b5b61096e848285610925565b509392505050565b600082601f83011261098b5761098a61085e565b5b813561099b848260208601610934565b91505092915050565b600080604083850312156109bb576109ba6107f6565b5b60006109c985828601610849565b925050602083013567ffffffffffffffff8111156109ea576109e96107fb565b5b6109f685828601610976565b9150509250929050565b6000819050919050565b610a1381610a00565b82525050565b6000602082019050610a2e6000830184610a0a565b92915050565b610a3d81610a00565b8114610a4857600080fd5b50565b600081359050610a5a81610a34565b92915050565b600080600060608486031215610a7957610a786107f6565b5b6000610a8786828701610849565b935050602084013567ffffffffffffffff811115610aa857610aa76107fb565b5b610ab486828701610976565b9250506040610ac586828701610a4b565b9150509250925092565b60008160070b9050919050565b610ae581610acf565b82525050565b6000602082019050610b006000830184610adc565b92915050565b60008115159050919050565b610b1b81610b06565b82525050565b6000602082019050610b366000830184610b12565b92915050565b600060208284031215610b5257610b516107f6565b5b6000610b6084828501610a4b565b91505092915050565b60008060008060808587031215610b8357610b826107f6565b5b6000610b9187828801610849565b945050602085013567ffffffffffffffff811115610bb257610bb16107fb565b5b610bbe87828801610976565b935050604085013567ffffffffffffffff811115610bdf57610bde6107fb565b5b610beb87828801610976565b9250506060610bfc87828801610a4b565b91505092959194509250565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b600081519050919050565b600082825260208201905092915050565b60005b83811015610c6e578082015181840152602081019050610c53565b83811115610c7d576000848401525b50505050565b6000610c8e82610c34565b610c988185610c3f565b9350610ca8818560208601610c50565b610cb181610868565b840191505092915050565b610cc581610b06565b82525050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b60048110610d0b57610d0a610ccb565b5b50565b6000819050610d1c82610cfa565b919050565b6000610d2c82610d0e565b9050919050565b610d3c81610d21565b82525050565b60006080830160008301518482036000860152610d5f8282610c83565b91505060208301518482036020860152610d798282610c83565b9150506040830151610d8e6040860182610cbc565b506060830151610da16060860182610d33565b508091505092915050565b6000610db88383610d42565b905092915050565b6000602082019050919050565b6000610dd882610c08565b610de28185610c13565b935083602082028501610df485610c24565b8060005b85811015610e305784840389528151610e118582610dac565b9450610e1c83610dc0565b925060208a01995050600181019050610df8565b50829750879550505050505092915050565b60006020820190508181036000830152610e5c8184610dcd565b905092915050565b610e6d81610820565b82525050565b600082825260208201905092915050565b6000610e8f82610c34565b610e998185610e73565b9350610ea9818560208601610c50565b610eb281610868565b840191505092915050565b6000604082019050610ed26000830185610e64565b8181036020830152610ee48184610e84565b90509392505050565b600081519050610efc81610a34565b92915050565b600060208284031215610f1857610f176107f6565b5b6000610f2684828501610eed565b91505092915050565b6000606082019050610f446000830186610e64565b8181036020830152610f568185610e84565b9050610f656040830184610a0a565b949350505050565b610f7681610acf565b8114610f8157600080fd5b50565b600081519050610f9381610f6d565b92915050565b600060208284031215610faf57610fae6107f6565b5b6000610fbd84828501610f84565b91505092915050565b610fcf81610b06565b8114610fda57600080fd5b50565b600081519050610fec81610fc6565b92915050565b600060208284031215611008576110076107f6565b5b600061101684828501610fdd565b91505092915050565b60006080820190506110346000830187610e64565b81810360208301526110468186610e84565b9050818103604083015261105a8185610e84565b90506110696060830184610a0a565b95945050505050565b600067ffffffffffffffff82111561108d5761108c610879565b5b602082029050602081019050919050565b600080fd5b600080fd5b600080fd5b60006110c06110bb846108f4565b6108d9565b9050828152602081018484840111156110dc576110db610863565b5b6110e7848285610c50565b509392505050565b600082601f8301126111045761110361085e565b5b81516111148482602086016110ad565b91505092915050565b6004811061112a57600080fd5b50565b60008151905061113c8161111d565b92915050565b600060808284031215611158576111576110a3565b5b61116260806108d9565b9050600082015167ffffffffffffffff811115611182576111816110a8565b5b61118e848285016110ef565b600083015250602082015167ffffffffffffffff8111156111b2576111b16110a8565b5b6111be848285016110ef565b60208301525060406111d284828501610fdd565b60408301525060606111e68482850161112d565b60608301525092915050565b600061120561120084611072565b6108d9565b905080838252602082019050602084028301858111156112285761122761109e565b5b835b8181101561126f57805167ffffffffffffffff81111561124d5761124c61085e565b5b80860161125a8982611142565b8552602085019450505060208101905061122a565b5050509392505050565b600082601f83011261128e5761128d61085e565b5b815161129e8482602086016111f2565b91505092915050565b6000602082840312156112bd576112bc6107f6565b5b600082015167ffffffffffffffff8111156112db576112da6107fb565b5b6112e784828501611279565b9150509291505056fea26469706673582212209d34227b9c73d9c6eb2b67ca8fabedb28adcac235655b12df2a572847549ea2a64736f6c634300080a0033 +608060405260666000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060006003553480156200005757600080fd5b506040516200192d3803806200192d83398181016040528101906200007d919062000170565b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555033600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050620001a2565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600062000138826200010b565b9050919050565b6200014a816200012b565b81146200015657600080fd5b50565b6000815190506200016a816200013f565b92915050565b60006020828403121562000189576200018862000106565b5b6000620001998482850162000159565b91505092915050565b61177b80620001b26000396000f3fe6080604052600436106100955760003560e01c806390b8436f1161005957806390b8436f1461018a5780639a0fb673146101c7578063bca8f527146101f0578063d11a93d01461022d578063f3513a371461026a5761009c565b80630d1b3daf1461009e5780632c5d24ae146100db57806357c6ea3e146100e557806361bc221a146101225780636be8916c1461014d5761009c565b3661009c57005b005b3480156100aa57600080fd5b506100c560048036038101906100c09190610d08565b610295565b6040516100d29190610d7d565b60405180910390f35b6100e361033c565b005b3480156100f157600080fd5b5061010c60048036038101906101079190610dc4565b61041b565b6040516101199190610e4f565b60405180910390f35b34801561012e57600080fd5b50610137610520565b6040516101449190610d7d565b60405180910390f35b34801561015957600080fd5b50610174600480360381019061016f9190610dc4565b610526565b6040516101819190610e85565b60405180910390f35b34801561019657600080fd5b506101b160048036038101906101ac9190610dc4565b61065c565b6040516101be9190610e85565b60405180910390f35b3480156101d357600080fd5b506101ee60048036038101906101e99190610ea0565b610761565b005b3480156101fc57600080fd5b5061021760048036038101906102129190610dc4565b61084b565b6040516102249190610e85565b60405180910390f35b34801561023957600080fd5b50610254600480360381019061024f9190610ecd565b6109ad565b6040516102619190610e4f565b60405180910390f35b34801561027657600080fd5b5061027f610ab5565b60405161028c91906111a6565b60405180910390f35b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16630d1b3daf84846040518363ffffffff1660e01b81526004016102f3929190611221565b602060405180830381865afa158015610310573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103349190611266565b905092915050565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461039657600080fd5b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663d0e30db0346040518263ffffffff1660e01b81526004016000604051808303818588803b15801561040057600080fd5b505af1158015610414573d6000803e3d6000fd5b5050505050565b6000600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461047757600080fd5b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166357c6ea3e8585856040518463ffffffff1660e01b81526004016104d493929190611293565b6020604051808303816000875af11580156104f3573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061051791906112fd565b90509392505050565b60035481565b6000600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461058257600080fd5b60016003546105919190611359565b60038190555060008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166390b8436f8686866040518463ffffffff1660e01b81526004016105f793929190611293565b6020604051808303816000875af1158015610616573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061063a91906113db565b9050600160035461064b9190611359565b600381905550809150509392505050565b6000600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146106b857600080fd5b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166390b8436f8585856040518463ffffffff1660e01b815260040161071593929190611293565b6020604051808303816000875af1158015610734573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061075891906113db565b90509392505050565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146107bb57600080fd5b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16632e1a7d4d826040518263ffffffff1660e01b81526004016108169190610d7d565b600060405180830381600087803b15801561083057600080fd5b505af1158015610844573d6000803e3d6000fd5b5050505050565b6000600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146108a757600080fd5b60016003546108b69190611359565b60038190555060008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166390b8436f8585856040518463ffffffff1660e01b815260040161091993929190611293565b6020604051808303816000875af1158015610938573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061095c91906113db565b50600160035461096c9190611359565b6003819055506040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016109a490611454565b60405180910390fd5b6000600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610a0957600080fd5b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663d11a93d0868686866040518563ffffffff1660e01b8152600401610a689493929190611474565b6020604051808303816000875af1158015610a87573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610aab91906112fd565b9050949350505050565b606060008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663f3513a376040518163ffffffff1660e01b8152600401600060405180830381865afa158015610b22573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f82011682018060405250810190610b4b91906116fc565b905090565b6000604051905090565b600080fd5b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000610b8f82610b64565b9050919050565b610b9f81610b84565b8114610baa57600080fd5b50565b600081359050610bbc81610b96565b92915050565b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b610c1582610bcc565b810181811067ffffffffffffffff82111715610c3457610c33610bdd565b5b80604052505050565b6000610c47610b50565b9050610c538282610c0c565b919050565b600067ffffffffffffffff821115610c7357610c72610bdd565b5b610c7c82610bcc565b9050602081019050919050565b82818337600083830152505050565b6000610cab610ca684610c58565b610c3d565b905082815260208101848484011115610cc757610cc6610bc7565b5b610cd2848285610c89565b509392505050565b600082601f830112610cef57610cee610bc2565b5b8135610cff848260208601610c98565b91505092915050565b60008060408385031215610d1f57610d1e610b5a565b5b6000610d2d85828601610bad565b925050602083013567ffffffffffffffff811115610d4e57610d4d610b5f565b5b610d5a85828601610cda565b9150509250929050565b6000819050919050565b610d7781610d64565b82525050565b6000602082019050610d926000830184610d6e565b92915050565b610da181610d64565b8114610dac57600080fd5b50565b600081359050610dbe81610d98565b92915050565b600080600060608486031215610ddd57610ddc610b5a565b5b6000610deb86828701610bad565b935050602084013567ffffffffffffffff811115610e0c57610e0b610b5f565b5b610e1886828701610cda565b9250506040610e2986828701610daf565b9150509250925092565b60008160070b9050919050565b610e4981610e33565b82525050565b6000602082019050610e646000830184610e40565b92915050565b60008115159050919050565b610e7f81610e6a565b82525050565b6000602082019050610e9a6000830184610e76565b92915050565b600060208284031215610eb657610eb5610b5a565b5b6000610ec484828501610daf565b91505092915050565b60008060008060808587031215610ee757610ee6610b5a565b5b6000610ef587828801610bad565b945050602085013567ffffffffffffffff811115610f1657610f15610b5f565b5b610f2287828801610cda565b935050604085013567ffffffffffffffff811115610f4357610f42610b5f565b5b610f4f87828801610cda565b9250506060610f6087828801610daf565b91505092959194509250565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b600081519050919050565b600082825260208201905092915050565b60005b83811015610fd2578082015181840152602081019050610fb7565b83811115610fe1576000848401525b50505050565b6000610ff282610f98565b610ffc8185610fa3565b935061100c818560208601610fb4565b61101581610bcc565b840191505092915050565b61102981610e6a565b82525050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b6004811061106f5761106e61102f565b5b50565b60008190506110808261105e565b919050565b600061109082611072565b9050919050565b6110a081611085565b82525050565b600060808301600083015184820360008601526110c38282610fe7565b915050602083015184820360208601526110dd8282610fe7565b91505060408301516110f26040860182611020565b5060608301516111056060860182611097565b508091505092915050565b600061111c83836110a6565b905092915050565b6000602082019050919050565b600061113c82610f6c565b6111468185610f77565b93508360208202850161115885610f88565b8060005b8581101561119457848403895281516111758582611110565b945061118083611124565b925060208a0199505060018101905061115c565b50829750879550505050505092915050565b600060208201905081810360008301526111c08184611131565b905092915050565b6111d181610b84565b82525050565b600082825260208201905092915050565b60006111f382610f98565b6111fd81856111d7565b935061120d818560208601610fb4565b61121681610bcc565b840191505092915050565b600060408201905061123660008301856111c8565b818103602083015261124881846111e8565b90509392505050565b60008151905061126081610d98565b92915050565b60006020828403121561127c5761127b610b5a565b5b600061128a84828501611251565b91505092915050565b60006060820190506112a860008301866111c8565b81810360208301526112ba81856111e8565b90506112c96040830184610d6e565b949350505050565b6112da81610e33565b81146112e557600080fd5b50565b6000815190506112f7816112d1565b92915050565b60006020828403121561131357611312610b5a565b5b6000611321848285016112e8565b91505092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600061136482610d64565b915061136f83610d64565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff038211156113a4576113a361132a565b5b828201905092915050565b6113b881610e6a565b81146113c357600080fd5b50565b6000815190506113d5816113af565b92915050565b6000602082840312156113f1576113f0610b5a565b5b60006113ff848285016113c6565b91505092915050565b7f7465737472657665727400000000000000000000000000000000000000000000600082015250565b600061143e600a836111d7565b915061144982611408565b602082019050919050565b6000602082019050818103600083015261146d81611431565b9050919050565b600060808201905061148960008301876111c8565b818103602083015261149b81866111e8565b905081810360408301526114af81856111e8565b90506114be6060830184610d6e565b95945050505050565b600067ffffffffffffffff8211156114e2576114e1610bdd565b5b602082029050602081019050919050565b600080fd5b600080fd5b600080fd5b600061151561151084610c58565b610c3d565b90508281526020810184848401111561153157611530610bc7565b5b61153c848285610fb4565b509392505050565b600082601f83011261155957611558610bc2565b5b8151611569848260208601611502565b91505092915050565b6004811061157f57600080fd5b50565b60008151905061159181611572565b92915050565b6000608082840312156115ad576115ac6114f8565b5b6115b76080610c3d565b9050600082015167ffffffffffffffff8111156115d7576115d66114fd565b5b6115e384828501611544565b600083015250602082015167ffffffffffffffff811115611607576116066114fd565b5b61161384828501611544565b6020830152506040611627848285016113c6565b604083015250606061163b84828501611582565b60608301525092915050565b600061165a611655846114c7565b610c3d565b9050808382526020820190506020840283018581111561167d5761167c6114f3565b5b835b818110156116c457805167ffffffffffffffff8111156116a2576116a1610bc2565b5b8086016116af8982611597565b8552602085019450505060208101905061167f565b5050509392505050565b600082601f8301126116e3576116e2610bc2565b5b81516116f3848260208601611647565b91505092915050565b60006020828403121561171257611711610b5a565b5b600082015167ffffffffffffffff8111156117305761172f610b5f565b5b61173c848285016116ce565b9150509291505056fea2646970667358221220fbbd8da0d7360633653761cbde3d46828949fcca1b71279d79140864c678daeb64736f6c634300080a0033 diff --git a/e2e/contracts/teststaking/TestStaking.go b/e2e/contracts/teststaking/TestStaking.go index b124d177dc..2251253862 100644 --- a/e2e/contracts/teststaking/TestStaking.go +++ b/e2e/contracts/teststaking/TestStaking.go @@ -39,8 +39,8 @@ type Validator struct { // TestStakingMetaData contains all meta data concerning the TestStaking contract. var TestStakingMetaData = &bind.MetaData{ - ABI: "[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_wzeta\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"stateMutability\":\"payable\",\"type\":\"fallback\"},{\"inputs\":[],\"name\":\"depositWZETA\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getAllValidators\",\"outputs\":[{\"components\":[{\"internalType\":\"string\",\"name\":\"operatorAddress\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"consensusPubKey\",\"type\":\"string\"},{\"internalType\":\"bool\",\"name\":\"jailed\",\"type\":\"bool\"},{\"internalType\":\"enumBondStatus\",\"name\":\"bondStatus\",\"type\":\"uint8\"}],\"internalType\":\"structValidator[]\",\"name\":\"validators\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"staker\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"validator\",\"type\":\"string\"}],\"name\":\"getShares\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"shares\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"staker\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"validatorSrc\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"validatorDst\",\"type\":\"string\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"moveStake\",\"outputs\":[{\"internalType\":\"int64\",\"name\":\"completionTime\",\"type\":\"int64\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"staker\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"validator\",\"type\":\"string\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"stake\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"staker\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"validator\",\"type\":\"string\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"unstake\",\"outputs\":[{\"internalType\":\"int64\",\"name\":\"completionTime\",\"type\":\"int64\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"wad\",\"type\":\"uint256\"}],\"name\":\"withdrawWZETA\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}]", - Bin: "0x608060405260666000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055503480156200005257600080fd5b50604051620014d3380380620014d383398181016040528101906200007891906200016b565b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555033600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550506200019d565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000620001338262000106565b9050919050565b620001458162000126565b81146200015157600080fd5b50565b60008151905062000165816200013a565b92915050565b60006020828403121562000184576200018362000101565b5b6000620001948482850162000154565b91505092915050565b61132680620001ad6000396000f3fe6080604052600436106100745760003560e01c806390b8436f1161004e57806390b8436f146101015780639a0fb6731461013e578063d11a93d014610167578063f3513a37146101a45761007b565b80630d1b3daf1461007d5780632c5d24ae146100ba57806357c6ea3e146100c45761007b565b3661007b57005b005b34801561008957600080fd5b506100a4600480360381019061009f91906109a4565b6101cf565b6040516100b19190610a19565b60405180910390f35b6100c2610276565b005b3480156100d057600080fd5b506100eb60048036038101906100e69190610a60565b610355565b6040516100f89190610aeb565b60405180910390f35b34801561010d57600080fd5b5061012860048036038101906101239190610a60565b61045a565b6040516101359190610b21565b60405180910390f35b34801561014a57600080fd5b5061016560048036038101906101609190610b3c565b61055f565b005b34801561017357600080fd5b5061018e60048036038101906101899190610b69565b610649565b60405161019b9190610aeb565b60405180910390f35b3480156101b057600080fd5b506101b9610751565b6040516101c69190610e42565b60405180910390f35b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16630d1b3daf84846040518363ffffffff1660e01b815260040161022d929190610ebd565b602060405180830381865afa15801561024a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061026e9190610f02565b905092915050565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146102d057600080fd5b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663d0e30db0346040518263ffffffff1660e01b81526004016000604051808303818588803b15801561033a57600080fd5b505af115801561034e573d6000803e3d6000fd5b5050505050565b6000600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146103b157600080fd5b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166357c6ea3e8585856040518463ffffffff1660e01b815260040161040e93929190610f2f565b6020604051808303816000875af115801561042d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104519190610f99565b90509392505050565b6000600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146104b657600080fd5b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166390b8436f8585856040518463ffffffff1660e01b815260040161051393929190610f2f565b6020604051808303816000875af1158015610532573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105569190610ff2565b90509392505050565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146105b957600080fd5b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16632e1a7d4d826040518263ffffffff1660e01b81526004016106149190610a19565b600060405180830381600087803b15801561062e57600080fd5b505af1158015610642573d6000803e3d6000fd5b5050505050565b6000600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146106a557600080fd5b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663d11a93d0868686866040518563ffffffff1660e01b8152600401610704949392919061101f565b6020604051808303816000875af1158015610723573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107479190610f99565b9050949350505050565b606060008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663f3513a376040518163ffffffff1660e01b8152600401600060405180830381865afa1580156107be573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f820116820180604052508101906107e791906112a7565b905090565b6000604051905090565b600080fd5b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061082b82610800565b9050919050565b61083b81610820565b811461084657600080fd5b50565b60008135905061085881610832565b92915050565b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6108b182610868565b810181811067ffffffffffffffff821117156108d0576108cf610879565b5b80604052505050565b60006108e36107ec565b90506108ef82826108a8565b919050565b600067ffffffffffffffff82111561090f5761090e610879565b5b61091882610868565b9050602081019050919050565b82818337600083830152505050565b6000610947610942846108f4565b6108d9565b90508281526020810184848401111561096357610962610863565b5b61096e848285610925565b509392505050565b600082601f83011261098b5761098a61085e565b5b813561099b848260208601610934565b91505092915050565b600080604083850312156109bb576109ba6107f6565b5b60006109c985828601610849565b925050602083013567ffffffffffffffff8111156109ea576109e96107fb565b5b6109f685828601610976565b9150509250929050565b6000819050919050565b610a1381610a00565b82525050565b6000602082019050610a2e6000830184610a0a565b92915050565b610a3d81610a00565b8114610a4857600080fd5b50565b600081359050610a5a81610a34565b92915050565b600080600060608486031215610a7957610a786107f6565b5b6000610a8786828701610849565b935050602084013567ffffffffffffffff811115610aa857610aa76107fb565b5b610ab486828701610976565b9250506040610ac586828701610a4b565b9150509250925092565b60008160070b9050919050565b610ae581610acf565b82525050565b6000602082019050610b006000830184610adc565b92915050565b60008115159050919050565b610b1b81610b06565b82525050565b6000602082019050610b366000830184610b12565b92915050565b600060208284031215610b5257610b516107f6565b5b6000610b6084828501610a4b565b91505092915050565b60008060008060808587031215610b8357610b826107f6565b5b6000610b9187828801610849565b945050602085013567ffffffffffffffff811115610bb257610bb16107fb565b5b610bbe87828801610976565b935050604085013567ffffffffffffffff811115610bdf57610bde6107fb565b5b610beb87828801610976565b9250506060610bfc87828801610a4b565b91505092959194509250565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b600081519050919050565b600082825260208201905092915050565b60005b83811015610c6e578082015181840152602081019050610c53565b83811115610c7d576000848401525b50505050565b6000610c8e82610c34565b610c988185610c3f565b9350610ca8818560208601610c50565b610cb181610868565b840191505092915050565b610cc581610b06565b82525050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b60048110610d0b57610d0a610ccb565b5b50565b6000819050610d1c82610cfa565b919050565b6000610d2c82610d0e565b9050919050565b610d3c81610d21565b82525050565b60006080830160008301518482036000860152610d5f8282610c83565b91505060208301518482036020860152610d798282610c83565b9150506040830151610d8e6040860182610cbc565b506060830151610da16060860182610d33565b508091505092915050565b6000610db88383610d42565b905092915050565b6000602082019050919050565b6000610dd882610c08565b610de28185610c13565b935083602082028501610df485610c24565b8060005b85811015610e305784840389528151610e118582610dac565b9450610e1c83610dc0565b925060208a01995050600181019050610df8565b50829750879550505050505092915050565b60006020820190508181036000830152610e5c8184610dcd565b905092915050565b610e6d81610820565b82525050565b600082825260208201905092915050565b6000610e8f82610c34565b610e998185610e73565b9350610ea9818560208601610c50565b610eb281610868565b840191505092915050565b6000604082019050610ed26000830185610e64565b8181036020830152610ee48184610e84565b90509392505050565b600081519050610efc81610a34565b92915050565b600060208284031215610f1857610f176107f6565b5b6000610f2684828501610eed565b91505092915050565b6000606082019050610f446000830186610e64565b8181036020830152610f568185610e84565b9050610f656040830184610a0a565b949350505050565b610f7681610acf565b8114610f8157600080fd5b50565b600081519050610f9381610f6d565b92915050565b600060208284031215610faf57610fae6107f6565b5b6000610fbd84828501610f84565b91505092915050565b610fcf81610b06565b8114610fda57600080fd5b50565b600081519050610fec81610fc6565b92915050565b600060208284031215611008576110076107f6565b5b600061101684828501610fdd565b91505092915050565b60006080820190506110346000830187610e64565b81810360208301526110468186610e84565b9050818103604083015261105a8185610e84565b90506110696060830184610a0a565b95945050505050565b600067ffffffffffffffff82111561108d5761108c610879565b5b602082029050602081019050919050565b600080fd5b600080fd5b600080fd5b60006110c06110bb846108f4565b6108d9565b9050828152602081018484840111156110dc576110db610863565b5b6110e7848285610c50565b509392505050565b600082601f8301126111045761110361085e565b5b81516111148482602086016110ad565b91505092915050565b6004811061112a57600080fd5b50565b60008151905061113c8161111d565b92915050565b600060808284031215611158576111576110a3565b5b61116260806108d9565b9050600082015167ffffffffffffffff811115611182576111816110a8565b5b61118e848285016110ef565b600083015250602082015167ffffffffffffffff8111156111b2576111b16110a8565b5b6111be848285016110ef565b60208301525060406111d284828501610fdd565b60408301525060606111e68482850161112d565b60608301525092915050565b600061120561120084611072565b6108d9565b905080838252602082019050602084028301858111156112285761122761109e565b5b835b8181101561126f57805167ffffffffffffffff81111561124d5761124c61085e565b5b80860161125a8982611142565b8552602085019450505060208101905061122a565b5050509392505050565b600082601f83011261128e5761128d61085e565b5b815161129e8482602086016111f2565b91505092915050565b6000602082840312156112bd576112bc6107f6565b5b600082015167ffffffffffffffff8111156112db576112da6107fb565b5b6112e784828501611279565b9150509291505056fea26469706673582212209d34227b9c73d9c6eb2b67ca8fabedb28adcac235655b12df2a572847549ea2a64736f6c634300080a0033", + ABI: "[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_wzeta\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"stateMutability\":\"payable\",\"type\":\"fallback\"},{\"inputs\":[],\"name\":\"counter\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"depositWZETA\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getAllValidators\",\"outputs\":[{\"components\":[{\"internalType\":\"string\",\"name\":\"operatorAddress\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"consensusPubKey\",\"type\":\"string\"},{\"internalType\":\"bool\",\"name\":\"jailed\",\"type\":\"bool\"},{\"internalType\":\"enumBondStatus\",\"name\":\"bondStatus\",\"type\":\"uint8\"}],\"internalType\":\"structValidator[]\",\"name\":\"validators\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"staker\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"validator\",\"type\":\"string\"}],\"name\":\"getShares\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"shares\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"staker\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"validatorSrc\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"validatorDst\",\"type\":\"string\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"moveStake\",\"outputs\":[{\"internalType\":\"int64\",\"name\":\"completionTime\",\"type\":\"int64\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"staker\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"validator\",\"type\":\"string\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"stake\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"staker\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"validator\",\"type\":\"string\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"stakeAndRevert\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"staker\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"validator\",\"type\":\"string\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"stakeWithStateUpdate\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"staker\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"validator\",\"type\":\"string\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"unstake\",\"outputs\":[{\"internalType\":\"int64\",\"name\":\"completionTime\",\"type\":\"int64\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"wad\",\"type\":\"uint256\"}],\"name\":\"withdrawWZETA\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}]", + Bin: "0x608060405260666000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060006003553480156200005757600080fd5b506040516200192d3803806200192d83398181016040528101906200007d919062000170565b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555033600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050620001a2565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600062000138826200010b565b9050919050565b6200014a816200012b565b81146200015657600080fd5b50565b6000815190506200016a816200013f565b92915050565b60006020828403121562000189576200018862000106565b5b6000620001998482850162000159565b91505092915050565b61177b80620001b26000396000f3fe6080604052600436106100955760003560e01c806390b8436f1161005957806390b8436f1461018a5780639a0fb673146101c7578063bca8f527146101f0578063d11a93d01461022d578063f3513a371461026a5761009c565b80630d1b3daf1461009e5780632c5d24ae146100db57806357c6ea3e146100e557806361bc221a146101225780636be8916c1461014d5761009c565b3661009c57005b005b3480156100aa57600080fd5b506100c560048036038101906100c09190610d08565b610295565b6040516100d29190610d7d565b60405180910390f35b6100e361033c565b005b3480156100f157600080fd5b5061010c60048036038101906101079190610dc4565b61041b565b6040516101199190610e4f565b60405180910390f35b34801561012e57600080fd5b50610137610520565b6040516101449190610d7d565b60405180910390f35b34801561015957600080fd5b50610174600480360381019061016f9190610dc4565b610526565b6040516101819190610e85565b60405180910390f35b34801561019657600080fd5b506101b160048036038101906101ac9190610dc4565b61065c565b6040516101be9190610e85565b60405180910390f35b3480156101d357600080fd5b506101ee60048036038101906101e99190610ea0565b610761565b005b3480156101fc57600080fd5b5061021760048036038101906102129190610dc4565b61084b565b6040516102249190610e85565b60405180910390f35b34801561023957600080fd5b50610254600480360381019061024f9190610ecd565b6109ad565b6040516102619190610e4f565b60405180910390f35b34801561027657600080fd5b5061027f610ab5565b60405161028c91906111a6565b60405180910390f35b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16630d1b3daf84846040518363ffffffff1660e01b81526004016102f3929190611221565b602060405180830381865afa158015610310573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103349190611266565b905092915050565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461039657600080fd5b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663d0e30db0346040518263ffffffff1660e01b81526004016000604051808303818588803b15801561040057600080fd5b505af1158015610414573d6000803e3d6000fd5b5050505050565b6000600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461047757600080fd5b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166357c6ea3e8585856040518463ffffffff1660e01b81526004016104d493929190611293565b6020604051808303816000875af11580156104f3573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061051791906112fd565b90509392505050565b60035481565b6000600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461058257600080fd5b60016003546105919190611359565b60038190555060008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166390b8436f8686866040518463ffffffff1660e01b81526004016105f793929190611293565b6020604051808303816000875af1158015610616573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061063a91906113db565b9050600160035461064b9190611359565b600381905550809150509392505050565b6000600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146106b857600080fd5b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166390b8436f8585856040518463ffffffff1660e01b815260040161071593929190611293565b6020604051808303816000875af1158015610734573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061075891906113db565b90509392505050565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146107bb57600080fd5b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16632e1a7d4d826040518263ffffffff1660e01b81526004016108169190610d7d565b600060405180830381600087803b15801561083057600080fd5b505af1158015610844573d6000803e3d6000fd5b5050505050565b6000600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146108a757600080fd5b60016003546108b69190611359565b60038190555060008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166390b8436f8585856040518463ffffffff1660e01b815260040161091993929190611293565b6020604051808303816000875af1158015610938573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061095c91906113db565b50600160035461096c9190611359565b6003819055506040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016109a490611454565b60405180910390fd5b6000600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610a0957600080fd5b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663d11a93d0868686866040518563ffffffff1660e01b8152600401610a689493929190611474565b6020604051808303816000875af1158015610a87573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610aab91906112fd565b9050949350505050565b606060008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663f3513a376040518163ffffffff1660e01b8152600401600060405180830381865afa158015610b22573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f82011682018060405250810190610b4b91906116fc565b905090565b6000604051905090565b600080fd5b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000610b8f82610b64565b9050919050565b610b9f81610b84565b8114610baa57600080fd5b50565b600081359050610bbc81610b96565b92915050565b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b610c1582610bcc565b810181811067ffffffffffffffff82111715610c3457610c33610bdd565b5b80604052505050565b6000610c47610b50565b9050610c538282610c0c565b919050565b600067ffffffffffffffff821115610c7357610c72610bdd565b5b610c7c82610bcc565b9050602081019050919050565b82818337600083830152505050565b6000610cab610ca684610c58565b610c3d565b905082815260208101848484011115610cc757610cc6610bc7565b5b610cd2848285610c89565b509392505050565b600082601f830112610cef57610cee610bc2565b5b8135610cff848260208601610c98565b91505092915050565b60008060408385031215610d1f57610d1e610b5a565b5b6000610d2d85828601610bad565b925050602083013567ffffffffffffffff811115610d4e57610d4d610b5f565b5b610d5a85828601610cda565b9150509250929050565b6000819050919050565b610d7781610d64565b82525050565b6000602082019050610d926000830184610d6e565b92915050565b610da181610d64565b8114610dac57600080fd5b50565b600081359050610dbe81610d98565b92915050565b600080600060608486031215610ddd57610ddc610b5a565b5b6000610deb86828701610bad565b935050602084013567ffffffffffffffff811115610e0c57610e0b610b5f565b5b610e1886828701610cda565b9250506040610e2986828701610daf565b9150509250925092565b60008160070b9050919050565b610e4981610e33565b82525050565b6000602082019050610e646000830184610e40565b92915050565b60008115159050919050565b610e7f81610e6a565b82525050565b6000602082019050610e9a6000830184610e76565b92915050565b600060208284031215610eb657610eb5610b5a565b5b6000610ec484828501610daf565b91505092915050565b60008060008060808587031215610ee757610ee6610b5a565b5b6000610ef587828801610bad565b945050602085013567ffffffffffffffff811115610f1657610f15610b5f565b5b610f2287828801610cda565b935050604085013567ffffffffffffffff811115610f4357610f42610b5f565b5b610f4f87828801610cda565b9250506060610f6087828801610daf565b91505092959194509250565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b600081519050919050565b600082825260208201905092915050565b60005b83811015610fd2578082015181840152602081019050610fb7565b83811115610fe1576000848401525b50505050565b6000610ff282610f98565b610ffc8185610fa3565b935061100c818560208601610fb4565b61101581610bcc565b840191505092915050565b61102981610e6a565b82525050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b6004811061106f5761106e61102f565b5b50565b60008190506110808261105e565b919050565b600061109082611072565b9050919050565b6110a081611085565b82525050565b600060808301600083015184820360008601526110c38282610fe7565b915050602083015184820360208601526110dd8282610fe7565b91505060408301516110f26040860182611020565b5060608301516111056060860182611097565b508091505092915050565b600061111c83836110a6565b905092915050565b6000602082019050919050565b600061113c82610f6c565b6111468185610f77565b93508360208202850161115885610f88565b8060005b8581101561119457848403895281516111758582611110565b945061118083611124565b925060208a0199505060018101905061115c565b50829750879550505050505092915050565b600060208201905081810360008301526111c08184611131565b905092915050565b6111d181610b84565b82525050565b600082825260208201905092915050565b60006111f382610f98565b6111fd81856111d7565b935061120d818560208601610fb4565b61121681610bcc565b840191505092915050565b600060408201905061123660008301856111c8565b818103602083015261124881846111e8565b90509392505050565b60008151905061126081610d98565b92915050565b60006020828403121561127c5761127b610b5a565b5b600061128a84828501611251565b91505092915050565b60006060820190506112a860008301866111c8565b81810360208301526112ba81856111e8565b90506112c96040830184610d6e565b949350505050565b6112da81610e33565b81146112e557600080fd5b50565b6000815190506112f7816112d1565b92915050565b60006020828403121561131357611312610b5a565b5b6000611321848285016112e8565b91505092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600061136482610d64565b915061136f83610d64565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff038211156113a4576113a361132a565b5b828201905092915050565b6113b881610e6a565b81146113c357600080fd5b50565b6000815190506113d5816113af565b92915050565b6000602082840312156113f1576113f0610b5a565b5b60006113ff848285016113c6565b91505092915050565b7f7465737472657665727400000000000000000000000000000000000000000000600082015250565b600061143e600a836111d7565b915061144982611408565b602082019050919050565b6000602082019050818103600083015261146d81611431565b9050919050565b600060808201905061148960008301876111c8565b818103602083015261149b81866111e8565b905081810360408301526114af81856111e8565b90506114be6060830184610d6e565b95945050505050565b600067ffffffffffffffff8211156114e2576114e1610bdd565b5b602082029050602081019050919050565b600080fd5b600080fd5b600080fd5b600061151561151084610c58565b610c3d565b90508281526020810184848401111561153157611530610bc7565b5b61153c848285610fb4565b509392505050565b600082601f83011261155957611558610bc2565b5b8151611569848260208601611502565b91505092915050565b6004811061157f57600080fd5b50565b60008151905061159181611572565b92915050565b6000608082840312156115ad576115ac6114f8565b5b6115b76080610c3d565b9050600082015167ffffffffffffffff8111156115d7576115d66114fd565b5b6115e384828501611544565b600083015250602082015167ffffffffffffffff811115611607576116066114fd565b5b61161384828501611544565b6020830152506040611627848285016113c6565b604083015250606061163b84828501611582565b60608301525092915050565b600061165a611655846114c7565b610c3d565b9050808382526020820190506020840283018581111561167d5761167c6114f3565b5b835b818110156116c457805167ffffffffffffffff8111156116a2576116a1610bc2565b5b8086016116af8982611597565b8552602085019450505060208101905061167f565b5050509392505050565b600082601f8301126116e3576116e2610bc2565b5b81516116f3848260208601611647565b91505092915050565b60006020828403121561171257611711610b5a565b5b600082015167ffffffffffffffff8111156117305761172f610b5f565b5b61173c848285016116ce565b9150509291505056fea2646970667358221220fbbd8da0d7360633653761cbde3d46828949fcca1b71279d79140864c678daeb64736f6c634300080a0033", } // TestStakingABI is the input ABI used to generate the binding from. @@ -210,6 +210,37 @@ func (_TestStaking *TestStakingTransactorRaw) Transact(opts *bind.TransactOpts, return _TestStaking.Contract.contract.Transact(opts, method, params...) } +// Counter is a free data retrieval call binding the contract method 0x61bc221a. +// +// Solidity: function counter() view returns(uint256) +func (_TestStaking *TestStakingCaller) Counter(opts *bind.CallOpts) (*big.Int, error) { + var out []interface{} + err := _TestStaking.contract.Call(opts, &out, "counter") + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// Counter is a free data retrieval call binding the contract method 0x61bc221a. +// +// Solidity: function counter() view returns(uint256) +func (_TestStaking *TestStakingSession) Counter() (*big.Int, error) { + return _TestStaking.Contract.Counter(&_TestStaking.CallOpts) +} + +// Counter is a free data retrieval call binding the contract method 0x61bc221a. +// +// Solidity: function counter() view returns(uint256) +func (_TestStaking *TestStakingCallerSession) Counter() (*big.Int, error) { + return _TestStaking.Contract.Counter(&_TestStaking.CallOpts) +} + // GetAllValidators is a free data retrieval call binding the contract method 0xf3513a37. // // Solidity: function getAllValidators() view returns((string,string,bool,uint8)[] validators) @@ -335,6 +366,48 @@ func (_TestStaking *TestStakingTransactorSession) Stake(staker common.Address, v return _TestStaking.Contract.Stake(&_TestStaking.TransactOpts, staker, validator, amount) } +// StakeAndRevert is a paid mutator transaction binding the contract method 0xbca8f527. +// +// Solidity: function stakeAndRevert(address staker, string validator, uint256 amount) returns(bool) +func (_TestStaking *TestStakingTransactor) StakeAndRevert(opts *bind.TransactOpts, staker common.Address, validator string, amount *big.Int) (*types.Transaction, error) { + return _TestStaking.contract.Transact(opts, "stakeAndRevert", staker, validator, amount) +} + +// StakeAndRevert is a paid mutator transaction binding the contract method 0xbca8f527. +// +// Solidity: function stakeAndRevert(address staker, string validator, uint256 amount) returns(bool) +func (_TestStaking *TestStakingSession) StakeAndRevert(staker common.Address, validator string, amount *big.Int) (*types.Transaction, error) { + return _TestStaking.Contract.StakeAndRevert(&_TestStaking.TransactOpts, staker, validator, amount) +} + +// StakeAndRevert is a paid mutator transaction binding the contract method 0xbca8f527. +// +// Solidity: function stakeAndRevert(address staker, string validator, uint256 amount) returns(bool) +func (_TestStaking *TestStakingTransactorSession) StakeAndRevert(staker common.Address, validator string, amount *big.Int) (*types.Transaction, error) { + return _TestStaking.Contract.StakeAndRevert(&_TestStaking.TransactOpts, staker, validator, amount) +} + +// StakeWithStateUpdate is a paid mutator transaction binding the contract method 0x6be8916c. +// +// Solidity: function stakeWithStateUpdate(address staker, string validator, uint256 amount) returns(bool) +func (_TestStaking *TestStakingTransactor) StakeWithStateUpdate(opts *bind.TransactOpts, staker common.Address, validator string, amount *big.Int) (*types.Transaction, error) { + return _TestStaking.contract.Transact(opts, "stakeWithStateUpdate", staker, validator, amount) +} + +// StakeWithStateUpdate is a paid mutator transaction binding the contract method 0x6be8916c. +// +// Solidity: function stakeWithStateUpdate(address staker, string validator, uint256 amount) returns(bool) +func (_TestStaking *TestStakingSession) StakeWithStateUpdate(staker common.Address, validator string, amount *big.Int) (*types.Transaction, error) { + return _TestStaking.Contract.StakeWithStateUpdate(&_TestStaking.TransactOpts, staker, validator, amount) +} + +// StakeWithStateUpdate is a paid mutator transaction binding the contract method 0x6be8916c. +// +// Solidity: function stakeWithStateUpdate(address staker, string validator, uint256 amount) returns(bool) +func (_TestStaking *TestStakingTransactorSession) StakeWithStateUpdate(staker common.Address, validator string, amount *big.Int) (*types.Transaction, error) { + return _TestStaking.Contract.StakeWithStateUpdate(&_TestStaking.TransactOpts, staker, validator, amount) +} + // Unstake is a paid mutator transaction binding the contract method 0x57c6ea3e. // // Solidity: function unstake(address staker, string validator, uint256 amount) returns(int64 completionTime) diff --git a/e2e/contracts/teststaking/TestStaking.json b/e2e/contracts/teststaking/TestStaking.json index ebc45c196a..fbfc23ab37 100644 --- a/e2e/contracts/teststaking/TestStaking.json +++ b/e2e/contracts/teststaking/TestStaking.json @@ -15,6 +15,19 @@ "stateMutability": "payable", "type": "fallback" }, + { + "inputs": [], + "name": "counter", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, { "inputs": [], "name": "depositWZETA", @@ -144,6 +157,64 @@ "stateMutability": "nonpayable", "type": "function" }, + { + "inputs": [ + { + "internalType": "address", + "name": "staker", + "type": "address" + }, + { + "internalType": "string", + "name": "validator", + "type": "string" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "stakeAndRevert", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "staker", + "type": "address" + }, + { + "internalType": "string", + "name": "validator", + "type": "string" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "stakeWithStateUpdate", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, { "inputs": [ { @@ -191,5 +262,5 @@ "type": "receive" } ], - "bin": "608060405260666000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055503480156200005257600080fd5b50604051620014d3380380620014d383398181016040528101906200007891906200016b565b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555033600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550506200019d565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000620001338262000106565b9050919050565b620001458162000126565b81146200015157600080fd5b50565b60008151905062000165816200013a565b92915050565b60006020828403121562000184576200018362000101565b5b6000620001948482850162000154565b91505092915050565b61132680620001ad6000396000f3fe6080604052600436106100745760003560e01c806390b8436f1161004e57806390b8436f146101015780639a0fb6731461013e578063d11a93d014610167578063f3513a37146101a45761007b565b80630d1b3daf1461007d5780632c5d24ae146100ba57806357c6ea3e146100c45761007b565b3661007b57005b005b34801561008957600080fd5b506100a4600480360381019061009f91906109a4565b6101cf565b6040516100b19190610a19565b60405180910390f35b6100c2610276565b005b3480156100d057600080fd5b506100eb60048036038101906100e69190610a60565b610355565b6040516100f89190610aeb565b60405180910390f35b34801561010d57600080fd5b5061012860048036038101906101239190610a60565b61045a565b6040516101359190610b21565b60405180910390f35b34801561014a57600080fd5b5061016560048036038101906101609190610b3c565b61055f565b005b34801561017357600080fd5b5061018e60048036038101906101899190610b69565b610649565b60405161019b9190610aeb565b60405180910390f35b3480156101b057600080fd5b506101b9610751565b6040516101c69190610e42565b60405180910390f35b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16630d1b3daf84846040518363ffffffff1660e01b815260040161022d929190610ebd565b602060405180830381865afa15801561024a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061026e9190610f02565b905092915050565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146102d057600080fd5b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663d0e30db0346040518263ffffffff1660e01b81526004016000604051808303818588803b15801561033a57600080fd5b505af115801561034e573d6000803e3d6000fd5b5050505050565b6000600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146103b157600080fd5b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166357c6ea3e8585856040518463ffffffff1660e01b815260040161040e93929190610f2f565b6020604051808303816000875af115801561042d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104519190610f99565b90509392505050565b6000600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146104b657600080fd5b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166390b8436f8585856040518463ffffffff1660e01b815260040161051393929190610f2f565b6020604051808303816000875af1158015610532573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105569190610ff2565b90509392505050565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146105b957600080fd5b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16632e1a7d4d826040518263ffffffff1660e01b81526004016106149190610a19565b600060405180830381600087803b15801561062e57600080fd5b505af1158015610642573d6000803e3d6000fd5b5050505050565b6000600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146106a557600080fd5b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663d11a93d0868686866040518563ffffffff1660e01b8152600401610704949392919061101f565b6020604051808303816000875af1158015610723573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107479190610f99565b9050949350505050565b606060008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663f3513a376040518163ffffffff1660e01b8152600401600060405180830381865afa1580156107be573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f820116820180604052508101906107e791906112a7565b905090565b6000604051905090565b600080fd5b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061082b82610800565b9050919050565b61083b81610820565b811461084657600080fd5b50565b60008135905061085881610832565b92915050565b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6108b182610868565b810181811067ffffffffffffffff821117156108d0576108cf610879565b5b80604052505050565b60006108e36107ec565b90506108ef82826108a8565b919050565b600067ffffffffffffffff82111561090f5761090e610879565b5b61091882610868565b9050602081019050919050565b82818337600083830152505050565b6000610947610942846108f4565b6108d9565b90508281526020810184848401111561096357610962610863565b5b61096e848285610925565b509392505050565b600082601f83011261098b5761098a61085e565b5b813561099b848260208601610934565b91505092915050565b600080604083850312156109bb576109ba6107f6565b5b60006109c985828601610849565b925050602083013567ffffffffffffffff8111156109ea576109e96107fb565b5b6109f685828601610976565b9150509250929050565b6000819050919050565b610a1381610a00565b82525050565b6000602082019050610a2e6000830184610a0a565b92915050565b610a3d81610a00565b8114610a4857600080fd5b50565b600081359050610a5a81610a34565b92915050565b600080600060608486031215610a7957610a786107f6565b5b6000610a8786828701610849565b935050602084013567ffffffffffffffff811115610aa857610aa76107fb565b5b610ab486828701610976565b9250506040610ac586828701610a4b565b9150509250925092565b60008160070b9050919050565b610ae581610acf565b82525050565b6000602082019050610b006000830184610adc565b92915050565b60008115159050919050565b610b1b81610b06565b82525050565b6000602082019050610b366000830184610b12565b92915050565b600060208284031215610b5257610b516107f6565b5b6000610b6084828501610a4b565b91505092915050565b60008060008060808587031215610b8357610b826107f6565b5b6000610b9187828801610849565b945050602085013567ffffffffffffffff811115610bb257610bb16107fb565b5b610bbe87828801610976565b935050604085013567ffffffffffffffff811115610bdf57610bde6107fb565b5b610beb87828801610976565b9250506060610bfc87828801610a4b565b91505092959194509250565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b600081519050919050565b600082825260208201905092915050565b60005b83811015610c6e578082015181840152602081019050610c53565b83811115610c7d576000848401525b50505050565b6000610c8e82610c34565b610c988185610c3f565b9350610ca8818560208601610c50565b610cb181610868565b840191505092915050565b610cc581610b06565b82525050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b60048110610d0b57610d0a610ccb565b5b50565b6000819050610d1c82610cfa565b919050565b6000610d2c82610d0e565b9050919050565b610d3c81610d21565b82525050565b60006080830160008301518482036000860152610d5f8282610c83565b91505060208301518482036020860152610d798282610c83565b9150506040830151610d8e6040860182610cbc565b506060830151610da16060860182610d33565b508091505092915050565b6000610db88383610d42565b905092915050565b6000602082019050919050565b6000610dd882610c08565b610de28185610c13565b935083602082028501610df485610c24565b8060005b85811015610e305784840389528151610e118582610dac565b9450610e1c83610dc0565b925060208a01995050600181019050610df8565b50829750879550505050505092915050565b60006020820190508181036000830152610e5c8184610dcd565b905092915050565b610e6d81610820565b82525050565b600082825260208201905092915050565b6000610e8f82610c34565b610e998185610e73565b9350610ea9818560208601610c50565b610eb281610868565b840191505092915050565b6000604082019050610ed26000830185610e64565b8181036020830152610ee48184610e84565b90509392505050565b600081519050610efc81610a34565b92915050565b600060208284031215610f1857610f176107f6565b5b6000610f2684828501610eed565b91505092915050565b6000606082019050610f446000830186610e64565b8181036020830152610f568185610e84565b9050610f656040830184610a0a565b949350505050565b610f7681610acf565b8114610f8157600080fd5b50565b600081519050610f9381610f6d565b92915050565b600060208284031215610faf57610fae6107f6565b5b6000610fbd84828501610f84565b91505092915050565b610fcf81610b06565b8114610fda57600080fd5b50565b600081519050610fec81610fc6565b92915050565b600060208284031215611008576110076107f6565b5b600061101684828501610fdd565b91505092915050565b60006080820190506110346000830187610e64565b81810360208301526110468186610e84565b9050818103604083015261105a8185610e84565b90506110696060830184610a0a565b95945050505050565b600067ffffffffffffffff82111561108d5761108c610879565b5b602082029050602081019050919050565b600080fd5b600080fd5b600080fd5b60006110c06110bb846108f4565b6108d9565b9050828152602081018484840111156110dc576110db610863565b5b6110e7848285610c50565b509392505050565b600082601f8301126111045761110361085e565b5b81516111148482602086016110ad565b91505092915050565b6004811061112a57600080fd5b50565b60008151905061113c8161111d565b92915050565b600060808284031215611158576111576110a3565b5b61116260806108d9565b9050600082015167ffffffffffffffff811115611182576111816110a8565b5b61118e848285016110ef565b600083015250602082015167ffffffffffffffff8111156111b2576111b16110a8565b5b6111be848285016110ef565b60208301525060406111d284828501610fdd565b60408301525060606111e68482850161112d565b60608301525092915050565b600061120561120084611072565b6108d9565b905080838252602082019050602084028301858111156112285761122761109e565b5b835b8181101561126f57805167ffffffffffffffff81111561124d5761124c61085e565b5b80860161125a8982611142565b8552602085019450505060208101905061122a565b5050509392505050565b600082601f83011261128e5761128d61085e565b5b815161129e8482602086016111f2565b91505092915050565b6000602082840312156112bd576112bc6107f6565b5b600082015167ffffffffffffffff8111156112db576112da6107fb565b5b6112e784828501611279565b9150509291505056fea26469706673582212209d34227b9c73d9c6eb2b67ca8fabedb28adcac235655b12df2a572847549ea2a64736f6c634300080a0033" + "bin": "608060405260666000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060006003553480156200005757600080fd5b506040516200192d3803806200192d83398181016040528101906200007d919062000170565b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555033600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050620001a2565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600062000138826200010b565b9050919050565b6200014a816200012b565b81146200015657600080fd5b50565b6000815190506200016a816200013f565b92915050565b60006020828403121562000189576200018862000106565b5b6000620001998482850162000159565b91505092915050565b61177b80620001b26000396000f3fe6080604052600436106100955760003560e01c806390b8436f1161005957806390b8436f1461018a5780639a0fb673146101c7578063bca8f527146101f0578063d11a93d01461022d578063f3513a371461026a5761009c565b80630d1b3daf1461009e5780632c5d24ae146100db57806357c6ea3e146100e557806361bc221a146101225780636be8916c1461014d5761009c565b3661009c57005b005b3480156100aa57600080fd5b506100c560048036038101906100c09190610d08565b610295565b6040516100d29190610d7d565b60405180910390f35b6100e361033c565b005b3480156100f157600080fd5b5061010c60048036038101906101079190610dc4565b61041b565b6040516101199190610e4f565b60405180910390f35b34801561012e57600080fd5b50610137610520565b6040516101449190610d7d565b60405180910390f35b34801561015957600080fd5b50610174600480360381019061016f9190610dc4565b610526565b6040516101819190610e85565b60405180910390f35b34801561019657600080fd5b506101b160048036038101906101ac9190610dc4565b61065c565b6040516101be9190610e85565b60405180910390f35b3480156101d357600080fd5b506101ee60048036038101906101e99190610ea0565b610761565b005b3480156101fc57600080fd5b5061021760048036038101906102129190610dc4565b61084b565b6040516102249190610e85565b60405180910390f35b34801561023957600080fd5b50610254600480360381019061024f9190610ecd565b6109ad565b6040516102619190610e4f565b60405180910390f35b34801561027657600080fd5b5061027f610ab5565b60405161028c91906111a6565b60405180910390f35b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16630d1b3daf84846040518363ffffffff1660e01b81526004016102f3929190611221565b602060405180830381865afa158015610310573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103349190611266565b905092915050565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461039657600080fd5b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663d0e30db0346040518263ffffffff1660e01b81526004016000604051808303818588803b15801561040057600080fd5b505af1158015610414573d6000803e3d6000fd5b5050505050565b6000600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461047757600080fd5b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166357c6ea3e8585856040518463ffffffff1660e01b81526004016104d493929190611293565b6020604051808303816000875af11580156104f3573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061051791906112fd565b90509392505050565b60035481565b6000600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461058257600080fd5b60016003546105919190611359565b60038190555060008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166390b8436f8686866040518463ffffffff1660e01b81526004016105f793929190611293565b6020604051808303816000875af1158015610616573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061063a91906113db565b9050600160035461064b9190611359565b600381905550809150509392505050565b6000600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146106b857600080fd5b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166390b8436f8585856040518463ffffffff1660e01b815260040161071593929190611293565b6020604051808303816000875af1158015610734573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061075891906113db565b90509392505050565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146107bb57600080fd5b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16632e1a7d4d826040518263ffffffff1660e01b81526004016108169190610d7d565b600060405180830381600087803b15801561083057600080fd5b505af1158015610844573d6000803e3d6000fd5b5050505050565b6000600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146108a757600080fd5b60016003546108b69190611359565b60038190555060008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166390b8436f8585856040518463ffffffff1660e01b815260040161091993929190611293565b6020604051808303816000875af1158015610938573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061095c91906113db565b50600160035461096c9190611359565b6003819055506040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016109a490611454565b60405180910390fd5b6000600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610a0957600080fd5b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663d11a93d0868686866040518563ffffffff1660e01b8152600401610a689493929190611474565b6020604051808303816000875af1158015610a87573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610aab91906112fd565b9050949350505050565b606060008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663f3513a376040518163ffffffff1660e01b8152600401600060405180830381865afa158015610b22573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f82011682018060405250810190610b4b91906116fc565b905090565b6000604051905090565b600080fd5b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000610b8f82610b64565b9050919050565b610b9f81610b84565b8114610baa57600080fd5b50565b600081359050610bbc81610b96565b92915050565b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b610c1582610bcc565b810181811067ffffffffffffffff82111715610c3457610c33610bdd565b5b80604052505050565b6000610c47610b50565b9050610c538282610c0c565b919050565b600067ffffffffffffffff821115610c7357610c72610bdd565b5b610c7c82610bcc565b9050602081019050919050565b82818337600083830152505050565b6000610cab610ca684610c58565b610c3d565b905082815260208101848484011115610cc757610cc6610bc7565b5b610cd2848285610c89565b509392505050565b600082601f830112610cef57610cee610bc2565b5b8135610cff848260208601610c98565b91505092915050565b60008060408385031215610d1f57610d1e610b5a565b5b6000610d2d85828601610bad565b925050602083013567ffffffffffffffff811115610d4e57610d4d610b5f565b5b610d5a85828601610cda565b9150509250929050565b6000819050919050565b610d7781610d64565b82525050565b6000602082019050610d926000830184610d6e565b92915050565b610da181610d64565b8114610dac57600080fd5b50565b600081359050610dbe81610d98565b92915050565b600080600060608486031215610ddd57610ddc610b5a565b5b6000610deb86828701610bad565b935050602084013567ffffffffffffffff811115610e0c57610e0b610b5f565b5b610e1886828701610cda565b9250506040610e2986828701610daf565b9150509250925092565b60008160070b9050919050565b610e4981610e33565b82525050565b6000602082019050610e646000830184610e40565b92915050565b60008115159050919050565b610e7f81610e6a565b82525050565b6000602082019050610e9a6000830184610e76565b92915050565b600060208284031215610eb657610eb5610b5a565b5b6000610ec484828501610daf565b91505092915050565b60008060008060808587031215610ee757610ee6610b5a565b5b6000610ef587828801610bad565b945050602085013567ffffffffffffffff811115610f1657610f15610b5f565b5b610f2287828801610cda565b935050604085013567ffffffffffffffff811115610f4357610f42610b5f565b5b610f4f87828801610cda565b9250506060610f6087828801610daf565b91505092959194509250565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b600081519050919050565b600082825260208201905092915050565b60005b83811015610fd2578082015181840152602081019050610fb7565b83811115610fe1576000848401525b50505050565b6000610ff282610f98565b610ffc8185610fa3565b935061100c818560208601610fb4565b61101581610bcc565b840191505092915050565b61102981610e6a565b82525050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b6004811061106f5761106e61102f565b5b50565b60008190506110808261105e565b919050565b600061109082611072565b9050919050565b6110a081611085565b82525050565b600060808301600083015184820360008601526110c38282610fe7565b915050602083015184820360208601526110dd8282610fe7565b91505060408301516110f26040860182611020565b5060608301516111056060860182611097565b508091505092915050565b600061111c83836110a6565b905092915050565b6000602082019050919050565b600061113c82610f6c565b6111468185610f77565b93508360208202850161115885610f88565b8060005b8581101561119457848403895281516111758582611110565b945061118083611124565b925060208a0199505060018101905061115c565b50829750879550505050505092915050565b600060208201905081810360008301526111c08184611131565b905092915050565b6111d181610b84565b82525050565b600082825260208201905092915050565b60006111f382610f98565b6111fd81856111d7565b935061120d818560208601610fb4565b61121681610bcc565b840191505092915050565b600060408201905061123660008301856111c8565b818103602083015261124881846111e8565b90509392505050565b60008151905061126081610d98565b92915050565b60006020828403121561127c5761127b610b5a565b5b600061128a84828501611251565b91505092915050565b60006060820190506112a860008301866111c8565b81810360208301526112ba81856111e8565b90506112c96040830184610d6e565b949350505050565b6112da81610e33565b81146112e557600080fd5b50565b6000815190506112f7816112d1565b92915050565b60006020828403121561131357611312610b5a565b5b6000611321848285016112e8565b91505092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600061136482610d64565b915061136f83610d64565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff038211156113a4576113a361132a565b5b828201905092915050565b6113b881610e6a565b81146113c357600080fd5b50565b6000815190506113d5816113af565b92915050565b6000602082840312156113f1576113f0610b5a565b5b60006113ff848285016113c6565b91505092915050565b7f7465737472657665727400000000000000000000000000000000000000000000600082015250565b600061143e600a836111d7565b915061144982611408565b602082019050919050565b6000602082019050818103600083015261146d81611431565b9050919050565b600060808201905061148960008301876111c8565b818103602083015261149b81866111e8565b905081810360408301526114af81856111e8565b90506114be6060830184610d6e565b95945050505050565b600067ffffffffffffffff8211156114e2576114e1610bdd565b5b602082029050602081019050919050565b600080fd5b600080fd5b600080fd5b600061151561151084610c58565b610c3d565b90508281526020810184848401111561153157611530610bc7565b5b61153c848285610fb4565b509392505050565b600082601f83011261155957611558610bc2565b5b8151611569848260208601611502565b91505092915050565b6004811061157f57600080fd5b50565b60008151905061159181611572565b92915050565b6000608082840312156115ad576115ac6114f8565b5b6115b76080610c3d565b9050600082015167ffffffffffffffff8111156115d7576115d66114fd565b5b6115e384828501611544565b600083015250602082015167ffffffffffffffff811115611607576116066114fd565b5b61161384828501611544565b6020830152506040611627848285016113c6565b604083015250606061163b84828501611582565b60608301525092915050565b600061165a611655846114c7565b610c3d565b9050808382526020820190506020840283018581111561167d5761167c6114f3565b5b835b818110156116c457805167ffffffffffffffff8111156116a2576116a1610bc2565b5b8086016116af8982611597565b8552602085019450505060208101905061167f565b5050509392505050565b600082601f8301126116e3576116e2610bc2565b5b81516116f3848260208601611647565b91505092915050565b60006020828403121561171257611711610b5a565b5b600082015167ffffffffffffffff8111156117305761172f610b5f565b5b61173c848285016116ce565b9150509291505056fea2646970667358221220fbbd8da0d7360633653761cbde3d46828949fcca1b71279d79140864c678daeb64736f6c634300080a0033" } diff --git a/e2e/contracts/teststaking/TestStaking.sol b/e2e/contracts/teststaking/TestStaking.sol index f4d633ca38..a92786519b 100644 --- a/e2e/contracts/teststaking/TestStaking.sol +++ b/e2e/contracts/teststaking/TestStaking.sol @@ -52,6 +52,9 @@ contract TestStaking { WZETA wzeta; address owner; + // @dev used to test state change in smart contract + uint256 public counter = 0; + constructor(address _wzeta) { wzeta = WZETA(_wzeta); owner = msg.sender; @@ -76,6 +79,20 @@ contract TestStaking { return staking.stake(staker, validator, amount); } + function stakeWithStateUpdate(address staker, string memory validator, uint256 amount) external onlyOwner returns (bool) { + counter = counter + 1; + bool success = staking.stake(staker, validator, amount); + counter = counter + 1; + return success; + } + + function stakeAndRevert(address staker, string memory validator, uint256 amount) external onlyOwner returns (bool) { + counter = counter + 1; + staking.stake(staker, validator, amount); + counter = counter + 1; + revert("testrevert"); + } + function unstake( address staker, string memory validator, diff --git a/e2e/e2etests/test_precompiles_staking_through_contract.go b/e2e/e2etests/test_precompiles_staking_through_contract.go index ade60de7bf..a9112f5b6e 100644 --- a/e2e/e2etests/test_precompiles_staking_through_contract.go +++ b/e2e/e2etests/test_precompiles_staking_through_contract.go @@ -4,10 +4,12 @@ import ( "math/big" sdk "github.com/cosmos/cosmos-sdk/types" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" "github.com/cosmos/cosmos-sdk/x/staking/types" "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/stretchr/testify/require" + "github.com/zeta-chain/node/cmd/zetacored/config" "github.com/zeta-chain/node/e2e/contracts/teststaking" "github.com/zeta-chain/node/e2e/runner" "github.com/zeta-chain/node/e2e/utils" @@ -58,15 +60,78 @@ func TestPrecompilesStakingThroughContract(r *runner.E2ERunner, args []string) { utils.MustWaitForTxReceipt(r.Ctx, r.ZEVMClient, tx, r.Logger, r.ReceiptTimeout) r.ZEVMAuth.Value = big.NewInt(0) - tx, err = testStaking.WithdrawWZETA(r.ZEVMAuth, big.NewInt(100000000000)) + stakeAmount := 100000000000 + tx, err = testStaking.WithdrawWZETA(r.ZEVMAuth, big.NewInt(int64(stakeAmount))) require.NoError(r, err) utils.MustWaitForTxReceipt(r.Ctx, r.ZEVMClient, tx, r.Logger, r.ReceiptTimeout) - // stake 3 to validator1 using testStaking smart contract - tx, err = testStaking.Stake(r.ZEVMAuth, testStakingAddr, validators[0].OperatorAddress, big.NewInt(3)) + // bank balance at the start + balanceBefore, err := r.BankClient.Balance(r.Ctx, &banktypes.QueryBalanceRequest{ + Address: sdk.AccAddress(testStakingAddr.Bytes()).String(), + Denom: config.BaseDenom, + }) + require.NoError(r, err) + require.Equal(r, int64(stakeAmount), balanceBefore.Balance.Amount.Int64()) + + // stake 3 to validator1 and revert in same function + tx, err = testStaking.StakeAndRevert(r.ZEVMAuth, testStakingAddr, validators[0].OperatorAddress, big.NewInt(3)) + require.NoError(r, err) + utils.MustWaitForTxReceipt(r.Ctx, r.ZEVMClient, tx, r.Logger, r.ReceiptTimeout) + + // check that bank balance was not changed because of revert in testStaking contract + balanceAfterRevert, err := r.BankClient.Balance(r.Ctx, &banktypes.QueryBalanceRequest{ + Address: sdk.AccAddress(testStakingAddr.Bytes()).String(), + Denom: config.BaseDenom, + }) + require.NoError(r, err) + require.Equal(r, balanceBefore.Balance.Amount.Int64(), balanceAfterRevert.Balance.Amount.Int64()) + + // check that counter was not updated + counter, err := testStaking.Counter(&bind.CallOpts{}) + require.NoError(r, err) + require.Equal(r, int64(0), counter.Int64()) + + // check that shares are still 0 + sharesAfterRevert, err := testStaking.GetShares(&bind.CallOpts{}, testStakingAddr, validators[0].OperatorAddress) + require.NoError(r, err) + require.Equal(r, int64(0), sharesAfterRevert.Int64()) + + // stake 1 to validator1 using testStaking smart contract without smart contract state update + tx, err = testStaking.Stake(r.ZEVMAuth, testStakingAddr, validators[0].OperatorAddress, big.NewInt(1)) + require.NoError(r, err) + utils.MustWaitForTxReceipt(r.Ctx, r.ZEVMClient, tx, r.Logger, r.ReceiptTimeout) + + // check that bank balance is reduced by 1 + balanceAfterStake, err := r.BankClient.Balance(r.Ctx, &banktypes.QueryBalanceRequest{ + Address: sdk.AccAddress(testStakingAddr.Bytes()).String(), + Denom: config.BaseDenom, + }) + require.NoError(r, err) + require.Equal(r, balanceBefore.Balance.Amount.Int64()-1, balanceAfterStake.Balance.Amount.Int64()) + + // stake 2 more to validator1 using testStaking smart contract with smart contract state update + tx, err = testStaking.StakeWithStateUpdate( + r.ZEVMAuth, + testStakingAddr, + validators[0].OperatorAddress, + big.NewInt(2), + ) require.NoError(r, err) utils.MustWaitForTxReceipt(r.Ctx, r.ZEVMClient, tx, r.Logger, r.ReceiptTimeout) + // check that bank balance is reduced by 2 more, 3 in total + balanceAfterStake, err = r.BankClient.Balance(r.Ctx, &banktypes.QueryBalanceRequest{ + Address: sdk.AccAddress(testStakingAddr.Bytes()).String(), + Denom: config.BaseDenom, + }) + require.NoError(r, err) + require.Equal(r, balanceBefore.Balance.Amount.Int64()-3, balanceAfterStake.Balance.Amount.Int64()) + + // check that counter is updated + counter, err = testStaking.Counter(&bind.CallOpts{}) + require.NoError(r, err) + require.Equal(r, int64(2), counter.Int64()) + // check shares are set to 3 sharesAfterVal1, err := testStaking.GetShares(&bind.CallOpts{}, testStakingAddr, validators[0].OperatorAddress) require.NoError(r, err) diff --git a/e2e/txserver/zeta_tx_server.go b/e2e/txserver/zeta_tx_server.go index 41270e2bb4..b0e6cecce2 100644 --- a/e2e/txserver/zeta_tx_server.go +++ b/e2e/txserver/zeta_tx_server.go @@ -39,6 +39,7 @@ import ( "github.com/zeta-chain/node/app" "github.com/zeta-chain/node/cmd/zetacored/config" + "github.com/zeta-chain/node/e2e/utils" "github.com/zeta-chain/node/pkg/chains" "github.com/zeta-chain/node/pkg/coin" authoritytypes "github.com/zeta-chain/node/x/authority/types" @@ -441,7 +442,7 @@ func (zts ZetaTxServer) DeployZRC20s( } // deploy eth zrc20 - _, err = zts.BroadcastTx(deployerAccount, fungibletypes.NewMsgDeployFungibleCoinZRC20( + res, err := zts.BroadcastTx(deployerAccount, fungibletypes.NewMsgDeployFungibleCoinZRC20( deployerAddr, "", chains.GoerliLocalnet.ChainId, @@ -454,9 +455,16 @@ func (zts ZetaTxServer) DeployZRC20s( if err != nil { return "", fmt.Errorf("failed to deploy eth zrc20: %s", err.Error()) } + zrc20, err := fetchZRC20FromDeployResponse(res) + if err != nil { + return "", err + } + if err := zts.initializeLiquidityCap(zrc20); err != nil { + return "", err + } // deploy btc zrc20 - _, err = zts.BroadcastTx(deployerAccount, fungibletypes.NewMsgDeployFungibleCoinZRC20( + res, err = zts.BroadcastTx(deployerAccount, fungibletypes.NewMsgDeployFungibleCoinZRC20( deployerAddr, "", chains.BitcoinRegtest.ChainId, @@ -469,9 +477,16 @@ func (zts ZetaTxServer) DeployZRC20s( if err != nil { return "", fmt.Errorf("failed to deploy btc zrc20: %s", err.Error()) } + zrc20, err = fetchZRC20FromDeployResponse(res) + if err != nil { + return "", err + } + if err := zts.initializeLiquidityCap(zrc20); err != nil { + return "", err + } // deploy sol zrc20 - _, err = zts.BroadcastTx(deployerAccount, fungibletypes.NewMsgDeployFungibleCoinZRC20( + res, err = zts.BroadcastTx(deployerAccount, fungibletypes.NewMsgDeployFungibleCoinZRC20( deployerAddr, "", chains.SolanaLocalnet.ChainId, @@ -484,9 +499,16 @@ func (zts ZetaTxServer) DeployZRC20s( if err != nil { return "", fmt.Errorf("failed to deploy sol zrc20: %s", err.Error()) } + zrc20, err = fetchZRC20FromDeployResponse(res) + if err != nil { + return "", err + } + if err := zts.initializeLiquidityCap(zrc20); err != nil { + return "", err + } // deploy erc20 zrc20 - res, err := zts.BroadcastTx(deployerAccount, fungibletypes.NewMsgDeployFungibleCoinZRC20( + res, err = zts.BroadcastTx(deployerAccount, fungibletypes.NewMsgDeployFungibleCoinZRC20( deployerAddr, erc20Addr, chains.GoerliLocalnet.ChainId, @@ -501,12 +523,12 @@ func (zts ZetaTxServer) DeployZRC20s( } // fetch the erc20 zrc20 contract address and remove the quotes - erc20zrc20Addr, err := FetchAttributeFromTxResponse(res, "Contract") + erc20zrc20Addr, err := fetchZRC20FromDeployResponse(res) if err != nil { - return "", fmt.Errorf("failed to fetch erc20 zrc20 contract address: %s, %s", err.Error(), res.String()) + return "", err } - if !ethcommon.IsHexAddress(erc20zrc20Addr) { - return "", fmt.Errorf("invalid address in event: %s", erc20zrc20Addr) + if err := zts.initializeLiquidityCap(erc20zrc20Addr); err != nil { + return "", err } return erc20zrc20Addr, nil @@ -557,6 +579,33 @@ func (zts *ZetaTxServer) SetAuthorityClient(authorityClient authoritytypes.Query zts.authorityClient = authorityClient } +// initializeLiquidityCap initializes the liquidity cap for the given coin with a large value +func (zts ZetaTxServer) initializeLiquidityCap(zrc20 string) error { + liquidityCap := sdktypes.NewUint(1e18).MulUint64(1e12) + + msg := fungibletypes.NewMsgUpdateZRC20LiquidityCap( + zts.MustGetAccountAddressFromName(utils.OperationalPolicyName), + zrc20, + liquidityCap, + ) + _, err := zts.BroadcastTx(utils.OperationalPolicyName, msg) + return err +} + +// fetchZRC20FromDeployResponse fetches the zrc20 address from the response +func fetchZRC20FromDeployResponse(res *sdktypes.TxResponse) (string, error) { + // fetch the erc20 zrc20 contract address and remove the quotes + zrc20Addr, err := FetchAttributeFromTxResponse(res, "Contract") + if err != nil { + return "", fmt.Errorf("failed to fetch zrc20 contract address: %s, %s", err.Error(), res.String()) + } + if !ethcommon.IsHexAddress(zrc20Addr) { + return "", fmt.Errorf("invalid address in event: %s", zrc20Addr) + } + + return zrc20Addr, nil +} + // fetchMessagePermissions fetches the message permissions for a given message // return a bool preV19 to indicate the node is preV19 and the query doesn't exist func (zts ZetaTxServer) fetchMessagePermissions(msg sdktypes.Msg) (authoritytypes.PolicyType, bool, error) { diff --git a/go.mod b/go.mod index 922c2cf4b1..9d1bc4a8e9 100644 --- a/go.mod +++ b/go.mod @@ -58,7 +58,7 @@ require ( github.com/spf13/pflag v1.0.5 github.com/spf13/viper v1.16.0 github.com/stretchr/testify v1.9.0 - github.com/zeta-chain/ethermint v0.0.0-20240729121328-43bf9ddbf82f + github.com/zeta-chain/ethermint v0.0.0-20240909234716-2fad916e7179 github.com/zeta-chain/keystone/keys v0.0.0-20231105174229-903bc9405da2 github.com/zeta-chain/protocol-contracts v1.0.2-athens3.0.20240819143729-b8229cd7b410 gitlab.com/thorchain/tss/go-tss v1.6.5 @@ -73,7 +73,7 @@ require ( google.golang.org/protobuf v1.32.0 gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c gopkg.in/yaml.v2 v2.4.0 - gopkg.in/yaml.v3 v3.0.1 // indirect + gopkg.in/yaml.v3 v3.0.1 gorm.io/driver/sqlite v1.4.4 gorm.io/gorm v1.24.6 ) diff --git a/go.sum b/go.sum index 89792efb1f..1472a98387 100644 --- a/go.sum +++ b/go.sum @@ -1621,8 +1621,8 @@ github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9dec github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= -github.com/zeta-chain/ethermint v0.0.0-20240729121328-43bf9ddbf82f h1:M3CQ2Ogbdw0FERKRrHDAUKnWOAjva6Dn5Jmad4UnYC4= -github.com/zeta-chain/ethermint v0.0.0-20240729121328-43bf9ddbf82f/go.mod h1:NeQEwcKBpKAUxIsii2F+jfyOD94jN/3fzPMv/1kVF9M= +github.com/zeta-chain/ethermint v0.0.0-20240909234716-2fad916e7179 h1:HykzQOeqBYFHPQCLrj7VAhoGOONtYJnt8IvyHNb9/d8= +github.com/zeta-chain/ethermint v0.0.0-20240909234716-2fad916e7179/go.mod h1:NeQEwcKBpKAUxIsii2F+jfyOD94jN/3fzPMv/1kVF9M= github.com/zeta-chain/go-ethereum v1.10.26-spc h1:NvY4rR9yw52wfxWt7YoFsWbaIwVMyOtTsWKqGAXk+sE= github.com/zeta-chain/go-ethereum v1.10.26-spc/go.mod h1:/6CsT5Ceen2WPLI/oCA3xMcZ5sWMF/D46SjM/ayY0Oo= github.com/zeta-chain/go-libp2p v0.0.0-20240710192637-567fbaacc2b4 h1:FmO3HfVdZ7LzxBUfg6sVzV7ilKElQU2DZm8PxJ7KcYI= @@ -1744,7 +1744,6 @@ golang.org/x/crypto v0.0.0-20220214200702-86341886e292/go.mod h1:IxCIyHEi3zRg3s0 golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.23.0 h1:dIJU/v2J8Mdglj/8rJ6UUOM3Zc9zLZxVZwwxMooUSAI= golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8= -golang.org/x/crypto v0.26.0/go.mod h1:GY7jblb9wI+FOo5y8/S2oY4zWP07AkOJ4+jxCqdqn54= golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20180807140117-3d87b88a115f/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= @@ -1793,7 +1792,6 @@ golang.org/x/mod v0.6.0-dev.0.20211013180041-c96bc1413d57/go.mod h1:3p9vT2HGsQu2 golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA= golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= -golang.org/x/mod v0.20.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20180719180050-a680a1efc54d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -1866,7 +1864,6 @@ golang.org/x/net v0.0.0-20221014081412-f15817d10f9b/go.mod h1:YDH+HFinaLZZlnHAfS golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco= golang.org/x/net v0.25.0 h1:d/OCCoBEUq33pjydKrGQhw7IlUPI2Oylr+8qLx49kac= golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM= -golang.org/x/net v0.28.0/go.mod h1:yqtgsTWOOnlGLG9GFRrK3++bGOUEkNBoHZc8MEDWPNg= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -1911,7 +1908,6 @@ golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20220929204114-8fcdb60fdcc0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= -golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20180810173357-98c5dad5d1a0/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -2036,16 +2032,12 @@ golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y= golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/sys v0.23.0 h1:YfKFowiIMvtgl1UERQoTPPToxltDeZfbj4H7dVUCwmM= -golang.org/x/sys v0.23.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.20.0 h1:VnkxpohqXaOBYJtBmEppKUG6mXpi+4O6purfc2+sMhw= golang.org/x/term v0.20.0/go.mod h1:8UkIAJTvZgivsXaD6/pH6U9ecQzZ45awqEOzuCvwpFY= -golang.org/x/term v0.23.0 h1:F6D4vR+EHoL9/sWAWgAR1H2DcHr4PareCbAaCo1RpuU= -golang.org/x/term v0.23.0/go.mod h1:DgV24QBUrK6jhZXl+20l6UWznPlwAHm1Q1mGHtydmSk= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -2059,7 +2051,6 @@ golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= -golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -2138,8 +2129,6 @@ golang.org/x/tools v0.1.8-0.20211029000441-d6a9af8af023/go.mod h1:nABZi5QlRsZVlz golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d h1:vU5i/LfpvrRCpgM/VPfJLg5KjxD3E+hfT1SH+d9zLwg= golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk= -golang.org/x/tools v0.24.0 h1:J1shsA93PJUEVaUSaay7UXAyE8aimq3GW0pjlolpa24= -golang.org/x/tools v0.24.0/go.mod h1:YhNqVBIfWHdzvTLs0d8LCuMhkKUgSUKldakyV7W/WDQ= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/precompiles/staking/staking.go b/precompiles/staking/staking.go index 6ce344a344..e800bf7d88 100644 --- a/precompiles/staking/staking.go +++ b/precompiles/staking/staking.go @@ -182,6 +182,7 @@ func (c *Contract) GetShares( func (c *Contract) Stake( ctx sdk.Context, + evm *vm.EVM, contract *vm.Contract, method *abi.Method, args []interface{}, @@ -231,6 +232,14 @@ func (c *Contract) Stake( return nil, err } + // if caller is not the same as origin it means call is coming through smart contract, + // and because state of smart contract calling precompile might be updated as well + // manually reduce amount in stateDB, so it is properly reflected in bank module + stateDB := evm.StateDB.(ptypes.ExtStateDB) + if contract.CallerAddress != evm.Origin { + stateDB.SubBalance(stakerAddress, amount) + } + return method.Outputs.Pack(true) } @@ -389,7 +398,7 @@ func (c *Contract) Run(evm *vm.EVM, contract *vm.Contract, _ bool) ([]byte, erro case StakeMethodName: var res []byte execErr := stateDB.ExecuteNativeAction(contract.Address(), nil, func(ctx sdk.Context) error { - res, err = c.Stake(ctx, contract, method, args) + res, err = c.Stake(ctx, evm, contract, method, args) return err }) if execErr != nil { diff --git a/precompiles/staking/staking_test.go b/precompiles/staking/staking_test.go index d7dfe933ac..b71316887f 100644 --- a/precompiles/staking/staking_test.go +++ b/precompiles/staking/staking_test.go @@ -376,7 +376,7 @@ func Test_Stake(t *testing.T) { t.Run("should fail if wrong args amount", func(t *testing.T) { // ARRANGE - ctx, contract, abi, sdkKeepers, _, _ := setup(t) + ctx, contract, abi, sdkKeepers, mockEVM, _ := setup(t) methodID := abi.Methods[StakeMethodName] r := rand.New(rand.NewSource(42)) validator := sample.Validator(t, r) @@ -395,7 +395,7 @@ func Test_Stake(t *testing.T) { args := []interface{}{stakerEthAddr, validator.OperatorAddress} // ACT - _, err = contract.Stake(ctx, &vm.Contract{CallerAddress: stakerAddr}, &methodID, args) + _, err = contract.Stake(ctx, mockEVM, &vm.Contract{CallerAddress: stakerAddr}, &methodID, args) // ASSERT require.Error(t, err) @@ -403,7 +403,7 @@ func Test_Stake(t *testing.T) { t.Run("should fail if staker is not eth addr", func(t *testing.T) { // ARRANGE - ctx, contract, abi, sdkKeepers, _, _ := setup(t) + ctx, contract, abi, sdkKeepers, mockEVM, _ := setup(t) methodID := abi.Methods[StakeMethodName] r := rand.New(rand.NewSource(42)) validator := sample.Validator(t, r) @@ -421,7 +421,7 @@ func Test_Stake(t *testing.T) { args := []interface{}{staker, validator.OperatorAddress, coins.AmountOf(config.BaseDenom).BigInt()} // ACT - _, err = contract.Stake(ctx, &vm.Contract{CallerAddress: stakerAddr}, &methodID, args) + _, err = contract.Stake(ctx, mockEVM, &vm.Contract{CallerAddress: stakerAddr}, &methodID, args) // ASSERT require.Error(t, err) @@ -429,7 +429,7 @@ func Test_Stake(t *testing.T) { t.Run("should fail if validator is not valid string", func(t *testing.T) { // ARRANGE - ctx, contract, abi, sdkKeepers, _, _ := setup(t) + ctx, contract, abi, sdkKeepers, mockEVM, _ := setup(t) methodID := abi.Methods[StakeMethodName] r := rand.New(rand.NewSource(42)) validator := sample.Validator(t, r) @@ -448,7 +448,7 @@ func Test_Stake(t *testing.T) { args := []interface{}{stakerEthAddr, 42, coins.AmountOf(config.BaseDenom).BigInt()} // ACT - _, err = contract.Stake(ctx, &vm.Contract{CallerAddress: stakerAddr}, &methodID, args) + _, err = contract.Stake(ctx, mockEVM, &vm.Contract{CallerAddress: stakerAddr}, &methodID, args) // ASSERT require.Error(t, err) @@ -456,7 +456,7 @@ func Test_Stake(t *testing.T) { t.Run("should fail if amount is not int64", func(t *testing.T) { // ARRANGE - ctx, contract, abi, sdkKeepers, _, _ := setup(t) + ctx, contract, abi, sdkKeepers, mockEVM, _ := setup(t) methodID := abi.Methods[StakeMethodName] r := rand.New(rand.NewSource(42)) validator := sample.Validator(t, r) @@ -475,7 +475,7 @@ func Test_Stake(t *testing.T) { args := []interface{}{stakerEthAddr, validator.OperatorAddress, coins.AmountOf(config.BaseDenom).Uint64()} // ACT - _, err = contract.Stake(ctx, &vm.Contract{CallerAddress: stakerAddr}, &methodID, args) + _, err = contract.Stake(ctx, mockEVM, &vm.Contract{CallerAddress: stakerAddr}, &methodID, args) // ASSERT require.Error(t, err) @@ -818,7 +818,7 @@ func Test_MoveStake(t *testing.T) { t.Run("should fail if staker is invalid arg", func(t *testing.T) { // ARRANGE - ctx, contract, abi, sdkKeepers, _, _ := setup(t) + ctx, contract, abi, sdkKeepers, mockEVM, _ := setup(t) methodID := abi.Methods[MoveStakeMethodName] r := rand.New(rand.NewSource(42)) validatorSrc := sample.Validator(t, r) @@ -844,7 +844,7 @@ func Test_MoveStake(t *testing.T) { // stake to validator src stakeMethodID := abi.Methods[StakeMethodName] - _, err = contract.Stake(ctx, &vm.Contract{CallerAddress: stakerAddr}, &stakeMethodID, argsStake) + _, err = contract.Stake(ctx, mockEVM, &vm.Contract{CallerAddress: stakerAddr}, &stakeMethodID, argsStake) require.NoError(t, err) argsMoveStake := []interface{}{ @@ -863,7 +863,7 @@ func Test_MoveStake(t *testing.T) { t.Run("should fail if validator src is invalid arg", func(t *testing.T) { // ARRANGE - ctx, contract, abi, sdkKeepers, _, _ := setup(t) + ctx, contract, abi, sdkKeepers, mockEVM, _ := setup(t) methodID := abi.Methods[MoveStakeMethodName] r := rand.New(rand.NewSource(42)) validatorSrc := sample.Validator(t, r) @@ -889,7 +889,7 @@ func Test_MoveStake(t *testing.T) { // stake to validator src stakeMethodID := abi.Methods[StakeMethodName] - _, err = contract.Stake(ctx, &vm.Contract{CallerAddress: stakerAddr}, &stakeMethodID, argsStake) + _, err = contract.Stake(ctx, mockEVM, &vm.Contract{CallerAddress: stakerAddr}, &stakeMethodID, argsStake) require.NoError(t, err) argsMoveStake := []interface{}{ @@ -908,7 +908,7 @@ func Test_MoveStake(t *testing.T) { t.Run("should fail if validator dest is invalid arg", func(t *testing.T) { // ARRANGE - ctx, contract, abi, sdkKeepers, _, _ := setup(t) + ctx, contract, abi, sdkKeepers, mockEVM, _ := setup(t) methodID := abi.Methods[MoveStakeMethodName] r := rand.New(rand.NewSource(42)) validatorSrc := sample.Validator(t, r) @@ -934,7 +934,7 @@ func Test_MoveStake(t *testing.T) { // stake to validator src stakeMethodID := abi.Methods[StakeMethodName] - _, err = contract.Stake(ctx, &vm.Contract{CallerAddress: stakerAddr}, &stakeMethodID, argsStake) + _, err = contract.Stake(ctx, mockEVM, &vm.Contract{CallerAddress: stakerAddr}, &stakeMethodID, argsStake) require.NoError(t, err) argsMoveStake := []interface{}{ @@ -953,7 +953,7 @@ func Test_MoveStake(t *testing.T) { t.Run("should fail if amount is invalid arg", func(t *testing.T) { // ARRANGE - ctx, contract, abi, sdkKeepers, _, _ := setup(t) + ctx, contract, abi, sdkKeepers, mockEVM, _ := setup(t) methodID := abi.Methods[MoveStakeMethodName] r := rand.New(rand.NewSource(42)) validatorSrc := sample.Validator(t, r) @@ -979,7 +979,7 @@ func Test_MoveStake(t *testing.T) { // stake to validator src stakeMethodID := abi.Methods[StakeMethodName] - _, err = contract.Stake(ctx, &vm.Contract{CallerAddress: stakerAddr}, &stakeMethodID, argsStake) + _, err = contract.Stake(ctx, mockEVM, &vm.Contract{CallerAddress: stakerAddr}, &stakeMethodID, argsStake) require.NoError(t, err) argsMoveStake := []interface{}{ @@ -998,7 +998,7 @@ func Test_MoveStake(t *testing.T) { t.Run("should fail if wrong args amount", func(t *testing.T) { // ARRANGE - ctx, contract, abi, sdkKeepers, _, _ := setup(t) + ctx, contract, abi, sdkKeepers, mockEVM, _ := setup(t) methodID := abi.Methods[MoveStakeMethodName] r := rand.New(rand.NewSource(42)) validatorSrc := sample.Validator(t, r) @@ -1024,7 +1024,7 @@ func Test_MoveStake(t *testing.T) { // stake to validator src stakeMethodID := abi.Methods[StakeMethodName] - _, err = contract.Stake(ctx, &vm.Contract{CallerAddress: stakerAddr}, &stakeMethodID, argsStake) + _, err = contract.Stake(ctx, mockEVM, &vm.Contract{CallerAddress: stakerAddr}, &stakeMethodID, argsStake) require.NoError(t, err) argsMoveStake := []interface{}{stakerEthAddr, validatorSrc.OperatorAddress, validatorDest.OperatorAddress} @@ -1152,7 +1152,7 @@ func Test_GetShares(t *testing.T) { stakeMethodID := abi.Methods[StakeMethodName] // ACT - _, err = contract.Stake(ctx, &vm.Contract{CallerAddress: stakerAddr}, &stakeMethodID, stakeArgs) + _, err = contract.Stake(ctx, mockEVM, &vm.Contract{CallerAddress: stakerAddr}, &stakeMethodID, stakeArgs) require.NoError(t, err) // ASSERT 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 diff --git a/x/fungible/keeper/evm.go b/x/fungible/keeper/evm.go index 3f975a23ea..ab0332dfe3 100644 --- a/x/fungible/keeper/evm.go +++ b/x/fungible/keeper/evm.go @@ -34,12 +34,10 @@ import ( observertypes "github.com/zeta-chain/node/x/observer/types" ) -// TODO USE string constant var ( BigIntZero = big.NewInt(0) ZEVMGasLimitDepositAndCall = big.NewInt(1_000_000) - - ZEVMGasLimitConnectorCall = big.NewInt(1_000_000) + ZEVMGasLimitConnectorCall = big.NewInt(1_000_000) ) // DeployContract deploys a new contract in the ZEVM @@ -98,9 +96,6 @@ func (k Keeper) DeployContract( // DeployZRC20Contract creates and deploys an ERC20 contract on the EVM with the // erc20 module account as owner. Also adds itself to ForeignCoins fungible module state variable -// TODO Unit test for these functions -// https://github.com/zeta-chain/node/issues/864 -// TODO Remove repetitive code func (k Keeper) DeployZRC20Contract( ctx sdk.Context, name, symbol string, @@ -154,17 +149,20 @@ func (k Keeper) DeployZRC20Contract( err.Error(), ) } - coin, _ := k.GetForeignCoins(ctx, contractAddr.Hex()) - coin.CoinType = coinType - coin.Name = name - coin.Symbol = symbol + + // create and set in the store the new foreign coin object + newCoin, _ := k.GetForeignCoins(ctx, contractAddr.Hex()) + newCoin.CoinType = coinType + newCoin.Name = name + newCoin.Symbol = symbol // #nosec G115 uint8 -> uint32 false positive - coin.Decimals = uint32(decimals) - coin.Asset = erc20Contract - coin.Zrc20ContractAddress = contractAddr.Hex() - coin.ForeignChainId = chain.ChainId - coin.GasLimit = gasLimit.Uint64() - k.SetForeignCoins(ctx, coin) + newCoin.Decimals = uint32(decimals) + newCoin.Asset = erc20Contract + newCoin.Zrc20ContractAddress = contractAddr.Hex() + newCoin.ForeignChainId = chain.ChainId + newCoin.GasLimit = gasLimit.Uint64() + newCoin.LiquidityCap = sdk.NewUint(types.DefaultLiquidityCap).MulUint64(uint64(newCoin.Decimals)) + k.SetForeignCoins(ctx, newCoin) return contractAddr, nil } diff --git a/x/fungible/keeper/evm_test.go b/x/fungible/keeper/evm_test.go index 10b15e8401..7c0ef0bf00 100644 --- a/x/fungible/keeper/evm_test.go +++ b/x/fungible/keeper/evm_test.go @@ -316,6 +316,7 @@ func TestKeeper_DeployZRC20Contract(t *testing.T) { require.Equal(t, "bar", foreignCoins.Symbol) require.Equal(t, coin.CoinType_Gas, foreignCoins.CoinType) require.Equal(t, uint64(1000), foreignCoins.GasLimit) + require.True(t, foreignCoins.LiquidityCap.Equal(sdk.NewUint(types.DefaultLiquidityCap).MulUint64(8))) // can get the zrc20 data zrc20Data, err := k.QueryZRC20Data(ctx, addr) diff --git a/x/fungible/keeper/gas_coin_and_pool_test.go b/x/fungible/keeper/gas_coin_and_pool_test.go index 1b7315393c..186828c8b4 100644 --- a/x/fungible/keeper/gas_coin_and_pool_test.go +++ b/x/fungible/keeper/gas_coin_and_pool_test.go @@ -43,6 +43,13 @@ func setupGasCoin( ) require.NoError(t, err) assertContractDeployment(t, evmk, ctx, addr) + + // increase the default liquidity cap + foreignCoin, found := k.GetForeignCoins(ctx, addr.Hex()) + require.True(t, found) + foreignCoin.LiquidityCap = sdk.NewUint(1e18).MulUint64(1e12) + k.SetForeignCoins(ctx, foreignCoin) + return addr } @@ -68,6 +75,13 @@ func deployZRC20( ) require.NoError(t, err) assertContractDeployment(t, evmk, ctx, addr) + + // increase the default liquidity cap + foreignCoin, found := k.GetForeignCoins(ctx, addr.Hex()) + require.True(t, found) + foreignCoin.LiquidityCap = sdk.NewUint(1e18).MulUint64(1e12) + k.SetForeignCoins(ctx, foreignCoin) + return addr } diff --git a/x/fungible/types/zrc20.go b/x/fungible/types/zrc20.go index 3b6865f8fd..97c94ddcdc 100644 --- a/x/fungible/types/zrc20.go +++ b/x/fungible/types/zrc20.go @@ -2,6 +2,11 @@ package types import ethcommon "github.com/ethereum/go-ethereum/common" +// DefaultLiquidityCap is the default value set for the liquidity cap of a new ZRC20 when deployed +// for security reason, this value is low. An arbitrary value should be set during the process of deploying a new ZRC20 +// The value is represented in the base unit of the ZRC20, final value is calculated by multiplying this value by 10^decimals +const DefaultLiquidityCap = uint64(1000) + // ZRC20Data represents the ZRC4 token details used to map // the token to a Cosmos Coin type ZRC20Data struct { 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 267c0da357..049845b79e 100644 --- a/zetaclient/chains/evm/observer/observer_test.go +++ b/zetaclient/chains/evm/observer/observer_test.go @@ -103,6 +103,11 @@ func MockEVMObserver( evmClient = evmClientDefault } + // 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). @@ -116,7 +121,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) @@ -125,9 +130,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 @@ -150,6 +165,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() @@ -166,6 +182,7 @@ func Test_NewObserver(t *testing.T) { }, chainParams: params, evmClient: evmClient, + evmJSONRPC: mocks.NewMockJSONRPCClient(), tss: mocks.NewTSSMainnet(), logger: base.Logger{}, ts: nil, @@ -184,11 +201,12 @@ func Test_NewObserver(t *testing.T) { evmClient.On("BlockNumber", mock.Anything).Return(uint64(0), fmt.Errorf("error RPC")) return evmClient }(), - tss: mocks.NewTSSMainnet(), - logger: base.Logger{}, - ts: nil, - fail: true, - message: "error RPC", + evmJSONRPC: mocks.NewMockJSONRPCClient(), + tss: mocks.NewTSSMainnet(), + logger: base.Logger{}, + ts: nil, + fail: true, + message: "error RPC", }, { name: "should fail on invalid ENV var", @@ -198,6 +216,7 @@ func Test_NewObserver(t *testing.T) { }, chainParams: params, evmClient: evmClient, + evmJSONRPC: mocks.NewMockJSONRPCClient(), tss: mocks.NewTSSMainnet(), before: func() { envVar := base.EnvVarLatestBlockByChain(chain) @@ -233,8 +252,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 61205baaa6..a128354a7f 100644 --- a/zetaclient/chains/evm/signer/signer_test.go +++ b/zetaclient/chains/evm/signer/signer_test.go @@ -70,15 +70,12 @@ 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.NewEVMRPCClient(t) evmClient.On("BlockNumber", mock.Anything).Return(uint64(1000), nil) - - params := mocks.MockChainParams(evmcfg.Chain.ChainId, 10) - cfg.EVMChainConfigs[chains.BscMainnet.ChainId] = evmcfg + evmJSONRPCClient := mocks.NewMockJSONRPCClient() + params := mocks.MockChainParams(chains.BscMainnet.ChainId, 10) logger := base.Logger{} ts := &metrics.TelemetryServer{} @@ -87,8 +84,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, diff --git a/zetaclient/orchestrator/orchestrator.go b/zetaclient/orchestrator/orchestrator.go index a44f7e80c3..6b2b673f4e 100644 --- a/zetaclient/orchestrator/orchestrator.go +++ b/zetaclient/orchestrator/orchestrator.go @@ -452,6 +452,8 @@ func (oc *Orchestrator) ScheduleCctxEVM( outboundScheduleLookback := uint64(float64(outboundScheduleLookahead) * evmOutboundLookbackFactor) // #nosec G115 positive outboundScheduleInterval := uint64(observer.GetChainParams().OutboundScheduleInterval) + criticalInterval := uint64(10) // for critical pending outbound we reduce re-try interval + nonCriticalInterval := outboundScheduleInterval * 2 // for non-critical pending outbound we increase re-try interval for idx, cctx := range cctxList { params := cctx.GetCurrentOutboundParam() @@ -486,8 +488,6 @@ func (oc *Orchestrator) ScheduleCctxEVM( // determining critical outbound; if it satisfies following criteria // 1. it's the first pending outbound for this chain // 2. the following 5 nonces have been in tracker - criticalInterval := uint64(10) // for critical pending outbound we reduce re-try interval - nonCriticalInterval := outboundScheduleInterval * 2 // for non-critical pending outbound we increase re-try interval if nonce%criticalInterval == zetaHeight%criticalInterval { count := 0 for i := nonce + 1; i <= nonce+10; i++ {