Proper dealing with protobuf3 decoding #1043
Labels
A: question
Admin: further information is requested
I: dependencies
Internal: related to dependencies
Milestone
Crate
ibc
Summary
Protobuf3 has the unfortunate semantics of allowing all fields to be optional, and leaves no way to mark a field as being required. (protocolbuffers/protobuf#2497) The
prost
crate follows this semantic, and decodes missing fields into default values such as0
and""
. This can cause unintended bugs when the relayer logic expects a given field to be present. In particular, the semantics allow empty buffers to be decoded successfully, producing nonsense values such as in #1042.On Rust side, we want to use the
Option
type to properly denote the absence of values, and have proper distinction between values not being present and the default values. One strategy to deal with this is to mark all scalar fields in the raw prost structs as beingoptional
, so thatprost
will properly decode them intoOption
value when the field is not present in the raw buffer. The conversion from raw prost structs into the proper domain types should then return error when the required fields have value ofNone
.We may need to modify the
proto-compiler
crate so that it properly marks all scalar fields as being optional in the generated Rust code.Acceptance Criteria
All scalar fields of the raw prost structs in
proto/src/prost
should have theOption
type.For Admin Use
The text was updated successfully, but these errors were encountered: