-
Notifications
You must be signed in to change notification settings - Fork 229
feat: deploy scripts for midprice pino #2164
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
Open
LukasDeco
wants to merge
1
commit into
master
Choose a base branch
from
lukas/midprice-pino-deploy-scripts
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| # midprice_pino devnet build/deploy (run from this directory or: make -f deploy-scripts/midprice_pino/Makefile) | ||
| SHELL := /bin/bash | ||
|
|
||
| MIDPRICE_MK_DIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) | ||
| # protocol-v2-deploy repo root (contains programs/midprice_pino, target/deploy) | ||
| PROTOCOL_V2_ROOT ?= $(abspath $(MIDPRICE_MK_DIR)../..) | ||
|
|
||
| SOLANA_URL ?= https://api.devnet.solana.com | ||
|
|
||
| # Optional for deploy-devnet (override on CLI: make deploy-devnet DEPLOYER_KEYPAIR=...) | ||
| DEPLOYER_KEYPAIR ?= | ||
| PROGRAM_KEYPAIR ?= | ||
| SOLANA_PATH ?= | ||
| DEVNET_ADMIN ?= | ||
| IDL_JSON ?= | ||
|
|
||
| .PHONY: help build-devnet deploy-devnet update-devnet-idl | ||
|
|
||
| help: | ||
| @echo "midprice_pino devnet" | ||
| @echo " make build-devnet Build with cargo build-sbf, copy artifacts to target/deploy" | ||
| @echo " make deploy-devnet solana program deploy (requires wallet — see below)" | ||
| @echo " make update-devnet-idl npx @solana-program/program-metadata write idl (needs idl.json)" | ||
| @echo "" | ||
| @echo "Variables:" | ||
| @echo " PROTOCOL_V2_ROOT=$(PROTOCOL_V2_ROOT) (repo root with programs/; override if different)" | ||
| @echo " SOLANA_URL=$(SOLANA_URL)" | ||
| @echo " IDL_JSON=$(IDL_JSON) (empty = deploy-scripts/midprice_pino/idl.json)" | ||
| @echo "Deploy keypairs:" | ||
| @echo " Program id: tests/fixtures/midprice_pino-keypair.json (override: PROGRAM_KEYPAIR=...)" | ||
| @echo " Payer: DEPLOYER_KEYPAIR=... or SOLANA_PATH + DEVNET_ADMIN" | ||
| @echo "IDL upload: default idl path is deploy-scripts/midprice_pino/idl.json (override: IDL_JSON=...)" | ||
|
|
||
| build-devnet: | ||
| PROTOCOL_V2_ROOT="$(PROTOCOL_V2_ROOT)" bash ./build-devnet.sh | ||
|
|
||
| deploy-devnet: | ||
| PROTOCOL_V2_ROOT="$(PROTOCOL_V2_ROOT)" SOLANA_URL="$(SOLANA_URL)" \ | ||
| DEPLOYER_KEYPAIR="$(DEPLOYER_KEYPAIR)" PROGRAM_KEYPAIR="$(PROGRAM_KEYPAIR)" \ | ||
| SOLANA_PATH="$(SOLANA_PATH)" DEVNET_ADMIN="$(DEVNET_ADMIN)" \ | ||
| bash ./deploy-devnet.sh | ||
|
|
||
| update-devnet-idl: | ||
| PROTOCOL_V2_ROOT="$(PROTOCOL_V2_ROOT)" SOLANA_URL="$(SOLANA_URL)" \ | ||
| DEPLOYER_KEYPAIR="$(DEPLOYER_KEYPAIR)" PROGRAM_KEYPAIR="$(PROGRAM_KEYPAIR)" \ | ||
| SOLANA_PATH="$(SOLANA_PATH)" DEVNET_ADMIN="$(DEVNET_ADMIN)" \ | ||
| IDL_JSON="$(IDL_JSON)" \ | ||
| bash ./update-devnet-idl.sh | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| #!/usr/bin/env bash | ||
| # Build midprice_pino and copy .so + program keypair to target/deploy. | ||
| # PROTOCOL_V2_ROOT: protocol-v2-deploy repo root with programs/midprice_pino (defaults to ../.. from this script). | ||
| set -euo pipefail | ||
|
|
||
| SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||
| if [[ -z "${PROTOCOL_V2_ROOT:-}" ]]; then | ||
| _default="$SCRIPT_DIR/../.." | ||
| if [[ ! -d "$_default/programs/midprice_pino" ]]; then | ||
| echo "ERROR: PROTOCOL_V2_ROOT is not set and programs/midprice_pino not found under $_default" >&2 | ||
| echo "Set PROTOCOL_V2_ROOT to your protocol-v2-deploy repo root (directory containing programs/)." >&2 | ||
| exit 1 | ||
| fi | ||
| PROTOCOL_V2_ROOT="$(cd "$_default" && pwd)" | ||
| fi | ||
|
|
||
| ROOT="$(cd "$PROTOCOL_V2_ROOT" && pwd)" | ||
| MIDPRICE_DIR="$ROOT/programs/midprice_pino" | ||
|
|
||
| if [[ ! -d "$MIDPRICE_DIR" ]]; then | ||
| echo "ERROR: programs/midprice_pino not found under $ROOT" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "Building midprice_pino in $MIDPRICE_DIR..." | ||
| mkdir -p "$ROOT/target/deploy" | ||
| (cd "$MIDPRICE_DIR" && cargo build-sbf --tools-version v1.52) | ||
|
|
||
| cp "$MIDPRICE_DIR/target/deploy/midprice_pino.so" "$ROOT/target/deploy/midprice_pino.so" | ||
| echo "Copied -> $ROOT/target/deploy/midprice_pino.so" | ||
|
|
||
| if [[ -f "$MIDPRICE_DIR/target/deploy/midprice_pino-keypair.json" ]]; then | ||
| cp "$MIDPRICE_DIR/target/deploy/midprice_pino-keypair.json" "$ROOT/target/deploy/midprice_pino-keypair.json" | ||
| echo "Copied -> $ROOT/target/deploy/midprice_pino-keypair.json" | ||
| fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| #!/usr/bin/env bash | ||
| # Deploy midprice_pino.so to devnet. | ||
| # PROTOCOL_V2_ROOT: protocol-v2-deploy repo root (defaults to ../.. from this script; same as Makefile). | ||
| set -euo pipefail | ||
|
|
||
| SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||
| if [[ -z "${PROTOCOL_V2_ROOT:-}" ]]; then | ||
| _default="$SCRIPT_DIR/../.." | ||
| if [[ ! -d "$_default/programs/midprice_pino" ]]; then | ||
| echo "ERROR: PROTOCOL_V2_ROOT is not set and programs/midprice_pino not found under $_default" >&2 | ||
| echo "Set PROTOCOL_V2_ROOT to your protocol-v2-deploy repo root (directory containing programs/)." >&2 | ||
| exit 1 | ||
| fi | ||
| PROTOCOL_V2_ROOT="$(cd "$_default" && pwd)" | ||
| fi | ||
|
|
||
| ROOT="$(cd "$PROTOCOL_V2_ROOT" && pwd)" | ||
| SO="$ROOT/target/deploy/midprice_pino.so" | ||
|
|
||
| if [[ ! -f "$SO" ]]; then | ||
| echo "ERROR: Missing $SO — run make build-devnet first" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| SOLANA_URL="${SOLANA_URL:-https://api.devnet.solana.com}" | ||
|
|
||
| # Program address comes from this keypair (same as bankrun tests/fixtures). | ||
| # Override: PROGRAM_KEYPAIR=... for a different program id keypair. | ||
| if [[ -n "${PROGRAM_KEYPAIR:-}" ]]; then | ||
| PROG_KEY="$PROGRAM_KEYPAIR" | ||
| else | ||
| PROG_KEY="$ROOT/tests/fixtures/midprice_pino-keypair.json" | ||
| fi | ||
|
|
||
| if [[ -n "${DEPLOYER_KEYPAIR:-}" ]]; then | ||
| PAYER_KEY="$DEPLOYER_KEYPAIR" | ||
| elif [[ -n "${SOLANA_PATH:-}" && -n "${DEVNET_ADMIN:-}" ]]; then | ||
| PAYER_KEY="${SOLANA_PATH}/${DEVNET_ADMIN}" | ||
| else | ||
| echo "ERROR: Set DEPLOYER_KEYPAIR, or both SOLANA_PATH and DEVNET_ADMIN (payer keypair)." >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| if [[ ! -f "$PROG_KEY" ]]; then | ||
| echo "ERROR: Program keypair not found: $PROG_KEY" >&2 | ||
| exit 1 | ||
| fi | ||
| if [[ ! -f "$PAYER_KEY" ]]; then | ||
| echo "ERROR: Deployer keypair not found: $PAYER_KEY" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "Deploying midprice_pino.so to $SOLANA_URL" | ||
| echo "Program id keypair (--program-id): $PROG_KEY" | ||
| echo "Deployer / fee payer (--keypair): $PAYER_KEY" | ||
|
|
||
| exec solana program deploy \ | ||
| --program-id "$PROG_KEY" \ | ||
| "$SO" \ | ||
| --url "$SOLANA_URL" \ | ||
| --keypair "$PAYER_KEY" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| #!/usr/bin/env bash | ||
| # Upload midprice_pino IDL to on-chain program metadata (devnet) via program-metadata CLI. | ||
| # Requires: idl.json (default: next to this script), payer keypair, devnet RPC. | ||
| set -euo pipefail | ||
|
|
||
| SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||
| if [[ -z "${PROTOCOL_V2_ROOT:-}" ]]; then | ||
| _default="$SCRIPT_DIR/../.." | ||
| if [[ ! -d "$_default/programs/midprice_pino" ]]; then | ||
| echo "ERROR: PROTOCOL_V2_ROOT is not set and programs/midprice_pino not found under $_default" >&2 | ||
| exit 1 | ||
| fi | ||
| PROTOCOL_V2_ROOT="$(cd "$_default" && pwd)" | ||
| fi | ||
|
|
||
| ROOT="$(cd "$PROTOCOL_V2_ROOT" && pwd)" | ||
| SOLANA_URL="${SOLANA_URL:-https://api.devnet.solana.com}" | ||
|
|
||
| if [[ -n "${PROGRAM_KEYPAIR:-}" ]]; then | ||
| PROG_KEY="$PROGRAM_KEYPAIR" | ||
| else | ||
| PROG_KEY="$ROOT/tests/fixtures/midprice_pino-keypair.json" | ||
| fi | ||
|
|
||
| if [[ -n "${DEPLOYER_KEYPAIR:-}" ]]; then | ||
| PAYER_KEY="$DEPLOYER_KEYPAIR" | ||
| elif [[ -n "${SOLANA_PATH:-}" && -n "${DEVNET_ADMIN:-}" ]]; then | ||
| PAYER_KEY="${SOLANA_PATH}/${DEVNET_ADMIN}" | ||
| else | ||
| echo "ERROR: Set DEPLOYER_KEYPAIR, or both SOLANA_PATH and DEVNET_ADMIN (payer keypair)." >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| IDL_JSON="${IDL_JSON:-$SCRIPT_DIR/idl.json}" | ||
|
|
||
| if [[ ! -f "$PROG_KEY" ]]; then | ||
| echo "ERROR: Program keypair not found: $PROG_KEY" >&2 | ||
| exit 1 | ||
| fi | ||
| if [[ ! -f "$PAYER_KEY" ]]; then | ||
| echo "ERROR: Deployer keypair not found: $PAYER_KEY" >&2 | ||
| exit 1 | ||
| fi | ||
| if [[ ! -f "$IDL_JSON" ]]; then | ||
| echo "ERROR: IDL file not found: $IDL_JSON" >&2 | ||
| echo "Set IDL_JSON=/path/to/idl.json or add deploy-scripts/midprice_pino/idl.json" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| PROGRAM_ID="$(solana-keygen pubkey "$PROG_KEY")" | ||
|
|
||
| echo "Writing IDL to program metadata on $SOLANA_URL" | ||
| echo " program: $PROGRAM_ID" | ||
| echo " idl: $IDL_JSON" | ||
| echo " payer: $PAYER_KEY" | ||
|
|
||
| exec npx @solana-program/program-metadata@latest write idl "$PROGRAM_ID" "$IDL_JSON" \ | ||
| -k "$PAYER_KEY" \ | ||
| --rpc "$SOLANA_URL" \ | ||
| --format json |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Relative script paths break when Makefile is invoked from a different directory.
The targets use
bash ./build-devnet.shetc., which only works when the Makefile is invoked from its directory. When usingmake -f deploy-scripts/midprice_pino/Makefile build-devnetfrom the repo root (as shown in line 1's comment), the relative paths will fail.🔧 Proposed fix — use absolute paths via MIDPRICE_MK_DIR
📝 Committable suggestion
🤖 Prompt for AI Agents