bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 4쪽 중 1쪽
The Sui Smart Contracts Platform
The MystenLabs Team
hello@mystenlabs.com
1 INTRODUCTION
Sui is a decentralized permissionless smart contract platform biased
towards low-latency management of assets. It uses the Move pro-
gramming language to define assets as objects that may be owned
by an address. Move programs define operations on these typed
objects including custom rules for their creation, the transfer of
these assets to new owners, and operations that mutate assets.
Sui is maintained by a permissionless set of authorities that play
a role similar to validators or miners in other blockchain systems. It
uses a Byzantine consistent broadcast protocol between authorities
to ensure the safety of common operations on assets, ensuring lower
latency and better scalability as compared to Byzantine agreement.
It only relies on Byzantine agreement for the safety of shared objects.
As well as governance operations and check-pointing, performed
off the critical latency path. Execution of smart contracts is also
naturally parallelized when possible. Sui supports light clients that
can authenticate reads as well as full clients that may audit all
transitions for integrity. These facilities allow for trust-minimized
bridges to other blockchains.
A native asset SUI is used to pay for gas for all operations. It is
also used by its owners to delegate stake to authorities to operate
Sui within epochs, and periodically, authorities are reconfigured
according to the stake delegated to them. Used gas is distributed to
authorities and their delegates according to their stake and their
contribution to the operation of Sui.
This whitepaper is organized in two parts, with Sect. 2 describing
the Sui programming model using the Move language, and Sect. 4
describing the operations of the permissionless decentralized sys-
tem that ensures safety, liveness and performance for Sui.
2 SUI SMART CONTRACT PROGRAMMING
Sui smart contracts are written in the Move[ 4] language. Move
is safe and expressive, and its type system and data model natu-
rally support the parallel agreement/execution strategies that make
Sui scalable. Move is an open-source programming language for
building smart contracts originally developed at Facebook for the
Diem blockchain. The language is platform-agnostic, and in ad-
dition to being adopted by Sui, it has been gaining popularity on
other platforms (e.g., 0L, StarCoin).
In this section we will discuss the main features of the Move
language and explain how it is used to create and manage assets on
Sui. A more thorough explanation of Move’s features can be found
in the Move Programming Language book1 and more Sui-specific
Move content can be found in the Sui Developer Portal 2, and a
more formal description of Move in the context of Sui can be found
in Section 3.
1https://diem.github.io/move/
2https://github.com/MystenLabs/fastnft/blob/main/doc/SUMMARY.md
2.1 Overview
Sui’s global state includes a pool of programmable objects created
and managed by Move packages that are collections of Move mod-
ules (see Section 2.1.1 for details) containing Move functions and
types. Move packages themselves are also objects. Thus, Sui objects
can be partitioned into two categories:
• Struct data values: Typed data governed by Move modules.
Each object is a struct value with fields that can contain
primitive types (e.g. integers, addresses), other objects, and
non-object structs.
• Package code values: a set of related Move bytecode mod-
ules published as an atomic unit. Each module in a package
can depend both on other modules in that package and on
modules in previously published packages.
Objects can encode assets (e.g., fungible or non-fungible tokens),
capabilities granting the permission to call certain functions or
create other objects, “smart contracts” that manage other assets,
and so on–it’s up to the programmer to decide. The Move code to
declare a custom Sui object type looks like this:
struct Obj has key {
id: VersionedID, // globally unique ID and version
f: u64 // objects can have primitive fields
g: OtherObj // fields can also store other objects
}
All structs representing Sui objects (but not all Move struct
values) must have the id field and the key ability3 indicating that
the value can be stored in Sui’s global object pool.
2.1.1 Modules. A Move program is organized as a set of modules,
each consisting of a list of struct declarations and function declara-
tions. A module can import struct types from other modules and
invoke functions declared by other modules.
Values declared in one Move module can flow into another–
e.g., module OtherObj in the example above could be defined in a
different module than the module defining Obj. This is different
from most smart contract languages, which allow only unstructured
bytes to flow across contract boundaries. However, Move is able
to support this because it provides encapsulation features to help
programmers write robustly safe [14] code. Specifically, Move’s
type system ensures that a type like Obj above can only be created,
destroyed, copied, read, and written by functions inside the module
that declares the type. This allows a module to enforce strong
invariants on its declared types that continue to hold even when
they flow across smart contract trust boundaries.
2.1.2 Transactions and Entrypoints. The global object pool is up-
dated via transactions that can create, destroy, read, and write
objects. A transaction must take each existing object it wishes to
operate on as an input. In addition, a transaction must include the
3https://diem.github.io/move/abilities.html
and The MystenLabs Team
versioned ID of a package object, the name of a module and func-
tion inside that package, and arguments to the function (including
input objects). For example, to call the function
public fun entrypoint(
o1: Obj, o2: & mut Obj, o3: &Obj, x: u64 , ctx: & mut TxContext
) { ... }
a transaction must supply ID’s for three distinct objects whose
type is Obj and an integer to bind to x. The TxContext is a special
parameter filled in by the runtime that contains the sender address
and information required to create new objects.
Inputs to an entrypoint (and more generally, to any Move func-
tion) can be passed with different mutability permissions encoded
in the type. An Obj input can be read, written, transferred, or de-
stroyed. A &mut Obj input can only be read or written, and a &Obj
can only be read. The transaction sender must be authorized to use
each of the input objects with the specified mutability permissions–
see Section 4.4 for more detail.
2.1.3 Creating and Transferring Objects. Programmers can create
objects by using the TxContext passed into the entrypoint to gener-
ate a fresh ID for the object:
public fun create_then_transfer(
f: u64 , g: OtherObj, o1: Obj, ctx: & mut TxContext
) {
let o2 = Obj { id: TxContext::fresh_id(ctx), f, g };
Transfer::transfer(o1, TxContext:sender());
Transfer::transfer(o2, TxContext:sender());
}
This code takes two objects of type OtherObj and Obj as input,
uses the first one and the generated ID to create a new Obj, and
then transfers both Obj objects to the transaction sender. Once an
object has been transferred, it flows into the global object pool and
cannot be accessed by code in the remainder of the transaction. The
Transfer module is part of the Sui standard library, which includes
functions for transferring objects to user addresses and to other
objects.
We note that if the programmer code neglected to include one
of the transfer calls, this code would be rejected by the Move type
system. Move enforces resource safety [5] protections to ensure
that objects cannot be created without permission, copied, or acci-
dentally destroyed. Another example of resource safety would be
an attempt to transfer the same object twice, which would also be
rejected by the Move type system.
3 THE SUI PROGRAMMING MODEL
In this section, we expand on the informal description of the Sui
programming model from Section 2 by presenting detailed seman-
tic definitions. The previous section showed examples of Move
source code; here we define the structure of Move bytecode. De-
velopers write, test, and formally verify [10, 16] Move source code
locally, then compile it to Move bytecode before publishing it to
the blockchain. Any Move bytecode be published on-chain must
pass through a bytecode verifier [4, 5] to ensure that it satisfies key
properties such as type, memory, and resource safety.
As mentioned in Section 2, Move is a platform-agnostic language
which can be adapted to fit specific needs of different systems
without forking the core language. In the following description, we
define both concepts from core Move language (denoted in black
text) and Sui-specific features extending the core Move language
(denoted with orange text).
3.1 Modules
Module = ModuleName×
(StructName ⇀ StructDecl)×
(FunName ⇀ FunDecl)× FunDecl
GenericParam = [Ability]
StructDecl = (FieldName ⇀ StorableType)×
[Ability]×[ GenericParam]
FunDecl = [Type][ Type]×[ Instr]×[ GenericParam]
Instr = TransferToAddr| TransferToObj| ShareMut|
ShareImmut| ...
Table 1: Module
Move code is organized into modules whose structure is defined in
Table 1. A module consists of a collection of named struct declara-
tions and a collection of named function declarations (examples of
these declaration are provided in Section 2.1). A module also con-
tains a special function declaration serving as the moduleinitializer.
This function is invoked exactly once at the time the module is
published on-chain.
A struct declaration is a collection of named fields, where a field
name is mapped to a storeable type. Its declaration also includes an
optional list of abilities (see Section 2 for a description of storeable
types and abilities). A struct declaration may also include a list of
generic parameters with ability constraints, in which case we call it a
generic struct declaration, for example struct Wrapper<T: copy>{
t: T } . A generic parameter represents a type to be used when
declaring struct fields – it is unknown at the time of struct declara-
tion, with a concrete type provided when the struct is instantiated
(i.e., as struct value is created).
A function declaration includes a list of parameter types, a list of
return types, and a list of instructions forming the function’s body.
A function declaration may also include a list of generic parameters
with ability constraints, in which case we call it a generic function
declaration, for example fun unwrap<T: copy>(p: Wrapper<T>){} .
Similarly to struct declarations, a generic parameter represents
a type unknown at function declaration time, but which is never-
theless used when declaring function parameters, return values
and a function body (concrete type is provided when a function is
called).
Instructions that can appear in a function body include all or-
dinary Move instructions with the exception of global storage in-
structions (e.g., move_to, move_from, borrow_global). See [14] for a
complete list of core Move’s instructions and their semantics. In Sui
persistent storage is supported via Sui’s global object pool rather
than the account-based global storage of core Move.
There are four Sui-specific object operations. Each of these oper-
ations changes the ownership metadata of the object (see Section
3.3) and returns it to the global object pool. Most simply, a Sui object
can be transferred to the address of a Sui end-user. An object can
also be transferred to another parent object–this operation requires
the caller to supply a mutable reference to the parent object in
The Sui Smart Contracts Platform
addition to the child object. An object can be mutably shared so it
can be read/written by anyone in the Sui system. Finally, an object
can be immutably shared so it can be read by anyone in the Sui
system, but not written by anyone.
The ability to distinguish between different kinds of ownership
is a unique feature of Sui. In other blockchain platforms we are
aware of, every contract and object is mutably shared. As we will
explain in Section 4, Sui leverages this information for parallel
transaction execution (for all transactions) and parallel agreement
(for transactions involving objects without shared mutability).
3.2 Types and Abilities
PrimType = {address, id, bool, u8, u64,... }
StructType = ModuleName× StructName×
[StorableType]
StorableType = PrimType⊎ StructType⊎
GenericType⊎ VectorType
VectorType = StorableType
GenericType = N
MutabilityQual = {mut, immut}
ReferenceType = StorableType× MutabilityQual
Type = ReferenceType⊎ StorableType
Ability = {key, store, copy, drop}
Table 2: Types and Abilities
A Move program manipulates both data stored in Sui global object
pool and transient data created when the Move program executes.
Both objects and transient data are Move values at the language
level. However, not all values are created equal – they may have
different properties and different structure as prescribed by their
types.
The types used in Move are defined in Table 2. Move supports
many of the same primitive types supported in other programming
languages, such as a boolean type or unsigned integer types of var-
ious sizes. In addition, core Move has an address type representing
an end-user in the system that is also used to identify the sender of
a transaction and (in Sui) the owner of an object. Finally, Sui defines
an id type representing an identity of a Sui object– see Section 3.3
for details.
A struct type describes an instance (i.e., a value) of a struct de-
clared in a given module (see Section 3.1 for information on struct
declarations). A struct type representing a generic struct declara-
tion (i.e., generic struct type) includes a list of storeable types – this
list is the counterpart of the generic parameter list in the struct dec-
laration. A storeable type can be either a concrete type (a primitive
or a struct) or a generic type. We call such types storeable because
they can appear as fields of structs and in objects stored persistently
on-chain, whereas reference types cannot.
For example, the Wrapper<u64> struct type is a generic struct type
parameterized with a concrete (primitive) storeable type u64 – this
kind of type can be used to create a struct instance (i.e.,value). On the
other hand, the same generic struct type can be parameterized with
a generic type (e.g., struct Parent<T> { w: Wrapper<T> } ) coming
from a generic parameter of the enclosing struct or function dec-
laration – this kind of type can be used to declare struct fields,
function params, etc. Structurally, a generic type is an integer index
(defined as N in Table 5) into the list of generic parameters in the
enclosing struct or function declaration.
A vector type in Move describes a variable length collection of
homogenous values. A Move vector can only contain storeable
types, and it is also a storeable type itself.
A Move program can operate directly on values or access them
indirectly via references. Areference type includes both the storeable
type referenced and a mutability qualifier used to determine (and
enforce) whether a value of a given type can be read and written
(mut) or only read (immut). Consequently, the most general form of
a Move value type (Type in Table 2) can be either a storeable type
or a reference type.
Finally, abilities in Move control what actions are permissible
for values of a given type, such as whether a value of a given type
can be copied (duplicated). Abilities constraint struct declarations
and generic type parameters. The Move bytecode verifier is respon-
sible for ensuring that sensitive operations like copies can only be
performed on types with the corresponding ability.
3.3 Objects and Ownership
TxDigest = 𝐶𝑜𝑚(Tx)
ObjID = 𝐶𝑜𝑚(TxDigest× N)
SingleOwner = Addr⊎ ObjID
Shared = {shared_mut, shared_immut}
Ownership = SingleOwner⊎ Shared
StructObj = StructType× Struct
ObjContents = StructObj⊎ Package
Obj = ObjContents× ObjID× Ownership× Version
Table 3: Objects and Ownership
Each Sui object has a globally unique identifier (ObjID in Table 3)
that serves as the persistent identity of the object as it flows between
owners and into and out of other objects. This ID is assigned to the
object by the transaction that creates it. An object ID is created by
applying a collision-resistant hash function to the contents of the
current transaction and to a counter recording how many objects
the transaction has created. A transaction (and thus its digest) is
guaranteed to be unique due to constraints on the input objects of
the transaction, as we will explain subsequently.
In addition to an ID, each object carries metadata about its own-
ership. An object is either uniquely owned by an address or another
object, shared with write/read permissions, or shared with only
read permissions. The ownership of an object determines whether
and how a transaction can use it as an input. Broadly, a uniquely
owned object can only be used in a transaction initiated by its
owner or including its parent object as an input, whereas a shared
object can be used by any transaction, but only with the specified
mutability permissions. See Section 4.4 for a full explanation.
There are two types of objects: package code objects, and struct
data objects. A package object contains of a list of modules. A struct
object contains a Move struct value and the Move type of that value.
and The MystenLabs Team
The contents of an object may change, but its ID, object type (pack-
age vs struct) and Move struct type are immutable. This ensures
that objects are strongly typed and have a persistent identity.
Finally, an object contains a version. Freshly created objects
have version 0, and an object’s version is incremented each time a
transaction takes the object as an input.
3.4 Addresses and Authenticators
Authenticator = Ed25519PubKey⊎ ECDSAPubKey⊎...
Addr = 𝐶𝑜𝑚(Authenticator)
Table 4: Addresses and Authenticators
An address is the persistent identity of a Sui end-user (although
note that a single user can have an arbitrary number of addresses).
To transfer an object to another user, the sender must know the
address of the recipient.
As we will discuss shortly, a Sui transaction must contain the
address of the user sending (i.e., initiating) the transaction and an
authenticator whose digest matches the address. The separation
between addresses and authenticators enables cryptographic agility.
An authenticator can be a public key from any signature scheme,
even if the schemes use different key lengths (e.g., to support post-
quantum signatures). In addition, an authenticator need not be a
single public key–it could also be (e.g.) a K-of-N multisig key.
3.5 Transactions
ObjRef = ObjID× Version×𝐶𝑜𝑚(Obj)
CallTarget = ObjRef× ModuleName× FunName
CallArg = ObjRef⊎ ObjID⊎ PrimType
Package = [Module]
Publish = Package×[ ObjRef]
Call = CallTarget×[ StorableType]×[ CallArg]
GasInfo = ObjRef× MaxGas× BaseFee× Tip
Tx = (Call⊎ Publish)× GasInfo× Addr× Authenticator
Table 5: Transactions
Sui has two different transaction types: publishing a new Move
package, and calling a previously published Move package. A pub-
lish transaction contains a package–a set of modules that will be
published together as a single object, as well as the dependencies of
all the modules in this package (encoded as a list of object references
that must refer to already-published package objects). To execute a
publish transaction, the Sui runtime will run the Move bytecode
verifier on each package, link the package against its dependencies,
and run the module initializer of each module. Module initializ-
ers are useful for bootstrapping the initial state of an application
implemented by the package.
A call transaction’s most important arguments are object inputs.
Object arguments are either specified via an object reference (for
single-owner and shared immutable objects) or an object ID (for
shared mutable objects). A프로젝트로 돌아가기