Line data Source code
1 : #include "fd_bundle_crank.h"
2 : #include "../../flamenco/runtime/fd_pubkey_utils.h"
3 :
4 : FD_STATIC_ASSERT( sizeof(fd_bundle_crank_tip_payment_config_t)==89UL, config_struct );
5 :
6 : static const fd_bundle_crank_3_t fd_bundle_crank_3_base[1] = {{
7 :
8 : .sig_cnt = 1,
9 : ._sig_cnt = 1,
10 : .ro_signed_cnt = 0,
11 : .ro_unsigned_cnt = 5,
12 : .acct_addr_cnt = 20,
13 :
14 : .system_program = { SYS_PROG_ID },
15 : .compute_budget_program = { COMPUTE_BUDGET_PROG_ID },
16 :
17 : .instr_cnt = 4,
18 : .compute_budget_instruction = {
19 : .prog_id = 15,
20 : .acct_cnt = 0,
21 : .data_sz = 5,
22 : .set_cu_limit = 2,
23 : .cus = 100000U
24 : },
25 :
26 : .init_tip_distribution_acct = {
27 : .prog_id = 19,
28 : .acct_cnt = 5,
29 : .acct_idx = { 9, 13, 17, 0, 18 },
30 : .data_sz = 43,
31 : .ix_discriminator = { FD_BUNDLE_CRANK_DISC_INIT_TIP_DISTR },
32 : },
33 :
34 : .change_tip_receiver = {
35 : .prog_id = 16,
36 : .acct_cnt = 13,
37 : .acct_idx = { 10, 11, 13, 12, 1, 2, 3, 4, 5, 6, 7, 8, 0 },
38 : .data_sz = 8,
39 : .ix_discriminator = { FD_BUNDLE_CRANK_DISC_CHANGE_TIP_RCV }
40 : },
41 :
42 : .change_block_builder = {
43 : .prog_id = 16,
44 : .acct_cnt = 13,
45 : .acct_idx = { 10, 13, 12, 14, 1, 2, 3, 4, 5, 6, 7, 8, 0},
46 : .data_sz = 16,
47 : .ix_discriminator = { FD_BUNDLE_CRANK_DISC_CHANGE_BLK_BLD },
48 : },
49 :
50 : /* Account addresses that depend on the network: */
51 : .tip_payment_accounts = {{ 0 }},
52 : .tip_distribution_program_config = { 0 },
53 : .tip_payment_program_config = { 0 },
54 : .tip_distribution_program = { 0 },
55 : .tip_payment_program = { 0 },
56 :
57 : /* Fields that depend on the validator configuration: */
58 : .authorized_voter = { 0 },
59 : .validator_vote_account = { 0 },
60 : .init_tip_distribution_acct.merkle_root_upload_authority = { 0 },
61 : .init_tip_distribution_acct.commission_bps = 0,
62 : .init_tip_distribution_acct.bump = 0,
63 :
64 : /* Fields that vary each time: */
65 : .old_tip_receiver = { 0 },
66 : .old_block_builder = { 0 },
67 : .new_tip_receiver = { 0 },
68 : .new_block_builder = { 0 },
69 : .change_block_builder.block_builder_commission_pct = 0UL
70 : }};
71 :
72 : static const fd_bundle_crank_2_t fd_bundle_crank_2_base[1] = {{
73 :
74 : .sig_cnt = 1,
75 : ._sig_cnt = 1,
76 : .ro_signed_cnt = 0,
77 : .ro_unsigned_cnt = 2,
78 : .acct_addr_cnt = 17,
79 :
80 : .compute_budget_program = { COMPUTE_BUDGET_PROG_ID },
81 :
82 : .instr_cnt = 3,
83 : .compute_budget_instruction = {
84 : .prog_id = 15,
85 : .acct_cnt = 0,
86 : .data_sz = 5,
87 : .set_cu_limit = 2,
88 : .cus = 80000U
89 : },
90 :
91 : .change_tip_receiver = {
92 : .prog_id = 16,
93 : .acct_cnt = 13,
94 : .acct_idx = { 10, 11, 13, 12, 1, 2, 3, 4, 5, 6, 7, 8, 0 },
95 : .data_sz = 8,
96 : .ix_discriminator = { FD_BUNDLE_CRANK_DISC_CHANGE_TIP_RCV }
97 : },
98 :
99 : .change_block_builder = {
100 : .prog_id = 16,
101 : .acct_cnt = 13,
102 : .acct_idx = { 10, 13, 12, 14, 1, 2, 3, 4, 5, 6, 7, 8, 0},
103 : .data_sz = 16,
104 : .ix_discriminator = { FD_BUNDLE_CRANK_DISC_CHANGE_BLK_BLD },
105 : },
106 :
107 : /* Account addresses that depend on the network: */
108 : .tip_payment_accounts = {{ 0 }},
109 : .tip_distribution_program_config = { 0 },
110 : .tip_payment_program_config = { 0 },
111 : .tip_payment_program = { 0 },
112 :
113 : /* Fields that depend on the validator configuration: */
114 : .authorized_voter = { 0 },
115 :
116 : /* Fields that vary each time: */
117 : .old_tip_receiver = { 0 },
118 : .old_block_builder = { 0 },
119 : .new_tip_receiver = { 0 },
120 : .new_block_builder = { 0 },
121 : .change_block_builder.block_builder_commission_pct = 0UL
122 : }};
123 :
124 : static const fd_acct_addr_t null_addr = { 0 };
125 :
126 : #define MAP_NAME pidx_map
127 306 : #define MAP_T fd_bundle_crank_gen_pidx_t
128 1068 : #define MAP_KEY_T fd_acct_addr_t
129 : #define MAP_MEMOIZE 0
130 : #define MAP_QUERY_OPT 2 /* low hit rate */
131 1404 : #define MAP_LG_SLOT_CNT 5 /* 18 entries, space for 32 */
132 399 : #define MAP_KEY_NULL null_addr
133 : #if FD_HAS_AVX
134 1068 : # define MAP_KEY_INVAL(k) _mm256_testz_si256( wb_ldu( (k).b ), wb_ldu( (k).b ) )
135 : #else
136 : # define MAP_KEY_INVAL(k) MAP_KEY_EQUAL(k, null_addr)
137 : #endif
138 660 : #define MAP_KEY_EQUAL(k0,k1) (!memcmp((k0).b,(k1).b, FD_TXN_ACCT_ADDR_SZ))
139 : #define MAP_KEY_EQUAL_IS_SLOW 1
140 : #define MAP_MEMOIZE 0
141 336 : #define MAP_KEY_HASH(key) ((uint)fd_ulong_hash( fd_ulong_load_8( (key).b ) ))
142 :
143 : #include "../../util/tmpl/fd_map.c"
144 :
145 :
146 540 : #define EXPAND_ARR8(arr, i) arr[(i)], arr[(i)+1], arr[(i)+2], arr[(i)+3], arr[(i)+4], arr[(i)+5], arr[(i)+6], arr[(i)+7],
147 135 : #define EXPAND_ARR32(arr, i) EXPAND_ARR8(arr, (i)) EXPAND_ARR8(arr, (i)+8) EXPAND_ARR8(arr, (i)+16) EXPAND_ARR8(arr, (i)+24)
148 :
149 :
150 :
151 : fd_bundle_crank_gen_t *
152 : fd_bundle_crank_gen_init( void * mem,
153 : fd_acct_addr_t const * tip_distribution_program_addr,
154 : fd_acct_addr_t const * tip_payment_program_addr,
155 : fd_acct_addr_t const * validator_vote_acct_addr,
156 : fd_acct_addr_t const * merkle_root_authority_addr,
157 9 : ulong commission_bps ) {
158 9 : fd_bundle_crank_gen_t * g = (fd_bundle_crank_gen_t *)mem;
159 9 : memcpy( g->crank3, fd_bundle_crank_3_base, sizeof(fd_bundle_crank_3_base) );
160 9 : memcpy( g->crank2, fd_bundle_crank_2_base, sizeof(fd_bundle_crank_2_base) );
161 :
162 9 : g->crank3->init_tip_distribution_acct.commission_bps = (ushort)commission_bps;
163 9 : memcpy( g->crank3->tip_distribution_program, tip_distribution_program_addr, 32UL );
164 9 : memcpy( g->crank3->tip_payment_program, tip_payment_program_addr, 32UL );
165 9 : memcpy( g->crank3->validator_vote_account, validator_vote_acct_addr, 32UL );
166 9 : memcpy( g->crank3->init_tip_distribution_acct.merkle_root_upload_authority, merkle_root_authority_addr, 32UL );
167 :
168 9 : uint cerr[1];
169 9 : do {
170 9 : char seed[13] = "TIP_ACCOUNT_0"; /* Not NUL terminated */
171 9 : uchar * seed_ptr[1] = { (uchar *)seed };
172 9 : ulong seed_len = 13;
173 81 : for( ulong i=0UL; i<8UL; i++ ) {
174 72 : seed[12] = (char)((ulong)'0' + i);
175 72 : uchar out_bump[1];
176 72 : FD_TEST( FD_PUBKEY_SUCCESS==fd_pubkey_find_program_address( (fd_pubkey_t const *)tip_payment_program_addr,
177 72 : 1UL, seed_ptr, &seed_len,
178 72 : (fd_pubkey_t *)g->crank3->tip_payment_accounts[i], out_bump, cerr ) );
179 72 : }
180 9 : } while( 0 );
181 :
182 9 : do {
183 9 : char seed[14] = "CONFIG_ACCOUNT"; /* Not NUL terminated */
184 9 : ulong seed_len = 14;
185 9 : uchar out_bump[1];
186 9 : uchar * seed_ptr[1] = { (uchar *)seed };
187 9 : FD_TEST( FD_PUBKEY_SUCCESS==fd_pubkey_find_program_address( (fd_pubkey_t const *)tip_payment_program_addr,
188 9 : 1UL, seed_ptr, &seed_len,
189 9 : (fd_pubkey_t *)g->crank3->tip_payment_program_config, out_bump, cerr ) );
190 : /* Same seed used for tip distribution config account too */
191 9 : FD_TEST( FD_PUBKEY_SUCCESS==fd_pubkey_find_program_address( (fd_pubkey_t const *)tip_distribution_program_addr,
192 9 : 1UL, seed_ptr, &seed_len,
193 9 : (fd_pubkey_t *)g->crank3->tip_distribution_program_config, out_bump, cerr ) );
194 9 : } while( 0 );
195 :
196 : /* Populate crank2 from crank3 */
197 9 : memcpy( g->crank2->tip_payment_accounts, g->crank3->tip_payment_accounts, 8UL*32UL );
198 9 : memcpy( g->crank2->tip_distribution_program_config, g->crank3->tip_distribution_program_config, 32UL );
199 9 : memcpy( g->crank2->tip_payment_program_config, g->crank3->tip_payment_program_config, 32UL );
200 9 : memcpy( g->crank2->tip_payment_program, g->crank3->tip_payment_program, 32UL );
201 :
202 9 : FD_TEST( sizeof(g->txn3)==fd_txn_parse( (uchar const *)g->crank3, sizeof(g->crank3), g->txn3, NULL ) );
203 9 : FD_TEST( sizeof(g->txn2)==fd_txn_parse( (uchar const *)g->crank2, sizeof(g->crank2), g->txn2, NULL ) );
204 :
205 9 : pidx_map_new( g->map );
206 9 : pidx_map_insert( g->map, (fd_acct_addr_t){{ EXPAND_ARR32( g->crank3->tip_payment_accounts[0], 0 ) }} )->idx= 1UL;
207 9 : pidx_map_insert( g->map, (fd_acct_addr_t){{ EXPAND_ARR32( g->crank3->tip_payment_accounts[1], 0 ) }} )->idx= 2UL;
208 9 : pidx_map_insert( g->map, (fd_acct_addr_t){{ EXPAND_ARR32( g->crank3->tip_payment_accounts[2], 0 ) }} )->idx= 3UL;
209 9 : pidx_map_insert( g->map, (fd_acct_addr_t){{ EXPAND_ARR32( g->crank3->tip_payment_accounts[3], 0 ) }} )->idx= 4UL;
210 9 : pidx_map_insert( g->map, (fd_acct_addr_t){{ EXPAND_ARR32( g->crank3->tip_payment_accounts[4], 0 ) }} )->idx= 5UL;
211 9 : pidx_map_insert( g->map, (fd_acct_addr_t){{ EXPAND_ARR32( g->crank3->tip_payment_accounts[5], 0 ) }} )->idx= 6UL;
212 9 : pidx_map_insert( g->map, (fd_acct_addr_t){{ EXPAND_ARR32( g->crank3->tip_payment_accounts[6], 0 ) }} )->idx= 7UL;
213 9 : pidx_map_insert( g->map, (fd_acct_addr_t){{ EXPAND_ARR32( g->crank3->tip_payment_accounts[7], 0 ) }} )->idx= 8UL;
214 9 : pidx_map_insert( g->map, (fd_acct_addr_t){{ EXPAND_ARR32( g->crank3->tip_distribution_program_config, 0 ) }} )->idx= 9UL;
215 9 : pidx_map_insert( g->map, (fd_acct_addr_t){{ EXPAND_ARR32( g->crank3->tip_payment_program_config, 0 ) }} )->idx=10UL;
216 9 : pidx_map_insert( g->map, (fd_acct_addr_t){{ EXPAND_ARR32( g->crank3->compute_budget_program, 0 ) }} )->idx=15UL;
217 9 : pidx_map_insert( g->map, (fd_acct_addr_t){{ EXPAND_ARR32( g->crank3->tip_payment_program, 0 ) }} )->idx=16UL;
218 9 : pidx_map_insert( g->map, (fd_acct_addr_t){{ EXPAND_ARR32( g->crank3->validator_vote_account, 0 ) }} )->idx=17UL;
219 9 : pidx_map_insert( g->map, (fd_acct_addr_t){{ EXPAND_ARR32( g->crank3->tip_distribution_program, 0 ) }} )->idx=19UL;
220 :
221 9 : g->configured_epoch = ULONG_MAX;
222 9 : return g;
223 9 : }
224 :
225 :
226 : static inline void
227 : fd_bundle_crank_update_epoch( fd_bundle_crank_gen_t * g,
228 9 : ulong epoch ) {
229 9 : struct __attribute__((packed)) {
230 9 : char tip_distr_acct[24];
231 9 : uchar vote_pubkey [32];
232 9 : ulong epoch;
233 9 : } seeds[1] = {{
234 9 : .tip_distr_acct = "TIP_DISTRIBUTION_ACCOUNT",
235 9 : .vote_pubkey = { EXPAND_ARR32( g->crank3->validator_vote_account, 0 ) },
236 9 : .epoch = epoch
237 9 : }};
238 9 : FD_STATIC_ASSERT( sizeof(seeds)==24UL+32UL+8UL, seed_struct );
239 9 : ulong seed_len = sizeof(seeds);
240 9 : uint custom_err[1];
241 :
242 9 : uchar * _seeds[1] = { (uchar *)seeds };
243 :
244 9 : FD_TEST( FD_PUBKEY_SUCCESS==fd_pubkey_find_program_address( (fd_pubkey_t const *)g->crank3->tip_distribution_program,
245 9 : 1UL, _seeds, &seed_len,
246 9 : (fd_pubkey_t *)g->crank3->new_tip_receiver,
247 9 : &(g->crank3->init_tip_distribution_acct.bump), custom_err ) );
248 9 : memcpy( g->crank2->new_tip_receiver, g->crank3->new_tip_receiver, 32UL );
249 9 : g->configured_epoch = epoch;
250 :
251 9 : }
252 :
253 : void
254 : fd_bundle_crank_get_addresses( fd_bundle_crank_gen_t * gen,
255 : ulong epoch,
256 : fd_acct_addr_t * out_tip_payment_config,
257 3 : fd_acct_addr_t * out_tip_receiver ) {
258 3 : if( FD_UNLIKELY( epoch!=gen->configured_epoch ) ) fd_bundle_crank_update_epoch( gen, epoch );
259 3 : memcpy( out_tip_payment_config, gen->crank3->tip_payment_program_config, 32UL );
260 3 : memcpy( out_tip_receiver, gen->crank3->new_tip_receiver, 32UL );
261 3 : }
262 :
263 : ulong
264 : fd_bundle_crank_generate( fd_bundle_crank_gen_t * gen,
265 : fd_bundle_crank_tip_payment_config_t const * old_tip_payment_config,
266 : fd_acct_addr_t const * new_block_builder,
267 : fd_acct_addr_t const * identity,
268 : fd_acct_addr_t const * tip_receiver_owner,
269 : ulong epoch,
270 : ulong block_builder_commission,
271 : uchar * out_payload,
272 36 : fd_txn_t * out_txn ) {
273 :
274 36 : if( FD_UNLIKELY( epoch!=gen->configured_epoch ) ) fd_bundle_crank_update_epoch( gen, epoch );
275 :
276 36 : if( FD_UNLIKELY( old_tip_payment_config->discriminator != 0x82ccfa1ee0aa0c9bUL ) ) {
277 0 : FD_LOG_WARNING(( "Found unexpected tip payment config account discriminator %lx. Refusing to crank bundles.",
278 0 : old_tip_payment_config->discriminator ));
279 0 : return ULONG_MAX;
280 0 : }
281 :
282 36 : int swap3 = !fd_memeq( tip_receiver_owner, gen->crank3->tip_distribution_program, sizeof(fd_acct_addr_t) );
283 :
284 36 : if( FD_LIKELY( fd_memeq( old_tip_payment_config->tip_receiver, gen->crank3->new_tip_receiver, 32UL ) &&
285 36 : fd_memeq( old_tip_payment_config->block_builder, new_block_builder, 32UL ) &&
286 36 : !swap3 &&
287 36 : old_tip_payment_config->commission_pct==block_builder_commission ) ) {
288 : /* Everything configured properly! */
289 6 : return 0UL;
290 6 : }
291 :
292 :
293 30 : if( FD_UNLIKELY( swap3 ) ) {
294 3 : memcpy( gen->crank3->authorized_voter, identity, 32UL );
295 3 : memcpy( gen->crank3->new_block_builder, new_block_builder, 32UL );
296 3 : memcpy( gen->crank3->old_tip_receiver, old_tip_payment_config->tip_receiver, 32UL );
297 3 : memcpy( gen->crank3->old_block_builder, old_tip_payment_config->block_builder, 32UL );
298 3 : gen->crank3->change_block_builder.block_builder_commission_pct = block_builder_commission;
299 27 : } else {
300 27 : memcpy( gen->crank2->authorized_voter, identity, 32UL );
301 27 : memcpy( gen->crank2->new_block_builder, new_block_builder, 32UL );
302 27 : memcpy( gen->crank2->old_tip_receiver, old_tip_payment_config->tip_receiver, 32UL );
303 27 : memcpy( gen->crank2->old_block_builder, old_tip_payment_config->block_builder, 32UL );
304 27 : gen->crank2->change_block_builder.block_builder_commission_pct = block_builder_commission;
305 27 : }
306 :
307 : /* If it weren't for the fact that the old tip payment config is
308 : essentially attacker-controlled, we'd be golden. However, someone
309 : trying to grief us can e.g. set the old block builder to the tip
310 : payment program, and if we're not careful, we'll create a
311 : transaction with a duplicate account. We trust identity, new
312 : tip_receiver, and new_block_builder well enough though. Note that
313 : it's not possible for either attacker-controlled address to be the
314 : system program, because the account must be writable, and write
315 : locks to the system program get demoted. */
316 30 : fd_bundle_crank_gen_pidx_t * identity_pidx = pidx_map_insert( gen->map, *(fd_acct_addr_t *)identity );
317 30 : if( FD_UNLIKELY( !identity_pidx ) ) {
318 0 : FD_LOG_WARNING(( "Indentity was already in map. Refusing to crank bundles." ));
319 0 : return ULONG_MAX;
320 0 : }
321 30 : identity_pidx->idx = 0UL;
322 :
323 30 : fd_bundle_crank_gen_pidx_t * new_tr_pidx = pidx_map_insert( gen->map, *(fd_acct_addr_t *)gen->crank3->new_tip_receiver );
324 30 : if( FD_UNLIKELY( !new_tr_pidx ) ) {
325 0 : pidx_map_remove( gen->map, identity_pidx );
326 0 : FD_LOG_WARNING(( "New block builder was already in map. Refusing to crank bundles." ));
327 0 : return ULONG_MAX;
328 0 : }
329 30 : new_tr_pidx->idx = 13UL;
330 :
331 30 : fd_bundle_crank_gen_pidx_t * new_bb_pidx = pidx_map_insert( gen->map, *(fd_acct_addr_t *)new_block_builder );
332 30 : if( FD_UNLIKELY( !new_bb_pidx ) ) {
333 0 : pidx_map_remove( gen->map, new_tr_pidx );
334 0 : pidx_map_remove( gen->map, identity_pidx );
335 0 : FD_LOG_WARNING(( "New block builder was already in map. Refusing to crank bundles." ));
336 0 : return ULONG_MAX;
337 0 : }
338 30 : new_bb_pidx->idx = 14UL;
339 :
340 30 : int inserted1 = 0;
341 30 : int inserted2 = 0;
342 30 : fd_bundle_crank_gen_pidx_t dummy1[1] = {{ .idx = 11UL }};
343 30 : fd_bundle_crank_gen_pidx_t dummy2[1] = {{ .idx = 12UL }};
344 :
345 30 : fd_bundle_crank_gen_pidx_t * old_tr_pidx = pidx_map_query( gen->map, *old_tip_payment_config->tip_receiver, NULL );
346 30 : if( FD_LIKELY( NULL==old_tr_pidx ) ) {
347 15 : old_tr_pidx = pidx_map_insert( gen->map, *old_tip_payment_config->tip_receiver );
348 15 : old_tr_pidx->idx = 11UL;
349 15 : inserted1 = 1;
350 15 : } else if( FD_UNLIKELY( !swap3 && old_tr_pidx->idx>16UL ) ) {
351 0 : old_tr_pidx = dummy1;
352 15 : } else {
353 : /* perturb the old tip receiver pubkey so that it's not a duplicate,
354 : then don't use it. */
355 15 : gen->crank3->old_tip_receiver[0]++;
356 15 : gen->crank2->old_tip_receiver[0]++;
357 15 : }
358 :
359 30 : fd_bundle_crank_gen_pidx_t * old_bb_pidx = pidx_map_query( gen->map, *old_tip_payment_config->block_builder, NULL );
360 30 : if( FD_UNLIKELY( NULL==old_bb_pidx ) ) {
361 6 : old_bb_pidx = pidx_map_insert( gen->map, *old_tip_payment_config->block_builder );
362 6 : old_bb_pidx->idx = 12UL;
363 6 : inserted2 = 1;
364 24 : } else if( FD_UNLIKELY( !swap3 && old_bb_pidx->idx>16UL ) ) {
365 0 : old_bb_pidx = dummy2;
366 24 : } else {
367 : /* perturb, but do it differently so it can't conflict with the
368 : old tip receiver if they're both the same. */
369 24 : gen->crank3->old_block_builder[0]--;
370 24 : gen->crank2->old_block_builder[0]--;
371 24 : }
372 :
373 30 : gen->crank3->change_tip_receiver.acct_idx [1] = (uchar)(old_tr_pidx->idx);
374 30 : gen->crank2->change_tip_receiver.acct_idx [1] = (uchar)(old_tr_pidx->idx);
375 30 : gen->crank3->change_tip_receiver.acct_idx [3] = (uchar)(old_bb_pidx->idx);
376 30 : gen->crank3->change_block_builder.acct_idx[2] = (uchar)(old_bb_pidx->idx);
377 30 : gen->crank2->change_tip_receiver.acct_idx [3] = (uchar)(old_bb_pidx->idx);
378 30 : gen->crank2->change_block_builder.acct_idx[2] = (uchar)(old_bb_pidx->idx);
379 :
380 30 : if( FD_UNLIKELY( inserted2 ) ) pidx_map_remove( gen->map, old_bb_pidx );
381 30 : if( FD_LIKELY ( inserted1 ) ) pidx_map_remove( gen->map, old_tr_pidx );
382 30 : pidx_map_remove( gen->map, new_bb_pidx );
383 30 : pidx_map_remove( gen->map, new_tr_pidx );
384 30 : pidx_map_remove( gen->map, identity_pidx );
385 :
386 30 : if( FD_UNLIKELY( swap3 ) ) {
387 3 : fd_memcpy( out_payload, gen->crank3, sizeof(gen->crank3) );
388 3 : fd_memcpy( out_txn, gen->txn3, sizeof(gen->txn3) );
389 3 : return sizeof(gen->crank3);
390 27 : } else {
391 27 : fd_memcpy( out_payload, gen->crank2, sizeof(gen->crank2) );
392 27 : fd_memcpy( out_txn, gen->txn2, sizeof(gen->txn2) );
393 27 : return sizeof(gen->crank2);
394 27 : }
395 30 : }
396 :
397 : void
398 : fd_bundle_crank_apply( fd_bundle_crank_gen_t * gen,
399 : fd_bundle_crank_tip_payment_config_t * tip_payment_config,
400 : fd_acct_addr_t const * new_block_builder,
401 : fd_acct_addr_t * tip_receiver_owner,
402 : ulong epoch,
403 0 : ulong block_builder_commission ) {
404 :
405 0 : if( FD_UNLIKELY( epoch!=gen->configured_epoch ) ) fd_bundle_crank_update_epoch( gen, epoch );
406 :
407 0 : memcpy( tip_receiver_owner, gen->crank3->tip_distribution_program, sizeof(fd_acct_addr_t) );
408 0 : memcpy( tip_payment_config->tip_receiver, gen->crank3->new_tip_receiver, sizeof(fd_acct_addr_t) );
409 0 : memcpy( tip_payment_config->block_builder, new_block_builder, sizeof(fd_acct_addr_t) );
410 :
411 0 : tip_payment_config->commission_pct = block_builder_commission;
412 0 : }
|