Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into feat/zksync-support
Browse files Browse the repository at this point in the history
  • Loading branch information
ljankovic-txfusion committed Dec 17, 2024
2 parents 6aba349 + 5f380e5 commit 231ab4c
Show file tree
Hide file tree
Showing 25 changed files with 272 additions and 103 deletions.
9 changes: 9 additions & 0 deletions .changeset/dull-pianos-kiss.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
'@hyperlane-xyz/helloworld': minor
'@hyperlane-xyz/widgets': minor
'@hyperlane-xyz/infra': minor
'@hyperlane-xyz/cli': minor
'@hyperlane-xyz/sdk': minor
---

Add FeeHook and Swell to pz and ez eth config generator. Bump up Registry 6.6.0
5 changes: 5 additions & 0 deletions .changeset/hot-spies-share.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@hyperlane-xyz/cli': minor
---

fix signer strategy init for broken cli commands
5 changes: 5 additions & 0 deletions .changeset/long-llamas-fly.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@hyperlane-xyz/cli": patch
---

Suppress help on CLI failures
5 changes: 5 additions & 0 deletions .changeset/nine-eyes-smile.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@hyperlane-xyz/core': minor
---

Made releaseValueToRecipient internal
2 changes: 1 addition & 1 deletion .registryrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
c7891cdf0fc6a1541c41e19251611c9152ee8bf9
bde63f7c32e8d169d7e3163b14b5bb25bd3d5042
4 changes: 4 additions & 0 deletions rust/main/config/mainnet_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -925,6 +925,9 @@
"protocolFee": "0x8B05BF30F6247a90006c5837eA63C7905D79e6d8",
"proxyAdmin": "0x75EE15Ee1B4A75Fa3e2fDF5DF3253c25599cc659",
"rpcUrls": [
{
"http": "https://rpc.ankr.com/eth"
},
{
"http": "https://ethereum.publicnode.com"
},
Expand Down Expand Up @@ -6322,6 +6325,7 @@
"validatorAnnounce": "0x1196055C61af3e3DA6f8458B07b255a72b64Bcf7"
},
"treasure": {
"batchContractAddress": "0x2e29fe39496a56856D8698bD43e1dF4D0CE6266a",
"blockExplorers": [
{
"apiUrl": "https://rpc-explorer-verify.treasure.lol/contract_verification",
Expand Down
32 changes: 16 additions & 16 deletions solidity/contracts/isms/hook/AbstractMessageIdAuthorizedIsm.sol
Original file line number Diff line number Diff line change
Expand Up @@ -78,28 +78,13 @@ abstract contract AbstractMessageIdAuthorizedIsm is
) external virtual returns (bool) {
bool verified = isVerified(message);
if (verified) {
releaseValueToRecipient(message);
_releaseValueToRecipient(message);
}
return verified;
}

// ============ Public Functions ============

/**
* @notice Release the value to the recipient if the message is verified.
* @param message Message to release value for.
*/
function releaseValueToRecipient(bytes calldata message) public {
bytes32 messageId = message.id();
uint256 _msgValue = verifiedMessages[messageId].clearBit(
VERIFIED_MASK_INDEX
);
if (_msgValue > 0) {
verifiedMessages[messageId] -= _msgValue;
payable(message.recipientAddress()).sendValue(_msgValue);
}
}

/**
* @notice Check if a message is verified through preVerifyMessage first.
* @param message Message to check.
Expand Down Expand Up @@ -138,6 +123,21 @@ abstract contract AbstractMessageIdAuthorizedIsm is

// ============ Internal Functions ============

/**
* @notice Release the value to the recipient if the message is verified.
* @param message Message to release value for.
*/
function _releaseValueToRecipient(bytes calldata message) internal {
bytes32 messageId = message.id();
uint256 _msgValue = verifiedMessages[messageId].clearBit(
VERIFIED_MASK_INDEX
);
if (_msgValue > 0) {
verifiedMessages[messageId] -= _msgValue;
payable(message.recipientAddress()).sendValue(_msgValue);
}
}

/**
* @notice Check if sender is authorized to message `preVerifyMessage`.
*/
Expand Down
2 changes: 1 addition & 1 deletion solidity/contracts/isms/hook/ArbL2ToL1Ism.sol
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ contract ArbL2ToL1Ism is
_verifyWithOutboxCall(metadata, message);
require(isVerified(message), "ArbL2ToL1Ism: message not verified");
}
releaseValueToRecipient(message);
_releaseValueToRecipient(message);
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion solidity/contracts/isms/hook/OPL2ToL1Ism.sol
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ contract OPL2ToL1Ism is
_verifyWithPortalCall(metadata, message);
require(isVerified(message), "OPL2ToL1Ism: message not verified");
}
releaseValueToRecipient(message);
_releaseValueToRecipient(message);
return true;
}

Expand Down
12 changes: 1 addition & 11 deletions typescript/cli/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@ import { configureLogger, errorRed } from './src/logger.js';
import { checkVersion } from './src/utils/version-check.js';
import { VERSION } from './src/version.js';

// From yargs code:
const MISSING_PARAMS_ERROR = 'Not enough non-option arguments';

console.log(chalk.blue('Hyperlane'), chalk.magentaBright('CLI'));

await checkVersion();
Expand Down Expand Up @@ -78,14 +75,7 @@ try {
.demandCommand()
.strict()
.help()
.fail((msg, err, yargs) => {
if (msg && !msg.includes(MISSING_PARAMS_ERROR)) errorRed('Error: ' + msg);
console.log('');
yargs.showHelp();
console.log('');
if (err) errorRed(err.toString());
process.exit(1);
}).argv;
.showHelpOnFail(false).argv;
} catch (error: any) {
errorRed('Error: ' + error.message);
}
2 changes: 1 addition & 1 deletion typescript/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"dependencies": {
"@aws-sdk/client-kms": "^3.577.0",
"@aws-sdk/client-s3": "^3.577.0",
"@hyperlane-xyz/registry": "6.3.0",
"@hyperlane-xyz/registry": "6.6.0",
"@hyperlane-xyz/sdk": "7.3.0",
"@hyperlane-xyz/utils": "7.3.0",
"@inquirer/core": "9.0.10",
Expand Down
3 changes: 2 additions & 1 deletion typescript/cli/src/commands/signCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ export const SIGN_COMMANDS = [
export function isSignCommand(argv: any): boolean {
//TODO: fix reading and checking warp without signer, and remove this
const temporarySignCommandsCheck =
argv._[0] === 'warp' && (argv._[1] === 'read' || argv._[1] === 'check');
argv._[0] === 'warp' &&
(argv._[1] === 'read' || argv._[1] === 'check' || argv._[1] === 'verify');
return (
SIGN_COMMANDS.includes(argv._[0]) ||
(argv._.length > 1 && SIGN_COMMANDS.includes(argv._[1])) ||
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { CommandType } from '../../../commands/signCommands.js';

import { MultiChainResolver } from './MultiChainResolver.js';
import { SingleChainResolver } from './SingleChainResolver.js';
import { ChainResolver } from './types.js';

/**
Expand All @@ -11,13 +10,16 @@ import { ChainResolver } from './types.js';
export class ChainResolverFactory {
private static strategyMap: Map<CommandType, () => ChainResolver> = new Map([
[CommandType.WARP_DEPLOY, () => MultiChainResolver.forWarpRouteConfig()],
[CommandType.WARP_SEND, () => MultiChainResolver.forOriginDestination()],
// Using the forRelayer resolver because warp send allows the user to self relay the tx
[CommandType.WARP_SEND, () => MultiChainResolver.forRelayer()],
[CommandType.WARP_APPLY, () => MultiChainResolver.forWarpRouteConfig()],
[CommandType.WARP_READ, () => MultiChainResolver.forWarpCoreConfig()],
[CommandType.WARP_CHECK, () => MultiChainResolver.forWarpCoreConfig()],
[CommandType.SEND_MESSAGE, () => MultiChainResolver.forOriginDestination()],
// Using the forRelayer resolver because send allows the user to self relay the tx
[CommandType.SEND_MESSAGE, () => MultiChainResolver.forRelayer()],
[CommandType.AGENT_KURTOSIS, () => MultiChainResolver.forAgentKurtosis()],
[CommandType.STATUS, () => MultiChainResolver.forOriginDestination()],
// Using the forRelayer resolver because status allows the user to self relay the tx
[CommandType.STATUS, () => MultiChainResolver.forRelayer()],
[CommandType.SUBMIT, () => MultiChainResolver.forStrategyConfig()],
[CommandType.RELAYER, () => MultiChainResolver.forRelayer()],
[CommandType.CORE_APPLY, () => MultiChainResolver.forCoreApply()],
Expand All @@ -30,7 +32,7 @@ export class ChainResolverFactory {
static getStrategy(argv: Record<string, any>): ChainResolver {
const commandKey = `${argv._[0]}:${argv._[1] || ''}`.trim() as CommandType;
const createStrategy =
this.strategyMap.get(commandKey) || (() => new SingleChainResolver());
this.strategyMap.get(commandKey) || (() => MultiChainResolver.default());
return createStrategy();
}
}
76 changes: 41 additions & 35 deletions typescript/cli/src/context/strategies/chain/MultiChainResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import {
DeployedCoreAddresses,
DeployedCoreAddressesSchema,
EvmCoreModule,
MultiProvider,
} from '@hyperlane-xyz/sdk';
import { assert } from '@hyperlane-xyz/utils';
import { ProtocolType, assert } from '@hyperlane-xyz/utils';

import { DEFAULT_WARP_ROUTE_DEPLOYMENT_CONFIG_PATH } from '../../../commands/options.js';
import { readCoreDeployConfigs } from '../../../config/core.js';
Expand All @@ -26,13 +27,12 @@ import { getWarpCoreConfigOrExit } from '../../../utils/warp.js';
import { ChainResolver } from './types.js';

enum ChainSelectionMode {
ORIGIN_DESTINATION,
AGENT_KURTOSIS,
WARP_CONFIG,
WARP_READ,
STRATEGY,
RELAYER,
CORE_APPLY,
DEFAULT,
}

// This class could be broken down into multiple strategies
Expand All @@ -54,13 +54,11 @@ export class MultiChainResolver implements ChainResolver {
return this.resolveAgentChains(argv);
case ChainSelectionMode.STRATEGY:
return this.resolveStrategyChains(argv);
case ChainSelectionMode.RELAYER:
return this.resolveRelayerChains(argv);
case ChainSelectionMode.CORE_APPLY:
return this.resolveCoreApplyChains(argv);
case ChainSelectionMode.ORIGIN_DESTINATION:
case ChainSelectionMode.DEFAULT:
default:
return this.resolveOriginDestinationChains(argv);
return this.resolveRelayerChains(argv);
}
}

Expand Down Expand Up @@ -119,28 +117,6 @@ export class MultiChainResolver implements ChainResolver {
return [argv.origin, ...argv.targets];
}

private async resolveOriginDestinationChains(
argv: Record<string, any>,
): Promise<ChainName[]> {
const { chainMetadata } = argv.context;

argv.origin =
argv.origin ??
(await runSingleChainSelectionStep(
chainMetadata,
'Select the origin chain',
));

argv.destination =
argv.destination ??
(await runSingleChainSelectionStep(
chainMetadata,
'Select the destination chain',
));

return [argv.origin, argv.destination];
}

private async resolveStrategyChains(
argv: Record<string, any>,
): Promise<ChainName[]> {
Expand All @@ -151,7 +127,29 @@ export class MultiChainResolver implements ChainResolver {
private async resolveRelayerChains(
argv: Record<string, any>,
): Promise<ChainName[]> {
return argv.chains.split(',').map((item: string) => item.trim());
const { multiProvider } = argv.context;
const chains = [];

if (argv.origin) {
chains.push(argv.origin);
}

if (argv.destination) {
chains.push(argv.destination);
}

if (!argv.chains) {
return Array.from(
new Set([...chains, ...this.getEvmChains(multiProvider)]),
);
}

return Array.from(
new Set([
...chains,
...argv.chains.split(',').map((item: string) => item.trim()),
]),
);
}

private async getWarpRouteConfigChains(
Expand Down Expand Up @@ -219,16 +217,20 @@ export class MultiChainResolver implements ChainResolver {
}
}

static forAgentKurtosis(): MultiChainResolver {
return new MultiChainResolver(ChainSelectionMode.AGENT_KURTOSIS);
private getEvmChains(multiProvider: MultiProvider): ChainName[] {
const chains = multiProvider.getKnownChainNames();

return chains.filter(
(chain) => multiProvider.getProtocol(chain) === ProtocolType.Ethereum,
);
}

static forOriginDestination(): MultiChainResolver {
return new MultiChainResolver(ChainSelectionMode.ORIGIN_DESTINATION);
static forAgentKurtosis(): MultiChainResolver {
return new MultiChainResolver(ChainSelectionMode.AGENT_KURTOSIS);
}

static forRelayer(): MultiChainResolver {
return new MultiChainResolver(ChainSelectionMode.RELAYER);
return new MultiChainResolver(ChainSelectionMode.DEFAULT);
}

static forStrategyConfig(): MultiChainResolver {
Expand All @@ -246,4 +248,8 @@ export class MultiChainResolver implements ChainResolver {
static forCoreApply(): MultiChainResolver {
return new MultiChainResolver(ChainSelectionMode.CORE_APPLY);
}

static default(): MultiChainResolver {
return new MultiChainResolver(ChainSelectionMode.DEFAULT);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,12 @@ export class MultiProtocolSignerManager {
let privateKey: string;

if (this.options.key) {
this.logger.info(
this.logger.debug(
`Using private key passed via CLI --key flag for chain ${chain}`,
);
privateKey = this.options.key;
} else if (ENV.HYP_KEY) {
this.logger.info(`Using private key from .env for chain ${chain}`);
this.logger.debug(`Using private key from .env for chain ${chain}`);
privateKey = ENV.HYP_KEY;
} else {
privateKey = await this.extractPrivateKey(chain, signerStrategy);
Expand All @@ -145,7 +145,7 @@ export class MultiProtocolSignerManager {
`No private key found for chain ${chain}`,
);

this.logger.info(
this.logger.debug(
`Extracting private key from strategy config/user prompt for chain ${chain}`,
);
return strategyConfig.privateKey;
Expand Down
2 changes: 1 addition & 1 deletion typescript/helloworld/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"version": "7.3.0",
"dependencies": {
"@hyperlane-xyz/core": "5.8.3",
"@hyperlane-xyz/registry": "6.3.0",
"@hyperlane-xyz/registry": "6.6.0",
"@hyperlane-xyz/sdk": "7.3.0",
"@openzeppelin/contracts-upgradeable": "^4.9.3",
"ethers": "^5.7.2"
Expand Down
3 changes: 1 addition & 2 deletions typescript/infra/config/environments/mainnet3/agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -276,8 +276,7 @@ export const hyperlaneContextAgentChainConfig: AgentChainConfig<
degenchain: true,
dogechain: true,
duckchain: true,
// Disabled until we get archival RPC for Eclipse
eclipsemainnet: false,
eclipsemainnet: true,
endurance: true,
ethereum: true,
everclear: true,
Expand Down
Loading

0 comments on commit 231ab4c

Please sign in to comment.