Difference between revisions of "Replicated state structure"

From Internet Computer Wiki
Jump to: navigation, search
Line 15: Line 15:
 
** Controllers - Each canister can have a (possibly empty) list of controllers. A controller of a canister has the ability to upgrade, stop or delete the canister.  
 
** Controllers - Each canister can have a (possibly empty) list of controllers. A controller of a canister has the ability to upgrade, stop or delete the canister.  
 
** Module hash - Each canister runs a Web Assembly (WASM) module. Module hash is the hash of the module.  
 
** Module hash - Each canister runs a Web Assembly (WASM) module. Module hash is the hash of the module.  
 +
** Metadata - Metadata contains a bunch of key-value pairs. When a WASM module is installed into the canister, the nodes look into "Custom Section" of the WASM module and place the data as metadata of the canister. The most common use cases of metadata are to store candid interface of the canister and git repository link of the canister code. 
 
** Certified state - A canister can choose to store a part of its state in the certified_state path.  
 
** Certified state - A canister can choose to store a part of its state in the certified_state path.  
 
* Subnet - We store some relevant information related to all the other subnets. Specifically,  
 
* Subnet - We store some relevant information related to all the other subnets. Specifically,  

Revision as of 23:47, 10 November 2022

This Page is Still Work in Progress

Each node of the Internet Computer maintains a state. The state includes the data related to canisters, the messages processed by the node, responses generated after processing the messages, etc. A portion of the state is individual to each node (Eg: messages received in the peer-to-peer layer, cryptographic key material). A portion of the state is identical for all the honest nodes in the subnet. This portion of the state is called replicated state of the subnet. In this article, we describe the structure of the replicated state stored on the Internet Computer.

Per-round Certified State

In each consensus round, one of the nodes in the subnet proposes a new block. The nodes in the subnet execute the consensus protocol to finalize one block per consensus round. Finalized blocks are passed onto the message routing layer. Message routing layer routes each message in the block into the appropriate input queue of the target canister.

For each canister C running on a subnet, there are several input queues. There is one input queue specifically for ingress messages (sent by the external users) to C. For each other canister C′, with whom C communicates, there is one input queue. This input queue is used to store cross-subnet messages received from canister C'. In each round, the execution layer will consume some of the inputs in these queues, update the replicated state of the relevant canisters, and place outputs in ingress history and various output queues. Ingress history is used store the responses generated by the canister on processing ingress messages. For each canister C running on a subnet, there are several output queues. For each other canister C′, with whom C communicates, there is one output queue. This output queue is used to store cross-subnet messages to be sent from C to C'.

After the round, each node in the subnet stores some relevant information related to the round execution in a tree structure as shown below. The execution layer is designed to execute all the canisters deterministically. Therefore, each node in the subnet should independently create at the same tree. Each node then create a Merkle tree by hashing the below tree, sign the root hash using their threshold signing key, and broadcast their signature share to rest of the nodes in the subnet. On receiving the signature shares from peers, each node then combines the signature shares to create a signature of the root hash. We now consider the tree as certified by the nodes in the subnet. The below state tree along with its signature is called Per-round certified state.

Caption

In the per-round state tree, we store the following information.

  • Time - Height of the blockchain for which the tree is generated.
  • Metadata - Metadata of the subnet.
  • Canister - For each canister running on the subnet, we store its certified state, module hash, controllers and metadata.
    • Controllers - Each canister can have a (possibly empty) list of controllers. A controller of a canister has the ability to upgrade, stop or delete the canister.
    • Module hash - Each canister runs a Web Assembly (WASM) module. Module hash is the hash of the module.
    • Metadata - Metadata contains a bunch of key-value pairs. When a WASM module is installed into the canister, the nodes look into "Custom Section" of the WASM module and place the data as metadata of the canister. The most common use cases of metadata are to store candid interface of the canister and git repository link of the canister code.
    • Certified state - A canister can choose to store a part of its state in the certified_state path.
  • Subnet - We store some relevant information related to all the other subnets. Specifically,
  • Request data -
  • Streams -

Total Replicated State