encode_data should check if a field is optional, and if it is, if the value is set to the default as described by the schema. If these conditions hold, the field does not need to be serialized, as the schema already defines its value on decoding.
https://developers.google.com/protocol-buffers/docs/proto?hl=en#optional