Internet Computer 백서

Internet Computer

원문

bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 7쪽 중 6쪽

XxSJ4KkkP6rHoxWMF+wFtKJvNpl27yYbdiVBC/4MXD4p49f9489+4bXPQ1gcDj/dmmJkXpFIYdN1vZ219Y3Nru7RT3t3bPzisHB23jco04y2mpNLdgBouRcJbKFDybqo5jQPJO8H4duZ3nrg2QiUPOEm5H9NhIiLBKFqp3ZehQjOoVN2aOwdZJV5BqlCgOah89UPFspgnyCQ1pue5Kfo51SiY5NNyPzM8pWxMh7xnaUJjbvx8fu2UnFslJJHSthIkc/X3RE5jYyZxYDtjiiOz7M3E/7xehtG1n4skzZAnbLEoyiRBRWavk1BozlBOLKFMC3srYSOqKUMbUNmG4C2/vEra9Zp3WXPv69XGTRFHCU7hDC7AgytowB00oQUMHuEZXuHNUc6L8+58LFrXnGLmBP7A+fwBvSWPOw==</latexit> ... <latexit sha1_base64="bzlxl0nvFr5YEoK+AGgdk5clavg=">AAAB7XicbVBNS8NAEJ34WetX1aOXxSJ4KkkP6rHoxWMF+wFtKJvNpl27yYbdiVBC/4MXD4p49f9489+4bXPQ1gcDj/dmmJkXpFIYdN1vZ219Y3Nru7RT3t3bPzisHB23jco04y2mpNLdgBouRcJbKFDybqo5jQPJO8H4duZ3nrg2QiUPOEm5H9NhIiLBKFqp3ZehQjOoVN2aOwdZJV5BqlCgOah89UPFspgnyCQ1pue5Kfo51SiY5NNyPzM8pWxMh7xnaUJjbvx8fu2UnFslJJHSthIkc/X3RE5jYyZxYDtjiiOz7M3E/7xehtG1n4skzZAnbLEoyiRBRWavk1BozlBOLKFMC3srYSOqKUMbUNmG4C2/vEra9Zp3WXPv69XGTRFHCU7hDC7AgytowB00oQUMHuEZXuHNUc6L8+58LFrXnGLmBP7A+fwBvSWPOw==</latexit> ... Figure 4: Per-round certified state organized as a tree • Output authentication. Cross-subnet messages and responses to ingress messages are authenticated using per-round certified state. Using the Merkle tree structure, an individual output (cross-subnet message or ingress message response) may be authen- ticated to any party by providing a threshold signature on the root of the Merkle tree, along with hash values on (and adjacent to) the path in the Merkle tree from the root to the leaf representing that output. The number of hash values needed to authen- ticate an individual output is therefore proportional to the depth of the Merkle tree, which is typically quite small, even if the size of the Merkle tree is very large. Thus, a single threshold signature can be used to efficiently authenticate many individual outputs. • Preventing and detecting non-determinism. Consensus guarantees that each replica processes inputs in the same order. Since each replica processes these in- puts deterministically, each replica should obtain the same state. However, the IC is designed with an extra layer of robustness to prevent and detect any (accidental) non-deterministic computation, should it arise. The per-round certified state is one of the mechanisms used to do this. Since we use an ( n−f)-out-of-n threshold signature for certification, and since f < n/3, there can only be one sequence of states that is certified. To see why state chaining is important, consider the following example. Suppose we have 4 replicas, P1,P 2,P 3,P 4, and one is corrupt, say P4. Each of the replicas P1,P 2,P 3 start out in the same state. – In round 1, because of a non-deterministic computation, P1,P 2 compute a mes- sagem1 to send to subnet A, whileP3 computes a message m′1 to send to subnet A. – In round 2,P1,P 3 compute a messagem2 to send to subnetB, whileP2 computes a message m′2 to send to subnet B. 35 – In round 3,P2,P 3 compute a messagem3 to send to subnetC, whileP1 computes a message m′3 to send to subnet C. This is illustrated in the following table: P1 m1→A m 2→B m ′3→C P2 m1→A m ′2→B m 3→C P3 m′1→A m 2→B m 3→C We are assuming that replicas P1, P2, and P3 each individually perform a valid se- quence of computations, but that because of non-determinism, these sequences are not identical. (Even though there is not supposed to be any non-determinism, in this example, we are supposing that there is.) Now suppose we did not chain the states. BecauseP4 is corrupt and may sign anything, he could create a 3-out-of-4 signature on a round-1 state that says “ m1→ A”, and similarly on a round-2 state that says “ m2→ B”, and on a round-3 state that says “m3→C”, even though the corresponding sequence m1→A, m2→B, m3→C may not be compatible with any valid sequence of computations . Worse yet, such an invalid sequence of computations could then lead to inconsistent states on other subnets. By chaining, we ensure that even if there is some non-determinism, any sequence of certified states corresponds to some valid sequence of computations that was actually carried out by honest replicas. • Coordination with consensus. The per-round certified state is also used to coor- dinate the execution and consensus layers, in two different ways: – Consensus throttling. Each replica will keep track of the latest round for which it has a certified state — this is called the certified height. It will also keep track of the latest round for which it has a notarized block — this is called the notarized height. If the notarized height is significantly greater than the certified height, this is a signal that execution is lagging consensus, and that consensus needs to be throttled. This lagging could be due to non-deterministic computation, or it could just be due to a more benign performance mismatch between the layers. Consensus is throttled by means of the delay functions discussed in Section 5.9 — specifically, each replica will increase the “governor” valueϵ as the gap between notarized height and certified height grows (this makes use of the notion of “locally adjusted delay functions, as in Section 5.12.2). – State-specific payload validation. As discussed in Section 5.7, the inputs in a pay- load must pass certain validity checks. In fact, these validity checks may depend to a certain degree on the state. A detail we skipped is that each block includes a round number, with the understanding that these validity checks should be made with respect to the certified state for that round number. A replica that 36 needs to perform this validation will wait until the state for that round number has been certified, and then use the certified state for that round to perform the validation. This ensures that even with non-deterministic computation, all replicas are performing the same validity tests (as otherwise, consensus could get stuck). 6.2 Query calls vs update calls As we have described it so far, ingress messages must pass through consensus so that they are processed in the same order by all replicas on a subnet. However, an important optimization is available to those ingress messages whose processing does not modify the replicated state of a subnet. These are called query calls — as opposed to other ingress messages, which are called update calls. Query calls are allowed to perform computations which read and possibly update the state of a canister, but any updates to the state of a canister are never committed to the replicated state. As such, a query call may be processed directly by a single replica without passing through consensus, which greatly reduces the latency for obtaining a response from a query call. Note that a response to a query call is not recorded in the ingress history data structure. As such, we cannot directly use the per-round certified state mechanism to authenticate responses to query calls. However, a separate mechanism for authenticating such responses is provided: certified variables. As a part of the per-round certified state, each canister on a subnet is allocated a small number of bytes, which is the certified variable for that canister, whose value may be updated via update calls, and may be authenticated using the per-round certified state mechanism. Moreover, a canister may use its certified variable to store a root of a Merkle tree. In this way, a response to a query call to a canister may be authenticated so long the response is a leaf in the Merkle tree rooted at the certified variable for that canister. 6.3 External user authentication One of the main differences between an ingress message and a cross-subnet message is the mechanism used for authenticating these messages. We have already seen above (see Section 6.1) how threshold signatures are used to authenticate cross-subnet messages. The NNS registry (see Section 1.5) holds the public verification keys for the threshold signatures used to authenticate cross-subnet messages. There is no central registry for external users. Rather, an external user identifies himself to a canister using a user identifier (aka principal), which is a hash of a public signature- verification key. The user holds a corresponding secret signing key, which is used to sign ingress messages. Such a signature, as well as the corresponding public key, is sent along with the ingress message. The IC automatically authenticates the signature and passes the user identifier to the appropriate canister. The canister may then authorize the requested operation, based on the user identifier and other parameters to the operation specified in the ingress message. First-time users generate a key pair and derive their user identifier from the public key during their first interaction with the IC. Returning users are authenticated using the secret key that is stored by the user agent. A user may associate several key pairs with a single 37 user identity, using signature delegation. This is useful, as it allows a single user to access the IC from several devices using the same user identity. 7 Execution Layer The execution environment processes one input at a time. This input is taken from one of the input queues, and is directed to one canister. Based on this input and the state of the canister, the execution environment updates the state of the canister, and additionally may add messages to output queues and update the ingress history (possibly with a response to an earlier ingress message). In a given round, the execution environment will process several inputs. A scheduler determines which inputs are executed in a given round, and in which order. Without going into all the details of the scheduler, we highlight some of the goals: • it must be deterministic, i.e., only depend on the given data; • it should distribute workloads fairly among canisters (but optimizing for throughput over latency). • the total amount of work done in each round, measured in terms of cycles (see Sec- tion 1.8), should be close to some pre-determined amount. Another task that the execution environment (together with the message router) must deal with are situations where a canister on one subnet is producing cross-subnet messages faster than they can be consumed by a canister on another subnet. For this, a self-regulating mechanism is implemented that throttles the producing canister. There are many other resource management and bookkeeping tasks that are dealt with by the execution environment. However, all of these tasks must be dealt with determinis- tically. 7.1 Random tape Each subnet has access to a distributed pseudorandom generator (PRG) . As men- tioned in Section 3, pseudorandom bits are derived from a seed that itself is an ( f + 1)-out- of-n BLS signature, called the Random Tape. There is a different Random Tape for each round of the consensus protocol. While this BLS signature is similar to that used for the Random Beacon used in consensus (see Section 5.5), the mechanics are somewhat different. In the consensus protocol, as soon as a block at height h is finalized, each honest replica will release its share of Random Tape for height h + 1. This has two implications: 1. Before a block at height h is finalized by any honest replica, the Random Tape at heighth + 1 is guaranteed to be unpredictable. 2. By the time a block at height h + 1 is finalized by any honest replica, that replica will typically have all the shares it needs to construct the Random Tape at height h + 1. 38 To obtain pseudorandom bits, a subnet must make a request for these bits. Such a pseudorandom-bit request will be made as a “system call” from the execution layer in some round, say h. The system will then respond to that request later, when the Random Tape of height h + 1 is available. By property (1) above, it is guaranteed that the requested pseudorandom bits are unpredictable at the time the request is made. By property (2) above, the requested random bits will typically be available at the time the next block is finalized. In fact, in the current implementation, at the time a block of height h is finalized, the Consensus Layer (see Section 5) will deliver both (the payload of) the block of height h and the Random Tape of height h + 1 simultaneously to the message routing layer for processing. 8 Chain-key cryptography II: chain-evolution technology As mentioned in Section 1.6.2, chain-key cryptography includes a collection of technologies for robustly and securely maintaining a blockchain-based replicated state machine over time, which together form what is called chain-evolution technology. Each subnet operates in epochs of many rounds (typically on the order of a few hundreds of rounds). Chain- evolution technology implements many essential maintenance activities that are executed periodically with a cadence that is tied to epochs: garbage collection, fast forwarding, subnet membership changes, pro-active resharing of secrets, and protocol upgrades. There are two essential ingredients to chain-evolution technology: summary blocks and catch-up packages (CUPs). 8.1 Summary blocks The first block in each epoch is a summary block . A summary block contains special data that will be used to manage the shares of the various threshold signature schemes (see Section 3). There are two threshold schemes: • one (f + 1)-out-of-n scheme, for which a new signing key is generated every epoch; • one (n−f)-out-of-n scheme, for which the signing key is reshared once every epoch. The low-threshold scheme is used for the random beacon and the random tape, while the high-threshold scheme is used to certify the replicated state of the subnet. Recall that the DKG protocol (see Section 3.5) requires that for each signing key, we have a set of dealings, and that each replica can non-interactively obtain its share of the signing key from this set of dealings. Also recall that NNS maintains a registry that, among other things, determines the membership of a subnet (see Section 1.5). The registry (and hence the subnet membership) may change over time. Thus, subnets must agree on which registry version they use at various times for various purposes. This information is also stored in the summary block. The summary block for epoch i contains the following data fields. • currentRegistryVersion. This registry version will determine the consensus committee used throughout epoch i — all tasks performed by the consensus layer (block making, notarization, finalization) will be performed by this committee. 39 • nextRegistryVersion. In each round of consensus, a block maker will include in its proposal the latest registry version it knows about (which must be no earlier than the block the proposed block extends). This ensures that the value nextRegistryVersion in the summary block of epoch i is fairly up to date. The value of currentRegistryVersion in epoch i is set to the value of nextRegistryVer- sion in epoch i− 1. • currentDealingSets. These are the dealing sets that determine the threshold signing keys that will be used to sign messages in epoch i. As we will see, the threshold signing committee for epoch i (i.e., the replicas that hold the corresponding threshold signing key shares) is the consensus committee for epoch i− 1 . • nextDealingSets. This is where dealings that are collected during epoch i− 1 are gathered and stored. 6 The value of currentDealingSets in epoch i will be set to the value of nextDealingSets in epoch i− 1 (which itself consists of dealings collected in epoch i− 2). • collectDealingParams. This describes the parameters that define the dealing sets to be collected during epoch i. During epoch i, block makers will include dealings in their proposed blocks that are validated relative to these parameters. The receiving committee for these dealings is based on the nextRegistryVersion value of the summary block of epoch i. For the low-threshold scheme, the dealing committee is the consensus committee for epoch i. For the high-threshold scheme, the shares to be reshared are based on the value of nextDealingSets of epochi. Therefore, the dealing committeeis the receiving committee for epoch i− 1, which is also the consensus committee for epoch i . Also observe that thethreshold signing committeefor epochi is the receiving committee in epoch i− 2, which is the consensus committee for epoch i− 1 . Consensus in epochi relies on the values currentRegistryVersionand currentDealingSets in epochi — in particular, the makeup of the consensus committee itself is based on curren- tRegistryVersion and the random beacon used in consensus is based on currentDealingSets. Moreover, just like any other block, there could be more than one summary block notarized at the beginning of epoch i, and that ambiguity needs to be resolved by consensus in epoch i. This seeming circularity is resolved by insisting that a summary block at the beginning of epoch i−1 has been finalized before epoch i starts, since the relevant values in the newer summary block are copied directly from that older summary block. This is actually an implicit synchrony assumption , but it is quite an academic assumption. Indeed, because of the “consensus throttling” discussed in Section 5.12.2 to ensure liveness, and because of 6A detail we have omitted is that if we fail to collect all the required dealings in epoch i − 1, then as a fallback, the value of nextDealingSets in epoch i will effectively be set to the value of currentDealingSets in epoch i. If this happens, then the protocol will make use of dealing committees and threshold signing committees from further in the past, as appropriate. 40 the length of an epoch is quite large, this can essentially never happen in practice: long before consensus could reach the end of epoch i− 1 without finalizing a summary block for epoch i− 1, the notarization delay function would grow to be astronomically large, and so the partial synchrony assumption needed for finalization will be satisfied (essentially) with certainty (for all practical purposes). 7 8.2 CUPs Before describing a CUP, we first point out one detail of random beacon: the random beacon for each round depends on the random beacon for the previous round. This is not an essential feature, but it impacts the design of the CUP. A CUP is a special message (not on the blockchain) that has (mostly) everything a replica needs to begin working in a given epoch, without knowing anything about previous epochs. It consists of the following data fields: • The root of a Merkle hash tree for the entire replicated state (as opposed to the partial, per-round certified state as in Section 6.1). • The summary block for the epoch. • The random beacon for the first round of the epoch. • A signature on the above fields under the ( n−f)-out-of-n threshold signing key for the subnet. To generate a CUP for a given epoch, a replica must wait until the summary block for that epoch is finalized and the corresponding per-round state is certified. As already mentioned, the entire replicated state must be hashed as a Merkle tree — even though a number of techniques are used to accelerate this process, this is still quite expensive, which is why it is only done once per epoch. Since a CUP contains only the root of this Merkle tree, a special state sync subprotocol is used that allows a replica to pull any state that it needs from its peers — again, a number of techniques are used to accelerate this process, but it is still quite expensive. Since we are using a high-threshold signature for a CUP, we can be sure that there is only one valid CUP in any epoch, and moreover, there will be many peers from which the state may be pulled. Also, since the public key of the threshold signature scheme remains constant over time, the CUP can be validated without knowing the current participants of the subnet. 8.3 Implementing chain-evolution technology Garbage collection: Because of the information contained in a CUP for a given epoch, it is safe for each replica to purge all inputs that have been processed, and all consensus- level protocol messages needed to order those inputs
프로젝트로 돌아가기