forked from ChainAgnostic/CAIPs
-
Notifications
You must be signed in to change notification settings - Fork 2
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
DRAFT: add caip ipld log #2
Open
zachferland
wants to merge
1
commit into
master
Choose a base branch
from
CAIPs/caip-ipld_log
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,105 @@ | ||||||||||||||||||||||||||||||||||||||||||||||
--- | ||||||||||||||||||||||||||||||||||||||||||||||
caip: <to be assigned> | ||||||||||||||||||||||||||||||||||||||||||||||
title: Authenticated IPLD Append-Only Log | ||||||||||||||||||||||||||||||||||||||||||||||
author: Zach Ferland <@zachferland>, Joel Thorstensson (@oed) | ||||||||||||||||||||||||||||||||||||||||||||||
discussions-to: <> | ||||||||||||||||||||||||||||||||||||||||||||||
status: Draft | ||||||||||||||||||||||||||||||||||||||||||||||
type: Standard | ||||||||||||||||||||||||||||||||||||||||||||||
created: 2022-11-10 | ||||||||||||||||||||||||||||||||||||||||||||||
updated: 2022-11-10 | ||||||||||||||||||||||||||||||||||||||||||||||
requires: <> | ||||||||||||||||||||||||||||||||||||||||||||||
--- | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
## Simple Summary | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
Authenticated IPLD Append-Only Logs provide the best of IPLD and an authenticated immutable underlying log with the ability to model mutable databases and data structures on top. | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
## Abstract | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
This specification combines IPLD and DagJWS (with optional use of CAIP-X DagJWS CACAO), with a minimal log based data structure. A log based data structure being a simple to define subset of a general IPLD DAG. | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
## Motivation | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
Append-only logs are a frequently used underlying immutable data structure in distributed systems to improve data integrity, consistency, performance, history, etc. Open distributed systems use hash linked lists/logs, to allow others to verify the integrity of any data. IPLD is a natural way to define an immutable append-only log. Combined with DagJWS and "CAIP-X DagJWS CACAO" it allows authenticated writes to these logs using blockchain accounts. Providing a common data base layer for users and applications besides more expensive on-chain data or centralized and siloed databases. | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
A minimally defined log structure allows a base level of interoperability while allowing diverse implementations of mutable databases and data structures on top. Base levels of interoperability could include log transport, update syncing, consensus, etc. | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
## Specification | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
Logs are made up of events. A genesis event being the origination of a new log and typically used to reference or name a log. Every additional “update” appended is a data event. This specification provides minimal definition of an IPLD log, parameters in both the headers and body can be added by specific implementations or protocols. Formats and types are described using [IPLD schema language](https://ipld.io/docs/schemas/). | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
Being a CAIP, with the optional use of "CAIP-X DagJWS CACAO", keys and references to signers are expected to be did:pkh or DIDs. General specifications would not necessarily rely on did:pkh or DIDs. | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
All events are DAGJWS payloads encoded in IPLD using the [DAG-JOSE codec](https://ipld.io/specs/codecs/dag-jose/spec/). | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
### Genesis Event | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
A log is initialized with a genesis event. The CID of this event can be used to reference or name this log. | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
```tsx | ||||||||||||||||||||||||||||||||||||||||||||||
type GenesisHeader struct { | ||||||||||||||||||||||||||||||||||||||||||||||
controllers [String] | ||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||
type GenesisEvent struct { | ||||||||||||||||||||||||||||||||||||||||||||||
header GenesisHeader | ||||||||||||||||||||||||||||||||||||||||||||||
data Any | &Any | ||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||
``` | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
Parameters defined as follows: | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
- `controllers` - an array of DID strings that defines which DIDs can write events to the log, when using CACAO, the did is expected to be the issuer of the CACAO | ||||||||||||||||||||||||||||||||||||||||||||||
- `data` - data is can be any type or a CID (Link) to data of any type | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
### Data Event | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
Log updates are data events. Data events are appended in the log to a genesis event or prior data events. | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
```tsx | ||||||||||||||||||||||||||||||||||||||||||||||
type DataHeader struct { | ||||||||||||||||||||||||||||||||||||||||||||||
controllers optional [String] | ||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
type DataEvent struct { | ||||||||||||||||||||||||||||||||||||||||||||||
id Link | ||||||||||||||||||||||||||||||||||||||||||||||
prev Link | ||||||||||||||||||||||||||||||||||||||||||||||
header optional DataHeader | ||||||||||||||||||||||||||||||||||||||||||||||
data Any | &Any | ||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+59
to
+68
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||
``` | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
Additional parameters defined as follows, controllers and data defined same as above. | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
- `id` - CID (Link) to the genesis event of the log | ||||||||||||||||||||||||||||||||||||||||||||||
- `prev` - CID (Link) to prior event in log | ||||||||||||||||||||||||||||||||||||||||||||||
- `header` - Optional header, included here only if changing header parameter value (controllers) from prior event. Other header values may be included outside this specification. | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
### Log Verification | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
A valid log is one that includes data events as defined above and traversing the log resolves to an originating genesis event as defined above. Each event is valid when it includes the required parameters above and the DAGJWS signature is valid for the given event `controller` did or valid as defined by "CAIP-X DagJWS CACAO". There will likely be additional verification steps specific to any protocol or implementation. | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
### Log Syncing | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
Logs are named or reference using their genesis events, but you need the latest data event to sync the entire log and resolve the path in IPLD from “latest” event to genesis event. The “latest” event can be reference as the log “tip”. The “latest” or tip selection and sharing is left up to any higher level specification or protocol, as this mostly deals with the data structure. Logs can have multiple tips when there is forks in the log, “tip” selection becomes a consensus problem, to be determined by specific protocols or implementations building on this specification. | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
### Log Extensions | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
This being a minimally define log on IPLD, later specifications or protocols can add additional parameters to both genesis and data events and their headers as needed. For example "CAIP-X IPLD Timestamp Proof" can be added as a data event to add time stamping to logs. | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
```tsx | ||||||||||||||||||||||||||||||||||||||||||||||
type AnchorDataEvent struct { | ||||||||||||||||||||||||||||||||||||||||||||||
id Link | ||||||||||||||||||||||||||||||||||||||||||||||
prev Link | ||||||||||||||||||||||||||||||||||||||||||||||
header optional DataHeader | ||||||||||||||||||||||||||||||||||||||||||||||
proof Link | ||||||||||||||||||||||||||||||||||||||||||||||
path String | ||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||
``` | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
## Links | ||||||||||||||||||||||||||||||||||||||||||||||
- [IPLD](https://ipld.io/) | ||||||||||||||||||||||||||||||||||||||||||||||
- [IPLD schema language](https://ipld.io/docs/schemas/) | ||||||||||||||||||||||||||||||||||||||||||||||
- [dag-jose](https://ipld.io/specs/codecs/dag-jose/spec/) | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
## Copyright | ||||||||||||||||||||||||||||||||||||||||||||||
Copyright and related rights waived via [CC0](https://creativecommons.org/publicdomain/zero/1.0/). |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure how to define ANY or CID of ANY in ipld schema language
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.