mirror of
https://github.com/Cuprate/cuprate.git
synced 2025-03-12 09:29:11 +00:00
add most flows
This commit is contained in:
parent
fb78f9ed10
commit
07c6c24736
7 changed files with 149 additions and 0 deletions
|
@ -26,4 +26,10 @@
|
|||
- [Admin Messages](./p2p_network/levin/admin.md)
|
||||
- [Protocol Messages](./p2p_network/levin/protocol.md)
|
||||
- [Common Types](./p2p_network/common_types.md)
|
||||
- [Message Flows](./p2p_network/message_flows.md)
|
||||
- [Handshake](./p2p_network/message_flows/handshake.md)
|
||||
- [Timed Sync](./p2p_network/message_flows/timed_sync.md)
|
||||
- [New Block](./p2p_network/message_flows/new_block.md)
|
||||
- [New Transactions](./p2p_network/message_flows/new_transactions.md)
|
||||
- [Chain Sync](./p2p_network/message_flows/chain_sync.md)
|
||||
- [Pruning](./pruning.md)
|
||||
|
|
19
books/protocol/src/p2p_network/message_flows.md
Normal file
19
books/protocol/src/p2p_network/message_flows.md
Normal file
|
@ -0,0 +1,19 @@
|
|||
# Message Flows
|
||||
|
||||
Message flows are sets of messages sent between peers, that achieve an identifiable goal, like a handshake.
|
||||
Some message flows are complex, involving many message types, whereas others are simple, requiring only 1.
|
||||
|
||||
The message flows here are not every possible request/response.
|
||||
|
||||
When documenting checks on the messages, checks not on the message will not be included. For example when receiving
|
||||
a handshake monerod will check if we have too many incoming connections, this check would not be included in the
|
||||
checks on the handshake request.
|
||||
|
||||
## Different Flows
|
||||
|
||||
- [Handshakes](./message_flows/handshake.md)
|
||||
- [Timed Sync](./message_flows/timed_sync.md)
|
||||
- [New Block](./message_flows/new_block.md)
|
||||
- [New Transactions](./message_flows/new_transactions.md)
|
||||
- [Chain Sync](./message_flows/chain_sync.md)
|
||||
|
51
books/protocol/src/p2p_network/message_flows/handshake.md
Normal file
51
books/protocol/src/p2p_network/message_flows/handshake.md
Normal file
|
@ -0,0 +1,51 @@
|
|||
# Handshakes
|
||||
|
||||
Handshakes are used to establish connections to peers.
|
||||
|
||||
## Flow
|
||||
|
||||
The default handshake flow is made up of the connecting peer sending a [handshake request](../levin/admin.md#handshake-request) and the
|
||||
receiving peer responding with a [handshake response](../levin/admin.md#handshake-response).
|
||||
|
||||
It should be noted that not all other messages are banned during handshakes, for example support flag requests can be sent and even some protocol
|
||||
requests.
|
||||
|
||||
### Handshake Request Checks
|
||||
|
||||
The receiving peer will check:
|
||||
|
||||
- The `network_id` is network ID expected.[^network-id]
|
||||
- The connection is an incoming connection.[^req-incoming-only]
|
||||
- The peer hasn't already completed a handshake.[^double-handshake]
|
||||
- If the network zone is public, then the `peer_id` must not be the same as ours.[^same-peer-id]
|
||||
- The core sync data is not malformed.[^core-sync-data-checks]
|
||||
|
||||
### Handshake Response Checks
|
||||
|
||||
Teh initiating peer will check:
|
||||
|
||||
- The `network_id` is network ID expected.[^res-network-id]
|
||||
- The number of peers in the peer list is less than `250`.[^max-peer-list-res]
|
||||
- All peers in the peer list are in the same zone.[^peers-all-in-same-zone]
|
||||
- The core sync data is not malformed.[^core-sync-data-checks]
|
||||
- If the network zone is public, then the `peer_id` must not be the same as ours.[^same-peer-id-res]
|
||||
|
||||
---
|
||||
|
||||
[^network-id]: <https://github.com/monero-project/monero/blob/cc73fe71162d564ffda8e549b79a350bca53c454/src/p2p/net_node.inl#L2510>
|
||||
|
||||
[^req-incoming-only]: <https://github.com/monero-project/monero/blob/cc73fe71162d564ffda8e549b79a350bca53c454/src/p2p/net_node.inl#L2519>
|
||||
|
||||
[^double-handshake]: <https://github.com/monero-project/monero/blob/cc73fe71162d564ffda8e549b79a350bca53c454/src/p2p/net_node.inl#L2527>
|
||||
|
||||
[^same-peer-id]: <https://github.com/monero-project/monero/blob/cc73fe71162d564ffda8e549b79a350bca53c454/src/p2p/net_node.inl#L2539>
|
||||
|
||||
[^core-sync-data-checks]: <https://github.com/monero-project/monero/blob/cc73fe71162d564ffda8e549b79a350bca53c454/src/cryptonote_protocol/cryptonote_protocol_handler.inl#L341>
|
||||
|
||||
[^res-network-id]: <https://github.com/monero-project/monero/blob/cc73fe71162d564ffda8e549b79a350bca53c454/src/p2p/net_node.inl#L1164>
|
||||
|
||||
[^max-peer-list-res]: <https://github.com/monero-project/monero/blob/cc73fe71162d564ffda8e549b79a350bca53c454/src/p2p/net_node.inl#L2170>
|
||||
|
||||
[^peers-all-in-same-zone]: <https://github.com/monero-project/monero/blob/cc73fe71162d564ffda8e549b79a350bca53c454/src/p2p/net_node.inl#L2182>
|
||||
|
||||
[^same-peer-id-res]: <https://github.com/monero-project/monero/blob/cc73fe71162d564ffda8e549b79a350bca53c454/src/p2p/net_node.inl#L1195>
|
29
books/protocol/src/p2p_network/message_flows/new_block.md
Normal file
29
books/protocol/src/p2p_network/message_flows/new_block.md
Normal file
|
@ -0,0 +1,29 @@
|
|||
# New Block
|
||||
|
||||
This is used whenever a new block is to be sent to peers. Only the fluffy block flow is described here, as the other method is depreciated.
|
||||
|
||||
## Flow
|
||||
|
||||
First the peer with the new block will send a [new fluffy block](../levin/protocol.md#notify-new-fluffy-block) notification, if the receiving
|
||||
peer has all the txs in the block then the flow is complete. Otherwise the peer sends a [fluffy missing transactions request](../levin/protocol.md#notify-request-fluffy-missing-tx)
|
||||
to the first peer, the first peer will then respond with again a [new fluffy block](../levin/protocol.md#notify-new-fluffy-block) notification but
|
||||
with the transactions requested.
|
||||
|
||||
```bob
|
||||
|
||||
,----------. ,----------.
|
||||
|Initiator | | Receiver |
|
||||
`-----+----' `-----+----'
|
||||
| New Fluffy Block |
|
||||
|-------------------->|
|
||||
| |
|
||||
| Missing Txs Request |
|
||||
|<- - - - - - - - - - |
|
||||
| |
|
||||
| New Fluffy Block |
|
||||
| - - - - - - - - - ->|
|
||||
| |
|
||||
| |
|
||||
V v
|
||||
```
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
# New Transactions
|
||||
|
||||
Monero uses the dandelion++ protocol to pass transactions around the network, this flow just describes the actual tx passing between nodes part.
|
||||
|
||||
## Flow
|
||||
|
||||
This flow is pretty simple, the txs are put into a [new transactions](../levin/protocol.md#notify-new-transactions) notification and sent to
|
||||
peers.
|
||||
|
||||
Hopefully in the future [this is changed](https://github.com/monero-project/monero/issues/9334).
|
||||
|
||||
There must be no duplicate txs in the notification.[^duplicate-txs]
|
||||
|
||||
---
|
||||
|
||||
[^duplicate-txs]: <https://github.com/monero-project/monero/blob/cc73fe71162d564ffda8e549b79a350bca53c454/src/cryptonote_protocol/cryptonote_protocol_handler.inl#L991>
|
28
books/protocol/src/p2p_network/message_flows/timed_sync.md
Normal file
28
books/protocol/src/p2p_network/message_flows/timed_sync.md
Normal file
|
@ -0,0 +1,28 @@
|
|||
# Timed Syncs
|
||||
|
||||
A timed sync request is sent every 60 seconds to make sure the connection is still live.
|
||||
|
||||
## Flow
|
||||
|
||||
First the timed sync initiator will send a [timed sync request](../levin/admin.md#timed-sync-request), the receiver will then
|
||||
respond with a [timed sync response](../levin/admin.md#timed-sync-response)
|
||||
|
||||
### Timed Sync Request Checks
|
||||
|
||||
- The core sync data is not malformed.[^core-sync-data-checks]
|
||||
|
||||
|
||||
### Timed Sync Response Checks
|
||||
|
||||
- The core sync data is not malformed.[^core-sync-data-checks]
|
||||
- The number of peers in the peer list is less than `250`.[^max-peer-list-res]
|
||||
- All peers in the peer list are in the same zone.[^peers-all-in-same-zone]
|
||||
|
||||
---
|
||||
|
||||
[^core-sync-data-checks]: <https://github.com/monero-project/monero/blob/cc73fe71162d564ffda8e549b79a350bca53c454/src/p2p/net_node.inl#L2464>
|
||||
|
||||
[^max-peer-list-res]: <https://github.com/monero-project/monero/blob/cc73fe71162d564ffda8e549b79a350bca53c454/src/p2p/net_node.inl#L2170>
|
||||
|
||||
[^peers-all-in-same-zone]: <https://github.com/monero-project/monero/blob/cc73fe71162d564ffda8e549b79a350bca53c454/src/p2p/net_node.inl#L2182>
|
||||
|
Loading…
Reference in a new issue