diff --git a/.gitignore b/.gitignore index 836329e728..b6c9df729d 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,7 @@ *.swn .vscode .idea +*.pyc # Build vendor diff --git a/.pending/breaking/gaia/3463-Revert-bank-module-handler-fork-re-enables-transfers b/.pending/breaking/gaia/3463-Revert-bank-module-handler-fork-re-enables-transfers deleted file mode 100644 index 02589d3117..0000000000 --- a/.pending/breaking/gaia/3463-Revert-bank-module-handler-fork-re-enables-transfers +++ /dev/null @@ -1 +0,0 @@ -#3463 Revert bank module handler fork (re-enables transfers) diff --git a/.pending/breaking/gaia/3875-Replace-async-flag-with---broadcast-mode-flag-where-the-default b/.pending/breaking/gaia/3875-Replace-async-flag-with---broadcast-mode-flag-where-the-default deleted file mode 100644 index dbbf6928aa..0000000000 --- a/.pending/breaking/gaia/3875-Replace-async-flag-with---broadcast-mode-flag-where-the-default +++ /dev/null @@ -1,3 +0,0 @@ -#3875 Replace `async` flag with `--broadcast-mode` flag where the default -value is `sync`. The `block` mode should not be used. The REST client now -uses `mode` parameter instead of the `return` parameter. diff --git a/.pending/breaking/gaiacli/Remove-REST-server-s b/.pending/breaking/gaiacli/Remove-REST-server-s deleted file mode 100644 index e308511133..0000000000 --- a/.pending/breaking/gaiacli/Remove-REST-server-s +++ /dev/null @@ -1 +0,0 @@ -#3938 Remove REST server's SSL support altogether. diff --git a/.pending/breaking/sdk/3245-Rename-validato b/.pending/breaking/sdk/3245-Rename-validato deleted file mode 100644 index 3886cfb6c9..0000000000 --- a/.pending/breaking/sdk/3245-Rename-validato +++ /dev/null @@ -1 +0,0 @@ -#3245 Rename validator.GetJailed() to validator.IsJailed() \ No newline at end of file diff --git a/.pending/breaking/sdk/3516-Remove-concept-of-shares-from-staking-unbonding-and-redelegation-UX b/.pending/breaking/sdk/3516-Remove-concept-of-shares-from-staking-unbonding-and-redelegation-UX deleted file mode 100644 index b8153c345a..0000000000 --- a/.pending/breaking/sdk/3516-Remove-concept-of-shares-from-staking-unbonding-and-redelegation-UX +++ /dev/null @@ -1,2 +0,0 @@ -#3516 Remove concept of shares from staking unbonding and redelegation UX; -replaced by direct coin amount. diff --git a/.pending/breaking/tendermint/4029-Upgrade-Tendermint-to-v0-31-3 b/.pending/breaking/tendermint/4029-Upgrade-Tendermint-to-v0-31-3 deleted file mode 100644 index fd59019084..0000000000 --- a/.pending/breaking/tendermint/4029-Upgrade-Tendermint-to-v0-31-3 +++ /dev/null @@ -1 +0,0 @@ -#4029 Upgrade Tendermint to v0.31.3 diff --git a/.pending/bugfixes/gaia/3825-Validate-genesis-before-running-gentx b/.pending/bugfixes/gaia/3825-Validate-genesis-before-running-gentx deleted file mode 100644 index 6e70b1f392..0000000000 --- a/.pending/bugfixes/gaia/3825-Validate-genesis-before-running-gentx +++ /dev/null @@ -1 +0,0 @@ -#3825 Validate genesis before running gentx \ No newline at end of file diff --git a/.pending/bugfixes/gaia/3889-When---generate-only-is-provided-the-Keybase-is-not-used-and-as-a-result b/.pending/bugfixes/gaia/3889-When---generate-only-is-provided-the-Keybase-is-not-used-and-as-a-result deleted file mode 100644 index cdeff1d63f..0000000000 --- a/.pending/bugfixes/gaia/3889-When---generate-only-is-provided-the-Keybase-is-not-used-and-as-a-result +++ /dev/null @@ -1,2 +0,0 @@ -#3889 When `--generate-only` is provided, the Keybase is not used and as a result -the `--from` value must be a valid Bech32 cosmos address. diff --git a/.pending/bugfixes/gaia/3974-Fix-go-env-sett b/.pending/bugfixes/gaia/3974-Fix-go-env-sett deleted file mode 100644 index e71f42b754..0000000000 --- a/.pending/bugfixes/gaia/3974-Fix-go-env-sett +++ /dev/null @@ -1 +0,0 @@ -3974 Fix go env setting in installation.md \ No newline at end of file diff --git a/.pending/bugfixes/gaia/3996-Change-make-get b/.pending/bugfixes/gaia/3996-Change-make-get deleted file mode 100644 index 24cebfb7e2..0000000000 --- a/.pending/bugfixes/gaia/3996-Change-make-get +++ /dev/null @@ -1 +0,0 @@ -3996 Change 'make get_tools' to 'make tools' in DOCS_README.md. \ No newline at end of file diff --git a/.pending/bugfixes/gaiacli/3883-Remove-Height-F b/.pending/bugfixes/gaiacli/3883-Remove-Height-F deleted file mode 100644 index 3b266da542..0000000000 --- a/.pending/bugfixes/gaiacli/3883-Remove-Height-F +++ /dev/null @@ -1 +0,0 @@ -#3883 Remove Height Flag from CLI Queries \ No newline at end of file diff --git a/.pending/bugfixes/gaiacli/3899-Using-gaiacli-c b/.pending/bugfixes/gaiacli/3899-Using-gaiacli-c deleted file mode 100644 index 0e732b58ab..0000000000 --- a/.pending/bugfixes/gaiacli/3899-Using-gaiacli-c +++ /dev/null @@ -1 +0,0 @@ -#3899 Using 'gaiacli config node' breaks ~/config/config.toml \ No newline at end of file diff --git a/.pending/bugfixes/sdk/3837-Fix-WithdrawValidatorCommission-to-properly-set-the-validator-s-remaining-commission b/.pending/bugfixes/sdk/3837-Fix-WithdrawValidatorCommission-to-properly-set-the-validator-s-remaining-commission deleted file mode 100644 index 4a46c3d2b3..0000000000 --- a/.pending/bugfixes/sdk/3837-Fix-WithdrawValidatorCommission-to-properly-set-the-validator-s-remaining-commission +++ /dev/null @@ -1 +0,0 @@ -#3837 Fix `WithdrawValidatorCommission` to properly set the validator's remaining commission. diff --git a/.pending/bugfixes/sdk/3870-Fix-DecCoins-TruncateDecimal-to-never-return-zero-coins-in b/.pending/bugfixes/sdk/3870-Fix-DecCoins-TruncateDecimal-to-never-return-zero-coins-in deleted file mode 100644 index f84e6217c0..0000000000 --- a/.pending/bugfixes/sdk/3870-Fix-DecCoins-TruncateDecimal-to-never-return-zero-coins-in +++ /dev/null @@ -1,2 +0,0 @@ -#3870 Fix DecCoins#TruncateDecimal to never return zero coins in -either the truncated coins or the change coins. diff --git a/.pending/bugfixes/sdk/3915-Remove-delimiting-support-from-ParseDecCoins b/.pending/bugfixes/sdk/3915-Remove-delimiting-support-from-ParseDecCoins deleted file mode 100644 index 343d1a79e0..0000000000 --- a/.pending/bugfixes/sdk/3915-Remove-delimiting-support-from-ParseDecCoins +++ /dev/null @@ -1 +0,0 @@ -#3915 Remove ';' delimiting support from ParseDecCoins diff --git a/.pending/bugfixes/sdk/3977-Fix-docker-imag b/.pending/bugfixes/sdk/3977-Fix-docker-imag deleted file mode 100644 index 82bf994dc4..0000000000 --- a/.pending/bugfixes/sdk/3977-Fix-docker-imag +++ /dev/null @@ -1 +0,0 @@ -#3977 Fix docker image build diff --git a/.pending/features/gaia/2935-optionally-asse b/.pending/features/gaia/2935-optionally-asse deleted file mode 100644 index 2832fe8e6f..0000000000 --- a/.pending/features/gaia/2935-optionally-asse +++ /dev/null @@ -1 +0,0 @@ -#2935 Optionally assert invariants on a blockly basis using `gaiad --assert-invariants-blockly` diff --git a/.pending/features/gaia/3886-Implement-minting-module-querier-and-CLI-REST-clients b/.pending/features/gaia/3886-Implement-minting-module-querier-and-CLI-REST-clients deleted file mode 100644 index 480f542e7a..0000000000 --- a/.pending/features/gaia/3886-Implement-minting-module-querier-and-CLI-REST-clients +++ /dev/null @@ -1 +0,0 @@ -#3886 Implement minting module querier and CLI/REST clients. diff --git a/.pending/features/gaiacli/3937-Add-command-to-query-community-pool b/.pending/features/gaiacli/3937-Add-command-to-query-community-pool deleted file mode 100644 index d5ec2f09fe..0000000000 --- a/.pending/features/gaiacli/3937-Add-command-to-query-community-pool +++ /dev/null @@ -1 +0,0 @@ -#3937 Add command to query community-pool \ No newline at end of file diff --git a/.pending/features/gaiarest/3937-Add-route-to-fetch-community-pool b/.pending/features/gaiarest/3937-Add-route-to-fetch-community-pool deleted file mode 100644 index 0cf25bcacb..0000000000 --- a/.pending/features/gaiarest/3937-Add-route-to-fetch-community-pool +++ /dev/null @@ -1 +0,0 @@ -#3937 Add route to fetch community-pool \ No newline at end of file diff --git a/.pending/features/gaiarest/3949-added-slashing-validators-signing_info-to-get-signing_info-for-all-validators b/.pending/features/gaiarest/3949-added-slashing-validators-signing_info-to-get-signing_info-for-all-validators deleted file mode 100644 index 048f24cda0..0000000000 --- a/.pending/features/gaiarest/3949-added-slashing-validators-signing_info-to-get-signing_info-for-all-validators +++ /dev/null @@ -1 +0,0 @@ -#3949 added /slashing/signing_infos to get signing_info for all validators \ No newline at end of file diff --git a/.pending/features/sdk/2935-New-module-Cris b/.pending/features/sdk/2935-New-module-Cris deleted file mode 100644 index f036ad14d6..0000000000 --- a/.pending/features/sdk/2935-New-module-Cris +++ /dev/null @@ -1 +0,0 @@ -#2935 New module Crisis which can test broken invariant with messages diff --git a/.pending/features/sdk/3813-New-sdk-NewCoins-safe-constructor-to-replace-bare b/.pending/features/sdk/3813-New-sdk-NewCoins-safe-constructor-to-replace-bare deleted file mode 100644 index bd25be4feb..0000000000 --- a/.pending/features/sdk/3813-New-sdk-NewCoins-safe-constructor-to-replace-bare +++ /dev/null @@ -1 +0,0 @@ -#3813 New sdk.NewCoins safe constructor to replace bare sdk.Coins{} declarations. diff --git a/.pending/features/sdk/3858-add-website-details-and-identity-to-gentx-cli-command b/.pending/features/sdk/3858-add-website-details-and-identity-to-gentx-cli-command deleted file mode 100644 index 0d55fa7f30..0000000000 --- a/.pending/features/sdk/3858-add-website-details-and-identity-to-gentx-cli-command +++ /dev/null @@ -1 +0,0 @@ -#3858 add website, details and identity to gentx cli command \ No newline at end of file diff --git a/.pending/features/sdk/Implement-coin-conversion-and-denomination-registration-utilities b/.pending/features/sdk/Implement-coin-conversion-and-denomination-registration-utilities deleted file mode 100644 index 4bd7e51e2c..0000000000 --- a/.pending/features/sdk/Implement-coin-conversion-and-denomination-registration-utilities +++ /dev/null @@ -1 +0,0 @@ -Implement coin conversion and denomination registration utilities diff --git a/.pending/improvements/gaia/3808-gaiad-and-gaiacli-integration-tests-use-build-binaries b/.pending/improvements/gaia/3808-gaiad-and-gaiacli-integration-tests-use-build-binaries deleted file mode 100644 index bfe0564348..0000000000 --- a/.pending/improvements/gaia/3808-gaiad-and-gaiacli-integration-tests-use-build-binaries +++ /dev/null @@ -1 +0,0 @@ -#3808 `gaiad` and `gaiacli` integration tests use ./build/ binaries. diff --git a/.pending/improvements/gaia/3819-Simulation-refa b/.pending/improvements/gaia/3819-Simulation-refa deleted file mode 100644 index bc4531f962..0000000000 --- a/.pending/improvements/gaia/3819-Simulation-refa +++ /dev/null @@ -1,7 +0,0 @@ -\#3819 Simulation refactor, log output now stored in ~/.gaiad/simulation/ - * Simulation moved to its own module (not a part of mock) - * Logger type instead of passing function variables everywhere - * Logger json output (for reloadable simulation running) - * Cleanup bank simulation messages / remove dup code in bank simulation - * Simulations saved in `~/.gaiad/simulations/` - * "Lean" simulation output option to exclude No-ops and !ok functions (`--SimulationLean` flag) diff --git a/.pending/improvements/gaia/3893-Improve-gaiacli-tx-sign-command b/.pending/improvements/gaia/3893-Improve-gaiacli-tx-sign-command deleted file mode 100644 index 3d8b67791a..0000000000 --- a/.pending/improvements/gaia/3893-Improve-gaiacli-tx-sign-command +++ /dev/null @@ -1,4 +0,0 @@ -#3893 Improve `gaiacli tx sign` command - * Add shorthand flags -a and -s for the account and sequence numbers respectively - * Mark the account and sequence numbers required during "offline" mode - * Always do an RPC query for account and sequence number during "online" mode diff --git a/.pending/improvements/gaiacli/3833-Modify-stake-to b/.pending/improvements/gaiacli/3833-Modify-stake-to deleted file mode 100644 index f399a0f76e..0000000000 --- a/.pending/improvements/gaiacli/3833-Modify-stake-to +++ /dev/null @@ -1 +0,0 @@ -#3833 Modify stake to atom in gaia's doc. \ No newline at end of file diff --git a/.pending/improvements/gaiacli/3841-Add-indent-to-J b/.pending/improvements/gaiacli/3841-Add-indent-to-J deleted file mode 100644 index b6e9dfb53e..0000000000 --- a/.pending/improvements/gaiacli/3841-Add-indent-to-J +++ /dev/null @@ -1 +0,0 @@ -#3841 Add indent to JSON of `gaiacli keys [add|show|list]` diff --git a/.pending/improvements/gaiacli/3859-Add-newline-to-echo-of-gaiacli-keys b/.pending/improvements/gaiacli/3859-Add-newline-to-echo-of-gaiacli-keys deleted file mode 100644 index c8baf2c004..0000000000 --- a/.pending/improvements/gaiacli/3859-Add-newline-to-echo-of-gaiacli-keys +++ /dev/null @@ -1 +0,0 @@ -#3859 Add newline to echo of `gaiacli keys ...` diff --git a/.pending/improvements/gaiacli/3959-Improving-error-messages-when-signing-with-ledger-devices-fails b/.pending/improvements/gaiacli/3959-Improving-error-messages-when-signing-with-ledger-devices-fails deleted file mode 100644 index ef3315b6ef..0000000000 --- a/.pending/improvements/gaiacli/3959-Improving-error-messages-when-signing-with-ledger-devices-fails +++ /dev/null @@ -1 +0,0 @@ -#3959 Improving error messages when signing with ledger devices fails \ No newline at end of file diff --git a/.pending/improvements/sdk/3238-Add-block-time-to-tx-responses-when-querying-for b/.pending/improvements/sdk/3238-Add-block-time-to-tx-responses-when-querying-for deleted file mode 100644 index d254b93e62..0000000000 --- a/.pending/improvements/sdk/3238-Add-block-time-to-tx-responses-when-querying-for +++ /dev/null @@ -1,2 +0,0 @@ -#3238 Add block time to tx responses when querying for -txs by tags or hash. diff --git a/.pending/improvements/sdk/3752-Explanatory-doc b/.pending/improvements/sdk/3752-Explanatory-doc deleted file mode 100644 index 1179bf065b..0000000000 --- a/.pending/improvements/sdk/3752-Explanatory-doc +++ /dev/null @@ -1 +0,0 @@ -\#3752 Explanatory docs for minting mechanism (`docs/spec/mint/01_concepts.md`) diff --git a/.pending/improvements/sdk/3801-baseapp-safety-improvements b/.pending/improvements/sdk/3801-baseapp-safety-improvements deleted file mode 100644 index c971a2e165..0000000000 --- a/.pending/improvements/sdk/3801-baseapp-safety-improvements +++ /dev/null @@ -1 +0,0 @@ -#3801 `baseapp` safety improvements diff --git a/.pending/improvements/sdk/3820-Make-Coins-IsAllGT-more-robust-and-consistent b/.pending/improvements/sdk/3820-Make-Coins-IsAllGT-more-robust-and-consistent deleted file mode 100644 index b2ee3f547d..0000000000 --- a/.pending/improvements/sdk/3820-Make-Coins-IsAllGT-more-robust-and-consistent +++ /dev/null @@ -1 +0,0 @@ -#3820 Make Coins.IsAllGT() more robust and consistent. diff --git a/.pending/improvements/sdk/3828-New-sdkch-tool-to-maintain-changelogs b/.pending/improvements/sdk/3828-New-sdkch-tool-to-maintain-changelogs deleted file mode 100644 index 46903cfa1d..0000000000 --- a/.pending/improvements/sdk/3828-New-sdkch-tool-to-maintain-changelogs +++ /dev/null @@ -1 +0,0 @@ -#3828 New sdkch tool to maintain changelogs diff --git a/.pending/improvements/sdk/3864-Make-Coins-IsAllGTE-more-consistent b/.pending/improvements/sdk/3864-Make-Coins-IsAllGTE-more-consistent deleted file mode 100644 index 2b1a3796fe..0000000000 --- a/.pending/improvements/sdk/3864-Make-Coins-IsAllGTE-more-consistent +++ /dev/null @@ -1 +0,0 @@ -#3864 Make Coins.IsAllGTE() more consistent. diff --git a/.pending/improvements/sdk/3907-Drop-dep-in-fav b/.pending/improvements/sdk/3907-Drop-dep-in-fav deleted file mode 100644 index b443e2f1e5..0000000000 --- a/.pending/improvements/sdk/3907-Drop-dep-in-fav +++ /dev/null @@ -1,3 +0,0 @@ -#3907: dep -> go mod migration -- Drop dep in favor of go modules. -- Upgrade to Go 1.12.1. diff --git a/.pending/improvements/sdk/3917-Allow-arbitrary-decreases-to-validator-commission-rates b/.pending/improvements/sdk/3917-Allow-arbitrary-decreases-to-validator-commission-rates deleted file mode 100644 index ab82ac9bd8..0000000000 --- a/.pending/improvements/sdk/3917-Allow-arbitrary-decreases-to-validator-commission-rates +++ /dev/null @@ -1 +0,0 @@ -#3917 Allow arbitrary decreases to validator commission rates. diff --git a/.pending/improvements/sdk/3937-Implement-community-pool-querier b/.pending/improvements/sdk/3937-Implement-community-pool-querier deleted file mode 100644 index 1862a67862..0000000000 --- a/.pending/improvements/sdk/3937-Implement-community-pool-querier +++ /dev/null @@ -1 +0,0 @@ -#3937 Implement community pool querier. diff --git a/.pending/improvements/sdk/3940-Codespace-shoul b/.pending/improvements/sdk/3940-Codespace-shoul deleted file mode 100644 index 0721a2c784..0000000000 --- a/.pending/improvements/sdk/3940-Codespace-shoul +++ /dev/null @@ -1 +0,0 @@ -#3940 Codespace should be lowercase. \ No newline at end of file diff --git a/.pending/improvements/sdk/3986-Update-the-Stringer-implementation-of-the-Proposal-type b/.pending/improvements/sdk/3986-Update-the-Stringer-implementation-of-the-Proposal-type deleted file mode 100644 index 670639d2b9..0000000000 --- a/.pending/improvements/sdk/3986-Update-the-Stringer-implementation-of-the-Proposal-type +++ /dev/null @@ -1 +0,0 @@ -#3986 Update the Stringer implementation of the Proposal type. diff --git a/.pending/improvements/sdk/926-circuit-breaker- b/.pending/improvements/sdk/926-circuit-breaker- deleted file mode 100644 index 9b3321e7de..0000000000 --- a/.pending/improvements/sdk/926-circuit-breaker- +++ /dev/null @@ -1 +0,0 @@ -\#926 circuit breaker high level explanation diff --git a/.pending/improvements/sdk/Fixed-various-linter b/.pending/improvements/sdk/Fixed-various-linter deleted file mode 100644 index 5b6cd8bb20..0000000000 --- a/.pending/improvements/sdk/Fixed-various-linter +++ /dev/null @@ -1 +0,0 @@ -Fixed various linters warnings in the context of the gometalinter -> golangci-lint migration #3896. diff --git a/CHANGELOG.md b/CHANGELOG.md index a3eeb79a92..ff1081e7c4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,169 @@ # Changelog +* [0.34.0](#0340) + * [Breaking Changes](#breaking-changes) + * [Gaia](#gaia) + * [Gaia CLI](#gaia-cli) + * [SDK](#sdk) + * [Tendermint](#tendermint) + * [New features](#new-features) + * [SDK](#sdk-1) + * [Gaia](#gaia-1) + * [Gaia CLI](#gaia-cli-1) + * [Gaia REST API](#gaia-rest-api) + * [Improvements](#improvements) + * [Gaia](#gaia-2) + * [Gaia CLI](#gaia-cli-2) + * [SDK](#sdk-2) + * [Bug Fixes](#bug-fixes) + * [Gaia](#gaia-3) + * [Gaia CLI](#gaia-cli-3) + * [SDK](#sdk-3) +* [0.33.2](#0332) + * [Improvements](#improvements-1) + * [Tendermint](#tendermint-1) +* [0.33.1](#0331) + * [Bug Fixes](#bug-fixes-1) + * [Gaia](#gaia-4) + +## 0.34.0 + +### Breaking Changes + +#### Gaia + +* [\#3463](https://github.com/cosmos/cosmos-sdk/issues/3463) Revert bank module handler fork (re-enables transfers) +* [\#3875](https://github.com/cosmos/cosmos-sdk/issues/3875) Replace `async` flag with `--broadcast-mode` flag where the default + value is `sync`. The `block` mode should not be used. The REST client now + uses `mode` parameter instead of the `return` parameter. + +#### Gaia CLI + +* [\#3938](https://github.com/cosmos/cosmos-sdk/issues/3938) Remove REST server's SSL support altogether. + +#### SDK + +* [\#3245](https://github.com/cosmos/cosmos-sdk/issues/3245) Rename validator.GetJailed() to validator.IsJailed() +* [\#3516](https://github.com/cosmos/cosmos-sdk/issues/3516) Remove concept of shares from staking unbonding and redelegation UX; + replaced by direct coin amount. + +#### Tendermint + +* [\#4029](https://github.com/cosmos/cosmos-sdk/issues/4029) Upgrade Tendermint to v0.31.3 + +### New features + +#### SDK + +* [\#2935](https://github.com/cosmos/cosmos-sdk/issues/2935) New module Crisis which can test broken invariant with messages +* [\#3813](https://github.com/cosmos/cosmos-sdk/issues/3813) New sdk.NewCoins safe constructor to replace bare sdk.Coins{} declarations. +* [\#3858](https://github.com/cosmos/cosmos-sdk/issues/3858) add website, details and identity to gentx cli command +* Implement coin conversion and denomination registration utilities + +#### Gaia + +* [\#2935](https://github.com/cosmos/cosmos-sdk/issues/2935) Optionally assert invariants on a blockly basis using `gaiad --assert-invariants-blockly` +* [\#3886](https://github.com/cosmos/cosmos-sdk/issues/3886) Implement minting module querier and CLI/REST clients. + +#### Gaia CLI + +* [\#3937](https://github.com/cosmos/cosmos-sdk/issues/3937) Add command to query community-pool + +#### Gaia REST API + +* [\#3937](https://github.com/cosmos/cosmos-sdk/issues/3937) Add route to fetch community-pool +* [\#3949](https://github.com/cosmos/cosmos-sdk/issues/3949) added /slashing/signing_infos to get signing_info for all validators + +### Improvements + +#### Gaia + +* [\#3808](https://github.com/cosmos/cosmos-sdk/issues/3808) `gaiad` and `gaiacli` integration tests use ./build/ binaries. +* \[\#3819](https://github.com/cosmos/cosmos-sdk/issues/3819) Simulation refactor, log output now stored in ~/.gaiad/simulation/ + * Simulation moved to its own module (not a part of mock) + * Logger type instead of passing function variables everywhere + * Logger json output (for reloadable simulation running) + * Cleanup bank simulation messages / remove dup code in bank simulation + * Simulations saved in `~/.gaiad/simulations/` + * "Lean" simulation output option to exclude No-ops and !ok functions (`--SimulationLean` flag) +* [\#3893](https://github.com/cosmos/cosmos-sdk/issues/3893) Improve `gaiacli tx sign` command + * Add shorthand flags -a and -s for the account and sequence numbers respectively + * Mark the account and sequence numbers required during "offline" mode + * Always do an RPC query for account and sequence number during "online" mode +* [\#4018](https://github.com/cosmos/cosmos-sdk/issues/4018) create genesis port script for release v.0.34.0 + +#### Gaia CLI + +* [\#3833](https://github.com/cosmos/cosmos-sdk/issues/3833) Modify stake to atom in gaia's doc. +* [\#3841](https://github.com/cosmos/cosmos-sdk/issues/3841) Add indent to JSON of `gaiacli keys [add|show|list]` +* [\#3859](https://github.com/cosmos/cosmos-sdk/issues/3859) Add newline to echo of `gaiacli keys ...` +* [\#3959](https://github.com/cosmos/cosmos-sdk/issues/3959) Improving error messages when signing with ledger devices fails + +#### SDK + +* [\#3238](https://github.com/cosmos/cosmos-sdk/issues/3238) Add block time to tx responses when querying for + txs by tags or hash. +* \[\#3752](https://github.com/cosmos/cosmos-sdk/issues/3752) Explanatory docs for minting mechanism (`docs/spec/mint/01_concepts.md`) +* [\#3801](https://github.com/cosmos/cosmos-sdk/issues/3801) `baseapp` safety improvements +* [\#3820](https://github.com/cosmos/cosmos-sdk/issues/3820) Make Coins.IsAllGT() more robust and consistent. +* [\#3828](https://github.com/cosmos/cosmos-sdk/issues/3828) New sdkch tool to maintain changelogs +* [\#3864](https://github.com/cosmos/cosmos-sdk/issues/3864) Make Coins.IsAllGTE() more consistent. +* [\#3907](https://github.com/cosmos/cosmos-sdk/issues/3907): dep -> go mod migration + * Drop dep in favor of go modules. + * Upgrade to Go 1.12.1. +* [\#3917](https://github.com/cosmos/cosmos-sdk/issues/3917) Allow arbitrary decreases to validator commission rates. +* [\#3937](https://github.com/cosmos/cosmos-sdk/issues/3937) Implement community pool querier. +* [\#3940](https://github.com/cosmos/cosmos-sdk/issues/3940) Codespace should be lowercase. +* [\#3986](https://github.com/cosmos/cosmos-sdk/issues/3986) Update the Stringer implementation of the Proposal type. +* [\#926](https://github.com/cosmos/cosmos-sdk/issues/926) circuit breaker high level explanation +* [\#3896](https://github.com/cosmos/cosmos-sdk/issues/3896) Fixed various linters warnings in the context of the gometalinter -> golangci-lint migration +* [\#3916](https://github.com/cosmos/cosmos-sdk/issues/3916) Hex encode data in tx responses + +### Bug Fixes + +#### Gaia + +* [\#3825](https://github.com/cosmos/cosmos-sdk/issues/3825) Validate genesis before running gentx +* [\#3889](https://github.com/cosmos/cosmos-sdk/issues/3889) When `--generate-only` is provided, the Keybase is not used and as a result + the `--from` value must be a valid Bech32 cosmos address. +* 3974 Fix go env setting in installation.md +* 3996 Change 'make get_tools' to 'make tools' in DOCS_README.md. + +#### Gaia CLI + +* [\#3883](https://github.com/cosmos/cosmos-sdk/issues/3883) Remove Height Flag from CLI Queries +* [\#3899](https://github.com/cosmos/cosmos-sdk/issues/3899) Using 'gaiacli config node' breaks ~/config/config.toml + +#### SDK + +* [\#3837](https://github.com/cosmos/cosmos-sdk/issues/3837) Fix `WithdrawValidatorCommission` to properly set the validator's remaining commission. +* [\#3870](https://github.com/cosmos/cosmos-sdk/issues/3870) Fix DecCoins#TruncateDecimal to never return zero coins in + either the truncated coins or the change coins. +* [\#3915](https://github.com/cosmos/cosmos-sdk/issues/3915) Remove ';' delimiting support from ParseDecCoins +* [\#3977](https://github.com/cosmos/cosmos-sdk/issues/3977) Fix docker image build +* [\#4020](https://github.com/cosmos/cosmos-sdk/issues/4020) Fix queryDelegationRewards by returning an error +when the validator or delegation do not exist. +* [\#4050](https://github.com/cosmos/cosmos-sdk/issues/4050) Fix DecCoins APIs +where rounding or truncation could result in zero decimal coins. +* [\#4088](https://github.com/cosmos/cosmos-sdk/issues/4088) Fix `calculateDelegationRewards` +by accounting for rounding errors when multiplying stake by slashing fractions. + +## 0.33.2 + +### Improvements + +#### Tendermint + +* Upgrade Tendermint to `v0.31.0-dev0-fix0` which includes critical security fixes. + +## 0.33.1 + +### Bug Fixes + +#### Gaia + +* [\#3999](https://github.com/cosmos/cosmos-sdk/pull/3999) Fix distribution delegation for zero height export bug + ## 0.33.0 BREAKING CHANGES diff --git a/client/lcd/lcd_test.go b/client/lcd/lcd_test.go index f21abce2b8..e4d49229b4 100644 --- a/client/lcd/lcd_test.go +++ b/client/lcd/lcd_test.go @@ -610,7 +610,9 @@ func TestSubmitProposal(t *testing.T) { require.Equal(t, uint32(0), resultTx.Code) var proposalID uint64 - cdc.MustUnmarshalBinaryLengthPrefixed(resultTx.Data, &proposalID) + bz, err := hex.DecodeString(resultTx.Data) + require.NoError(t, err) + cdc.MustUnmarshalBinaryLengthPrefixed(bz, &proposalID) // verify balance acc = getAccount(t, port, addr) @@ -645,7 +647,9 @@ func TestDeposit(t *testing.T) { require.Equal(t, uint32(0), resultTx.Code) var proposalID uint64 - cdc.MustUnmarshalBinaryLengthPrefixed(resultTx.Data, &proposalID) + bz, err := hex.DecodeString(resultTx.Data) + require.NoError(t, err) + cdc.MustUnmarshalBinaryLengthPrefixed(bz, &proposalID) // verify balance acc = getAccount(t, port, addr) @@ -702,7 +706,9 @@ func TestVote(t *testing.T) { require.Equal(t, uint32(0), resultTx.Code) var proposalID uint64 - cdc.MustUnmarshalBinaryLengthPrefixed(resultTx.Data, &proposalID) + bz, err := hex.DecodeString(resultTx.Data) + require.NoError(t, err) + cdc.MustUnmarshalBinaryLengthPrefixed(bz, &proposalID) // verify balance acc = getAccount(t, port, addr) @@ -803,18 +809,24 @@ func TestProposalsQuery(t *testing.T) { // Addr1 proposes (and deposits) proposals #1 and #2 resultTx := doSubmitProposal(t, port, seeds[0], names[0], passwords[0], addrs[0], halfMinDeposit, fees) var proposalID1 uint64 - cdc.MustUnmarshalBinaryLengthPrefixed(resultTx.Data, &proposalID1) + bz, err := hex.DecodeString(resultTx.Data) + require.NoError(t, err) + cdc.MustUnmarshalBinaryLengthPrefixed(bz, &proposalID1) tests.WaitForHeight(resultTx.Height+1, port) resultTx = doSubmitProposal(t, port, seeds[0], names[0], passwords[0], addrs[0], halfMinDeposit, fees) var proposalID2 uint64 - cdc.MustUnmarshalBinaryLengthPrefixed(resultTx.Data, &proposalID2) + bz, err = hex.DecodeString(resultTx.Data) + require.NoError(t, err) + cdc.MustUnmarshalBinaryLengthPrefixed(bz, &proposalID2) tests.WaitForHeight(resultTx.Height+1, port) // Addr2 proposes (and deposits) proposals #3 resultTx = doSubmitProposal(t, port, seeds[1], names[1], passwords[1], addrs[1], halfMinDeposit, fees) var proposalID3 uint64 - cdc.MustUnmarshalBinaryLengthPrefixed(resultTx.Data, &proposalID3) + bz, err = hex.DecodeString(resultTx.Data) + require.NoError(t, err) + cdc.MustUnmarshalBinaryLengthPrefixed(bz, &proposalID3) tests.WaitForHeight(resultTx.Height+1, port) // Addr2 deposits on proposals #2 & #3 diff --git a/contrib/export/lib.py b/contrib/export/lib.py new file mode 100644 index 0000000000..2e7457f753 --- /dev/null +++ b/contrib/export/lib.py @@ -0,0 +1,28 @@ +#!/usr/bin/env python3 + +import argparse +import json +import sys + + +def init_default_argument_parser(prog_desc, default_chain_id, default_start_time): + parser = argparse.ArgumentParser(description=prog_desc) + parser.add_argument( + 'exported_genesis', + help='exported genesis.json file', + type=argparse.FileType('r'), default=sys.stdin, + ) + parser.add_argument('--chain-id', type=str, default=default_chain_id) + parser.add_argument('--start-time', type=str, default=default_start_time) + return parser + + +def main(argument_parser, process_genesis_func): + args = argument_parser.parse_args() + if args.chain_id.strip() == '': + sys.exit('chain-id required') + + genesis = json.loads(args.exported_genesis.read()) + + print(json.dumps(process_genesis_func( + genesis=genesis, parsed_args=args,), indent=True)) diff --git a/contrib/export/v0.33.x-to-v0.34.0.py b/contrib/export/v0.33.x-to-v0.34.0.py new file mode 100755 index 0000000000..bb7d6520cf --- /dev/null +++ b/contrib/export/v0.33.x-to-v0.34.0.py @@ -0,0 +1,45 @@ +#!/usr/bin/env python3 + +import lib + + +def process_raw_genesis(genesis, parsed_args): + # update genesis with breaking changes + genesis['consensus_params']['block'] = genesis['consensus_params']['block_size'] + del genesis['consensus_params']['block_size'] + + genesis['app_state']['crisis'] = { + 'constant_fee': { + 'amount': '1333000000', # ~$5,000 worth of uatoms + 'denom': 'uatom', + }, + } + + # default tm value + genesis['consensus_params']['block']['time_iota_ms'] = '1000' + + # proposal #1 updates + genesis['app_state']['mint']['params']['blocks_per_year'] = '4855015' + + # proposal #2 updates + genesis['consensus_params']['block']['max_gas'] = '2000000' + genesis['consensus_params']['block']['max_bytes'] = '200000' + + # enable transfers + genesis['app_state']['bank']['send_enabled'] = True + genesis['app_state']['distr']['withdraw_addr_enabled'] = True + + # Set new chain ID and genesis start time + genesis['chain_id'] = parsed_args.chain_id.strip() + genesis['genesis_time'] = parsed_args.start_time + + return genesis + + +if __name__ == '__main__': + parser = lib.init_default_argument_parser( + prog_desc='Convert genesis.json from v0.33.x to v0.34.0', + default_chain_id='cosmoshub-n', + default_start_time='2019-02-11T12:00:00Z', + ) + lib.main(parser, process_raw_genesis) diff --git a/go.mod b/go.mod index faa47726d1..a845f33837 100644 --- a/go.mod +++ b/go.mod @@ -46,7 +46,7 @@ require ( github.com/tendermint/btcd v0.1.1 github.com/tendermint/go-amino v0.14.1 github.com/tendermint/iavl v0.12.1 - github.com/tendermint/tendermint v0.31.3 + github.com/tendermint/tendermint v0.31.4 github.com/zondax/hid v0.9.0 // indirect golang.org/x/crypto v0.0.0-20180904163835-0709b304e793 google.golang.org/grpc v1.19.0 // indirect diff --git a/go.sum b/go.sum index 0c92764b3d..271dd1eb71 100644 --- a/go.sum +++ b/go.sum @@ -147,8 +147,8 @@ github.com/tendermint/go-amino v0.14.1 h1:o2WudxNfdLNBwMyl2dqOJxiro5rfrEaU0Ugs6o github.com/tendermint/go-amino v0.14.1/go.mod h1:i/UKE5Uocn+argJJBb12qTZsCDBcAYMbR92AaJVmKso= github.com/tendermint/iavl v0.12.1 h1:JDfyhM/Hhrumu1CL1Nxrypm8sNTPYqmeHo1IZLiJoXM= github.com/tendermint/iavl v0.12.1/go.mod h1:EoKMMv++tDOL5qKKVnoIqtVPshRrEPeJ0WsgDOLAauM= -github.com/tendermint/tendermint v0.31.3 h1:IlehDNREaGdt/VVZTjs978R/lhmnIf4NOH3j+ZhhbZA= -github.com/tendermint/tendermint v0.31.3/go.mod h1:ymcPyWblXCplCPQjbOYbrF1fWnpslATMVqiGgWbZrlc= +github.com/tendermint/tendermint v0.31.4 h1:F/vZ/fMHZJriAkDLjf9ZrReJQsuELiTmJLqigmbE5NU= +github.com/tendermint/tendermint v0.31.4/go.mod h1:ymcPyWblXCplCPQjbOYbrF1fWnpslATMVqiGgWbZrlc= github.com/zondax/hid v0.9.0 h1:eiT3P6vNxAEVxXMw66eZUAAnU2zD33JBkfG/EnfAKl8= github.com/zondax/hid v0.9.0/go.mod h1:l5wttcP0jwtdLjqjMMWFVEE7d1zO0jvSPA9OPZxWpEM= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= diff --git a/types/dec_coin.go b/types/dec_coin.go index d9116c323e..1ecfd82608 100644 --- a/types/dec_coin.go +++ b/types/dec_coin.go @@ -312,55 +312,90 @@ func (coins DecCoins) IsAnyNegative() bool { return false } -// multiply all the coins by a decimal +// MulDec multiplies all the coins by a decimal. +// +// CONTRACT: No zero coins will be returned. func (coins DecCoins) MulDec(d Dec) DecCoins { - res := make([]DecCoin, len(coins)) - for i, coin := range coins { + var res DecCoins + for _, coin := range coins { product := DecCoin{ Denom: coin.Denom, Amount: coin.Amount.Mul(d), } - res[i] = product + + if !product.IsZero() { + res = res.Add(DecCoins{product}) + } } + return res } -// multiply all the coins by a decimal, truncating +// MulDecTruncate multiplies all the decimal coins by a decimal, truncating. It +// panics if d is zero. +// +// CONTRACT: No zero coins will be returned. func (coins DecCoins) MulDecTruncate(d Dec) DecCoins { - res := make([]DecCoin, len(coins)) - for i, coin := range coins { + var res DecCoins + + for _, coin := range coins { product := DecCoin{ Denom: coin.Denom, Amount: coin.Amount.MulTruncate(d), } - res[i] = product + + if !product.IsZero() { + res = res.Add(DecCoins{product}) + } } + return res } -// divide all the coins by a decimal +// QuoDec divides all the decimal coins by a decimal. It panics if d is zero. +// +// CONTRACT: No zero coins will be returned. func (coins DecCoins) QuoDec(d Dec) DecCoins { - res := make([]DecCoin, len(coins)) - for i, coin := range coins { + if d.IsZero() { + panic("invalid zero decimal") + } + + var res DecCoins + for _, coin := range coins { quotient := DecCoin{ Denom: coin.Denom, Amount: coin.Amount.Quo(d), } - res[i] = quotient + + if !quotient.IsZero() { + res = res.Add(DecCoins{quotient}) + } } + return res } -// divide all the coins by a decimal, truncating +// QuoDecTruncate divides all the decimal coins by a decimal, truncating. It +// panics if d is zero. +// +// CONTRACT: No zero coins will be returned. func (coins DecCoins) QuoDecTruncate(d Dec) DecCoins { - res := make([]DecCoin, len(coins)) - for i, coin := range coins { + if d.IsZero() { + panic("invalid zero decimal") + } + + var res DecCoins + for _, coin := range coins { quotient := DecCoin{ Denom: coin.Denom, Amount: coin.Amount.QuoTruncate(d), } - res[i] = quotient + + if !quotient.IsZero() { + res = res.Add(DecCoins{quotient}) + } } + return res } diff --git a/types/dec_coin_test.go b/types/dec_coin_test.go index f439484f92..7e904fe5dc 100644 --- a/types/dec_coin_test.go +++ b/types/dec_coin_test.go @@ -290,3 +290,28 @@ func TestDecCoinsTruncateDecimal(t *testing.T) { ) } } + +func TestDecCoinsQuoDecTruncate(t *testing.T) { + x := MustNewDecFromStr("1.00") + y := MustNewDecFromStr("10000000000000000000.00") + + testCases := []struct { + coins DecCoins + input Dec + result DecCoins + panics bool + }{ + {DecCoins{}, ZeroDec(), DecCoins(nil), true}, + {DecCoins{NewDecCoinFromDec("foo", x)}, y, DecCoins(nil), false}, + {DecCoins{NewInt64DecCoin("foo", 5)}, NewDec(2), DecCoins{NewDecCoinFromDec("foo", MustNewDecFromStr("2.5"))}, false}, + } + + for i, tc := range testCases { + if tc.panics { + require.Panics(t, func() { tc.coins.QuoDecTruncate(tc.input) }) + } else { + res := tc.coins.QuoDecTruncate(tc.input) + require.Equal(t, tc.result, res, "unexpected result; tc #%d, coins: %s, input: %s", i, tc.coins, tc.input) + } + } +} diff --git a/types/result.go b/types/result.go index 9b679b3860..e83ed56e16 100644 --- a/types/result.go +++ b/types/result.go @@ -1,6 +1,7 @@ package types import ( + "encoding/hex" "encoding/json" "fmt" "strings" @@ -67,7 +68,7 @@ type TxResponse struct { Height int64 `json:"height"` TxHash string `json:"txhash"` Code uint32 `json:"code,omitempty"` - Data []byte `json:"data,omitempty"` + Data string `json:"data,omitempty"` RawLog string `json:"raw_log,omitempty"` Logs ABCIMessageLogs `json:"logs,omitempty"` Info string `json:"info,omitempty"` @@ -91,7 +92,7 @@ func NewResponseResultTx(res *ctypes.ResultTx, tx Tx, timestamp string) TxRespon TxHash: res.Hash.String(), Height: res.Height, Code: res.TxResult.Code, - Data: res.TxResult.Data, + Data: strings.ToUpper(hex.EncodeToString(res.TxResult.Data)), RawLog: res.TxResult.Log, Logs: parsedLogs, Info: res.TxResult.Info, @@ -129,7 +130,7 @@ func newTxResponseCheckTx(res *ctypes.ResultBroadcastTxCommit) TxResponse { Height: res.Height, TxHash: txHash, Code: res.CheckTx.Code, - Data: res.CheckTx.Data, + Data: strings.ToUpper(hex.EncodeToString(res.CheckTx.Data)), RawLog: res.CheckTx.Log, Logs: parsedLogs, Info: res.CheckTx.Info, @@ -156,7 +157,7 @@ func newTxResponseDeliverTx(res *ctypes.ResultBroadcastTxCommit) TxResponse { Height: res.Height, TxHash: txHash, Code: res.DeliverTx.Code, - Data: res.DeliverTx.Data, + Data: strings.ToUpper(hex.EncodeToString(res.DeliverTx.Data)), RawLog: res.DeliverTx.Log, Logs: parsedLogs, Info: res.DeliverTx.Info, @@ -177,7 +178,7 @@ func NewResponseFormatBroadcastTx(res *ctypes.ResultBroadcastTx) TxResponse { return TxResponse{ Code: res.Code, - Data: res.Data.Bytes(), + Data: res.Data.String(), RawLog: res.Log, Logs: parsedLogs, TxHash: res.Hash.String(), @@ -200,8 +201,8 @@ func (r TxResponse) String() string { sb.WriteString(fmt.Sprintf(" Code: %d\n", r.Code)) } - if r.Data != nil { - sb.WriteString(fmt.Sprintf(" Data: %s\n", string(r.Data))) + if r.Data != "" { + sb.WriteString(fmt.Sprintf(" Data: %s\n", r.Data)) } if r.RawLog != "" { diff --git a/types/staking.go b/types/staking.go index fadf57f913..79832ac00a 100644 --- a/types/staking.go +++ b/types/staking.go @@ -75,6 +75,7 @@ type Validator interface { GetDelegatorShares() Dec // total outstanding delegator shares TokensFromShares(Dec) Dec // token worth of provided delegator shares TokensFromSharesTruncated(Dec) Dec // token worth of provided delegator shares, truncated + TokensFromSharesRoundUp(Dec) Dec // token worth of provided delegator shares, rounded up SharesFromTokens(amt Int) (Dec, Error) // shares worth of delegator's bond SharesFromTokensTruncated(amt Int) (Dec, Error) // truncated shares worth of delegator's bond } diff --git a/x/distribution/keeper/delegation.go b/x/distribution/keeper/delegation.go index 0bbe091519..4b388ff923 100644 --- a/x/distribution/keeper/delegation.go +++ b/x/distribution/keeper/delegation.go @@ -64,13 +64,16 @@ func (k Keeper) calculateDelegationRewards(ctx sdk.Context, val sdk.Validator, d startingPeriod := startingInfo.PreviousPeriod stake := startingInfo.Stake - // iterate through slashes and withdraw with calculated staking for sub-intervals - // these offsets are dependent on *when* slashes happen - namely, in BeginBlock, after rewards are allocated... - // slashes which happened in the first block would have been before this delegation existed, - // UNLESS they were slashes of a redelegation to this validator which was itself slashed - // (from a fault committed by the redelegation source validator) earlier in the same BeginBlock + // Iterate through slashes and withdraw with calculated staking for + // distribution periods. These period offsets are dependent on *when* slashes + // happen - namely, in BeginBlock, after rewards are allocated... + // Slashes which happened in the first block would have been before this + // delegation existed, UNLESS they were slashes of a redelegation to this + // validator which was itself slashed (from a fault committed by the + // redelegation source validator) earlier in the same BeginBlock. startingHeight := startingInfo.Height - // slashes this block happened after reward allocation, but we have to account for them for the stake sanity check below + // Slashes this block happened after reward allocation, but we have to account + // for them for the stake sanity check below. endingHeight := uint64(ctx.BlockHeight()) if endingHeight > startingHeight { k.IterateValidatorSlashEventsBetween(ctx, del.GetValidatorAddr(), startingHeight, endingHeight, @@ -78,7 +81,9 @@ func (k Keeper) calculateDelegationRewards(ctx sdk.Context, val sdk.Validator, d endingPeriod := event.ValidatorPeriod if endingPeriod > startingPeriod { rewards = rewards.Add(k.calculateDelegationRewardsBetween(ctx, val, startingPeriod, endingPeriod, stake)) - // note: necessary to truncate so we don't allow withdrawing more rewards than owed + + // Note: It is necessary to truncate so we don't allow withdrawing + // more rewards than owed. stake = stake.MulTruncate(sdk.OneDec().Sub(event.Fraction)) startingPeriod = endingPeriod } @@ -87,18 +92,26 @@ func (k Keeper) calculateDelegationRewards(ctx sdk.Context, val sdk.Validator, d ) } - // a stake sanity check - recalculated final stake should be less than or equal to current stake - // here we cannot use Equals because stake is truncated when multiplied by slash fractions - // we could only use equals if we had arbitrary-precision rationals + // A total stake sanity check; Recalculated final stake should be less than or + // equal to current stake here. We cannot use Equals because stake is truncated + // when multiplied by slash fractions (see above). We could only use equals if + // we had arbitrary-precision rationals. currentStake := val.TokensFromShares(del.GetShares()) if stake.GT(currentStake) { - panic(fmt.Sprintf("calculated final stake for delegator %s greater than current stake: %s, %s", - del.GetDelegatorAddr(), stake, currentStake)) + // account for rounding errors due to stake being multiplied by slash fractions + currentStakeRoundUp := val.TokensFromSharesRoundUp(del.GetShares()) + if stake.Equal(currentStakeRoundUp) { + stake = currentStake + } else { + panic(fmt.Sprintf("calculated final stake for delegator %s greater than current stake"+ + "\n\tfinal stake:\t%s"+ + "\n\tcurrent stake:\t%s", + del.GetDelegatorAddr(), stake, currentStake)) + } } // calculate rewards for final period rewards = rewards.Add(k.calculateDelegationRewardsBetween(ctx, val, startingPeriod, endingPeriod, stake)) - return rewards } diff --git a/x/distribution/keeper/querier.go b/x/distribution/keeper/querier.go index 6b7ca4ae5a..6b79313395 100644 --- a/x/distribution/keeper/querier.go +++ b/x/distribution/keeper/querier.go @@ -207,7 +207,17 @@ func queryDelegationRewards(ctx sdk.Context, _ []string, req abci.RequestQuery, ctx, _ = ctx.CacheContext() val := k.stakingKeeper.Validator(ctx, params.ValidatorAddress) + if val == nil { + // TODO: Should use ErrNoValidatorFound from staking/types + return nil, sdk.ErrInternal(fmt.Sprintf("validator %s does not exist", params.ValidatorAddress)) + } + del := k.stakingKeeper.Delegation(ctx, params.DelegatorAddress, params.ValidatorAddress) + if del == nil { + // TODO: Should use ErrNoDelegation from staking/types + return nil, sdk.ErrInternal("delegation does not exist") + } + endingPeriod := k.incrementValidatorPeriod(ctx, val) rewards := k.calculateDelegationRewards(ctx, val, del, endingPeriod) diff --git a/x/distribution/keeper/validator.go b/x/distribution/keeper/validator.go index 18c6cc6e87..93c20f4793 100644 --- a/x/distribution/keeper/validator.go +++ b/x/distribution/keeper/validator.go @@ -106,7 +106,10 @@ func (k Keeper) updateValidatorSlashFraction(ctx sdk.Context, valAddr sdk.ValAdd } currentMultiplicand := sdk.OneDec().Sub(currentFraction) newMultiplicand := sdk.OneDec().Sub(fraction) - updatedFraction := sdk.OneDec().Sub(currentMultiplicand.Mul(newMultiplicand)) + + // using MulTruncate here conservatively increases the slashing amount + updatedFraction := sdk.OneDec().Sub(currentMultiplicand.MulTruncate(newMultiplicand)) + if updatedFraction.LT(sdk.ZeroDec()) { panic("negative slash fraction") } diff --git a/x/staking/types/validator.go b/x/staking/types/validator.go index e7132ebff3..c048de744c 100644 --- a/x/staking/types/validator.go +++ b/x/staking/types/validator.go @@ -421,6 +421,12 @@ func (v Validator) TokensFromSharesTruncated(shares sdk.Dec) sdk.Dec { return (shares.MulInt(v.Tokens)).QuoTruncate(v.DelegatorShares) } +// TokensFromSharesRoundUp returns the token worth of provided shares, rounded +// up. +func (v Validator) TokensFromSharesRoundUp(shares sdk.Dec) sdk.Dec { + return (shares.MulInt(v.Tokens)).QuoRoundUp(v.DelegatorShares) +} + // SharesFromTokens returns the shares of a delegation given a bond amount. It // returns an error if the validator has no tokens. func (v Validator) SharesFromTokens(amt sdk.Int) (sdk.Dec, sdk.Error) {