research/remote_log/remote_log_spec.md

151 lines
3.0 KiB
Markdown
Raw Normal View History

2019-09-06 09:54:39 +00:00
# Remote log specification
2019-09-24 05:03:20 +00:00
> Version: 0.0.3 (Draft)
2019-09-04 12:45:11 +00:00
>
> Authors: Oskar Thorén oskar@status.im, Dean Eigenmann dean@status.im
## Table of Contents
2019-09-24 04:51:20 +00:00
- [Abstract](#abstract)
- [Definitions](#definitions)
- [Roles](#roles)
- [Wire Protocol](#wire-protocol)
2019-09-24 05:03:20 +00:00
- [Secure Transport, Storage, and Name System](#secure-transport-storage-and-name-system)
2019-09-24 04:51:20 +00:00
- [Payloads](#payloads)
- [Flow](#flow)
- [Footnotes](#footnotes)
- [Acknowledgements](#acknowledgements)
2019-09-04 12:45:11 +00:00
## Abstract
2019-09-21 06:13:39 +00:00
A remote log is a replication of a local log. This means a node can read data
from a node that is offline.
2019-09-06 09:54:39 +00:00
2019-09-04 12:45:11 +00:00
## Definitions
2019-09-21 07:17:16 +00:00
| Term | Definition |
| ----------- | -------------------------------------------------------------------------------------- |
| CAS | Content-addressed storage. Stores data that can be addressed by its hash. |
| Name system | Name system. Associates mutable data to a name. |
| Remote log | Replication of a local log at a different location. |
2019-09-06 09:54:39 +00:00
2019-09-04 12:45:11 +00:00
## Roles
1. Node
2. Name system (NS)
3. Content-addressed storage (CAS)
2019-09-06 09:54:39 +00:00
## Wire Protocol
2019-09-24 05:03:20 +00:00
### Secure Transport, Storage, and Name System
This specification does not define anything related to to: secure transport,
content addressed storage, or the Name System. It is assumed these capabilities
are abstracted away in such a way that any such protocol can easily be
implemented.
<!-- TODO: Elaborate on properties required here. -->
2019-09-06 09:54:39 +00:00
### Payloads
2019-09-24 05:03:20 +00:00
Payloads are implemented using [protocol buffers v3](https://developers.google.com/protocol-buffers/).
**CAS service**:
2019-09-06 09:54:39 +00:00
```protobuf
package vac.cas;
service CAS {
rpc Add(Content) returns (Address) {}
rpc Get(Address) returns (Content) {}
}
message Address {
bytes id = 1;
}
message Content {
bytes data = 1;
}
```
2019-09-24 05:03:20 +00:00
**NS service**:
2019-09-06 09:54:39 +00:00
```protobuf
service NS {
rpc Update(NameUpdate) returns (Response) {}
rpc Fetch(Query) returns (Content) {}
}
message NameUpdate {
string name = 1;
bytes content = 2;
}
message Query {
string name = 1;
}
message Content {
bytes data = 1;
}
message Response {
bytes data = 1;
}
```
2019-09-24 05:03:20 +00:00
<!-- XXX: Response and data type a bit weird, Ok/Err enum? -->
<!-- TODO: Do we want NameInit here? -->
2019-09-06 09:54:39 +00:00
2019-09-24 05:03:20 +00:00
**Remote log:**
2019-09-21 07:17:16 +00:00
2019-09-06 09:54:39 +00:00
```protobuf
message RemoteLog {
Body body = 1;
bytes tail = 2;
message Body {
repeated Pair pair = 1;
}
message Pair {
bytes remoteHash = 1;
bytes localHash = 2;
}
}
```
2019-09-24 05:03:20 +00:00
<!-- TODO: Extend pair with (optional) data -->
2019-09-04 12:45:11 +00:00
## Flow
2019-09-06 09:54:39 +00:00
<!-- This section is only here for research right now, might move or be unnecessary -->
<!-- Wil likely be replaced with similar flow to one in MVDS.spec -->
```mermaid
sequenceDiagram
Alice->>CAS: Add content
CAS->>Alice: Address
Alice->>NS: Update NameUpdate
NS->>Alice: Response
Bob->>NS: Fetch
NS->>Bob: Content
Bob->>CAS: Fetch Query
CAS->>Bob: Content
```
<!--
2019-09-04 12:45:11 +00:00
## Footnotes
2019-09-06 09:54:39 +00:00
TBD.
2019-09-04 12:45:11 +00:00
## Acknowledgements
2019-09-06 09:54:39 +00:00
TBD.