Skip to content

First version (ABCI only ATM) of documenting protobuf version translation#780

Closed
sergio-mena wants to merge 2 commits intofeature/proto-upgradefrom
sergio/proto-version-translation-abci
Closed

First version (ABCI only ATM) of documenting protobuf version translation#780
sergio-mena wants to merge 2 commits intofeature/proto-upgradefrom
sergio/proto-version-translation-abci

Conversation

@sergio-mena
Copy link
Collaborator

@sergio-mena sergio-mena commented May 1, 2023

Contributes to #95

This is my first attempt at documenting:

  • whether it makes sense to interpret a protobuf message from the previous version
  • if it does make sense, how to translate the data found in the previous version into the current one

... and the same for interpreting a protobuf message from the current version while in the previous version.

This should be helpful for integrators that, e.g., need to work with two versions at the same time. They could take advantage of these annotations in order to construct domain types that would support the required versions of the protos.

I kind of invented some keywords along the way, with the intention of keeping the text concise. Those keywords should be self-explanatory. Let me know if that's not the case, and I'll add some explanations in the README.

Feedback is more than welcome. I have only done ABCI since I'd like to gather feedback to then proceed with the rest of the proto files.


PR checklist

  • Tests written/updated
  • Changelog entry added in .changelog (we use unclog to manage our changelog)
  • Updated relevant documentation (docs/ or spec/) and code comments

@sergio-mena sergio-mena requested a review from a team as a code owner May 1, 2023 19:14
@sergio-mena sergio-mena self-assigned this May 1, 2023
@sergio-mena sergio-mena mentioned this pull request May 1, 2023
4 tasks
@sergio-mena sergio-mena changed the title First versoin on documenting protobuf version translation First versoin (ABCI only) on documenting protobuf version translation May 1, 2023
@sergio-mena sergio-mena changed the title First versoin (ABCI only) on documenting protobuf version translation First version (ABCI only ATM) on documenting protobuf version translation May 1, 2023
@sergio-mena sergio-mena changed the title First version (ABCI only ATM) on documenting protobuf version translation First version (ABCI only ATM) of documenting protobuf version translation May 1, 2023
//----------------------------------------
// Request types

// Handling v1 as v2: REJECT
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to clarify, does this mean that, if we receive v1.Request, but we're expecting v2.Request, we reject it?

Copy link
Collaborator Author

@sergio-mena sergio-mena May 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exactly.
And "reject" means:

  • either "it doesn't make sense" (this is the case here)
  • or it is an error condition

Let me know if you think it is worth distinguishing between REJECT and ERROR (I'm not doing it ATM)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, so my intuition was correct. And I think "REJECT" is fine. Thanks!

Copy link
Contributor

@thanethomson thanethomson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd be interested to know what @mzabaluev thinks of this convention.

@mzabaluev
Copy link
Contributor

mzabaluev commented May 3, 2023

I think we need to build more understanding as to what these different versions exactly mean in terms of protocol messages on the wire and language bindings. In general, assuming backward-compatible definitions, there is no way to distinguish which version the sender used to encode the message. The only way it could be feasible is to detect when new fields are present (meaning that the sender's definition is newer than that used by the recipient), or when reserved fields used in older versions are present (meaning that the sender used an older definition).

But by design of most protobuf stacks, it's not possible to deduce this information in the bindings that receive decoded messages; furthermore, it's discouraged by the general idea of evolving protobuf protocols. Unless you use some message metadata/reflection capabilities (not available in Rust/prost), you get no idea if the sender used a different version to encode since the unknown and reserved fields are ignored by the decoder, and the newly added enum variants are mapped to the zero value.

Copy link
Contributor

@mzabaluev mzabaluev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In light of the above comment, I don't think most of this information is applicable in practice. The compatibility comments should be limited to handling situations when a field added in a newer version of the message is missing or set to the zero value (these conditions are not expected to be practically distinguishable by the proto consumer), possibly meaning that the sender used an older version to encode.

@sergio-mena
Copy link
Collaborator Author

@mzabaluev I mostly agree with your reasoning, however your reasoning is focusing on marshalling/unmarshalling of protobufs. This PR is not really about that, but rather domain knowledge a developer needs if they are not expert in those protobufs. For instance, it would help someone writing code that handles more than one version at once.

I believe that's precisely what you're doing in cometbft/tendermint-rs#1312. Further, these lines contain the information you had to ask over Slack a few days ago (and rightly so, because the info was missing).

My impression is that the word "handle" used in the text added in this PR is somewhat misleading. Maybe:

  • instead of "Handling v1 as v2"
  • it should read "Translating v1 into v2" ?

I guess it's best if we discuss this synchronously.

@mzabaluev
Copy link
Contributor

Yes, the added comments should perhaps provide a migration guide between versions, in cases when just following the usual protobuf rules is not enough (if you can make it good by just filling the newly added fields with zero values, no additional information is needed). In the present form, it's not clear to me how the application developer should make use of the provided rules.

@mzabaluev
Copy link
Contributor

mzabaluev commented May 4, 2023

In the specific case of ABCI, the application should be instructed to handle Request as per the expected version.
With the changed API and semantics, applications built for 0.37 cannot be expected to work correctly with a 0.38 node and vice versa, correct?

@sergio-mena
Copy link
Collaborator Author

sergio-mena commented May 4, 2023

With the changed API and semantics, applications built for 0.37 cannot be expected to work correctly with a 0.38 node and vice versa, correct?

Exactly. That's what all the REJECTs I wrote for those mean... the REJECT means "don't even try to mix up versions of these messages".

But there's more: the example I gave you is missing info without this PR. Also, some messages were renamed, and without this PR, it is not obvious for someone examining the various versions for ABCI protobufs.

//----------------------------------------
// Blockchain Types

// Handling v1 as v3: ACCEPT
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Differences from v1 to v3



// Handling v1 as v2: ACCEPT
// SET abci_version:v2 TO "<NOT PROVIDED>"
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// SET abci_version:v2 TO "<NOT PROVIDED>"
// follow normal protobuf rules

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(from discussionwith @mzabaluev): Consider removing this, as this is considered as the default (so only document the "REJECT"s as counter-intuitive

// Misc.

// v1 type: LastCommitInfo
// Handling v1 as v2: ACCEPT
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A lonely "ACCEPT"

  • not only means the two types are identical
  • it should also means (for messages that are not identical) that normal protobuf rules should be followed

string abci_version = 4;
}

// Handling v1 as v2: REJECT
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Handling v1 as v2: REJECT
// Handling v1 as v2: REJECT -- [explain why]

everywhere

@github-actions
Copy link

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the stale For use by stalebot label May 16, 2023
@sergio-mena sergio-mena removed the stale For use by stalebot label May 16, 2023
@github-actions
Copy link

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the stale For use by stalebot label May 27, 2023
@github-actions github-actions bot closed this Jun 1, 2023
@lasarojc lasarojc reopened this Jun 1, 2023
@lasarojc lasarojc removed the stale For use by stalebot label Jun 1, 2023
@lasarojc lasarojc added the wip Work in progress label Jun 1, 2023
@sergio-mena
Copy link
Collaborator Author

We decided not to pursue this approach

@sergio-mena sergio-mena deleted the sergio/proto-version-translation-abci branch September 6, 2024 19:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

wip Work in progress

Projects

No open projects
Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants