-
Notifications
You must be signed in to change notification settings - Fork 10
Support unknown fields #456
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
As mentioned off-line previously, PBJ deliberately didn't implement support for unknown fields as a performance optimization, so as to avoid allocating objects (e.g. maps, byte arrays, and similar) to keep this information in the models. However, as long as this feature is optional, then PBJ could support unknown fields. For example, it could be enabled via an additional
In the generated model implementation, we'd add a private field of type
The model's Finally, the codec's However, it's unclear whether applications need to have access to the unknown fields data. Since they are unknown to the application, it's clear that the application is using a .proto model that differs from the model which was used to serialize the original object. Therefore, with the exception of a few edge cases, the application wouldn't be able to meaningfully interpret the unknown fields. Could you please confirm if access to the unknown fields is necessary at the model public API level, and if so, please clarify the use case? |
Yes, as already stated, the mirror node uses the data from the unknown fields. It is a requirement that mirror node not fail if it encounters a transaction type that it doesn't understand. But we still want to store generic transaction info so we extract the transaction type ordinal from the protobuf. We also extract the signature type and bytes for newly added signatures we're unaware of. And it's used in various tests. Here's a link to those areas: https://github.com/search?q=repo%3Ahiero-ledger%2Fhiero-mirror-node%20unknownfields&type=code I might also suggest that the parse method is getting a bit unwieldy with the addition of more overloaded params. We might want to add an options class so it is future compatible with any new option. For example, |
I agree that an API with an Thanks for elaborating on your use-case. That makes sense. Would an access to an unmodifiable |
Yes, that works for us. Thanks for looking into this. |
@steven-sheehy : The fix is out for review at #471 The only notable change from what we've discussed above is the
You can see that |
Problem
The mirror node needs to be both backwards and future compatible with all versions of the record and block stream protobufs. If any field is removed, we still need to parse historical versions of it. If any new transaction type is added but we have not updated the protobuf version to add support, we still store generic transaction info without failing.
Solution
Add optional support for unknown fields when using
parse()
. In protoc, this takes the form ofMap<Integer, Field> fields
.parseStrict()
should remain unchanged and throw an error if unknown fields are present.Alternatives
No response
The text was updated successfully, but these errors were encountered: