Skip to content

Commit ebb1a13

Browse files
authored
[twap] Delete old twap implementation (#358)
* checkpoint * Remove all old sma files * Bring back warnings denial * restore PRICE_ACCOUNT_SIZE * Restore PRICE_ACCOUNT_SIZE * Add check for the upper bound * Oops,fix test * Typo * Fix CI
1 parent 5bb7e0c commit ebb1a13

File tree

10 files changed

+6
-1320
lines changed

10 files changed

+6
-1320
lines changed

program/c/src/oracle/oracle.h

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,6 @@
77
extern "C" {
88
#endif
99

10-
// The size of the "time machine" account defined in the
11-
// Rust portion of the codebase.
12-
const uint64_t TIME_MACHINE_STRUCT_SIZE = 1200ULL;
13-
14-
const uint64_t EXTRA_PUBLISHER_SPACE = 3072ULL;
15-
16-
1710
// magic number at head of account
1811
#define PC_MAGIC 0xa1b2c3d4
1912

@@ -205,7 +198,10 @@ typedef struct pc_price
205198

206199
static_assert( sizeof( pc_price_t ) == 3312, "" );
207200

208-
const uint64_t PRICE_ACCOUNT_SIZE = TIME_MACHINE_STRUCT_SIZE + EXTRA_PUBLISHER_SPACE + sizeof( pc_price_t );
201+
// This constant needs to be an upper bound of the price account size, it is used within pythd for ztsd.
202+
// It is set tighly to the current price account + 96 component prices + 48 bytes for cumulative sums
203+
const uint64_t PRICE_ACCOUNT_SIZE = 3312 + 96 * sizeof( pc_price_comp_t) + 48;
204+
209205

210206
// command enumeration
211207
typedef enum {

program/rust/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ mod deserialize;
88
mod error;
99
mod instruction;
1010
mod processor;
11-
mod time_machine_types;
1211
mod utils;
1312

1413
#[cfg(test)]

program/rust/src/processor/upd_price.rs

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -126,23 +126,6 @@ pub fn upd_price(
126126
}
127127
}
128128

129-
#[cfg(test)]
130-
// Sma feature disabled in production for now
131-
{
132-
use crate::accounts::PythAccount;
133-
let account_len = price_account.try_data_len()?;
134-
if aggregate_updated
135-
&& account_len == crate::time_machine_types::PriceAccountWrapper::MINIMUM_SIZE
136-
{
137-
let mut price_account = load_checked::<crate::time_machine_types::PriceAccountWrapper>(
138-
price_account,
139-
cmd_args.header.version,
140-
)?;
141-
price_account.add_price_to_time_machine()?;
142-
}
143-
}
144-
145-
146129
// Try to update the publisher's price
147130
if is_component_update(cmd_args)? {
148131
let status: u32 =

program/rust/src/tests/mod.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,9 @@ mod test_publish;
1616
mod test_publish_batch;
1717
mod test_set_min_pub;
1818
mod test_sizes;
19-
mod test_sma;
20-
mod test_sma_epoch_transition;
2119
mod test_upd_aggregate;
2220
mod test_upd_permissions;
2321
mod test_upd_price;
2422
mod test_upd_price_no_fail_on_error;
2523
mod test_upd_product;
26-
mod test_upd_sma;
2724
mod test_utils;

program/rust/src/tests/test_sizes.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ use {
3131
UpdPriceArgs,
3232
},
3333
tests::test_utils::AccountSetup,
34-
time_machine_types::PriceAccountWrapper,
3534
utils::try_convert,
3635
},
3736
solana_program::pubkey::Pubkey,
@@ -74,10 +73,8 @@ fn test_sizes() {
7473
assert_eq!(size_of::<PriceComponent>(), 96);
7574
assert_eq!(size_of::<PriceEma>(), 24);
7675
assert_eq!(size_of::<PriceAccount>(), 3312);
77-
assert_eq!(
78-
size_of::<PriceAccountWrapper>(),
79-
try_convert::<_, usize>(PRICE_ACCOUNT_SIZE).unwrap()
80-
);
76+
assert_eq!(PRICE_ACCOUNT_SIZE, 12576);
77+
assert!(size_of::<PriceAccount>() <= try_convert::<_, usize>(PRICE_ACCOUNT_SIZE).unwrap());
8178
assert_eq!(size_of::<PermissionAccount>(), 112);
8279
}
8380

program/rust/src/tests/test_sma.rs

Lines changed: 0 additions & 180 deletions
This file was deleted.

0 commit comments

Comments
 (0)