Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions pc/rpc_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -910,19 +910,29 @@ bool rpc::upd_price::build_tx(
auto& first = *upds[ 0 ];

// accounts
tx.add_len( n + 3 ); // n + 3 accounts: publish, symbol{n}, sysvar, program
tx.add_len( n + 4 ); // n + 4 accounts: publish, symbol{n}, sysvar, pyth program, compute budget program
tx.add( *first.pkey_ ); // publish account
for ( unsigned i = 0; i < n; ++i ) {
tx.add( *upds[ i ]->akey_ ); // symbol account
}
tx.add( *(pub_key*)sysvar_clock ); // sysvar account
tx.add( *first.gkey_ ); // programid
tx.add( *(pub_key*)compute_budget_program_id ); // compute budget program id

// recent block hash
tx.add( *first.bhash_ ); // recent block hash

// instructions section
tx.add_len( n ); // n instruction(s)
tx.add_len( n + 1 ); // 1 compute limit instruction, n upd_price instruction(s)

// Set compute limit
tx.add( (uint8_t)( n + 3 ) ); // compute budget program id index in accounts list
tx.add_len<0>(); // no accounts
// compute limit instruction parameters
tx.add_len<sizeof(uint8_t) + sizeof(uint32_t)>(); // uint8_t enum variant + uint32_t requested compute units
tx.add( (uint8_t) 2 ); // SetComputeLimit enum variant
tx.add( (uint32_t) CU_BUDGET_PER_IX * n ); // the budget (scaled for number of instructions)

for ( unsigned i = 0; i < n; ++i ) {
tx.add( (uint8_t)( n + 2 ) ); // program_id index
tx.add_len< 3 >(); // 3 accounts: publish, symbol, sysvar
Expand Down
20 changes: 20 additions & 0 deletions program/c/src/oracle/oracle.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ const uint64_t EXTRA_PUBLISHER_SPACE = 3072ULL;
#define PC_ACCTYPE_TEST 4
#define PC_ACCTYPE_PERMISSIONS 5


// Compute budget requested per price update instruction
// The biggest instruction appears to be about ~10300 CUs, so overestimate by 100%.
#define CU_BUDGET_PER_IX 20000

// binary version of sysvar_clock account id
const uint64_t sysvar_clock[] = {
0xc974c71817d5a706UL,
Expand All @@ -61,6 +66,21 @@ const uint64_t sysvar_clock[] = {
0x215b5573UL
};

// compute budget program id in hex (but wrong endianness)
/*
321721e56f460603
e79bc372baadecff
6b12f7c5bbe58cbc
403a9b432c
*/

const uint64_t compute_budget_program_id[] = {
0x321721e56f460603UL,
0xe79bc372baadecffUL,
0x6b12f7c5bbe58cbcUL,
0x403a9b432cUL
};

// public key of symbol or publisher account
typedef union pc_pub_key
{
Expand Down