You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/cad/003_encoding/README.md
+7-17Lines changed: 7 additions & 17 deletions
Original file line number
Diff line number
Diff line change
@@ -627,34 +627,20 @@ Implementations which require more than 63 fields MAY adopt their own scheme to
627
627
- Have the Record specify one field which contains a vector of additional fields
628
628
- Use the first field (index 0) to specify the interpretation of following fields (which may contain arbitrary values as sub-structures)
629
629
630
-
### `0xB0` - `0xB1` Byte Flags (Boolean)
631
-
632
-
The possible Boolean values are `true` and `false`, which are coded as 1-byte Byte Flags.
633
-
634
-
```
635
-
Encoded as:
636
-
0xB0 <=> false
637
-
0xB1 <=> true
638
-
```
639
-
640
-
The two Boolean Values `true` or `false` have the Encodings `0xb1` and `0xb0` respectively.
641
-
642
-
Note: These Tags are chosen to aid human readability, such that the first hexadecimal digit `b` suggests "binary" or "boolean", and the second hexadecimal digit represents the bit value.
643
-
644
-
### `0xB2`-`0xBF` Byte Flags (Extensible)
630
+
### `0xB0`-`0xBF` Byte Flags (Extensible)
645
631
646
632
Byte flags are one byte encodings (similar to Booleans) available for application specific use.
647
633
648
634
```
649
635
`0xBn`
650
636
651
637
Where
652
-
- n = a hex value from 2-15
638
+
- n = a hex value from 0-15
653
639
```
654
640
655
641
Applications MAY use byte flags as a efficient single byte value, i.e. the complete value encoding is always exactly one byte. For example, the encoding `0xb2` might represent an "unknown" value in ternary logic.
656
642
657
-
Values `0xb0` and `0xb1` are already reserved for the two boolean values, though an application MAY repurpose these as single byte values (along with `0x00` and `0x10`) providing these values are not needed for some other purpose.
643
+
Values `0xb0` and `0xb1` are typically used for the two boolean values, though an application MAY repurpose these as single byte values (along with `0x00` and `0x10`) providing these values are not needed for some other purpose.
658
644
659
645
Fun Idea: A 1-byte Lisp where `0x10` is an opening paren, `0x00` is a closing paren and `0xb0 - 0xbf` are the allowable tokens.
660
646
@@ -721,6 +707,10 @@ Examples:
721
707
- an application might define `0xE5` as an extension where the value references a known JSON schema.
722
708
- another application might define `0xE0` as an enum where the values are the possible states of a finite state machine
723
709
710
+
### `0xF0` - `0xFE` Reserved
711
+
712
+
These values are reserved for possible future CAD3 extensions. at present they are illegal
713
+
724
714
### `0xFF` Illegal
725
715
726
716
The `0xFF` tag is always illegal as a tag byte in any encoding.
Copy file name to clipboardExpand all lines: docs/cad/015_peercomms/README.md
+54-16Lines changed: 54 additions & 16 deletions
Original file line number
Diff line number
Diff line change
@@ -14,34 +14,47 @@ Objectives:
14
14
- Asynchronous model supported by default
15
15
- Flexibility to adapt to different transport protocols
16
16
- Consistency with lattice data principles
17
+
- Usage of CAD3 data for message payloads
17
18
18
19
## Messages
19
20
20
21
Peers communicate via messages. A message is an atomic, asynchronous piece of data passed from a sender to a receiver.
21
22
22
-
A Message consists of:
23
+
Each message has a CAD3 payload.
24
+
25
+
### Message Encoding
26
+
27
+
The Message encoding format is designed to efficiently encode a CAD3 payload. Since CAD3 structures can contain multiple branches, each with their own encoding, the key idea is to send the top level encoding first, then follow this with any required child branches.
28
+
29
+
A Message is normally encoded as a Blob of bytes consisting of the following:
23
30
24
-
- A Message Type tag (one byte)
25
-
- Encoded message payload (according to Cell encoding rules)
31
+
- Encoded top level message payload (according to CAD3 Cell encoding rules)
26
32
- Optional: One or more additional branch cell encodings
27
33
- A VLC encoded length
28
34
- Branch cell encoding (according to Cell encoding rules)
29
35
30
-
Encoded message data depends on the message type.
31
-
32
-
Each individual cell encoding MUST fit within a fixed size buffer (currently 8192 bytes). However, by including the additional branch cell encodings, it is possible to include branch cells referenced by the payload. In this way:
36
+
Each individual cell encoding MUST fit within a fixed size buffer (currently 16383 bytes). However, by including the additional branch cell encodings, it is possible to include branch cells referenced by the payload. In this way:
33
37
- Large data structures can be passed in a single message
34
-
- Branch cells can be omitted, in which case the message is regarded as **partial**. Partial messages are appropriate for values such as lattice deltas where the recipient is expected to already be in possession of the omitted branches.
38
+
- Branch cells can be omitted, in which case the message is regarded as **partial**. Partial messages are appropriate for values such as lattice deltas where the recipient is expected to already be in possession of the omitted branches. A partial message is valid, however the receiver may not be able to access the full payload immediately.
35
39
36
-
The overall size of the message is not part of the message itself, but will be provided by the transport mechanism e.g.:
40
+
The overall size of the message is not part of the message itself, but will typically be provided by the transport mechanism e.g.:
37
41
- For binary protocol messages, the message length precedes the message
38
42
- For HTTP messages of type `application/cvx-raw` the message length is specified in the HTTP `Content-Length` header.
39
43
- For messages passed as an octet stream, the message length is naturally delineated by the end of the stream
40
44
41
45
### Message Types
42
46
47
+
The type of the message can be inferred from the payload. Any CAD3 value may form a valid Message, so the interpretation of these values is part of the peer protocol (i.e. application specific).
48
+
49
+
Currently recognised message types follow:
50
+
43
51
#### BELIEF
44
52
53
+
```
54
+
CAD3 Payload:
55
+
Belief
56
+
```
57
+
45
58
This message specifies a belief from an other peer that is being shared as part of the CPoS consensus algorithm.
46
59
47
60
Receiving peers SHOULD validate this belief message, and if valid perform a belief merge with their current belief.
@@ -50,12 +63,13 @@ Receiving peers MAY ignore beliefs if they are experiencing high demand and need
50
63
51
64
Receiving peers SHOULD ignore and/or minimise processing for beliefs that have already been received and merged. This is safe because belief merges are idempotent.
52
65
53
-
#### DATA
54
-
55
-
This message type provides one or more encoded cells of data. Usually, this will be a component part of a longer message or a response to a `MISSING_DATA` message.
56
-
57
66
#### QUERY
58
67
68
+
```
69
+
CAD3 Payload:
70
+
[:QR msg-id form address?]
71
+
```
72
+
59
73
This message represents a request for a peer to compute the results of a query (considered as a read-only transaction).
60
74
61
75
Peers SHOULD make a best effort attempt to respond to queries from authorised clients.
@@ -64,6 +78,11 @@ Peers MAY reject queries if they are experiencing high demand. In such cases pee
64
78
65
79
#### TRANSACT
66
80
81
+
```
82
+
CAD3 Payload:
83
+
[:TX msg-id signed-transaction]
84
+
```
85
+
67
86
This message represents a request for a Peer to process a transaction by incorporating it into a subsequent Block that the Peer proposes to the Network.
68
87
69
88
Peers MUST reject transactions that are not correctly signed. Failure to do so may result in slashing.
@@ -72,27 +91,42 @@ Peers MUST reject transactions that have a previously used sequence number.
72
91
73
92
#### RESULT
74
93
94
+
```
95
+
CAD3 Payload:
96
+
Result
97
+
```
98
+
75
99
This message represents the result of another message request (usually a transaction or query).
76
100
77
-
A Result message MUST reference the message ID of the original message.
101
+
A Result message MUST reference the message ID of the original message. Results that do not correspond to a pending outgoing request ID should normally be ignored.
78
102
79
103
#### STATUS
80
104
105
+
```
106
+
CAD3 Payload:
107
+
[:SR msg-id]
108
+
```
109
+
81
110
This message represents a request for a Peer to provide information about its current status, including data about latest consensus state.
82
111
83
112
Peers SHOULD respond to the status request immediately if able.
84
113
85
114
Peers MAY cache their most recent status response for efficiency reasons.
86
115
87
-
#### MISSING_DATA
116
+
#### DATA_REQUEST
117
+
118
+
```
119
+
CAD3 Payload:
120
+
[:DR msg-id hash0 hash1 .....]
121
+
```
88
122
89
123
This message represents a request for missing data. Usually, this is sent by a peer when it is attempting to process a partial message but some data is missing locally, and it needs to acquire the missing data before proceeding.
90
124
91
-
The Missing Data request must include the Value ID (hash of encoding) for the missing data. Note: It is guaranteed that if a peer has received a partial message, it must be able to determine the hashes of any directly missing data (since they will be encoded as refs in the partial message).
125
+
The Missing Data request must include the Value IDs (hash of encoding) for the missing data branches. Note: It is guaranteed that if a peer has received a partial message, it must be able to determine the hashes of any directly missing data (since they will be encoded as branch refs in the partial message).
92
126
93
127
Peer that send this message MAY suspend processing of a message pending receipt of missing data from the original sender. If the original sender is unable to satisfy this request in a timely manner, the suspended message SHOULD be discarded.
94
128
95
-
Receiving Peers SHOULD respond by sending a `DATA` message containing the missing data specified. Failure to do so may result in a previous message being ignored.
129
+
Receiving Peers SHOULD respond by sending a `RESULT` message containing the missing data specified.
96
130
97
131
### Trust
98
132
@@ -108,6 +142,10 @@ Peers MAY accept messages from any source, but if they do, they SHOULD prioritis
108
142
109
143
The standard mechanism for message passing is TCP connections established between peers.
110
144
145
+
Messages are sent as:
146
+
- a VLQ encoded message length N
147
+
- N bytes representing the Message encoding
148
+
111
149
### UDP Connections
112
150
113
151
UDP will be explored as a potential future transport protocol for efficiency and performance reasons.
Copy file name to clipboardExpand all lines: docs/cad/017_peerops/README.md
+47-11Lines changed: 47 additions & 11 deletions
Original file line number
Diff line number
Diff line change
@@ -4,9 +4,9 @@
4
4
5
5
Operating a peer is an important responsibility in the Convex Network.
6
6
7
-
Anyone can run a peer, and they are responsible for maintaining the Consensus of the Network.
7
+
Anyone can run a peer, and they are responsible for maintaining the Consensus of the Network. They must place a minimum stake of 1000 Convex Coins.
8
8
9
-
Most users of the Convex Network do not need to run a peer - they connect to peers via clients software that submits transactions and queries information on their behalf.
9
+
Most users of the Convex Network do not need to run a peer - they connect to peers via client software that submits transactions and queries information on their behalf. The peer API is open to client requests by default: Peer operators who wish to restrict this may need to set up additional configuration or infrastructure.
10
10
11
11
This document primarily contains recommendations for peer operators
12
12
@@ -15,32 +15,54 @@ This document primarily contains recommendations for peer operators
15
15
Running a Peer requires:
16
16
17
17
- An Internet-connected Server
18
-
- At least 100 MBits/sec continuous bandwidth
18
+
- At least 100 MBits/sec continuous network bi-directional bandwidth
19
19
- A modern processor with at least 8 dedicated Cores
20
-
- At least 8 GB RAM (32 Gb Recommended)
21
-
- At least 2 TB fast Storage (NVMe Recommended)
20
+
- At least 8 GB RAM (32 GB Recommended)
21
+
- At least 1 TB fast Storage (NVMe Recommended)
22
22
- A secure modern operating system (Linux recommended) with good support for memory mapped files
23
23
- Java 21 or above
24
24
25
25
The network should be configured with:
26
-
- a publicly accessible IP address (IPv4 or IPv6)
26
+
- a publicly accessible IP address (IPv4 or IPv6). Dual stack networking support is required in the OS.
27
27
- firewall access to the server via TCP on a chosen port (the Convex protocol default `18888` is recommended)
28
-
- a trusted DNS entry (e.g. `peer.mycompany.com`)
28
+
- a trusted DNS entry (e.g. `peer.mycompany.com`) is recommended
29
+
- HTTPS certificates recommended for the HTTPS REST API
29
30
30
31
The DNS entry is optional, but it will help significantly with discoverability / user access to your peer.
31
32
32
33
## Configuration
33
34
35
+
### Accounts
36
+
37
+
In order to operate a peer you will need a Peer Controller account. This can be any account on the Convex network, e.g. `#1678` with at least 1000 Convex Coins.
38
+
34
39
### Peer Config
35
40
36
41
Peers can be configured at launch in various ways.
37
42
38
-
Peers SHOULD configure the number of concurrent outgoing Peer connections according to their available bandwidth. 20 recommended for Peers with fast connections.
43
+
#### Outgoing connections
44
+
45
+
Peers MAY configure the number of concurrent outgoing Peer connections according to their available bandwidth. 20 (the default) recommended for Peers with sufficient outgoing bandwidth. There are trade-offs here:
46
+
- With more outgoing connections, your transactions will reach consensus faster
47
+
- You must weight this up against bandwidth costs
48
+
- If the number is too low your published blocks may get lost if the destinations do not relay them.
49
+
50
+
TODO: describe mechanism to set connection count controls
39
51
40
52
41
53
42
54
## Startup
43
55
56
+
## Syncing
57
+
58
+
Your peer will need to synchronize with teh network by connecting to at least one existing peer.
59
+
60
+
The following peers are available at time of writing for synchronisation:
61
+
```
62
+
peer.convex.live:18888
63
+
```
64
+
65
+
TODO: CLI commend top start peer with target host
44
66
45
67
## Shutdown
46
68
@@ -56,7 +78,9 @@ It may occur that a peer becomes temporarily disconnected from the peer network.
56
78
57
79
Peers are designed to automatically recover from temporary network failure and re-establish connections when possible. Peers with normal configuration SHOULD periodically re-attempt to connect with other peers randomly until connection with the Network is re-established.
58
80
59
-
Peer Operators SHOULD provide for an alternative way to connect to the main network, if only for the purposes of withrawing the Peer's Stake (Peers are at risk of penalisation if they remain disconnected for too long).
81
+
Peer Operators SHOULD provide for an alternative way to connect to the main network, if only for the purposes of withdrawing the Peer's Stake. For example, a peer operator may monitor the connectivity of their peer and use Convex Desktop to de-stake the peer if it loses connections.
82
+
83
+
TODO: describe best way to monitor this. Perhaps API peer health endpoint?
60
84
61
85
### Security Breach
62
86
@@ -68,22 +92,34 @@ Peer Operators SHOULD attempt to withdraw their Stake immediately, possibly thro
68
92
69
93
Peers are required to post a Peer Stake to participate in consensus.
70
94
95
+
### Setting a stake
96
+
97
+
### Withdrawing stake
98
+
99
+
### Stake penalties
100
+
101
+
In Protonet, there is no slashing of stake (i.e. peers are not formally penalised for incorrect behaviour).
102
+
103
+
In the future peers may be automatically penalised for provably incorrect behaviour.
104
+
71
105
## Key Management
72
106
73
107
## Connection Management
74
108
75
109
A Convex Peer is designed to automatically manage P2P connections to the Network during normal operations. In most cases, assuming good network connectivity, a Peer should require no manual intervention to control connections to other Peers.
76
110
111
+
112
+
77
113
### Incoming Connections
78
114
79
-
Peers treat incoming connections as regular Clients, i.e. they afford no particular special priviledges to incoming connections from other Peers. The purpose of this is to ensure that Bad Peers have no particular ability to influence a Peer that they connect to.
115
+
Peers treat incoming connections as regular Clients, i.e. they afford no particular special privileges to incoming connections from other Peers. The purpose of this is to ensure that Bad Peers have no particular ability to influence a Peer that they connect to.
80
116
81
117
### Outgoing connections
82
118
83
119
A Peer maintains a managed list of outgoing connections (i.e. connections to which they broadcast their Beliefs).
84
120
85
121
Outgoing connections follow the following rules:
86
-
-**Validated hosts**: Peers MUST only connect to Peers accesible on the network via the host address specified for the destination Peer in the current consensus, **or** if they are explicitly instructed to connect to a specific host address by the Peer Operator (e.g. when joining the Network). This minimises the chance of connecting to Bad Peers.
122
+
-**Validated hosts**: Peers MUST only connect to Peers accessible on the network via the host address specified for the destination Peer in the current consensus, **or** if they are explicitly instructed to connect to a specific host address by the Peer Operator (e.g. when joining the Network). This minimises the chance of connecting to Bad Peers.
87
123
-**Random elimination**: Peers SHOULD eliminate connections at random for low-staked Peers. This allows the Peer network to stay dynamic, and give an opportunity for new Peers to be connected to
88
124
-**Stake-weighted selection** Peers MUST connect to other Peers preferentially according to stake, so that Bad Peers do not have a significant chance of isolating a Peer
89
125
-**Target connection count**: Peers should attempt to maintain a number of outgoing connections to Peers as configured by the Peer Operator. This allows Peer Operators to control their bandwidth usage.
0 commit comments