Skip to content

Commit 9c85e63

Browse files
committed
work
1 parent 2ffb66e commit 9c85e63

File tree

3 files changed

+51
-55
lines changed

3 files changed

+51
-55
lines changed

src/app/firedancer/topology.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ fd_topo_initialize( config_t * config ) {
449449

450450
FOR(exec_tile_cnt) fd_topob_tile_uses( topo, &topo->tiles[ fd_topo_find_tile( topo, "exec", i ) ], funk_obj, FD_SHMEM_JOIN_MODE_READ_WRITE );
451451
/* */ fd_topob_tile_uses( topo, replay_tile, funk_obj, FD_SHMEM_JOIN_MODE_READ_WRITE );
452-
if(rpcserv_tile) fd_topob_tile_uses( topo, rpcserv_tile, funk_obj, FD_SHMEM_JOIN_MODE_READ_WRITE );
452+
if(enable_rpc) fd_topob_tile_uses( topo, rpcserv_tile, funk_obj, FD_SHMEM_JOIN_MODE_READ_WRITE );
453453
FOR(writer_tile_cnt) fd_topob_tile_uses( topo, &topo->tiles[ fd_topo_find_tile( topo, "writer", i ) ], funk_obj, FD_SHMEM_JOIN_MODE_READ_WRITE );
454454

455455
/* Setup a shared wksp object for banks. */
@@ -777,8 +777,11 @@ fd_topo_initialize( config_t * config ) {
777777
/**/ fd_topob_tile_out( topo, "replay", 0UL, "replay_notif", 0UL );
778778

779779
if( enable_rpc ) {
780-
fd_topob_tile_in( topo, "rpcsrv", 0UL, "metric_in", "replay_notif", 0UL, FD_TOPOB_UNRELIABLE, FD_TOPOB_POLLED );
781-
fd_topob_tile_in( topo, "rpcsrv", 0UL, "metric_in", "stake_out", 0UL, FD_TOPOB_UNRELIABLE, FD_TOPOB_POLLED );
780+
fd_topob_tile_in( topo, "rpcsrv", 0UL, "metric_in", "replay_notif", 0UL, FD_TOPOB_UNRELIABLE, FD_TOPOB_POLLED );
781+
fd_topob_tile_in( topo, "rpcsrv", 0UL, "metric_in", "stake_out", 0UL, FD_TOPOB_UNRELIABLE, FD_TOPOB_POLLED );
782+
for( ulong j=0UL; j<shred_tile_cnt; j++ ) {
783+
fd_topob_tile_in( topo, "rpcsrv", 0UL, "metric_in", "shred_repair", j, FD_TOPOB_UNRELIABLE, FD_TOPOB_POLLED );
784+
}
782785
}
783786

784787
/* For now the only plugin consumer is the GUI */

src/discof/rpcserver/fd_rpc_service.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
#define HEADER_fd_src_discof_rpcserver_fd_rpc_service_h
33

44
#include "../replay/fd_replay_notif.h"
5-
6-
#include "../../disco/store/fd_store.h"
75
#include "../../flamenco/leaders/fd_multi_epoch_leaders.h"
86
#include "../../waltz/http/fd_http_server.h"
97

@@ -26,7 +24,6 @@ struct fd_rpcserver_args {
2624

2725
/* Bump allocator */
2826
fd_spad_t * spad;
29-
fd_store_t * store;
3027
};
3128
typedef struct fd_rpcserver_args fd_rpcserver_args_t;
3229

src/discof/rpcserver/fd_rpcserv_tile.c

Lines changed: 45 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -9,34 +9,39 @@
99
#include "../rpcserver/fd_rpc_service.h"
1010

1111
#include "../../flamenco/leaders/fd_multi_epoch_leaders.h"
12-
#include "../../util/pod/fd_pod_format.h"
1312
#include "../../disco/keyguard/fd_keyload.h"
1413
#include "../../disco/keyguard/fd_keyswitch.h"
1514

16-
#include <errno.h>
1715
#include <fcntl.h>
1816
#include <unistd.h>
1917

20-
#define REPLAY_NOTIF_IDX 0
21-
#define STAKE_IN_IDX 1
18+
#define IN_KIND_REPLAY_NOTIF 0
19+
#define IN_KIND_STAKE_OUT 1
20+
#define IN_KIND_SHRED_REPAIR 2
21+
22+
#define MAX_IN_LINKS (16)
23+
24+
typedef union {
25+
struct {
26+
fd_wksp_t * mem;
27+
ulong chunk0;
28+
ulong wmark;
29+
ulong mtu;
30+
};
31+
} fd_rpcserv_in_ctx_t;
2232

2333
struct fd_rpcserv_tile_ctx {
2434
fd_rpcserver_args_t args;
2535

2636
fd_rpc_ctx_t * ctx;
27-
fd_store_t * store;
2837

2938
fd_pubkey_t identity_key;
3039
fd_keyswitch_t * keyswitch;
3140

32-
fd_wksp_t * replay_notif_in_mem;
33-
ulong replay_notif_in_chunk0;
34-
ulong replay_notif_in_wmark;
3541
fd_replay_notif_msg_t replay_notif_in_state;
3642

37-
fd_wksp_t * stake_in_mem;
38-
ulong stake_in_chunk0;
39-
ulong stake_in_wmark;
43+
uchar in_kind[ MAX_IN_LINKS ];
44+
fd_rpcserv_in_ctx_t in_links[ MAX_IN_LINKS ];
4045

4146
uchar __attribute__((aligned(FD_MULTI_EPOCH_LEADERS_ALIGN))) mleaders_mem[ FD_MULTI_EPOCH_LEADERS_FOOTPRINT ];
4247
};
@@ -95,21 +100,15 @@ during_frag( fd_rpcserv_tile_ctx_t * ctx,
95100
ulong chunk,
96101
ulong sz,
97102
ulong ctl FD_PARAM_UNUSED ) {
98-
99-
if( FD_UNLIKELY( in_idx==REPLAY_NOTIF_IDX ) ) {
100-
if( FD_UNLIKELY( chunk<ctx->replay_notif_in_chunk0 || chunk>ctx->replay_notif_in_wmark ) ) {
101-
FD_LOG_ERR(( "chunk %lu %lu corrupt, not in range [%lu,%lu]", chunk, sz,
102-
ctx->replay_notif_in_chunk0, ctx->replay_notif_in_wmark ));
103-
}
104-
fd_rpc_replay_during_frag( ctx->ctx, &ctx->replay_notif_in_state, fd_chunk_to_laddr_const( ctx->replay_notif_in_mem, chunk ), (int)sz );
105-
106-
} else if( FD_UNLIKELY( in_idx==STAKE_IN_IDX ) ) {
107-
if( FD_UNLIKELY( chunk<ctx->stake_in_chunk0 || chunk>ctx->stake_in_wmark ) ) {
108-
FD_LOG_ERR(( "chunk %lu %lu corrupt, not in range [%lu,%lu]", chunk, sz,
109-
ctx->stake_in_chunk0, ctx->stake_in_wmark ));
110-
}
111-
fd_rpc_stake_during_frag( ctx->ctx, ctx->args.leaders, fd_chunk_to_laddr_const( ctx->stake_in_mem, chunk ), (int)sz );
112-
103+
if( FD_UNLIKELY( chunk<ctx->in_links[in_idx].chunk0 || chunk>ctx->in_links[in_idx].wmark ) ) {
104+
FD_LOG_ERR(( "chunk %lu %lu corrupt, not in range [%lu,%lu]", chunk, sz,
105+
ctx->in_links[in_idx].chunk0, ctx->in_links[in_idx].wmark ));
106+
}
107+
uchar kind = ctx->in_kind[ in_idx ];
108+
if( FD_UNLIKELY( kind==IN_KIND_REPLAY_NOTIF ) ) {
109+
fd_rpc_replay_during_frag( ctx->ctx, &ctx->replay_notif_in_state, fd_chunk_to_laddr_const( ctx->in_links[in_idx].mem, chunk ), (int)sz );
110+
} else if( FD_UNLIKELY( kind == IN_KIND_STAKE_OUT ) ) {
111+
fd_rpc_stake_during_frag( ctx->ctx, ctx->args.leaders, fd_chunk_to_laddr_const( ctx->in_links[in_idx].mem, chunk ), (int)sz );
113112
} else {
114113
FD_LOG_ERR(("Unknown in_idx %lu for rpc", in_idx));
115114
}
@@ -131,9 +130,10 @@ after_frag( fd_rpcserv_tile_ctx_t * ctx,
131130
(void)tspub;
132131
(void)stem;
133132

134-
if( FD_LIKELY( in_idx==REPLAY_NOTIF_IDX ) ) {
133+
uchar kind = ctx->in_kind[ in_idx ];
134+
if( FD_UNLIKELY( kind==IN_KIND_REPLAY_NOTIF ) ) {
135135
fd_rpc_replay_after_frag( ctx->ctx, &ctx->replay_notif_in_state );
136-
} else if( FD_UNLIKELY( in_idx==STAKE_IN_IDX ) ) {
136+
} else if( FD_UNLIKELY( kind == IN_KIND_STAKE_OUT ) ) {
137137
fd_rpc_stake_after_frag( ctx->ctx, ctx->args.leaders );
138138
} else {
139139
FD_LOG_ERR(("Unknown in_idx %lu for rpc", in_idx));
@@ -171,12 +171,6 @@ privileged_init( fd_topo_t * topo,
171171
uchar * spad_mem_cur = spad_mem;
172172
args->spad = fd_spad_join( fd_spad_new( spad_mem_cur, FD_RPC_SCRATCH_MAX ) );
173173

174-
/* Blockstore setup */
175-
ulong store_obj_id = fd_pod_queryf_ulong( topo->props, ULONG_MAX, "store" );
176-
FD_TEST( store_obj_id!=ULONG_MAX );
177-
args->store = fd_store_join( fd_topo_obj_laddr( topo, store_obj_id ) );
178-
FD_TEST( args->store!=NULL );
179-
180174
args->block_index_max = tile->rpcserv.block_index_max;
181175
args->txn_index_max = tile->rpcserv.txn_index_max;
182176
args->acct_index_max = tile->rpcserv.acct_index_max;
@@ -195,13 +189,6 @@ unprivileged_init( fd_topo_t * topo,
195189
fd_topo_tile_t * tile ) {
196190
void * scratch = fd_topo_obj_laddr( topo, tile->tile_obj_id );
197191

198-
if( FD_UNLIKELY( tile->in_cnt != 2 ||
199-
strcmp( topo->links[ tile->in_link_id[ REPLAY_NOTIF_IDX ] ].name, "replay_notif") ||
200-
strcmp( topo->links[ tile->in_link_id[ STAKE_IN_IDX ] ].name, "stake_out" ) ) ) {
201-
FD_LOG_ERR(( "repair tile has none or unexpected input links %lu %s %s",
202-
tile->in_cnt, topo->links[ tile->in_link_id[ 0 ] ].name, topo->links[ tile->in_link_id[ 1 ] ].name ));
203-
}
204-
205192
if( FD_UNLIKELY( tile->out_cnt != 0 ) ) {
206193
FD_LOG_ERR(( "repair tile has none or unexpected output links %lu %s %s",
207194
tile->out_cnt, topo->links[ tile->out_link_id[ 0 ] ].name, topo->links[ tile->out_link_id[ 1 ] ].name ));
@@ -216,15 +203,24 @@ unprivileged_init( fd_topo_t * topo,
216203
if( FD_UNLIKELY( scratch_top > (ulong)scratch + scratch_footprint( tile ) ) )
217204
FD_LOG_ERR(( "scratch overflow %lu %lu %lu", scratch_top - (ulong)scratch - scratch_footprint( tile ), scratch_top, (ulong)scratch + scratch_footprint( tile ) ));
218205

219-
fd_topo_link_t * replay_notif_in_link = &topo->links[ tile->in_link_id[ REPLAY_NOTIF_IDX ] ];
220-
ctx->replay_notif_in_mem = topo->workspaces[ topo->objs[ replay_notif_in_link->dcache_obj_id ].wksp_id ].wksp;
221-
ctx->replay_notif_in_chunk0 = fd_dcache_compact_chunk0( ctx->replay_notif_in_mem, replay_notif_in_link->dcache );
222-
ctx->replay_notif_in_wmark = fd_dcache_compact_wmark ( ctx->replay_notif_in_mem, replay_notif_in_link->dcache, replay_notif_in_link->mtu );
206+
for( uint in_idx=0U; in_idx<(tile->in_cnt); in_idx++ ) {
207+
fd_topo_link_t * link = &topo->links[ tile->in_link_id[ in_idx ] ];
208+
if( 0==strcmp( link->name, "replay_notif" ) ) {
209+
ctx->in_kind[ in_idx ] = IN_KIND_REPLAY_NOTIF;
210+
} else if( 0==strcmp( link->name, "stake_out" ) ) {
211+
ctx->in_kind[ in_idx ] = IN_KIND_STAKE_OUT;
212+
} else if( 0==strcmp( link->name, "shred_repair" ) ) {
213+
ctx->in_kind[ in_idx ] = IN_KIND_SHRED_REPAIR;
214+
} else {
215+
FD_LOG_ERR(( "rpcserv tile has unexpected input link %s", link->name ));
216+
}
223217

224-
fd_topo_link_t * stake_in_link = &topo->links[ tile->in_link_id[ STAKE_IN_IDX ] ];
225-
ctx->stake_in_mem = topo->workspaces[ topo->objs[ stake_in_link->dcache_obj_id ].wksp_id ].wksp;
226-
ctx->stake_in_chunk0 = fd_dcache_compact_chunk0( ctx->stake_in_mem, stake_in_link->dcache );
227-
ctx->stake_in_wmark = fd_dcache_compact_wmark ( ctx->stake_in_mem, stake_in_link->dcache, stake_in_link->mtu );
218+
ctx->in_links[ in_idx ].mem = topo->workspaces[ topo->objs[ link->dcache_obj_id ].wksp_id ].wksp;
219+
ctx->in_links[ in_idx ].chunk0 = fd_dcache_compact_chunk0( ctx->in_links[ in_idx ].mem, link->dcache );
220+
ctx->in_links[ in_idx ].wmark = fd_dcache_compact_wmark ( ctx->in_links[ in_idx ].mem, link->dcache, link->mtu );
221+
ctx->in_links[ in_idx ].mtu = link->mtu;
222+
FD_TEST( fd_dcache_compact_is_safe( ctx->in_links[in_idx].mem, link->dcache, link->mtu, link->depth ) );
223+
}
228224

229225
ctx->keyswitch = fd_keyswitch_join( fd_topo_obj_laddr( topo, tile->keyswitch_obj_id ) );
230226
FD_TEST( ctx->keyswitch );

0 commit comments

Comments
 (0)