fix: repeated fields are packed in proto3 #2509
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
As described here vacp2p/nim-libp2p#1035 proto3 repeated fields are packed by default, so with this PR we use
writePacked
andgetPackedRepeatedField
instead ofwrite3
andgetRepeatedField
.However, this would mean that once a release is done, nodes using the previous version would not be compatible with the newer release, which can be problematic.
@jm-clius, @alrevuelta, what would be the recommended approach here?
Some possibilities that come to mind are the following:
[packed=false]
so it behaves like nwaku, and then just close this PR. This would be the 'easy' solution, and would require some coordination so when infra deploys a release with version >= 0.25.0, all contributors also update their desktop version to something that uses this protobuffer:Neither the first nor the second option seem ideal because the impact they have and also because they modify an existing field in a protobuffer, and this seems to not be the recommended approach?
Then in nwaku code we'd use
getPackedRepeatedField
on field 3, and if it's not populated, usegetPackedRepeatedField
on field2, and if it's empty, usegetRepeatedField
. This would solve the problem of nwaku not understanding go-waku's packed field. For writing, we'd still usewrite3
for field 2 andwritePacked
for field3.Currently go-waku does not care about the format of the field for reading data since it seems to try decoding both packed and unpacked data. I think this is the cleanest option