Skip to content

Commit cd9dc8c

Browse files
- new price aggregation and twap algorithms
- reject price updates for same or previous slot - switch to using programSubscribe instead of accountSubscribe to cut down on websocket subscriptions - decommission parameter account as new algo doesnt need it - error handling check for bad pyth_tx connection - check that previous account is a mapping account when adding new mapping account to list - fix to add/subtract of numbers with very large diff in magnitude - track leader slots and tally missing slots by leader from capture withi slots_info and leader_stats binaries - add -m <commitment> option to control commitment level on program subscription - rename coalesce to sub_drop since they represent account updates that are dropped by solana subscription - deserialize price account info per symbol buffer - hit_rate defined as number received updates where the pub slot changes divided by number of sent transactions - new callback when price account re-initializes: on_response(price_init*) - added "pyth get_block" command to to study all pyth transactions in a single block/slot tighter publish frequency
1 parent 4332ef3 commit cd9dc8c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+3044
-3387
lines changed

CMakeLists.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,10 @@ add_executable( test_publish pctest/test_publish.cpp )
9898
target_link_libraries( test_publish ${PC_DEP} )
9999
add_executable( test_qset pctest/test_qset.cpp )
100100
target_link_libraries( test_qset ${PC_DEP} )
101-
add_executable( test_slot pctest/test_slot.cpp )
102-
target_link_libraries( test_slot ${PC_DEP} )
101+
add_executable( slots_info pctest/slots_info.cpp )
102+
target_link_libraries( slots_info ${PC_DEP} )
103+
add_executable( leader_stats pctest/leader_stats.cpp )
104+
target_link_libraries( leader_stats ${PC_DEP} )
103105

104106
add_test( test_unit test_unit )
105107
add_test( test_net test_net )

dashboard/dashboard.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class Prices
4141
let px = res.price * this.fact[expo];
4242
let conf = res.conf * this.fact[expo];
4343
let twap = res.twap * this.fact[expo];
44-
let avol = res.avol * this.fact[expo];
44+
let twac = res.twac * this.fact[expo];
4545
let color = 'cornsilk';
4646
if ( res.status == 'unknown' ) {
4747
color = '#c0392b';
@@ -53,7 +53,7 @@ class Prices
5353
this.draw_cell( row.cells[col++], px.toFixed(expo), color );
5454
this.draw_cell( row.cells[col++], conf.toFixed(expo), color );
5555
this.draw_cell( row.cells[col++], twap.toFixed(expo), color );
56-
this.draw_cell( row.cells[col++], avol.toFixed(expo), color );
56+
this.draw_cell( row.cells[col++], twac.toFixed(expo), color );
5757
this.draw_cell( row.cells[col++], res.status, color );
5858
this.draw_cell( row.cells[col++], res.valid_slot, color );
5959
this.draw_cell( row.cells[col++], res.pub_slot, color );

dashboard/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ <h2>pyth dashboard
1818
<th width=100px>price</th>
1919
<th width=100px>conf</th>
2020
<th width=100px>twap</th>
21-
<th width=100px>avol</th>
21+
<th width=100px>twac</th>
2222
<th width=80>status</th>
2323
<th>valid_slot</th>
2424
<th>pub_slot</th>

doc/getting_started.md

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,36 +29,35 @@ This will output the public key in base58 encoding and will look something like:
2929
5rYvdyWAunZgD2EC1aKo7hQbutUUnkt7bBFM6xNq2z7Z
3030
```
3131

32-
Once permissioned, you need three additional public keys in the key-store. The id of the mapping-account that contains the directory listing of the on-chain symbols, the id of the on-chain oracle program that you use to publish prices and the id of the parameter-account that contains various math look-up tables used to compute the aggregate price. Mapping, program and parameter accounts are maintained in three separate environments: pythnet, devnet and forthcoming mainnet-beta.
32+
Once permissioned, you need two additional public keys in the key-store. The id of the mapping-account that contains the directory listing of the on-chain symbols and the id of the on-chain oracle program that you use to publish prices. Mapping and program accounts are maintained in two separate environments: devnet and forthcoming mainnet-beta.
3333

3434
Use the init_key_store.sh script to initialize these account keys:
3535

3636
```
37-
KENV=pythnet # or devnet or mainnet-beta
37+
KENV=devnet # or mainnet-beta
3838
3939
# initialize keys for solana devnet
4040
../pctest/init_key_store.sh $KENV $KDIR
4141
4242
```
4343

44-
This creates three files: `$KDIR/mapping_key.json`, `$KDIR/program_key.json`, and `$KDIR/param_key.json`.
44+
This creates two files: `$KDIR/mapping_key.json` and `$KDIR/program_key.json`.
4545

46-
Once permissioned, you can test your setup by running the test_publish.cpp example program for publishing and subscribing to two test symbols. To test publishing on pythnet you need to run:
46+
Once permissioned, you can test your setup by running the test_publish.cpp example program for publishing and subscribing to two test symbols. To test publishing on devnet you need to run:
4747

4848

4949
```
50-
KHOST=44.232.27.44
51-
./test_publish -k $KDIR -r $KHOST -t $KHOST
50+
KHOST=api.devnet.solana.com
51+
THOST=<your_pyth_tx_host>
52+
./test_publish -k $KDIR -r $KHOST -t $THOST
5253
```
5354

5455
The -r and -t options correspond to the locations of required solana validator and pyth_tx server instances.
5556

56-
The certification environment (pythnet) can be found at the IP address 44.232.27.44 where the test validator and pyth_tx instances run. Please also provide to the administrator the IP address you plan to publish to pythnet from so that it can be added to the pythnet firewall.
57-
5857
You can also publish to solana using the pythd server. Start up the server using the same key-store directory and host specification:
5958

6059
```
61-
./pythd -k $KDIR -r $KHOST -t $KHOST
60+
./pythd -k $KDIR -r $KHOST -t $THOST
6261
```
6362

6463
Run the test_publish.py example program on the same host to connect to the pythd server:
@@ -76,7 +75,7 @@ The solana rpc interface is used for tracking slot and account updates. The pyth
7675

7776
pyth_tx runs as a separate server rather than being integrated directly into the client library to avoid a publisher from having to submit UDP datagrams to hundreds of different IP address from within an organization's firewall. Instead, a pyth_tx server can be deployed outside the firewall and a publisher clienti, running inside the firewall, can make a single TCP connection to it on a dedicated port.
7877

79-
You can run your own pyth_tx instance (recommended) or connect to provided server instances running against pythnet and mainnet-beta environments.
78+
You can run your own pyth_tx instance (recommended) or connect to provided server instances running against mainnet-beta.
8079

8180
Start up the pyth_tx server as follows:
8281

doc/migrating_to_version_2.md

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

pc/key_store.cpp

Lines changed: 1 addition & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,7 @@ key_store::key_store()
4141
has_mkey_( false ),
4242
has_mpub_( false ),
4343
has_gkey_( false ),
44-
has_gpub_( false ),
45-
has_akey_( false ),
46-
has_apub_( false )
44+
has_gpub_( false )
4745
{
4846
}
4947

@@ -128,16 +126,6 @@ std::string key_store::get_program_pub_key_file() const
128126
return dir_ + "program_key.json";
129127
}
130128

131-
std::string key_store::get_param_key_pair_file() const
132-
{
133-
return dir_ + "param_key_pair.json";
134-
}
135-
136-
std::string key_store::get_param_pub_key_file() const
137-
{
138-
return dir_ + "param_key.json";
139-
}
140-
141129
key_pair *key_store::create_publish_key_pair()
142130
{
143131
pkey_.gen();
@@ -265,47 +253,6 @@ pub_key *key_store::get_program_pub_key()
265253
return &gpub_;
266254
}
267255

268-
key_pair *key_store::create_param_key_pair()
269-
{
270-
akey_.gen();
271-
if ( !write_key_file( get_param_key_pair_file(), akey_ ) ) {
272-
return nullptr;
273-
}
274-
akey_.get_pub_key( apub_ );
275-
has_akey_ = true;
276-
has_apub_ = true;
277-
return &akey_;
278-
}
279-
280-
key_pair *key_store::get_param_key_pair()
281-
{
282-
if ( has_akey_ ) {
283-
return &akey_;
284-
}
285-
if ( !akey_.init_from_file( get_param_key_pair_file() ) ) {
286-
return nullptr;
287-
}
288-
akey_.get_pub_key( apub_ );
289-
has_akey_ = true;
290-
has_apub_ = true;
291-
return &akey_;
292-
}
293-
294-
pub_key *key_store::get_param_pub_key()
295-
{
296-
if ( has_apub_ ) {
297-
return &apub_;
298-
}
299-
if ( get_param_key_pair() ) {
300-
return &apub_;
301-
}
302-
if ( !apub_.init_from_file( get_param_pub_key_file() ) ) {
303-
return nullptr;
304-
}
305-
has_apub_ = true;
306-
return &apub_;
307-
}
308-
309256
bool key_store::create_account_key_pair( key_pair& res )
310257
{
311258
res.gen();

pc/key_store.hpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ namespace pc
2929
std::string get_mapping_pub_key_file() const;
3030
std::string get_program_key_pair_file() const;
3131
std::string get_program_pub_key_file() const;
32-
std::string get_param_key_pair_file() const;
33-
std::string get_param_pub_key_file() const;
3432

3533
// primary publishing and funding key
3634
key_pair *create_publish_key_pair();
@@ -48,11 +46,6 @@ namespace pc
4846
key_pair *get_program_key_pair();
4947
pub_key *get_program_pub_key();
5048

51-
// get parameter account key_pair or public key
52-
key_pair *create_param_key_pair();
53-
key_pair *get_param_key_pair();
54-
pub_key *get_param_pub_key();
55-
5649
// create new mapping or symbol account
5750
bool create_account_key_pair( key_pair& );
5851
bool get_account_key_pair( const pub_key&, key_pair& );
@@ -64,17 +57,13 @@ namespace pc
6457
bool has_mpub_;
6558
bool has_gkey_;
6659
bool has_gpub_;
67-
bool has_akey_;
68-
bool has_apub_;
6960
key_pair pkey_; // primary publishing and funding key
7061
key_pair mkey_; // mapping account key
7162
key_pair gkey_; // program key pair
72-
key_pair akey_; // parameter account key pair
7363
key_cache ckey_; // publishing cache key
7464
pub_key ppub_; // publisher public key
7565
pub_key mpub_; // mapping account public key
7666
pub_key gpub_; // program id
77-
pub_key apub_; // parameter account public key
7867
std::string dir_; // key store directory
7968
};
8069

0 commit comments

Comments
 (0)