Skip to content

Commit

Permalink
feat(finalizer): Bi-directional CCTP Finalizations (#1156)
Browse files Browse the repository at this point in the history
* feat: WIP

Signed-off-by: james-a-morris <[email protected]>

* feat(finalizer): initial WIP of CCTP

* improve: add support for executed root bundle events

* improve: docs, helper fns, and testing

* chore: linter

* chore(rebase): fix linting

* chore: fix rebase

* nit: set fake execution chain more accurately

* improve: hubpool client

* improve: use SDK variant of this function

* docs: add comment to where domains can be found

* improve: clean code style

* improve: post debugging commit

* nit: remove testing code.

* nit: log proof count

* improve: avoid changing multicaller existing logic

* improve: variable rename

* docs: add comment

* docs: add comments

---------

Signed-off-by: james-a-morris <[email protected]>
  • Loading branch information
james-a-morris authored Jan 30, 2024
1 parent ac1f64d commit 274ae32
Show file tree
Hide file tree
Showing 14 changed files with 655 additions and 125 deletions.
25 changes: 25 additions & 0 deletions src/common/Constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,12 @@ export const CHAIN_CACHE_FOLLOW_DISTANCE: { [chainId: number]: number } = {
534352: 0,
// Testnets:
5: 0,
11155111: 0,
280: 0,
420: 0,
80001: 0,
84531: 0,
84532: 0,
421613: 0,
534351: 0,
};
Expand Down Expand Up @@ -214,8 +216,10 @@ export const multicall3Addresses = {
420: "0xcA11bde05977b3631167028862bE2a173976CA11",
80001: "0xcA11bde05977b3631167028862bE2a173976CA11",
84531: "0xcA11bde05977b3631167028862bE2a173976CA11",
84532: "0xcA11bde05977b3631167028862bE2a173976CA11",
421613: "0xcA11bde05977b3631167028862bE2a173976CA11",
534351: "0xcA11bde05977b3631167028862bE2a173976CA11",
11155111: "0xcA11bde05977b3631167028862bE2a173976CA11",
};
export type Multicall2Call = {
callData: ethers.utils.BytesLike;
Expand All @@ -225,3 +229,24 @@ export type Multicall2Call = {
// These are the spokes that can hold both ETH and WETH, so they should be added together when caclulating whether
// a bundle execution is possible with the funds in the pool.
export const spokesThatHoldEthAndWeth = [10, 324, 8453];

/**
* An official mapping of chain IDs to CCTP domains. This mapping is separate from chain identifiers
* and is an internal mappinng maintained by Circle.
* @link https://developers.circle.com/stablecoins/docs/supported-domains
*/
export const chainIdsToCctpDomains: { [chainId: number]: number } = {
// Mainnet
1: 0, // Mainnet
10: 2, // Optimism
42161: 3, // Arbitrum
8453: 6, // Base
137: 7, // Polygon

// Testnet
11155111: 0, // Eth Sepolia
11155420: 2, // Optimism Sepolia
421614: 3, // Arbitrum Sepolia
84532: 6, // Base Sepolia
80001: 7, // Polygon PoS Mumbai
};
75 changes: 75 additions & 0 deletions src/common/ContractAddresses.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,44 @@
// ABI definition for CCTP contracts
const CCTP_MESSAGE_TRANSMITTER_CONTRACT_ABI = [
{
anonymous: false,
inputs: [
{
indexed: false,
internalType: "bytes",
name: "message",
type: "bytes",
},
],
name: "MessageSent",
type: "event",
},
{
inputs: [
{
internalType: "bytes",
name: "message",
type: "bytes",
},
{
internalType: "bytes",
name: "attestation",
type: "bytes",
},
],
name: "receiveMessage",
outputs: [
{
internalType: "bool",
name: "success",
type: "bool",
},
],
stateMutability: "nonpayable",
type: "function",
},
];

// Constants file exporting hardcoded contract addresses per chain.
export const CONTRACT_ADDRESSES: {
[chainId: number]: {
Expand Down Expand Up @@ -472,6 +513,10 @@ export const CONTRACT_ADDRESSES: {
},
],
},
cctpMessageTransmitter: {
address: "0x0a992d191deec32afe36203ad87d7d289a738f81",
abi: CCTP_MESSAGE_TRANSMITTER_CONTRACT_ABI,
},
scrollRelayMessenger: {
address: "0x6774Bcbd5ceCeF1336b5300fb5186a12DDD8b367",
abi: [
Expand Down Expand Up @@ -614,6 +659,10 @@ export const CONTRACT_ADDRESSES: {
eth: {
address: "0xDeadDeAddeAddEAddeadDEaDDEAdDeaDDeAD0000",
},
cctpMessageTransmitter: {
address: "0x4d41f22c5a0e5c74090899e5a8fb597a8842b3e8",
abi: CCTP_MESSAGE_TRANSMITTER_CONTRACT_ABI,
},
},
137: {
withdrawableErc20: {
Expand Down Expand Up @@ -642,6 +691,10 @@ export const CONTRACT_ADDRESSES: {
},
],
},
cctpMessageTransmitter: {
address: "0xF3be9355363857F3e001be68856A2f96b4C39Ba9",
abi: CCTP_MESSAGE_TRANSMITTER_CONTRACT_ABI,
},
},
324: {
zkSyncDefaultErc20Bridge: {
Expand Down Expand Up @@ -733,6 +786,10 @@ export const CONTRACT_ADDRESSES: {
eth: {
address: "0xDeadDeAddeAddEAddeadDEaDDEAdDeaDDeAD0000",
},
cctpMessageTransmitter: {
address: "0xAD09780d193884d503182aD4588450C416D6F9D4",
abi: CCTP_MESSAGE_TRANSMITTER_CONTRACT_ABI,
},
},
42161: {
erc20Gateway: {
Expand Down Expand Up @@ -786,5 +843,23 @@ export const CONTRACT_ADDRESSES: {
},
],
},
cctpMessageTransmitter: {
address: "0xC30362313FBBA5cf9163F0bb16a0e01f01A896ca",
abi: CCTP_MESSAGE_TRANSMITTER_CONTRACT_ABI,
},
},

// Testnets
11155111: {
cctpMessageTransmitter: {
address: "0x7865fAfC2db2093669d92c0F33AeEF291086BEFD",
abi: CCTP_MESSAGE_TRANSMITTER_CONTRACT_ABI,
},
},
84532: {
cctpMessageTransmitter: {
address: "0x7865fAfC2db2093669d92c0F33AeEF291086BEFD",
abi: CCTP_MESSAGE_TRANSMITTER_CONTRACT_ABI,
},
},
};
Loading

0 comments on commit 274ae32

Please sign in to comment.