|
12 | 12 | #include "../../flamenco/runtime/sysvar/fd_sysvar_epoch_schedule.h"
|
13 | 13 | #include "../../disco/fd_disco.h"
|
14 | 14 | #include "../../util/pod/fd_pod_format.h"
|
| 15 | +#include "../replay/fd_exec.h" |
15 | 16 |
|
16 | 17 | #include <errno.h>
|
17 | 18 | #include <fcntl.h>
|
@@ -227,74 +228,28 @@ scratch_footprint( fd_topo_tile_t const * tile ) {
|
227 | 228 | return FD_LAYOUT_FINI( l, scratch_align() );
|
228 | 229 | }
|
229 | 230 |
|
230 |
| -ulong |
231 |
| -fd_stake_weights_by_node_custom( fd_snapshot_manifest_epoch_stakes_t const * epoch_stakes, |
232 |
| - fd_vote_stake_weight_t * weights ) { |
233 |
| - |
234 |
| - for( ulong i=0UL; i<epoch_stakes->vote_stakes_len; i++ ) { |
235 |
| - weights[ i ].stake = epoch_stakes->vote_stakes[ i ].stake; |
236 |
| - memcpy( weights[ i ].id_key.uc, epoch_stakes->vote_stakes[ i ].identity, sizeof(fd_pubkey_t) ); |
237 |
| - memcpy( weights[ i ].vote_key.uc, epoch_stakes->vote_stakes[ i ].vote, sizeof(fd_pubkey_t) ); |
238 |
| - } |
239 |
| - sort_vote_weights_by_stake_vote_inplace( weights, epoch_stakes->vote_stakes_len); |
240 |
| - return epoch_stakes->vote_stakes_len; |
241 |
| -} |
242 |
| - |
243 |
| -static inline ulong |
244 |
| -generate_stake_weight_msg( ulong epoch, |
245 |
| - fd_epoch_schedule_t const * epoch_schedule, |
246 |
| - fd_snapshot_manifest_epoch_stakes_t const * epoch_stakes, |
247 |
| - ulong * stake_weight_msg_out ) { |
248 |
| - |
249 |
| - fd_stake_weight_msg_t * stake_weight_msg = (fd_stake_weight_msg_t *)fd_type_pun( stake_weight_msg_out ); |
250 |
| - fd_vote_stake_weight_t * stake_weights = stake_weight_msg->weights; |
251 |
| - ulong stake_weight_idx = fd_stake_weights_by_node_custom( epoch_stakes, stake_weights ); |
252 |
| - |
253 |
| - stake_weight_msg->epoch = epoch; |
254 |
| - stake_weight_msg->staked_cnt = stake_weight_idx; |
255 |
| - stake_weight_msg->start_slot = fd_epoch_slot0( epoch_schedule, epoch ); |
256 |
| - stake_weight_msg->slot_cnt = epoch_schedule->slots_per_epoch; |
257 |
| - stake_weight_msg->excluded_stake = 0UL; |
258 |
| - stake_weight_msg->vote_keyed_lsched = 0UL; |
259 |
| - |
260 |
| - return fd_stake_weight_msg_sz( epoch_stakes->vote_stakes_len ); |
261 |
| -} |
262 | 231 | static void
|
263 |
| -publish_stake_weights( fd_capture_tile_ctx_t * ctx, |
264 |
| - fd_stem_context_t * stem, |
265 |
| - fd_snapshot_manifest_t const * manifest ) { |
266 |
| - FD_SPAD_FRAME_BEGIN( ctx->shared_spad ) { |
267 |
| - |
268 |
| - /* Process the schedule from manifest. */ |
269 |
| - fd_epoch_schedule_t schedule[1]; |
270 |
| - schedule[0].slots_per_epoch = manifest->epoch_schedule_params.slots_per_epoch; |
271 |
| - schedule[0].leader_schedule_slot_offset = manifest->epoch_schedule_params.leader_schedule_slot_offset; |
272 |
| - schedule[0].warmup = manifest->epoch_schedule_params.warmup; |
273 |
| - schedule[0].first_normal_epoch = manifest->epoch_schedule_params.first_normal_epoch; |
274 |
| - schedule[0].first_normal_slot = manifest->epoch_schedule_params.first_normal_slot; |
275 |
| - ulong epoch = fd_slot_to_epoch( schedule, manifest->slot, NULL ); |
276 |
| - |
277 |
| - /* current epoch */ |
278 |
| - if( 1 ) { |
279 |
| - ulong * stake_weights_msg = fd_chunk_to_laddr( ctx->stake_out->mem, ctx->stake_out->chunk ); |
280 |
| - ulong stake_weights_sz = generate_stake_weight_msg( epoch, schedule, &manifest->epoch_stakes[0], stake_weights_msg ); |
281 |
| - ulong stake_weights_sig = 4UL; |
282 |
| - fd_stem_publish( stem, 0UL, stake_weights_sig, ctx->stake_out->chunk, stake_weights_sz, 0UL, 0UL, fd_frag_meta_ts_comp( fd_tickcount() ) ); |
283 |
| - ctx->stake_out->chunk = fd_dcache_compact_next( ctx->stake_out->chunk, stake_weights_sz, ctx->stake_out->chunk0, ctx->stake_out->wmark ); |
284 |
| - FD_LOG_NOTICE(("sending current epoch stake weights - epoch: %lu, stake_weight_cnt: %lu, start_slot: %lu, slot_cnt: %lu", stake_weights_msg[0], stake_weights_msg[1], stake_weights_msg[2], stake_weights_msg[3])); |
285 |
| - } |
286 |
| - |
287 |
| - /* next current epoch */ |
288 |
| - if( 1 ) { |
289 |
| - ulong * stake_weights_msg = fd_chunk_to_laddr( ctx->stake_out->mem, ctx->stake_out->chunk ); |
290 |
| - ulong stake_weights_sz = generate_stake_weight_msg( epoch + 1, schedule, &manifest->epoch_stakes[1], stake_weights_msg ); |
291 |
| - ulong stake_weights_sig = 4UL; |
292 |
| - fd_stem_publish( stem, 0UL, stake_weights_sig, ctx->stake_out->chunk, stake_weights_sz, 0UL, 0UL, fd_frag_meta_ts_comp( fd_tickcount() ) ); |
293 |
| - ctx->stake_out->chunk = fd_dcache_compact_next( ctx->stake_out->chunk, stake_weights_sz, ctx->stake_out->chunk0, ctx->stake_out->wmark ); |
294 |
| - FD_LOG_NOTICE(("sending next epoch stake weights - epoch: %lu, stake_weight_cnt: %lu, start_slot: %lu, slot_cnt: %lu", stake_weights_msg[0], stake_weights_msg[1], stake_weights_msg[2], stake_weights_msg[3])); |
295 |
| - } |
296 |
| - |
297 |
| - } FD_SPAD_FRAME_END; |
| 232 | +publish_stake_weights_manifest( fd_capture_tile_ctx_t * ctx, |
| 233 | + fd_stem_context_t * stem, |
| 234 | + fd_snapshot_manifest_t const * manifest ) { |
| 235 | + fd_epoch_schedule_t const * schedule = fd_type_pun_const( &manifest->epoch_schedule_params ); |
| 236 | + ulong epoch = fd_slot_to_epoch( schedule, manifest->slot, NULL ); |
| 237 | + |
| 238 | + /* current epoch */ |
| 239 | + ulong * stake_weights_msg = fd_chunk_to_laddr( ctx->stake_out->mem, ctx->stake_out->chunk ); |
| 240 | + ulong stake_weights_sz = generate_stake_weight_msg_manifest( epoch, schedule, &manifest->epoch_stakes[0], stake_weights_msg ); |
| 241 | + ulong stake_weights_sig = 4UL; |
| 242 | + fd_stem_publish( stem, 0UL, stake_weights_sig, ctx->stake_out->chunk, stake_weights_sz, 0UL, 0UL, fd_frag_meta_ts_comp( fd_tickcount() ) ); |
| 243 | + ctx->stake_out->chunk = fd_dcache_compact_next( ctx->stake_out->chunk, stake_weights_sz, ctx->stake_out->chunk0, ctx->stake_out->wmark ); |
| 244 | + FD_LOG_NOTICE(("sending current epoch stake weights - epoch: %lu, stake_weight_cnt: %lu, start_slot: %lu, slot_cnt: %lu", stake_weights_msg[0], stake_weights_msg[1], stake_weights_msg[2], stake_weights_msg[3])); |
| 245 | + |
| 246 | + /* next current epoch */ |
| 247 | + stake_weights_msg = fd_chunk_to_laddr( ctx->stake_out->mem, ctx->stake_out->chunk ); |
| 248 | + stake_weights_sz = generate_stake_weight_msg_manifest( epoch + 1, schedule, &manifest->epoch_stakes[1], stake_weights_msg ); |
| 249 | + stake_weights_sig = 4UL; |
| 250 | + fd_stem_publish( stem, 0UL, stake_weights_sig, ctx->stake_out->chunk, stake_weights_sz, 0UL, 0UL, fd_frag_meta_ts_comp( fd_tickcount() ) ); |
| 251 | + ctx->stake_out->chunk = fd_dcache_compact_next( ctx->stake_out->chunk, stake_weights_sz, ctx->stake_out->chunk0, ctx->stake_out->wmark ); |
| 252 | + FD_LOG_NOTICE(("sending next epoch stake weights - epoch: %lu, stake_weight_cnt: %lu, start_slot: %lu, slot_cnt: %lu", stake_weights_msg[0], stake_weights_msg[1], stake_weights_msg[2], stake_weights_msg[3])); |
298 | 253 | }
|
299 | 254 |
|
300 | 255 | static inline int
|
@@ -483,7 +438,7 @@ after_credit( fd_capture_tile_ctx_t * ctx,
|
483 | 438 |
|
484 | 439 | fd_fseq_update( ctx->manifest_wmark, manifest->slot );
|
485 | 440 |
|
486 |
| - publish_stake_weights( ctx, stem, manifest ); |
| 441 | + publish_stake_weights_manifest( ctx, stem, manifest ); |
487 | 442 | //*charge_busy = 0;
|
488 | 443 | }
|
489 | 444 | /* No need to strcmp every time after_credit is called. */
|
|
0 commit comments