Skip to content

Commit

Permalink
Merge branch 'main' into pb/jan6
Browse files Browse the repository at this point in the history
  • Loading branch information
paulbalaji authored Jan 11, 2025
2 parents 0ae74fb + 5765587 commit 3ee3b66
Show file tree
Hide file tree
Showing 16 changed files with 457 additions and 44 deletions.
5 changes: 5 additions & 0 deletions .changeset/eleven-carrots-shave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@hyperlane-xyz/sdk': patch
---

Fix the return type of multisig and aggregation ISMs for zksync-stack chains.
5 changes: 5 additions & 0 deletions .changeset/rare-windows-deny.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@hyperlane-xyz/infra': minor
---

Add rstETH/ethereum-zircuit warp config
12 changes: 12 additions & 0 deletions config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
ethereum:
type: collateral
token: "0x7a4EffD87C2f3C55CA251080b1343b605f327E3a"
owner: "0xDA0d054265bB30F4f32C92066428FE57513E7ee1"
mailbox: "0xc005dc82818d67AF737725bD4bf75435d065D239"
interchainSecurityModule: "0x0000000000000000000000000000000000000000"
zircuit:
type: synthetic
owner: "0xA1895dF8AE7b7678E82E76b167A24c82Fb83ec9A"
mailbox: "0xc2FbB9411186AB3b1a6AFCCA702D1a80B48b197c"
interchainSecurityModule: "0x0000000000000000000000000000000000000000"

90 changes: 70 additions & 20 deletions typescript/infra/config/environments/mainnet3/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ import {
AggregationHookConfig,
AggregationIsmConfig,
ChainMap,
ChainTechnicalStack,
CoreConfig,
FallbackRoutingHookConfig,
HookType,
IgpConfig,
IsmType,
MerkleTreeHookConfig,
MultisigConfig,
Expand All @@ -20,10 +22,15 @@ import {
} from '@hyperlane-xyz/sdk';
import { Address, objMap } from '@hyperlane-xyz/utils';

import { getChain } from '../../registry.js';

import { igp } from './igp.js';
import { DEPLOYER, ethereumChainOwners } from './owners.js';
import { supportedChainNames } from './supportedChainNames.js';

// There are no static ISMs or hooks for zkSync, this means
// that the default ISM is a routing ISM and the default hook
// is a fallback routing hook.
export const core: ChainMap<CoreConfig> = objMap(
ethereumChainOwners,
(local, owner) => {
Expand All @@ -33,11 +40,26 @@ export const core: ChainMap<CoreConfig> = objMap(
.map((origin) => [origin, defaultMultisigConfigs[origin]]),
);

const isZksyncChain =
getChain(local).technicalStack === ChainTechnicalStack.ZkSync;

// zkSync uses a different ISM for the merkle root
const merkleRoot = (multisig: MultisigConfig): MultisigIsmConfig =>
multisigConfigToIsmConfig(IsmType.MERKLE_ROOT_MULTISIG, multisig);
multisigConfigToIsmConfig(
isZksyncChain
? IsmType.STORAGE_MERKLE_ROOT_MULTISIG
: IsmType.MERKLE_ROOT_MULTISIG,
multisig,
);

// zkSync uses a different ISM for the message ID
const messageIdIsm = (multisig: MultisigConfig): MultisigIsmConfig =>
multisigConfigToIsmConfig(IsmType.MESSAGE_ID_MULTISIG, multisig);
multisigConfigToIsmConfig(
isZksyncChain
? IsmType.STORAGE_MESSAGE_ID_MULTISIG
: IsmType.MESSAGE_ID_MULTISIG,
multisig,
);

const routingIsm: RoutingIsmConfig = {
type: IsmType.ROUTING,
Expand All @@ -52,17 +74,30 @@ export const core: ChainMap<CoreConfig> = objMap(
...owner,
};

// No static aggregation ISM support on zkSync
const defaultZkSyncIsm = (): RoutingIsmConfig => ({
type: IsmType.ROUTING,
domains: objMap(
originMultisigs,
(_, multisig): MultisigIsmConfig => messageIdIsm(multisig),
),
...owner,
});

const pausableIsm: PausableIsmConfig = {
type: IsmType.PAUSABLE,
paused: false,
owner: DEPLOYER, // keep pausable hot
};

const defaultIsm: AggregationIsmConfig = {
type: IsmType.AGGREGATION,
modules: [routingIsm, pausableIsm],
threshold: 2,
};
// No static aggregation ISM support on zkSync
const defaultIsm: AggregationIsmConfig | RoutingIsmConfig = isZksyncChain
? defaultZkSyncIsm()
: {
type: IsmType.AGGREGATION,
modules: [routingIsm, pausableIsm],
threshold: 2,
};

const merkleHook: MerkleTreeHookConfig = {
type: HookType.MERKLE_TREE,
Expand All @@ -75,30 +110,45 @@ export const core: ChainMap<CoreConfig> = objMap(
paused: false,
owner: DEPLOYER, // keep pausable hot
};
const aggregationHooks = objMap(

// No static aggregation hook support on zkSync
const defaultHookDomains = objMap(
originMultisigs,
(_origin, _): AggregationHookConfig => ({
type: HookType.AGGREGATION,
hooks: [pausableHook, merkleHook, igpHook],
}),
(_origin, _): AggregationHookConfig | IgpConfig => {
return isZksyncChain
? igpHook
: {
type: HookType.AGGREGATION,
hooks: [pausableHook, merkleHook, igpHook],
};
},
);

const defaultHook: FallbackRoutingHookConfig = {
type: HookType.FALLBACK_ROUTING,
...owner,
domains: aggregationHooks,
domains: defaultHookDomains,
fallback: merkleHook,
};

if (typeof owner.owner !== 'string') {
throw new Error('beneficiary must be a string');
}
const requiredHook: ProtocolFeeHookConfig = {
type: HookType.PROTOCOL_FEE,
maxProtocolFee: ethers.utils.parseUnits('1', 'gwei').toString(), // 1 gwei of native token
protocolFee: BigNumber.from(0).toString(), // 0 wei
beneficiary: owner.owner as Address, // Owner can be AccountConfig
...owner,
};

// No aggregation hook support on zkSync, so we ignore protocolFee
// and make the merkleTreeHook required
const requiredHook: ProtocolFeeHookConfig | MerkleTreeHookConfig =
isZksyncChain
? {
type: HookType.MERKLE_TREE,
}
: {
type: HookType.PROTOCOL_FEE,
maxProtocolFee: ethers.utils.parseUnits('1', 'gwei').toString(), // 1 gwei of native token
protocolFee: BigNumber.from(0).toString(), // 0 wei
beneficiary: owner.owner as Address, // Owner can be AccountConfig
...owner,
};

return {
defaultIsm,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { ethers } from 'ethers';

import { ChainMap, HypTokenRouterConfig, TokenType } from '@hyperlane-xyz/sdk';
import { Address } from '@hyperlane-xyz/utils';

import {
RouterConfigWithoutOwner,
tokens,
} from '../../../../../src/config/warp.js';

const formSafes: ChainMap<Address> = {
base: '0xFCdf33C6461fE8476AA0b7aC92D631d58c4e0d84',
form: '0x41B624412B529409A437f08Ef80bCabE81053650',
};

export const getBaseFormAIXBTWarpConfig = async (
routerConfig: ChainMap<RouterConfigWithoutOwner>,
): Promise<ChainMap<HypTokenRouterConfig>> => {
const base: HypTokenRouterConfig = {
...routerConfig.base,
owner: formSafes.base,
type: TokenType.collateral,
token: tokens.base.AIXBT,
interchainSecurityModule: ethers.constants.AddressZero,
};

const form: HypTokenRouterConfig = {
...routerConfig.form,
owner: formSafes.form,
type: TokenType.synthetic,
interchainSecurityModule: ethers.constants.AddressZero,
};

return {
form,
base,
};
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { ethers } from 'ethers';

import { ChainMap, HypTokenRouterConfig, TokenType } from '@hyperlane-xyz/sdk';
import { Address } from '@hyperlane-xyz/utils';

import {
RouterConfigWithoutOwner,
tokens,
} from '../../../../../src/config/warp.js';

const formSafes: ChainMap<Address> = {
base: '0xFCdf33C6461fE8476AA0b7aC92D631d58c4e0d84',
form: '0x41B624412B529409A437f08Ef80bCabE81053650',
};

export const getBaseFormGAMEWarpConfig = async (
routerConfig: ChainMap<RouterConfigWithoutOwner>,
): Promise<ChainMap<HypTokenRouterConfig>> => {
const base: HypTokenRouterConfig = {
...routerConfig.base,
owner: formSafes.base,
type: TokenType.collateral,
token: tokens.base.GAME,
interchainSecurityModule: ethers.constants.AddressZero,
};

const form: HypTokenRouterConfig = {
...routerConfig.form,
owner: formSafes.form,
type: TokenType.synthetic,
interchainSecurityModule: ethers.constants.AddressZero,
};

return {
form,
base,
};
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { ethers } from 'ethers';

import { ChainMap, HypTokenRouterConfig, TokenType } from '@hyperlane-xyz/sdk';
import { Address } from '@hyperlane-xyz/utils';

import {
RouterConfigWithoutOwner,
tokens,
} from '../../../../../src/config/warp.js';

const formSafes: ChainMap<Address> = {
ethereum: '0xec5ad23e29203301B2C1a765718Cc1de7A8d3FbF',
form: '0x41B624412B529409A437f08Ef80bCabE81053650',
};

export const getEthereumFormWBTCWarpConfig = async (
routerConfig: ChainMap<RouterConfigWithoutOwner>,
): Promise<ChainMap<HypTokenRouterConfig>> => {
const ethereum: HypTokenRouterConfig = {
...routerConfig.ethereum,
owner: formSafes.ethereum,
type: TokenType.collateral,
token: tokens.ethereum.WBTC,
interchainSecurityModule: ethers.constants.AddressZero,
};

const form: HypTokenRouterConfig = {
...routerConfig.form,
owner: formSafes.form,
type: TokenType.synthetic,
interchainSecurityModule: ethers.constants.AddressZero,
};

return {
form,
ethereum,
};
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { ethers } from 'ethers';

import { ChainMap, HypTokenRouterConfig, TokenType } from '@hyperlane-xyz/sdk';
import { Address } from '@hyperlane-xyz/utils';

import {
RouterConfigWithoutOwner,
tokens,
} from '../../../../../src/config/warp.js';

const formSafes: ChainMap<Address> = {
ethereum: '0xec5ad23e29203301B2C1a765718Cc1de7A8d3FbF',
form: '0x41B624412B529409A437f08Ef80bCabE81053650',
};

export const getEthereumFormWSTETHWarpConfig = async (
routerConfig: ChainMap<RouterConfigWithoutOwner>,
): Promise<ChainMap<HypTokenRouterConfig>> => {
const ethereum: HypTokenRouterConfig = {
...routerConfig.ethereum,
owner: formSafes.ethereum,
type: TokenType.collateral,
token: tokens.ethereum.WSTETH,
interchainSecurityModule: ethers.constants.AddressZero,
};

const form: HypTokenRouterConfig = {
...routerConfig.form,
owner: formSafes.form,
type: TokenType.synthetic,
interchainSecurityModule: ethers.constants.AddressZero,
};

return {
form,
ethereum,
};
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { ethers } from 'ethers';

import { ChainMap, HypTokenRouterConfig, TokenType } from '@hyperlane-xyz/sdk';

import {
RouterConfigWithoutOwner,
tokens,
} from '../../../../../src/config/warp.js';

const RstETHSafes = {
ethereum: '0xDA0d054265bB30F4f32C92066428FE57513E7ee1',
zircuit: '0xA1895dF8AE7b7678E82E76b167A24c82Fb83ec9A',
};

const ISM_CONFIG = ethers.constants.AddressZero; // Default ISM

export const getEthereumZircuitRstETHWarpConfig = async (
routerConfig: ChainMap<RouterConfigWithoutOwner>,
): Promise<ChainMap<HypTokenRouterConfig>> => {
const ethereum: HypTokenRouterConfig = {
...routerConfig.ethereum,
owner: RstETHSafes.ethereum,
type: TokenType.collateral,
token: tokens.ethereum.rstETH,
interchainSecurityModule: ISM_CONFIG,
};

const zircuit: HypTokenRouterConfig = {
...routerConfig.zircuit,
owner: RstETHSafes.zircuit,
type: TokenType.synthetic,
interchainSecurityModule: ISM_CONFIG,
};

return {
ethereum,
zircuit,
};
};
Loading

0 comments on commit 3ee3b66

Please sign in to comment.