Conflux eSpace

Conflux Network 在 v2.0 升级中引入了一个兼容以太坊的子空间(子链) - eSpace。该空间完全兼容以太坊接口包括 RPC 和 EVM,以太坊生态的项目和用户可以无缝迁移至 eSpace,包括钱包,开发工具,Defi,NFT 等。 以太坊用户在 Conflux eSpace 不仅可以保证相同的体验,还可以享受 Conflux 网络的高性能和低手续费。

eSpace Quick Start

连接 Metamask

领取测试代币

CFX 空间互跨

Hardhat 开发 ERC20 Token

Note

Spaces 介绍

Space 概念

Conflux 网络在 v2.0(Hydra) 升级中通过 CIP-90 引入了一个全新的空间 - eSpace, 该空间是一个接口上完全兼容以太坊的独立空间独立链,实现了 RPCEVM 层面的完全兼容。而原有的链保持不变且不受影响,被命名为 CoreSpace

空间是一个逻辑上的概念,用于将以太坊格式交易Conflux TX 隔离与区分。两个空间是逻辑上相互独立互不影响的。

也可以把 Core 和 eSpace 理解为两条单独的链,而 eSpace 是 Core 的子链。类似于 Avalanche 的三链架构。

又或者可以参照操作系统虚拟化技术的概念,把 eSpace 理解为在原有网络之上虚拟出来的一条以太坊链

为什么要引入 eSpace

Conflux 通过创新性的树图共识,实现了一个高性能的完全去中心化的公链。Conflux 网络的交易手续费极低,相比于以太坊等网络几乎可以认为免费。但由于网络上线时间较晚,基础设施和工具不完善。为了降低项目和用户的迁移成本,且让用户享受到 Conflux 低手续费,高 TPS 等优势,引入了 eSpace。

通过实现接口上的完全兼容,以太坊的智能合约和应用不做任何修改,可直接部署至 eSpace;以太坊的开发工具,SDK,钱包,服务等可直接在 eSpace 使用;用户也不需要学习新的知识,使用原有工具直接上手。

两个 Space 的关系

CoreSpace 和 eSpace 是逻辑上独立的两个空间,有各自的交易,账户状态,合约,两者互不影响:

底层数据存储上,两个空间复用了同一个数据账本(链),一个数据区块可能会同时包含两个 Space 的交易,只是在交易执行时按照交易类型进行区分,各自只会对本空间内的账户状态产生影响。

Space 间如何通信

引入 eSpace 全新空间(链)的时候,并没有引入新的 Token,在 eSpace 中仍然需要使用 CFX 来支付交易手续费和价值转移。通过新引入的 CrossSpaceCall 内置合约可实现 CFX 在两个空间互跨。

映射地址 (Mirror Address)

每个 Core 空间的账户在 eSpace 会存在一个对应的账户,我们称之为 Mirror Address, 但反之 eSpace 的账户在 Core 则没有。Core 账户在 eSpace 的映射地址是通过固定的规则计算出来的,具体步骤为:

  1. Base32 地址进行 decode 操作,得到 Buffer 格式的地址 payload
  2. 将 payload 进行 keccak 计算,并取最后 20 个字节
  3. 将上一步得到的地址进行 hex 编码即是在 eSpace 的映射地址

Conflux 各 SDK 均提供了计算 base32 地址映射地址的方法:

> const { address } = require('js-conflux-sdk')
undefined
> address.cfxMappedEVMSpaceAddress('cfx:aamgvyzht7h1zxdghb9ee9w26wrz8rd3gj837392dp')
'0x62954816cE133B41Ab888e1b68b62549DE2f32e0'
>

注意:不要把 base32 地址 decode 之后的 hex 地址,直接作为 eSpace 映射地址使用,该操作是错误的,会导致资金丢失

CrossSpaceCall 内置合约

CrossSpaceCall 是位于 Core 空间的一个内置合约,其 hex40 格式地址为 0x0888000000000000000000000000000000000006 该合约的具体接口可参看它的接口文档

CrossSpaceCall 内置合约主要提供如下几个功能:

  1. CFX 在两个空间互跨
  2. Core 空间发起交易,在 eSpace 部署创建合约
  3. 在 Core 空间调用 eSpace 的合约方法

CFX 的空间互跨是同步的,在一笔交易内即可完成,相较于跨链要更加简单,安全,快速。ConfluxHub CrossSpace app 即是基于此内置合约开发的一款 CFX, ERC20 空间互跨应用,使用非常简单。

CrossSpaceCall 内置合约详情可参看单独的介绍

开发者如何选择

Conflux Core 空间,是原生空间,支持合约代付网络空间更大(TPS更高),但需要使用独有的 Base32 地址,RPC, SDK 等。因此如果你想开发一个全新的项目,可以选择 Core 空间,项目的用户可以免 gas 费与项目交互。

如果是一个以太坊项目想利用 Conflux 的高性能,低收费特性,降低用户成本,可选择 eSpace;项目可直接部署,无须做任何修改。如果开发者是一名熟练的以太坊工程师,也可直接选择 eSpace,使用熟悉的工具,SDK 快速上手。

参考

CrossSpaceCall 内置合约

CheatSheet

RPC & chainId

Mainnet

Testnet

Scan

Testnet Faucet

SpaceBridge

L1 bridges

FAQs

eSpace 区块有奖励么

两个空间共用一条链,由 Core 空间的矿工打包,因此只有 Core 空间的区块有奖励。

eSpace 区块时间大概是多少,交易确认时间是多少

eSpace 区块的大致时间为 1 秒,即 1s 一个区块,大致的确认时间为 40-50 个区块。

eSpace 区块 gasLimit 上限是多大,一个区块能有多少笔交易?

eSpace 区块的 gasLimit 为 1500w gas,区块交易数量受交易本身 gas 大小影响,按普通 CFX 转账花费 21000 gas 计算,大概为 700 多笔交易。

但 eSpace 的打包规则为,每 5 个区块才会有一个打包 eSpace 的交易。总体平均大致每秒可执行 600w gas 的交易.

eSpace 支持 1559 格式交易么

不支持,暂时只支持 155 跟 legacy 格式的交易

eSpace 主网使用的共识机制 PoW or PoS ?

PoW

eSpace 有没有像 Core 一样可获取不可回滚块的 RPC ?

没有单独的 RPC 获取该值, 一般用 50-100 个区块就行

eSpace 交易中有一个 standardV 字段,这个字段是可扩展的么,交易所需要关注这个字段么?

standardV 是签名标准的 V 值,不需要关注

为什么 eSpace Scan 上查看某些交易的 gasPrice,燃气费为 0

通过 CrossSpaceCall 进行跨链操作时,会产生一种特殊交易 Phantom Transaction,这种交易的 gasPrice 和燃气费为 0,且交易的签名是不可验证的。

EN Translate

EN Translate

Spaces

The Concept of Space

In Conflux v2.0 (Hydra) upgrade, a new space called eSpace is introduced by CIP-90. It is an independent space (or chain) which is compatible with Ethereum interface, including RPC and EVM. The original chain will be called CoreSpace and remain unchanged and unaffected.

Space is an abstract concept that is used to isolate and distinguish Ethereum format transaction from Conflux transaction. The two spaces are logically independent, and they do not affect each other.

To better understand, you can think CoreSpace and eSpace as two separate chains, where eSpace is a sub-chain of CoreSpace.

In other ways, we can refer to the virtualization technology from operating system concepts, and hence understood eSpace as a virtualized Ethereum chain running in the original network.

Why Introduce eSpace?

Conflux is a high-performance, fully decentralized public chain enabled by an innovative Tree-Graph consensus algorithm. The transaction fee of Conflux is very low that can be seen as almost free compared to other networks such as Ethereum. But consider Ethereum has already build a mature ecosystem including tools, SDKs, wallets, Solidity libraries. In order to reduce the migration cost of projects and users, and make users experience the advantages of low fees and high TPS of Conflux, eSpace was introduced.

Through the fully compatible interface, smart contracts and dApps of Ethereum can be directly deployed to eSpace without any modification. Development tools, SDKs, wallets, and services of Ethereum can be directly used in eSpace. Users do not need to learn new knowledge but just use the original tools to get started directly.

eSpace is very easy to use for ethereum developers and users, just like BSC, Polygon, Aurora.

The Relationship Between the Two Space

CoreSpace and eSpace are two logically independent spaces with their own transactions, account status, and contracts.

In terms of the underlying data storage, both Spaces reuse the same ledger (chain). A block may contain transactions from both Spaces, and they are only differentiated by the transaction type when transactions are executed. Each will only impact the account status in its own Space.

How to Communicate Between Spaces

The brand new eSpace chain has not introduced new tokens. CFX is still used as native token in eSpace to pay transaction fees. Which can be transferred across the two spaces by the newly introduced internal contract CrossSpaceCall.

Mirror Address

Each account in CoreSpace has a corresponding account in eSpace, which we call the Mirror Address. However, eSpace accounts do not have the corresponding account in CoreSpace. The mirror address from CoreSpace to eSpace is calculated by fixed steps:

  1. Decode the original Base32 address to get the address payload with the Buffer format.
  2. Hash the payload by Keccak and take the last 20 bytes
  3. The mirror address is the result of the previous step in hex encoding

Conflux SDKs provide methods to calculate the base32 mirror address.

// js-conflux-sdk example
> const { address } = require('js-conflux-sdk')
> address.cfxMappedEVMSpaceAddress('cfx:aamgvyzht7h1zxdghb9ee9w26wrz8rd3gj837392dp')
'0x62954816cE133B41Ab888e1b68b62549DE2f32e0'

Note: Do not directly use the hex address that is resulted from decoding the base32 address as the eSpace mirror address or eSpace address. This operation is wrong and will lead to loss of assets.

Internal Contract CrossSpaceCall

CrossSpaceCall is an internal contract located in CoreSpace with hex40 format address 0x08880000000000000000000000000000000000000006. The specific interface of the contract can be found in its interface documentation

The internal contract CrossSpaceCall provides several functions.

  1. It enables the cross-space transfers of CFX.
  2. It enables deploy contracts to eSpace from CoreSpace.
  3. It enables eSpace contract methods to be called in CoreSpace.

The cross-space transfers of CFX are synchronous and can be done within one transaction. It is simpler, safer, and faster compared to cross-chain transfers.

ConfluxHub CrossSpace app is a CFX, ERC20 cross-space transfer application based on this internal contract, which is very user-friendly.

The detail of CrossSpaceCall can be found in the separate section.

How To Choose

Conflux CoreSpace is a native space that supports contract sponsorship and has more network capacity (higher TPS), but requires unique Base32 addresses, RPC, SDK, etc. Therefore, if you want to develop a brand new project, you can choose the CoreSpace and the users of the project can interact with the project by paying no gas fee.

If you want to deploy an Ethereum project to take advantage of Conflux's high performance and low cost in order to reduce user costs, you can choose eSpace. The project can be deployed directly without any modification. If you are a skilled Ethereum engineer, you can also choose eSpace directly and use the tools and SDKs that you are familiar with to get started quickly.

Reference