Skip to content

Commit 3122ac4

Browse files
riptlripatel-fd
authored andcommitted
solfuzz: allow building without flatcc
1 parent 905e7b6 commit 3122ac4

File tree

8 files changed

+38
-13
lines changed

8 files changed

+38
-13
lines changed

src/flamenco/runtime/tests/Local.mk

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
ifdef FD_HAS_SECP256K1
22

3-
ifdef FD_HAS_FLATCC
43
$(call add-hdrs,fd_solfuzz.h)
54
$(call add-objs,fd_solfuzz fd_solfuzz_exec,fd_flamenco_test)
65

@@ -26,5 +25,3 @@ endif
2625

2726
run-runtime-backtest: $(OBJDIR)/bin/fd_ledger $(OBJDIR)/bin/firedancer-dev
2827
OBJDIR=$(OBJDIR) src/flamenco/runtime/tests/run_backtest_ci.sh $(BACKTEST_ARGS)
29-
30-
endif

src/flamenco/runtime/tests/fd_dump_pb.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
#ifndef HEADER_fd_src_flamenco_runtime_tests_fd_dump_pb_h
22
#define HEADER_fd_src_flamenco_runtime_tests_fd_dump_pb_h
33

4-
#if FD_HAS_FLATCC
5-
64
/* fd_dump_pb.h provides APIs for dumping syscalls, instructions, transactions, and blocks
75
into a digestable and replayable Protobuf message. This is useful for debugging
86
ledger test mismatches, collecting seed corpora, and gathering real data to test
@@ -211,6 +209,4 @@ fd_dump_elf_to_protobuf( fd_exec_txn_ctx_t * txn_ctx,
211209

212210
FD_PROTOTYPES_END
213211

214-
#endif /* FD_HAS_FLATCC */
215-
216212
#endif /* HEADER_fd_src_flamenco_runtime_tests_fd_dump_pb_h */

src/flamenco/runtime/tests/fd_elf_harness.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
#include "fd_solfuzz.h"
22
#include "fd_solfuzz_private.h"
3-
#include "flatbuffers/generated/flatbuffers_common_builder.h"
4-
#include "flatbuffers/generated/flatbuffers_common_reader.h"
53
#include "generated/elf.pb.h"
64
#include "../../../ballet/sbpf/fd_sbpf_loader.h"
75
#include "../program/fd_bpf_loader_program.h"
86
#include "../../vm/fd_vm_base.h"
97
#include "../../progcache/fd_prog_load.h"
108

9+
#if FD_HAS_FLATCC
10+
#include "flatbuffers/generated/flatbuffers_common_builder.h"
11+
#include "flatbuffers/generated/flatbuffers_common_reader.h"
1112
#include "flatbuffers/generated/elf_reader.h"
1213
#include "flatbuffers/generated/elf_builder.h"
14+
#endif
1315

1416
#define SORT_NAME sort_ulong
1517
#define SORT_KEY_T ulong
@@ -140,6 +142,8 @@ fd_solfuzz_pb_elf_loader_run( fd_solfuzz_runner_t * runner,
140142
return actual_end - (ulong) output_buf;
141143
}
142144

145+
#if FD_HAS_FLATCC
146+
143147
void
144148
fd_solfuzz_fb_elf_loader_build_err_effects( fd_solfuzz_runner_t * runner, int err ) {
145149
FD_TEST( !SOL_COMPAT_NS(ELFLoaderEffects_start_as_root)( runner->fb_builder ) );
@@ -246,3 +250,5 @@ fd_solfuzz_fb_elf_loader_run( fd_solfuzz_runner_t * runner,
246250

247251
return SOL_COMPAT_V2_SUCCESS;
248252
}
253+
254+
#endif /* FD_HAS_FLATCC */

src/flamenco/runtime/tests/fd_harness_common.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ fd_solfuzz_pb_restore_features( fd_features_t * features,
7070
return 1;
7171
}
7272

73+
#if FD_HAS_FLATCC
74+
7375
void
7476
fd_solfuzz_fb_restore_features( fd_features_t * features,
7577
SOL_COMPAT_NS(FeatureSet_table_t) feature_set ) {
@@ -88,3 +90,5 @@ fd_solfuzz_fb_restore_features( fd_features_t * features,
8890
fd_features_set( features, id, 0UL );
8991
}
9092
}
93+
94+
#endif /* FD_HAS_FLATCC */

src/flamenco/runtime/tests/fd_sol_compat.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@
1515
#include "generated/txn.pb.h"
1616
#include "generated/type.pb.h"
1717

18+
#if FD_HAS_FLATCC
1819
#include "flatbuffers/generated/elf_reader.h"
1920
#include "flatbuffers/generated/flatbuffers_common_reader.h"
21+
#endif
2022

2123
#include <assert.h>
2224
#include <errno.h>
@@ -310,6 +312,8 @@ sol_compat_shred_parse_v1( uchar * out,
310312
TODO: Make sol_compat_v2 APIs infallible???
311313
*/
312314

315+
#if FD_HAS_FLATCC
316+
313317
int
314318
sol_compat_elf_loader_v2( uchar * out,
315319
ulong * out_sz,
@@ -327,3 +331,5 @@ sol_compat_elf_loader_v2( uchar * out,
327331

328332
return SOL_COMPAT_V2_SUCCESS;
329333
}
334+
335+
#endif /* FD_HAS_FLATCC */

src/flamenco/runtime/tests/fd_solfuzz.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,12 @@ fd_solfuzz_runner_new( fd_wksp_t * wksp,
117117
runner->runtime_stack = fd_wksp_alloc_laddr( wksp, alignof(fd_runtime_stack_t), sizeof(fd_runtime_stack_t), wksp_tag );
118118
if( FD_UNLIKELY( !runner->runtime_stack ) ) goto bail2;
119119

120+
# if FD_HAS_FLATCC
120121
/* TODO: Consider implementing custom allocators and emitters.
121122
The default builder / emitter uses libc allocators */
122123
int builder_err = flatcc_builder_init( runner->fb_builder );
123124
if( FD_UNLIKELY( builder_err ) ) goto bail2;
125+
# endif
124126

125127
runner->spad = fd_spad_join( fd_spad_new( spad_mem, spad_max ) );
126128
if( FD_UNLIKELY( !runner->spad ) ) goto bail2;
@@ -166,7 +168,9 @@ fd_solfuzz_runner_delete( fd_solfuzz_runner_t * runner ) {
166168
fd_progcache_admin_leave( runner->progcache_admin, &shpcache );
167169
if( shpcache ) fd_wksp_free_laddr( fd_funk_delete( shpcache ) );
168170

171+
# if FD_HAS_FLATCC
169172
flatcc_builder_clear( runner->fb_builder );
173+
# endif
170174

171175
if( runner->spad ) fd_wksp_free_laddr( fd_spad_delete( fd_spad_leave( runner->spad ) ) );
172176
if( runner->banks ) fd_wksp_free_laddr( fd_banks_delete( fd_banks_leave( runner->banks ) ) );

src/flamenco/runtime/tests/fd_solfuzz.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515
#include "../../accdb/fd_accdb_user.h"
1616
#include "../../progcache/fd_progcache_admin.h"
1717
#include "../../progcache/fd_progcache_user.h"
18+
#if FD_HAS_FLATCC
1819
#include "flatcc/flatcc_builder.h"
20+
#endif
1921

2022
/* A fd_solfuzz_runner_t object processes solfuzz inputs. Can be reused
2123
for different inputs, even of different types. Single-thread per
@@ -43,7 +45,9 @@ struct fd_solfuzz_runner {
4345
fd_exec_accounts_t * exec_accounts;
4446
fd_runtime_stack_t * runtime_stack;
4547

48+
# if FD_HAS_FLATCC
4649
flatcc_builder_t fb_builder[1]; /* Persistent flatbuffers builder */
50+
# endif
4751

4852
int enable_vm_tracing;
4953
};
@@ -176,9 +180,11 @@ fd_solfuzz_pb_elf_loader_run( fd_solfuzz_runner_t * runner,
176180
void * output_buf,
177181
ulong output_bufsz );
178182

183+
#if FD_HAS_FLATCC
179184
int
180185
fd_solfuzz_fb_elf_loader_run( fd_solfuzz_runner_t * runner,
181186
void const * input_ );
187+
#endif
182188

183189
int
184190
fd_solfuzz_pb_elf_loader_fixture( fd_solfuzz_runner_t * runner,

src/flamenco/runtime/tests/fd_solfuzz_private.h

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@
1010
#include "../../../ballet/nanopb/pb_decode.h"
1111
#include "generated/context.pb.h"
1212

13+
#if FD_HAS_FLATCC
1314
#include "flatcc/flatcc_builder.h"
1415
#include "flatbuffers/generated/context_reader.h"
16+
#endif
1517

1618
FD_PROTOTYPES_BEGIN
1719

@@ -37,12 +39,14 @@ int
3739
fd_solfuzz_pb_restore_features( fd_features_t * features,
3840
fd_exec_test_feature_set_t const * feature_set );
3941

42+
#if FD_HAS_FLATCC
4043
/* Flatbuffers variant of the above. This function call should never
4144
fail (all passed in features should be supported). Throws FD_LOG_ERR
4245
if any unsupported features are inputted. */
4346
void
4447
fd_solfuzz_fb_restore_features( fd_features_t * features,
4548
SOL_COMPAT_NS(FeatureSet_table_t) feature_set );
49+
#endif
4650

4751
typedef ulong( exec_test_run_pb_fn_t )( fd_solfuzz_runner_t *,
4852
void const *,
@@ -67,17 +71,19 @@ fd_solfuzz_pb_execute_wrapper( fd_solfuzz_runner_t * runner,
6771

6872
typedef int( exec_test_run_fb_fn_t )( fd_solfuzz_runner_t *, void const * );
6973

74+
#if FD_HAS_FLATCC
7075
/* Returns SOL_COMPAT_V2_SUCCESS on success and SOL_COMPAT_V2_FAILURE on
7176
failure */
7277
static inline int
7378
fd_solfuzz_fb_execute_wrapper( fd_solfuzz_runner_t * runner,
7479
void const * input,
7580
exec_test_run_fb_fn_t * exec_test_run_fn ) {
76-
FD_SPAD_FRAME_BEGIN( runner->spad ) {
77-
flatcc_builder_reset( runner->fb_builder );
78-
return exec_test_run_fn( runner, input );
79-
} FD_SPAD_FRAME_END;
81+
FD_SPAD_FRAME_BEGIN( runner->spad ) {
82+
flatcc_builder_reset( runner->fb_builder );
83+
return exec_test_run_fn( runner, input );
84+
} FD_SPAD_FRAME_END;
8085
}
86+
#endif /* FD_HAS_FLATCC */
8187

8288
/* Utils */
8389

0 commit comments

Comments
 (0)