Skip to content
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

New messages for pull rumors #1877

Merged
merged 15 commits into from
May 27, 2024
100 changes: 91 additions & 9 deletions docs/protocol.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
- [Sending a heartbeat message to servers](#sending-a-heartbeat-message-to-servers)
- [Retrieving messages from server using ids ](#retrieving-messages-from-server-using-ids-)
- [Spreading a Rumor](#spreading-a-rumor)
- [Sharing rumor state](#sharing-rumor-state)
- [Answer](#answer)
- [RPC answer error](#rpc-answer-error)
- [Mid-level (message) communication](#mid-level-message-communication)
Expand Down Expand Up @@ -191,6 +192,9 @@ and its arguments (`params`).
},
{
"$ref": "method/rumor.json"
},
{
"$ref": "method/rumor_state.json"
}
],

Expand All @@ -211,6 +215,8 @@ Here are the different methods that can be called:
* Publish
* Heartbeat
* GetMessagesById
* Rumor
* RumorState

### Greeting a server
🧭 **RPC Message** > **Query** > **Greet Server**
Expand All @@ -227,15 +233,15 @@ Notification
```json5
// ../protocol/examples/query/greet_server/greet_server.json

{
"jsonrpc": "2.0",
"method": "greet_server",
"params": {
"public_key": "J9fBzJV70Jk5c-i3277Uq4CmeL4t53WDfUghaK0HpeM=",
"client_address": "wss://popdemo.dedis.ch:9000/client",
"server_address": "wss://popdemo.dedis.ch:9001/server"
}
}
{
"jsonrpc": "2.0",
"method": "greet_server",
"params": {
"public_key": "J9fBzJV70Jk5c-i3277Uq4CmeL4t53WDfUghaK0HpeM=",
"client_address": "wss://popdemo.dedis.ch:9000/client",
"server_address": "wss://popdemo.dedis.ch:9001/server"
}
}

```

Expand Down Expand Up @@ -1062,6 +1068,82 @@ RPC
```
</details>

### Sharing rumor state

🧭 **RPC Message** > **Query** > **Rumor state**

The purpose of this RPC is to share to other servers a snapshot of the last rumor ID received from each neighbor.

Upon reception of this state, the receiver will send back missing rumors to the querier, which will then propagate new rumors accross the network.

```json5
// ../protocol/examples/query/rumor_state/rumor_state.json

{
"jsonrpc": "2.0",
"id": 4,
"method": "rumor_state",
"params": {
"rumor_state": {
"J9fBzJV70Jk5c-i3277Uq4CmeL4t53WDfUghaK0HpeM=": 3,
"RZOPi59Iy5gkpS2mkpfQJNl44HKc2jVbF0iTGm0RvfU=": 5,
"CfG2ByLhtLJH--T2BL9hZ6eGm11tpkE-5KuvysSCY0I=": 1,
"r8cG9HyJ1FGBke_5IblCdH19mvy39MvLFSArVmY3FpY=": 10
}
}
}

```

<details>
<summary>
💡 See the full specification
</summary>

```json5
// ../protocol/query/method/object/rumor_state.json

{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "https://raw.githubusercontent.com/dedis/popstellar/master/protocol/query/method/object/rumor_state.json",
"title": "State of received rumors",
"description": "An object containing key-value pairs where each key is a server public key and each value is the last rumor_id it received from this server",
"type": "object",
"additionalProperties": false,
"patternProperties": {
"^(?:[a-zA-Z0-9-_]{4})*(?:|[a-zA-Z0-9-_]{3}=|[a-zA-Z0-9+-_]{2}==|[a-zA-Z0-9+-_]===)$": {
"description": "[Integer] ID of the rumor",
"type": "integer",
"minimum": 0
}
}
}

```

```json5
// ../protocol/query/method/object/rumor_state.json

{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "https://raw.githubusercontent.com/dedis/popstellar/master/protocol/query/method/object/rumor_state.json",
"title": "State of received rumors",
"description": "An object containing key-value pairs where each key is a server public key and each value is the last rumor_id it received from this server",
"type": "object",
"additionalProperties": false,
"patternProperties": {
"^(?:[a-zA-Z0-9-_]{4})*(?:|[a-zA-Z0-9-_]{3}=|[a-zA-Z0-9+-_]{2}==|[a-zA-Z0-9+-_]===)$": {
"description": "[Integer] ID of the rumor",
"type": "integer",
"minimum": 0
}
}
}

```

</details>

## Answer

🧭 **RPC Message** > **Answer**
Expand Down
13 changes: 13 additions & 0 deletions protocol/examples/query/rumor_state/rumor_state.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"jsonrpc": "2.0",
"id": 4,
"method": "rumor_state",
"params": {
"rumor_state": {
"J9fBzJV70Jk5c-i3277Uq4CmeL4t53WDfUghaK0HpeM=": 3,
"RZOPi59Iy5gkpS2mkpfQJNl44HKc2jVbF0iTGm0RvfU=": 5,
"CfG2ByLhtLJH--T2BL9hZ6eGm11tpkE-5KuvysSCY0I=": 1,
"r8cG9HyJ1FGBke_5IblCdH19mvy39MvLFSArVmY3FpY=": 10
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"jsonrpc": "2.0",
"id": 4,
"method": "rumor_state",
"params": {
"rumor_state": {
"J9fBzJV70Jk5c-i3277Uq4CmeL4t53WDfUghaK0HpeM=": 3,
"RZOPi59Iy5gkpS2mkpfQJNl44HKc2jVbF0iTGm0RvfU=": 5,
"CfG2ByLhtLJH--T2BL9hZ6eGm11tpkE-5KuvysSCY0I=": 1,
"r8cG9HyJ1FGBke_5IblCdH19mvy39MvLFSArVmY3FpY=": 10
},
"additionalParams": ""
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"jsonrpc": "2.0",
"id": 4,
"method": "rumor_state",
"params": {
"rumor_state": {
"J9fBzJV70Jk5c-i3277Uq4CmeL4t53WDfUghaK0HpeM=": 3,
"RZOPi59Iy5gkpS2mkpfQJNl44HKc2jVbF0iTGm0RvfU=": 5,
"CfG2ByLhtLJH--T2BL9hZ6eGm11tpkE-5KuvysSCY0I=": 1,
"r8cG9HyJ1FGBke_5IblCdH19mvy39MvLFSArVmY3FpY=": -10
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"jsonrpc": "2.0",
"id": 4,
"method": "rumor_state",
"params": {
"rumor_state": {
"notInBase64": 3,
"RZOPi59Iy5gkpS2mkpfQJNl44HKc2jVbF0iTGm0RvfU=": 5,
"CfG2ByLhtLJH--T2BL9hZ6eGm11tpkE-5KuvysSCY0I=": 1,
"r8cG9HyJ1FGBke_5IblCdH19mvy39MvLFSArVmY3FpY=": 10
}
}
}
15 changes: 15 additions & 0 deletions protocol/query/method/object/rumor_state.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "https://raw.githubusercontent.com/dedis/popstellar/master/protocol/query/method/object/rumor_state.json",
"title": "State of received rumors",
"description": "An object containing key-value pairs where each key is a server public key and each value is the last rumor_id it received from this server",
"type": "object",
"additionalProperties": false,
"patternProperties": {
"^(?:[a-zA-Z0-9-_]{4})*(?:|[a-zA-Z0-9-_]{3}=|[a-zA-Z0-9+-_]{2}==|[a-zA-Z0-9+-_]===)$": {
"description": "[Integer] ID of the rumor",
"type": "integer",
"minimum": 0
}
}
}
34 changes: 34 additions & 0 deletions protocol/query/method/rumor_state.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "https://raw.githubusercontent.com/dedis/popstellar/master/protocol/query/method/rumor_state.json",
"description": "Match sharing state of last rumor seen per sender",
"type": "object",
"additionalProperties": false,
"properties": {
"method": {
"description": "[String] operation to be performed by the query",
"const": "rumor_state"
},

"params": {
"type": "object",
"additionalProperties": false,
"properties": {
"rumor_state": {
Copy link
Collaborator

Choose a reason for hiding this comment

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

you could just write state, we already know it is a rumor_state with the method

"$ref": "object/rumor_state.json"
}
},
"required": ["rumor_state"]
},

"jsonrpc": {
"$comment": "Defined by the parent, but needed here for the validation"
},

"id": {
"type": "integer"
}
},

"required": ["method", "params", "id", "jsonrpc"]
}
3 changes: 3 additions & 0 deletions protocol/query/query.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@
},
{
"$ref": "method/rumor.json"
},
{
"$ref": "method/rumor_state.json"
}
],

Expand Down
4 changes: 4 additions & 0 deletions protocol/test/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ const method_get_messages_by_id_schema = require("../query/method/get_messages_b
const method_greet_server_schema = require("../query/method/greet_server.json");

const method_rumor_schema = require("../query/method/rumor.json")
const method_rumor_state_schema = require("../query/method/rumor_state.json")
const object_rumor_state_schema = require("../query/method/object/rumor_state.json")

const message_data_schema = require("../query/method/message/data/data.json");
const message_data_roll_call_close_schema = require("../query/method/message/data/dataCloseRollCall.json");
Expand Down Expand Up @@ -83,6 +85,8 @@ ajv.addSchema([
method_greet_server_schema,

method_rumor_schema,
method_rumor_state_schema,
object_rumor_state_schema,

message_data_schema,

Expand Down
3 changes: 2 additions & 1 deletion protocol/test/main.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ describe("Check root schema", () => {
"query/heartbeat",
"query/get_messages_by_id",
"query/greet_server",
"query/rumor"
"query/rumor",
"query/rumor_state"
],
rootSchema
);
Expand Down
32 changes: 21 additions & 11 deletions protocol/test/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading