@@ -462,7 +462,7 @@ load_transaction_account( fd_runtime_t * runtime,
462462 fd_txn_account_t * acct ,
463463 uchar is_writable ,
464464 uchar unknown_acc ,
465- ulong txn_idx ) {
465+ ulong acc_idx ) {
466466
467467 /* Handling the sysvar instructions account explictly.
468468 https://github.com/anza-xyz/agave/blob/v2.3.1/svm/src/account_loader.rs#L817-L824 */
@@ -471,7 +471,7 @@ load_transaction_account( fd_runtime_t * runtime,
471471 constructed by the SVM and modified within each transaction's
472472 instruction execution only, so it incurs a loaded size cost
473473 of 0. */
474- fd_sysvar_instructions_serialize_account ( txn_in , txn_out , (fd_instr_info_t const * )runtime -> instr .infos , TXN ( txn_in -> txn )-> instr_cnt , txn_idx );
474+ fd_sysvar_instructions_serialize_account ( runtime , txn_in , txn_out , (fd_instr_info_t const * )runtime -> instr .infos , TXN ( txn_in -> txn )-> instr_cnt , acc_idx );
475475 return 0UL ;
476476 }
477477
@@ -490,7 +490,8 @@ load_transaction_account( fd_runtime_t * runtime,
490490
491491 /* https://github.com/anza-xyz/agave/blob/v2.3.1/svm/src/account_loader.rs#L828-L835 */
492492 if ( is_writable ) {
493- acct -> starting_lamports = fd_txn_account_get_lamports ( acct ); /* TODO: why do we do this everywhere? */
493+ runtime -> accounts .starting_lamports [acc_idx ] = fd_txn_account_get_lamports ( acct );
494+ runtime -> accounts .starting_dlen [acc_idx ] = fd_txn_account_get_data_len ( acct );
494495 }
495496 return fd_ulong_sat_add ( base_account_size , fd_txn_account_get_data_len ( acct ) );
496497 }
@@ -1069,7 +1070,8 @@ fd_executor_validate_transaction_fee_payer( fd_runtime_t * runtime,
10691070 fd_executor_create_rollback_fee_payer_account ( runtime , bank , txn_in , txn_out , total_fee );
10701071
10711072 /* Set the starting lamports (to avoid unbalanced lamports issues in instruction execution) */
1072- fee_payer_rec -> starting_lamports = fd_txn_account_get_lamports ( fee_payer_rec ); /* TODO: why do we do this everywhere? */
1073+ runtime -> accounts .starting_lamports [FD_FEE_PAYER_TXN_IDX ] = fd_txn_account_get_lamports ( fee_payer_rec );
1074+ runtime -> accounts .starting_dlen [FD_FEE_PAYER_TXN_IDX ] = fd_txn_account_get_data_len ( fee_payer_rec );
10731075
10741076 txn_out -> details .execution_fee = execution_fee ;
10751077 txn_out -> details .priority_fee = priority_fee ;
@@ -1562,7 +1564,7 @@ fd_executor_setup_executable_account( fd_runtime_t * runtime,
15621564 account will not exist within the executable accounts list. */
15631565 fd_pubkey_t * programdata_acc = & program_loader_state -> inner .program .programdata_address ;
15641566 fd_funk_txn_xid_t xid = { .ul = { fd_bank_slot_get ( bank ), bank -> idx } };
1565- if ( FD_LIKELY ( fd_txn_account_init_from_funk_readonly ( & runtime -> executable . accounts [ * executable_idx ],
1567+ if ( FD_LIKELY ( fd_txn_account_init_from_funk_readonly ( & runtime -> accounts . executables [ * executable_idx ],
15661568 programdata_acc ,
15671569 runtime -> funk ,
15681570 & xid )== 0 ) ) {
@@ -1601,7 +1603,7 @@ fd_executor_setup_accounts_for_txn( fd_runtime_t * runtime,
16011603# endif
16021604
16031605 txn_out -> accounts .nonce_idx_in_txn = ULONG_MAX ;
1604- runtime -> executable . cnt = executable_idx ;
1606+ runtime -> accounts . executable_cnt = executable_idx ;
16051607
16061608 /* Set up instr infos from the txn descriptor. No Agave equivalent to this function. */
16071609 fd_executor_setup_instr_infos_from_txn_instrs ( runtime , bank , txn_in , txn_out );
@@ -1657,11 +1659,12 @@ fd_execute_txn( fd_runtime_t * runtime,
16571659
16581660 /* TODO: This function needs to be split out of fd_execute_txn and be placed
16591661 into the replay tile once it is implemented. */
1660- return fd_executor_txn_check ( bank , txn_out );
1662+ return fd_executor_txn_check ( runtime , bank , txn_out );
16611663}
16621664
16631665int
1664- fd_executor_txn_check ( fd_bank_t * bank ,
1666+ fd_executor_txn_check ( fd_runtime_t * runtime ,
1667+ fd_bank_t * bank ,
16651668 fd_txn_out_t * txn_out ) {
16661669 fd_rent_t const * rent = fd_bank_rent_query ( bank );
16671670
@@ -1671,9 +1674,12 @@ fd_executor_txn_check( fd_bank_t * bank,
16711674 ulong ending_lamports_l = 0 ;
16721675 ulong ending_lamports_h = 0 ;
16731676
1677+
16741678 /* https://github.com/anza-xyz/agave/blob/b2c388d6cbff9b765d574bbb83a4378a1fc8af32/svm/src/account_rent_state.rs#L63 */
16751679 for ( ulong idx = 0 ; idx < txn_out -> accounts .accounts_cnt ; idx ++ ) {
16761680 fd_txn_account_t * b = & txn_out -> accounts .accounts [idx ];
1681+ ulong starting_lamports = runtime -> accounts .starting_lamports [idx ];
1682+ ulong starting_dlen = runtime -> accounts .starting_dlen [idx ];
16771683
16781684 // Was this account written to?
16791685 /* TODO: Clean this logic up... lots of redundant checks with our newer account loading model.
@@ -1697,41 +1703,41 @@ fd_executor_txn_check( fd_bank_t * bank,
16971703 // no-op
16981704 } else {
16991705 /* https://github.com/anza-xyz/agave/blob/b2c388d6cbff9b765d574bbb83a4378a1fc8af32/svm/src/account_rent_state.rs#L45-L59 */
1700- uchar before_uninitialized = b -> starting_dlen == ULONG_MAX || b -> starting_lamports == 0 ;
1701- uchar before_rent_exempt = b -> starting_dlen != ULONG_MAX && b -> starting_lamports >= fd_rent_exempt_minimum_balance ( rent , b -> starting_dlen );
1706+ uchar before_uninitialized = starting_dlen == ULONG_MAX || starting_lamports == 0 ;
1707+ uchar before_rent_exempt = starting_dlen != ULONG_MAX && starting_lamports >= fd_rent_exempt_minimum_balance ( rent , starting_dlen );
17021708
17031709 /* https://github.com/anza-xyz/agave/blob/b2c388d6cbff9b765d574bbb83a4378a1fc8af32/svm/src/account_rent_state.rs#L50 */
17041710 if ( before_uninitialized || before_rent_exempt ) {
17051711 FD_LOG_DEBUG (( "Rent exempt error for %s Curr len %lu Starting len %lu Curr lamports %lu Starting lamports %lu Curr exempt %lu Starting exempt %lu" ,
17061712 FD_BASE58_ENC_32_ALLOCA ( b -> pubkey -> uc ),
17071713 fd_txn_account_get_data_len ( b ),
1708- b -> starting_dlen ,
1714+ starting_dlen ,
17091715 fd_txn_account_get_lamports ( b ),
1710- b -> starting_lamports ,
1716+ starting_lamports ,
17111717 fd_rent_exempt_minimum_balance ( rent , fd_txn_account_get_data_len ( b ) ),
1712- fd_rent_exempt_minimum_balance ( rent , b -> starting_dlen ) ));
1718+ fd_rent_exempt_minimum_balance ( rent , starting_dlen ) ));
17131719 /* https://github.com/anza-xyz/agave/blob/b2c388d6cbff9b765d574bbb83a4378a1fc8af32/svm/src/account_rent_state.rs#L104 */
17141720 return FD_RUNTIME_TXN_ERR_INSUFFICIENT_FUNDS_FOR_RENT ;
17151721 /* https://github.com/anza-xyz/agave/blob/b2c388d6cbff9b765d574bbb83a4378a1fc8af32/svm/src/account_rent_state.rs#L56 */
1716- } else if ( (fd_txn_account_get_data_len ( b ) == b -> starting_dlen ) && fd_txn_account_get_lamports ( b ) <= b -> starting_lamports ) {
1722+ } else if ( (fd_txn_account_get_data_len ( b ) == starting_dlen ) && fd_txn_account_get_lamports ( b ) <= starting_lamports ) {
17171723 // no-op
17181724 } else {
17191725 FD_LOG_DEBUG (( "Rent exempt error for %s Curr len %lu Starting len %lu Curr lamports %lu Starting lamports %lu Curr exempt %lu Starting exempt %lu" ,
17201726 FD_BASE58_ENC_32_ALLOCA ( b -> pubkey -> uc ),
17211727 fd_txn_account_get_data_len ( b ),
1722- b -> starting_dlen ,
1728+ starting_dlen ,
17231729 fd_txn_account_get_lamports ( b ),
1724- b -> starting_lamports ,
1730+ starting_lamports ,
17251731 fd_rent_exempt_minimum_balance ( rent , fd_txn_account_get_data_len ( b ) ),
1726- fd_rent_exempt_minimum_balance ( rent , b -> starting_dlen ) ));
1732+ fd_rent_exempt_minimum_balance ( rent , starting_dlen ) ));
17271733 /* https://github.com/anza-xyz/agave/blob/b2c388d6cbff9b765d574bbb83a4378a1fc8af32/svm/src/account_rent_state.rs#L104 */
17281734 return FD_RUNTIME_TXN_ERR_INSUFFICIENT_FUNDS_FOR_RENT ;
17291735 }
17301736 }
17311737 }
17321738
1733- if ( b -> starting_lamports != ULONG_MAX ) {
1734- fd_uwide_inc ( & starting_lamports_h , & starting_lamports_l , starting_lamports_h , starting_lamports_l , b -> starting_lamports );
1739+ if ( starting_lamports != ULONG_MAX ) {
1740+ fd_uwide_inc ( & starting_lamports_h , & starting_lamports_l , starting_lamports_h , starting_lamports_l , starting_lamports );
17351741 }
17361742 }
17371743 }
0 commit comments