Skip to content

Commit 1b262ad

Browse files
committed
remove solana specific code
1 parent 46caea4 commit 1b262ad

File tree

10 files changed

+14
-149
lines changed

10 files changed

+14
-149
lines changed

.github/workflows/docker.yaml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -61,17 +61,7 @@ jobs:
6161
run : |
6262
docker create -ti --name container "${DOCKER_IMAGE}" bash
6363
docker cp container:/home/pyth/pyth-client/target/pyth/pythnet/pyth_oracle_pythnet.so .
64-
docker cp container:/home/pyth/pyth-client/target/pyth/solana/pyth_oracle_solana.so .
6564
docker rm -f container
66-
67-
- name : Publish Solana binary
68-
if : env.IS_ORACLE_RELEASE == 'true'
69-
uses: svenstaro/upload-release-action@133984371c30d34e38222a64855679a414cb7575
70-
with:
71-
repo_token: ${{ secrets.GITHUB_TOKEN }}
72-
file: ./pyth_oracle_solana.so
73-
asset_name: pyth_oracle_solana.so
74-
tag: ${{ github.ref }}
7565
7666
- name : Publish Pythnet binary
7767
if : env.IS_ORACLE_RELEASE == 'true'

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,10 +155,10 @@ 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 binaries for both the Solana mainnet and Pythnet oracle programs (`pyth_oracle_solana.so` and `pyth_oracle_pythnet.so`).
158+
1. Create a release branch from `main`. This should include binary for both the Pythnet oracle programs (`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`.
161-
4. Execute `solana program write-buffer <ORACLE_PROGRAM_BINARY_FILENAME>` where `<ORACLE_PROGRAM_BINARY_FILENAME>` can be `pyth_oracle_solana.so` or `pyth_oracle_pythnet.so` to obtain the buffer address.
161+
4. Execute `solana program write-buffer pyth_oracle_pythnet.so` to obtain the buffer address.
162162
5. Run `solana program show <ORACLE_PROGRAM_PUBKEY>` to obtain the authority of the current program.
163163
6. Use `solana program set-buffer-authority <BUFFER_PUBKEY> --new-buffer-authority <NEW_BUFFER_AUTHORITY>` to assign the upgrade authority from the previous step to the buffer address.
164164
7. Submit a proposal with [`xc-admin`](https://github.com/pyth-network/pyth-crosschain/tree/main/governance/xc_admin/packages/xc_admin_cli) for program upgrade using the `upgrade-program` command.

program/rust/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ lazy_static = "1.4.0"
4343
# to cargo-build-bpf at that point - we manually capture them at
4444
# compile-time and pass on to the child process.
4545
[features]
46+
default = ["pythnet"]
4647
check = [] # Skips make build in build.rs, use with cargo-clippy and cargo-check
4748
debug = []
4849
library = []

program/rust/src/accounts.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@ mod product;
4343
// Some types only exist during use as a library.
4444
#[cfg(feature = "strum")]
4545
pub use price::MessageType;
46-
#[cfg(feature = "pythnet")]
47-
pub use price::PriceCumulative;
4846
#[cfg(test)]
4947
pub use product::{
5048
account_has_key_values,
@@ -56,6 +54,7 @@ pub use {
5654
price::{
5755
PriceAccount,
5856
PriceComponent,
57+
PriceCumulative,
5958
PriceEma,
6059
PriceInfo,
6160
PythOracleSerialize,
@@ -72,7 +71,6 @@ pub use {
7271
/// are authorized to perform certain administrative actions.
7372
pub const PERMISSIONS_SEED: &str = "permissions";
7473

75-
#[cfg(feature = "pythnet")]
7674
/// The update price instruction can optionally invoke another program via CPI. The
7775
/// CPI will be signed with the PDA `[UPD_PRICE_WRITE_SEED, invoked_program_public_key]`
7876
/// such that the caller can authenticate its origin.

program/rust/src/accounts/price.rs

Lines changed: 0 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
#[cfg(feature = "pythnet")]
21
pub use price_pythnet::*;
3-
#[cfg(not(feature = "pythnet"))]
4-
pub use price_solana::*;
52
use {
63
super::{
74
AccountHeader,
@@ -21,7 +18,6 @@ use {
2118
};
2219

2320
/// Pythnet-specific PriceAccount implementation
24-
#[cfg(feature = "pythnet")]
2521
mod price_pythnet {
2622
pub type PriceAccount = PriceAccountPythnet;
2723

@@ -191,79 +187,6 @@ mod price_pythnet {
191187
}
192188
}
193189

194-
/// Solana-specific PriceAccount implementation
195-
#[cfg(not(feature = "pythnet"))]
196-
mod price_solana {
197-
pub type PriceAccount = PriceAccountSolana;
198-
199-
use {
200-
super::*,
201-
crate::c_oracle_header::PC_NUM_COMP_SOLANA,
202-
};
203-
204-
/// Legacy Solana-only price account format. This price account
205-
/// schema is maintained for compatibility reasons.
206-
///
207-
/// The main source of incompatibility on mainnet/devnet is the
208-
/// possibility of strict account size checks which could break
209-
/// existing users if they encountered a longer struct like
210-
/// PriceAccountPythnet (see mod price_pythnet for details)
211-
#[repr(C)]
212-
#[derive(Copy, Clone, Pod, Zeroable)]
213-
pub struct PriceAccountSolana {
214-
pub header: AccountHeader,
215-
/// Type of the price account
216-
pub price_type: u32,
217-
/// Exponent for the published prices
218-
pub exponent: i32,
219-
/// Current number of authorized publishers
220-
pub num_: u32,
221-
/// Number of valid quotes for the last aggregation
222-
pub num_qt_: u32,
223-
/// Last slot with a succesful aggregation (status : TRADING)
224-
pub last_slot_: u64,
225-
/// Second to last slot where aggregation was attempted
226-
pub valid_slot_: u64,
227-
/// Ema for price
228-
pub twap_: PriceEma,
229-
/// Ema for confidence
230-
pub twac_: PriceEma,
231-
/// Last time aggregation was attempted
232-
pub timestamp_: i64,
233-
/// Minimum valid publisher quotes for a succesful aggregation
234-
pub min_pub_: u8,
235-
/// Whether the current aggregate price has been sent as a message to the message buffer.
236-
/// 0 = false, 1 = true. (this is a u8 to make the Pod trait happy)
237-
pub message_sent_: u8,
238-
/// Configurable max latency in slots between send and receive
239-
pub max_latency_: u8,
240-
/// Unused placeholder for alignment
241-
pub unused_2_: i8,
242-
pub unused_3_: i32,
243-
/// Corresponding product account
244-
pub product_account: Pubkey,
245-
/// Next price account in the list
246-
pub next_price_account: Pubkey,
247-
/// Second to last slot where aggregation was succesful (i.e. status : TRADING)
248-
pub prev_slot_: u64,
249-
/// Aggregate price at prev_slot_
250-
pub prev_price_: i64,
251-
/// Confidence interval at prev_slot_
252-
pub prev_conf_: u64,
253-
/// Timestamp of prev_slot_
254-
pub prev_timestamp_: i64,
255-
/// Last attempted aggregate results
256-
pub agg_: PriceInfo,
257-
/// Publishers' price components
258-
pub comp_: [PriceComponent; PC_NUM_COMP_SOLANA as usize],
259-
}
260-
261-
impl PythAccount for PriceAccountSolana {
262-
const ACCOUNT_TYPE: u32 = PC_ACCTYPE_PRICE;
263-
const INITIAL_SIZE: u32 = size_of::<PriceAccountSolana>() as u32;
264-
}
265-
}
266-
267190
#[repr(C)]
268191
#[derive(Copy, Clone, Pod, Zeroable)]
269192
pub struct PriceComponent {

program/rust/src/processor/upd_price.rs

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,10 @@
1-
#[cfg(feature = "pythnet")]
2-
use {
3-
crate::accounts::{
4-
PythOracleSerialize,
5-
UPD_PRICE_WRITE_SEED,
6-
},
7-
solana_program::instruction::{
8-
AccountMeta,
9-
Instruction,
10-
},
11-
solana_program::program::invoke_signed,
12-
};
131
use {
142
crate::{
153
accounts::{
164
PriceAccount,
175
PriceInfo,
6+
PythOracleSerialize,
7+
UPD_PRICE_WRITE_SEED,
188
},
199
deserialize::{
2010
load,
@@ -35,6 +25,11 @@ use {
3525
account_info::AccountInfo,
3626
clock::Clock,
3727
entrypoint::ProgramResult,
28+
instruction::{
29+
AccountMeta,
30+
Instruction,
31+
},
32+
program::invoke_signed,
3833
program_error::ProgramError,
3934
pubkey::Pubkey,
4035
sysvar::Sysvar,
@@ -44,10 +39,7 @@ use {
4439
#[cfg(target_arch = "bpf")]
4540
#[link(name = "cpyth-bpf")]
4641
extern "C" {
47-
#[cfg(feature = "pythnet")]
4842
pub fn c_upd_aggregate_pythnet(_input: *mut u8, clock_slot: u64, clock_timestamp: i64) -> bool;
49-
#[cfg(not(feature = "pythnet"))]
50-
pub fn c_upd_aggregate_solana(_input: *mut u8, clock_slot: u64, clock_timestamp: i64) -> bool;
5143

5244
#[allow(unused)]
5345
pub fn c_upd_twap(_input: *mut u8, nslots: i64);
@@ -56,21 +48,15 @@ extern "C" {
5648
#[cfg(not(target_arch = "bpf"))]
5749
#[link(name = "cpyth-native")]
5850
extern "C" {
59-
#[cfg(feature = "pythnet")]
6051
pub fn c_upd_aggregate_pythnet(_input: *mut u8, clock_slot: u64, clock_timestamp: i64) -> bool;
61-
#[cfg(not(feature = "pythnet"))]
62-
pub fn c_upd_aggregate_solana(_input: *mut u8, clock_slot: u64, clock_timestamp: i64) -> bool;
6352

6453
#[allow(unused)]
6554
pub fn c_upd_twap(_input: *mut u8, nslots: i64);
6655
}
6756

6857
#[inline]
6958
pub unsafe fn c_upd_aggregate(input: *mut u8, clock_slot: u64, clock_timestamp: i64) -> bool {
70-
#[cfg(feature = "pythnet")]
71-
return c_upd_aggregate_pythnet(input, clock_slot, clock_timestamp);
72-
#[cfg(not(feature = "pythnet"))]
73-
return c_upd_aggregate_solana(input, clock_slot, clock_timestamp);
59+
c_upd_aggregate_pythnet(input, clock_slot, clock_timestamp)
7460
}
7561

7662
/// Publish component price, never returning an error even if the update failed
@@ -197,7 +183,6 @@ pub fn upd_price(
197183
let mut price_data = load_checked::<PriceAccount>(price_account, cmd_args.header.version)?;
198184

199185
// Feature-gated accumulator-specific code, used only on pythnet/pythtest
200-
#[cfg(feature = "pythnet")]
201186
{
202187
// We want to send a message every time the aggregate price updates. However, during the migration,
203188
// not every publisher will necessarily provide the accumulator accounts. The message_sent_ flag

program/rust/src/tests/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ mod test_upd_price_no_fail_on_error;
2626
mod test_upd_product;
2727
mod test_utils;
2828

29-
#[cfg(feature = "pythnet")]
29+
3030
mod test_twap;
31-
#[cfg(feature = "pythnet")]
3231
mod test_upd_price_v2;

program/rust/src/tests/pyth_simulator.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,7 @@ lazy_static::lazy_static! {
7878

7979
// Detect features and pass them onto cargo-build-bpf.
8080
// IMPORTANT: All features of this crate must have gates added to this vector.
81-
let features: Vec<&str> = vec![
82-
#[cfg(feature = "pythnet")]
83-
"pythnet",
84-
85-
];
81+
let features: Vec<&str> = vec!["pythnet"];
8682

8783
let mut cmd = std::process::Command::new("cargo");
8884
cmd.arg("build-bpf");
@@ -215,7 +211,6 @@ impl PythSimulator {
215211
.await
216212
.unwrap();
217213

218-
219214
result
220215
}
221216

program/rust/src/tests/test_sizes.rs

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ fn test_sizes() {
5353
size_of::<Pubkey>() + 2 * size_of::<PriceInfo>()
5454
);
5555

56-
#[cfg(feature = "pythnet")]
5756
{
5857
use crate::{
5958
accounts::PriceCumulative,
@@ -77,24 +76,6 @@ fn test_sizes() {
7776
assert_eq!(size_of::<PriceCumulative>(), 48);
7877
}
7978

80-
#[cfg(not(feature = "pythnet"))]
81-
{
82-
use crate::c_oracle_header::PC_NUM_COMP_SOLANA;
83-
84-
// Sanity-check the Solana PC_NUM_COMP
85-
assert_eq!(PC_NUM_COMP, PC_NUM_COMP_SOLANA);
86-
87-
assert_eq!(
88-
size_of::<PriceAccount>(),
89-
48 + u64::BITS as usize
90-
+ 3 * size_of::<Pubkey>()
91-
+ size_of::<PriceInfo>()
92-
+ (PC_NUM_COMP_SOLANA as usize) * size_of::<PriceComponent>()
93-
);
94-
assert_eq!(size_of::<PriceAccount>(), 3312);
95-
assert!(size_of::<PriceAccount>() <= try_convert::<_, usize>(ZSTD_UPPER_BOUND).unwrap());
96-
}
97-
9879
assert_eq!(size_of::<CommandHeader>(), 8);
9980
assert_eq!(size_of::<AddPriceArgs>(), 16);
10081
assert_eq!(size_of::<InitPriceArgs>(), 16);

scripts/build-bpf.sh

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,6 @@ cargo test --locked
2424
# Re-run tests affected by features
2525
cargo test --locked --features pythnet
2626

27-
cargo-build-bpf -- --locked -Z build-std=std,panic_abort -Z build-std-features=panic_immediate_abort
28-
sha256sum ./target/**/*.so
29-
echo "Checking size of pyth_oracle.so for mainnet"
30-
./scripts/check-size.sh 81760
31-
mkdir -p target/pyth/solana/
32-
mv target/deploy/pyth_oracle.so target/pyth/solana/pyth_oracle_solana.so
33-
3427
cargo-build-bpf -- --locked -Z build-std=std,panic_abort -Z build-std-features=panic_immediate_abort --features pythnet
3528
sha256sum ./target/**/*.so
3629
echo "Checking size of pyth_oracle.so for pythnet"

0 commit comments

Comments
 (0)