Cross-chain bridge for transferring assets between Phala and other blockchains.
SubBridge pallet
SubBridge Topology
Whereamount
is a certain amount of asset,pha_location
is the path of PHA under the XCM protocol standard, which is defined by SubBridge and represented by MultiLocation, usually represented as:
Among them, 2035
is the parachain ID of the Phala network. So how do we use the XCM protocol to represent any non-parachain‘s account address? It determines how SubBridge will recognize and forward cross-chain transactions.
What we do in practice is that we incorporate other non-parachains into sub-addresses of the Phala network, similar to the local area network specified by TCP/IP. In this way, the account address of an EVM chain can be represented as:
Among them,Similarly, the assets of any chain also need to be unified. The assets on the parachain are defined by the team of the parachain to define their corresponding MultiAsset; the EVM chain assets based on SubBridge are also defined as the sub-asset of the Khala network like the account address. That is, the usual asset location would be represented as:bridge
represents a specific bridge, for example, SygmaBridge uses sygma to represent; ChainBridge usescb
to represent;chain
represents the ID of the EVM chain under the EVM Bridge system. Currently, Ethereum is 0 under both SygmaBridge and ChainBridge protocol;account
represents the ID on the EVM chain. An account, usually a 20-byte hexadecimal string.
Among them, token
represents the contract address of a certain ERC20 or ERC721 of EVM.
pallet-registry::forceRegisterAsset
with given registration informations. When the council enacted the call, an asset instance will be created by pallet-assets
, and some extra registration information will be saved in pallet-registry
.
There are several things we need to pay attention to. The first one is that each asset has a bunch of metadata defined in pallet-assets
, like name
, symbol
, etc. We have provided an extrinsic called forceSetMetadata
in pallet-registry
which can be used to update the metadata of an asset. Another one is that each asset has some privileged accounts used to manage the asset, like Issuer
, Admin
, etc. Different account has different permission. In asset-registry
, we set all the privileged accounts of each asset to an account derived by PalletId(b"phala/ar")
. This means no external account has permission to do things beyond authority.
All registered assets can be found at here. The asset registration informations are stored on-chain, head to polkadot.js.app and choose RPC assetsRegistry→registryInfoByIds
to see details. Here is a screenshot of KSM registration information:
Registration infomartion of KSM
Note: For assets on Phala, also can be found on Assets
tab in polkadot.js app
assetRegistry::forceEnabledSygmaBridge
or assetRegistry::forceEnabledChainbridge
should be enacted by the council. This will enable the crosschain transfer to a specific EVM chain. And assetRegistry::forceDisableSygmaBridge
or assetRegistry::forceDisableChainBridge
is used to disable it. When SygmaBridge or ChainBridge was enabled for the asset, you will see we have new data being added to the returned registration information. For example, the enabled-bridges information of ZLK is shown below:
chainId
is 2 means it has enabled crosschain transfer between the Khala network and Moonriver EVM. ResourceId
is used to bind ZLK on the Khala network and ERC20-ZLK on Moonriver EVM. reserveAccount
is used to save ZLK temporarily when transferring ZLK from the Khala network to Moonriver EVM, and will transfer back to the recipient account when someone transfer ZLK from Moonriver EVM back to Khala network. isMintable
is false
tells the client that should aware of the ZLK balance of reserve account.
Note: For SygmaBridge, asset config need to be done by Sygma team.
Lifecycle of SubBridge Cross-chain Transaction
0x8F92e7353b180937895E0C5937d616E8ea1A2Bb9
. Up to now, the contract has been running safely for nearly a year, and the contract has also been audited by Certik, a third-party auditor hired by Phala. The detailed audit report can be found here