Skip to content

Commit

Permalink
[SC-452] Refactor forwarders and receivers (#17)
Browse files Browse the repository at this point in the history
* adding cctp support

* complete circle cctp

* remove get sender function as its pointless in this style of callback

* add polygon and avalanche support

* use more general language for cctp domain

* rename some of the variables

* more var renaming; use l2 authority

* review fixes

* convert domain into a struct + library; starting to split out bridges from the domains

* more refactoring of bridge

* part way through testing refactor

* wip cctp

* still wip for refactoring bridge testing

* large refactor to split out domains and bridges and move into library structure

* fix optimism

* fix AMB

* got arbitrum working

* refactor XChainForwaders into separate libraries and support both directions on every bridge

* refactor receivers; started adjusting integration tests

* refactor integration tests

* fix all tests; update readme

* rm unused console

* remove the chain specific helper functions

* add constructor tests for coverage

* remove constructor test; add diagram

* add unit tests for amb receiver

* add cctp unit test

* change cctp authority type

* update to new cctp receiver

* add arbitrum receiever unit tests

* add optimism test

* use relative paths for library code

* fix for subsequent messages

* forge install: openzeppelin-contracts

v5.0.2

* use fallback() instead of forward()

* dont use absolute paths

* fix tests to remove forward()

* move image up; more about the receiver; typo

* formatting

* rm old unused commented out line

* review fixes

* align
  • Loading branch information
hexonaut authored Jun 12, 2024
1 parent 26f8b54 commit e1f9443
Show file tree
Hide file tree
Showing 33 changed files with 1,169 additions and 846 deletions.
Binary file added .assets/xchain-helpers.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[submodule "lib/forge-std"]
path = lib/forge-std
url = https://github.com/foundry-rs/forge-std
[submodule "lib/openzeppelin-contracts"]
path = lib/openzeppelin-contracts
url = https://github.com/openzeppelin/openzeppelin-contracts
19 changes: 18 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
# xchain-helpers

This repository contains tooling for multichain testing such as cross-chain e2e testing support.
This repository has three tools for use with multi-chain development. Domains refer to blockchains which are connected by bridges. Domains may have multiple bridges connecting them, for example both the Optimism Native Bridge and Circle CCTP connect Ethereum and Optimism domains.

## Forwarders

These libraries provide standardized syntax for sending a message to a bridge.

## Receivers

![xchain-helpers](.assets/xchain-helpers.png)

The most common pattern is to have an authorized contract forward a message to another "business logic" contract to abstract away bridge dependencies. Receivers are contracts which perform this generic translation - decoding the bridge-specific message and forwarding to another `target` contract. The `target` contract should have logic to restrict who can call it and permission this to one or more bridge receivers.

Most receivers implement a `fallback()` function which after validating that the call came from an authorized party on the other side of the bridge will forward the call to the `target` contract with the same function signature. This separation of concerns makes it easy for the receiver contract to focus on validating the bridge message, and the business logic `target` contract can validate the `msg.sender` comes from the receiver which validates the whole process. This ensures no chain-specific code is required for the business logic contract.

## E2E Testing Infrastructure

Provides tooling to record messages sent to supported bridges and relay them on the other side simulating a real message going across.

***
*The IP in this repository was assigned to Mars SPC Limited in respect of the MarsOne SP*
1 change: 1 addition & 0 deletions lib/openzeppelin-contracts
Submodule openzeppelin-contracts added at dbb610
33 changes: 0 additions & 33 deletions src/ArbitrumReceiver.sol

This file was deleted.

52 changes: 0 additions & 52 deletions src/CCTPReceiver.sol

This file was deleted.

44 changes: 0 additions & 44 deletions src/GnosisReceiver.sol

This file was deleted.

38 changes: 0 additions & 38 deletions src/OptimismReceiver.sol

This file was deleted.

Loading

0 comments on commit e1f9443

Please sign in to comment.