Skip to content

Commit 1db25fb

Browse files
flamenco: clean up disable_rent_fees_collection
1 parent 21a7f17 commit 1db25fb

File tree

3 files changed

+5
-101
lines changed

3 files changed

+5
-101
lines changed

src/flamenco/runtime/fd_executor.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -465,11 +465,9 @@ load_transaction_account( fd_exec_txn_ctx_t * txn_ctx,
465465
https://github.com/anza-xyz/agave/blob/v2.2.0/svm/src/account_loader.rs#L552-L565 */
466466
if( FD_LIKELY( !unknown_acc ) ) {
467467
if( is_writable ) {
468-
txn_ctx->collected_rent += fd_runtime_collect_rent_from_account( txn_ctx->slot,
469-
fd_bank_epoch_schedule_query( txn_ctx->bank ),
468+
txn_ctx->collected_rent += fd_runtime_collect_rent_from_account( fd_bank_epoch_schedule_query( txn_ctx->bank ),
470469
fd_bank_rent_query( txn_ctx->bank ),
471470
fd_bank_slots_per_year_get( txn_ctx->bank ),
472-
&txn_ctx->features,
473471
acct,
474472
epoch );
475473
acct->starting_lamports = acct->vt->get_lamports( acct ); /* TODO: why do we do this everywhere? */
@@ -843,11 +841,9 @@ fd_executor_validate_transaction_fee_payer( fd_exec_txn_ctx_t * txn_ctx ) {
843841
/* Collect rent from the fee payer
844842
https://github.com/anza-xyz/agave/blob/v2.2.13/svm/src/transaction_processor.rs#L583-L589 */
845843
ulong epoch = fd_slot_to_epoch( fd_bank_epoch_schedule_query( txn_ctx->bank ), txn_ctx->slot, NULL );
846-
txn_ctx->collected_rent += fd_runtime_collect_rent_from_account( txn_ctx->slot,
847-
fd_bank_epoch_schedule_query( txn_ctx->bank ),
844+
txn_ctx->collected_rent += fd_runtime_collect_rent_from_account( fd_bank_epoch_schedule_query( txn_ctx->bank ),
848845
fd_bank_rent_query( txn_ctx->bank ),
849846
fd_bank_slots_per_year_get( txn_ctx->bank ),
850-
&txn_ctx->features,
851847
fee_payer_rec,
852848
epoch );
853849

src/flamenco/runtime/fd_runtime.c

Lines changed: 2 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -433,116 +433,26 @@ fd_runtime_get_rent_due( fd_epoch_schedule_t const * schedule,
433433
return (long)fd_rust_cast_double_to_ulong(years_elapsed * (double)lamports_per_year);
434434
}
435435

436-
/* https://github.com/anza-xyz/agave/blob/v2.0.10/sdk/src/rent_collector.rs#L117-149 */
437-
/* Collect rent from an account. Returns the amount of rent collected. */
438-
static ulong
439-
fd_runtime_collect_from_existing_account( ulong slot,
440-
fd_epoch_schedule_t const * schedule,
441-
fd_rent_t const * rent,
442-
double slots_per_year,
443-
fd_txn_account_t * acc,
444-
ulong epoch ) {
445-
ulong collected_rent = 0UL;
446-
#define NO_RENT_COLLECTION_NOW (-1)
447-
#define EXEMPT (-2)
448-
#define COLLECT_RENT (-3)
449-
450-
/* An account must be hashed regardless of if rent is collected from it. */
451-
acc->vt->set_slot( acc, slot );
452-
453-
/* Inlining calculate_rent_result
454-
https://github.com/anza-xyz/agave/blob/v2.0.10/sdk/src/rent_collector.rs#L153-184 */
455-
int calculate_rent_result = COLLECT_RENT;
456-
457-
/* RentResult::NoRentCollectionNow */
458-
if( FD_LIKELY( acc->vt->get_rent_epoch( acc )==FD_RENT_EXEMPT_RENT_EPOCH || acc->vt->get_rent_epoch( acc )>epoch ) ) {
459-
calculate_rent_result = NO_RENT_COLLECTION_NOW;
460-
goto rent_calculation;
461-
}
462-
/* RentResult::Exempt */
463-
/* Inlining should_collect_rent() */
464-
int should_collect_rent = !( acc->vt->is_executable( acc ) ||
465-
!memcmp( acc->pubkey, &fd_sysvar_incinerator_id, sizeof(fd_pubkey_t) ) );
466-
if( !should_collect_rent ) {
467-
calculate_rent_result = EXEMPT;
468-
goto rent_calculation;
469-
}
470-
471-
/* https://github.com/anza-xyz/agave/blob/v2.0.10/sdk/src/rent_collector.rs#L167-180 */
472-
long rent_due = fd_runtime_get_rent_due( schedule,
473-
rent,
474-
slots_per_year,
475-
acc,
476-
epoch );
477-
if( rent_due==FD_RENT_EXEMPT ) {
478-
calculate_rent_result = EXEMPT;
479-
} else if( rent_due==0L ) {
480-
calculate_rent_result = NO_RENT_COLLECTION_NOW;
481-
} else {
482-
calculate_rent_result = COLLECT_RENT;
483-
}
484-
485-
rent_calculation:
486-
switch( calculate_rent_result ) {
487-
case EXEMPT:
488-
acc->vt->set_rent_epoch( acc, FD_RENT_EXEMPT_RENT_EPOCH );
489-
break;
490-
case NO_RENT_COLLECTION_NOW:
491-
break;
492-
case COLLECT_RENT:
493-
if( FD_UNLIKELY( (ulong)rent_due>=acc->vt->get_lamports( acc ) ) ) {
494-
/* Reclaim account */
495-
collected_rent += (ulong)acc->vt->get_lamports( acc );
496-
acc->vt->set_lamports( acc, 0UL );
497-
acc->vt->set_data_len( acc, 0UL );
498-
acc->vt->clear_owner( acc );
499-
} else {
500-
collected_rent += (ulong)rent_due;
501-
/* It's ok to not check the overflow error because
502-
the rent_due value will always be less than the account's lamports here */
503-
acc->vt->checked_sub_lamports( acc, (ulong)rent_due );
504-
acc->vt->set_rent_epoch( acc, epoch+1UL );
505-
}
506-
}
507-
508-
return collected_rent;
509-
510-
#undef NO_RENT_COLLECTION_NOW
511-
#undef EXEMPT
512-
#undef COLLECT_RENT
513-
}
514-
515436
/* fd_runtime_collect_rent_from_account performs rent collection duties.
516437
Although the Solana runtime prevents the creation of new accounts
517438
that are subject to rent, some older accounts are still undergo the
518439
rent collection process. Updates the account's 'rent_epoch' if
519440
needed. Returns the amount of rent collected. */
520441
/* https://github.com/anza-xyz/agave/blob/v2.0.10/svm/src/account_loader.rs#L71-96 */
521442
ulong
522-
fd_runtime_collect_rent_from_account( ulong slot,
523-
fd_epoch_schedule_t const * schedule,
443+
fd_runtime_collect_rent_from_account( fd_epoch_schedule_t const * schedule,
524444
fd_rent_t const * rent,
525445
double slots_per_year,
526-
fd_features_t * features,
527446
fd_txn_account_t * acc,
528447
ulong epoch ) {
529448

530-
if( !FD_FEATURE_ACTIVE( slot, features, disable_rent_fees_collection ) ) {
531-
return fd_runtime_collect_from_existing_account( slot,
532-
schedule,
533-
rent,
534-
slots_per_year,
535-
acc,
536-
epoch );
537-
} else {
538-
if( FD_UNLIKELY( acc->vt->get_rent_epoch( acc )!=FD_RENT_EXEMPT_RENT_EPOCH &&
449+
if( FD_UNLIKELY( acc->vt->get_rent_epoch( acc )!=FD_RENT_EXEMPT_RENT_EPOCH &&
539450
fd_runtime_get_rent_due( schedule,
540451
rent,
541452
slots_per_year,
542453
acc,
543454
epoch )==FD_RENT_EXEMPT ) ) {
544455
acc->vt->set_rent_epoch( acc, FD_RENT_EXEMPT_RENT_EPOCH );
545-
}
546456
}
547457
return 0UL;
548458
}

src/flamenco/runtime/fd_runtime.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -319,11 +319,9 @@ fd_runtime_update_leaders( fd_bank_t * bank,
319319
/* TODO: Invoked by fd_executor: layering violation. Rent logic is deprecated
320320
and will be torn out entirely very soon. */
321321
ulong
322-
fd_runtime_collect_rent_from_account( ulong slot,
323-
fd_epoch_schedule_t const * schedule,
322+
fd_runtime_collect_rent_from_account( fd_epoch_schedule_t const * schedule,
324323
fd_rent_t const * rent,
325324
double slots_per_year,
326-
fd_features_t * features,
327325
fd_txn_account_t * acc,
328326
ulong epoch );
329327

0 commit comments

Comments
 (0)