Skip to content

Commit 443d43e

Browse files
authored
Merge pull request #4 from switchboard-xyz/mitch-infra
Mitch infra
2 parents b7c1ac0 + 6b5735d commit 443d43e

File tree

6 files changed

+211
-24
lines changed

6 files changed

+211
-24
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
chain: "solana"
2+
cluster: "devnet"
3+
heartbeatInterval: "30"
4+
infisicalSecretKey: "SOLANA_KEY"
5+
infisicalSecretSlug: "dev"
6+
jupiterSwapApiKey: "3a3b41bc06d49f9c89a8550ff84072be"
7+
namespace: "devnet-pull"
8+
networkId: "devnet"
9+
pagerdutyEventKey: "redacted"
10+
rpcUrl: "https://switchbo-switchbo-6225.devnet.rpcpool.com/f6fb9f02-0777-498b-b8f5-67cbb1fc0d14"
11+
solanaMainnetRpc: "https://switchbo-switchbo-6225.devnet.rpcpool.com/f6fb9f02-0777-498b-b8f5-67cbb1fc0d14"
12+
wssUrl: "wss://switchbo-switchbo-6225.devnet.rpcpool.com/f6fb9f02-0777-498b-b8f5-67cbb1fc0d14"
13+
gateway:
14+
host: "pull-gateway.switchboard.xyz"
15+
image: "docker.io/switchboardlabs/pull-oracle:dev-RC_03_13_24_14_17"
16+
oracle:
17+
image: "docker.io/switchboardlabs/pull-oracle:dev-RC_03_13_24_14_17"
18+
authority: "2KgowxogBrGqRcgXQEmqFvC3PGtCu66qERNJevYW8Ajh"
19+
guardian:
20+
queue: "71wi6H1ByDG9qnRd5Ef8PSKoKH8rJ7pve7NDvB7Y4tqi"
21+
key: "Ewq5ec637q9pvzZH5xBHtqxqUPSjo1j4sB1nXeeGNRHo"
22+
host: "guardian-oracle.switchboard.xyz"
23+
push:
24+
queue: "uPeRMdfPmrPqgRWSrjAnAkH78RqAhe5kXoW6vBYRqFX"
25+
key: "8AGNUUHphu8YevPoTGTbcbsJLKBe2F6byukfoPUWSHWm"
26+
host: "push-oracle.switchboard.xyz"
27+
pull:
28+
queue: "5Qv744yu7DmEbU669GmYRqL9kpQsyYsaVKdR8YiBMTaP"
29+
key: "BfvoZHYSxgJe4P7jbt9HTqJHip7Lf3xRB1QNszEPrhCx"
30+
host: "pull-oracle.switchboard.xyz"
31+
32+
# command: shell
33+
sgx:
34+
type: "azure"
35+
memoryMiB: 32Mi
36+
cpu: 1500m
37+

chains/solana/devnet-pull.yaml

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,34 +6,27 @@ infisicalSecretSlug: "dev"
66
jupiterSwapApiKey: "3a3b41bc06d49f9c89a8550ff84072be"
77
namespace: "devnet-pull"
88
networkId: "devnet"
9-
pagerdutyEventKey: "redacted"
10-
rpcUrl: "redacted"
11-
solanaMainnetRpc: "redacted"
12-
wssUrl: "redacted"
9+
pagerdutyEventKey: "FILL_IN_HERE>"
10+
rpcUrl: "<FILL_IN_HERE>"
11+
solanaMainnetRpc: "<FILL_IN_HERE>"
12+
wssUrl: "<FILL_IN_HERE>"
1313
gateway:
14-
host: "pull-gateway.switchboard.xyz"
14+
host: "<FILL_IN_HERE>"
1515
image: "docker.io/switchboardlabs/pull-oracle:dev-RC_03_11_24_00_40"
1616
#you can get the keys below by running scripts/bootstrap.ts
1717
oracle:
1818
image: "docker.io/switchboardlabs/pull-oracle:dev-RC_03_11_24_00_40"
19-
authority: "2KgowxogBrGqRcgXQEmqFvC3PGtCu66qERNJevYW8Ajh"
19+
authority: "<FILL_IN_HERE>"
2020
guardian:
2121
queue: "RH4MXRCHriboKoPynKsGacC61D9QHa1hVXLFXMX9QNc"
22-
key: "redacted"
23-
host: "guardian-oracle.switchboard.xyz"
22+
host: "<FILL_IN_HERE>"
23+
key: "<FILL_IN_HERE>"
2424
push:
2525
queue: "uPeRMdfPmrPqgRWSrjAnAkH78RqAhe5kXoW6vBYRqFX"
26-
key: "redacted"
27-
host: "push-oracle.switchboard.xyz"
26+
host: "<FILL_IN_HERE>"
27+
key: "<FILL_IN_HERE>"
2828
pull:
2929
queue: "v1k9qvCuvYgDkAcTExnrkt2BPNENfVVpowp5d7PYKAa"
30-
key: "redacted"
31-
host: "pull-oracle.switchboard.xyz"
32-
33-
# command: shell
34-
35-
# sgx:
36-
# type: "azure"
37-
# memoryMiB: 32Mi
38-
# cpu: 1500m
30+
host: "<FILL_IN_HERE>"
31+
key: "<FILL_IN_HERE>"
3932

charts/pull-service/templates/oracle-deployment.yaml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,6 @@ spec:
134134
name: IPFS_KEY
135135
value: {{ $values.ipfsKey | quote }}
136136
# SOLANA
137-
-
138-
name: SWITCHBOARD_ATTESTATION_PROGRAM_ID
139-
value: {{ $values.attestationProgramId | quote }}
140137
-
141138
name: ORACLE_AUTHORITY
142139
value: {{ $values.oracle.authority }}
@@ -181,7 +178,6 @@ spec:
181178
{{ end }}
182179

183180

184-
185181
ports:
186182
- name: web
187183
containerPort: {{ $config.port }}

scripts/anneal.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ elif [ "$1" == "equinix-devnet" ]; then
77
cp ~/.kube/config-equinix ~/.kube/config
88
helm upgrade -i pull-oracle-devnet ./charts/pull-service/ -f ./chains/solana/devnet-pull-equinix.yaml
99
else
10-
echo "Invalid argument. Please use either 'mainnet' or 'devnet'."
10+
echo "Invalid argument. Please use either 'equinix-devnet' or 'devnet'."
1111
fi
1212

scripts/bootstrap.ts

Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
import * as anchor from "@coral-xyz/anchor";
2+
import * as spl from "@solana/spl-token";
3+
import type { AccountInfo, AccountMeta } from "@solana/web3.js";
4+
import {
5+
AddressLookupTableProgram,
6+
Connection,
7+
Keypair,
8+
MessageV0,
9+
PublicKey,
10+
sendAndConfirmTransaction,
11+
SystemProgram,
12+
Transaction,
13+
TransactionInstruction,
14+
TransactionMessage,
15+
VersionedTransaction,
16+
} from "@solana/web3.js";
17+
import { Big, BigUtils, bs58 } from "@switchboard-xyz/common";
18+
import { OracleJob } from "@switchboard-xyz/common";
19+
import * as sb from "@switchboard-xyz/solana.js";
20+
import { toBufferLE } from "bigint-buffer";
21+
import * as crypto from "crypto";
22+
import * as fs from "fs";
23+
const assert = require("assert");
24+
25+
const walletFile = "your wallet file json here";
26+
// example "/Users/mgild/switchboard_environments_v2/devnet/upgrade_authority/test.json"
27+
const payerFile = "your payer file json here"
28+
let PID = new PublicKey("sbattyXrzedoNATfc4L31wC9Mhxsi1BmFhTiN8gDshx");
29+
// PID = new PublicKey("CR1hCrkKveeWrYYs5kk7rasRM2AH1vZy8s8fn42NBwkq");
30+
const RPC_URL = "https://api.devnet.solana.com";
31+
32+
33+
34+
async function fetchLatestSlotHash(
35+
connection: Connection
36+
): Promise<[bigint, string]> {
37+
const slotHashesSysvarKey = new PublicKey(
38+
"SysvarS1otHashes111111111111111111111111111"
39+
);
40+
const accountInfo = await connection.getAccountInfo(slotHashesSysvarKey, {
41+
commitment: "confirmed",
42+
dataSlice: { length: 40, offset: 8 },
43+
});
44+
let buffer = accountInfo!.data;
45+
const slotNumber = buffer.readBigUInt64LE();
46+
buffer = buffer.slice(8);
47+
return [slotNumber, bs58.encode(buffer)];
48+
}
49+
50+
async function initWalletFromFile(filePath: string): Promise<anchor.Wallet> {
51+
// Read the file
52+
const secretKeyString: string = fs.readFileSync(filePath, {
53+
encoding: "utf8",
54+
});
55+
const secretKey: Uint8Array = Uint8Array.from(JSON.parse(secretKeyString));
56+
57+
// Create a keypair from the secret key
58+
const keypair: Keypair = Keypair.fromSecretKey(secretKey);
59+
60+
// Create a wallet
61+
const wallet: anchor.Wallet = new anchor.Wallet(keypair);
62+
63+
return wallet;
64+
}
65+
66+
async function initKeypairFromFile(filePath: string): Promise<Keypair> {
67+
// Read the file
68+
const secretKeyString: string = fs.readFileSync(filePath, {
69+
encoding: "utf8",
70+
});
71+
const secretKey: Uint8Array = Uint8Array.from(JSON.parse(secretKeyString));
72+
73+
// Create a keypair from the secret key
74+
const keypair: Keypair = Keypair.fromSecretKey(secretKey);
75+
76+
return keypair;
77+
}
78+
79+
async function keypairFromJson(secretKeyString: string): Promise<Keypair> {
80+
const secretKey: Uint8Array = Uint8Array.from(JSON.parse(secretKeyString));
81+
82+
// Create a keypair from the secret key
83+
return Keypair.fromSecretKey(secretKey);
84+
}
85+
86+
export function logEnvVariables(
87+
env: Array<[string, string | anchor.web3.PublicKey]>,
88+
pre = "Make sure to add the following to your .env file:"
89+
) {
90+
console.log(
91+
`\n${pre}\n\t${env
92+
.map(([key, value]) => `${key.toUpperCase()}=${value}`)
93+
.join("\n\t")}\n`
94+
);
95+
}
96+
97+
(async () => {
98+
const ORACLE_IP = "127.0.0.1";
99+
100+
let PID = new PublicKey("sbattyXrzedoNATfc4L31wC9Mhxsi1BmFhTiN8gDshx");
101+
PID = sb.SB_ON_DEMAND_PID;
102+
const connection = new Connection(
103+
RPC_URL,
104+
"confirmed"
105+
);
106+
107+
const wallet = await initWalletFromFile(
108+
walletFile
109+
);
110+
const devnetPayer = await initKeypairFromFile(
111+
payerFile
112+
);
113+
const provider = new anchor.AnchorProvider(connection, wallet, {});
114+
const idl = await anchor.Program.fetchIdl(PID, provider);
115+
const program = new anchor.Program(idl!, PID, provider);
116+
const switchboardProgram = sb.SwitchboardProgram.from(
117+
connection,
118+
devnetPayer,
119+
sb.SB_V2_PID,
120+
PID
121+
);
122+
123+
const [slotNumber, slotHash] = await fetchLatestSlotHash(connection);
124+
const bootstrappedQueue = (await sb.AttestationQueueAccount.bootstrapNewQueue(
125+
switchboardProgram
126+
)) as any;
127+
console.log(bootstrappedQueue);
128+
129+
const attestationQueueAccount = bootstrappedQueue.attestationQueue.account;
130+
const verifierOracleAccount = bootstrappedQueue.verifier.account;
131+
const quoteKeypair2 = Keypair.generate();
132+
133+
const [verifier2, signature] = await attestationQueueAccount.createVerifier({
134+
createPermissions: true,
135+
keypair: quoteKeypair2,
136+
enable: true,
137+
queueAuthorityPubkey: devnetPayer.publicKey,
138+
authority: devnetPayer.publicKey,
139+
queueAccount: attestationQueueAccount.publicKey,
140+
registryKey: new Uint8Array(64).fill(0),
141+
});
142+
console.log(verifier2.publicKey);
143+
144+
logEnvVariables([
145+
["SWITCHBOARD_ATTESTATION_QUEUE_KEY", attestationQueueAccount.publicKey],
146+
["SWITCHBOARD_VERIFIER_ORACLE_KEY", verifierOracleAccount.publicKey],
147+
["SWITCHBOARD_VERIFIER_ORACLE_KEY2", verifier2.publicKey.toString()],
148+
]);
149+
150+
const y = bootstrappedQueue.signatures.map((s: any, i: any): any => {
151+
return { name: `bootstrap_queue #${i + 1}`, tx: s };
152+
});
153+
console.log(y);
154+
return;
155+
})();

scripts/ingress-init.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx || true
2+
helm upgrade -i ingress-nginx ingress-nginx/ingress-nginx \
3+
--namespace ingress-nginx \
4+
--create-namespace \
5+
--timeout 600s \
6+
--debug

0 commit comments

Comments
 (0)