@@ -910,19 +910,29 @@ bool rpc::upd_price::build_tx(
910910 auto & first = *upds[ 0 ];
911911
912912 // 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
914914 tx.add ( *first.pkey_ ); // publish account
915915 for ( unsigned i = 0 ; i < n; ++i ) {
916916 tx.add ( *upds[ i ]->akey_ ); // symbol account
917917 }
918918 tx.add ( *(pub_key*)sysvar_clock ); // sysvar account
919919 tx.add ( *first.gkey_ ); // programid
920+ tx.add ( *(pub_key*)compute_budget_program_id ); // compute budget program id
920921
921922 // recent block hash
922923 tx.add ( *first.bhash_ ); // recent block hash
923924
924925 // 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+
926936 for ( unsigned i = 0 ; i < n; ++i ) {
927937 tx.add ( (uint8_t )( n + 2 ) ); // program_id index
928938 tx.add_len < 3 >(); // 3 accounts: publish, symbol, sysvar
0 commit comments