@@ -910,19 +910,29 @@ bool rpc::upd_price::build_tx(
910
910
auto & first = *upds[ 0 ];
911
911
912
912
// accounts
913
- tx.add_len ( n + 3 ); // n + 3 accounts: publish, symbol{n}, sysvar, program
913
+ tx.add_len ( n + 4 ); // n + 4 accounts: publish, symbol{n}, sysvar, pyth program, compute budget program
914
914
tx.add ( *first.pkey_ ); // publish account
915
915
for ( unsigned i = 0 ; i < n; ++i ) {
916
916
tx.add ( *upds[ i ]->akey_ ); // symbol account
917
917
}
918
918
tx.add ( *(pub_key*)sysvar_clock ); // sysvar account
919
919
tx.add ( *first.gkey_ ); // programid
920
+ tx.add ( *(pub_key*)compute_budget_program_id ); // compute budget program id
920
921
921
922
// recent block hash
922
923
tx.add ( *first.bhash_ ); // recent block hash
923
924
924
925
// instructions section
925
- tx.add_len ( n ); // n instruction(s)
926
+ tx.add_len ( n + 1 ); // 1 compute limit instruction, n upd_price instruction(s)
927
+
928
+ // Set compute limit
929
+ tx.add ( (uint8_t )( n + 3 ) ); // compute budget program id index in accounts list
930
+ tx.add_len <0 >(); // no accounts
931
+ // compute limit instruction parameters
932
+ tx.add_len <sizeof (uint8_t ) + sizeof (uint32_t )>(); // uint8_t enum variant + uint32_t requested compute units
933
+ tx.add ( (uint8_t ) 2 ); // SetComputeLimit enum variant
934
+ tx.add ( (uint32_t ) CU_BUDGET_PER_IX * n ); // the budget (scaled for number of instructions)
935
+
926
936
for ( unsigned i = 0 ; i < n; ++i ) {
927
937
tx.add ( (uint8_t )( n + 2 ) ); // program_id index
928
938
tx.add_len < 3 >(); // 3 accounts: publish, symbol, sysvar
0 commit comments