Skip to content

Commit 5a9f0e1

Browse files
flamenco, runtime: implement deprecate_rent_exemption_threshold
1 parent 3be8509 commit 5a9f0e1

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
@@ -1709,6 +1709,12 @@ fd_feature_id_t const ids[] = {
17091709
.name = "enforce_fixed_fec_set",
17101710
.cleaned_up = {UINT_MAX, UINT_MAX, UINT_MAX} },
17111711

1712+
{ .index = offsetof(fd_features_t, deprecate_rent_exemption_threshold)>>3,
1713+
.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"},
1714+
/* rent6iVy6PDoViPBeJ6k5EJQrkj62h7DPyLbWGHwjrC */
1715+
.name = "deprecate_rent_exemption_threshold",
1716+
.cleaned_up = {UINT_MAX, UINT_MAX, UINT_MAX} },
1717+
17121718
{ .index = ULONG_MAX }
17131719
};
17141720
/* TODO replace this with fd_map_perfect */
@@ -1965,6 +1971,7 @@ fd_feature_id_query( ulong prefix ) {
19651971
case 0x866094bbfe00a7c6: return &ids[ 247 ];
19661972
case 0x7c4802b8ba3fa849: return &ids[ 248 ];
19671973
case 0xab2a2311ca83eb09: return &ids[ 249 ];
1974+
case 0xf4792febab30b80c: return &ids[ 250 ];
19681975
default: break;
19691976
}
19701977
return NULL;
@@ -2220,4 +2227,5 @@ FD_STATIC_ASSERT( offsetof( fd_features_t, poseidon_enforce_padding
22202227
FD_STATIC_ASSERT( offsetof( fd_features_t, relax_intrabatch_account_locks )>>3==247UL, layout );
22212228
FD_STATIC_ASSERT( offsetof( fd_features_t, provide_instruction_data_offset_in_vm_r2 )>>3==248UL, layout );
22222229
FD_STATIC_ASSERT( offsetof( fd_features_t, enforce_fixed_fec_set )>>3==249UL, layout );
2230+
FD_STATIC_ASSERT( offsetof( fd_features_t, deprecate_rent_exemption_threshold )>>3==250UL, layout );
22232231
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 (250UL)
11+
#define FD_FEATURE_ID_CNT (251UL)
1212

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

1616
union fd_features {
1717
ulong f[ FD_FEATURE_ID_CNT ];
@@ -266,5 +266,6 @@ union fd_features {
266266
/* 0x866094bbfe00a7c6 */ ulong relax_intrabatch_account_locks;
267267
/* 0x7c4802b8ba3fa849 */ ulong provide_instruction_data_offset_in_vm_r2;
268268
/* 0xab2a2311ca83eb09 */ ulong enforce_fixed_fec_set;
269+
/* 0xf4792febab30b80c */ ulong deprecate_rent_exemption_threshold;
269270
};
270271
};

src/flamenco/features/feature_map.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,5 +248,6 @@
248248
{"name":"poseidon_enforce_padding","pubkey":"poUdAqRXXsNmfqAZ6UqpjbeYgwBygbfQLEvWSqVhSnb"},
249249
{"name":"relax_intrabatch_account_locks","pubkey":"ENTRYnPAoT5Swwx73YDGzMp3XnNH1kxacyvLosRHza1i"},
250250
{"name":"provide_instruction_data_offset_in_vm_r2","pubkey":"5xXZc66h4UdB6Yq7FzdBxBiRAFMMScMLwHxk2QZDaNZL"},
251-
{"name":"enforce_fixed_fec_set","pubkey":"fixfecLZYMfkGzwq6NJA11Yw6KYztzXiK9QcL3K78in"}
251+
{"name":"enforce_fixed_fec_set","pubkey":"fixfecLZYMfkGzwq6NJA11Yw6KYztzXiK9QcL3K78in"},
252+
{"name":"deprecate_rent_exemption_threshold","pubkey":"rent6iVy6PDoViPBeJ6k5EJQrkj62h7DPyLbWGHwjrC"}
252253
]

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
@@ -556,6 +556,28 @@ fd_features_activate( fd_bank_t * bank,
556556
}
557557
}
558558

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

625+
if( FD_UNLIKELY( FD_FEATURE_JUST_ACTIVATED_BANK( bank, deprecate_rent_exemption_threshold ) ) ) {
626+
deprecate_rent_exemption_threshold( bank, accdb, xid, capture_ctx, funk );
627+
}
628+
603629
/* Apply builtin program feature transitions
604630
https://github.com/anza-xyz/agave/blob/v2.1.0/runtime/src/bank.rs#L6621-L6624 */
605631

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)