The decentralization framework UniDAG

Yevhenii Doshyn
7 min readApr 2, 2018

The decentralization framework UniDAG is a set of software and libraries for creating a replicated distributed database, based on the dagchain, a clear network architecture and UniDAG consensus algorithm.

Network Architecture

The UniDAG network consists of a peer-to-peer and, simultaneously, Client-Server network from various devices. In addition, a three-tier architecture is used to increase scalability and configurability.

All devices connected to the network are divided into 2 types: Client and Node (Server).

A,B,C — Node.

a — Client.

Client — a device that uses data from the client layer and the logic layer. The number of clients is unlimited. Any device can act as a client, performing the conditions of protection and consensus.

Node — a device that uses data from the logic layer and the database layer. The number of nodes obeys the rule 2k + 1, where k is a positive integer (1,2,3 … etc.). As a rule, powerful computers should act as nodes. The main part of the logic layer is executed on them. All connected nodes are a decentralized peer-to-peer network.

Three-tier architecture

X — program layer of the client.

Y1 — logic layer on the client side.

Y2 — logic layer on the node side.

Z — database layer.

The client layer is an interface layer that is responsible for displaying information on the user’s end devices and creating a data block.

A logic layer is the main layer that performs data processing functions and is the middleman between the client layer and the database layer.

A database layer is a layer that provides data storage.

Consensus of the node

A 50% + 1 rule is used to achieve consensus between nodes. It means that, in case of disagreement, the system makes a decision true to (k + 1) nodes, where (2k + 1) is the total number of nodes.

Identifying devices

To achieve a consensus between network devices and provide protection from potential attacks, they must be identified and unified in a certain way.

For nodes, there is a permanent scheme for sequentially assigning the corresponding sequence numbers in the form of integers from 1 to (2k + 1), where (2k + 1) is the total number of nodes.

1, 2, 3, k, (k+1) — node identifiers.

For clients, another identification scheme operates. It is based on the identifier that is generated in the client layer, then the predefined period in the database layer is preserved. If this is set by network parameters, it is removed from the database.

General circuit diagram

To build the Dagchain UniDAG, the unit with data is taken as the basic unit. The dagchain block also contains, as in the classical block, the header and the transmitted data. The header consists of the technical characteristics of the block, which are added as they are formed and processed both on the client side and on the node side. The block contains data generated by only one client.

A — Block header.

В — Data.

When adding a block to the UniDAG network, it ‘signs’ strictly 2 previous blocks, adding data about them to its header according to predetermined algorithms and excluding the possibility of ‘branching’. Special are the first two ‘genesis’ blocks, which ‘sign’ 0 and 1 block respectively.

Each block transmitted by the client is sequentially assigned its integer sequence number N with an increase of 1 from the beginning of the chain and adding this number to the block header.

t — Time.

1 , 2 , 3 , N , (N+1) , (N+2) — serial numbers

General principle of network operation

The client, using the connected device to the network, creates a data block. The logic layer on the client side processes it with the client’s identifier added to the header. One of the nodes takes the block and, at the same time, immediately retransmits it to the remaining nodes, adding its identifier and the assigned sequence number to the block header. As a result, the header of the block written in the circuit is expanded by additional two parameters. After this, on the side of the node, the logic layer continues processing the data according to the predetermined algorithms and adds the block to the circuit.

X — client identifier.

А1 , А2 , А3 — node identifier (sequence number).

N — sequence number of the block.

UniDAG Consensus Algorithm

Consensus UniDAG is a specific rule by which the identical order of blocks on all nodes is preserved.

When building a chain of blocks, two situations are possible:

  1. Clients send transactions at different times, and completely all the nodes manage to process them and consecutively write them into the chain.

t ( x ) < t ( y ) < t ( z) , where t — Time.

The chain of blocks then acquires this form:

Note: the first three blocks also have their own identifier parameters.

In this situation, the blocks are written to the chain without conflicts and don’t require strict rules of priority.

2. Clients send the formed blocks in one or very small amount of time, when all nodes can’t process them and write them in a strict identical sequence. In practice, this means that the sequence numbers of the blocks coincide.

To achieve consensus, the system uses the ‘recording delay’ parameter and the node identifier rule.

  • Record latency is a system parameter that regulates the processing time of blocks before writing to the circuit. It is set in automatic or manual mode. The parameter must satisfy the requirement to maintain consensus. It is based on the time of the initial block processing by the node and the maximum block transfer time between the nodes.

T = ( tp+tt) * s

T — recording delay.

tp— initial block processing time.

tt— the maximum block transfer time between nodes.

s — coefficient of stability. It is necessary for continuous operation of the system in the case of short-term changes tp and tt .

  • The rule of node identifiers: a block with a smaller node identifier is assigned the first sequence number, and the block with a large node identifier is assigned the following.

A1 < A2 ➝ NA1 < NA2

N — block sequence number.

A — node identifier.

t ( x ) ≈ t ( y ) ≈ t ( z ), where t — Time.

A1 < A2 < A3

Each node receives 3 blocks with the same sequence numbers N. During the time specified by the ‘record delay’ system parameter, each node processes and records them to the dagchain chain according to consensus.

( X , A1 , N ) | ( Y , A2 , N ) | ( Z , A3 , N ) ➝

( X , A1 , N ) | ( Y , A2 , N +1 ) | ( Z , A3 , N +2 )

T — record delay.

Let’s consider one more case of the scheme of work of these 2 rules.

Clients with identifiers x, y, z send blocks in a short period of time to two different nodes having identifiers A1, A2 respectively.

t ( x ) ≈ t ( y ) < t ( z ), where t — Time.

A1 < A2 < A3 .

According to the condition, one of the nodes takes 1 block, and the other node 2 blocks. The first node assigns the sequence number N to the block X, and the second node, in order of priority, the numbers N and (N + 1) to the blocks from Y and Z, respectively. After processing, in the time specified by the ’record delay’ system parameter, the blocks with client identifiers X, Y, Z are assigned the serial numbers N, (N + 1) and (N + 2), respectively, and they are added to the dagchain.

( X , A1 , N ) | ( Y , A2 , N ) | ( Z , A2 , N+1 ) ➝

( X , A1 , N ) | ( Y , A2 , N +1 ) | ( Z , A2 , N +2 )

T — record delay.

In case of other possible conflicts, the rule of node consensus is applied, that is, the chain that is written in (50% + 1) node is considered correct.

Network security

Network security directly depends on the configuration settings, such as: hashing algorithm, “record delay”, data transfer method, etc. at various stages of the work of specific implementations.

It is fourth part of our main document. You can read others here:

Part 1: Philosophy of the world UniDAG

Part 2: UniDAG Backup Framework

Part 3: UniDAG Backup Framework

Part 5: Software Development Kit UniDAG

Part 6: Features and practical applications of UniDAG

For more information,please visit http://www.unidag.world

--

--