Skip to content

Commit 90ba997

Browse files
authored
Remove resize logic (#316)
* Remove resize logic * Cleanup * Cleanup
1 parent 08940f1 commit 90ba997

File tree

8 files changed

+1
-269
lines changed

8 files changed

+1
-269
lines changed

docker/Dockerfile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,6 @@ export PYTHONPATH=\"\${PYTHONPATH:+\$PYTHONPATH:}\${HOME}/pyth-client\"\n\
5757

5858
COPY --chown=pyth:pyth . pyth-client/
5959

60-
RUN pip3 install solana
61-
6260
# Build off-chain binaries.
6361
RUN cd pyth-client && ./scripts/build.sh
6462

program/rust/src/processor.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ mod del_product;
2222
mod del_publisher;
2323
mod init_mapping;
2424
mod init_price;
25-
mod resize_price_account;
2625
mod set_min_pub;
2726
mod upd_permissions;
2827
mod upd_price;
@@ -38,7 +37,6 @@ pub use {
3837
del_publisher::del_publisher,
3938
init_mapping::init_mapping,
4039
init_price::init_price,
41-
resize_price_account::resize_price_account,
4240
set_min_pub::set_min_pub,
4341
upd_permissions::upd_permissions,
4442
upd_price::{
@@ -72,7 +70,7 @@ pub fn process_instruction(
7270
UpdTest => Err(OracleError::UnrecognizedInstruction.into()),
7371
SetMinPub => set_min_pub(program_id, accounts, instruction_data),
7472
UpdPriceNoFailOnError => upd_price_no_fail_on_error(program_id, accounts, instruction_data),
75-
ResizePriceAccount => resize_price_account(program_id, accounts, instruction_data),
73+
ResizePriceAccount => Err(OracleError::UnrecognizedInstruction.into()),
7674
DelPrice => del_price(program_id, accounts, instruction_data),
7775
DelProduct => del_product(program_id, accounts, instruction_data),
7876
UpdPermissions => upd_permissions(program_id, accounts, instruction_data),

program/rust/src/processor/resize_price_account.rs

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

program/rust/src/tests/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ mod test_del_publisher;
99
mod test_init_mapping;
1010
mod test_init_price;
1111
mod test_permission_migration;
12-
mod test_resize_account;
1312
mod test_set_min_pub;
1413
mod test_sizes;
1514
mod test_sma;

program/rust/src/tests/pyth_simulator.rs

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -331,32 +331,6 @@ impl PythSimulator {
331331
.await
332332
}
333333

334-
/// Resize a price account (using the resize_price_account
335-
/// instruction).
336-
pub async fn resize_price_account(
337-
&mut self,
338-
price_keypair: &Keypair,
339-
) -> Result<(), BanksClientError> {
340-
let cmd: CommandHeader = OracleCommand::ResizePriceAccount.into();
341-
let instruction = Instruction::new_with_bytes(
342-
self.program_id,
343-
bytes_of(&cmd),
344-
vec![
345-
AccountMeta::new(self.genesis_keypair.pubkey(), true),
346-
AccountMeta::new(price_keypair.pubkey(), true),
347-
AccountMeta::new(system_program::id(), false),
348-
],
349-
);
350-
351-
self.process_ix(
352-
instruction,
353-
&vec![price_keypair],
354-
&copy_keypair(&self.genesis_keypair),
355-
)
356-
.await
357-
}
358-
359-
360334
/// Update permissions (using the upd_permissions intruction) and return the pubkey of the
361335
/// permissions account
362336
pub async fn upd_permissions(

program/rust/src/tests/test_permission_migration.rs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ use {
2525
DelPublisher,
2626
InitMapping,
2727
InitPrice,
28-
ResizePriceAccount,
2928
SetMinPub,
3029
UpdProduct,
3130
},
@@ -226,20 +225,6 @@ fn test_permission_migration() {
226225
Err(OracleError::PermissionViolation.into())
227226
);
228227

229-
assert_eq!(
230-
process_instruction(
231-
&program_id,
232-
&[
233-
attacker_account.clone(),
234-
price_account.clone(),
235-
price_account.clone(), // Mock system program
236-
permissions_account.clone()
237-
],
238-
bytes_of::<CommandHeader>(&ResizePriceAccount.into())
239-
),
240-
Err(OracleError::PermissionViolation.into())
241-
);
242-
243228
assert_eq!(
244229
process_instruction(
245230
&program_id,

program/rust/src/tests/test_resize_account.rs

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

pyth/tests/test_publish.py

Lines changed: 0 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,3 @@
1-
from typing import Dict
2-
from construct import Bytes, Int32sl, Int32ul, Struct
3-
from solana.publickey import PublicKey
4-
from solana.transaction import AccountMeta, TransactionInstruction, Transaction
5-
from solana.keypair import Keypair
6-
from solana.rpc.api import Client
7-
import base64
8-
import os
9-
import asyncio
10-
111
import json
122
import time
133
from subprocess import check_call, check_output
@@ -29,58 +19,6 @@ def get_price_acct():
2919
output = output.decode('ascii')
3020
output = json.loads(output)
3121
return output['price_accounts'][0]
32-
33-
def get_key_pair(path_to_file):
34-
with open(path_to_file) as key_file:
35-
key_data = json.load(key_file)
36-
return Keypair.from_secret_key(key_data)
37-
38-
def get_path_to_pythdir_pair(account_addr):
39-
return os.path.join(pyth_dir, "account_" + str(account_addr) + ".json")
40-
41-
42-
43-
def resize_account(price_account_address):
44-
"""
45-
given a string with the pubkey of a price account it calls the resize instruction of the Oracle on it
46-
"""
47-
#constants from oracle.h
48-
PROGRAM_VERSION = 2 #TODO: update this
49-
COMMAND_UPD_ACCOUNT = 14
50-
SYSTEM_PROGRAM = "11111111111111111111111111111111"
51-
52-
#update version of price accounts to make sure they resize
53-
layout = Struct("version" / Int32ul, "command" / Int32sl)
54-
data = layout.build(dict(version=PROGRAM_VERSION, command=COMMAND_UPD_ACCOUNT))
55-
funding_key = PublicKey(solana_keygen[0])
56-
price_key = PublicKey(price_account_address)
57-
system_key = PublicKey(SYSTEM_PROGRAM)
58-
resize_instruction = TransactionInstruction(
59-
data=data,
60-
keys=[
61-
AccountMeta(pubkey=funding_key, is_signer=True, is_writable=True),
62-
AccountMeta(pubkey=price_key, is_signer=True, is_writable=True),
63-
AccountMeta(pubkey=system_key, is_signer=False, is_writable=False),
64-
],
65-
program_id = PublicKey(solana_program_deploy),
66-
)
67-
txn = Transaction().add(resize_instruction)
68-
txn.fee_payer = funding_key
69-
funding_key_pair = get_key_pair(solana_keygen[1])
70-
path_to_price = get_path_to_pythdir_pair(price_key)
71-
price_key_pair = get_key_pair(path_to_price)
72-
solana_client = Client("http://localhost:8899")
73-
solana_client.send_transaction(txn, funding_key_pair, price_key_pair)
74-
75-
def get_account_size(acc_address):
76-
"""
77-
given a string with the pubkey of an account, return its size
78-
"""
79-
PublicKey(acc_address)
80-
solana_client = Client("http://localhost:8899")
81-
data = solana_client.get_account_info(PublicKey(acc_address), encoding = 'base64').value.data
82-
return len(data)
83-
8422

8523
before = get_price_acct()
8624
assert before['publisher_accounts'][0]['price'] == 0
@@ -116,15 +54,6 @@ def get_account_size(acc_address):
11654
assert after['publisher_accounts'][0]['conf'] == 7
11755
assert after['publisher_accounts'][0]['status'] == 'trading'
11856

119-
resize_account(pyth_init_price['LTC'])
120-
time.sleep(20)
121-
#defined in oracle.h
122-
new_account_size = 7584
123-
assert get_account_size(pyth_init_price['LTC']) == new_account_size
124-
125-
126-
127-
#try adding a new price to the resized accounts
12857
cmd = [
12958
'pyth', 'upd_price_val',
13059
pyth_init_price['LTC'],

0 commit comments

Comments
 (0)