DeFiCh / metachain

DFIP 2111-B: VOC: Ethereum Virtual Machine (EVM) Support
https://docs.defimetachain.org
MIT License
22 stars 4 forks source link

Bi-directional Native to Meta Asset "Trustless" Bridging #96

Open fuxingloh opened 2 years ago

fuxingloh commented 2 years ago

What would you like to be added:

Bi-directional bridging of assets between Native & Meta Chain. Essentially a trustless bridge between the 2 chain within the same ecosystem. This requires understanding of the current trustless bridging design that earmark to be documented in #8.

Introduction of 2 Smart Contract (DfTX & EVM Contract). All supply of DFI comes from the Native Chain. Burning on Native = minting on Meta and vice-versa.

This requires the relevant Transactions to be performed and exchanged between chains. The transaction must be interpolated from 2 chains.

Implementation on Native DMCHandler() and Meta Connect/Mint Handler

RPC Methods in https://github.com/DeFiCh/metachain/issues/89 and related to #94

RPC metaConsensusRpc_mintBlock and handled on Native DMCHandler():

Extract "DfTx.Meta.send" on Native and pass it as structured request params when minting block on MetaChain. MetaChain will automatically include "minting" transaction crediting to the respective address.

RPC metaConsensusRpc_connectBlock and handled on Native DMCHandler():

Extract "Meta Contract.send" on Meta and return it as a structured response for DMCHandler() to process "bridging claims" on the Native layer via DMCHandler(). Burn Meta > Mint Native.

defichain-bot commented 2 years ago

@fuxingloh: Thanks for opening an issue, it is currently awaiting triage.

The triage/accepted label can be added by foundation members by writing /triage accepted in a comment.

Details I am a bot created to help the [DeFiCh](https://github.com/DeFiCh) developers manage community feedback and contributions. You can check out my [manifest file](https://github.com/DeFiCh/metachain/blob/main/.github/governance.yml) to understand my behavior and what I can do. If you want to use this for your project, you can check out the [BirthdayResearch/oss-governance-bot](https://github.com/BirthdayResearch/oss-governance-bot) repository.
wafflespeanut commented 1 year ago

Posting @canonbrother's logic here so that it doesn't get lost:

DFC

DMCtxs = DFCtxs.map(tx.type === DMC)
DFC.call('defi_mint', [sender, DMCTxs])
DFC.lock(txs, vault)

DMC

mint(sender, DFCtxs) {
  validate(sender) // must be validator
  { dest, amt } = DFCTxs
  issue(amt, dest)
  // let **Aura** handle all these txs in pool.. 
}
canonbrother commented 1 year ago
graph

mint([DFI are minted])
lock([DFI are locked])
burn([DFI are burned])
unlock([DFI are unlocked])

subgraph DFC
F203 --> F204 --> F205 --> F206 --> F207 --> F208
end

subgraph DMC
M1 --> M2 --> M3
end

F204 -.-> M1
mint --> M1
lock --> F204

M3 -.-> F208
burn --> M3
unlock --> F208
canonbrother commented 1 year ago
graph

send20P([$20:PENDING])
send20A([$20:ACTIVE])
send46P([$46:PENDING])
send46A([$46:ACTIVE])

subgraph DFC
F203 --> F204 --> F205 --> F206 --> F207 --> F208 --> F209
end

subgraph DMC
M1 --> M2 --> M3 --> M4 --> M5 --> M6
end

F204 --send $20 to DMC--> M1
send20P -.-> M1
M2 --verify block is confirmed--> F205
send20A -.-> M3

M5 --send--> F207
send46P -.-> F207
F208 --verify --> M6
send46A -.-> F209