Skip to content

Commit d5446c8

Browse files
committed
flamenco: use correct loaded accounts size for txn loading failures
1 parent 20dec15 commit d5446c8

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

src/flamenco/runtime/fd_runtime.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1795,6 +1795,25 @@ fd_runtime_pre_execute_check( fd_execute_txn_task_info_t * task_info,
17951795
https://github.com/anza-xyz/agave/blob/v2.1.6/svm/src/transaction_processor.rs#L341-L357 */
17961796
task_info->txn->flags |= FD_TXN_P_FLAGS_FEES_ONLY;
17971797
task_info->exec_res = err;
1798+
1799+
/* If the transaction fails to load, the "rollback" accounts will include one of the following:
1800+
1. Nonce account only
1801+
2. Fee payer only
1802+
3. Nonce account + fee payer
1803+
1804+
Because the cost tracker uses the loaded account data size in block cost calculations, we need to
1805+
make sure our calculated loaded accounts data size is conformant with Agave's.
1806+
https://github.com/anza-xyz/agave/blob/v2.1.14/runtime/src/bank.rs#L4116 */
1807+
task_info->txn_ctx->loaded_accounts_data_size = 0UL;
1808+
1809+
/* This branch checks for case 3 - if the nonce account is present in the transaction and is not the fee
1810+
payer, then we add the dlen of the nonce account. */
1811+
if( task_info->txn_ctx->nonce_account_idx_in_txn!=ULONG_MAX &&
1812+
task_info->txn_ctx->nonce_account_idx_in_txn!=FD_FEE_PAYER_TXN_IDX ) {
1813+
task_info->txn_ctx->loaded_accounts_data_size += task_info->txn_ctx->rollback_nonce_account->vt->get_data_len( task_info->txn_ctx->rollback_nonce_account );
1814+
}
1815+
/* We should always add the dlen of the fee payer right after, since that is guaranteed to not have been added by the above branch. */
1816+
task_info->txn_ctx->loaded_accounts_data_size += task_info->txn_ctx->accounts[FD_FEE_PAYER_TXN_IDX].vt->get_data_len( &task_info->txn_ctx->accounts[FD_FEE_PAYER_TXN_IDX] );
17981817
} else {
17991818
task_info->txn->flags = 0U;
18001819
task_info->exec_res = err;

src/flamenco/runtime/tests/run_ledger_tests_all.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,4 @@ src/flamenco/runtime/tests/run_ledger_test.sh -l mainnet-327324660 -s snapshot-3
7777
src/flamenco/runtime/tests/run_ledger_test.sh -l devnet-370199634 -s snapshot-370199633-D8mrtzcNV8iNVarHs4mi55QHrCfmzDScYL8BBYXUHAwW.tar.zst -p 60 -y 16 -m 500000 -e 370199634 -c 2.1.14
7878
src/flamenco/runtime/tests/run_ledger_test.sh -l mainnet-330219081 -s snapshot-330219080-2QzJWhxjNohZR2xeeFDkxt2UcdvSKZ8HhXaFdRXwg8iC.tar.zst -p 60 -y 16 -m 2000000 -e 330219086 -c 2.1.14
7979
src/flamenco/runtime/tests/run_ledger_test.sh -l devnet-372721907 -s snapshot-372721906-FtUjok2JfLPwJCRVcioV12M8FWbbJaC91XEJzm4eZy53.tar.zst -p 60 -y 16 -m 2000000 -e 372721910 -c 2.1.14
80+
src/flamenco/runtime/tests/run_ledger_test.sh -l mainnet-331691646 -s snapshot-331691639-3NmZ4rd7nHfn6tuS4E5gUfAwWMoBAQ6K1yntNkyhPbrb.tar.zst -p 60 -y 20 -m 2000000 -e 331691650 -c 2.1.14

0 commit comments

Comments
 (0)