转至元数据结尾
转至元数据起始

正在查看旧版本。 查看 当前版本.

与当前比较 查看页面历史

« 上一页 版本 50 下一步 »

前言

当前,区块链之上的各种应用的雏形已经具备,但如何让区块链技术大规模采用,是所有的公链需要解答的问题。

这个问题可以拆解为两个问题:

  1. 区块链如何接受大规模用户?也就是区块链的扩容难题。

  2. 应用应该以什么形态和链结合?也就是链和 Web3 应用的关系。

关于扩容的问题,当前区块链世界主要有三条路线:

  1. 通过改进共识机制,或者减少验证节点等方式来实现扩容。

  2. 通过分片或者平行链来实现扩容。

  3. 通过分层的方式进行扩容。

Starcoin 选择了第三种路线,主要是基于以下理由:

  1. 分层是一种人类社会习惯的解决扩容问题的方式,比如司法系统,政治机构,都是通过分层来解决扩容难题,不同层之间的制约机制可以保证安全。

  2. 区块链的不可能三角中,Layer1 应该更侧重安全。

  3. 不同的应用,应用的不同阶段,对去中心化的要求,对安全的要求,对吞吐的要求都不一样,需要有一种面向应用的演进方案,通过分层的方式更容易实现。

Stargate 是 Starcoin 区块链网络上的分层协议框架。它通过统一的抽象,支持不同的分层方案。Layer1 保证安全(Security)和无准入(Permissionless)。Layer2 实现终局性(Finality),将状态和计算从 Layer1 迁移到 Layer2,实现全局扩容以及交易的即时确认。Layer3 通过面向应用的局部共识,最终实现对 Web3 应用的支撑。

Preface


Currently, the prototypes of various applications on top of blockchain are available, but how to make blockchain technology mass adoption is the question that all public chains need to answer.

This question can be deconstructed into two questions:

  1. How does the blockchain support massive users? That is the blockchain's scaling problem.

  2. In what way should applications be combined with the chain? That is the relationship between the chain and the Web3 application.

On the issue of scaling, there are three main approaches in the current blockchain world.

  1. Scaling is achieved by improving the consensus mechanism, or by reducing the number of validation nodes, etc.

  2. Scaling through sharding or parallel chains.

  3. Scaling through layering.

Starcoin has chosen the third approach for the following reasons:

  1. Layers are a customary approach to solve the scaling problem in human societies, such as judicial systems and political institutions, all solve the scaling problem by layering, and the constraint mechanism between different layers can ensure security.

  2. In the impossible triangle of blockchain, Layer1 should focus more on security.

  3. The requirements for decentralization, security, and throughput are different for different applications and different stages of applications. It is easier to achieve a gradual application-oriented evolutionary solution through a layered approach.

Stargate is a layered protocol framework on the Starcoin blockchain network. It supports different layering solutions through a universal abstraction.

  1. Layer1 ensures Security and Permissionless.

  2. Layer2 enables Finality, migrating state and computation from Layer1 to Layer2, enabling global scaling and instant confirmation of transactions.

  3. Layer3 supports Web3 applications through application-oriented consensus solutions.

关键方案

分层的所有方案中,主要面临三个技术难题:

  1. 如何在 Layer1 校验 Layer2 的执行结果并进行仲裁?Layer3 到 Layer2 同理。

  2. Layer2 以及 Layer3 能否依赖 Layer1 的合约? 这个影响智能合约跨层的可组合性。

  3. 合约的状态如何在不同的层之间迁移?

Key Solutions

There are three main technical challenges in all the layering solutions:

  1. How to verify and arbitrate the transaction execution results of Layer2 at Layer1? and Layer3 to Layer2 as well.

  2. Can Layer2 and Layer3 depend on Layer1's smart contracts? This affects the composability of smart contracts across layers.

  3. How does the state of a smart contract move between layers?

交易校验

区块链上执行一个交易,虽然要基于历史状态进行,但实际上不会读取全部的历史状态。如果只提供该交易所依赖的状态,也可以计算出新的状态。

区块链的状态转换可以通过以下公式表达(以太坊黄皮书):

σt+1 ≡ Υ(σt, T)

  • σ𝑡+1 代表下一个世界状态

  • Υ 代表状态转换函数

  • σ𝑡 代表当前世界状态

  • T 代表一个交易

Y 要执行 T 的时候,依赖当前状态 σ𝑡,但 Y 并不会读取所有的历史状态,如果把 Y 需要的状态抽出一个子集 σ`𝑡,并同时提供证明,σ`𝑡 属于 σ𝑡,就可以实现状态转换。

Transaction verification

The execution of a transaction on the blockchain, while to be executed based on the historical state, will not actually read the entire historical state. A new state can also be calculated if only the state that the transaction depends on is provided.

The blockchain state transition can be represented by the following formula (from Ethereum Yellow Paper).

σt+1 ≡ Υ(σt, T)

  • σ𝑡+1 represents the next world state

  • Υ represents the state transition function

  • σ𝑡 represents the current state of the world

  • T represents a transaction

Y to execute T relies on the current state σ𝑡, but Y does not read all σ𝑡 states. If a subset σ`𝑡 of the states required by Y is extracted and the proof is also provided that σ`𝑡 belongs to σ𝑡, the state transition can also be achieved.


我们把交易执行所依赖的前置状态子集叫做读取集(ReadSet),状态的证明叫读取集证明(ReadSetProof),把它们和交易以及执行后的状态树的根哈希一起打包,叫做富状态交易(StateFullTransaction)。

We call the subset of states on which the execution of the transaction depends as ReadSet and the proof of the states as ReadSetProof and package them together with the transaction and the root hash of the state tree after execution as StateFullTransaction.

数据结构表达如下:

The data structure is represented as follows:

pub struct ReadSet{
  state:Vec<(AccessPath,Vec<u8>)>,
}
pub struct ReadSetProof{
  //TODO define proof
}

pub struct StateFullTransaction{
  read_set: ReadSet,
  proof: ReadSetProof,
  transaction: SignedUserTransaction,
  //Transaction info is transaction execute result, include new state_root, event_root, etc.
  transaction_info: TransactionInfo,
}

富状态交易(StateFullTransaction)包含了交易执行依赖的状态,是可以自校验的,校验方法的伪代码表达如下:

The StateFullTransaction contains the state of the transaction execution dependent and is self-verifiable. The pseudo-code expression of the verification method is as follows.

StateLessVM{
  
  fn eval(txn: StateFullTransaction, prev_state_root: HashValue): bool{
    //通过 ReadSet 构造状态树
    //Constructing a state tree via ReadSet
    let state_tree = build_state_tree(txn.read_set);
    //验证 state_tree 的 root 和 prev_state_root 一致 
    assert(state_tree.root == prev_state_root);
    //在状态树的基础上执行交易
    let output = execute_txn(&state_tree, txn.transaction);
    //将执行结果中的 WriteSet 写入 state_tree
    state_tree.apply(output.write_set);
    //验证执行后的结果和 StateFullTransaction 的 transaction info 匹配
    assert(state_tree.root == txn.transaction_info.state_root);
    //验证 transaction_info 中的其他字段
  }
}

校验富状态交易不依赖于外部状态,所以校验交易的 VM 是 StateLess 的,交易执行依赖的 Layer2 的智能合约代码也一并包含在 ReadSet 中。

Verifying StateFullTransaction does not depend on external state, so the VM for verifying transactions is StateLess, and the Layer2 smart contract code on which the transaction execution depends is also included in the ReadSet.

智能合约的依赖
Dependency of Smart Contracts

区块链分层后,给智能合约之间的依赖关系带来了难题,Layer2 的合约能否依赖 Layer 1 的合约?这里的依赖包含两方面的意义,一代码的依赖,二状态的依赖。当前的所有分层方案中,跨层的合约依赖问题都没有得到很好的解决,只能通过异步消息的机制互通。

After the blockchain is layered, the dependency relationship between smart contracts brings a difficult challenge: Can Layer2 contracts depend on Layer1 contracts? The dependency here contains two meanings, one is the dependency of code and the other is the dependency of state. In all current layered solutions, the problem of cross-layer contract dependency has not been well solved, and can only be interoperated through the mechanism of asynchronous messages.

在 Stargate 中,基于 Move 的静态依赖的特性,Layer2 可以在编译期直接依赖 Layer1 的合约。当 Layer2 的合约执行时,执行上下文的切换如下图所示:

In Stargate, Layer2 can depend on Layer1's contract directly at compile time due to the static dependency feature of Move. When Layer2's contract executes, the execution context switches as shown in the following figure:

  1. 如果 Layer2 合约依赖的 Layer1 的合约是无状态的,不需要读取状态(比如纯算法的合约),则和 Layer1 合约和 Layer1 合约之间的依赖一样。

  2. 如果 Layer2 合约依赖的 Layer1 的合约获取了只读状态(使用 borrow_global 指令),则通过远程状态加载器从 Layer1 获取状态。不过读取的状态不是 Layer1 的最新状态,而是该 Layer2 交易关联的 Layer1 高度的历史状态。

  3. 如果 Layer2 合约依赖的 Layer1 的合约获取了可修改状态(使用 borrow_global_mut/move_from/move_to 指令),则表明这个交易是一个跨层的交易,需要到 Layer1 执行跨层的状态迁移交易。这部分是否可以做成对开发者完全透明,需要进一步技术调研。当前先通过一种显示的方式进行状态迁移。

这样,就可以提供一种近乎于无缝的跨层的编程体验。

  1. If the Layer1 contract on which the Layer2 contract depends is stateless and does not need to read state (e.g., a purely algorithmic contract), the dependency is the same as between Layer1 contracts.

  2. If the Layer1 contract on which the Layer2 contract depends acquires a read-only state (using the borrow_global directive), the state is acquired from Layer1 via a remote state loader. However, the state read is not the latest state of Layer1, but rather a historical state of Layer1 associated with the Layer2 transaction.

  3. If the Layer1 contract on which the Layer2 contract depends acquires a modifiable state (using the borrow_global_mut/move_from/move_to directive), then the transaction is a cross-layer transaction and a cross-layer state move transaction needs to be executed at Layer1. Whether this part can be made completely transparent to developers requires further technical research. Currently, the state move is performed in a clear method first.

This will provide a seamless cross-layer programming experience.

状态迁移
State Movement

状态在不同的 Layer 之间迁移,类似于跨链方案,当前大多数方案都是通过合约将 Token 或者资产在某一层锁定,然后在另外一层铸造出来,需要针对每一种状态或者资产类型设计校验以及铸造方案(比如 Token 和 NFT 的校验是不一样的),或者只实现跨链的合约调用,确保交易执行成功,并不校验状态(有安全风险)。

State movement between different Layers is similar to cross-chain solutions. Most current solutions are to lock Token or assets in one layer through contracts and then mint them in another layer, which requires designing verification and minting solutions for each state or asset type (for example, the verification of Token and NFT is different), or only implementing cross-chain contract calls to ensure successful transaction execution without verifying the state (which has security risks).

使用 Move 这种面向资源的编程语言时,状态在不同的 Layer 之间迁移和合约中从外部存储加载状态类似,我们可以设计一种通用的状态迁移模型。

  1. 定义一种跨层的交易类型,该类型的交易实际上包含两个交易,一个需要在 Layer1 执行,一个需要在 Layer2 执行。

  2. Layer1 的交易中,通过调用跨层的合约,将状态 S 从 Layer1 移动出来,锁定在一个特殊的数据结构中,叫做 SpacetimeBox, 这个结构同时存在与 Layer1 和 Layer2 的状态中。

  3. Layer2 的交易中,通过调用跨层的合约,将 SpacetimeBox 移动出来并销毁,得到 S。

  4. Layer2 给 Layer1 汇报 StateRoot 时,同时提交 SpacetimeBox 的不存在状态证明,证明 SpacetimeBox 已经在 Layer2 得到正确处理,Layer1 释放 SpacetimeBox。

  5. 如果想从 Layer2 将 S 迁移回 Layer 1, 方法同理,不过顺序相反。

  6. 从 Layer2 到 Layer1 的迁移,不同的方案有不同的挑战期,挑战期间中间状态会锁在 SpacetimeBox 中。

When using a resource-oriented programming language like Move, where state moves between different Layers similarly to how state is loaded from external storage in a contract, we can design a generic state movement model.

  1. Define a cross-layer transaction type that actually contains two transactions, one that needs to be executed in Layer1 and one that needs to be executed in Layer2.

In the Layer1 transaction, the state S is moved out of Layer1 via a call to the cross-layer contract and locked in a special data structure called SpacetimeBox, which exists in both the Layer1 and Layer2 states.

In Layer2's transaction, the SpacetimeBox is moved out and destroyed by calling the cross-layer contract to get S. Layer2 reports the status of S to Layer1.

When Layer2 reports the StateRoot to Layer1, it also submits the non-existence proof of the SpacetimeBox, which proves that the SpacetimeBox has been properly processed in Layer2, and Layer1 releases the SpacetimeBox.

If you want to move S from Layer2 back to Layer1, do the same thing, but in reverse order.

The movement from Layer2 to Layer1 has different challenge periods for different scenarios, and the intermediate state is locked in the SpacetimeBox during the challenge period.

示例代码如下:

module CrossLayer{
   // Move state `s` to layer2 with the `id`, only can call on layer1 
   public native move_to_layer2<S>(signer: &signer, id: Layer2ID, s: S);
   // Move state `S` from layer2 with the `id`, only can call on layer1 
   public native move_from_layer2<S>(signer: &signer, id: Layer2ID): S;
   // Move state `s` to layer1, only can call on layer2
   public native move_to_layer1<S>(signer: &signer, s: S);
   // Move state `S` from layer1, only can call on layer2
   public native move_from_layer1<S>(signer: &signer):S;
}

//transaction on layer1
public(script) script_on_layer1(signer: Signer){
  let s = MyModule::get_state_from_somewhere(&signer);
  CrossLayer::move_to_layer2(&siger, dappx_layer2, s);
}

//transaction on dappx layer2
public(script) script_on_layer2(signer: Signer){
  let s = CrossLayer::move_from_layer1<S>(&siger);
  //do something with s.
  LocalModule::save_to_layer2(&signer,s);
}

SpacetimeBox 的封装以及校验是在 native 层实现的,对合约层是透明的。通用的状态迁移最大的难题在于状态的校验,我们可以把状态分为两种:

  1. 可以合并的状态,例如 Token。比如 1000 个 A Token 和 100 个 A Token 可以合并为 1100 个 Token。每种可以合并的状态需要在 Layer1 累加一个总数,跨层迁移时进行校验,保证二层不能凭空创造出 Token。

  2. 不可合并的状态,例如 NFT,或者用户合约自定义的自由状态。SpacetimeBox 中记录了原始状态的哈希,保证状态跨层迁移时状态不会被改变。不可合并的状态,从 Layer1 迁移到 Layer2,只能改变归属,能在 Layer2 更新。

The encapsulation and verification of SpacetimeBox are implemented in the native layer and are transparent to the contract layer. The biggest challenge of generic state movement is the verification of the state, which can be divided into two types:

  1. For mergeable state , such as Token, for example, 1000 A Token and 100 A Token can be merged into 1100 Token. each mergeable state needs to accumulate a total number in Layer1 and be verified when migrating across layers to ensure that Layer2 cannot create Token out of thin air.

  2. For non-mergeable state, such as NFT, or user-contracted free state, Layer1 generates a state tree for all original state moved from Layer1, and records the root hash of the tree to ensure that the state is not changed when it is moved across layers. Non-mergeable state, moved from Layer1 to Layer2, can only change the ownership and cannot be updated in Layer2.

技术架构
Technical Architecture

整体架构分为三层,

  1. Layer1 通过 PoW 共识保证安全(Security)和无准入(Permissionless)。这部分已经实现。

  2. Layer2 通过 PoS 共识给 Layer1 提供终局性(Finality),同时给 Rollup 的 Accumulator 提供去中心化能力。 Rollup 方案可以让网络整体的 TPS 提高到 10~100 倍。

  3. Layer3 通过状态通道(State Channel)以及 DAppChain ,将不同的应用的共识隔离在应用的局部网络中,可提供无限的扩展能力。

The overall architecture is three-layer.

  1. Layer1 ensures Security and Permissionless through PoW consensus. This part has been implemented.

  2. Layer2 provides finality to Layer1 through PoS consensus and decentralization to Rollup's Accumulator. The Rollup solution can increase the overall TPS of the network to 10 to 100 times.

  3. Layer3 isolates the consensus of different applications in the application network through State Channel and DAppChain, which can provide unlimited scalability.

Rollup

Rollup 是一种相对成熟的扩容机制,一些项目已经实现,在 Rollup 中有几个角色:

  1. 累加器(Accumulator),在其他项目中叫定序器(Sequencer)或者聚合器(Aggregator)。它主要的功能是给交易排序,并且定期将 Layer2 的交易提交到 Layer1 。Stargate 的 Rollup 方案中,它不仅仅提供排序,同时会将交易哈希进行累加,用于提供交易的顺序证明。累加器同时也要执行交易,并且定时将每个交易执行之后的状态树的根哈希提交到 Layer1。

  2. 状态提供者(State Provider),按照累加器提供的交易顺序,执行交易,给第三方提供状态查询接口。

  3. 校验者(Verifier),执行交易并与累加器提交到 Layer1 的状态树的根哈希进行比较,如果发现累加器作弊则向 Layer1 提交欺诈证明。

Rollup is a scaling solution and there are several roles in Rollup:

  1. Accumulator, called Sequencer or Aggregator in other projects. Stargate's Rollup solution, not only provides sorting but also accumulates transaction hashes, which are used to provide proof of the order of transactions. The accumulator also executes transactions and periodically commits the root hash of the state tree to Layer1 after each transaction is executed.

  2. The State Provider executes the transactions according to the transaction order provided by the accumulator and provides the state query API to users.

  3. Verifier, executes transactions and compares them with the root hash of the state tree submitted to Layer1 by the accumulator, and submits proof of fraud to Layer1 if the accumulator is found to be cheating.

当前 Stargate 的 Rollup 方案属于 Optimistic Rollup 的一种。Optimistic Rollup 方案下,Layer1 并不会校验 Layer2 的每个交易,而是乐观的相信 Layer2 的 Accumulator 节点,直到有校验者提出欺诈证明,这样相当于把计算和状态都迁移到了 Layer2。

考虑到未来可能引入 ZK Rollup 方案,Stargate 的架构上,交易的校验机制设计为一种抽象的方案,可以通过富状态交易的重复执行的方式实现,也可以通过零知识证明的方式实现,可以通过统一的架构适配不同的方案。

The current Stargate rollup solution is a type of Optimistic Rollup, where Layer1 does not verify every transaction in Layer2, but optimistically trusts Layer2's Accumulator node until a verifier presents proof of fraud, which is equivalent to migrating both computation and state to Layer2.

Considering that the ZK Rollup scheme will be introduced in the future, Stargate's architecture is designed as an abstract solution for the verification mechanism of transactions, which can be implemented by verifying FullStatusTransactions or by verifying zero-knowledge proofs, and the different solutions can be adopted through a universal architecture.

Stargate 的 Rollup 方案相对于其他的 Rollup 方案有几个差异点:

  1. 累加器和 Layer1 共享一套 PoS 共识网络,实现去中心化以及高可用。

  2. 通过累加器提供的顺序证明,以及富状态交易的验证机制,让钱包客户端也具有验证交易的能力,从而承担校验者的能力。

  3. 数据可用性由 Layer2 PoS 共识网络以及钱包客户端来保证,累加器可以只给 Layer1 提交 Layer2 交易的哈希,这样 Rollup 可以将吞吐提升 100x。

Rollup 依然依赖 Layer1 的全局共识,所以受限于 Layer1 的吞吐能力。它的主要目标是降低 Layer1 的计算成本,将状态维护在链下,通过乐观(Optimistic)挑战机制保证安全,可以即时确认 Layer2 的交易状态,给用户提供类似互联网应用的体验,同时也为 Layer3 的扩展方案打好基础。

Stargate's Rollup solution differs from other Rollup solutions in several points.

  1. The accumulator and Layer1 share a PoS consensus network, achieving decentralization and high availability.

  2. The accumulator provides the sequential proofs and the verification mechanism for StateFullTransaction, allowing the wallet client to verify the transactions and take on the verifier role.

  3. Data availability is guaranteed by the Layer2 PoS consensus network and the wallet client, and the accumulator can submit hashes of Layer2 transactions to Layer1 only, allowing Rollup to increase throughput by 100x.

Rollup still relies on the global consensus of Layer1, so it is limited by the throughput capacity of Layer1. Its main goal is to reduce the computational cost of Layer1, maintain state off-chain, and ensure security through an optimistic challenge mechanism. It can instantly confirm the transaction status of Layer2, providing users with an Internet-like application experience, and also laying the foundation for the Layer3 solutions.

State Channel

状态通道(State Channel) ,或者叫支付通道(Payment Channel),以闪电网络(Lightning Network )为代表,也是一种比较成熟的扩容方案。它的思路是双方各自抵押一部分资产在链上,然后在链下维护一个两个参与方(理论上也可以扩展到多个参与方)的局部共识状态,每次变更都需要双方确认。但为了解决单方不合作难题,任何一方都可以单方在链上发起关闭通道的交易,等待一个挑战期后,通道自动关闭,参与方按最后一次双方确认的状态进行清算。

State Channel, or Payment Channel, represented by Lightning Network, is also a proven scaling solution. The idea is that each participant pledges a certain amount of assets on the chain, and then maintains a local consensus state off-chain for both participants (theoretically, it can be extended to multiple participants), and each transaction requires confirmation from both participants. However, in order to solve the problem of non-cooperation, either party can be forced to initiate a liquidation transaction on the chain, and after waiting for a challenging period, the channel will be automatically closed and the participants will be liquidated based on the last confirmed state by both participants.

Stargate 中的 State Channel 方案和其他状态通道有几个差异点:

  1. State Channel 中可以执行合约,这样通道不仅仅用来转账,还可以执行一些复杂的,有状态累计的合约。

  2. 因为它可以执行合约,所以也可以支付任意类型的 Token,以及 NFT。

  3. 状态通道构建在 Layer2 之上,而不是 Layer1 之上,主要是要依赖 Layer2 的即时确认能力,降低建立通道的成本以及确认时间。

状态通道要大规模的应用,其中一个关键门槛是,Layer1 上的状态通道创建成本比较高,等待确认时间比较长。

但如果状态通道在 Layer2 之上,则可以消除这个门槛。这样 Starcoin/Stargate P2P 网络中的任意两个节点,都可以将自己的 P2P 连接升级为状态通道,然后通过状态通道进行数据传输和流式计费。这也是 DAppService 的基础设施。

The State Channel solution in Stargate differs from other state channels in several points:

  1. SmartContract can be executed in the State Channel so that the channel can be used not only to transfer Token but also to execute complex, stateful contracts.

  2. As it can execute contracts, it can also pay any type of Assert, as well as NFTs.

  3. State Channel are built on Layer2 instead of Layer1, mainly because they rely on Layer2's instant confirmation capability to reduce the cost and confirmation time to create the channel.

One of the key thresholds for the massive adoption of State Channel is that the cost of creating a channel on Layer1 is high and the waiting time is long.

However, if the State Channel is on Layer2, this threshold can be eliminated. This allows any two nodes in the Starcoin/Stargate P2P network can upgrade their P2P connections to a State Channel, and then perform data transfer and streaming billing over the State Channel. This is also the infrastructure of DAppService.

DAppService

基于 Stargate 框架搭建的,通过状态通道网络提供付费的 RPC 服务。

DAppService 本身不是去中心化的,但它运行在 P2P 网络上,可以通过 P2P 网络进行服务发现以及远程调用,通过状态通道进行计费。

它相当于 Web2 服务到 Web3 服务的一个桥,任意当前的互联网服务都可以将自己的付费机制变更为流式计费机制,直接接入到 Web3 的 P2P 网络中。

Built on the Stargate framework, it provides a paid RPC service through State Channel network.

DAppService is not decentralized, but it runs on a P2P network, allowing service discovery and remote call through the P2P network, and billing through the State Channel.

It is equivalent to a bridge from Web2 service to Web3 service, and any current Web2 service can change its payment method to a streaming billing method and enter into Web3 P2P network directly.

DAppChain

基于 Stargete 框架搭建的,包含子共识机制的 DApp Chain。它需要注册到 Layer2 中,同时抵押一定数额的 Layer2 资产。如果用户遇到 DApp 的欺诈,可向 Layer2 提交欺诈证明,Layer2 会对 DApp 进行惩罚,但惩罚的上限以 DApp 的注册抵押资产为上限。

The DApp Chain is built based on the Stargete framework and includes a sub-consensus mechanism, which requires registration in Layer2 and collateralizing a certain amount of Layer2 assets. If a user encounters a fraudulent DApp, he can submit proof of fraud to Layer2, and Layer2 will punish the DApp, but the penalty is limited to the maximum amount of the DApp's registered collateral assets.

整体网络概览架构如下图:
The overview of network architecture is shown in the following figure:

  1. Layer1 与 Layer2,Layer3 以及用户的终端钱包,都在同一个 P2P 网络中,都可以通过 P2P 网络进行通信。

  2. 充分发挥终端的作用。终端钱包有自己在 P2P 网络中的身份,可以执行和验证交易,可以存储交易历史,提供数据可用性,可以提交 Layer2 的欺诈证明给 Layer1。同样,也可以提交 DApp 的欺诈证明给 Layer2。

  3. 不同的 DApp,比如 X DApp, Y DApp 可选择不同的方案接入到 Starcoin 网络。

  1. Layer1 is in the same P2P network as Layer2, Layer3, and the user's endpoint wallet, all of which can communicate through the P2P network.

  2. The endpoints are fully exploited. The endpoint wallets have their own identity in the P2P network, can execute and verify transactions, can store transaction history, provide data availability, and can submit Layer2's fraud proofs to Layer1. similarly, they can submit DApp's fraud proofs to Layer2.

  3. Different DApps, such as X DApp, Y DApp, can choose different options to access the Starcoin network.

最后回答开篇提出的两个问题:

  1. 区块链如何接受大规模用户?Starcoin 通过分层的方案来实现扩容。并且一个链要支持大规模的 DApp 接入,仅仅靠 Rollup 方案很难达到目的,必须考虑局部共识机制,所以 Stargate 提供了整体的 Layer1 + Layer2(Rollup) + Layer3(DAppService + DAppChain) 解决方案。

  2. 应用应该以什么形态和链结合?未来应用会以两种方式和链结合,一种是只将链作为付费通道,Stargate 提供 DAppService 可以将传统的 WebService 直接接入到 Web3 的基础设施中。另外一种是 DApp 本身作为一个链,Stargate 提供一个应用链框架,可以快速搭建应用链,并接入到 Starcoin 网络中,安全受 Layer2 和 Layer1 的约束,资产可以在不同的层以及 DApp 之间迁移。

Finally, to answer the two questions in the opening paragraph.

  1. How does a blockchain support massive users? Starcoin achieves scaling through a layered solution. Moreover, if a chain wants to support massive DApp users, it is difficult to achieve the goal by Rollup solution alone, so local consensus mechanism must be considered. Therefore, Stargate provides the integrated Layer1 + Layer2 (Rollup) + Layer3 (DAppService + DAppChain) solution.

  2. In what way should applications be combined with the chain? In the future, applications will be combined with chains in two approaches, one is to use the chain as a payment channel, and Stargate provides DAppService that can connect traditional WebService directly to the Web3 infrastructure. The other is application chains, where Stargate provides an application chain framework to quickly build application chains and integrate them into the Starcoin network, securely governed by Layer2 and Layer1, and where assets can be moved between different layers and DApps.

路线图

路线图包含了三个主要的方向:

  1. Layer1 , Layer2,Layer3,主要目标解决链的扩展性难题以及给 DApp 提供集成方案。

  2. Move 以及 DApp 生态,主要目标是降低开发者的学习门槛以及给开发者提供全栈工具。

  3. 多链生态的互操作性,主要目标是尽可能和其他链互通,融入到其他链的生态中去。

其中,箭头表示依赖关系,虚线表示可能的探索方向。

Roadmap contains three main areas:

  1. Layer1, Layer2, Layer3, the main goal is to solve the chain scalability problem and provide integration solutions for DApps.

  2. Move and DApp ecosystem, the main goal is to reduce the learning threshold of developers and provide full-stack tools to developers.

  3. Interoperability of multi-chain ecosystem, the main goal is to interoperate with other chains and integrate into the ecosystem of other chains as much as possible.

Where arrows indicate dependencies and dashed lines indicate possible exploration areas.

Starcoin 团队在团队成立最初的一年多时间里,尝试在 Bitcoin 以及 Ethereum 上试验 Layer2 的方案,并得出了两个基本的结论:

  1. Bitcoin 由于 Script 的限制,Layer1 很难给 Layer2 的交易提供仲裁能力,必须通过复杂的协议,将仲裁逻辑转换成锁模式(哈希锁,时间锁),很难支撑面向 DApp 的 Layer2 的需求。

  2. Ethereum 的智能合约功能强大,但由于它的合约状态都绑定在合约账户内,无法做到跨层的状态迁移以及类型复用。一方面很难实现通用的状态迁移,另外一方面跨层的智能合约之间很难发挥出组合能力,等应用之间的关系进一步复杂就会遇到瓶颈。

所以 Starcoin 团队尝试了一种新的智能合约语言 Move,并先通过模拟 Layer1 的方式来对 Stargate 技术思路进行 PoC 试验,尝试在状态通道中执行智能合约,然后决定做一条新的 Layer1 for Layer2 的公链,在 Layer1 引入 Move 智能合约。

The Starcoin team tried to explore the Layer2 solution on Bitcoin and Ethereum during the first year and came to two basic conclusions:

  1. Bitcoin's Script limitations make it difficult for Layer1 to provide arbitration ability for Layer2 transactions, and the arbitration logic must be converted to lock mode (hash lock, time lock) through a complex protocol, making it difficult to support the requirements of DApp-oriented Layer2.

  2. Ethereum's smart contracts are powerful, but because its contract state is bound in the contract account, it cannot do cross-layer state movement and type reuse. On the one hand, it is difficult to achieve universal state movement, and on the other hand, it is difficult to support the composability of smart contracts across layers, and the bottleneck will be encountered when the relationship between applications is more complicated in feature.

Therefore, the Starcoin team adopted a new smart contract language, Move, and first conducted PoC tests on the Stargate technology idea by simulating Layer1, trying to execute smart contracts in the State Channel, and then decided to make a new Layer1 for Layer2 public chain, introducing Move smart contracts in Layer1.

2021 年 5月,Starcoin 主网上线。经过半年的稳定运行和持续迭代,到现在(2022 年 1月)Layer1 已经初步具备了 Layer2 的关键依赖,所以继续 Stargate 项目的设计与开发,有以下几个关键节点:

  1. EasyGas,实现以任意 Token 支付 Gas 的能力。该特性依赖于链上的 swap。大约在 2022 年第一季度实现。

  2. 轻节点,轻节点虽然不保存全局状态,但可以执行交易,校验区块,生成富状态交易。嵌入式轻节点(浏览器或者手机客户端)依赖轻节点的实现,富状态客户端钱包依赖嵌入式轻节点的实现。

  3. 分层的混合共识机制,在 PoW 基础上新增一套 PoS 的共识机制,给 Layer1 提供终局性。

  4. Rollup 第一阶段,不考虑 Accumulator 的高可用,主要实现富状态交易的验证,状态的在不同层之间的迁移,以及跨层的合约依赖。

  5. Rollup 第二阶段,将 Rollup 和 PoS 共识整合在一起,解决 Accumulator 高可用和去中心化的问题。

  6. P2P 网络之上的 RPC 框架,这个是一个通用的 P2P 网络服务框架,用来简化 P2P 网络上的 RPC 服务的开发。

  7. 基于 Rollup 的状态通道,以及状态通道之上的 DAppService 框架。

  8. 基于 Rollup 的 DAppChain 框架。

In May 2021, the Starcoin main network was launched. After half a year of stable operation and continuous iteration, by now (January 2022) Layer1 has the initial key dependencies of Layer2, so the design and development of the Stargate project will continue.

The Stargate roadmap has the following key milestones:

  1. EasyGas, which implements the ability to pay for Gas with any Token. This feature relies on swap on the chain and will be implemented around Q1 2022.

  2. Light nodes, do not keep all states but can execute transactions, verify blocks, and generate rich state transactions. Embedded light nodes (browser or mobile clients) rely on the implementation of light nodes, and rich-state client wallets rely on the implementation of embedded light nodes.

  3. Layered hybrid consensus mechanism, adding a PoS consensus mechanism on top of PoW, providing finality to Layer1.

  4. In the first phase of Rollup, the Accumulator is not considered highly available but focuses on the verification of FullStateTransactions, movement of state between different layers, and cross-layer contract dependencies.

  5. In the second phase of Rollup, Rollup and PoS consensus are integrated to solve the problems of Accumulator high availability and decentralization.

  6. RPC framework on top of the P2P network. it is a generic P2P web service framework to simplify the development of RPC services on P2P networks.

  7. Rollup-based state channel, and DAppService framework on top of state channel.

  8. Rollup-based DAppChain framework.

术语说明

  1. 自由状态:在 Move 中,如果某种类型的实例可以由外部 Module 持有,则认为该状态的自由的。

Glossary of Terms

  1. Free state: In Move, if an instance of a type can be held by other Modules, the state is regarded as free.

  • 无标签