Skip to content

Commit

Permalink
feat: enable Ink in the relayer
Browse files Browse the repository at this point in the history
Signed-off-by: james-a-morris <[email protected]>
  • Loading branch information
james-a-morris committed Dec 23, 2024
1 parent 7663aeb commit 197b995
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 2 deletions.
31 changes: 29 additions & 2 deletions src/clients/bridges/AdapterManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,22 @@ export class AdapterManager {
);
};

const { OPTIMISM, ARBITRUM, POLYGON, ZK_SYNC, BASE, MODE, LINEA, LISK, BLAST, REDSTONE, SCROLL, ZORA, ALEPH_ZERO } =
CHAIN_IDs;
const {
OPTIMISM,
ARBITRUM,
POLYGON,
ZK_SYNC,
BASE,
MODE,
LINEA,
LISK,
BLAST,
REDSTONE,
SCROLL,
ZORA,
ALEPH_ZERO,
INK,
} = CHAIN_IDs;
const hubChainId = hubPoolClient.chainId;
const l1Signer = spokePoolClients[hubChainId].spokePool.signer;
const constructBridges = (chainId: number) => {
Expand Down Expand Up @@ -185,6 +199,19 @@ export class AdapterManager {
);
}

if (this.spokePoolClients[INK] !== undefined) {
this.adapters[INK] = new BaseChainAdapter(
spokePoolClients,
INK,
hubChainId,
filterMonitoredAddresses(INK),
logger,
SUPPORTED_TOKENS[INK],
constructBridges(INK),
DEFAULT_GAS_MULTIPLIER[INK] ?? 1
);
}

logger.debug({
at: "AdapterManager#constructor",
message: "Initialized AdapterManager",
Expand Down
32 changes: 32 additions & 0 deletions src/common/Constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export const MIN_DEPOSIT_CONFIRMATIONS: { [threshold: number | string]: { [chain
[CHAIN_IDs.ARBITRUM]: 0,
[CHAIN_IDs.BASE]: 120,
[CHAIN_IDs.BLAST]: 120,
[CHAIN_IDs.INK]: 120, // Follows Optimism
[CHAIN_IDs.LINEA]: 30,
[CHAIN_IDs.LISK]: 120,
[CHAIN_IDs.MAINNET]: 64, // Finalized block: https://www.alchemy.com/overviews/ethereum-commitment-levels
Expand All @@ -81,6 +82,7 @@ export const MIN_DEPOSIT_CONFIRMATIONS: { [threshold: number | string]: { [chain
[CHAIN_IDs.ARBITRUM]: 0,
[CHAIN_IDs.BASE]: 60,
[CHAIN_IDs.BLAST]: 60,
[CHAIN_IDs.INK]: 60, // Follows Optimism
[CHAIN_IDs.LINEA]: 1,
[CHAIN_IDs.LISK]: 60,
[CHAIN_IDs.MAINNET]: 32, // Justified block
Expand All @@ -98,6 +100,7 @@ export const MIN_DEPOSIT_CONFIRMATIONS: { [threshold: number | string]: { [chain
[CHAIN_IDs.ARBITRUM]: 0,
[CHAIN_IDs.BASE]: 60,
[CHAIN_IDs.BLAST]: 60,
[CHAIN_IDs.INK]: 60, // Follows Optimism
[CHAIN_IDs.LINEA]: 1,
[CHAIN_IDs.LISK]: 60,
[CHAIN_IDs.MAINNET]: 16, // Mainnet reorgs are rarely > 4 blocks in depth so this is a very safe buffer
Expand Down Expand Up @@ -125,6 +128,7 @@ export const CHAIN_MAX_BLOCK_LOOKBACK = {
[CHAIN_IDs.BASE]: 10000,
[CHAIN_IDs.BLAST]: 10000,
[CHAIN_IDs.BOBA]: 4990,
[CHAIN_IDs.INK]: 10000,
[CHAIN_IDs.LINEA]: 5000,
[CHAIN_IDs.LISK]: 10000,
[CHAIN_IDs.MAINNET]: 5000,
Expand All @@ -140,6 +144,7 @@ export const CHAIN_MAX_BLOCK_LOOKBACK = {
[CHAIN_IDs.ARBITRUM_SEPOLIA]: 10000,
[CHAIN_IDs.BASE_SEPOLIA]: 10000,
[CHAIN_IDs.BLAST_SEPOLIA]: 10000,
[CHAIN_IDs.INK_SEPOLIA]: 10000,
[CHAIN_IDs.LISK_SEPOLIA]: 10000,
[CHAIN_IDs.MODE_SEPOLIA]: 10000,
[CHAIN_IDs.OPTIMISM_SEPOLIA]: 10000,
Expand All @@ -159,6 +164,7 @@ export const BUNDLE_END_BLOCK_BUFFERS = {
[CHAIN_IDs.BOBA]: 0, // **UPDATE** 288 is disabled so there should be no buffer.
[CHAIN_IDs.LINEA]: 40, // At 3s/block, 2 mins = 40 blocks.
[CHAIN_IDs.LISK]: 60, // 2s/block gives 2 mins buffer time.
[CHAIN_IDs.INK]: 120, // 1s/block gives 2 mins buffer time
[CHAIN_IDs.MAINNET]: 5, // 12s/block
[CHAIN_IDs.MODE]: 60, // 2s/block. Same finality profile as Optimism
[CHAIN_IDs.OPTIMISM]: 60, // 2s/block
Expand All @@ -172,6 +178,7 @@ export const BUNDLE_END_BLOCK_BUFFERS = {
[CHAIN_IDs.ARBITRUM_SEPOLIA]: 0,
[CHAIN_IDs.BASE_SEPOLIA]: 0,
[CHAIN_IDs.BLAST_SEPOLIA]: 0,
[CHAIN_IDs.INK_SEPOLIA]: 0,
[CHAIN_IDs.LISK_SEPOLIA]: 0,
[CHAIN_IDs.MODE_SEPOLIA]: 0,
[CHAIN_IDs.OPTIMISM_SEPOLIA]: 0,
Expand Down Expand Up @@ -203,6 +210,7 @@ export const CHAIN_CACHE_FOLLOW_DISTANCE: { [chainId: number]: number } = {
[CHAIN_IDs.BASE]: 120,
[CHAIN_IDs.BLAST]: 120,
[CHAIN_IDs.BOBA]: 0,
[CHAIN_IDs.INK]: 120, // Follows Optimism
[CHAIN_IDs.LISK]: 120,
[CHAIN_IDs.LINEA]: 100, // Linea has a soft-finality of 1 block. This value is padded - but at 3s/block the padding is 5 minutes
[CHAIN_IDs.MAINNET]: 128,
Expand All @@ -218,6 +226,7 @@ export const CHAIN_CACHE_FOLLOW_DISTANCE: { [chainId: number]: number } = {
[CHAIN_IDs.ARBITRUM_SEPOLIA]: 0,
[CHAIN_IDs.BASE_SEPOLIA]: 0,
[CHAIN_IDs.BLAST_SEPOLIA]: 0,
[CHAIN_IDs.INK_SEPOLIA]: 0,
[CHAIN_IDs.LISK_SEPOLIA]: 0,
[CHAIN_IDs.MODE_SEPOLIA]: 0,
[CHAIN_IDs.OPTIMISM_SEPOLIA]: 0,
Expand All @@ -234,6 +243,7 @@ export const DEFAULT_NO_TTL_DISTANCE: { [chainId: number]: number } = {
[CHAIN_IDs.BASE]: 86400,
[CHAIN_IDs.BLAST]: 86400,
[CHAIN_IDs.BOBA]: 86400,
[CHAIN_IDs.INK]: 86400,
[CHAIN_IDs.LINEA]: 57600,
[CHAIN_IDs.LISK]: 86400,
[CHAIN_IDs.MAINNET]: 14400,
Expand Down Expand Up @@ -274,6 +284,7 @@ export const PROVIDER_CACHE_TTL_MODIFIER = 0.15;
export const spokesThatHoldEthAndWeth = [
CHAIN_IDs.BASE,
CHAIN_IDs.BLAST,
CHAIN_IDs.INK,
CHAIN_IDs.LINEA,
CHAIN_IDs.LISK,
CHAIN_IDs.MODE,
Expand Down Expand Up @@ -310,6 +321,7 @@ export const SUPPORTED_TOKENS: { [chainId: number]: string[] } = {
[CHAIN_IDs.ARBITRUM]: ["USDC", "USDT", "WETH", "DAI", "WBTC", "UMA", "BAL", "ACX", "POOL"],
[CHAIN_IDs.BASE]: ["BAL", "DAI", "ETH", "WETH", "USDC", "POOL"],
[CHAIN_IDs.BLAST]: ["DAI", "WBTC", "WETH"],
[CHAIN_IDs.INK]: ["ETH", "WETH"],
[CHAIN_IDs.LINEA]: ["USDC", "USDT", "WETH", "WBTC", "DAI"],
[CHAIN_IDs.LISK]: ["WETH", "USDT", "LSK", "WBTC"],
[CHAIN_IDs.MODE]: ["ETH", "WETH", "USDC", "USDT", "WBTC"],
Expand Down Expand Up @@ -364,6 +376,7 @@ export const CANONICAL_BRIDGE: {
[CHAIN_IDs.ARBITRUM]: ArbitrumOrbitBridge,
[CHAIN_IDs.BASE]: OpStackDefaultERC20Bridge,
[CHAIN_IDs.BLAST]: OpStackDefaultERC20Bridge,
[CHAIN_IDs.INK]: OpStackDefaultERC20Bridge,
[CHAIN_IDs.LINEA]: LineaBridge,
[CHAIN_IDs.LISK]: OpStackDefaultERC20Bridge,
[CHAIN_IDs.MODE]: OpStackDefaultERC20Bridge,
Expand Down Expand Up @@ -402,6 +415,9 @@ export const CUSTOM_BRIDGE: {
[TOKEN_SYMBOLS_MAP.DAI.addresses[CHAIN_IDs.MAINNET]]: BlastBridge,
[TOKEN_SYMBOLS_MAP.WETH.addresses[CHAIN_IDs.MAINNET]]: OpStackWethBridge,
},
[CHAIN_IDs.INK]: {
[TOKEN_SYMBOLS_MAP.WETH.addresses[CHAIN_IDs.MAINNET]]: OpStackWethBridge,
},
[CHAIN_IDs.LINEA]: {
[TOKEN_SYMBOLS_MAP.USDC.addresses[CHAIN_IDs.MAINNET]]: LineaUSDCBridge,
[TOKEN_SYMBOLS_MAP.WETH.addresses[CHAIN_IDs.MAINNET]]: LineaWethBridge,
Expand Down Expand Up @@ -505,6 +521,7 @@ export const EXPECTED_L1_TO_L2_MESSAGE_TIME = {
[CHAIN_IDs.ARBITRUM]: 20 * 60,
[CHAIN_IDs.BASE]: 20 * 60,
[CHAIN_IDs.BLAST]: 20 * 60,
[CHAIN_IDs.INK]: 60 * 60,
[CHAIN_IDs.LINEA]: 60 * 60,
[CHAIN_IDs.LISK]: 20 * 60,
[CHAIN_IDs.MODE]: 20 * 60,
Expand Down Expand Up @@ -598,6 +615,21 @@ export const OPSTACK_CONTRACT_OVERRIDES = {
},
l2: DEFAULT_L2_CONTRACT_ADDRESSES,
},
[CHAIN_IDs.INK]: {
l1: {
AddressManager: "0x9b7c9bbd6d540a8a4dedd935819fc4408ba71153",
L1CrossDomainMessenger: "0x69d3cf86b2bf1a9e99875b7e2d9b6a84426c171f",
L1StandardBridge: CONTRACT_ADDRESSES[CHAIN_IDs.MAINNET].ovmStandardBridge_57073.address,
StateCommitmentChain: ZERO_ADDRESS,
CanonicalTransactionChain: ZERO_ADDRESS,
BondManager: ZERO_ADDRESS,
OptimismPortal: "0x5d66c1782664115999c47c9fa5cd031f495d3e4f",
L2OutputOracle: ZERO_ADDRESS,
OptimismPortal2: ZERO_ADDRESS,
DisputeGameFactory: "0x10d7b35078d3baabb96dd45a9143b94be65b12cd",
},
l2: DEFAULT_L2_CONTRACT_ADDRESSES,
},
};

export const DEFAULT_GAS_MULTIPLIER: { [chainId: number]: number } = {
Expand Down
13 changes: 13 additions & 0 deletions src/common/ContractAddresses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ export const CONTRACT_ADDRESSES: {
address: "0x735aDBbE72226BD52e818E7181953f42E3b0FF21",
abi: OVM_L1_STANDARD_BRIDGE_ABI,
},
ovmStandardBridge_57073: {
address: "0x88ff1e5b602916615391f55854588efcbb7663f0",
abi: OVM_L1_STANDARD_BRIDGE_ABI,
},
ovmStandardBridge_81457: {
address: "0x697402166Fbf2F22E970df8a6486Ef171dbfc524",
abi: OVM_L1_STANDARD_BRIDGE_ABI,
Expand Down Expand Up @@ -311,6 +315,15 @@ export const CONTRACT_ADDRESSES: {
address: "0xDeadDeAddeAddEAddeadDEaDDEAdDeaDDeAD0000",
},
},
57073: {
ovmStandardBridge: {
address: "0x4200000000000000000000000000000000000010",
abi: OVM_L2_STANDARD_BRIDGE_ABI,
},
eth: {
address: "0xDeadDeAddeAddEAddeadDEaDDEAdDeaDDeAD0000",
},
},
81457: {
ovmStandardBridge: {
address: "0x4200000000000000000000000000000000000010",
Expand Down
4 changes: 4 additions & 0 deletions src/finalizer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@ const chainFinalizers: { [chainId: number]: { finalizeOnL2: ChainFinalizer[]; fi
finalizeOnL1: [opStackFinalizer],
finalizeOnL2: [],
},
[CHAIN_IDs.INK]: {
finalizeOnL1: [opStackFinalizer],
finalizeOnL2: [],
},
// Testnets
[CHAIN_IDs.BASE_SEPOLIA]: {
finalizeOnL1: [cctpL2toL1Finalizer],
Expand Down

0 comments on commit 197b995

Please sign in to comment.