From d30e1d83b63a9b4d3765ea5be1287bf6af67108c Mon Sep 17 00:00:00 2001 From: Erik Grinaker Date: Tue, 25 Aug 2020 11:23:16 +0200 Subject: [PATCH] types: comment on need for length prefixing (#5283) Fixes #5276. --- types/proposal.go | 6 ++++-- types/vote.go | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/types/proposal.go b/types/proposal.go index f714de309..20f9e5fbe 100644 --- a/types/proposal.go +++ b/types/proposal.go @@ -100,9 +100,11 @@ func (p *Proposal) String() string { } // ProposalSignBytes returns the proto-encoding of the canonicalized Proposal, -// for signing. +// for signing. Panics if the marshaling fails. // -// Panics if the marshaling fails. +// The encoded Protobuf message is varint length-prefixed (using MarshalDelimited) +// for backwards-compatibility with the Amino encoding, due to e.g. hardware +// devices that rely on this encoding. // // See CanonicalizeProposal func ProposalSignBytes(chainID string, p *tmproto.Proposal) []byte { diff --git a/types/vote.go b/types/vote.go index aff0b1730..177eb23a7 100644 --- a/types/vote.go +++ b/types/vote.go @@ -85,9 +85,11 @@ func (vote *Vote) CommitSig() CommitSig { } // VoteSignBytes returns the proto-encoding of the canonicalized Vote, for -// signing. +// signing. Panics is the marshaling fails. // -// Panics if the marshaling fails. +// The encoded Protobuf message is varint length-prefixed (using MarshalDelimited) +// for backwards-compatibility with the Amino encoding, due to e.g. hardware +// devices that rely on this encoding. // // See CanonicalizeVote func VoteSignBytes(chainID string, vote *tmproto.Vote) []byte {