Replies: 2 comments
-
@brickpop might have thoughts :) I generally agree that public-facing API types should be separate. Right now they leak into many places where they shouldn't. That said, I think this might be easier said than done: we interface with a bunch of different pieces at the data layer (database, vochain, APIs), and it's likely they won't all share the same types. So we might end up with one internal type, and 2+ external-facing types. We should be careful about unnecessary duplication. |
Beta Was this translation helpful? Give feedback.
-
I agree with the thoughts exposed by @mvdan. Indeed, the protocol v2 proposal revolves around the idea that the Transport data models have their own definition, tightly aligned with the definition of the data that we are wrapping, signing, bundling, etc. Then, any components participating in the network, adapt to them, and not the other way around.
I totally agree that the api/rpc layer would have its own adapters to transform the incoming data into structs that the Domain layer of the Vochain can handle without dependencies (Clean code phylosophy main points). This doesn't prevent the Vochain from using its own protobuf serialization if deemed necessary, but the way things are handled internally shouldn't be leaking elsewhere, other than the Vochain itself. To the benefits exposed by @arnaucube I would add that having a transport-level protobuf model:
I would like to write an outline of the proto v2 proposal's main points, which align very much with your view, Arnau. I also think that this is a change that would be rolled out incrementally. Deprecating certain of the current API's as soon as the Transport RPC models become available on |
Beta Was this translation helpful? Give feedback.
-
Proposal on internal & external data in vocdoni-node
Proposal that affects the vocdoni-node internals. This is an initial draft of the proposal, to start conversations regarding this topic and find a consensus for future iterations of the vocdoni-node.
Main idea
Current status is that vocdoni-node uses protobuf data structures both for external data transport and for internal logic of the node.
The main idea of this proposal is that internal structs should not need to be the same than the ones used for data transport. This means to use protobuf only for data transport and not for internal logic of the vocdoni-node.
So, protobuf data structs would be only used in the 'api/rpc layer' when processing the incoming data and when sending data outside, but from 'doors inside' the vocdoni-node would use its own defined internal structs.
As a 'rule of thumb', think of protobuf being an efficient replacement for json data packets, but internally in the node the jsons are converted into own internal structs, so the same would happen with the protobuf structs, they would be converted into internal structs of the node.
Additionally, protobuf structs could be used also to encode into bytes the data structs that are stored into key-value database.
Example of this approach used in Tendermint:
Reasoning
Having a thin layer between the external-protobuf-structs and the internal-structs, has multiple benefits:
external-protobuf-struct
intointernal-struct
internal-struct
toexternal-protobuf-struct
and viceversa, so when integration flows are done nobody needs to spent time debugging which struct is giving problemsBeta Was this translation helpful? Give feedback.
All reactions