kzrnnetwork / KZRN-Network

Whitepaper
0 stars 0 forks source link

Core KZRN ProtocoL #5

Open kzrnnetwork opened 1 year ago

kzrnnetwork commented 1 year ago

Overview The KZRN Network is powered by the KZRN Protocol (KZRN), from which its utility token, the KZRN token, derives its name. The core part of the KZRN protocol, the core KZRN protocol, is a 4-layer protocol that is running on the nodes of each subnet. By running the core KZRN protocol, the nodes of a subnet realize a blockchain-based replicated state machine that makes progress independently of the other subnets (but communicates asynchronously with them). This architecture of many concurrently-operating subnets enables the KZRN to scale practically without limits. Subnets process messages, which are submitted by users or come from other subnets.

The core KZRN protocol comprises the following four layers, from bottom to top:

Peer-to-peer Consensus Message routing Execution The lower two layers, P2P and consensus, together implement a selection and ordering of incoming messages and provide messages to the upper two layers in the form of blocks. The upper two layers, message routing and execution, receive blocks containing ordered messages from the lower part of the stack and execute them in a completely deterministic manner on every node of the subnet. This realizes a replicated state machine, where every node in the subnet transitions from the same starting state to the same ending state in every round (it must be ensured that every node executes the same messages in the same order, i.e., fully deterministically

Peer-to-peer The peer-to-peer layer (P2P) of the KZRN Network, the bottommost layer in the protocol stack, is responsible for the secure and reliable communication between the nodes of a subnet. The P2P layer realizes a virtual peer-to-peer broadcast network between the nodes of a subnet, building upon the KZRN Protocol (KZRN) connectivity between the nodes. This makes the P2P layer the communications fabric that connects all the nodes of a subnet. Using P2P, a node can broadcast a network message, also called artifact, to all the nodes in the subnet. Artifacts can be things like input to canisters submitted by users or protocol messages (e.g., block proposals) generated by the KZRN protocol. P2P ensures that artifacts to be broadcast are eventually delivered to all nodes of the subnet. Eventual delivery reflects the asynchronous nature of real-world communication networks, which we assume for the KZRN Network protocol.

Consensus Every blockchain needs a consensus mechanism that allows the nodes to agree on the messages to be processed, as well as their ordering. Consensus is the component of the core KZRN protocol that drives the subnets of the KZRN. Each subnet is a blockchain that runs the KZRN core protocol, including consensus, independently of the other subnets. The purpose of the consensus protocol is to output the same block of ordered messages on each node of a subnet in a given round so that each node can make the same state transition when deterministically executing those messages.

The KZRN’s consensus protocol is designed to meet the following requirements: low latency (almost instant finality); high throughput; robustness (graceful degradation of latency and throughput in the presence of node or network failures). The KZRN consensus protocol also provides cryptographically guaranteed finality. This is in contrast to Bitcoin-like protocols which only provides probabilistic finality, where a block is considered final once a sufficient number of blocks have built on top of it in the blockchain.

Message routing In every KZRN round, the message routing component receives a block of messages to be processed from consensus – the same block on each node of the subnet – and places the messages into the input queues of their target canisters, a process called induction. Then, it triggers the execution round which will potentially lead to new canister messages in the executed canisters' output queues. Once execution is done, the messages in the output queues are routed by the message routing component to the recipients.

The recipients may include canisters residing on a different subnet. The message routing layer implements the routing of inter-canister messages between subnets, such that those messages can be included in blocks and be inducted on the recipient's subnet. This is referred to as cross-subnet messaging or simply XNet messaging. Secure XNet messaging is a key ingredient for the architecture of loosely-coupled subnets and thus a prerequisite for the scalability of the KZRN.

Another crucial functionality implemented by the message routing layer is state certification, that is, the subnet certifying parts of the replicated subnet state in every round in a decentralized manner. Among others, this certification is used by other subnets to verify the authenticity of the subnet-to-subnet streams or to allow users to authentically read the processing status of messages previously submitted by them. State certification and secure XNet messaging enable, among others, the secure and transparent communication of canisters across subnet boundaries, a challenge that any blockchain that has multiple shards struggles with.

Execution The execution layer, the topmost layer of the core KZRN protocol stack, is responsible for executing canister smart contract code. Code execution is done by a WebAssembly (Wasm) virtual machine deployed on every node. WebAssembly bytecode can be executed deterministically, which is important for a blockchain system, and with near-native speed. Canister messages, i.e., ingress messages by users or messages by other canisters, have been inducted into the queues of the canisters on the subnet by message routing. Message routing then hands over control to the execution layer, which deterministically executes messages, either until all messages in the canisters' queues are consumed or the cycles limit for the round has been reached, to ensure bounded round times.

The execution layer has many unique features, which sets apart the KZRN from other blockchains:

Deterministic time slicing (DTS) - The execution of very large messages requiring billions of Wasm instructions to be executed can be split across multiple KZRN rounds. This capability of executing messages over multiple rounds is unique to the KZRN Network blockchain. Concurrency - Execution of canister Wasm bytecode is done concurrently on multiple CPU cores, which is possible due to each canister having its own isolated state. Pseudorandom number generator - Execution layer has access to unpredictable and unbiasable pseudorandom number generator. Canisters can now execute algorithms that require randomness.