Design objectives

Simplechain P2P The module provides efficient, universal, and secure basic network communication functions, supports unicast, multicast, and broadcast of blockchain messages, supports status synchronization of blockchain nodes, and supports multiple protocols.

Main functions of P2P

  • Blockchain Node Identification: A blockchain node is uniquely identified by the blockchain Node Identification, and the blockchain node is addressed by the blockchain node identification on the blockchain network.

  • Manage network connections: Maintain long TCP connections between blockchain nodes on the blockchain network, automatically disconnect abnormal connections, and automatically lift connections

  • Message sending and receiving: Unicast, multicast, or broadcast messages between blockchain nodes in the blockchain network

  • Status synchronization: Synchronization status between blockchain nodes

Simplechain Node Identification

The Node Identification of Simplechain is generated by the public key of the ECC algorithm. Each blockchain node must have a unique ECC key pair. The Node Identification uniquely identifies a blockchain node in the blockchain network. In general, to join a blockchain network, a node key node.key file in ECC format is required.

In addition to the unique blockchain Node Identification, Simplechain nodes can also focus on topics for addressing. Simplechain node addressing:

  • Blockchain Node Identification addressing: Use the blockchain Node Identification to locate a unique blockchain node in the blockchain network.
  • Topic addressing: Use the Topic to locate a group of nodes that focus on the Topic in the blockchain network.

Manage network connections

A long TCP connection is automatically initiated and maintained between Simplechain nodes. When a system fault or network exception occurs, the connection is automatically restarted. When a connection is established between nodes, the CA certificate is used for authentication.

Connection establishment process

participant node A
participant node B

Node A->>Node A: Load the Key
Node B->>Node B: Load the key
Node A->>NOde B: Initiate the connection
Node B->>Node A: Successful
Node B->Node A: Initiate SSL handshake
Node B->Node A: Successful handshake, establish SSL connection

Sending and receiving messages

Messages between nodes support unicast, multicast, and broadcast.

  • Unicast: a single node sends a message to a single blockchain node and identifies the address through the blockchain node.
  • Multicast: a single node sends messages to a group of blockchain nodes through Topic addressing
  • Broadcast: a single node sends messages to all blockchain nodes

Unicast process

sequenceDiagram
   participant node A
   participant node B

   node A->>node A: Filter online nodes based on node ID
   node A->>node B: Send message
   node B->>node A: message return packet

Multicast process

sequenceDiagram
   participant  node A
   participant  node B
   participant  node C
   participant  node D 

   node A->>node A: 根据Topic 1,选择节点B、C
   node A->>node B: 发送消息
   nide A->>node C: 发送消息
        node B->>node B: 根据Topic 2,选择节点C、D
        node B->>node C: 发送消息
        node B->>node D: 发送消息
        node C->>node C: 根据Topic 3,选择节点D
        node C->>node B: 发送消息

Broadcast process

sequenceDiagram
    participant node A
    participant node B
    participant node C
    participant node D

    节点A->>节点A: 遍历所有节点ID
    节点A->>节点B: 发送消息
    节点A->>节点C: 发送消息
    节点A->>节点D: 发送消息
    节点B->>节点B: 遍历所有节点ID
    节点B->>节点C: 发送消息
    节点B->>节点D: 发送消息
    节点C->>节点C: 遍历所有节点ID
    节点C->>节点D: 发送消息

Status synchronization

Each node maintains its own state, broadcasts the Seq of the state on the whole network at a fixed time, and synchronizes it with other nodes.

sequenceDiagram
    participant node A
    participant node B

    node A->node B: 广播seq
    node A->>node A: 判断节点B的seq是否变化
    node A->>node B: seq变化,发起状态查询请求
    node B->>node A: 返回节点状态
    node A->>node A: 更新节点B的状态和seq

results matching ""

    No results matching ""