diff --git a/pc/rpc_client.cpp b/pc/rpc_client.cpp index 9096b19f9..d823afdfa 100644 --- a/pc/rpc_client.cpp +++ b/pc/rpc_client.cpp @@ -923,7 +923,7 @@ bool rpc::upd_price::build_tx( tx.add( *first.bhash_ ); // recent block hash // instructions section - tx.add_len( n + 1 ); // 1 compute limit instruction, n upd_price instruction(s) + tx.add_len( n + 1 + 1 ); // 1 compute limit instruction, 1 compute unit price instruction, n upd_price instruction(s) // Set compute limit tx.add( (uint8_t)( n + 3 ) ); // compute budget program id index in accounts list @@ -933,6 +933,19 @@ bool rpc::upd_price::build_tx( tx.add( (uint8_t) 2 ); // SetComputeLimit enum variant tx.add( (uint32_t) CU_BUDGET_PER_IX * n ); // the budget (scaled for number of instructions) + // Requested price per compute unit, in micro lamports + // We want to pay 5000 lamports in total, so ((5000/20000) / 8) * (10^6) + // assuming upper bound of 20000 CUs and 8 instructions. + const uint64_t cu_price_micro_lamports = 31250; + + // Set compute unit price + tx.add( (uint8_t)( n + 3 ) ); + tx.add_len<0>(); // no accounts + // compute unit price instruction parameters + tx.add_len(); // uint8_t enum variant + uint62_t compute price + tx.add( (uint8_t) 3 ); // SetComputePrice enum variant + tx.add( (uint64_t) cu_price_micro_lamports ); // price we are willing to pay per compute unit in Micro Lamports + 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 diff --git a/program/c/src/oracle/oracle.h b/program/c/src/oracle/oracle.h index 56121f6b0..2e4321df9 100644 --- a/program/c/src/oracle/oracle.h +++ b/program/c/src/oracle/oracle.h @@ -74,6 +74,7 @@ e79bc372baadecff 403a9b432c */ +// correct const uint64_t compute_budget_program_id[] = { 0x321721e56f460603UL, 0xe79bc372baadecffUL,