44fd_borrowed_account_get_data_mut ( fd_borrowed_account_t * borrowed_acct ,
55 uchar * * data_out ,
66 ulong * dlen_out ) {
7- fd_txn_account_t * acct = borrowed_acct -> acct ;
87
98 /* https://github.com/anza-xyz/agave/blob/v2.1.14/sdk/src/transaction_context.rs#L824 */
109 int err ;
@@ -14,17 +13,16 @@ fd_borrowed_account_get_data_mut( fd_borrowed_account_t * borrowed_acct,
1413 }
1514
1615 if ( data_out != NULL )
17- * data_out = fd_txn_account_get_data_mut ( acct );
16+ * data_out = fd_account_data ( borrowed_acct -> meta );
1817 if ( dlen_out != NULL )
19- * dlen_out = fd_txn_account_get_data_len ( acct ) ;
18+ * dlen_out = borrowed_acct -> meta -> dlen ;
2019
2120 return FD_EXECUTOR_INSTR_SUCCESS ;
2221}
2322
2423int
2524fd_borrowed_account_set_owner ( fd_borrowed_account_t * borrowed_acct ,
2625 fd_pubkey_t const * owner ) {
27- fd_txn_account_t * acct = borrowed_acct -> acct ;
2826
2927 /* Only the owner can assign a new owner
3028 https://github.com/anza-xyz/agave/blob/v2.1.14/sdk/src/transaction_context.rs#L741 */
@@ -46,15 +44,15 @@ fd_borrowed_account_set_owner( fd_borrowed_account_t * borrowed_acct,
4644
4745 /* Don't copy the account if the owner does not change
4846 https://github.com/anza-xyz/agave/blob/v2.1.14/sdk/src/transaction_context.rs#L757 */
49- if ( !memcmp ( fd_txn_account_get_owner ( acct ) , owner , sizeof ( fd_pubkey_t ) ) ) {
47+ if ( !memcmp ( borrowed_acct -> meta -> owner , owner , sizeof (fd_pubkey_t ) ) ) {
5048 return FD_EXECUTOR_INSTR_SUCCESS ;
5149 }
5250
5351 /* Agave self.touch() is a no-op */
5452
5553 /* Copy into owner
5654 https://github.com/anza-xyz/agave/blob/v2.1.14/sdk/src/transaction_context.rs#L761 */
57- fd_txn_account_set_owner ( acct , owner );
55+ fd_memcpy ( borrowed_acct -> meta -> owner , owner , sizeof ( fd_pubkey_t ) );
5856 return FD_EXECUTOR_INSTR_SUCCESS ;
5957}
6058
@@ -63,12 +61,11 @@ fd_borrowed_account_set_owner( fd_borrowed_account_t * borrowed_acct,
6361int
6462fd_borrowed_account_set_lamports ( fd_borrowed_account_t * borrowed_acct ,
6563 ulong lamports ) {
66- fd_txn_account_t * acct = borrowed_acct -> acct ;
6764
6865 /* An account not owned by the program cannot have its blanace decrease
6966 https://github.com/anza-xyz/agave/blob/v2.1.14/sdk/src/transaction_context.rs#L775 */
7067 if ( FD_UNLIKELY ( (!fd_borrowed_account_is_owned_by_current_program ( borrowed_acct )) &&
71- (lamports < fd_txn_account_get_lamports ( acct ) ) ) ) {
68+ (lamports < borrowed_acct -> meta -> lamports ) ) ) {
7269 return FD_EXECUTOR_INSTR_ERR_EXTERNAL_ACCOUNT_LAMPORT_SPEND ;
7370 }
7471
@@ -80,21 +77,20 @@ fd_borrowed_account_set_lamports( fd_borrowed_account_t * borrowed_acct,
8077
8178 /* Don't copy the account if the lamports do not change
8279 https://github.com/anza-xyz/agave/blob/v2.1.14/sdk/src/transaction_context.rs#L787 */
83- if ( fd_txn_account_get_lamports ( acct ) == lamports ) {
80+ if ( borrowed_acct -> meta -> lamports == lamports ) {
8481 return FD_EXECUTOR_INSTR_SUCCESS ;
8582 }
8683
8784 /* Agave self.touch() is a no-op */
8885
89- fd_txn_account_set_lamports ( acct , lamports ) ;
86+ borrowed_acct -> meta -> lamports = lamports ;
9087 return FD_EXECUTOR_INSTR_SUCCESS ;
9188}
9289
9390int
9491fd_borrowed_account_set_data_from_slice ( fd_borrowed_account_t * borrowed_acct ,
9592 uchar const * data ,
9693 ulong data_sz ) {
97- fd_txn_account_t * acct = borrowed_acct -> acct ;
9894
9995 /* https://github.com/anza-xyz/agave/blob/v2.1.14/sdk/src/transaction_context.rs#L865 */
10096 int err ;
@@ -115,16 +111,16 @@ fd_borrowed_account_set_data_from_slice( fd_borrowed_account_t * borrowed_acct,
115111 }
116112
117113 /* AccountSharedData::set_data_from_slice() */
118- fd_txn_account_set_data ( acct , data , data_sz );
114+ borrowed_acct -> meta -> dlen = (uint )data_sz ;
115+ fd_memcpy ( fd_account_data ( borrowed_acct -> meta ), data , data_sz );
119116
120117 return FD_EXECUTOR_INSTR_SUCCESS ;
121118}
122119
123120int
124121fd_borrowed_account_set_data_length ( fd_borrowed_account_t * borrowed_acct ,
125122 ulong new_len ) {
126- fd_txn_account_t * acct = borrowed_acct -> acct ;
127- int err = FD_EXECUTOR_INSTR_SUCCESS ;
123+ int err = FD_EXECUTOR_INSTR_SUCCESS ;
128124
129125 /* https://github.com/anza-xyz/agave/blob/v2.1.14/sdk/src/transaction_context.rs#L883 */
130126 if ( FD_UNLIKELY ( !fd_borrowed_account_can_data_be_resized ( borrowed_acct , new_len , & err ) ) ) {
@@ -136,7 +132,7 @@ fd_borrowed_account_set_data_length( fd_borrowed_account_t * borrowed_acct,
136132 return err ;
137133 }
138134
139- ulong old_len = fd_txn_account_get_data_len ( acct ) ;
135+ ulong old_len = borrowed_acct -> meta -> dlen ;
140136
141137 /* Don't copy the account if the length does not change
142138 https://github.com/anza-xyz/agave/blob/v2.1.14/sdk/src/transaction_context.rs#L886 */
@@ -153,19 +149,18 @@ fd_borrowed_account_set_data_length( fd_borrowed_account_t * borrowed_acct,
153149
154150 /* Resize the account
155151 https://github.com/anza-xyz/agave/blob/v2.1.14/sdk/src/transaction_context.rs#L891 */
156- fd_txn_account_resize ( acct , new_len );
152+ fd_account_meta_resize ( borrowed_acct -> meta , new_len );
153+
157154 return FD_EXECUTOR_INSTR_SUCCESS ;
158155}
159156
160157int
161158fd_borrowed_account_set_executable ( fd_borrowed_account_t * borrowed_acct ,
162159 int is_executable ) {
163- fd_txn_account_t * acct = borrowed_acct -> acct ;
164-
165160 /* To become executable an account must be rent exempt
166161 https://github.com/anza-xyz/agave/blob/v2.1.14/sdk/src/transaction_context.rs#L1003-L1006 */
167162 fd_rent_t const * rent = fd_bank_rent_query ( borrowed_acct -> instr_ctx -> bank );
168- if ( FD_UNLIKELY ( fd_txn_account_get_lamports ( acct ) < fd_rent_exempt_minimum_balance ( rent , fd_txn_account_get_data_len ( acct ) ) ) ) {
163+ if ( FD_UNLIKELY ( borrowed_acct -> meta -> lamports < fd_rent_exempt_minimum_balance ( rent , borrowed_acct -> meta -> dlen ) ) ) {
169164 return FD_EXECUTOR_INSTR_ERR_EXECUTABLE_ACCOUNT_NOT_RENT_EXEMPT ;
170165 }
171166
@@ -190,7 +185,7 @@ fd_borrowed_account_set_executable( fd_borrowed_account_t * borrowed_acct,
190185 /* Agave self.touch() is a no-op */
191186
192187 /* https://github.com/anza-xyz/agave/blob/v2.1.14/sdk/src/transaction_context.rs#L1027 */
193- fd_txn_account_set_executable ( acct , is_executable ) ;
188+ borrowed_acct -> meta -> executable = !! is_executable ;
194189
195190 return FD_EXECUTOR_INSTR_SUCCESS ;
196191}
@@ -200,8 +195,7 @@ fd_borrowed_account_update_accounts_resize_delta( fd_borrowed_account_t * borrow
200195 ulong new_len ,
201196 int * err ) {
202197 fd_exec_instr_ctx_t const * instr_ctx = borrowed_acct -> instr_ctx ;
203- fd_txn_account_t * acct = borrowed_acct -> acct ;
204- ulong size_delta = fd_ulong_sat_sub ( new_len , fd_txn_account_get_data_len ( acct ) );
198+ ulong size_delta = fd_ulong_sat_sub ( new_len , borrowed_acct -> meta -> dlen );
205199
206200 /* TODO: The size delta should never exceed the value of ULONG_MAX so this
207201 could be replaced with a normal addition. However to match execution with
@@ -215,11 +209,10 @@ int
215209fd_borrowed_account_can_data_be_resized ( fd_borrowed_account_t const * borrowed_acct ,
216210 ulong new_length ,
217211 int * err ) {
218- fd_txn_account_t * acct = borrowed_acct -> acct ;
219212
220213 /* Only the owner can change the length of the data
221214 https://github.com/anza-xyz/agave/blob/v2.1.14/sdk/src/transaction_context.rs#L1095 */
222- if ( FD_UNLIKELY ( (fd_txn_account_get_data_len ( acct ) != new_length ) &
215+ if ( FD_UNLIKELY ( (borrowed_acct -> meta -> dlen != new_length ) &
223216 (!fd_borrowed_account_is_owned_by_current_program ( borrowed_acct )) ) ) {
224217 * err = FD_EXECUTOR_INSTR_ERR_ACC_DATA_SIZE_CHANGED ;
225218 return 0 ;
@@ -234,7 +227,7 @@ fd_borrowed_account_can_data_be_resized( fd_borrowed_account_t const * borrowed_
234227
235228 /* The resize can not exceed the per-transaction maximum
236229 https://github.com/anza-xyz/agave/blob/v2.1.14/sdk/src/transaction_context.rs#L1104-L1108 */
237- ulong length_delta = fd_ulong_sat_sub ( new_length , fd_txn_account_get_data_len ( acct ) );
230+ ulong length_delta = fd_ulong_sat_sub ( new_length , borrowed_acct -> meta -> dlen );
238231 ulong new_accounts_resize_delta = fd_ulong_sat_add ( borrowed_acct -> instr_ctx -> txn_out -> details .accounts_resize_delta , length_delta );
239232 if ( FD_UNLIKELY ( new_accounts_resize_delta > MAX_PERMITTED_ACCOUNT_DATA_ALLOCS_PER_TXN ) ) {
240233 * err = FD_EXECUTOR_INSTR_ERR_MAX_ACCS_DATA_ALLOCS_EXCEEDED ;
0 commit comments