@@ -433,116 +433,26 @@ fd_runtime_get_rent_due( fd_epoch_schedule_t const * schedule,
433
433
return (long )fd_rust_cast_double_to_ulong (years_elapsed * (double )lamports_per_year );
434
434
}
435
435
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
-
515
436
/* fd_runtime_collect_rent_from_account performs rent collection duties.
516
437
Although the Solana runtime prevents the creation of new accounts
517
438
that are subject to rent, some older accounts are still undergo the
518
439
rent collection process. Updates the account's 'rent_epoch' if
519
440
needed. Returns the amount of rent collected. */
520
441
/* https://github.com/anza-xyz/agave/blob/v2.0.10/svm/src/account_loader.rs#L71-96 */
521
442
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 ,
524
444
fd_rent_t const * rent ,
525
445
double slots_per_year ,
526
- fd_features_t * features ,
527
446
fd_txn_account_t * acc ,
528
447
ulong epoch ) {
529
448
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 &&
539
450
fd_runtime_get_rent_due ( schedule ,
540
451
rent ,
541
452
slots_per_year ,
542
453
acc ,
543
454
epoch )== FD_RENT_EXEMPT ) ) {
544
455
acc -> vt -> set_rent_epoch ( acc , FD_RENT_EXEMPT_RENT_EPOCH );
545
- }
546
456
}
547
457
return 0UL ;
548
458
}
0 commit comments