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

feat: filter chains to check depending on Operator chain #5008

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
19 changes: 17 additions & 2 deletions typescript/cli/src/avs/check.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@ import {
ValidatorAnnounce__factory,
} from '@hyperlane-xyz/core';
import { ChainMap, ChainName, MultiProvider } from '@hyperlane-xyz/sdk';
import { Address, ProtocolType, isObjEmpty } from '@hyperlane-xyz/utils';
import {
Address,
OperatorChain,
ProtocolType,
isObjEmpty,
} from '@hyperlane-xyz/utils';

import { CommandContext } from '../context/types.js';
import {
Expand Down Expand Up @@ -81,7 +86,7 @@ export const checkValidatorAvsSetup = async (
);

if (!isObjEmpty(avsOperatorRecord)) {
await setValidatorInfo(context, avsOperatorRecord, topLevelErrors);
await setValidatorInfo(chain, context, avsOperatorRecord, topLevelErrors);
}

logOutput(avsOperatorRecord, topLevelErrors);
Expand Down Expand Up @@ -226,6 +231,7 @@ const setOperatorName = async (
};

const setValidatorInfo = async (
operatorChain: string,
context: CommandContext,
avsOperatorRecord: Record<Address, ValidatorInfo>,
topLevelErrors: string[],
Expand All @@ -242,6 +248,15 @@ const setValidatorInfo = async (
// skip if chain is not an Ethereum chain
if (chainMetadata[chain].protocol !== ProtocolType.Ethereum) continue;

// skip if chain network type match the operator chain
if (
(operatorChain === OperatorChain.Ethereum &&
chainMetadata[chain].isTestnet) ||
(operatorChain === OperatorChain.Holesky &&
!chainMetadata[chain].isTestnet)
)
continue;

const chainAddresses = addresses[chain];

// skip if no contract addresses are found for this chain
Expand Down
2 changes: 2 additions & 0 deletions typescript/utils/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ export {
MerkleProof,
MessageStatus,
Numberish,
OperatorChain,
OperatorChainValue,
ParsedLegacyMultisigIsmMetadata,
ParsedMessage,
ProtocolSmallestUnit,
Expand Down
7 changes: 7 additions & 0 deletions typescript/utils/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
import type { SignatureLike } from '@ethersproject/bytes';
import type { BigNumber, ethers } from 'ethers';

export enum OperatorChain {
Ethereum = 'ethereum',
Holesky = 'holesky',
}
// A type that also allows for literal values of the enum
export type OperatorChainValue = `${OperatorChain}`;

export enum ProtocolType {
Ethereum = 'ethereum',
Sealevel = 'sealevel',
Expand Down
Loading