Motivation:
Harmony is the first sharded Proof-of-Stake blockchain that’s launched back in 2019. Sharding and scalability have always been the most known and important feature of Harmony and most of our community members and supporters are in it for our technology of sharding.
Our mainnet network has been running with 4 shards for many years without security issues. However, only shard 0 is fully utilized while the other 3 shards are idle almost all the time due to the lack of interoperability between shards.
Launching the cross-shard messaging protocol not only will unlock the utility of all the 4 shards in harmony, it will also mark Harmony as the first blockchain with a fully interoperable sharding solutions which is still EVM compatible.
Competitor Analysis:
- Near - their sharding is not functional yet.
- Cosmos - the IBC protocol involves complicated network message passing. It takes 9 steps for users to do a cross-zone token transfer.
- Polkadot - interoperability are done through bridges and there is not much design detail on it. Seems it’s just using the canonical bridge technology for the parachains to talk to each other.
Current Design:
https://gitlab.com/mukn/harmony1-proposal/-/blob/main/README.md
*By Rongjian Lan; (To be) Approved by Leo, Ganesha, Jack, Peter.
Execution Plan
Further Design Exploration
- Write down a list of potential applications that will utilize cross-shard protocol
- GameFi
- Lending
- NFT
- DAO Governance
- Design and formalize cross-shard HRC20 and NFT smart contract standards.
- How tokens can be implemented on multiple shards?
- How existing HRC20 tokens on shard 0 can be extended to become cross-shard tokens?
- How to deal with error handling on the receiving shards?
- Can cross-shard reading without transferring token be achieved?
- Registration of all the smart contracts in all shards that belong to the same cross-shard token, so they can recognize each other in the cross-shard communication.
- Design the web portal for cross-shard tokens
- Could be a website that display cross-shard tokens and interact with metamask to do standard cross-shard token transfers.
- Potentially be integrated with 1wallet
Implementation (Pending on Design Exploration)
- Protocol
- EVM router smart contract
- Outgoing message and incoming message creation and storage
- Message passing between shards via p2p protocol
- Change of existing cross-shard message data structure to include additional fields such as gas related parameters.
- Cross-shard gas consumption and resend logic.
- SDK and Toolings
- Cross-shard sending API with confirmation event listener, timeout handler and retry logic.
- Cross-shard token reader API that queries balances across all shards where the token is deployed.
- Cross-shard token events subscription
- User Interfaces
- An official harmony released website to check cross-shard token balances and transfer token across shard (especially for metamask users)
- Testing
- Functionality testing on SDK, UIs and cross-shard txn.
- Load testing on cross-shard txns to make sure the network can handle cross-shard txn spams.
Launch
- Release
- Node client release with the cross-shard txn hard fork
- Medium article release describing the feature and the selling points.
- Technical documentation about cross-shard txns in docs.harmony.one for developers.
- Post-release initiatives
- Hackathon on cross-shard HRC20 NFT token standards and any other cross-shard applications.
- Marketing effort (news, videos etc) to sell as the first cross-shard txn launched in the industry.
Cross-shard Use Cases
- DEX add liquidity pair (token A, token B) case 1: DEX: shard 0, token A: shard 0, token B: shard 1 case 2: DEX: shard 0, token A: shard 1, token B: shard 1 case 3: DEX: shard 0, token A: shard 1, token B: shard 2
- Oracle invocation (read-only) case 1: Oracle: shard 0, DApp: shard 1
- code example:
import "@chainlink/contracts/src/v0.6/interfaces/AggregatorV3Interface.sol";
AggregatorV3Interface oneUSD = AggregatorV3Interface(
0xdCD81FbbD6c4572A69a534D8b8152c562dA8AbEF
);
(, int256 onePrice, , uint256 oneTimeStamp, ) = oneUSD.latestRoundData(); // price invocation
// usage of onePrice & oneTimeStamp