Skip to content

Commit

Permalink
Merge branch 'main' into rossy/warp-ui-utils-migration
Browse files Browse the repository at this point in the history
  • Loading branch information
jmrossy committed Nov 13, 2024
2 parents c38cc75 + 1866635 commit f01854c
Show file tree
Hide file tree
Showing 42 changed files with 907 additions and 326 deletions.
5 changes: 5 additions & 0 deletions .changeset/mighty-panthers-play.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@hyperlane-xyz/sdk': minor
---

Enroll new validators for alephzeroevmmainnet, chilizmainnet, flowmainnet, immutablezkevmmainnet, metal, polynomialfi, rarichain, rootstockmainnet, superpositionmainnet, flame, prom, inevm.
5 changes: 5 additions & 0 deletions .changeset/odd-frogs-move.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@hyperlane-xyz/sdk': minor
---

Added helpers to Token and token adapters to get bridged supply of tokens"
7 changes: 7 additions & 0 deletions .changeset/rare-llamas-float.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@hyperlane-xyz/widgets': minor
---

New Icons
Updated modal with new props
Updated storybook for modal and icon list
7 changes: 7 additions & 0 deletions .changeset/real-phones-bake.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@hyperlane-xyz/infra': minor
'@hyperlane-xyz/cli': minor
'@hyperlane-xyz/sdk': minor
---

Implements persistent relayer for use in CLI
6 changes: 6 additions & 0 deletions .changeset/strange-poems-build.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@hyperlane-xyz/widgets': minor
---

Props and style update: IconButton and Tooltip
New Icons: XCircleIcon and SwapIcon
3 changes: 2 additions & 1 deletion .github/workflows/monorepo-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ on:
- '**'
pull_request:
paths:
# For now, because this image is only used to use `infra`, we just build for infra changes
# For now, because this image is only used to use `infra`, we just build for infra or .registryrc changes
- 'typescript/infra/**'
- '.registryrc'
- 'Dockerfile'
- '.dockerignore'
- '.github/workflows/monorepo-docker.yml'
Expand Down
2 changes: 1 addition & 1 deletion .registryrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
10fdae0f566c7c213b6b1b27b8620e8776f2895f
3e366eae1d49da4270695b157d7af00bb761156a
167 changes: 84 additions & 83 deletions rust/main/config/mainnet_config.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion rust/main/hyperlane-base/src/metrics/agent_metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ impl MetricsUpdater {
let chain_metrics = match self.provider.get_chain_metrics().await {
Ok(Some(chain_metrics)) => chain_metrics,
Err(err) => {
trace!(chain, ?err, "Failed to get chain metrics");
warn!(chain, ?err, "Failed to get chain metrics");
return;
}
_ => {
Expand Down
3 changes: 1 addition & 2 deletions typescript/cli/scripts/run-e2e-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
function cleanup() {
set +e
pkill -f anvil
rm -rf /tmp/anvil2
rm -rf /tmp/anvil3
rm -rf ./tmp
rm -f ./test-configs/anvil/chains/anvil2/addresses.yaml
rm -f ./test-configs/anvil/chains/anvil3/addresses.yaml
set -e
Expand Down
81 changes: 70 additions & 11 deletions typescript/cli/src/commands/relayer.ts
Original file line number Diff line number Diff line change
@@ -1,35 +1,94 @@
import { HyperlaneCore, HyperlaneRelayer } from '@hyperlane-xyz/sdk';
import {
ChainMap,
HyperlaneCore,
HyperlaneRelayer,
RelayerCacheSchema,
} from '@hyperlane-xyz/sdk';
import { Address } from '@hyperlane-xyz/utils';

import { CommandModuleWithContext } from '../context/types.js';
import { log } from '../logger.js';
import { tryReadJson, writeJson } from '../utils/files.js';
import { getWarpCoreConfigOrExit } from '../utils/input.js';

import { agentTargetsCommandOption } from './options.js';
import {
agentTargetsCommandOption,
overrideRegistryUriCommandOption,
symbolCommandOption,
warpCoreConfigCommandOption,
} from './options.js';
import { MessageOptionsArgTypes } from './send.js';

const DEFAULT_RELAYER_CACHE = `${overrideRegistryUriCommandOption.default}/relayer-cache.json`;

export const relayerCommand: CommandModuleWithContext<
MessageOptionsArgTypes & { chains?: string }
MessageOptionsArgTypes & {
chains?: string;
cache: string;
symbol?: string;
warp?: string;
}
> = {
command: 'relayer',
describe: 'Run a Hyperlane message self-relayer',
describe: 'Run a Hyperlane message relayer',
builder: {
chains: agentTargetsCommandOption,
cache: {
describe: 'Path to relayer cache file',
type: 'string',
default: DEFAULT_RELAYER_CACHE,
},
symbol: symbolCommandOption,
warp: warpCoreConfigCommandOption,
},
handler: async ({ context, chains }) => {
const chainsArray = chains
? chains.split(',').map((_) => _.trim())
: undefined;
handler: async ({ context, cache, chains, symbol, warp }) => {
const chainAddresses = await context.registry.getAddresses();
const core = HyperlaneCore.fromAddressesMap(
chainAddresses,
context.multiProvider,
);

const relayer = new HyperlaneRelayer({ core });
const chainsArray =
chains?.split(',').map((_) => _.trim()) ?? Object.keys(chainAddresses);

const whitelist: ChainMap<Address[]> = Object.fromEntries(
chainsArray.map((chain) => [chain, []]),
);

// add warp route addresses to whitelist
if (symbol || warp) {
const warpRoute = await getWarpCoreConfigOrExit({
context,
symbol,
warp,
});
warpRoute.tokens.forEach(
({ chainName, addressOrDenom }) =>
(whitelist[chainName] = [addressOrDenom!]),
);
}

const relayer = new HyperlaneRelayer({ core, whitelist });
// TODO: fix merkle hook stubbing

const jsonCache = tryReadJson(cache);
if (jsonCache) {
try {
const parsedCache = RelayerCacheSchema.parse(jsonCache);
relayer.hydrate(parsedCache);
} catch (error) {
log(`Error hydrating cache: ${error}`);
}
}

log('Starting relayer ...');
relayer.start(chainsArray);
relayer.start();

process.once('SIGINT', () => {
relayer.stop(chainsArray);
log('Stopping relayer ...');
relayer.stop();

writeJson(cache, relayer.cache);
process.exit(0);
});
},
Expand Down
2 changes: 1 addition & 1 deletion typescript/cli/src/commands/signCommands.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Commands that send tx and require a key to sign.
// It's useful to have this listed here so the context
// middleware can request keys up front when required.
export const SIGN_COMMANDS = ['deploy', 'send', 'status', 'submit'];
export const SIGN_COMMANDS = ['deploy', 'send', 'status', 'submit', 'relayer'];

export function isSignCommand(argv: any): boolean {
return (
Expand Down
2 changes: 1 addition & 1 deletion typescript/cli/src/consts.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export const MINIMUM_CORE_DEPLOY_GAS = (1e8).toString();
export const MINIMUM_WARP_DEPLOY_GAS = (6e8).toString(); // Rough calculation through deployments to testnets with 2x buffer
export const MINIMUM_WARP_DEPLOY_GAS = (3e7).toString();
export const MINIMUM_TEST_SEND_GAS = (3e5).toString();
export const MINIMUM_AVS_GAS = (3e6).toString();
export const PROXY_DEPLOYED_URL = 'https://proxy.hyperlane.xyz';
25 changes: 25 additions & 0 deletions typescript/cli/src/tests/commands/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { $ } from 'zx';

import { ERC20Test__factory, ERC4626Test__factory } from '@hyperlane-xyz/core';
import { ChainAddresses } from '@hyperlane-xyz/registry';
import {
Expand Down Expand Up @@ -183,3 +185,26 @@ export async function sendWarpRouteMessageRoundTrip(
await hyperlaneWarpSendRelay(chain1, chain2, warpCoreConfigPath);
return hyperlaneWarpSendRelay(chain2, chain1, warpCoreConfigPath);
}

export async function hyperlaneSendMessage(
origin: string,
destination: string,
) {
return $`yarn workspace @hyperlane-xyz/cli run hyperlane send message \
--registry ${REGISTRY_PATH} \
--origin ${origin} \
--destination ${destination} \
--key ${ANVIL_KEY} \
--verbosity debug \
--yes`;
}

export function hyperlaneRelayer(chains: string[], warp?: string) {
return $`yarn workspace @hyperlane-xyz/cli run hyperlane relayer \
--registry ${REGISTRY_PATH} \
--chains ${chains.join(',')} \
--warp ${warp ?? ''} \
--key ${ANVIL_KEY} \
--verbosity debug \
--yes`;
}
3 changes: 2 additions & 1 deletion typescript/cli/src/tests/commands/warp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,10 @@ export async function hyperlaneWarpSendRelay(
origin: string,
destination: string,
warpCorePath: string,
relay = true,
) {
return $`yarn workspace @hyperlane-xyz/cli run hyperlane warp send \
--relay \
${relay ? '--relay' : ''} \
--registry ${REGISTRY_PATH} \
--overrides " " \
--origin ${origin} \
Expand Down
82 changes: 82 additions & 0 deletions typescript/cli/src/tests/relay.e2e-test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
import { TokenType } from '@hyperlane-xyz/sdk';

import { writeYamlOrJson } from '../utils/files.js';

import { hyperlaneCoreDeploy } from './commands/core.js';
import {
REGISTRY_PATH,
hyperlaneRelayer,
hyperlaneSendMessage,
} from './commands/helpers.js';
import {
hyperlaneWarpDeploy,
hyperlaneWarpSendRelay,
} from './commands/warp.js';

const CHAIN_NAME_1 = 'anvil2';
const CHAIN_NAME_2 = 'anvil3';

const SYMBOL = 'ETH';

const WARP_DEPLOY_OUTPUT = `${REGISTRY_PATH}/deployments/warp_routes/${SYMBOL}/${CHAIN_NAME_1}-${CHAIN_NAME_2}-config.yaml`;

const EXAMPLES_PATH = './examples';
const CORE_CONFIG_PATH = `${EXAMPLES_PATH}/core-config.yaml`;

const TEST_TIMEOUT = 100_000; // Long timeout since these tests can take a while
describe('hyperlane relayer e2e tests', async function () {
this.timeout(TEST_TIMEOUT);

before(async () => {
await hyperlaneCoreDeploy(CHAIN_NAME_1, CORE_CONFIG_PATH);
await hyperlaneCoreDeploy(CHAIN_NAME_2, CORE_CONFIG_PATH);

const warpConfig = {
anvil2: {
type: TokenType.native,
symbol: SYMBOL,
},
anvil3: {
type: TokenType.synthetic,
symbol: SYMBOL,
},
};

const warpConfigPath = './tmp/warp-route-config.yaml';
writeYamlOrJson(warpConfigPath, warpConfig);
await hyperlaneWarpDeploy(warpConfigPath);
});

describe('relayer', () => {
it('should relay core messages', async () => {
const process = hyperlaneRelayer([CHAIN_NAME_1, CHAIN_NAME_2]);

await hyperlaneSendMessage(CHAIN_NAME_1, CHAIN_NAME_2);
await hyperlaneSendMessage(CHAIN_NAME_2, CHAIN_NAME_1);

await process.kill('SIGINT');
});

it('should relay warp messages', async () => {
const process = hyperlaneRelayer(
[CHAIN_NAME_1, CHAIN_NAME_2],
WARP_DEPLOY_OUTPUT,
);

await hyperlaneWarpSendRelay(
CHAIN_NAME_1,
CHAIN_NAME_2,
WARP_DEPLOY_OUTPUT,
false,
);
await hyperlaneWarpSendRelay(
CHAIN_NAME_2,
CHAIN_NAME_1,
WARP_DEPLOY_OUTPUT,
false,
);

await process.kill('SIGINT');
});
});
});
1 change: 1 addition & 0 deletions typescript/cli/src/utils/relay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@ export function stubMerkleTreeConfig(
},
},
ism: {},
backlog: [],
});
}
Loading

0 comments on commit f01854c

Please sign in to comment.