Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mitch infra #4

Merged
merged 18 commits into from
Mar 20, 2024
37 changes: 37 additions & 0 deletions chains/solana/devnet-pull-equinix.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
chain: "solana"
cluster: "devnet"
heartbeatInterval: "30"
infisicalSecretKey: "SOLANA_KEY"
infisicalSecretSlug: "dev"
jupiterSwapApiKey: "3a3b41bc06d49f9c89a8550ff84072be"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛑 Gitleaks has detected a secret with rule-id generic-api-key in commit 02ed0a3.
If this secret is a true positive, please rotate the secret ASAP.

If this secret is a false positive, you can add the fingerprint below to your .gitleaksignore file and commit the change to this branch.

echo 02ed0a31181f014d75b196318bc131e5d51a480c:chains/solana/devnet-pull-equinix.yaml:generic-api-key:10 >> .gitleaksignore

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"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛑 Gitleaks has detected a secret with rule-id generic-api-key in commit 02ed0a3.
If this secret is a true positive, please rotate the secret ASAP.

If this secret is a false positive, you can add the fingerprint below to your .gitleaksignore file and commit the change to this branch.

echo 02ed0a31181f014d75b196318bc131e5d51a480c:chains/solana/devnet-pull-equinix.yaml:generic-api-key:22 >> .gitleaksignore

guardian:
queue: "71wi6H1ByDG9qnRd5Ef8PSKoKH8rJ7pve7NDvB7Y4tqi"
key: "Ewq5ec637q9pvzZH5xBHtqxqUPSjo1j4sB1nXeeGNRHo"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛑 Gitleaks has detected a secret with rule-id generic-api-key in commit 898ea28.
If this secret is a true positive, please rotate the secret ASAP.

If this secret is a false positive, you can add the fingerprint below to your .gitleaksignore file and commit the change to this branch.

echo 898ea28ea68d070a20eb953c23f43f1ad3907ac2:chains/solana/devnet-pull-equinix.yaml:generic-api-key:21 >> .gitleaksignore

host: "guardian-oracle.switchboard.xyz"
push:
queue: "uPeRMdfPmrPqgRWSrjAnAkH78RqAhe5kXoW6vBYRqFX"
key: "8AGNUUHphu8YevPoTGTbcbsJLKBe2F6byukfoPUWSHWm"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛑 Gitleaks has detected a secret with rule-id generic-api-key in commit 02ed0a3.
If this secret is a true positive, please rotate the secret ASAP.

If this secret is a false positive, you can add the fingerprint below to your .gitleaksignore file and commit the change to this branch.

echo 02ed0a31181f014d75b196318bc131e5d51a480c:chains/solana/devnet-pull-equinix.yaml:generic-api-key:29 >> .gitleaksignore

host: "push-oracle.switchboard.xyz"
pull:
queue: "5Qv744yu7DmEbU669GmYRqL9kpQsyYsaVKdR8YiBMTaP"
key: "BfvoZHYSxgJe4P7jbt9HTqJHip7Lf3xRB1QNszEPrhCx"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛑 Gitleaks has detected a secret with rule-id generic-api-key in commit 898ea28.
If this secret is a true positive, please rotate the secret ASAP.

If this secret is a false positive, you can add the fingerprint below to your .gitleaksignore file and commit the change to this branch.

echo 898ea28ea68d070a20eb953c23f43f1ad3907ac2:chains/solana/devnet-pull-equinix.yaml:generic-api-key:29 >> .gitleaksignore

host: "pull-oracle.switchboard.xyz"

# command: shell
sgx:
type: "azure"
memoryMiB: 32Mi
cpu: 1500m

31 changes: 12 additions & 19 deletions chains/solana/devnet-pull.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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: "<FILL_IN_HERE>"
solanaMainnetRpc: "<FILL_IN_HERE>"
wssUrl: "<FILL_IN_HERE>"
gateway:
host: "pull-gateway.switchboard.xyz"
host: "<FILL_IN_HERE>"
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: "<FILL_IN_HERE>"
guardian:
queue: "RH4MXRCHriboKoPynKsGacC61D9QHa1hVXLFXMX9QNc"
key: "redacted"
host: "guardian-oracle.switchboard.xyz"
host: "<FILL_IN_HERE>"
key: "<FILL_IN_HERE>"
push:
queue: "uPeRMdfPmrPqgRWSrjAnAkH78RqAhe5kXoW6vBYRqFX"
key: "redacted"
host: "push-oracle.switchboard.xyz"
host: "<FILL_IN_HERE>"
key: "<FILL_IN_HERE>"
pull:
queue: "v1k9qvCuvYgDkAcTExnrkt2BPNENfVVpowp5d7PYKAa"
key: "redacted"
host: "pull-oracle.switchboard.xyz"

# command: shell

# sgx:
# type: "azure"
# memoryMiB: 32Mi
# cpu: 1500m
host: "<FILL_IN_HERE>"
key: "<FILL_IN_HERE>"

4 changes: 0 additions & 4 deletions charts/pull-service/templates/oracle-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down Expand Up @@ -181,7 +178,6 @@ spec:
{{ end }}



ports:
- name: web
containerPort: {{ $config.port }}
Expand Down
2 changes: 1 addition & 1 deletion scripts/anneal.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

155 changes: 155 additions & 0 deletions scripts/bootstrap.ts
Original file line number Diff line number Diff line change
@@ -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<anchor.Wallet> {
// 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<Keypair> {
// 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<Keypair> {
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;
})();
6 changes: 6 additions & 0 deletions scripts/ingress-init.sh
Original file line number Diff line number Diff line change
@@ -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
Loading