Skip to content

Commit 78078c2

Browse files
committed
refactor
1 parent 19505ef commit 78078c2

File tree

6 files changed

+27
-58
lines changed

6 files changed

+27
-58
lines changed

.pre-commit-config.yaml

+20-25
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,21 @@
11
repos:
2-
- repo: https://github.com/pre-commit/pre-commit-hooks
3-
rev: v3.2.0
4-
hooks:
5-
- id: trailing-whitespace
6-
files : program/
7-
- id: end-of-file-fixer
8-
files : program/
9-
- id: check-added-large-files
10-
- repo: local
11-
hooks:
12-
- id: cargo-fmt
13-
name: Cargo Fmt
14-
language: "rust"
15-
entry: cargo +nightly-2023-03-01 fmt
16-
pass_filenames: false
17-
- id: cargo-clippy-solana
18-
name: Cargo Clippy Solana
19-
language: "rust"
20-
entry : cargo +nightly-2023-03-01 clippy --tests --features check -- -D warnings
21-
pass_filenames : false
22-
- id: cargo-clippy-pythnet
23-
name: Cargo Clippy Pythnet
24-
language: "rust"
25-
entry : cargo +nightly-2023-03-01 clippy --tests --features pythnet,check -- -D warnings
26-
pass_filenames : false
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v3.2.0
4+
hooks:
5+
- id: trailing-whitespace
6+
files: program/
7+
- id: end-of-file-fixer
8+
files: program/
9+
- id: check-added-large-files
10+
- repo: local
11+
hooks:
12+
- id: cargo-fmt
13+
name: Cargo Fmt
14+
language: "rust"
15+
entry: cargo +nightly-2023-03-01 fmt
16+
pass_filenames: false
17+
- id: cargo-clippy-pythnet
18+
name: Cargo Clippy Pythnet
19+
language: "rust"
20+
entry: cargo +nightly-2023-03-01 clippy --tests -- -D warnings
21+
pass_filenames: false

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ Finally, in docker extension inside VS Code click right and choose "Attach VS Co
155155

156156
Oracle program upgrades are managed by the Pythian Council multisig. The steps to deploy a new version are:
157157

158-
1. Create a release branch from `main`. This should include binary for the Pythnet oracle program (`pyth_oracle_pythnet.so`).
158+
1. Create a release branch from `main`. This should include the binary for the Pythnet oracle program (`pyth_oracle_pythnet.so`).
159159
2. [Install Solana CLI](https://docs.solana.com/cli/install-solana-cli-tools#use-solanas-install-tool) if not already installed.
160160
3. Set Solana config for the target network, e.g., devnet: `solana config set --url https://api.devnet.solana.com`.
161161
4. Execute `solana program write-buffer pyth_oracle_pythnet.so` to obtain the buffer address.

program/rust/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ lazy_static = "1.4.0"
4646
check = [] # Skips make build in build.rs, use with cargo-clippy and cargo-check
4747
debug = []
4848
library = []
49-
pythnet = [] # logic-affecting features start with this one
5049

5150
[lib]
5251
crate-type = ["cdylib", "lib"]

program/rust/build.rs

+4-7
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ use {
1212
fn main() {
1313
let target_arch = std::env::var("CARGO_CFG_TARGET_ARCH").unwrap();
1414

15-
let has_feat_pythnet = std::env::var("CARGO_FEATURE_PYTHNET").is_ok();
1615
let has_feat_check = std::env::var("CARGO_FEATURE_CHECK").is_ok();
1716

1817
// OUT_DIR is the path cargo provides to a build directory under `target/` specifically for
@@ -28,13 +27,11 @@ fn main() {
2827
let mut make_extra_flags = vec![];
2928
let mut clang_extra_flags = vec![];
3029

31-
if has_feat_pythnet {
32-
// Define PC_PYTHNET for the C binary build
33-
make_extra_flags.push("PC_PYTHNET=1");
30+
// Define PC_PYTHNET for the C binary build
31+
make_extra_flags.push("PC_PYTHNET=1");
3432

35-
// Define PC_PYTHNET for the bindings build
36-
clang_extra_flags.push("-DPC_PYTHNET=1");
37-
}
33+
// Define PC_PYTHNET for the bindings build
34+
clang_extra_flags.push("-DPC_PYTHNET=1");
3835

3936
let mut make_targets = vec![];
4037
if target_arch == "bpf" {

program/rust/src/tests/pyth_simulator.rs

-22
Original file line numberDiff line numberDiff line change
@@ -75,28 +75,6 @@ lazy_static::lazy_static! {
7575
// simulator. lazy_static makes this happen only once per test
7676
// run.
7777
static ref ORACLE_PROGRAM_BINARY_PATH: PathBuf = {
78-
79-
// Detect features and pass them onto cargo-build-bpf.
80-
// IMPORTANT: All features of this crate must have gates added to this vector.
81-
let features: Vec<&str> = vec!["pythnet"];
82-
83-
let mut cmd = std::process::Command::new("cargo");
84-
cmd.arg("build-bpf");
85-
86-
if !features.is_empty() {
87-
cmd.arg("--features");
88-
cmd.args(features);
89-
}
90-
91-
let status = cmd.status().unwrap();
92-
93-
if !status.success() {
94-
panic!(
95-
"cargo-build-bpf did not exit with 0 (code {:?})",
96-
status.code()
97-
);
98-
}
99-
10078
let target_dir = concat!(env!("CARGO_MANIFEST_DIR"), "/../../target");
10179

10280
PathBuf::from(target_dir).join("deploy/pyth_oracle.so")

scripts/build-bpf.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ set -x
2020
cd "${PYTH_DIR}"
2121

2222
# Re-run tests affected by features
23-
cargo test --locked --features pythnet
23+
cargo test --locked
2424

25-
cargo-build-bpf -- --locked -Z build-std=std,panic_abort -Z build-std-features=panic_immediate_abort --features pythnet
25+
cargo-build-bpf -- --locked -Z build-std=std,panic_abort -Z build-std-features=panic_immediate_abort
2626
sha256sum ./target/**/*.so
2727
echo "Checking size of pyth_oracle.so for pythnet"
2828
./scripts/check-size.sh 88429

0 commit comments

Comments
 (0)