From 317bd0bee3146483c10d0bfb26ebd355fd4c5786 Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Tue, 21 Jun 2022 08:13:26 +0200 Subject: [PATCH 1/2] Fix decoding validator update Backport of https://github.com/cosmos/cosmjs/pull/1178 --- CHANGELOG.md | 4 ++++ .../tendermint34/adaptor/responses.spec.ts | 21 +++++++++++++++++++ .../src/tendermint34/adaptor/responses.ts | 5 +++-- 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 71503476..bc7cdf73 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ and this project adheres to ## [Unreleased] +- @cosmjs/tendermint-rpc: Fix decoding validator updates due to slashing ([#1177]). + +[#1177]: https://github.com/cosmos/cosmjs/issues/1177 + ## [0.28.7] - 2022-06-14 ### Fixed diff --git a/packages/tendermint-rpc/src/tendermint34/adaptor/responses.spec.ts b/packages/tendermint-rpc/src/tendermint34/adaptor/responses.spec.ts index 04bdd6ee..d00a3120 100644 --- a/packages/tendermint-rpc/src/tendermint34/adaptor/responses.spec.ts +++ b/packages/tendermint-rpc/src/tendermint34/adaptor/responses.spec.ts @@ -49,6 +49,27 @@ describe("Adaptor Responses", () => { votingPower: 11418237, }); }); + + it("works for block results format without voting power", () => { + // from https://rpc.cosmos.network/block_results?height=10883046 + const update = decodeValidatorUpdate({ + pub_key: { + Sum: { + type: "tendermint.crypto.PublicKey_Ed25519", + value: { + ed25519: "HjSC7VkhKih6xMhudlqfaFE8ZZnP8RKJPv4iqR7RhcE=", + }, + }, + }, + }); + expect(update).toEqual({ + pubkey: { + algorithm: "ed25519", + data: fromBase64("HjSC7VkhKih6xMhudlqfaFE8ZZnP8RKJPv4iqR7RhcE="), + }, + votingPower: 0, + }); + }); }); describe("decodeValidatorInfo", () => { diff --git a/packages/tendermint-rpc/src/tendermint34/adaptor/responses.ts b/packages/tendermint-rpc/src/tendermint34/adaptor/responses.ts index d76fbce2..f4ac865f 100644 --- a/packages/tendermint-rpc/src/tendermint34/adaptor/responses.ts +++ b/packages/tendermint-rpc/src/tendermint34/adaptor/responses.ts @@ -257,13 +257,14 @@ function decodeConsensusParams(data: RpcConsensusParams): responses.ConsensusPar // for block results interface RpcValidatorUpdate { readonly pub_key: RpcPubkey; - readonly power: string; + // When omitted, this means zero (see https://github.com/cosmos/cosmjs/issues/1177#issuecomment-1160115080) + readonly power?: string; } export function decodeValidatorUpdate(data: RpcValidatorUpdate): responses.ValidatorUpdate { return { pubkey: decodePubkey(assertObject(data.pub_key)), - votingPower: Integer.parse(assertNotEmpty(data.power)), + votingPower: Integer.parse(data.power ?? 0), }; } From 5ec2da12c4798b44cfbab963b39db9858dda944b Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Tue, 21 Jun 2022 08:38:45 +0200 Subject: [PATCH 2/2] Set version 0.26.8 --- CHANGELOG.md | 8 ++++++-- packages/amino/package.json | 2 +- packages/cli/package.json | 2 +- packages/cosmwasm-stargate/package.json | 2 +- packages/crypto/package.json | 2 +- packages/encoding/package.json | 2 +- packages/faucet-client/package.json | 2 +- packages/faucet/package.json | 2 +- packages/json-rpc/package.json | 2 +- packages/ledger-amino/package.json | 2 +- packages/math/package.json | 2 +- packages/proto-signing/package.json | 2 +- packages/socket/package.json | 2 +- packages/stargate/package.json | 2 +- packages/stream/package.json | 2 +- packages/tendermint-rpc/package.json | 2 +- packages/utils/package.json | 2 +- 17 files changed, 22 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bc7cdf73..3e765392 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,10 @@ and this project adheres to ## [Unreleased] -- @cosmjs/tendermint-rpc: Fix decoding validator updates due to slashing ([#1177]). +## [0.28.8] - 2022-06-21 + +- @cosmjs/tendermint-rpc: Fix decoding validator updates due to slashing + ([#1177]). [#1177]: https://github.com/cosmos/cosmjs/issues/1177 @@ -912,7 +915,8 @@ CHANGELOG entries missing. Please see [the diff][0.24.1]. `FeeTable`. @cosmjs/cosmwasm has its own `FeeTable` with those properties. - @cosmjs/sdk38: Rename package to @cosmjs/launchpad. -[unreleased]: https://github.com/cosmos/cosmjs/compare/v0.28.7...HEAD +[unreleased]: https://github.com/cosmos/cosmjs/compare/v0.28.8...HEAD +[0.28.8]: https://github.com/cosmos/cosmjs/compare/v0.28.7...v0.28.8 [0.28.7]: https://github.com/cosmos/cosmjs/compare/v0.28.6...v0.28.7 [0.28.6]: https://github.com/cosmos/cosmjs/compare/v0.28.5...v0.28.6 [0.28.5]: https://github.com/cosmos/cosmjs/compare/v0.28.4...v0.28.5 diff --git a/packages/amino/package.json b/packages/amino/package.json index 4ed96dcc..2be2f926 100644 --- a/packages/amino/package.json +++ b/packages/amino/package.json @@ -1,6 +1,6 @@ { "name": "@cosmjs/amino", - "version": "0.28.7", + "version": "0.26.8", "description": "Helpers for Amino based signing.", "contributors": [ "Simon Warta " diff --git a/packages/cli/package.json b/packages/cli/package.json index 3fee3283..358dd39f 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "@cosmjs/cli", - "version": "0.28.7", + "version": "0.26.8", "description": "Command line interface", "contributors": [ "IOV SAS ", diff --git a/packages/cosmwasm-stargate/package.json b/packages/cosmwasm-stargate/package.json index 5d6f12b3..09c09dd9 100644 --- a/packages/cosmwasm-stargate/package.json +++ b/packages/cosmwasm-stargate/package.json @@ -1,6 +1,6 @@ { "name": "@cosmjs/cosmwasm-stargate", - "version": "0.28.7", + "version": "0.26.8", "description": "CosmWasm SDK", "contributors": [ "Will Clark " diff --git a/packages/crypto/package.json b/packages/crypto/package.json index 2c34df99..01d448fe 100644 --- a/packages/crypto/package.json +++ b/packages/crypto/package.json @@ -1,6 +1,6 @@ { "name": "@cosmjs/crypto", - "version": "0.28.7", + "version": "0.26.8", "description": "Cryptography resources for blockchain projects", "contributors": [ "IOV SAS ", diff --git a/packages/encoding/package.json b/packages/encoding/package.json index c5973b3d..bda9da0e 100644 --- a/packages/encoding/package.json +++ b/packages/encoding/package.json @@ -1,6 +1,6 @@ { "name": "@cosmjs/encoding", - "version": "0.28.7", + "version": "0.26.8", "description": "Encoding helpers for blockchain projects", "contributors": [ "IOV SAS " diff --git a/packages/faucet-client/package.json b/packages/faucet-client/package.json index aa29bff7..b669e060 100644 --- a/packages/faucet-client/package.json +++ b/packages/faucet-client/package.json @@ -1,6 +1,6 @@ { "name": "@cosmjs/faucet-client", - "version": "0.28.7", + "version": "0.26.8", "description": "The faucet client", "contributors": [ "Will Clark " diff --git a/packages/faucet/package.json b/packages/faucet/package.json index 245a5f95..3efe26bb 100644 --- a/packages/faucet/package.json +++ b/packages/faucet/package.json @@ -1,6 +1,6 @@ { "name": "@cosmjs/faucet", - "version": "0.28.7", + "version": "0.26.8", "description": "The faucet", "contributors": [ "Ethan Frey ", diff --git a/packages/json-rpc/package.json b/packages/json-rpc/package.json index 8536baab..cd536716 100644 --- a/packages/json-rpc/package.json +++ b/packages/json-rpc/package.json @@ -1,6 +1,6 @@ { "name": "@cosmjs/json-rpc", - "version": "0.28.7", + "version": "0.26.8", "description": "Framework for implementing a JSON-RPC 2.0 API", "contributors": [ "IOV SAS ", diff --git a/packages/ledger-amino/package.json b/packages/ledger-amino/package.json index e33db23b..0a8b7275 100644 --- a/packages/ledger-amino/package.json +++ b/packages/ledger-amino/package.json @@ -1,6 +1,6 @@ { "name": "@cosmjs/ledger-amino", - "version": "0.28.7", + "version": "0.26.8", "description": "A library for signing Amino-encoded transactions using Ledger devices", "contributors": [ "Will Clark " diff --git a/packages/math/package.json b/packages/math/package.json index af777631..dd76dbeb 100644 --- a/packages/math/package.json +++ b/packages/math/package.json @@ -1,6 +1,6 @@ { "name": "@cosmjs/math", - "version": "0.28.7", + "version": "0.26.8", "description": "Math helpers for blockchain projects", "contributors": [ "IOV SAS " diff --git a/packages/proto-signing/package.json b/packages/proto-signing/package.json index a0d43b29..4801f47e 100644 --- a/packages/proto-signing/package.json +++ b/packages/proto-signing/package.json @@ -1,6 +1,6 @@ { "name": "@cosmjs/proto-signing", - "version": "0.28.7", + "version": "0.26.8", "description": "Utilities for protobuf based signing (Cosmos SDK 0.40+)", "contributors": [ "Will Clark ", diff --git a/packages/socket/package.json b/packages/socket/package.json index 4c797903..0ad5813f 100644 --- a/packages/socket/package.json +++ b/packages/socket/package.json @@ -1,6 +1,6 @@ { "name": "@cosmjs/socket", - "version": "0.28.7", + "version": "0.26.8", "description": "Utility functions for working with WebSockets", "contributors": [ "IOV SAS ", diff --git a/packages/stargate/package.json b/packages/stargate/package.json index b4c513fc..0d536cbc 100644 --- a/packages/stargate/package.json +++ b/packages/stargate/package.json @@ -1,6 +1,6 @@ { "name": "@cosmjs/stargate", - "version": "0.28.7", + "version": "0.26.8", "description": "Utilities for Cosmos SDK 0.40", "contributors": [ "Simon Warta " diff --git a/packages/stream/package.json b/packages/stream/package.json index 8753bae2..08f270ff 100644 --- a/packages/stream/package.json +++ b/packages/stream/package.json @@ -1,6 +1,6 @@ { "name": "@cosmjs/stream", - "version": "0.28.7", + "version": "0.26.8", "description": "Utility functions for producing and consuming streams", "contributors": [ "IOV SAS ", diff --git a/packages/tendermint-rpc/package.json b/packages/tendermint-rpc/package.json index d88ff874..51df5516 100644 --- a/packages/tendermint-rpc/package.json +++ b/packages/tendermint-rpc/package.json @@ -1,6 +1,6 @@ { "name": "@cosmjs/tendermint-rpc", - "version": "0.28.7", + "version": "0.26.8", "description": "Tendermint RPC clients", "contributors": [ "IOV SAS ", diff --git a/packages/utils/package.json b/packages/utils/package.json index 2d79fba6..0f50c5b6 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -1,6 +1,6 @@ { "name": "@cosmjs/utils", - "version": "0.28.7", + "version": "0.26.8", "description": "Utility tools, primarily for testing code", "contributors": [ "IOV SAS "