Skip to content

Commit

Permalink
DomainRouting and FallbackDomainRouting hooks deployer (hyperlane-xyz…
Browse files Browse the repository at this point in the history
…#2825)

### Description

Add deployer for routing and fallback routing hooks

### Drive-by changes

None

### Related issues



### Backward compatibility

Yes

### Testing

Manual
  • Loading branch information
aroralanuk authored Oct 30, 2023
1 parent f05c50c commit 81569b2
Show file tree
Hide file tree
Showing 28 changed files with 1,512 additions and 142 deletions.
433 changes: 412 additions & 21 deletions rust/config/testnet4_config.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ interface ICrossDomainMessenger {
bytes calldata _message
) external payable;

/*************
* Variables *
*************/

function xDomainMessageSender() external view returns (address);

function OTHER_MESSENGER() external view returns (address);
}

interface IL1CrossDomainMessenger is ICrossDomainMessenger {}

interface IL2CrossDomainMessenger is ICrossDomainMessenger {
function messageNonce() external view returns (uint256);
}
13 changes: 5 additions & 8 deletions typescript/infra/config/aggregationIsm.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import {
AggregationIsmConfig,
ChainName,
ModuleType,
} from '@hyperlane-xyz/sdk';
import { AggregationIsmConfig, ChainName } from '@hyperlane-xyz/sdk';
import { IsmType } from '@hyperlane-xyz/sdk/dist/ism/types';

import { Contexts } from './contexts';
import { multisigIsm } from './multisigIsm';
Expand All @@ -13,11 +10,11 @@ export const aggregationIsm = (
context: Contexts,
): AggregationIsmConfig => {
return {
type: ModuleType.AGGREGATION,
type: IsmType.AGGREGATION,
modules: [
// Ordering matters to preserve determinism
multisigIsm(remote, ModuleType.MERKLE_ROOT_MULTISIG, context),
multisigIsm(remote, ModuleType.MESSAGE_ID_MULTISIG, context),
multisigIsm(remote, IsmType.MERKLE_ROOT_MULTISIG, context),
multisigIsm(remote, IsmType.MESSAGE_ID_MULTISIG, context),
],
threshold: 1,
};
Expand Down
4 changes: 2 additions & 2 deletions typescript/infra/config/environments/test/aggregationIsm.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { AggregationIsmConfig, ModuleType } from '@hyperlane-xyz/sdk';
import { AggregationIsmConfig, IsmType } from '@hyperlane-xyz/sdk';

import { merkleRootMultisig, messageIdMultisig } from './multisigIsm';

export const aggregationIsm = (validatorKey: string): AggregationIsmConfig => {
return {
type: ModuleType.AGGREGATION,
type: IsmType.AGGREGATION,
modules: [
merkleRootMultisig(validatorKey),
messageIdMultisig(validatorKey),
Expand Down
18 changes: 15 additions & 3 deletions typescript/infra/config/environments/test/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ import {
AggregationHookConfig,
ChainMap,
CoreConfig,
FallbackRoutingHookConfig,
HookType,
IgpHookConfig,
IsmType,
MerkleTreeHookConfig,
ModuleType,
RoutingIsmConfig,
} from '@hyperlane-xyz/sdk';
import { ProtocolFeeHookConfig } from '@hyperlane-xyz/sdk/src/hook/types';
Expand All @@ -20,7 +21,7 @@ import { owners } from './owners';

export const core: ChainMap<CoreConfig> = objMap(owners, (local, owner) => {
const defaultIsm: RoutingIsmConfig = {
type: ModuleType.ROUTING,
type: IsmType.ROUTING,
owner,
domains: Object.fromEntries(
Object.entries(chainToValidator)
Expand All @@ -38,11 +39,22 @@ export const core: ChainMap<CoreConfig> = objMap(owners, (local, owner) => {
...igp[local],
};

const defaultHook: AggregationHookConfig = {
const aggregationHook: AggregationHookConfig = {
type: HookType.AGGREGATION,
hooks: [merkleHook, igpHook],
};

const defaultHook: FallbackRoutingHookConfig = {
type: HookType.FALLBACK_ROUTING,
owner,
fallback: merkleHook,
domains: Object.fromEntries(
Object.entries(chainToValidator)
.filter(([chain, _]) => chain !== local)
.map(([chain, _]) => [chain, aggregationHook]),
),
};

const requiredHook: ProtocolFeeHookConfig = {
type: HookType.PROTOCOL_FEE,
maxProtocolFee: ethers.utils.parseUnits('1', 'gwei'), // 1 gwei of native token
Expand Down
6 changes: 3 additions & 3 deletions typescript/infra/config/environments/test/multisigIsm.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ChainMap, ModuleType, MultisigIsmConfig } from '@hyperlane-xyz/sdk';
import { ChainMap, IsmType, MultisigIsmConfig } from '@hyperlane-xyz/sdk';

// the addresses here must line up with the e2e test's validator addresses
// Validators are anvil accounts 4-6
Expand All @@ -10,15 +10,15 @@ export const chainToValidator: Record<string, string> = {

export const merkleRootMultisig = (validatorKey: string): MultisigIsmConfig => {
return {
type: ModuleType.MERKLE_ROOT_MULTISIG,
type: IsmType.MERKLE_ROOT_MULTISIG,
validators: [validatorKey],
threshold: 1,
};
};

export const messageIdMultisig = (validatorKey: string): MultisigIsmConfig => {
return {
type: ModuleType.MESSAGE_ID_MULTISIG,
type: IsmType.MESSAGE_ID_MULTISIG,
validators: [validatorKey],
threshold: 1,
};
Expand Down
4 changes: 2 additions & 2 deletions typescript/infra/config/environments/test/routingIsm.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ModuleType, RoutingIsmConfig } from '@hyperlane-xyz/sdk';
import { IsmType, RoutingIsmConfig } from '@hyperlane-xyz/sdk';

import { multisigIsm } from './multisigIsm';

Expand All @@ -7,7 +7,7 @@ export const routingIsm = (
owner: string,
): RoutingIsmConfig => {
return {
type: ModuleType.ROUTING,
type: IsmType.ROUTING,
owner,
domains: Object.fromEntries(
Object.entries(multisigIsm).filter(([chain]) => chain !== local_chain),
Expand Down
72 changes: 47 additions & 25 deletions typescript/infra/config/environments/testnet4/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,21 @@ import {
AggregationHookConfig,
AggregationIsmConfig,
ChainMap,
Chains,
CoreConfig,
FallbackRoutingHookConfig,
HookConfig,
HookType,
IgpHookConfig,
IsmType,
MerkleTreeHookConfig,
ModuleType,
MultisigConfig,
MultisigIsmConfig,
ProtocolFeeHookConfig,
RoutingIsmConfig,
defaultMultisigIsmConfigs,
} from '@hyperlane-xyz/sdk';
import { OpStackIsmConfig } from '@hyperlane-xyz/sdk/dist/ism/types';
import { objMap } from '@hyperlane-xyz/utils';

import { supportedChainNames } from './chains';
Expand All @@ -28,35 +32,35 @@ export const core: ChainMap<CoreConfig> = objMap(owners, (local, owner) => {
.map((origin) => [origin, defaultMultisigIsmConfigs[origin]]),
);

const messageIdRouting: RoutingIsmConfig = {
type: ModuleType.ROUTING,
domains: objMap(
originMultisigs,
(_, multisig): MultisigIsmConfig => ({
type: ModuleType.MESSAGE_ID_MULTISIG,
...multisig,
}),
),
owner,
};
const merkleRoot = (multisig: MultisigConfig): MultisigIsmConfig => ({
type: IsmType.MERKLE_ROOT_MULTISIG,
...multisig,
});

const messageIdIsm = (multisig: MultisigConfig): MultisigIsmConfig => ({
type: IsmType.MESSAGE_ID_MULTISIG,
...multisig,
});

const merkleRootRouting: RoutingIsmConfig = {
type: ModuleType.ROUTING,
const defaultIsm: RoutingIsmConfig = {
type: IsmType.ROUTING,
domains: objMap(
originMultisigs,
(_, multisig): MultisigIsmConfig => ({
type: ModuleType.MERKLE_ROOT_MULTISIG,
...multisig,
(_, multisig): AggregationIsmConfig => ({
type: IsmType.AGGREGATION,
modules: [messageIdIsm(multisig), merkleRoot(multisig)],
threshold: 1,
}),
),
owner,
};

const defaultIsm: AggregationIsmConfig = {
type: ModuleType.AGGREGATION,
modules: [messageIdRouting, merkleRootRouting],
threshold: 1,
};
if (local === Chains.basegoerli || local === Chains.optimismgoerli) {
defaultIsm.domains[Chains.goerli] = {
origin: Chains.goerli,
type: IsmType.OP_STACK,
nativeBridge: '0x4200000000000000000000000000000000000007',
} as OpStackIsmConfig;
}

const merkleHook: MerkleTreeHookConfig = {
type: HookType.MERKLE_TREE,
Expand All @@ -67,9 +71,27 @@ export const core: ChainMap<CoreConfig> = objMap(owners, (local, owner) => {
...igp[local],
};

const defaultHook: AggregationHookConfig = {
const aggregationHook = (opStackHook: HookConfig): AggregationHookConfig => ({
type: HookType.AGGREGATION,
hooks: [merkleHook, igpHook],
hooks: [opStackHook, igpHook],
});

const domains = Object.fromEntries(
Object.entries(owners)
.filter(([chain, _]) => chain !== local)
.map(([chain, _]) => [chain, aggregationHook(merkleHook) as HookConfig]),
);

// if (local === Chains.goerli) {
// domains[Chains.optimismgoerli] = aggregationHook(opHookConfig);
// domains[Chains.basegoerli] = aggregationHook(baseHookConfig);
// }

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

const requiredHook: ProtocolFeeHookConfig = {
Expand Down
Loading

0 comments on commit 81569b2

Please sign in to comment.