Skip to content

Commit 8e8fcf1

Browse files
authored
[xc-admin] Introduce the new UPGRADE_OPS_KEY (#716)
* Do it * Cleanup
1 parent f62676d commit 8e8fcf1

File tree

9 files changed

+62
-26
lines changed

9 files changed

+62
-26
lines changed

governance/xc_admin/packages/xc_admin_common/src/deterministic_oracle_accounts.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
SystemProgram,
1010
TransactionInstruction,
1111
} from "@solana/web3.js";
12-
import { OPS_KEY } from "./multisig";
12+
import { PRICE_FEED_OPS_KEY } from "./multisig";
1313

1414
/**
1515
* Get seed for deterministic creation of a price/product account
@@ -58,7 +58,7 @@ export async function findDetermisticAccountAddress(
5858
): Promise<[PublicKey, string]> {
5959
const seed: string = getSeed(type, symbol);
6060
const address: PublicKey = await PublicKey.createWithSeed(
61-
OPS_KEY,
61+
PRICE_FEED_OPS_KEY,
6262
seed,
6363
getPythProgramKeyForCluster(cluster)
6464
);

governance/xc_admin/packages/xc_admin_common/src/multisig.ts

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { PublicKey } from "@solana/web3.js";
1+
import { Cluster, PublicKey } from "@solana/web3.js";
22
import Squads, {
33
DEFAULT_MULTISIG_PROGRAM_ID,
44
getIxPDA,
@@ -8,13 +8,53 @@ import { InstructionAccount, TransactionAccount } from "@sqds/mesh/lib/types";
88
import BN from "bn.js";
99
import lodash from "lodash";
1010

11+
/**
12+
* Address of the upgrade multisig
13+
*/
14+
export const UPGRADE_MULTISIG: Record<Cluster | "localnet", PublicKey> = {
15+
"mainnet-beta": new PublicKey("FVQyHcooAtThJ83XFrNnv74BcinbRH3bRmfFamAHBfuj"),
16+
testnet: new PublicKey("FVQyHcooAtThJ83XFrNnv74BcinbRH3bRmfFamAHBfuj"),
17+
devnet: new PublicKey("6baWtW1zTUVMSJHJQVxDUXWzqrQeYBr6mu31j3bTKwY3"),
18+
localnet: new PublicKey("FVQyHcooAtThJ83XFrNnv74BcinbRH3bRmfFamAHBfuj"),
19+
};
20+
21+
/**
22+
* Address of the price feed multisig
23+
*/
24+
export const PRICE_FEED_MULTISIG: Record<Cluster | "localnet", PublicKey> = {
25+
"mainnet-beta": new PublicKey("92hQkq8kBgCUcF9yWN8URZB9RTmA4mZpDGtbiAWA74Z8"),
26+
testnet: new PublicKey("92hQkq8kBgCUcF9yWN8URZB9RTmA4mZpDGtbiAWA74Z8"),
27+
devnet: new PublicKey("92hQkq8kBgCUcF9yWN8URZB9RTmA4mZpDGtbiAWA74Z8"),
28+
localnet: new PublicKey("92hQkq8kBgCUcF9yWN8URZB9RTmA4mZpDGtbiAWA74Z8"),
29+
};
30+
1131
/**
1232
* Address of the ops key (same on all networks)
1333
*/
14-
export const OPS_KEY = new PublicKey(
34+
export const PRICE_FEED_OPS_KEY = new PublicKey(
1535
"ACzP6RC98vcBk9oTeAwcH1o5HJvtBzU59b5nqdwc7Cxy"
1636
);
1737

38+
export const UPGRADE_OPS_KEY = new PublicKey(
39+
"opsLibxVY7Vz5eYMmSfX8cLFCFVYTtH6fr6MiifMpA7"
40+
);
41+
42+
export function getOpsKey(vault: PublicKey): PublicKey {
43+
if (
44+
Object.values(PRICE_FEED_MULTISIG).some((pubkey) => {
45+
return pubkey.equals(vault);
46+
})
47+
)
48+
return PRICE_FEED_OPS_KEY;
49+
else if (
50+
Object.values(UPGRADE_MULTISIG).some((pubkey) => {
51+
return pubkey.equals(vault);
52+
})
53+
)
54+
return UPGRADE_OPS_KEY;
55+
else throw new Error("Unrecognized multisig vault");
56+
}
57+
1858
/**
1959
* Find all proposals for vault `vault` using Squads client `squad`
2060
* @param squad Squads client

governance/xc_admin/packages/xc_admin_common/src/propose.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import {
1717
deriveFeeCollectorKey,
1818
} from "@certusone/wormhole-sdk/lib/cjs/solana/wormhole";
1919
import { ExecutePostedVaa } from "./governance_payload/ExecutePostedVaa";
20-
import { OPS_KEY } from "./multisig";
20+
import { getOpsKey, PRICE_FEED_OPS_KEY } from "./multisig";
2121

2222
export const MAX_EXECUTOR_PAYLOAD_SIZE = PACKET_DATA_SIZE - 687; // Bigger payloads won't fit in one addInstruction call when adding to the proposal
2323
export const SIZE_OF_SIGNED_BATCH = 30;
@@ -311,7 +311,12 @@ export async function wrapAsRemoteInstruction(
311311

312312
const buffer: Buffer = new ExecutePostedVaa("pythnet", instructions).encode();
313313

314-
const accounts = getPostMessageAccounts(wormholeAddress, emitter, messagePDA);
314+
const accounts = getPostMessageAccounts(
315+
wormholeAddress,
316+
emitter,
317+
getOpsKey(vault),
318+
messagePDA
319+
);
315320

316321
return {
317322
instruction: await wormholeProgram.methods
@@ -326,14 +331,15 @@ export async function wrapAsRemoteInstruction(
326331
function getPostMessageAccounts(
327332
wormholeAddress: PublicKey,
328333
emitter: PublicKey,
334+
payer: PublicKey,
329335
message: PublicKey
330336
) {
331337
return {
332338
bridge: deriveWormholeBridgeDataKey(wormholeAddress),
333339
message,
334340
emitter,
335341
sequence: deriveEmitterSequenceKey(emitter, wormholeAddress),
336-
payer: OPS_KEY,
342+
payer,
337343
feeCollector: deriveFeeCollectorKey(wormholeAddress),
338344
clock: SYSVAR_CLOCK_PUBKEY,
339345
rent: SYSVAR_RENT_PUBKEY,

governance/xc_admin/packages/xc_admin_frontend/components/PermissionDepermissionKey.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ import {
1212
getMultisigCluster,
1313
isRemoteCluster,
1414
mapKey,
15+
PRICE_FEED_MULTISIG,
1516
proposeInstructions,
1617
WORMHOLE_ADDRESS,
1718
} from 'xc_admin_common'
1819
import { ClusterContext } from '../contexts/ClusterContext'
1920
import { usePythContext } from '../contexts/PythContext'
20-
import { PRICE_FEED_MULTISIG } from '../hooks/useMultisig'
2121
import { ProductRawConfig } from '../hooks/usePyth'
2222
import Arrow from '../images/icons/down.inline.svg'
2323
import { capitalizeFirstLetter } from '../utils/capitalizeFirstLetter'

governance/xc_admin/packages/xc_admin_frontend/components/tabs/General.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ import {
1010
getMultisigCluster,
1111
isRemoteCluster,
1212
mapKey,
13+
PRICE_FEED_MULTISIG,
1314
proposeInstructions,
1415
WORMHOLE_ADDRESS,
1516
} from 'xc_admin_common'
1617
import { ClusterContext } from '../../contexts/ClusterContext'
1718
import { useMultisigContext } from '../../contexts/MultisigContext'
1819
import { usePythContext } from '../../contexts/PythContext'
19-
import { PRICE_FEED_MULTISIG } from '../../hooks/useMultisig'
2020
import { capitalizeFirstLetter } from '../../utils/capitalizeFirstLetter'
2121
import ClusterSwitch from '../ClusterSwitch'
2222
import Modal from '../common/Modal'

governance/xc_admin/packages/xc_admin_frontend/components/tabs/Proposals.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import {
1919
getRemoteCluster,
2020
MultisigInstruction,
2121
MultisigParser,
22+
PRICE_FEED_MULTISIG,
2223
PythMultisigInstruction,
2324
UnrecognizedProgram,
2425
WormholeMultisigInstruction,
@@ -27,7 +28,6 @@ import { ClusterContext } from '../../contexts/ClusterContext'
2728
import { useMultisigContext } from '../../contexts/MultisigContext'
2829
import { usePythContext } from '../../contexts/PythContext'
2930
import { StatusFilterContext } from '../../contexts/StatusFilterContext'
30-
import { PRICE_FEED_MULTISIG } from '../../hooks/useMultisig'
3131
import VerifiedIcon from '../../images/icons/verified.inline.svg'
3232
import VotedIcon from '../../images/icons/voted.inline.svg'
3333
import { capitalizeFirstLetter } from '../../utils/capitalizeFirstLetter'

governance/xc_admin/packages/xc_admin_frontend/components/tabs/UpdatePermissions.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ import {
2323
mapKey,
2424
proposeInstructions,
2525
WORMHOLE_ADDRESS,
26+
UPGRADE_MULTISIG,
2627
} from 'xc_admin_common'
2728
import { ClusterContext } from '../../contexts/ClusterContext'
2829
import { useMultisigContext } from '../../contexts/MultisigContext'
2930
import { usePythContext } from '../../contexts/PythContext'
30-
import { UPGRADE_MULTISIG } from '../../hooks/useMultisig'
3131
import CopyIcon from '../../images/icons/copy.inline.svg'
3232
import { capitalizeFirstLetter } from '../../utils/capitalizeFirstLetter'
3333
import ClusterSwitch from '../ClusterSwitch'

governance/xc_admin/packages/xc_admin_frontend/hooks/useMultisig.ts

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,27 +18,15 @@ import {
1818
isRemoteCluster,
1919
MultisigInstruction,
2020
MultisigParser,
21+
PRICE_FEED_MULTISIG,
2122
PythMultisigInstruction,
2223
UnrecognizedProgram,
24+
UPGRADE_MULTISIG,
2325
WormholeMultisigInstruction,
2426
} from 'xc_admin_common'
2527
import { ClusterContext } from '../contexts/ClusterContext'
2628
import { pythClusterApiUrls } from '../utils/pythClusterApiUrl'
2729

28-
export const UPGRADE_MULTISIG: Record<Cluster | 'localnet', PublicKey> = {
29-
'mainnet-beta': new PublicKey('FVQyHcooAtThJ83XFrNnv74BcinbRH3bRmfFamAHBfuj'),
30-
testnet: new PublicKey('FVQyHcooAtThJ83XFrNnv74BcinbRH3bRmfFamAHBfuj'),
31-
devnet: new PublicKey('6baWtW1zTUVMSJHJQVxDUXWzqrQeYBr6mu31j3bTKwY3'),
32-
localnet: new PublicKey('FVQyHcooAtThJ83XFrNnv74BcinbRH3bRmfFamAHBfuj'),
33-
}
34-
35-
export const PRICE_FEED_MULTISIG: Record<Cluster | 'localnet', PublicKey> = {
36-
'mainnet-beta': new PublicKey('92hQkq8kBgCUcF9yWN8URZB9RTmA4mZpDGtbiAWA74Z8'),
37-
testnet: new PublicKey('92hQkq8kBgCUcF9yWN8URZB9RTmA4mZpDGtbiAWA74Z8'),
38-
devnet: new PublicKey('92hQkq8kBgCUcF9yWN8URZB9RTmA4mZpDGtbiAWA74Z8'),
39-
localnet: new PublicKey('92hQkq8kBgCUcF9yWN8URZB9RTmA4mZpDGtbiAWA74Z8'),
40-
}
41-
4230
interface MultisigHookData {
4331
isLoading: boolean
4432
error: any // TODO: fix any

package-lock.json

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)