Skip to content

Commit c2e05d0

Browse files
authored
chore(lazer): update governance scripts to make them work (#2261)
1 parent e77ee10 commit c2e05d0

File tree

5 files changed

+36
-38
lines changed

5 files changed

+36
-38
lines changed

governance/xc_admin/packages/xc_admin_cli/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -959,7 +959,7 @@ multisigCommand(
959959
const updateInstruction = await lazerProgram.methods
960960
.update(trustedSigner, expiryTime)
961961
.accounts({
962-
authority: await vault.getVaultAuthorityPDA(targetCluster),
962+
topAuthority: await vault.getVaultAuthorityPDA(targetCluster),
963963
storage: SOLANA_STORAGE_ID,
964964
})
965965
.instruction();

governance/xc_admin/packages/xc_admin_common/src/multisig_transaction/idl/lazer.json

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -238,28 +238,13 @@
238238
"name": "Ed25519InstructionMustPrecedeCurrentInstruction"
239239
},
240240
{
241-
"name": "LoadInstructionAtFailed",
242-
"fields": [
243-
{
244-
"defined": "ProgramError"
245-
}
246-
]
241+
"name": "LoadInstructionAtFailed"
247242
},
248243
{
249-
"name": "LoadCurrentIndexFailed",
250-
"fields": [
251-
{
252-
"defined": "ProgramError"
253-
}
254-
]
244+
"name": "LoadCurrentIndexFailed"
255245
},
256246
{
257-
"name": "ClockGetFailed",
258-
"fields": [
259-
{
260-
"defined": "ProgramError"
261-
}
262-
]
247+
"name": "ClockGetFailed"
263248
},
264249
{
265250
"name": "InvalidEd25519InstructionProgramId"

lazer/contracts/solana/README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
## Verifiable Build
44

55
To build the program in a verifiable way, use [Solana Verify CLI](https://github.com/Ellipsis-Labs/solana-verifiable-build). This tool builds the program in
6-
a docker container to ensure that the resulting binary is deterministic and verifiable. Run the following command to build the program:
6+
a docker container to ensure that the resulting binary is deterministic and verifiable. Run the following command to build the program
7+
in [the lazer root directory](./../../):
78

89
```bash
9-
solana-verify build -- --features solana-program
10+
solana-verify build --library-name pyth_lazer_solana_contract
1011
```
1112

1213
Once the build is complete, the program binary will be located in the `target/deploy` directory.

lazer/contracts/solana/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
"test:format": "prettier --check **/*.*",
88
"test:anchor": "CARGO_TARGET_DIR=\"$PWD/target\" anchor test",
99
"test": "pnpm run test:format && pnpm run test:anchor",
10-
"setup": "anchor build && pnpm ts-node scripts/setup.ts",
11-
"check_trusted_signer": "pnpm ts-node scripts/check_trusted_signer.ts"
10+
"setup": "pnpm ts-node scripts/setup.ts",
11+
"check-trusted-signer": "pnpm ts-node scripts/check_trusted_signer.ts"
1212
},
1313
"dependencies": {
1414
"@coral-xyz/anchor": "^0.30.1"

lazer/contracts/solana/scripts/setup.ts

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,30 @@ import yargs from "yargs/yargs";
66
import { readFileSync } from "fs";
77
import NodeWallet from "@coral-xyz/anchor/dist/cjs/nodewallet";
88

9-
// This script initializes the program and updates the trusted signer
9+
// This script initializes the program. It should be run once after the program is deployed. Additionally, if the
10+
// top authority be the same as the given keypair and the trusted signer and expiry time are provided, the trusted
11+
// signer will be updated.
1012
//
11-
// There are some assumptions made in this script:
12-
// 1. The program id is derived from the idl file (pytd...).
13-
// 2. The keypair provided is the top authority keypair
13+
// Note: the program id is derived from the idl file (pytd...). Run `anchor test` to generate it.
1414
async function main() {
1515
let argv = await yargs(process.argv.slice(2))
1616
.options({
1717
url: { type: "string", demandOption: true },
1818
"keypair-path": { type: "string", demandOption: true },
19-
"trusted-signer": { type: "string", demandOption: true },
20-
"expiry-time-seconds": { type: "number", demandOption: true },
19+
"top-authority": { type: "string", demandOption: true },
20+
treasury: { type: "string", demandOption: true },
21+
"trusted-signer": { type: "string", demandOption: false },
22+
"expiry-time-seconds": { type: "number", demandOption: false },
2123
})
2224
.parse();
2325

2426
const keypair = anchor.web3.Keypair.fromSecretKey(
2527
new Uint8Array(JSON.parse(readFileSync(argv.keypairPath, "ascii")))
2628
);
29+
30+
const topAuthority = new anchor.web3.PublicKey(argv.topAuthority);
31+
const treasury = new anchor.web3.PublicKey(argv.treasury);
32+
2733
const wallet = new NodeWallet(keypair);
2834
const connection = new anchor.web3.Connection(argv.url, {
2935
commitment: "confirmed",
@@ -39,21 +45,27 @@ async function main() {
3945
if (storage.length === 0) {
4046
console.log("Initializing the program");
4147
await program.methods
42-
.initialize(keypair.publicKey, anchor.web3.PublicKey.unique())
48+
.initialize(topAuthority, treasury)
4349
.accounts({
4450
payer: wallet.publicKey,
4551
})
4652
.rpc();
4753
}
4854

49-
console.log("Updating the trusted signer");
50-
await program.methods
51-
.update(
52-
new anchor.web3.PublicKey(argv.trustedSigner),
53-
new anchor.BN(argv.expiryTimeSeconds)
54-
)
55-
.accounts({})
56-
.rpc();
55+
if (
56+
topAuthority.equals(wallet.publicKey) &&
57+
argv.trustedSigner &&
58+
argv.expiryTimeSeconds
59+
) {
60+
console.log("Updating the trusted signer");
61+
await program.methods
62+
.update(
63+
new anchor.web3.PublicKey(argv.trustedSigner),
64+
new anchor.BN(argv.expiryTimeSeconds)
65+
)
66+
.accounts({})
67+
.rpc();
68+
}
5769
}
5870

5971
main();

0 commit comments

Comments
 (0)