Skip to content
This repository has been archived by the owner on Aug 24, 2023. It is now read-only.

Commit

Permalink
chore(docs): add draft of MetaChain consensus (#101)
Browse files Browse the repository at this point in the history
#### What this PR does / why we need it:

As per the title, this PR is a working draft version of MetaChain
Consensus.

Signed-off-by: Fuxing Loh <[email protected]>
Co-authored-by: Eli <[email protected]>
  • Loading branch information
fuxingloh and eli-lim authored Sep 18, 2022
1 parent 6251c1b commit 9799411
Show file tree
Hide file tree
Showing 10 changed files with 125 additions and 12 deletions.
11 changes: 5 additions & 6 deletions docs/:200:DeFiChain Basics/:100:what-is-metachain.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@
title: What is MetaChain?
---

:::div{class="admonitions yellow"}
Currently work in progress — this article/page is consider draft, the information reflected here might not be
up-to-date.
:::

`DeFiCh/metachain` started as a codename research & development
for [DFIP 2111-B: VOC: Ethereum Virtual Machine (EVM) Support](https://github.com/DeFiCh/dfips/issues/96). Proposed as a
DFIP on Nov 2021; DFIP 2111-B provided DeFiChain with more flexibility to think beyond what is possible today. It
introduced a new dimension to the DeFiChain ecosystem, allowing us to stretch the definition of Native DeFi.

- Smart contract capability through a turing-complete environment for faster paced innovation
- Embrace the multi-chain future enabling easier cross compatibility and extensibility.

---

:::div{class="admonitions red"}
TODO
:::
5 changes: 5 additions & 0 deletions docs/:200:DeFiChain Basics/:110:what-is-nativechain.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
---
title: What is NativeChain?
---

:::div{class="admonitions yellow"}
Currently work in progress — this article/page is consider draft, the information reflected here might not be
up-to-date.
:::
5 changes: 5 additions & 0 deletions docs/:200:DeFiChain Basics/:120:what-is-dfi.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
---
title: What is DFI?
---

:::div{class="admonitions yellow"}
Currently work in progress — this article/page is consider draft, the information reflected here might not be
up-to-date.
:::
5 changes: 5 additions & 0 deletions docs/:200:DeFiChain Basics/:500:wallet.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
---
title: DeFiChain Wallets
---

:::div{class="admonitions yellow"}
Currently work in progress — this article/page is consider draft, the information reflected here might not be
up-to-date.
:::
5 changes: 5 additions & 0 deletions docs/:300:MetaChain Protocol/:100:whitepaper.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
---
title: MetaChain Whitepaper
---

:::div{class="admonitions yellow"}
Currently work in progress — this article/page is consider draft, the information reflected here might not be
up-to-date.
:::
87 changes: 87 additions & 0 deletions docs/:300:MetaChain Protocol/:200:consensus.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
---
title: MetaChain Consensus
---

:::div{class="admonitions yellow"}
Currently work in progress — this article/page is consider draft, the information reflected here might not be
up-to-date.
:::

## Proof-of-?

'Proof-of-' is often colloquially referred to as the consensus mechanism generally agreed upon between multiple actors
for moving the chain forward. Given there is no disagreement between multiple actors, a consensus is achieved. Since its
genesis, DeFiChain has used a Proof-of-Stake (PoS) consensus mechanism adapted from Bitcoin Core's original
Proof-of-Work (PoW) implementation for moving the chain forward.

```mermaid
graph LR
n[UTXO Based Ledger]
m[EVM Based Ledger]
subgraph "NativeChain (PoS)"
n
end
subgraph "MetaChain (PoA)"
m
end
n --Mint Block--> m
n --Propogate Block--> m
```

For the purpose of describing the different DeFiChain consensus at play, NativeChain refers to the UTXO Bitcoin-based
chain, while MetaChain refers to the EVM-based chain.

### Proof-of-Stake (PoS) at NativeChain

NativeChain utilizes a Proof-of-Stake (PoS) algorithm similar to Bitcoin Core's original Proof-of-Work (PoW) mining
algorithm. Validators are selected in proportion to their quantity of holdings in the associated cryptocurrency.

NativeChain uses the concept of Masternode for its PoS implementation. To run a Masternode on NativeChain, a staker must
hold a minimum of 20,000 DFI. Masternodes on NativeChain participate in active transaction validations and block
creations. Each staking node can perform only 1 hash per second, with the nonce from the Bitcoin Core PoW algorithm
replaced by a staker's masternode ID.

### Proof-of-Authority (PoA) at MetaChain

The Proof-of-Authority (PoA) is a consensus method that gives a designated number of actors the power to validate
transactions within the network. MetaChain validators are Masternodes appointed from the NativeChain group of
validators. Running a Masternode on NativeChain allows the actor to validate transactions on the MetaChain network as
they do on the NativeChain network.

## MetaChain Consensus-lite Design

Operating on a consensus-lite design via Proof-of-Authority (PoA), the MetaChain embeds each EVM Block on the
NativeChain. It relies on NativeChain peer-to-peer networking for block propagation. Connectivity between NativeChain
and MetaChain is established through JSON-RPC, secured within a trusted communication medium.

### Block Creation

When the NativeChain validator finds a valid hash, it will instruct the attached MetaChain node to mint a new block. The
attached MetaChain node will mint a new block encoded
with [SCALE CODEC](https://docs.substrate.io/reference/scale-codec/). The newly minted block will be next on top of the
current tip, embedded into the NativeChain block index and propagated via NativeChain peer-to-peer networking.

### Block Connecting

MetaChain has no peer-to-peer (p2p) networking capability; encoded blocks are imported and propagated via the
NativeChain p2p network. The encoded blocks are imported into MetaChain during NativeChain `connectBlock()`. MetaChain
does its block validation separately and in addition to NativeChain's validation. Once validated and indexed on
MetaChain, NativeChain will deem the entire block as valid during the `connectBlock()` subroutine.

### Benefits of a consensus-lite Design

Utilizing a consensus-lite design removes the usual complexity and problems that arise from a consensus-heavy design.
Piggybacking on NativeChain, we isolate and concentrate consensus design decisions into the NativeChain. Rollback and
fork resolutions become a non-issue on MetaChain as the NativeChain handles it.

> ### Precedent for Innovation
>
> To set the precedent for innovation, MetaChain consensus is designed to be consensus-lite for continuous and
> sustainable iterative development. MetaChain is designed to be operated as a parallel subnet of the NativeChain; it
> utilizes the NativeChain consensus mechanism to move the chain forward, allowing more subchains to be abstracted and
> added.
3 changes: 0 additions & 3 deletions docs/:300:MetaChain Protocol/:200:improvement-proposal.md

This file was deleted.

5 changes: 5 additions & 0 deletions docs/:300:MetaChain Protocol/:300:token-bridge.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
---
title: MetaChain Tokens & Bridge
---

:::div{class="admonitions yellow"}
Currently work in progress — this article/page is consider draft, the information reflected here might not be
up-to-date.
:::
8 changes: 8 additions & 0 deletions docs/:300:MetaChain Protocol/:600:node-upgrades.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
title: MetaChain Node Upgrades
---

:::div{class="admonitions yellow"}
Currently work in progress — this article/page is consider draft, the information reflected here might not be
up-to-date.
:::
3 changes: 0 additions & 3 deletions docs/:900:MetaChain Governance/:200:node-upgrades.md

This file was deleted.

0 comments on commit 9799411

Please sign in to comment.