-
-
Notifications
You must be signed in to change notification settings - Fork 55
Backward compatibility of the Log #211
Comments
I'll kick off the discussion with a proposal that we use a monotonically increasing This has the benefit of freeing the entry versions from having to be in lock-step with the package version, and gives us all the added benefit of being able to join logs of different versions. If possible, best to leave the old entries where they are instead of recreating/duplicating them in a migration. Entries without identities: leave as public? |
Lots of great thoughts here, thank you @vvp and @aphelionz!
Agreed. We have this as
Old versions also have a signature, under
This is very true. I don't think we can "migrate" the logs in a way that the actual entries will be converted to the new structure due to the signatures in each entry. Which, I believe, leaves us with the second option of supporting multiple versions. However, as you say @vvp, this can make the code quite complex and highly error-prone, so it seems to me that the question is: Do we want to or need to support multiple versions? If not, what are the consequences to users? If yes, what are the consequences to development and for maintainers (eg. do we commit to support all versions of logs from today all the way to the far future)? Is there a way we could provide migration tools in a way that the end-user initiates and authorizes the migration (ie. they re-sign all converted/transformed entries) instead of developers building on/with orbitdb? |
I've been thinking about the same thing but in https://github.com/peer-base/peer-base land and this is the way to go. There's always the latest canonical version of the data-structure and we must convert old versions to the canonical version when reading. This means we must tag those data structures with the versions and have code to migrate to the latest version incrementally. Also, I would think that embracing conventional commits would improve the visibility of changes to developers. Many projects in the IPFS land already use them. You may check how to quickly setup the necessary tooling on some repos, for instance, this one. Basically:
|
I made a comment in @satazor 's PR that begins to address this: https://github.com/orbitdb/ipfs-log/pull/213/files#r244635479 Reading back through these comments, I believe we should increment the version number |
I would like to make a more formal proposal based on the discussion we had on #213. Data-structuresIt's normal for the data-structures of All the code that interacts with those data-structures should always assume that they are in the latest version. This makes it easy to reason about the code because there's only one shape of the data-structures: the most recent one. Instead of doing this in an ad-hoc manner, we should come up with a scheme that would allow us to transform those data-structures from older to newer versions and vice-versa. These are the scenarios to take into consideration:
Having that said, I propose to tag all the data-structures with a const schema = [
versions: [
{
version: 0,
up(data) {},
down(data) {},
codec: { name: 'dag-pb-v0' }
},
{
version: 1,
up(data) {},
down(data) {},
codec: { name: 'dag-cbor', ipldLinks: ['next'] }
},
// more in the future...
],
codecs: {
'dab-pb-v0': {
matches(cid, dagNode) {}
fromDagNode(dagNode) {},
toDagNode(data, ipldLinks) {}
},
'dag-cbor': {
matches(cid, dagNode) {}
fromDagNode(dagNode) {},
toDagNode(data, ipldLinks) {}
},
// more in the future...
},
] ...where:
A versioning pipeline based on the schema, would have the following API:
|
As OrbitDB version 0.20.0 (orbitdb/orbitdb#524) is getting nearer and work on IPLD support (#200) has started, it would be a good time to discuss about the backward compatibility of the log. Currently there is not much:
v
-field but it cannot be used to differentiate between incompatible versions because it's currently always 0.For example, in next release there's a new
identity
field in entry-structures. Current version expects it to be there when entries are loaded from IPFS, and access-controller will actually fail if there's noidentity
information in entries to append. All the log entries created with previous versions will not have this information. Fortunately, this check is done only on new items appended/joined into log, so appending new entries to old logs will still work after version upgrade.Some design aspects that I see:
LogIO.fromMultihash()
), whereas versioning the entries too would allow joining logs with different versions together and be more flexible in backward compatibility. Single-version log would probably need to have an internal version-specificlogId
which would then have consequences on entries' log references too.Any thoughts, opinions? 🙂
The text was updated successfully, but these errors were encountered: