From b128b5fb5f7ec4f0abdc92684270e951e0f3bcda Mon Sep 17 00:00:00 2001 From: Trevor Porter Date: Mon, 18 Mar 2024 10:58:18 +0000 Subject: [PATCH 1/3] Hacky solana balance monitoring --- .../funding/fund-keys-from-deployer.ts | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/typescript/infra/scripts/funding/fund-keys-from-deployer.ts b/typescript/infra/scripts/funding/fund-keys-from-deployer.ts index a319f05f63..37ec1ff8cd 100644 --- a/typescript/infra/scripts/funding/fund-keys-from-deployer.ts +++ b/typescript/infra/scripts/funding/fund-keys-from-deployer.ts @@ -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'; @@ -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, @@ -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; }); @@ -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( From 935df9d3f0e521aa9845a32419fb10a85c891b4b Mon Sep 17 00:00:00 2001 From: Trevor Porter Date: Mon, 18 Mar 2024 11:59:09 +0000 Subject: [PATCH 2/3] update Dockerfile --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 3b9b30b71a..ec3c51ce6d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM node:16-alpine +FROM node:18-alpine WORKDIR /hyperlane-monorepo From 3f5e27a55d45246f0d52e97cf943b890202b875a Mon Sep 17 00:00:00 2001 From: Trevor Porter Date: Mon, 18 Mar 2024 12:18:01 +0000 Subject: [PATCH 3/3] update image --- typescript/infra/config/environments/mainnet2/funding.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/typescript/infra/config/environments/mainnet2/funding.ts b/typescript/infra/config/environments/mainnet2/funding.ts index 22b7e95abc..d25145a6e2 100644 --- a/typescript/infra/config/environments/mainnet2/funding.ts +++ b/typescript/infra/config/environments/mainnet2/funding.ts @@ -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