Skip to content

Commit

Permalink
refactor file locations
Browse files Browse the repository at this point in the history
  • Loading branch information
Mo-Hussain committed Jan 29, 2025
1 parent f7bb65f commit 7570f80
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 38 deletions.
5 changes: 2 additions & 3 deletions typescript/infra/scripts/agent-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import { Contexts } from '../config/contexts.js';
import { agents } from '../config/environments/agents.js';
import { WarpRouteIds } from '../config/environments/mainnet3/warp/warpIds.js';
import { validatorBaseConfigsFn } from '../config/environments/utils.js';
import { AlertType } from '../config/grafanaAlerts.js';
import {
getChain,
getChainAddresses,
Expand All @@ -44,6 +43,8 @@ import {
EnvironmentConfig,
assertEnvironment,
} from '../src/config/environment.js';
import { BalanceThresholdType } from '../src/config/funding/balances.js';
import { AlertType } from '../src/config/funding/grafanaAlerts.js';
import { Role } from '../src/roles.js';
import {
assertContext,
Expand All @@ -55,8 +56,6 @@ import {
writeMergedJSONAtPath,
} from '../src/utils/utils.js';

import { BalanceThresholdType } from './funding/utils/constants.js';

const debugLog = rootLogger.child({ module: 'infra:scripts:utils' }).debug;

export enum Modules {
Expand Down
10 changes: 4 additions & 6 deletions typescript/infra/scripts/funding/calculate-relayer-daily-burn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@ import { rootLogger } from '@hyperlane-xyz/utils';
import rawDailyRelayerBurn from '../../config/environments/mainnet3/balances/dailyRelayerBurn.json';
import { mainnet3SupportedChainNames } from '../../config/environments/mainnet3/supportedChainNames.js';
import rawTokenPrices from '../../config/environments/mainnet3/tokenPrices.json';
import { RELAYER_MIN_DOLLAR_BALANCE_PER_DAY } from '../../src/config/funding/balances.js';
import { formatDailyRelayerBurn } from '../../src/funding/grafana.js';
import { fetchLatestGCPSecret } from '../../src/utils/gcloud.js';
import { writeJsonAtPath } from '../../src/utils/utils.js';

import { RELAYER_MIN_DOLLAR_BALANCE_PER_DAY } from './utils/constants.js';
import { formatDailyRelayerBurn } from './utils/grafana.js';

const tokenPrices: ChainMap<string> = rawTokenPrices;
const currentDailyRelayerBurn: ChainMap<number> = rawDailyRelayerBurn;

Expand All @@ -31,9 +30,8 @@ async function main() {
`Token prices missing for chains: ${chainsMissingInTokenPrices.join(
', ',
)} consider adding them to tokenPrices.json and running the script again.`,

process.exit(1),
);
process.exit(1);
}

const sql = await getReadOnlyScraperDb();
Expand Down Expand Up @@ -84,7 +82,7 @@ async function fetchDailyRelayerBurnData(sql: Sql) {
WHERE
mv.send_occurred_at >= CURRENT_TIMESTAMP - (INTERVAL '1 day' * ${LOOK_BACK_DAYS})
AND dest_domain.is_test_net IS FALSE
AND mv.destination_domain_id not in (1408864445, 1399811149) -- ignore sealevel chains as scrapper does not capture all costs
AND mv.destination_domain_id not in (1408864445, 1399811149) -- ignore sealevel chains as scraper does not capture all costs
AND mv.is_delivered IS TRUE
GROUP BY
dest_domain.name
Expand Down
11 changes: 5 additions & 6 deletions typescript/infra/scripts/funding/read-alert-thresholds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@ import yargs from 'yargs';

import { rootLogger } from '@hyperlane-xyz/utils';

import { alertConfigMapping } from '../../config/grafanaAlerts.js';
import { writeJsonAtPath } from '../../src/utils/utils.js';
import { withAlertTypeRequired, withWrite } from '../agent-utils.js';

import { THRESHOLD_CONFIG_PATH } from '../../src/config/funding/balances.js';
import { alertConfigMapping } from '../../src/config/funding/grafanaAlerts.js';
import {
THRESHOLD_CONFIG_PATH,
getAlertThresholds,
sortThresholds,
} from './utils/grafana.js';
} from '../../src/funding/grafana.js';
import { writeJsonAtPath } from '../../src/utils/utils.js';
import { withAlertTypeRequired, withWrite } from '../agent-utils.js';

async function main() {
const { alertType, write } = await withWrite(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,20 @@ import { ChainMap } from '@hyperlane-xyz/sdk';
import { rootLogger } from '@hyperlane-xyz/utils';

import rawDailyBurn from '../../config/environments/mainnet3/balances/dailyRelayerBurn.json';
import { readJSONAtPath, writeJsonAtPath } from '../../src/utils/utils.js';
import {
withBalanceThresholdConfig,
withConfirmAllChoices,
} from '../agent-utils.js';

import {
BalanceThresholdType,
THRESHOLD_CONFIG_PATH,
balanceThresholdConfigMapping,
} from './utils/constants.js';
} from '../../src/config/funding/balances.js';
import {
THRESHOLD_CONFIG_PATH,
formatDailyRelayerBurn,
sortThresholds,
} from './utils/grafana.js';
} from '../../src/funding/grafana.js';
import { readJSONAtPath, writeJsonAtPath } from '../../src/utils/utils.js';
import {
withBalanceThresholdConfig,
withConfirmAllChoices,
} from '../agent-utils.js';

const dailyBurn: ChainMap<number> = rawDailyBurn;

Expand Down
14 changes: 8 additions & 6 deletions typescript/infra/scripts/funding/write-alert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,19 @@ import yargs from 'yargs';
import { ChainMap } from '@hyperlane-xyz/sdk';
import { rootLogger } from '@hyperlane-xyz/utils';

import { AlertType, alertConfigMapping } from '../../config/grafanaAlerts.js';
import { readJSONAtPath } from '../../src/utils/utils.js';
import { withAlertType, withConfirmAllChoices } from '../agent-utils.js';

import { THRESHOLD_CONFIG_PATH } from '../../src/config/funding/balances.js';
import {
AlertType,
alertConfigMapping,
} from '../../src/config/funding/grafanaAlerts.js';
import {
THRESHOLD_CONFIG_PATH,
fetchGrafanaAlert,
fetchServiceAccountToken,
generateQuery,
updateGrafanaAlert,
} from './utils/grafana.js';
} from '../../src/funding/grafana.js';
import { readJSONAtPath } from '../../src/utils/utils.js';
import { withAlertType, withConfirmAllChoices } from '../agent-utils.js';

async function main() {
const { alertType, all } = await withConfirmAllChoices(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ interface BalanceThresholdConfig {
choiceLabel: string;
}

export const THRESHOLD_CONFIG_PATH = './config/environments/mainnet3/balances';

const RELAYER_BALANCE_TARGET_DAYS = 8;
const RELAYER_MIN_DOLLAR_BALANCE_TARGET = 25;
export const RELAYER_MIN_DOLLAR_BALANCE_PER_DAY =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ import {
HIGH_URGENCY_RELAYER_HEADER,
LOW_URGENCY_KEY_FUNDER_FOOTER,
LOW_URGENCY_KEY_FUNDER_HEADER,
} from '../scripts/funding/utils/alert-query-templates.js';
} from './alert-query-templates.js';
import {
BalanceThresholdType,
balanceThresholdConfigMapping,
} from '../scripts/funding/utils/constants.js';
} from './balances.js';

export const GRAFANA_URL = 'https://abacusworks.grafana.net';

export enum AlertType {
LowUrgencyKeyFunderBalance = 'lowUrgencyKeyFunderBalance',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,13 @@ import { rootLogger } from '@hyperlane-xyz/utils';

import {
AlertType,
GRAFANA_URL,
ProvisionedAlertRule,
WalletName,
alertConfigMapping,
walletNameQueryFormat,
} from '../../../config/grafanaAlerts.js';
import { fetchGCPSecret } from '../../../src/utils/gcloud.js';

export const GRAFANA_URL = 'https://abacusworks.grafana.net';

export const THRESHOLD_CONFIG_PATH = './config/environments/mainnet3/balances';
} from '../config/funding/grafanaAlerts.js';
import { fetchGCPSecret } from '../utils/gcloud.js';

export const logger = rootLogger.child({ module: 'grafana' });

Expand Down

0 comments on commit 7570f80

Please sign in to comment.