BibliothecaDAO / realms-contracts

Realms Monorepo for Ethereum contracts and Starknet contracts.
https://bibliothecadao.xyz/
MIT License
86 stars 33 forks source link

feat(lords-bridge): L1 and L2 contracts #242

Closed ponderingdemocritus closed 1 year ago

milancermak commented 1 year ago

Updated the PR with a completely new implementation of both L1 and L2 pieces of the bridge, because the previous one was subpar. The current one is heavily inspired by the DAI bridge and Starkgate.

It is very minimal, both Solidity and Cairo contracts are without external dependencies. They are both immutable. There's not message cancellation support. There's a cyclic dependency when deploying them because the L1 contract constructor takes and address of the L2 contract but the L2 contract constructor needs the address of the L1 contract. CREATE2 should help here.

The general idea is that L1 will always be the source of truth / balances for $LORDS. Any $LORDS bridged over to L2 will be held in escrow by the L1 bridge contract and minted on L2 when bridging over. When moving back from L2 to L1, the L2 $LORDS are burnt and eventually released from escrow on L1 - this claiming on L1 needs another tx on L1 due to how the StarkNet messaging works. I've added a README to describe how the whole system in short. There's seemingly not much to it, but bridges are finicky beasts, please be doubly careful when reviewing and take into account any exceptions and problems that might arise that I might have missed.

One part of the system that needs updating is the L2 $LORDS contract. I'll work on it next and open another PR.