Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions CIPs/cip-124.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,14 @@ An eventId is a special type of [StreamId](https://cips.ceramic.network/CIPs/cip

```js
concatBytes(
varint(0xce), // streamid varint
varint(0x05), // cip-124 EventID varint
varint(network_id), // network_id varint
last8bytes(sha256(sort_value)), // separator [u8; 8]
varint(0xce), // streamid varint b'\xce\x01'
varint(0x05), // cip-124 EventID varint b'\x05'
varint(network_id), // network_id varint 1 or 5 bytes
last8Bytes(sha256(separator_key + "|" + separator_value)), // separator [u8; 8]
context_value // [u8; 8]
cbor(blockNumber), // 0 - u64_max; 1-9 bytes
last8bytes(sha256(controller)), // controller [u8; 8]
last4bytes(init_event_cid_bytes), // StreamID [u8; 4]
cbor(event_height), // event_height cbor unsigned int
event_cid_bytes, // [u8]
)
```
Expand All @@ -63,10 +64,15 @@ Where:
* `0xce` is the streamid multicode as defined in the [multicodec table](https://github.com/multiformats/multicodec/blob/master/table.csv).
* `0x05` is the streamtype code for an cip-124 EventID as defined in the [streamTypes table](../tables/streamtypes.csv).
* `network_id` is a number as defined in the [networkIds table](../tables/networkIds.csv)
* `sort_value` is based on a user provided value for *sort-key* and *sort-value*
* `separator_key` is the header field that has the separator_value in it.
* `separator_value` is the value in the field specified by the separator_key
* `context_key` is the header field that has the context_value in it.
* `context_value` is the first 8 bytes of the value in the field specified by the context_key.
* `blockNumber` is the ETH blockNumber from the after header or a prev time event.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"after header" isn't really defined yet (CIP is pending) does it make sense to mention it here? Maybe we need to merge the after CIP before this PR?

* If the after header is not present then follow the prev cain to a time event.
* If there is no time event in the chain then use 0
Comment on lines +71 to +73
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use block_timestamp instead of blockNumber? This would give us flexibility in the future if we wanted to support other ways than ethereum blocks as a source of truth for this value.

* `controller` is the controller DID of the stream this event belongs to
* `init_event_cid_bytes` is the CID of the first Event of the this stream.
* `event_height` is the "height" of the event InitEvent. For InitEvents this value is `0` else `prev.event_height + 1`.
Comment on lines 75 to -69
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that we are removing event_height, is init_event_cid_bytes still relevant? Seems like this would sort multiple events from the same stream next to each other given that they happen at the same ethereum block. There would be no specific logic to the order between these events though.
Seems to me that having the InitEvent hash here adds marginal value given that we sort by controller before that?

* `event_cid_bytes` the CID of the event itself
* `last8bytes` and `last4bytes` takes the last N bytes of the input and prepends with zeros if the input is shorter

Expand Down