On Protocol Buffers and determinism #8
Replies: 3 comments
-
IMO the most realistic and friction-less approach to solve this (possible) issue is by following a set of rules for defining the protobuf models similar to the Cosmo's one https://docs.cosmos.network/master/architecture/adr-027-deterministic-protobuf-serialization.html Right now the most affected Protobud spec (which needs to be compatible across different programing language implementations) is this https://github.com/vocdoni/dvote-protobuf/blob/master/src/common/vote.proto So a first step would be to make our own Cosmos-like canonical guide and to apply it in the vote.proto model. |
Beta Was this translation helpful? Give feedback.
-
cc: @mvdan Discussion regarding proto & determinism on serialisation is centralized here. |
Beta Was this translation helpful? Give feedback.
-
This issue was handled by adding a new extra protobuf The new protobuf message is named "SignedTX": https://github.com/vocdoni/dvote-protobuf/blob/master/src/vochain/vochain.proto#L34 |
Beta Was this translation helpful? Give feedback.
-
Define a set of rules for deterministic Protobuf serialisation:
From the official Google Protobuf docs
From the release note of Protobuf 3.0.0
From the opencontainers.com Google group
The following checks may fail for a protocol buffer message instance
The problem is not only cross-language, but it may affect a single library too. There is no guarantee that the same library will consistently implement a deterministic encoding over time.
The indeterminism is caused by:
Examples where determinism is not guaranteed:
Encoding fields in different order than the tag number order.
Encoding packed fields as unpacked.
Encoding integers as longer varint byte sequences than needed.
Encoding same (non-repeated) field multiple times.
Proposed solutions by other projects
Proposed solution by Cosmos
Proposed solution Regen Network
Protocol labs
Beta Was this translation helpful? Give feedback.
All reactions