mirror of https://github.com/vacp2p/rfc.git
13/14/16/21: Change in timestamp format (#483)
* Timestamps refactored to int64 (nanoseconds resolution). Related to https://github.com/status-im/nim-waku/issues/834 * Updated times to Timestamp type * Refactored timestamps * Made spec consistent with timestamp refactoring * Fixed misunderstanding on proto3 types * Fixed timestamps to sint64 * Fixed correct time to pb2 timestamps and Store protocol version changed to beta4 * Revert changes (not needed for now) * Revert changes We'll change to sint64 when we'll refactor chat2 to use Timestamp type for timestamps
This commit is contained in:
parent
f11d4988f3
commit
d88dc1261c
|
@ -89,7 +89,7 @@ Since Waku v2 is built on top of libp2p, many protocols have a libp2p protocol i
|
|||
The current main [protocol identifiers](https://docs.libp2p.io/concepts/protocols/) are:
|
||||
|
||||
1. `/vac/waku/relay/2.0.0`
|
||||
2. `/vac/waku/store/2.0.0-beta3`
|
||||
2. `/vac/waku/store/2.0.0-beta4`
|
||||
3. `/vac/waku/filter/2.0.0-beta1`
|
||||
4. `/vac/waku/lightpush/2.0.0-beta1`
|
||||
|
||||
|
@ -182,7 +182,7 @@ such as low bandwidth or being mostly offline.
|
|||
|
||||
#### Historical message support
|
||||
|
||||
**Protocol identifier***: `/vac/waku/store/2.0.0-beta3`
|
||||
**Protocol identifier***: `/vac/waku/store/2.0.0-beta4`
|
||||
|
||||
This is used to fetch historical messages for mostly offline devices.
|
||||
See [13/WAKU2-STORE](/spec/13) spec for more details.
|
||||
|
|
|
@ -13,7 +13,7 @@ contributors:
|
|||
This specification explains the Waku `13/WAKU2-STORE` protocol which enables querying of messages received through relay protocol and stored by other nodes.
|
||||
It also supports pagination for more efficient querying of historical messages.
|
||||
|
||||
**Protocol identifier***: `/vac/waku/store/2.0.0-beta3`
|
||||
**Protocol identifier***: `/vac/waku/store/2.0.0-beta4`
|
||||
|
||||
# Design Requirements
|
||||
Nodes willing to provide storage service using `13/WAKU2-STORE` protocol SHOULD provide a complete and full view of message history.
|
||||
|
@ -53,8 +53,8 @@ syntax = "proto3";
|
|||
|
||||
message Index {
|
||||
bytes digest = 1;
|
||||
double receiverTime = 2;
|
||||
double senderTime = 3;
|
||||
sint64 receiverTime = 2;
|
||||
sint64 senderTime = 3;
|
||||
}
|
||||
|
||||
message PagingInfo {
|
||||
|
@ -101,8 +101,8 @@ message HistoryRPC {
|
|||
To perform pagination, each `WakuMessage` stored at a node running the `13/WAKU2-STORE` protocol is associated with a unique `Index` that encapsulates the following parts.
|
||||
- `digest`: a sequence of bytes representing the SHA256 hash of a `WakuMessage`.
|
||||
The hash is computed over the concatenation of `contentTopic` and `payload` fields of a `WakuMessage` (see [14/WAKU2-MESSAGE](/spec/14)).
|
||||
- `receiverTime`: the UNIX time at which the waku message is received by the receiving node.
|
||||
- `senderTime`: the UNIX time at which the waku message is generated by its sender.
|
||||
- `receiverTime`: the UNIX time in nanoseconds at which the waku message is received by the receiving node.
|
||||
- `senderTime`: the UNIX time in nanoseconds at which the waku message is generated by its sender.
|
||||
|
||||
### PagingInfo
|
||||
|
||||
|
|
|
@ -35,8 +35,7 @@ The `version` field MAY be filled out to allow for various types of payload encr
|
|||
Omitting it means the version is 0.
|
||||
|
||||
The `timestamp` field MAY be filled out to signify the time at which the message is generated by its sender.
|
||||
This field holds the Unix epoch time in seconds.
|
||||
The fractional part represents the sub-seconds.
|
||||
This field holds the Unix epoch time in nanoseconds.
|
||||
Omitting it means the timestamp is unspecified.
|
||||
|
||||
## Payloads
|
||||
|
@ -50,7 +49,7 @@ message WakuMessage {
|
|||
bytes payload = 1;
|
||||
string contentTopic = 2;
|
||||
uint32 version = 3;
|
||||
double timestamp = 4;
|
||||
sint64 timestamp = 4;
|
||||
}
|
||||
```
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ Refer to [`Waku Message` specification](https://github.com/vacp2p/specs/blob/mas
|
|||
| `payload` | `String` | mandatory | The message payload as a hex encoded data string |
|
||||
| `contentTopic` | `String` | optional | Message content topic for optional content-based filtering |
|
||||
| `version` | `Number` | optional | Message version. Used to indicate type of payload encryption. Default version is 0 (no payload encryption). |
|
||||
| `timestamp` | `Number` | optional | The time at which the message is generated by its sender. This field holds the Unix epoch time in seconds as a 64-bits float value. The fractional part represents sub-seconds. |
|
||||
| `timestamp` | `Number` | optional | The time at which the message is generated by its sender. This field holds the Unix epoch time in nanoseconds as a 64-bits integer value. |
|
||||
|
||||
## Method naming
|
||||
|
||||
|
@ -107,7 +107,7 @@ The following structured types are defined for use on the Relay API:
|
|||
| ----: | :---: | :---: | ----------- |
|
||||
| `payload` | `String` | mandatory | The payload being relayed as a hex encoded data string |
|
||||
| `contentTopic` | `String` | optional | Message content topic for optional content-based filtering |
|
||||
| `timestamp` | `Number` | optional | The time at which the message is generated by its sender. This field holds the Unix epoch time in seconds as a 64-bits float value. The fractional part represents sub-seconds. |
|
||||
| `timestamp` | `Number` | optional | The time at which the message is generated by its sender. This field holds the Unix epoch time in nanoseconds as a 64-bits integer value. |
|
||||
|
||||
|
||||
> **_NOTE:_** `WakuRelayMessage` maps directly to a [`WakuMessage`](#WakuMessage), except that the latter contains an explicit message `version`. For `WakuRelay` purposes, the versioning is handled by the API.
|
||||
|
@ -204,7 +204,7 @@ The following structured types are defined for use on the Store API:
|
|||
| Field | Type | Inclusion | Description |
|
||||
| ----: | :---: | :---: |----------- |
|
||||
| `digest` | `String` | mandatory | A hash for the message at this [`Index`](#Index) |
|
||||
| `receivedTime` | `Number` | mandatory | UNIX timestamp at which the message at this [`Index`](#Index) was received |
|
||||
| `receivedTime` | `Number` | mandatory | UNIX timestamp in nanoseconds at which the message at this [`Index`](#Index) was received |
|
||||
|
||||
#### ContentFilter
|
||||
|
||||
|
@ -224,8 +224,8 @@ The `get_waku_v2_store_v1_messages` method retrieves historical messages on spec
|
|||
| ----: | :---: | :---: |----------- |
|
||||
| `pubsubTopic` | `String` | optional | The pubsub topic on which a [`WakuMessage`](#WakuMessage) is published |
|
||||
| `contentFilters` | `Array`[[`ContentFilter`](#contentfilter)] | optional | Array of content filters to query for historical messages |
|
||||
| `startTime` | `Number`| optional | The inclusive lower bound on the [`timestamp`](/spec/14#Payloads) of queried [`WakuMessage`s](#WakuMessage). This parameter holds the Unix epoch time in seconds as a 64-bits float value. The fractional part represents sub-seconds. |
|
||||
| `endTime` | `Number` | optional | The inclusive upper bound on the [`timestamp`](/spec/14#Payloads) of queried [`WakuMessage`s](#WakuMessage). This parameter holds the Unix epoch time in seconds as a 64-bits float value. The fractional part represents sub-seconds. |
|
||||
| `startTime` | `Number`| optional | The inclusive lower bound on the [`timestamp`](/spec/14#Payloads) of queried [`WakuMessage`s](#WakuMessage). This field holds the Unix epoch time in nanoseconds as a 64-bits integer value. |
|
||||
| `endTime` | `Number` | optional | The inclusive upper bound on the [`timestamp`](/spec/14#Payloads) of queried [`WakuMessage`s](#WakuMessage). This field holds the Unix epoch time in nanoseconds as a 64-bits integer value. |
|
||||
| `pagingOptions` | [`PagingOptions`](#PagingOptions) | optional | Pagination information |
|
||||
|
||||
#### Response
|
||||
|
@ -563,7 +563,7 @@ This method is part of the `store` API and the specific resources to retrieve ar
|
|||
"pageSize": 2,
|
||||
"cursor": {
|
||||
"digest": "abcdef",
|
||||
"receivedTime": 1605887187
|
||||
"receivedTime": 1605887187000000000
|
||||
},
|
||||
"forward": false
|
||||
}
|
||||
|
@ -578,7 +578,7 @@ This method is part of the `store` API and the specific resources to retrieve ar
|
|||
|
||||
#### Request
|
||||
|
||||
```curl -d '{"jsonrpc":"2.0","id":"id","method":"get_waku_v2_store_v1_messages", "params":[ "", [{"contentTopic":"/waku/2/default-content/proto"}],{"pageSize":2,"cursor":{"digest":"abcdef","receivedTime":1605887187.00},"forward":false}]}' --header "Content-Type: application/json" http://localhost:8545```
|
||||
```curl -d '{"jsonrpc":"2.0","id":"id","method":"get_waku_v2_store_v1_messages", "params":[ "", [{"contentTopic":"/waku/2/default-content/proto"}],{"pageSize":2,"cursor":{"digest":"abcdef","receivedTime":1605887187000000000},"forward":false}]}' --header "Content-Type: application/json" http://localhost:8545```
|
||||
|
||||
```jsonrpc
|
||||
{
|
||||
|
@ -594,7 +594,7 @@ This method is part of the `store` API and the specific resources to retrieve ar
|
|||
"pageSize": 2,
|
||||
"cursor": {
|
||||
"digest": "abcdef",
|
||||
"receivedTime": 1605887187
|
||||
"receivedTime": 1605887187000000000
|
||||
},
|
||||
"forward": false
|
||||
}
|
||||
|
@ -622,7 +622,7 @@ This method is part of the `store` API and the specific resources to retrieve ar
|
|||
"pageSize": 2,
|
||||
"cursor": {
|
||||
"digest": "123abc",
|
||||
"receivedTime": 1605866187
|
||||
"receivedTime": 1605866187000000000
|
||||
},
|
||||
"forward": false
|
||||
}
|
||||
|
|
|
@ -35,8 +35,8 @@ message HistoryQuery {
|
|||
string pubsubtopic = 2;
|
||||
repeated ContentFilter contentFilters = 3;
|
||||
PagingInfo pagingInfo = 4;
|
||||
+ double start_time = 5;
|
||||
+ double end_time = 6;
|
||||
+ sint64 start_time = 5;
|
||||
+ sint64 end_time = 6;
|
||||
}
|
||||
|
||||
```
|
||||
|
@ -45,10 +45,10 @@ message HistoryQuery {
|
|||
|
||||
RPC call to query historical messages.
|
||||
- `start_time`: this field MAY be filled out to signify the starting point of the queried time window.
|
||||
This field holds the Unix epoch time.
|
||||
This field holds the Unix epoch time in nanoseconds.
|
||||
The `messages` field of the corresponding [`HistoryResponse`](/spec/13#HistoryResponse) MUST contain historical waku messages whose [`timestamp`](/spec/14#Payloads) is larger than or equal to the `start_time`.
|
||||
- `end_time` this field MAY be filled out to signify the ending point of the queried time window.
|
||||
This field holds the Unix epoch time.
|
||||
This field holds the Unix epoch time in nanoseconds.
|
||||
The `messages` field of the corresponding [`HistoryResponse`](/spec/13#HistoryResponse) MUST contain historical waku messages whose [`timestamp`](/spec/14#Payloads) is less than or equal to the `end_time`.
|
||||
|
||||
A time-based query is considered valid if its `end_time` is larger than or equal to the `start_time`.
|
||||
|
@ -57,7 +57,7 @@ RPC call to query historical messages.
|
|||
|
||||
|
||||
|
||||
In order to account for nodes asynchrony, and assuming that nodes may be out of sync for at most 20 seconds, the querying nodes SHOULD add an offset of 20 seconds to their offline time window.
|
||||
In order to account for nodes asynchrony, and assuming that nodes may be out of sync for at most 20 seconds (i.e., 20000000000 nanoseconds), the querying nodes SHOULD add an offset of 20 seconds to their offline time window.
|
||||
That is if the original window is [`l`,`r`] then the history query SHOULD be made for `[start_time: l - 20s, end_time: r + 20s]`.
|
||||
|
||||
Note that `HistoryQuery` preserves `AND` operation among the queried attributes.
|
||||
|
|
Loading…
Reference in New Issue