diff --git a/src/app/fdctl/run/tiles/fd_dedup.c b/src/app/fdctl/run/tiles/fd_dedup.c index 3890d56c65..0f5019d011 100644 --- a/src/app/fdctl/run/tiles/fd_dedup.c +++ b/src/app/fdctl/run/tiles/fd_dedup.c @@ -242,7 +242,7 @@ unprivileged_init( fd_topo_t * topo, FD_SCRATCH_ALLOC_INIT( l, scratch ); fd_dedup_ctx_t * ctx = FD_SCRATCH_ALLOC_APPEND( l, alignof( fd_dedup_ctx_t ), sizeof( fd_dedup_ctx_t ) ); - fd_tcache_t * tcache = fd_tcache_join( fd_tcache_new( FD_SCRATCH_ALLOC_APPEND( l, FD_TCACHE_ALIGN, fd_tcache_footprint( tile->dedup.tcache_depth, 0) ), tile->dedup.tcache_depth, 0 ) ); + fd_tcache_t * tcache = fd_tcache_join( fd_tcache_new( FD_SCRATCH_ALLOC_APPEND( l, fd_tcache_align(), fd_tcache_footprint( tile->dedup.tcache_depth, 0) ), tile->dedup.tcache_depth, 0 ) ); if( FD_UNLIKELY( !tcache ) ) FD_LOG_ERR(( "fd_tcache_new failed" )); ctx->tcache_depth = fd_tcache_depth ( tcache ); diff --git a/src/app/fdctl/run/tiles/fd_net.c b/src/app/fdctl/run/tiles/fd_net.c index 1d196b1740..17d68c2e4e 100644 --- a/src/app/fdctl/run/tiles/fd_net.c +++ b/src/app/fdctl/run/tiles/fd_net.c @@ -128,7 +128,7 @@ scratch_footprint( fd_topo_tile_t const * tile ) { l = FD_LAYOUT_APPEND( l, fd_xsk_align(), fd_xsk_footprint( FD_NET_MTU, tile->net.xdp_rx_queue_size, tile->net.xdp_rx_queue_size, tile->net.xdp_tx_queue_size, tile->net.xdp_tx_queue_size ) ); l = FD_LAYOUT_APPEND( l, fd_xsk_aio_align(), fd_xsk_aio_footprint( tile->net.xdp_tx_queue_size, tile->net.xdp_aio_depth ) ); } - l = FD_LAYOUT_APPEND( l, fd_ip_align(), fd_ip_footprint( 0U, 0U ) ); + l = FD_LAYOUT_APPEND( l, fd_ip_align(), fd_ip_footprint( 0UL, 0UL ) ); return FD_LAYOUT_FINI( l, scratch_align() ); } diff --git a/src/app/fdctl/run/tiles/fd_replay.c b/src/app/fdctl/run/tiles/fd_replay.c index 4a559164bb..d5648c23db 100644 --- a/src/app/fdctl/run/tiles/fd_replay.c +++ b/src/app/fdctl/run/tiles/fd_replay.c @@ -286,7 +286,8 @@ scratch_footprint( fd_topo_tile_t const * tile FD_PARAM_UNUSED ) { l = FD_LAYOUT_APPEND( l, FD_BMTREE_COMMIT_ALIGN, FD_BMTREE_COMMIT_FOOTPRINT(0) ); } l = FD_LAYOUT_APPEND( l, FD_SCRATCH_ALIGN_DEFAULT, tile->replay.tpool_thread_count * TPOOL_WORKER_MEM_SZ ); - l = FD_LAYOUT_APPEND( l, fd_spad_align(), tile->replay.tpool_thread_count * fd_spad_footprint( MAX_TX_ACCOUNT_LOCKS * fd_ulong_align_up( FD_ACC_TOT_SZ_MAX, FD_ACCOUNT_REC_ALIGN ) ) ); + ulong thread_spad_size = fd_spad_footprint( MAX_TX_ACCOUNT_LOCKS * fd_ulong_align_up( FD_ACC_TOT_SZ_MAX, FD_ACCOUNT_REC_ALIGN ) ); + l = FD_LAYOUT_APPEND( l, fd_spad_align(), tile->replay.tpool_thread_count * thread_spad_size ); l = FD_LAYOUT_APPEND( l, fd_scratch_smem_align(), fd_scratch_smem_footprint( SCRATCH_MAX ) ); l = FD_LAYOUT_APPEND( l, fd_scratch_fmem_align(), fd_scratch_fmem_footprint( SCRATCH_DEPTH ) ); l = FD_LAYOUT_FINI ( l, scratch_align() ); diff --git a/src/app/fdctl/run/tiles/fd_store_int.c b/src/app/fdctl/run/tiles/fd_store_int.c index 929b8da8d5..1c2e14f6e4 100644 --- a/src/app/fdctl/run/tiles/fd_store_int.c +++ b/src/app/fdctl/run/tiles/fd_store_int.c @@ -542,7 +542,7 @@ privileged_init( fd_topo_t * topo, FD_SCRATCH_ALLOC_INIT( l, scratch ); fd_store_tile_ctx_t * ctx = FD_SCRATCH_ALLOC_APPEND( l, alignof(fd_store_tile_ctx_t), sizeof(fd_store_tile_ctx_t) ); - FD_SCRATCH_ALLOC_FINI( l, sizeof(fd_store_tile_ctx_t) ); + FD_SCRATCH_ALLOC_FINI( l, scratch_align() ); if( FD_UNLIKELY( !strcmp( tile->store_int.identity_key_path, "" ) ) ) FD_LOG_ERR(( "identity_key_path not set" )); @@ -773,7 +773,7 @@ populate_allowed_seccomp( fd_topo_t const * topo, void * scratch = fd_topo_obj_laddr( topo, tile->tile_obj_id ); FD_SCRATCH_ALLOC_INIT( l, scratch ); fd_store_tile_ctx_t * ctx = FD_SCRATCH_ALLOC_APPEND( l, alignof(fd_store_tile_ctx_t), sizeof(fd_store_tile_ctx_t) ); - FD_SCRATCH_ALLOC_FINI( l, alignof(fd_store_tile_ctx_t) ); + FD_SCRATCH_ALLOC_FINI( l, scratch_align() ); populate_sock_filter_policy_store_int( out_cnt, out, (uint)fd_log_private_logfile_fd(), (uint)ctx->blockstore_fd ); return sock_filter_policy_store_int_instr_cnt; diff --git a/src/choreo/eqvoc/fd_eqvoc.c b/src/choreo/eqvoc/fd_eqvoc.c index a0e7bff2bd..956fd26231 100644 --- a/src/choreo/eqvoc/fd_eqvoc.c +++ b/src/choreo/eqvoc/fd_eqvoc.c @@ -51,9 +51,9 @@ fd_eqvoc_join( void * sheqvoc ) { } FD_SCRATCH_ALLOC_INIT( l, sheqvoc ); - fd_eqvoc_t * eqvoc = FD_SCRATCH_ALLOC_APPEND( l, alignof(fd_eqvoc_t), sizeof(fd_eqvoc_t) ); - void * fec_pool = FD_SCRATCH_ALLOC_APPEND( l, fd_eqvoc_fec_pool_align(), fd_eqvoc_fec_pool_footprint( eqvoc->fec_max ) ); - void * fec_map = FD_SCRATCH_ALLOC_APPEND( l, fd_eqvoc_fec_map_align(), fd_eqvoc_fec_map_footprint( eqvoc->fec_max ) ); + fd_eqvoc_t * eqvoc = FD_SCRATCH_ALLOC_APPEND( l, alignof(fd_eqvoc_t), sizeof(fd_eqvoc_t) ); + void * fec_pool = FD_SCRATCH_ALLOC_APPEND( l, fd_eqvoc_fec_pool_align(), fd_eqvoc_fec_pool_footprint( eqvoc->fec_max ) ); + void * fec_map = FD_SCRATCH_ALLOC_APPEND( l, fd_eqvoc_fec_map_align(), fd_eqvoc_fec_map_footprint( eqvoc->fec_max ) ); void * proof_pool = FD_SCRATCH_ALLOC_APPEND( l, fd_eqvoc_proof_pool_align(), fd_eqvoc_proof_pool_footprint( eqvoc->proof_max ) ); void * proof_map = FD_SCRATCH_ALLOC_APPEND( l, fd_eqvoc_proof_map_align(), fd_eqvoc_proof_map_footprint( eqvoc->proof_max ) ); void * sha512 = FD_SCRATCH_ALLOC_APPEND( l, fd_sha512_align(), fd_sha512_footprint() ); diff --git a/src/disco/quic/fd_quic_tile.c b/src/disco/quic/fd_quic_tile.c index cfad901079..1311fc4e84 100644 --- a/src/disco/quic/fd_quic_tile.c +++ b/src/disco/quic/fd_quic_tile.c @@ -52,14 +52,14 @@ scratch_align( void ) { FD_FN_PURE static inline ulong scratch_footprint( fd_topo_tile_t const * tile ) { - ulong depth = tile->quic.out_depth; + ulong out_depth = tile->quic.out_depth; ulong reasm_max = tile->quic.reasm_cnt; fd_quic_limits_t limits = quic_limits( tile ); /* May FD_LOG_ERR */ ulong l = FD_LAYOUT_INIT; - l = FD_LAYOUT_APPEND( l, alignof( fd_quic_ctx_t ), sizeof( fd_quic_ctx_t ) ); - l = FD_LAYOUT_APPEND( l, fd_quic_align(), fd_quic_footprint( &limits ) ); - l = FD_LAYOUT_APPEND( l, fd_tpu_reasm_align(), fd_tpu_reasm_footprint( depth, reasm_max ) ); + l = FD_LAYOUT_APPEND( l, alignof( fd_quic_ctx_t ), sizeof( fd_quic_ctx_t ) ); + l = FD_LAYOUT_APPEND( l, fd_quic_align(), fd_quic_footprint( &limits ) ); + l = FD_LAYOUT_APPEND( l, fd_tpu_reasm_align(), fd_tpu_reasm_footprint( out_depth, reasm_max ) ); return FD_LAYOUT_FINI( l, scratch_align() ); } diff --git a/src/disco/quic/fd_tpu_reasm.c b/src/disco/quic/fd_tpu_reasm.c index ae8b7dbe76..5788e0d3f2 100644 --- a/src/disco/quic/fd_tpu_reasm.c +++ b/src/disco/quic/fd_tpu_reasm.c @@ -20,11 +20,11 @@ fd_tpu_reasm_footprint( ulong depth, ulong slot_cnt = depth+burst; ulong chain_cnt = fd_tpu_reasm_map_chain_cnt_est( slot_cnt ); return FD_LAYOUT_FINI( FD_LAYOUT_APPEND( FD_LAYOUT_APPEND( FD_LAYOUT_APPEND( FD_LAYOUT_APPEND( FD_LAYOUT_INIT, - FD_TPU_REASM_ALIGN, sizeof(fd_tpu_reasm_t) ), /* hdr */ + fd_tpu_reasm_align(), sizeof(fd_tpu_reasm_t) ), /* hdr */ alignof(uint), depth *sizeof(uint) ), /* pub_slots */ alignof(fd_tpu_reasm_slot_t), slot_cnt*sizeof(fd_tpu_reasm_slot_t) ), /* slots */ fd_tpu_reasm_map_align(), fd_tpu_reasm_map_footprint( chain_cnt ) ), /* map */ - FD_TPU_REASM_ALIGN ); + fd_tpu_reasm_align() ); } @@ -53,11 +53,11 @@ fd_tpu_reasm_new( void * shmem, ulong chain_cnt = fd_tpu_reasm_map_chain_cnt_est( slot_cnt ); FD_SCRATCH_ALLOC_INIT( l, shmem ); - fd_tpu_reasm_t * reasm = FD_SCRATCH_ALLOC_APPEND( l, alignof(fd_tpu_reasm_t), sizeof(fd_tpu_reasm_t) ); + fd_tpu_reasm_t * reasm = FD_SCRATCH_ALLOC_APPEND( l, fd_tpu_reasm_align(), sizeof(fd_tpu_reasm_t) ); ulong * pub_slots = FD_SCRATCH_ALLOC_APPEND( l, alignof(uint), depth*sizeof(uint) ); fd_tpu_reasm_slot_t * slots = FD_SCRATCH_ALLOC_APPEND( l, alignof(fd_tpu_reasm_slot_t), slot_cnt*sizeof(fd_tpu_reasm_slot_t) ); void * map_mem = FD_SCRATCH_ALLOC_APPEND( l, fd_tpu_reasm_map_align(), fd_tpu_reasm_map_footprint( chain_cnt ) ); - FD_SCRATCH_ALLOC_FINI( l, alignof(fd_tpu_reasm_t) ); + FD_SCRATCH_ALLOC_FINI( l, fd_tpu_reasm_align() ); fd_memset( reasm, 0, sizeof(fd_tpu_reasm_t) ); fd_memset( slots, 0, burst*sizeof(fd_tpu_reasm_slot_t) ); diff --git a/src/disco/stem/fd_stem.c b/src/disco/stem/fd_stem.c index b72888790e..a4b1360211 100644 --- a/src/disco/stem/fd_stem.c +++ b/src/disco/stem/fd_stem.c @@ -191,7 +191,8 @@ STEM_(scratch_footprint)( ulong in_cnt, l = FD_LAYOUT_APPEND( l, alignof(ulong *), cons_cnt*sizeof(ulong *) ); /* cons_slow */ l = FD_LAYOUT_APPEND( l, alignof(ulong), cons_cnt*sizeof(ulong) ); /* cons_out */ l = FD_LAYOUT_APPEND( l, alignof(ulong), cons_cnt*sizeof(ulong) ); /* cons_seq */ - l = FD_LAYOUT_APPEND( l, alignof(ushort), (in_cnt+cons_cnt+1UL)*sizeof(ushort) ); /* event_map */ + const ulong event_cnt = in_cnt + 1UL + cons_cnt; + l = FD_LAYOUT_APPEND( l, alignof(ushort), event_cnt*sizeof(ushort) ); /* event_map */ return FD_LAYOUT_FINI( l, STEM_(scratch_align)() ); } @@ -301,7 +302,7 @@ STEM_(run1)( ulong in_cnt, cons_fseq = (ulong const **)FD_SCRATCH_ALLOC_APPEND( l, alignof(ulong const *), cons_cnt*sizeof(ulong const *) ); cons_slow = (ulong **) FD_SCRATCH_ALLOC_APPEND( l, alignof(ulong *), cons_cnt*sizeof(ulong *) ); - cons_out = (ulong *) FD_SCRATCH_ALLOC_APPEND( l, alignof(ulong), cons_cnt*sizeof(ulong *) ); + cons_out = (ulong *) FD_SCRATCH_ALLOC_APPEND( l, alignof(ulong), cons_cnt*sizeof(ulong) ); cons_seq = (ulong *) FD_SCRATCH_ALLOC_APPEND( l, alignof(ulong), cons_cnt*sizeof(ulong) ); if( FD_UNLIKELY( !!cons_cnt && !_cons_fseq ) ) FD_LOG_ERR(( "NULL cons_fseq" )); diff --git a/src/flamenco/gossip/fd_gossip.c b/src/flamenco/gossip/fd_gossip.c index b9bc88de17..6d9aca186f 100644 --- a/src/flamenco/gossip/fd_gossip.c +++ b/src/flamenco/gossip/fd_gossip.c @@ -351,7 +351,7 @@ fd_gossip_footprint( void ) { l = FD_LAYOUT_APPEND( l, fd_stats_table_align(), fd_stats_table_footprint(FD_STATS_KEY_MAX) ); l = FD_LAYOUT_APPEND( l, fd_weights_table_align(), fd_weights_table_footprint(MAX_STAKE_WEIGHTS) ); l = FD_LAYOUT_APPEND( l, fd_push_states_pool_align(), fd_push_states_pool_footprint(FD_PUSH_LIST_MAX) ); - l = FD_LAYOUT_FINI(l, fd_gossip_align()); + l = FD_LAYOUT_FINI( l, fd_gossip_align() ); return l; } @@ -391,7 +391,7 @@ fd_gossip_new ( void * shmem, ulong seed ) { shm = FD_SCRATCH_ALLOC_APPEND(l, fd_push_states_pool_align(), fd_push_states_pool_footprint(FD_PUSH_LIST_MAX)); glob->push_states_pool = fd_push_states_pool_join( fd_push_states_pool_new( shm, FD_PUSH_LIST_MAX ) ); - ulong scratch_top = FD_SCRATCH_ALLOC_FINI(l, 1UL); + ulong scratch_top = FD_SCRATCH_ALLOC_FINI( l, fd_gossip_align() ); if ( scratch_top > (ulong)shmem + fd_gossip_footprint() ) { FD_LOG_ERR(("Not enough space allocated for gossip")); } diff --git a/src/flamenco/runtime/tests/fd_exec_instr_test.c b/src/flamenco/runtime/tests/fd_exec_instr_test.c index c640931b6b..9ee6e23703 100644 --- a/src/flamenco/runtime/tests/fd_exec_instr_test.c +++ b/src/flamenco/runtime/tests/fd_exec_instr_test.c @@ -75,9 +75,9 @@ fd_exec_instr_test_runner_align( void ) { ulong fd_exec_instr_test_runner_footprint( void ) { ulong l = FD_LAYOUT_INIT; - l = FD_LAYOUT_APPEND( l, alignof(fd_exec_instr_test_runner_t), sizeof(fd_exec_instr_test_runner_t) ); - l = FD_LAYOUT_APPEND( l, fd_funk_align(), fd_funk_footprint() ); - return l; + l = FD_LAYOUT_APPEND( l, fd_exec_instr_test_runner_align(), sizeof(fd_exec_instr_test_runner_t) ); + l = FD_LAYOUT_APPEND( l, fd_funk_align(), fd_funk_footprint() ); + return FD_LAYOUT_FINI( l, fd_exec_instr_test_runner_align() ); } fd_exec_instr_test_runner_t * @@ -85,9 +85,9 @@ fd_exec_instr_test_runner_new( void * mem, void * spad_mem, ulong wksp_tag ) { FD_SCRATCH_ALLOC_INIT( l, mem ); - void * runner_mem = FD_SCRATCH_ALLOC_APPEND( l, alignof(fd_exec_instr_test_runner_t), sizeof(fd_exec_instr_test_runner_t) ); - void * funk_mem = FD_SCRATCH_ALLOC_APPEND( l, fd_funk_align(), fd_funk_footprint() ); - FD_SCRATCH_ALLOC_FINI( l, alignof(fd_exec_instr_test_runner_t) ); + void * runner_mem = FD_SCRATCH_ALLOC_APPEND( l, fd_exec_instr_test_runner_align(), sizeof(fd_exec_instr_test_runner_t) ); + void * funk_mem = FD_SCRATCH_ALLOC_APPEND( l, fd_funk_align(), fd_funk_footprint() ); + FD_SCRATCH_ALLOC_FINI( l, fd_exec_instr_test_runner_align() ); ulong txn_max = 4+fd_tile_cnt(); ulong rec_max = 1024UL; @@ -658,7 +658,7 @@ _txn_context_create_and_exec( fd_exec_instr_test_runner_t * runner, epoch_bank->rent = *slot_ctx->sysvar_cache->val_rent; } - /* Provde default slot hashes of size 1 if not provided */ + /* Provide default slot hashes of size 1 if not provided */ if( !slot_ctx->sysvar_cache->has_slot_hashes ) { fd_slot_hash_t * slot_hashes = deq_fd_slot_hash_t_alloc( fd_scratch_virtual(), 1 ); fd_slot_hash_t * dummy_elem = deq_fd_slot_hash_t_push_tail_nocopy( slot_hashes ); @@ -1657,6 +1657,13 @@ fd_exec_vm_syscall_test_run( fd_exec_instr_test_runner_t * runner, goto error; fd_valloc_t valloc = fd_scratch_virtual(); + if (is_cpi) { + ctx->txn_ctx->instr_info_cnt = 1; + } + + ctx->txn_ctx->instr_trace[0].instr_info = (fd_instr_info_t *)ctx->instr; + ctx->txn_ctx->instr_trace[0].stack_height = 1; + /* Capture outputs */ ulong output_end = (ulong)output_buf + output_bufsz; FD_SCRATCH_ALLOC_INIT( l, output_buf );