From f5449e40fd1369898349199ca90eeb3ae63bee70 Mon Sep 17 00:00:00 2001 From: Joe Bowman Date: Mon, 30 Jul 2018 22:17:17 +0100 Subject: [PATCH 1/4] update /slashing/signing_info/ endpoint of lcd to take cosmosvalpub instead of cosmosvaladdr for consistencyu reasons --- x/slashing/client/rest/query.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/x/slashing/client/rest/query.go b/x/slashing/client/rest/query.go index 123e235ce0a5..62cbca855d32 100644 --- a/x/slashing/client/rest/query.go +++ b/x/slashing/client/rest/query.go @@ -25,16 +25,15 @@ func signingInfoHandlerFn(ctx context.CoreContext, storeName string, cdc *wire.C // read parameters vars := mux.Vars(r) - bech32validator := vars["validator"] - validatorAddr, err := sdk.ValAddressFromBech32(bech32validator) - if err != nil { + pk, err := sdk.GetValPubKeyBech32(vars["validator"]) + if err != nil { w.WriteHeader(http.StatusBadRequest) w.Write([]byte(err.Error())) return - } + } - key := slashing.GetValidatorSigningInfoKey(validatorAddr) + key := slashing.GetValidatorSigningInfoKey(sdk.ValAddress(pk.Address())) res, err := ctx.QueryStore(key, storeName) if err != nil { w.WriteHeader(http.StatusInternalServerError) From a02432d88e8c347d4210a24e519f554b2b77f51b Mon Sep 17 00:00:00 2001 From: Joe Bowman Date: Mon, 30 Jul 2018 22:22:54 +0100 Subject: [PATCH 2/4] update pending.md --- PENDING.md | 1 + 1 file changed, 1 insertion(+) diff --git a/PENDING.md b/PENDING.md index 557a5e457b45..a16e90aa38ee 100644 --- a/PENDING.md +++ b/PENDING.md @@ -25,6 +25,7 @@ BREAKING CHANGES * `gaiacli gov vote --voter` * [x/gov] Added tags sub-package, changed tags to use dash-case * [x/gov] Governance parameters are now stored in globalparams store +* [lcd] \#1866 Updated lcd /slashing/signing_info endpoint to take cosmosvalpub instead of cosmosvaladdr FEATURES * [lcd] Can now query governance proposals by ProposalStatus From cfad15e62bd817b4365494deed50c79cfc11442a Mon Sep 17 00:00:00 2001 From: Joe Bowman Date: Tue, 31 Jul 2018 00:26:27 +0100 Subject: [PATCH 3/4] update test that calls /slashing/signing-info endpoint --- client/lcd/lcd_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/client/lcd/lcd_test.go b/client/lcd/lcd_test.go index 87566cff9335..ad632ff5c082 100644 --- a/client/lcd/lcd_test.go +++ b/client/lcd/lcd_test.go @@ -526,8 +526,8 @@ func TestUnrevoke(t *testing.T) { // XXX: any less than this and it fails tests.WaitForHeight(3, port) - - signingInfo := getSigningInfo(t, port, sdk.ValAddress(pks[0].Address())) + pkString, _ := sdk.Bech32ifyValPub(pks[0]) + signingInfo := getSigningInfo(t, port, pkString) tests.WaitForHeight(4, port) require.Equal(t, true, signingInfo.IndexOffset > 0) require.Equal(t, int64(0), signingInfo.JailedUntil) @@ -710,8 +710,8 @@ func doIBCTransfer(t *testing.T, port, seed, name, password string, addr sdk.Acc return resultTx } -func getSigningInfo(t *testing.T, port string, validatorAddr sdk.ValAddress) slashing.ValidatorSigningInfo { - res, body := Request(t, port, "GET", fmt.Sprintf("/slashing/signing_info/%s", validatorAddr), nil) +func getSigningInfo(t *testing.T, port string, validatorPubKey string) slashing.ValidatorSigningInfo { + res, body := Request(t, port, "GET", fmt.Sprintf("/slashing/signing_info/%s", validatorPubKey), nil) require.Equal(t, http.StatusOK, res.StatusCode, body) var signingInfo slashing.ValidatorSigningInfo err := cdc.UnmarshalJSON([]byte(body), &signingInfo) From 6782672d6651799ea0b47624b200b44576bead42 Mon Sep 17 00:00:00 2001 From: Joe Bowman Date: Tue, 31 Jul 2018 00:35:15 +0100 Subject: [PATCH 4/4] fix indentation --- client/lcd/lcd_test.go | 2 +- x/slashing/client/rest/query.go | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/client/lcd/lcd_test.go b/client/lcd/lcd_test.go index ad632ff5c082..9785b902437b 100644 --- a/client/lcd/lcd_test.go +++ b/client/lcd/lcd_test.go @@ -526,7 +526,7 @@ func TestUnrevoke(t *testing.T) { // XXX: any less than this and it fails tests.WaitForHeight(3, port) - pkString, _ := sdk.Bech32ifyValPub(pks[0]) + pkString, _ := sdk.Bech32ifyValPub(pks[0]) signingInfo := getSigningInfo(t, port, pkString) tests.WaitForHeight(4, port) require.Equal(t, true, signingInfo.IndexOffset > 0) diff --git a/x/slashing/client/rest/query.go b/x/slashing/client/rest/query.go index 62cbca855d32..535a642d4285 100644 --- a/x/slashing/client/rest/query.go +++ b/x/slashing/client/rest/query.go @@ -26,12 +26,12 @@ func signingInfoHandlerFn(ctx context.CoreContext, storeName string, cdc *wire.C // read parameters vars := mux.Vars(r) - pk, err := sdk.GetValPubKeyBech32(vars["validator"]) - if err != nil { + pk, err := sdk.GetValPubKeyBech32(vars["validator"]) + if err != nil { w.WriteHeader(http.StatusBadRequest) w.Write([]byte(err.Error())) return - } + } key := slashing.GetValidatorSigningInfoKey(sdk.ValAddress(pk.Address())) res, err := ctx.QueryStore(key, storeName)