From e74176ad1aa68daa911bfe697d5538ce12e2bcbc Mon Sep 17 00:00:00 2001 From: Erik Grinaker Date: Thu, 1 Oct 2020 17:02:11 +0200 Subject: [PATCH] privval: fix ping message encoding (#5442) Fixes #5371. --- CHANGELOG_PENDING.md | 2 ++ privval/msgs.go | 6 +++--- privval/msgs_test.go | 4 ++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/CHANGELOG_PENDING.md b/CHANGELOG_PENDING.md index 78d13cf9a..9028185f0 100644 --- a/CHANGELOG_PENDING.md +++ b/CHANGELOG_PENDING.md @@ -28,3 +28,5 @@ Friendly reminder, we have a [bug bounty program](https://hackerone.com/tendermi ### BUG FIXES +- [privval] \#5441 Fix faulty ping message encoding causing nil message errors in logs (@erikgrinaker) + diff --git a/privval/msgs.go b/privval/msgs.go index b7a95dbfe..bcfed629b 100644 --- a/privval/msgs.go +++ b/privval/msgs.go @@ -29,11 +29,11 @@ func mustWrapMsg(pb proto.Message) privvalproto.Message { case *privvalproto.SignProposalRequest: msg.Sum = &privvalproto.Message_SignProposalRequest{SignProposalRequest: pb} case *privvalproto.PingRequest: - msg.Sum = &privvalproto.Message_PingRequest{} + msg.Sum = &privvalproto.Message_PingRequest{PingRequest: pb} case *privvalproto.PingResponse: - msg.Sum = &privvalproto.Message_PingResponse{} + msg.Sum = &privvalproto.Message_PingResponse{PingResponse: pb} default: - panic(fmt.Errorf("unknown message type %T", msg)) + panic(fmt.Errorf("unknown message type %T", pb)) } return msg diff --git a/privval/msgs_test.go b/privval/msgs_test.go index 61b809b2f..f6f1681db 100644 --- a/privval/msgs_test.go +++ b/privval/msgs_test.go @@ -78,8 +78,8 @@ func TestPrivvalVectors(t *testing.T) { msg proto.Message expBytes string }{ - {"ping request", &privproto.PingRequest{}, ""}, - {"ping response", &privproto.PingResponse{}, ""}, + {"ping request", &privproto.PingRequest{}, "3a00"}, + {"ping response", &privproto.PingResponse{}, "4200"}, {"pubKey request", &privproto.PubKeyRequest{}, "0a00"}, {"pubKey response", &privproto.PubKeyResponse{PubKey: &ppk, Error: nil}, "12240a220a20556a436f1218d30942efe798420f51dc9b6a311b929c578257457d05c5fcf230"}, {"pubKey response with error", &privproto.PubKeyResponse{PubKey: nil, Error: remoteError}, "121212100801120c697427732061206572726f72"},