diff --git a/chains/solana/devnet-pull-equinix.yaml b/chains/solana/devnet-pull-equinix.yaml new file mode 100644 index 0000000..082d873 --- /dev/null +++ b/chains/solana/devnet-pull-equinix.yaml @@ -0,0 +1,37 @@ +chain: "solana" +cluster: "devnet" +heartbeatInterval: "30" +infisicalSecretKey: "SOLANA_KEY" +infisicalSecretSlug: "dev" +jupiterSwapApiKey: "3a3b41bc06d49f9c89a8550ff84072be" +namespace: "devnet-pull" +networkId: "devnet" +pagerdutyEventKey: "redacted" +rpcUrl: "https://switchbo-switchbo-6225.devnet.rpcpool.com/f6fb9f02-0777-498b-b8f5-67cbb1fc0d14" +solanaMainnetRpc: "https://switchbo-switchbo-6225.devnet.rpcpool.com/f6fb9f02-0777-498b-b8f5-67cbb1fc0d14" +wssUrl: "wss://switchbo-switchbo-6225.devnet.rpcpool.com/f6fb9f02-0777-498b-b8f5-67cbb1fc0d14" +gateway: + host: "pull-gateway.switchboard.xyz" + image: "docker.io/switchboardlabs/pull-oracle:dev-RC_03_13_24_14_17" +oracle: + image: "docker.io/switchboardlabs/pull-oracle:dev-RC_03_13_24_14_17" + authority: "2KgowxogBrGqRcgXQEmqFvC3PGtCu66qERNJevYW8Ajh" + guardian: + queue: "71wi6H1ByDG9qnRd5Ef8PSKoKH8rJ7pve7NDvB7Y4tqi" + key: "Ewq5ec637q9pvzZH5xBHtqxqUPSjo1j4sB1nXeeGNRHo" + host: "guardian-oracle.switchboard.xyz" + push: + queue: "uPeRMdfPmrPqgRWSrjAnAkH78RqAhe5kXoW6vBYRqFX" + key: "8AGNUUHphu8YevPoTGTbcbsJLKBe2F6byukfoPUWSHWm" + host: "push-oracle.switchboard.xyz" + pull: + queue: "5Qv744yu7DmEbU669GmYRqL9kpQsyYsaVKdR8YiBMTaP" + key: "BfvoZHYSxgJe4P7jbt9HTqJHip7Lf3xRB1QNszEPrhCx" + host: "pull-oracle.switchboard.xyz" + +# command: shell +sgx: + type: "azure" + memoryMiB: 32Mi + cpu: 1500m + diff --git a/chains/solana/devnet-pull.yaml b/chains/solana/devnet-pull.yaml index a7e0021..9e15406 100644 --- a/chains/solana/devnet-pull.yaml +++ b/chains/solana/devnet-pull.yaml @@ -6,34 +6,27 @@ infisicalSecretSlug: "dev" jupiterSwapApiKey: "3a3b41bc06d49f9c89a8550ff84072be" namespace: "devnet-pull" networkId: "devnet" -pagerdutyEventKey: "redacted" -rpcUrl: "redacted" -solanaMainnetRpc: "redacted" -wssUrl: "redacted" +pagerdutyEventKey: "FILL_IN_HERE>" +rpcUrl: "" +solanaMainnetRpc: "" +wssUrl: "" gateway: - host: "pull-gateway.switchboard.xyz" + host: "" image: "docker.io/switchboardlabs/pull-oracle:dev-RC_03_11_24_00_40" #you can get the keys below by running scripts/bootstrap.ts oracle: image: "docker.io/switchboardlabs/pull-oracle:dev-RC_03_11_24_00_40" - authority: "2KgowxogBrGqRcgXQEmqFvC3PGtCu66qERNJevYW8Ajh" + authority: "" guardian: queue: "RH4MXRCHriboKoPynKsGacC61D9QHa1hVXLFXMX9QNc" - key: "redacted" - host: "guardian-oracle.switchboard.xyz" + host: "" + key: "" push: queue: "uPeRMdfPmrPqgRWSrjAnAkH78RqAhe5kXoW6vBYRqFX" - key: "redacted" - host: "push-oracle.switchboard.xyz" + host: "" + key: "" pull: queue: "v1k9qvCuvYgDkAcTExnrkt2BPNENfVVpowp5d7PYKAa" - key: "redacted" - host: "pull-oracle.switchboard.xyz" - -# command: shell - -# sgx: -# type: "azure" -# memoryMiB: 32Mi -# cpu: 1500m + host: "" + key: "" diff --git a/charts/pull-service/templates/oracle-deployment.yaml b/charts/pull-service/templates/oracle-deployment.yaml index 7f2387f..1551781 100644 --- a/charts/pull-service/templates/oracle-deployment.yaml +++ b/charts/pull-service/templates/oracle-deployment.yaml @@ -134,9 +134,6 @@ spec: name: IPFS_KEY value: {{ $values.ipfsKey | quote }} # SOLANA - - - name: SWITCHBOARD_ATTESTATION_PROGRAM_ID - value: {{ $values.attestationProgramId | quote }} - name: ORACLE_AUTHORITY value: {{ $values.oracle.authority }} @@ -181,7 +178,6 @@ spec: {{ end }} - ports: - name: web containerPort: {{ $config.port }} diff --git a/scripts/anneal.sh b/scripts/anneal.sh index 076d6f2..afbf1b2 100644 --- a/scripts/anneal.sh +++ b/scripts/anneal.sh @@ -7,6 +7,6 @@ elif [ "$1" == "equinix-devnet" ]; then cp ~/.kube/config-equinix ~/.kube/config helm upgrade -i pull-oracle-devnet ./charts/pull-service/ -f ./chains/solana/devnet-pull-equinix.yaml else - echo "Invalid argument. Please use either 'mainnet' or 'devnet'." + echo "Invalid argument. Please use either 'equinix-devnet' or 'devnet'." fi diff --git a/scripts/bootstrap.ts b/scripts/bootstrap.ts new file mode 100644 index 0000000..ef5edca --- /dev/null +++ b/scripts/bootstrap.ts @@ -0,0 +1,155 @@ +import * as anchor from "@coral-xyz/anchor"; +import * as spl from "@solana/spl-token"; +import type { AccountInfo, AccountMeta } from "@solana/web3.js"; +import { + AddressLookupTableProgram, + Connection, + Keypair, + MessageV0, + PublicKey, + sendAndConfirmTransaction, + SystemProgram, + Transaction, + TransactionInstruction, + TransactionMessage, + VersionedTransaction, +} from "@solana/web3.js"; +import { Big, BigUtils, bs58 } from "@switchboard-xyz/common"; +import { OracleJob } from "@switchboard-xyz/common"; +import * as sb from "@switchboard-xyz/solana.js"; +import { toBufferLE } from "bigint-buffer"; +import * as crypto from "crypto"; +import * as fs from "fs"; +const assert = require("assert"); + +const walletFile = "your wallet file json here"; +// example "/Users/mgild/switchboard_environments_v2/devnet/upgrade_authority/test.json" +const payerFile = "your payer file json here" +let PID = new PublicKey("sbattyXrzedoNATfc4L31wC9Mhxsi1BmFhTiN8gDshx"); +// PID = new PublicKey("CR1hCrkKveeWrYYs5kk7rasRM2AH1vZy8s8fn42NBwkq"); +const RPC_URL = "https://api.devnet.solana.com"; + + + +async function fetchLatestSlotHash( + connection: Connection +): Promise<[bigint, string]> { + const slotHashesSysvarKey = new PublicKey( + "SysvarS1otHashes111111111111111111111111111" + ); + const accountInfo = await connection.getAccountInfo(slotHashesSysvarKey, { + commitment: "confirmed", + dataSlice: { length: 40, offset: 8 }, + }); + let buffer = accountInfo!.data; + const slotNumber = buffer.readBigUInt64LE(); + buffer = buffer.slice(8); + return [slotNumber, bs58.encode(buffer)]; +} + +async function initWalletFromFile(filePath: string): Promise { + // Read the file + const secretKeyString: string = fs.readFileSync(filePath, { + encoding: "utf8", + }); + const secretKey: Uint8Array = Uint8Array.from(JSON.parse(secretKeyString)); + + // Create a keypair from the secret key + const keypair: Keypair = Keypair.fromSecretKey(secretKey); + + // Create a wallet + const wallet: anchor.Wallet = new anchor.Wallet(keypair); + + return wallet; +} + +async function initKeypairFromFile(filePath: string): Promise { + // Read the file + const secretKeyString: string = fs.readFileSync(filePath, { + encoding: "utf8", + }); + const secretKey: Uint8Array = Uint8Array.from(JSON.parse(secretKeyString)); + + // Create a keypair from the secret key + const keypair: Keypair = Keypair.fromSecretKey(secretKey); + + return keypair; +} + +async function keypairFromJson(secretKeyString: string): Promise { + const secretKey: Uint8Array = Uint8Array.from(JSON.parse(secretKeyString)); + + // Create a keypair from the secret key + return Keypair.fromSecretKey(secretKey); +} + +export function logEnvVariables( + env: Array<[string, string | anchor.web3.PublicKey]>, + pre = "Make sure to add the following to your .env file:" +) { + console.log( + `\n${pre}\n\t${env + .map(([key, value]) => `${key.toUpperCase()}=${value}`) + .join("\n\t")}\n` + ); +} + +(async () => { + const ORACLE_IP = "127.0.0.1"; + + let PID = new PublicKey("sbattyXrzedoNATfc4L31wC9Mhxsi1BmFhTiN8gDshx"); + PID = sb.SB_ON_DEMAND_PID; + const connection = new Connection( + RPC_URL, + "confirmed" + ); + + const wallet = await initWalletFromFile( + walletFile + ); + const devnetPayer = await initKeypairFromFile( + payerFile + ); + const provider = new anchor.AnchorProvider(connection, wallet, {}); + const idl = await anchor.Program.fetchIdl(PID, provider); + const program = new anchor.Program(idl!, PID, provider); + const switchboardProgram = sb.SwitchboardProgram.from( + connection, + devnetPayer, + sb.SB_V2_PID, + PID + ); + + const [slotNumber, slotHash] = await fetchLatestSlotHash(connection); + const bootstrappedQueue = (await sb.AttestationQueueAccount.bootstrapNewQueue( + switchboardProgram + )) as any; + console.log(bootstrappedQueue); + + const attestationQueueAccount = bootstrappedQueue.attestationQueue.account; + const verifierOracleAccount = bootstrappedQueue.verifier.account; + const quoteKeypair2 = Keypair.generate(); + + const [verifier2, signature] = await attestationQueueAccount.createVerifier({ + createPermissions: true, + keypair: quoteKeypair2, + enable: true, + queueAuthorityPubkey: devnetPayer.publicKey, + authority: devnetPayer.publicKey, + queueAccount: attestationQueueAccount.publicKey, + registryKey: new Uint8Array(64).fill(0), + }); + console.log(verifier2.publicKey); + + logEnvVariables([ + ["SWITCHBOARD_ATTESTATION_QUEUE_KEY", attestationQueueAccount.publicKey], + ["SWITCHBOARD_VERIFIER_ORACLE_KEY", verifierOracleAccount.publicKey], + ["SWITCHBOARD_VERIFIER_ORACLE_KEY2", verifier2.publicKey.toString()], + ]); + + const y = bootstrappedQueue.signatures.map((s: any, i: any): any => { + return { name: `bootstrap_queue #${i + 1}`, tx: s }; + }); + console.log(y); + return; +})(); diff --git a/scripts/ingress-init.sh b/scripts/ingress-init.sh new file mode 100644 index 0000000..785870e --- /dev/null +++ b/scripts/ingress-init.sh @@ -0,0 +1,6 @@ +helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx || true +helm upgrade -i ingress-nginx ingress-nginx/ingress-nginx \ + --namespace ingress-nginx \ + --create-namespace \ + --timeout 600s \ + --debug