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: monitor sealevel ATA payer balances in the key funder #4533

Open
wants to merge 3 commits 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
2 changes: 1 addition & 1 deletion typescript/infra/config/environments/mainnet3/funding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const keyFunderConfig: KeyFunderConfig<
> = {
docker: {
repo: 'gcr.io/abacus-labs-dev/hyperlane-monorepo',
tag: '9c056c7-20240911-154400',
tag: '877656c-20240919-202332',
},
// We're currently using the same deployer/key funder key as mainnet2.
// To minimize nonce clobbering we offset the key funder cron
Expand Down
95 changes: 95 additions & 0 deletions typescript/infra/scripts/funding/fund-keys-from-deployer.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { EthBridger, getL2Network } from '@arbitrum/sdk';
import { CrossChainMessenger } from '@eth-optimism/sdk';
import { Connection, PublicKey } from '@solana/web3.js';
import { BigNumber, ethers } from 'ethers';
import { Gauge, Registry } from 'prom-client';
import { format } from 'util';

import { eclipsemainnet } from '@hyperlane-xyz/registry';
import {
ChainMap,
ChainName,
Expand All @@ -14,6 +16,7 @@ import { Address, objFilter, objMap, rootLogger } from '@hyperlane-xyz/utils';

import { Contexts } from '../../config/contexts.js';
import { getEnvAddresses } from '../../config/registry.js';
import { getSecretRpcEndpoints } from '../../src/agents/index.js';
import {
KeyAsAddress,
fetchLocalKeyAddresses,
Expand Down Expand Up @@ -96,6 +99,43 @@ const MIN_DELTA_DENOMINATOR = ethers.BigNumber.from(10);
const RC_FUNDING_DISCOUNT_NUMERATOR = ethers.BigNumber.from(2);
const RC_FUNDING_DISCOUNT_DENOMINATOR = ethers.BigNumber.from(10);

interface SealevelAccount {
pubkey: PublicKey;
walletName: string;
}

const sealevelAccountsToTrack: ChainMap<SealevelAccount[]> = {
solanamainnet: [
{
// WIF warp route ATA payer
pubkey: new PublicKey('R5oMfxcbjx4ZYK1B2Aic1weqwt2tQsRzFEGe5WJfAxh'),
walletName: 'WIF/eclipsemainnet-solanamainnet/ata-payer',
},
{
// USDC warp route ATA payer
pubkey: new PublicKey('A1XtL9mAzkNEpBPinrCpDRrPqVAFjgaxDk4ATFVoQVyc'),
walletName: 'USDC/eclipsemainnet-ethereum-solanamainnet/ata-payer',
},
],
eclipsemainnet: [
{
// WIF warp route ATA payer
pubkey: new PublicKey('HCQAfDd5ytAEidzR9g7CipjEGv2ZrSSZq1UY34oDFv8h'),
walletName: 'WIF/eclipsemainnet-solanamainnet/ata-payer',
},
{
// USDC warp route ATA payer
pubkey: new PublicKey('7arS1h8nwVVmmTVWSsu9rQ4WjLBN8iAi4DvHi8gWjBNC'),
walletName: 'USDC/eclipsemainnet-ethereum-solanamainnet/ata-payer',
},
{
// tETH warp route ATA payer
pubkey: new PublicKey('Hyy4jryRxgZm5pvuSx29fXxJ9J55SuDtXiCo89kmNuz5'),
walletName: 'tETH/eclipsemainnet-ethereum/ata-payer',
},
],
};

// Funds key addresses for multiple contexts from the deployer key of the context
// specified via the `--context` flag.
// The --contexts-and-roles flag is used to specify the contexts and the key roles
Expand Down Expand Up @@ -466,6 +506,13 @@ class ContextFunder {
false,
);

if (
this.environment === 'mainnet3' &&
this.context === Contexts.Hyperlane
) {
await this.updateSolanaWalletBalanceGauge();
}

return failureOccurred;
}

Expand Down Expand Up @@ -812,6 +859,54 @@ class ContextFunder {
),
);
}

private async updateSolanaWalletBalanceGauge() {
for (const chain of Object.keys(sealevelAccountsToTrack) as ChainName[]) {
await this.updateSealevelWalletBalanceAccounts(
chain,
sealevelAccountsToTrack[chain],
);
}
}

private async updateSealevelWalletBalanceAccounts(
chain: ChainName,
accounts: SealevelAccount[],
) {
const rpcUrls = await getSecretRpcEndpoints(this.environment, chain);
const provider = new Connection(rpcUrls[0], 'confirmed');

for (const { pubkey, walletName } of accounts) {
logger.info(
{
chain,
pubkey: pubkey.toString(),
walletName,
},
'Fetching sealevel wallet balance',
);
const balance = await provider.getBalance(pubkey);
logger.info(
{
balance,
chain,
pubkey: pubkey.toString(),
walletName,
},
'Got sealevel chain wallet balance',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
'Got sealevel chain wallet balance',
'Retrieved sealevel chain wallet balance',

);
walletBalanceGauge
.labels({
chain,
wallet_address: pubkey.toString(),
wallet_name: walletName,
token_symbol: 'Native',
token_name: 'Native',
...constMetricLabels,
})
.set(balance / 1e9);
}
}
}

async function getAddressInfo(
Expand Down
Loading