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

Hacky solana balance monitoring #3432

Merged
merged 3 commits into from
Mar 18, 2024
Merged
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 Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:16-alpine
FROM node:18-alpine

WORKDIR /hyperlane-monorepo

Expand Down
2 changes: 1 addition & 1 deletion typescript/infra/config/environments/mainnet2/funding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { environment } from './chains';
export const keyFunderConfig: KeyFunderConfig = {
docker: {
repo: 'gcr.io/abacus-labs-dev/hyperlane-monorepo',
tag: '98658d0-20231207-121541',
tag: '4798278-20240318-115942',
},
// We're currently using the same deployer key as mainnet.
// To minimize nonce clobbering we offset the key funder cron
Expand Down
58 changes: 58 additions & 0 deletions typescript/infra/scripts/funding/fund-keys-from-deployer.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { EthBridger, getL2Network } from '@arbitrum/sdk';
import { Connection, PublicKey } from '@solana/web3.js';
import { BigNumber, ethers } from 'ethers';
import { Gauge, Registry } from 'prom-client';
import { format } from 'util';
Expand All @@ -21,6 +22,7 @@ import {
} from '@hyperlane-xyz/utils';

import { Contexts } from '../../config/contexts';
import { getSecretRpcEndpoint } from '../../src/agents';
import { KeyAsAddress, getRoleKeysPerChain } from '../../src/agents/key-utils';
import {
BaseCloudAgentKey,
Expand Down Expand Up @@ -431,6 +433,14 @@ class ContextFunder {
const failure = await this.attemptToFundKey(key, chain);
failureOccurred ||= failure;
}

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

return failureOccurred;
});

Expand Down Expand Up @@ -709,6 +719,54 @@ class ContextFunder {
),
);
}

private async updateSolanaWalletBalanceGauge() {
const chain = 'solana';

const solanaRpcUrls = await getSecretRpcEndpoint(
this.environment,
chain,
false,
);
const solanaProvider = new Connection(solanaRpcUrls[0], 'confirmed');
const accounts = [
{
// The Solana relayer
pubkey: new PublicKey('CLT7m1JBCqJx6FM3obi9ohTnML1zmdzFcX2SgWj1D8qV'),
walletName: 'relayer',
},
{
// The account used to pay for state rent used by new ZBC balances
pubkey: new PublicKey('DRoxXLkV2sAsZb7bPbCJQnucTxvQCcfzfmThC3ZVNorv'),
walletName: 'nautilus-zbc-rent',
},
];

for (const { pubkey, walletName } of accounts) {
log('Fetching Solana wallet balance', {
chain,
pubkey: pubkey.toString(),
walletName,
});
const balance = await solanaProvider.getBalance(pubkey);
log('Got Solana wallet balance', {
balance,
chain,
pubkey: pubkey.toString(),
walletName,
});
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