Skip to content

Commit

Permalink
chore: cleanup & update README
Browse files Browse the repository at this point in the history
  • Loading branch information
sujithsomraaj committed Nov 28, 2023
1 parent 6232675 commit 782b4aa
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 66 deletions.
10 changes: 5 additions & 5 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FOUNDRY_PROFILE=local
ETH_FORK_URL=
BSC_FORK_URL=
POLYGON_FORK_URL=
ARB_FORK_URL=
AVA_FORK_URL=
ETH_FORK_URL=https://rpc.notadegen.com/eth
BSC_FORK_URL=https://bsc-dataseed1.binance.org
POLYGON_FORK_URL=https://polygon-mainnet.infura.io/v3/8873097743b54814abaf83f9ae0f5520
ARB_FORK_URL=https://arbitrum.llamarpc.com
AVA_FORK_URL=https://1rpc.io/avax/c
PRIVATE_KEY=
56 changes: 9 additions & 47 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,51 +1,17 @@

# Multi-Message Aggregation (MMA) Design

> **For latest GitBook, you can find it here:** https://multi-message-aggregation.gitbook.io/multi-message-aggregation/
![A World with MMA](https://i.imgur.com/MBnJdid.png)

# xERC20 <> Multi-Message Aggregation (MMA)
A demonstration model for an xERC20 token, as outlined by [ERC-7281](https://www.xerc20.com/), utilizing the Multiple Arbitrary Message Bridge framework built by [Uniswap Foundation](https://github.com/MultiMessageAggregation/multibridge) in partnership with LI.FI.

## Introduction
xERC20 addresses the challenges of fragmented liquidity across various blockchains and the risks associated with relying on a single Arbitrary Message Bridge (AMB). However, it faces limitations related to the minting and burning caps. To overcome these drawbacks, this model employs a combination of message bridges without any constraints, effectively resolving these issues on a broader level.

**Multi-Message Aggregation (MMA) is an additive security module for cross-chain communication.** It utilizes multiple [Arbitrary Messaging Bridges](https://blog.li.fi/navigating-arbitrary-messaging-bridges-a-comparison-framework-8720f302e2aa) (AMB) to send messages from one EVM chain to another EVM chain.

Instead of relying on a single AMB, MMA allows the message sender to relay the message through multiple AMBs. This way, even if one AMB is exploited, no malicious actions can be executed on the destination chain.

## Features
### Core MMA architecture
- **Minimized feature sets**: barebone implementation, low level of complexity.
- **Configurable**: during deployment, individual project can configure their own parameters to fit their specific use case and risk tolerance.
### Adapter
- **Standardization**: Implements EIP-5164 for all APIs on the sending and receiving end.
- **Industry buyin**: currently more than **SIX** bridge providers have their adapters for MMA.

## Workflow for crosschain governance

Assume, we use 3 bridges to relay governance message from Ethereum mainnet to a destination chain. (This number can be changed during actual deployment or via a later governance vote.)


On the destination chain, if 2 of the 3 AMB agree with each other, we would consider the message.

The flow of the message and how it is transformed and relayed is detailed below:

1. Uniswap Ethereum governance structure, `src`, approves to execute a message `msg` on destination chain `dst`.
2. Uniswap governance sends `msg` to `MultiBridgeMessageSender`.
3. `MultiBridgeMessageSender` relays `msg` to different adapters `adapter`.
4. `adapter` encodes `msg` into the corresponding formatted message, `formatted_msg`, and sends it to the hardcoded AMB contracts `AMB`.
5. Each `AMB` independently carries `formatted_msg` to `dst`.
6. On the destination chain, another set of `adapters` decodes `formatted_msgs` into the original `msg`.
7. `msg` is collected inside the `MultiBridgeMessageReceiver` contract.
8. If 2 out of 3 `msg` is the same, the `msg` will be executed on `dst`.

![Illustration of ](https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FyWOfgotvwuIBhzylK0ud%2Fuploads%2Fco073eKSrR7xUmhObi7v%2FMMA_Highlevel.png?alt=media&token=bff8ec55-c04f-4ab9-b362-caae601154db)
![Diagram](https://github.com/lifinance/MMAxERC20/img/Flowchart.jpg)

## Local Development

**Step 1:** Clone the repository

```sh
$ git clone https://github.com/MultiMessageAggregation/multibridge
$ git clone https://github.com/lifinance/MMAxERC20
```

**note:** Please make sure [foundry](https://github.com/foundry-rs/foundry) is installed to proceed further.
Expand Down Expand Up @@ -78,15 +44,9 @@ $ forge test

**note:** We use [pigeon](https://github.com/exp-table/pigeon/tree/docs) to simulate the cross-chain behavior on forked mainnets.

## Contribution guidelines
Thank you for your interest in contributing to MMA! We welcome all contributions to make our project better!

### Before you start
Before you start contributing to the project, please make sure you have read and understood the project's [Gitbook documentation](https://multi-message-aggregation.gitbook.io/multi-message-aggregation/). If you have any questions, drop Kydo a DM on [Twitter](https://twitter.com/0xkydo).
### How to contribute
## How to contribute ?
#### Reporting bugs and issues
If you find any bugs or issues with the project, please create a GitHub issue and include as much detail as possible.
If you find any bugs or issues with the project, please create a GitHub issue and include as much detail as possible.

#### Code contribution
If you want to contribute code to the project, please follow these guidelines:
Expand Down Expand Up @@ -135,6 +95,8 @@ contracts
│   ├── IMessageReceiverAdapter.sol
│   ├── IMessageSenderAdapter.sol
│   └── IMultiBridgeMessageReceiver.sol
└── token
├── xERC20.sol
└── libraries
├── Error.sol
├── Message.sol
Expand Down
Binary file added img/Flowchart.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/MultiBridgeMessageSender.sol
Original file line number Diff line number Diff line change
Expand Up @@ -466,4 +466,4 @@ contract MultiBridgeMessageSender {
(bool success,) = to.call{value: value}(new bytes(0));
require(success, "safeTransferETH: ETH transfer failed");
}
}
}
28 changes: 19 additions & 9 deletions src/token/xERC20.sol
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ contract xERC20 is IXERC20, ERC20 {
mmaSender = IMultiMessageSender(_mmaSender);
mmaReceiver = _mmaReceiver;

/// @dev mints 1 million tokens
// @dev mints 1 million tokens to initial owner
_mint(_initialOwner, 1e24);
}

Expand All @@ -45,24 +45,30 @@ contract xERC20 is IXERC20, ERC20 {
{
_burn(msg.sender, _amount);

/// assume CREATE2
/// assume msg has 29 day expiration
/// assume msg.sender as refund address
// assume CREATE2
// assume msg has 29 day expiration
// assume msg.sender as refund address
mmaSender.remoteCall{value: msg.value}(
_dstChainId, address(this), bytes(""), _amount, 29 days, msg.sender, _fees, 2, new address[](0)
);
}

function setLockbox(address _lockbox) external override {}
function setLockbox(address _lockbox) external override {
// no use case for now
revert();
}

function setLimits(address _bridge, uint256 _mintingLimit, uint256 _burningLimit) external override {}
function setLimits(address _bridge, uint256 _mintingLimit, uint256 _burningLimit) external override {
// no use case for now
revert();
}

function mint(address _user, uint256 _amount) external override onlyMultiMessageReceiver {
_mint(_user, _amount);
}

function burn(address _user, uint256 _amount) external override {
/// @notice no use case for now
// no use case for now
revert();
}

Expand All @@ -71,12 +77,16 @@ contract xERC20 is IXERC20, ERC20 {
return type(uint256).max;
}

function burningMaxLimitOf(address _bridge) external view override returns (uint256 _limit) {}
function burningMaxLimitOf(address _bridge) external view override returns (uint256 _limit) {
return 0;
}

function mintingCurrentLimitOf(address _bridge) external view override returns (uint256 _limit) {
if (_bridge != mmaReceiver) return 0;
return type(uint256).max;
}

function burningCurrentLimitOf(address _bridge) external view override returns (uint256 _limit) {}
function burningCurrentLimitOf(address _bridge) external view override returns (uint256 _limit) {
return 0;
}
}
4 changes: 0 additions & 4 deletions test/Setup.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ pragma solidity >=0.8.20;

/// library imports
import {Test, Vm} from "forge-std/Test.sol";
import "forge-std/console.sol";

import "openzeppelin-contracts/contracts/access/Ownable.sol";

/// @dev imports from Pigeon Helper (Facilitate State Transfer Mocks)
Expand Down Expand Up @@ -201,7 +199,6 @@ abstract contract Setup is Test {

/// @dev deploys the axelar adapters to all configured chains
function _deployAxelarAdapters() internal {
console.log("deploying axelar adapters");
uint256 len = ALL_CHAINS.length;

/// @notice deploy receiver adapters to all DST_CHAINS
Expand Down Expand Up @@ -256,7 +253,6 @@ abstract contract Setup is Test {
++j;
}
}
console.log("deploying axelar adapters complete");
}

/// @dev deploys the amb helpers to all configured chains
Expand Down

0 comments on commit 782b4aa

Please sign in to comment.