Skip to content

Commit 914d2a1

Browse files
flamenco, runtime: implement deprecate_rent_exemption_threshold
1 parent b2c7680 commit 914d2a1

File tree

8 files changed

+389
-3
lines changed

8 files changed

+389
-3
lines changed

src/flamenco/features/fd_features.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#define FD_FEATURE_ACTIVE(_slot, _features, _feature_name) FD_FEATURE_ACTIVE_( _slot, _features, _feature_name )
3030
#define FD_FEATURE_ACTIVE_BANK(_bank, _feature_name) FD_FEATURE_ACTIVE_( fd_bank_slot_get( _bank ), fd_bank_features_query( _bank ), _feature_name )
3131
#define FD_FEATURE_ACTIVE_BANK_OFFSET(_bank, _offset) FD_FEATURE_ACTIVE_OFFSET_( fd_bank_slot_get( _bank ), fd_bank_features_query( _bank ), _offset )
32+
#define FD_FEATURE_JUST_ACTIVATED_BANK(_bank, _feature_name) FD_FEATURE_JUST_ACTIVATED_( fd_bank_slot_get( _bank ), fd_bank_features_query( _bank ), _feature_name )
3233

3334

3435
/* fd_features_t is the current set of enabled feature flags.

src/flamenco/features/fd_features_generated.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1715,6 +1715,12 @@ fd_feature_id_t const ids[] = {
17151715
.name = "increase_cpi_account_info_limit",
17161716
.cleaned_up = {UINT_MAX, UINT_MAX, UINT_MAX} },
17171717

1718+
{ .index = offsetof(fd_features_t, deprecate_rent_exemption_threshold)>>3,
1719+
.id = {"\x0c\xb8\x30\xab\xeb\x2f\x79\xf4\x53\xf9\xb1\x27\x15\xb8\x75\x56\xc4\x82\x1a\x67\xe0\x03\xa8\x07\x5e\x13\xa7\x58\xdd\xf7\xa2\x1d"},
1720+
/* rent6iVy6PDoViPBeJ6k5EJQrkj62h7DPyLbWGHwjrC */
1721+
.name = "deprecate_rent_exemption_threshold",
1722+
.cleaned_up = {UINT_MAX, UINT_MAX, UINT_MAX} },
1723+
17181724
{ .index = ULONG_MAX }
17191725
};
17201726
/* TODO replace this with fd_map_perfect */
@@ -1972,6 +1978,7 @@ fd_feature_id_query( ulong prefix ) {
19721978
case 0x7c4802b8ba3fa849: return &ids[ 248 ];
19731979
case 0xab2a2311ca83eb09: return &ids[ 249 ];
19741980
case 0x55792888a8cf31ef: return &ids[ 250 ];
1981+
case 0xf4792febab30b80c: return &ids[ 251 ];
19751982
default: break;
19761983
}
19771984
return NULL;
@@ -2228,4 +2235,5 @@ FD_STATIC_ASSERT( offsetof( fd_features_t, relax_intrabatch_account_locks
22282235
FD_STATIC_ASSERT( offsetof( fd_features_t, provide_instruction_data_offset_in_vm_r2 )>>3==248UL, layout );
22292236
FD_STATIC_ASSERT( offsetof( fd_features_t, enforce_fixed_fec_set )>>3==249UL, layout );
22302237
FD_STATIC_ASSERT( offsetof( fd_features_t, increase_cpi_account_info_limit )>>3==250UL, layout );
2238+
FD_STATIC_ASSERT( offsetof( fd_features_t, deprecate_rent_exemption_threshold )>>3==251UL, layout );
22312239
FD_STATIC_ASSERT( sizeof( fd_features_t )>>3==FD_FEATURE_ID_CNT, layout );

src/flamenco/features/fd_features_generated.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
#endif
99

1010
/* FEATURE_ID_CNT is the number of features in ids */
11-
#define FD_FEATURE_ID_CNT (251UL)
11+
#define FD_FEATURE_ID_CNT (252UL)
1212

1313
/* Feature set ID calculated from all feature names */
14-
#define FD_FEATURE_SET_ID (1776864602U)
14+
#define FD_FEATURE_SET_ID (2346311975U)
1515

1616
union fd_features {
1717
ulong f[ FD_FEATURE_ID_CNT ];
@@ -267,5 +267,6 @@ union fd_features {
267267
/* 0x7c4802b8ba3fa849 */ ulong provide_instruction_data_offset_in_vm_r2;
268268
/* 0xab2a2311ca83eb09 */ ulong enforce_fixed_fec_set;
269269
/* 0x55792888a8cf31ef */ ulong increase_cpi_account_info_limit;
270+
/* 0xf4792febab30b80c */ ulong deprecate_rent_exemption_threshold;
270271
};
271272
};

src/flamenco/features/feature_map.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,5 +249,6 @@
249249
{"name":"relax_intrabatch_account_locks","pubkey":"ENTRYnPAoT5Swwx73YDGzMp3XnNH1kxacyvLosRHza1i"},
250250
{"name":"provide_instruction_data_offset_in_vm_r2","pubkey":"5xXZc66h4UdB6Yq7FzdBxBiRAFMMScMLwHxk2QZDaNZL"},
251251
{"name":"enforce_fixed_fec_set","pubkey":"fixfecLZYMfkGzwq6NJA11Yw6KYztzXiK9QcL3K78in"},
252-
{"name":"increase_cpi_account_info_limit","pubkey":"H6iVbVaDZgDphcPbcZwc5LoznMPWQfnJ1AM7L1xzqvt5"}
252+
{"name":"increase_cpi_account_info_limit","pubkey":"H6iVbVaDZgDphcPbcZwc5LoznMPWQfnJ1AM7L1xzqvt5"},
253+
{"name":"deprecate_rent_exemption_threshold","pubkey":"rent6iVy6PDoViPBeJ6k5EJQrkj62h7DPyLbWGHwjrC"}
253254
]

src/flamenco/runtime/Local.mk

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,12 @@ ifdef FD_HAS_ATOMIC
6666
ifdef FD_HAS_INT128
6767
$(call add-hdrs,fd_runtime.h fd_runtime_err.h fd_runtime_const.h fd_runtime_stack.h fd_runtime_helpers.h)
6868
$(call add-objs,fd_runtime,fd_flamenco)
69+
ifdef FD_HAS_HOSTED
70+
ifdef FD_HAS_SECP256K1
71+
$(call make-unit-test,test_deprecate_rent_exemption_threshold,test_deprecate_rent_exemption_threshold,fd_flamenco fd_funk fd_ballet fd_util)
72+
$(call run-unit-test,test_deprecate_rent_exemption_threshold,)
73+
endif
74+
endif
6975
endif
7076
endif
7177

src/flamenco/runtime/fd_runtime.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -560,6 +560,28 @@ fd_features_activate( fd_bank_t * bank,
560560
}
561561
}
562562

563+
/* SIMD-0194: deprecate_rent_exemption_threshold
564+
https://github.com/anza-xyz/agave/blob/v3.1.4/runtime/src/bank.rs#L5322-L5329 */
565+
static void
566+
deprecate_rent_exemption_threshold( fd_bank_t * bank,
567+
fd_accdb_user_t * accdb,
568+
fd_funk_txn_xid_t const * xid,
569+
fd_capture_ctx_t * capture_ctx,
570+
fd_funk_t * funk ) {
571+
fd_rent_t rent[1] = {0};
572+
if( FD_UNLIKELY( !fd_sysvar_rent_read( funk, xid, rent ) ) ) {
573+
FD_LOG_CRIT(( "fd_sysvar_rent_read failed" ));
574+
}
575+
rent->lamports_per_uint8_year = FD_SIMD_0194_NEW_LAMPORTS_PER_UINT8_YEAR;
576+
rent->exemption_threshold = FD_SIMD_0194_NEW_RENT_EXEMPTION_THRESHOLD;
577+
578+
/* We don't refresh the sysvar cache here. The cache is refreshed in
579+
fd_sysvar_cache_restore, which is called at the start of every block
580+
in fd_runtime_block_execute_prepare, after this function. */
581+
fd_sysvar_rent_write( bank, accdb, xid, capture_ctx, rent );
582+
fd_bank_rent_set( bank, *rent );
583+
}
584+
563585
/* Starting a new epoch.
564586
New epoch: T
565587
Just ended epoch: T-1
@@ -604,6 +626,10 @@ fd_runtime_process_new_epoch( fd_banks_t * banks,
604626
fd_features_activate( bank, accdb, xid, capture_ctx );
605627
fd_features_restore( bank, funk, xid );
606628

629+
if( FD_UNLIKELY( FD_FEATURE_JUST_ACTIVATED_BANK( bank, deprecate_rent_exemption_threshold ) ) ) {
630+
deprecate_rent_exemption_threshold( bank, accdb, xid, capture_ctx, funk );
631+
}
632+
607633
/* Apply builtin program feature transitions
608634
https://github.com/anza-xyz/agave/blob/v2.1.0/runtime/src/bank.rs#L6621-L6624 */
609635

src/flamenco/runtime/sysvar/fd_sysvar_rent.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55
#include "../../accdb/fd_accdb_user.h"
66
#include "../../types/fd_types.h"
77

8+
/* SIMD-0194: deprecate_rent_exemption_threshold
9+
https://github.com/anza-xyz/agave/blob/v3.1.4/runtime/src/bank.rs#L5322-L5329 */
10+
#define FD_SIMD_0194_NEW_LAMPORTS_PER_UINT8_YEAR (6960UL)
11+
#define FD_SIMD_0194_NEW_RENT_EXEMPTION_THRESHOLD (1.0)
12+
813
FD_PROTOTYPES_BEGIN
914

1015
/* fd_sysvar_rent_init copies the cached rent sysvar stored from

0 commit comments

Comments
 (0)