Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merkle Tree Hook Deployer changes #2747

Merged
merged 22 commits into from
Oct 2, 2023
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions rust/utils/run-locally/src/ethereum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ pub fn start_anvil(config: Arc<Config>) -> AgentHandles {
log!("Deploying hyperlane core contracts...");
yarn_infra.clone().cmd("deploy-core").run().join();

log!("Deploying hyperlane hook contracts...");
yarn_infra.clone().cmd("deploy-hook").run().join();

aroralanuk marked this conversation as resolved.
Show resolved Hide resolved
log!("Deploying hyperlane igp contracts...");
yarn_infra.cmd("deploy-igp").run().join();

Expand Down
35 changes: 2 additions & 33 deletions typescript/infra/config/aggregationIsm.ts
Original file line number Diff line number Diff line change
@@ -1,59 +1,28 @@
import {
AggregationIsmConfig,
ChainMap,
ChainName,
Chains,
IsmConfig,
ModuleType,
MultisigIsmConfig,
RoutingIsmConfig,
defaultMultisigIsmConfigs,
} from '@hyperlane-xyz/sdk';
import { Address, objFilter, objMap } from '@hyperlane-xyz/utils';
import { Address } from '@hyperlane-xyz/utils';

import { DeployEnvironment } from '../src/config';

import { Contexts } from './contexts';
import { supportedChainNames as mainnet2Chains } from './environments/mainnet2/chains';
import { owners as mainnet2Owners } from './environments/mainnet2/owners';
import { chainNames as testChains } from './environments/test/chains';
import { owners as testOwners } from './environments/test/owners';
import { supportedChainNames as testnet3Chains } from './environments/testnet3/chains';
import { owners as testnet3Owners } from './environments/testnet3/owners';
import { rcMultisigIsmConfigs } from './multisigIsm';

const chains = {
mainnet2: mainnet2Chains,
testnet3: testnet3Chains,
test: testChains,
};
import { multisigIsms } from './multisigIsm';

const owners = {
testnet3: testnet3Owners,
mainnet2: mainnet2Owners,
test: testOwners,
};

export const multisigIsms = (
env: DeployEnvironment,
local: ChainName,
type: MultisigIsmConfig['type'],
context: Contexts,
): ChainMap<MultisigIsmConfig> =>
objMap(
objFilter(
context === Contexts.ReleaseCandidate
? rcMultisigIsmConfigs
: defaultMultisigIsmConfigs,
(chain, config): config is MultisigIsmConfig =>
chain !== local && chains[env].includes(chain),
),
(_, config) => ({
...config,
type,
}),
);

/// Routing => Multisig ISM type
export const routingIsm = (
environment: DeployEnvironment,
Expand Down
65 changes: 33 additions & 32 deletions typescript/infra/config/environments/mainnet2/hooks.ts
Original file line number Diff line number Diff line change
@@ -1,35 +1,36 @@
import {
ChainMap,
HookConfig,
HookContractType,
MessageHookConfig,
NoMetadataIsmConfig,
filterByChains,
} from '@hyperlane-xyz/sdk';
import { objMap } from '@hyperlane-xyz/utils';
// import {
// ChainMap,
// InterceptorType,
// InterceptorConfig,
// NoMetadataIsmConfig,
// OpStackHookConfig,
// filterByChains,
// } from '@hyperlane-xyz/sdk';
// import { objMap } from '@hyperlane-xyz/utils';

import { owners } from './owners';
// import { owners } from './owners';

const chainNameFilter = new Set(['ethereum', 'optimism']);
const filteredOwnersResult = filterByChains<string>(owners, chainNameFilter);
// const chainNameFilter = new Set(['ethereum', 'optimism']);
// const filteredOwnersResult = filterByChains<string>(owners, chainNameFilter);

export const hooks: ChainMap<HookConfig> = objMap(
filteredOwnersResult,
(chain) => {
if (chain === 'ethereum') {
const hookConfig: MessageHookConfig = {
hookContractType: HookContractType.HOOK,
nativeBridge: '0x25ace71c97B33Cc4729CF772ae268934F7ab5fA1',
remoteIsm: '0x4c5859f0f772848b2d91f1d83e2fe57935348029', // dummy, remoteISM should be deployed first
destination: 'optimism',
};
return hookConfig;
} else {
const ismConfig: NoMetadataIsmConfig = {
hookContractType: HookContractType.ISM,
nativeBridge: '0x4200000000000000000000000000000000000007',
};
return ismConfig;
}
},
);
// export const hooks: ChainMap<InterceptorConfig> = objMap(
// filteredOwnersResult,
// (chain) => {
// if (chain === 'ethereum') {
// const hookConfig: OpStackHookConfig = {
// InterceptorType: InterceptorType.HOOK,
aroralanuk marked this conversation as resolved.
Show resolved Hide resolved
// mailbox: '0x23',
// nativeBridge: '0x25ace71c97B33Cc4729CF772ae268934F7ab5fA1',
// remoteIsm: '0x4c5859f0f772848b2d91f1d83e2fe57935348029', // dummy, remoteISM should be deployed first
// destination: 'optimism',
// };
// return hookConfig;
// } else {
// const ismConfig: NoMetadataIsmConfig = {
// InterceptorType: InterceptorType.ISM,
// nativeBridge: '0x4200000000000000000000000000000000000007',
// };
// return ismConfig;
// }
// },
// );
4 changes: 2 additions & 2 deletions typescript/infra/config/environments/mainnet2/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { core } from './core';
import { keyFunderConfig } from './funding';
import { storageGasOracleConfig } from './gas-oracle';
import { helloWorld } from './helloworld';
import { hooks } from './hooks';
// import { hooks } from './hooks';
import { igp } from './igp';
import { infrastructure } from './infrastructure';
import { bridgeAdapterConfigs, relayerConfig } from './liquidityLayer';
Expand Down Expand Up @@ -45,7 +45,7 @@ export const environment: EnvironmentConfig = {
igp,
owners,
infra: infrastructure,
hooks,
// hooks,
helloWorld,
keyFunderConfig,
storageGasOracleConfig,
Expand Down
35 changes: 0 additions & 35 deletions typescript/infra/config/environments/test/hooks.ts
aroralanuk marked this conversation as resolved.
Show resolved Hide resolved

This file was deleted.

7 changes: 4 additions & 3 deletions typescript/infra/config/environments/test/index.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
import { JsonRpcProvider } from '@ethersproject/providers';

import { MultiProvider, TestChains } from '@hyperlane-xyz/sdk';
import { MultiProvider } from '@hyperlane-xyz/sdk';

import { EnvironmentConfig } from '../../../src/config';

import { agents } from './agent';
import { testConfigs } from './chains';
import { core } from './core';
import { storageGasOracleConfig } from './gas-oracle';
import { hooks } from './hooks';
// import { hooks } from './hooks';
aroralanuk marked this conversation as resolved.
Show resolved Hide resolved
import { igp } from './igp';
import { infra } from './infra';
import { merkleRoot } from './interceptor';
import { owners } from './owners';

export const environment: EnvironmentConfig = {
environment: 'test',
chainMetadataConfigs: testConfigs,
agents,
core,
hooks,
hooks: merkleRoot,
igp,
owners,
infra,
Expand Down
36 changes: 36 additions & 0 deletions typescript/infra/config/environments/test/interceptor.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import {
ChainMap,
InterceptorConfig,
InterceptorType,
} from '@hyperlane-xyz/sdk';
import { objMap } from '@hyperlane-xyz/utils';

import { chainToValidator, merkleRootMultisig } from './multisigIsm';
import { owners } from './owners';

export const merkleRoot: ChainMap<InterceptorConfig> = objMap(
owners,
(chain, _) => {
const config: InterceptorConfig = {
hook: {
type: InterceptorType.HOOK,
},
aroralanuk marked this conversation as resolved.
Show resolved Hide resolved
ism: merkleRootMultisig(chainToValidator[chain]),
};
return config;
},
);

// const mrConfig: ChainMap<InterceptorConfig> = {
// test1: {
// type: InterceptorType.HOOK,
// destinationDomain: BigNumber.from(10),
// destination: 'test2',
// nativeBridge: '0xa85233c63b9ee964add6f2cffe00fd84eb32338f',
// },
// test2: {
// type: InterceptorType.ISM,
// origin: 'test1',
// nativeBridge: '0x322813fd9a801c5507c9de605d63cea4f2ce6c44',
// },
// };
aroralanuk marked this conversation as resolved.
Show resolved Hide resolved
9 changes: 5 additions & 4 deletions typescript/infra/config/environments/test/multisigIsm.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ChainMap, ModuleType, MultisigIsmConfig } from '@hyperlane-xyz/sdk';
import { ChainName } from '@hyperlane-xyz/sdk/src';

// the addresses here must line up with the e2e test's validator addresses
// Validators are anvil accounts 4-6
Expand All @@ -8,18 +9,18 @@ export const chainToValidator: Record<string, string> = {
test3: '0x976EA74026E726554dB657fA54763abd0C3a0aa9',
};

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

export const messageIdMultisig = (validatorKey: string): MultisigIsmConfig => {
export const messageIdMultisig = (chain: ChainName): MultisigIsmConfig => {
return {
type: ModuleType.MESSAGE_ID_MULTISIG,
validators: [validatorKey],
validators: [chain],
threshold: 1,
};
};
Expand Down
62 changes: 31 additions & 31 deletions typescript/infra/config/environments/testnet3/hooks.ts
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
import {
ChainMap,
HookConfig,
HookContractType,
MessageHookConfig,
NoMetadataIsmConfig,
filterByChains,
} from '@hyperlane-xyz/sdk';
import { objMap } from '@hyperlane-xyz/utils';
// import {
// ChainMap,
// HookContractType,
// InterceptorConfig,
// NoMetadataIsmConfig,
// OpStackHookConfig,
// filterByChains,
// } from '@hyperlane-xyz/sdk';
// import { objMap } from '@hyperlane-xyz/utils';

import { owners } from './owners';
// import { owners } from './owners';

const chainNameFilter = new Set(['goerli', 'optimismgoerli']);
const filteredOwnersResult = filterByChains<string>(owners, chainNameFilter);
// const chainNameFilter = new Set(['goerli', 'optimismgoerli']);
// const filteredOwnersResult = filterByChains<string>(owners, chainNameFilter);

export const hooks: ChainMap<HookConfig> = objMap(
filteredOwnersResult,
(chain) => {
if (chain === 'goerli') {
const hookConfig: MessageHookConfig = {
hookContractType: HookContractType.HOOK,
nativeBridge: '0x5086d1eEF304eb5284A0f6720f79403b4e9bE294',
destination: 'optimismgoerli',
};
return hookConfig;
} else {
const ismConfig: NoMetadataIsmConfig = {
hookContractType: HookContractType.ISM,
nativeBridge: '0x4200000000000000000000000000000000000007',
};
return ismConfig;
}
},
);
// export const hooks: ChainMap<InterceptorConfig> = objMap(
// filteredOwnersResult,
// (chain) => {
aroralanuk marked this conversation as resolved.
Show resolved Hide resolved
// if (chain === 'goerli') {
// const hookConfig: OpStackHookConfig = {
// hookContractType: HookContractType.HOOK,
// nativeBridge: '0x5086d1eEF304eb5284A0f6720f79403b4e9bE294',
// destination: 'optimismgoerli',
// };
// return hookConfig;
// } else {
// const ismConfig: NoMetadataIsmConfig = {
// hookContractType: HookContractType.ISM,
// nativeBridge: '0x4200000000000000000000000000000000000007',
// };
// return ismConfig;
// }
// },
// );
4 changes: 2 additions & 2 deletions typescript/infra/config/environments/testnet3/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { core } from './core';
import { keyFunderConfig } from './funding';
import { storageGasOracleConfig } from './gas-oracle';
import { helloWorld } from './helloworld';
import { hooks } from './hooks';
// import { hooks } from './hooks';
aroralanuk marked this conversation as resolved.
Show resolved Hide resolved
import { igp } from './igp';
import { infrastructure } from './infrastructure';
import { bridgeAdapterConfigs } from './liquidityLayer';
Expand Down Expand Up @@ -46,7 +46,7 @@ export const environment: EnvironmentConfig = {
igp,
infra: infrastructure,
helloWorld,
hooks,
// hooks,
owners,
keyFunderConfig,
liquidityLayerConfig: {
Expand Down
Loading