Sui 백서

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

n object reference consists of an object ID, an object version, and the hash of the object value. The Sui runtime will resolve both object ID’s and object references to object values stored in the global object pool. For object references, the runtime will check the version of the reference against the version of the object in the pool, as well as checking that the reference’s hash matches the pool object. This ensures that the runtime’s view of the object matches the transaction sender’s view of the object. In addition, a call transaction accepts type arguments and pure value arguments. Type arguments instantiate generic type parame- ters of the entrypoint function to be invoked (e.g., if the entrypoint function is send_coin<T>(c: Coin<T>, ...) , the generic type pa- rameter T could be instantiated with the type argument SUI to send the Sui native token). Pure values can include primitive types and vectors of primitive types, but not struct types. The function to be invoked by the call is specified via an object reference (which must refer to a package object), a name of a module in that package, and a name of a function in that package. To execute a call transaction, the Sui runtime will resolve the function, bind the type, object, and value arguments to the function parameters, and use the Move VM to execute the function. Both call and publish transactions are subject to gas metering and gas fees. The metering limit is expressed by a maximum gas budget. The runtime will execute the transaction until the budget is reached, and will abort with no effects (other than deducting fees and reporting the abort code) if the budget is exhausted. The fees are deducted from a gas object specified as an object reference. This object must be a Sui native token (i.e., its type must be Coin<SUI>). Sui uses EIP15594-style fees: the protocol defines a base fee (denominated in gas units per Sui token) that is algorith- mically adjusted at epoch boundaries, and the transaction sender can also include an optional tip (denominated in Sui tokens). Under normal system load, transactions will be processed promptly even with no tip. However, if the system is congested, transactions with a larger tip will be prioritized. The total fee deduced from the gas object is(GasUsed∗ BaseFee)+ Tip. 3.6 Transaction Effects Event = StructType× Struct Create = Obj Update = Obj Wrap = ObjID× Version Delete = ObjID× Version ObjEffect = Create⊎ Update⊎ Wrap⊎ Delete AbortCode = N× ModuleName SuccessEffects = [ObjEffect]×[ Event] AbortEffects = AbortCode TxEffects = SuccessEffects⊎ AbortEffects Table 6: Transaction Effects Transaction execution generates transaction effects which are dif- ferent in the case when execution of a transaction is successful (SuccessEffects in Table 6) and when it is not ( AbortEffects in Table 6). 4https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1559.md The Sui Smart Contracts Platform Upon successful transaction execution, transaction effects in- clude information about changes made to Sui’s global object pool (including both updates to existing objects and freshly created ob- jects) and events generated during transaction execution. Another effect of successful transaction execution could be object removal (i.e., deletion) from the global pool and also wrapping (i.e., embed- ding) one object into another, which has a similar effect to removal – a wrapped object disappears from the global pool and exists only as a part of the object that wraps it. Since deleted and wrapped objects are no longer accessible in the global pool, these effects are represented by the ID and version of the object. Events encode side effects of successful transaction execution beyond updates to the global object pool. Structurally, an event consists of a Move struct and its type. Events are intended to be consumed by actors outside the blockchain, but cannot be read by Move programs. Transactions in Move have an all-or-nothing semantics – if ex- ecution of a transaction aborts at some point (e.g., due to an un- expected failure), even if some changes to objects had happened (or some events had been generated) prior to this point, none of these effects persist in an aborted transaction. Instead, an aborted transaction effect includes a numeric abort code and the name of a module where the transaction abort occurred. Gas fees are still charged for aborted transactions. 4 THE SUI SYSTEM In this section we describe Sui from a systems’ perspective, includ- ing the mechanisms to ensure safety and liveness across authorities despite Byzantine failures. We also explain the operation of clients, including light clients that need some assurance about the system state without validating its full state. Brief background. At a systems level Sui is an evolution of the FastPay [3] low-latency settlement system, extended to operate on arbitrary objects through user-defined smart contracts, and with a permissionless delegated proof of stake committee composition [2]. Basic asset management by object owners is based on a variant of Byzantine consistent broadcast [6] that has lower latency and is easier to scale across many machines as compared to traditional implementations of Byzantine consensus [8, 11, 12].When full agree- ment is required we use a high-throughput DAG-based consensus, e.g. [9] to manage locks, while execution on different shared objects is parallelized. Protocol outline. Figure 1 illustrates the high-level interactions between a client and Sui authorities to commit a transaction. We describe them here briefly: • A user with a private signing key creates and signs a user transaction to mutate objects they own, or shared objects, within Sui. Subsequently, user signature keys are not needed, and the remaining of the process may be performed by the user client, or a gateway on behalf of the user (denoted as keyless operation in the diagram). • The user transaction is sent to the Sui authorities, that each check it for validity, and upon success sign it and return the signed transaction to the client. The client collects the re- sponses from a quorum of authorities to form a transaction certificate. • The transaction certificate is then sent back to all author- ities, and if the transaction involves shared objects it is also sent to a Byzantine agreement protocol operated by the Sui authorities. Authorities check the certificate, and in case shared objects are involved also wait for the agree- ment protocol to sequence it in relation to other shared object transactions, and then execute the transaction and summarize its effects into a signed effects response. • Once a quorum of authorities has executed the certificate its effects are final (denoted as finality in the diagram). Clients can collect a quorum of authority responses and create an effects certificate and use it as a proof of the finality of the transactions effects. This section describes each of these operations in detail, as well as operations to reconfigure and manage state across authorities. 4.1 System Model Sui operates in a sequence of epochs denoted by𝑒∈{ 0,... }. Each epoch is managed by a committee𝐶𝑒 =(𝑉𝑒,𝑆𝑒(·)) , where𝑉𝑒 is a set of authorities with known public verification keys and network end-points. The function 𝑆𝑒(𝑣) maps each authority 𝑣∈ 𝑉𝑒 to a number of units of delegated stake. We assume that 𝐶𝑒 for each epoch is signed by a quorum (see below) of authority stake at epoch 𝑒− 1. (Sect. 4.7 discusses the formation and management of commit- tees). Within an epoch, some authorities are correct (they follow the protocol faithfully and are live), while others are Byzantine (they de- viate arbitrarily from the protocol). The security assumption is that the set of honest authorities𝐻𝑒⊆𝑉𝑒 is assigned a quorum of stake within the epoch, i.e. ˝ℎ∈𝐻𝑒𝑆𝑒(ℎ) > 2/3 ˝𝑣∈𝑉𝑒𝑆𝑒(𝑣) (and refer to any set of authorities with over two-thirds stake as a quorum). There exists at least one live and correct party that acts as arelay for each certificate (see Sect. 4.3) between honest authorities. This ensures liveness, and provides an eventual delivery property to the Byzantine broadcast (see totality of reliable broadcast in [6]). Each authority operates such a relay, either individually or through a col- lective dissemination protocol. External entities, including Sui light clients, replicas and services may also take on this role. The distinc- tion between the passive authority core, and an internal or external active relay component that is less reliable or trusted, ensures a clear demarcation and minimization of the Trusted Computing Base [15] on which Sui’s safety and liveness relies. 4.2 Authority & Replica Data Structures Sui authorities rely on a number of data structures to represent state. We define these structures based on the operations they support. They all have a deterministic byte representation. An Object (Obj) stores user smart contracts and data within Sui. They are the Sui system-level encoding of the Move objects introduced in Sect. 2. They support the following set of operations: • ref(Obj) returns the reference (ObjRef) of the object, namely a triplet (ObjID, Version, ObjDigest). ObjID is practically and The MystenLabs Team Key Interaction to Process Transaction Client User Transaction Collect Transaction Certificate Effects Certificate Finality Collect Keyless Operation Authorities Process Transaction Process Certificate Shared Objects only Consensus Byzantine Agreement Figure 1: Outline of interactions to commit a transaction. unique for all new objects created, and Version is an in- creasing positive integer representing the object version as it is being mutated. • owner(Obj) returns the authenticator Auth of the owner of the object. In the simplest case, Auth is an address, repre- senting a public key that may use this object. More complex authenticators are also available (see Sect. 4.4). • read-only(Obj) returns true if the object is read-only. Read- only objects may never be mutated, wrapped or deleted. They may also be used by anyone, not just their owners. • parent(Obj) returns the transaction digest (TxDigest) that last mutated or created the object. • contents(Obj) returns the object type Type and data Data that can be used to check the validity of transactions and carry the application-specific information of the object. The object reference ( ObjRef) is used to index objects. It is also used to authenticate objects since ObjDigest is a commitment to their full contents. A transaction (Tx) is a structure representing a state transition for one or more objects. They support the following set of operations: • digest(Tx) returns the TxDigest, which is a binding crypto- graphic commitment to the transaction. • epoch(Tx) returns the EpochID during which this transac- tion may be executed. • inputs(Tx) returns a sequence of object[ObjRef] the trans- action needs to execute. • payment(Tx) returns a reference to an ObjRef to be used to pay for gas, as well as the maximum gas limit, and a conversion rate between a unit of gas and the unit of value in the gas payment object. • valid(Tx,[Obj]) returns true if the transaction is valid, given the requested input objects provided. Validity is discussed in Sect. 4.4, and relates to the transactions being authorized to act on the input objects, as well as sufficient gas being available to cover the costs of its execution. • exec(Tx,[Obj]) executes the transaction and returns a struc- ture Effects representing its effects. A valid transaction ex- ecution is infallible, and its output is deterministic. A transaction is indexed by its TxDigest, which may also be used to authenticate its full contents. All valid transactions (except the special hard-coded genesis transaction) have at least one owned input, namely the objects used to pay for gas. A transaction effects (Effects) structure summarizes the outcome of a transaction execution. It supports the following operations: • digest(Effects) is a commitment EffDigest to the Effects structure, that may be used to index or authenticate it. • transaction(Effects) returns the TxDigest of the executed transaction yielding the effects. • dependencies(Effects) returns a sequence of dependencies [TxDigest] that should be executed before the transaction with these effects may execute. • contents(Effects) returns a summary of the execution.Status reports the outcome of the smart contract execution. The lists Created, Mutated, Wrapped, Unwrapped and Deleted, list the object references that underwent the respective op- erations. And Events lists the events emitted by the execu- tion. A transaction certificate TxCert on a transaction contains the transaction itself as well as the identifiers and signatures from a quorum of authorities. Note that a certificate may not be unique, in that the same logical certificate may be represented by a different set of authorities forming a quorum. Additionally, a certificate might not strictly be signed by exactly a 2/3 quorum, but possibly more if more authorities are responsive. However, two different valid certificates on the same transaction should be treated as represent- ing semantically the same certificate. A partial certificate (TxSign) contains the same information, but signatures from a set of author- ities representing stake lower than the required quorum, usually a single authority. The identifiers of signers are included in the certificate (i.e., accountable signatures [? ]) to identify authorities The Sui Smart Contracts Platform ready to process the certificate, or that may be used to download past information required to process the certificate (see Sect. 4.8). Similarly, an effects certificate EffCert on an effects structure contains the effects structure itself, and signatures from authorities5 that represent a quorum for the epoch in which the transaction is valid. The same caveats, about non-uniqueness and identity apply as for transaction certificates. A partial effects certificate, usually containing a single authority signature and the effects structure is denoted as EffSign. Persistent Stores. Each authority and replica maintains a set of persistent stores. The stores implement persistent map seman- tics and can be represented as a set of key-value pairs (denoted 𝑚𝑎𝑝[𝑘𝑒𝑦]→ 𝑣𝑎𝑙𝑢𝑒 ), such that only one pair has a given key. Before a pair is inserted a contains(𝑘𝑒𝑦) call returns false, and get(𝑘𝑒𝑦) returns an error. After a pair is insertedcontains(𝑘𝑒𝑦) calls returns true, and get(𝑘𝑒𝑦) return the value. An authority maintains the following persistent stores: • The order lock map Lock𝑣[ObjRef] →TxSignOption re- cords the first valid transaction Tx seen and signed by the authority for an owned object version ObjRef, or None if the object version exists but no valid transaction using as an input it has been seen. It may also record the first certificate seen with this object as an input. This table, and its update rules, represents the state of the distributed locks on objects across Sui authorities, and ensures safety under concurrent processing of transactions. • The certificate map Ct𝑣[TxDigest] → (TxCert, EffSign) records all full certificates TxCert, which also includes Tx, processed by the authority within their validity epoch, along with their signed effects EffSign. They are indexed by transaction digest TxDigest • The object map Obj𝑣[ObjRef]→ Obj records all objects Obj created by transactions included in certificates within Ct𝑣 indexed by ObjRef. This store can be completely de- rived by re-executing all certificates inCt𝑣. A secondary in- dex is maintained that maps ObjID to the latest object with this ID. This is the only information necessary to process new transactions, and older versions are only maintained to facilitate reads and audit. • The synchronization map Sync𝑣[ObjRef]→ TxDigest in- dexes all certificates within Ct𝑣 by the objects they create, mutate or delete as tuples ObjRef. This structure can be fully re-created by processing all certificates in Ct𝑣, and is used to help client synchronize transactions affecting objects they care about. Authorities maintain all four structures, and also provide access to local checkpoints of their certificate map to allow other authori- ties and replicas to download their full set of processed certificates. A replica does not process transactions but only certificates, and re-executes them to update the other tables as authorities do. It also maintains an order lock map to audit non-equivocation. 5Note that if the signature algorithm permits it, authority signatures can be compressed, but always using accountable signature aggregation, because tracking who signed is important for gas profit distribution and other network health measurements. An authority may be designed as a full replica maintaining all four stores (and checkpoints) to facilitate reads and synchroniza- tion, combined with a minimal authority core that only maintains object locks and objects for the latest version of objects used to pro- cess new transactions and certificates. This minimizes the Trusted Computing Base relied upon for safety. Only the order lock map requires strong key self-consistency, namely a read on a key should always return whether a value or None is present for a key that exists, and such a check should be atomic with an update that sets a lock to a non-None value. This is a weaker property than strong consistency across keys, and allows for efficient sharding of the store for scaling. The other stores may be eventually consistent without affecting safety. 4.3 Authority Base Operation Process Transaction. Upon receiving a transactionTx an authority performs a number of checks: (1) It ensures epoch(Tx) is the current epoch. (2) It ensures all object referencesinputs(Tx) and the gas object reference in payment(Tx) exist within Obj𝑣 and loads them into[Obj]. For owned objects the exact reference should be available; for read-only or shared objects the object ID should exist. (3) Ensures sufficient gas can be made available in the gas object to cover the cost of executing the transaction. (4) It checks valid(Tx,[Obj]) is true. This step ensures the au- thentication information in the transaction allows access to the owned objects. (5) It checks that Lock𝑣[ObjRef] for all owned inputs(Tx) ob- jects exist, and it is either None or set to the same Tx, and atomically sets it to TxSign. (We call these the ‘locks checks’). If any of the checks fail processing ends, and an error is returned. However, it is safe for a partial update ofLock𝑣 to persist (although our current implementation does not do partial updates, but atomic updates of all locks). If all checks are successful then the authority returns a signature on the transaction, ie. a partial certificate TxSign. Processing an order is idempotent upon success, and returns a partial certificate (TxSign), or a full certificate (TxCert) if one is available. Any party may collate a transaction and signatures ( TxSign) for a set of authorities forming a quorum for epoch 𝑒, to form a transaction certificate TxCert. Process Certificate. Upon receiving a certificate an authority checks all validity conditions for the transaction, except those re- lating to locks (the so-called ‘locks checks’). Instead it performs the following checks: for each owned input object in inputs(Tx) it checks that the lock exists, and that it is either None, set to any TxSign, or set to a certificate for the same transaction as the cur- rent certificate. If this modified locks check fails, the authority has detected an unrecoverable Byzantine failure, halts normal opera- tions, and starts a disaster recovery process. For shared objects (see Sect. 4.4) authorities check that the locks have been set through the certificate being sequenced in a consensus, to determine the and The MystenLabs Team version of the share object to use. If so, the transaction may be executed; other
프로젝트로 돌아가기