-
Notifications
You must be signed in to change notification settings - Fork 293
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
State exports can be deserialized in multiple ways #1547
Labels
Milestone
Comments
It seems it was a really bad choice to put a map in the Pin protobuf, as per https://developers.google.com/protocol-buffers/docs/proto3#maps there is no guarantees on wire order or anything. Thinking on approaches around this, which might involve deprecation of the protobuf field and using an array instead. |
hsanjuan
added a commit
that referenced
this issue
May 5, 2022
This deprecates the Metadata protobuf map and starts serializing metadata as an array that is always sorted by the metadata key. This should resolve the issue that an state export file can be imported resulting in two different CRDT dags because the binary representation of the pin can arbitrarily change depending on how the keys in the map are listed, and thus the CID of a delta is impacted. So with this, a state export should result in exactly the same DAG regardless of where it is imported.
hsanjuan
added a commit
that referenced
this issue
May 5, 2022
This deprecates the Metadata protobuf map and starts serializing metadata as an array that is always sorted by the metadata key. This should resolve the issue that an state export file can be imported resulting in two different CRDT dags because the binary representation of the pin can arbitrarily change depending on how the keys in the map are listed, and thus the CID of a delta is impacted. So with this, a state export should result in exactly the same DAG regardless of where it is imported.
hsanjuan
added a commit
that referenced
this issue
May 5, 2022
Fix #1547: Store pin metadata in a sorted array
hsanjuan
added a commit
that referenced
this issue
Jun 16, 2022
This deprecates the Metadata protobuf map and starts serializing metadata as an array that is always sorted by the metadata key. This should resolve the issue that an state export file can be imported resulting in two different CRDT dags because the binary representation of the pin can arbitrarily change depending on how the keys in the map are listed, and thus the CID of a delta is impacted. So with this, a state export should result in exactly the same DAG regardless of where it is imported.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
A state export file contain pins. Each pin object may potentially have a user-defined metadata map.
These maps can potentially be serialized in any order. When the pin is stored as part of a delta, the binary representation of it may differ randomnly. This causes the created CRDT deltas to have different CIDs.
This means that multiple peers do not obtain a consistent state when the same state file is imported.
The serialization of a Pin to protobuf should be reproducible and only occur in one way for equivalent pin objects.
The text was updated successfully, but these errors were encountered: