-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.zig
More file actions
1103 lines (943 loc) · 50.7 KB
/
build.zig
File metadata and controls
1103 lines (943 loc) · 50.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
const std = @import("std");
// Although this function looks imperative, it does not perform the build
// directly and instead it mutates the build graph (`b`) that will be then
// executed by an external runner. The functions in `std.Build` implement a DSL
// for defining build steps and express dependencies between them, allowing the
// build runner to parallelize the build automatically (and the cache system to
// know when a step doesn't need to be re-run).
pub fn build(b: *std.Build) void {
// Standard target options allow the person running `zig build` to choose
// what target to build for. Here we do not override the defaults, which
// means any target is allowed, and the default is native. Other options
// for restricting supported target set are available.
const target = b.standardTargetOptions(.{});
// Standard optimization options allow the person running `zig build` to select
// between Debug, ReleaseSafe, ReleaseFast, and ReleaseSmall. Here we do not
// set a preferred release mode, allowing the user to decide how to optimize.
const optimize = b.standardOptimizeOption(.{});
// It's also possible to define more custom flags to toggle optional features
// of this build script using `b.option()`. All defined flags (including
// target and optimize options) will be listed when running `zig build --help`
// in this directory.
// Get the primitives dependency - it handles all crypto lib building internally
const primitives_dep = b.dependency("voltaire", .{
.target = target,
.optimize = optimize,
});
// Use primitives package exported modules (pre-configured with all C libs, include paths, etc.)
const primitives_mod = primitives_dep.module("primitives");
const crypto_mod = primitives_dep.module("crypto");
const precompiles_mod = primitives_dep.module("precompiles");
const blockchain_mod = primitives_dep.module("blockchain");
const jsonrpc_mod = b.addModule("jsonrpc", .{
.root_source_file = primitives_dep.path("packages/voltaire-zig/src/jsonrpc/root.zig"),
.target = target,
.optimize = optimize,
.imports = &.{
.{ .name = "voltaire", .module = primitives_mod },
.{ .name = "crypto", .module = crypto_mod },
},
});
// This creates a module, which represents a collection of source files alongside
// some compilation options, such as optimization mode and linked system libraries.
// Zig modules are the preferred way of making Zig code available to consumers.
// addModule defines a module that we intend to make available for importing
// to our consumers. We must give it a name because a Zig package can expose
// multiple modules and consumers will need to be able to specify which
// module they want to access.
const mod = b.addModule("guillotine_mini", .{
// The root source file is the "entry point" of this module. Users of
// this module will only be able to access public declarations contained
// in this file, which means that if you have declarations that you
// intend to expose to consumers that were defined in other files part
// of this module, you will have to make sure to re-export them from
// the root file.
.root_source_file = b.path("guillotine-mini/src/root.zig"),
// Later on we'll use this module as the root module of a test executable
// which requires us to specify a target.
.target = target,
.imports = &.{
.{ .name = "voltaire", .module = primitives_mod },
.{ .name = "precompiles", .module = precompiles_mod },
.{ .name = "crypto", .module = crypto_mod },
},
});
// Here we define an executable. An executable needs to have a root module
// which needs to expose a `main` function. While we could add a main function
// to the module defined above, it's sometimes preferable to split business
// business logic and the CLI into two separate modules.
//
// If your goal is to create a Zig library for others to use, consider if
// it might benefit from also exposing a CLI tool. A parser library for a
// data serialization format could also bundle a CLI syntax checker, for example.
//
// If instead your goal is to create an executable, consider if users might
// be interested in also being able to embed the core functionality of your
// program in their own executable in order to avoid the overhead involved in
// subprocessing your CLI tool.
//
// Main executable removed - this is a library-only package
// Creates an executable that will run `test` blocks from the provided module.
// Here `mod` needs to define a target, which is why earlier we made sure to
// set the relative field.
const mod_tests = b.addTest(.{
.root_module = mod,
});
// A run step that will run the test executable.
const run_mod_tests = b.addRunArtifact(mod_tests);
// A top level step for running all tests (includes unit tests + spec tests)
const test_step = b.step("test", "Run tests");
test_step.dependOn(&run_mod_tests.step);
// Unit tests only (fast, no spec tests)
const unit_test_step = b.step("unit", "Run unit tests only (fast)");
unit_test_step.dependOn(&run_mod_tests.step);
// Create EVM module (used by spec tests and client EVM adapter)
const evm_mod = b.addModule("evm", .{
.root_source_file = b.path("guillotine-mini/src/root.zig"),
.target = target,
.optimize = optimize,
.imports = &.{
.{ .name = "voltaire", .module = primitives_mod },
.{ .name = "precompiles", .module = precompiles_mod },
.{ .name = "crypto", .module = crypto_mod },
},
});
// Client DB module (database abstraction layer)
const client_db_mod = b.addModule("client_db", .{
.root_source_file = b.path("client/db/root.zig"),
.target = target,
.optimize = optimize,
.imports = &.{
.{ .name = "voltaire", .module = primitives_mod },
},
});
const client_db_tests = b.addTest(.{
.root_module = client_db_mod,
});
const run_client_db_tests = b.addRunArtifact(client_db_tests);
test_step.dependOn(&run_client_db_tests.step);
unit_test_step.dependOn(&run_client_db_tests.step);
const client_db_test_step = b.step("test-db", "Run database abstraction layer tests");
client_db_test_step.dependOn(&run_client_db_tests.step);
// Client Trie module (Merkle Patricia Trie)
const client_trie_mod = b.addModule("client_trie", .{
.root_source_file = b.path("client/trie/root.zig"),
.target = target,
.optimize = optimize,
.imports = &.{
.{ .name = "voltaire", .module = primitives_mod },
.{ .name = "crypto", .module = crypto_mod },
},
});
const client_trie_tests = b.addTest(.{
.root_module = client_trie_mod,
});
const run_client_trie_tests = b.addRunArtifact(client_trie_tests);
test_step.dependOn(&run_client_trie_tests.step);
unit_test_step.dependOn(&run_client_trie_tests.step);
const client_trie_test_step = b.step("test-trie", "Run Merkle Patricia Trie tests");
client_trie_test_step.dependOn(&run_client_trie_tests.step);
// Trie integration tests (ethereum-tests/TrieTests fixtures)
const trie_fixture_mod = b.addModule("trie_fixtures", .{
.root_source_file = b.path("guillotine-mini/test/trie/fixtures.zig"),
.target = target,
.optimize = optimize,
.imports = &.{
.{ .name = "client_trie", .module = client_trie_mod },
.{ .name = "voltaire", .module = primitives_mod },
.{ .name = "crypto", .module = crypto_mod },
},
});
const trie_fixture_tests = b.addTest(.{
.root_module = trie_fixture_mod,
});
const run_trie_fixture_tests = b.addRunArtifact(trie_fixture_tests);
run_trie_fixture_tests.setCwd(b.path("."));
test_step.dependOn(&run_trie_fixture_tests.step);
const trie_fixture_step = b.step("test-trie-fixtures", "Run trie fixture integration tests");
trie_fixture_step.dependOn(&run_trie_fixture_tests.step);
const nethermind_trie_diff_mod = b.addModule("nethermind_trie_diff", .{
.root_source_file = b.path("scripts/nethermind-diff-trie.zig"),
.target = target,
.optimize = optimize,
.imports = &.{
.{ .name = "client_trie", .module = client_trie_mod },
.{ .name = "voltaire", .module = primitives_mod },
.{ .name = "crypto", .module = crypto_mod },
},
});
const nethermind_trie_diff_exe = b.addExecutable(.{
.name = "nethermind_trie_diff",
.root_module = nethermind_trie_diff_mod,
});
const run_nethermind_trie_diff = b.addRunArtifact(nethermind_trie_diff_exe);
const nethermind_diff_step = b.step("nethermind-diff", "Run Nethermind trie differential test");
nethermind_diff_step.dependOn(&run_nethermind_trie_diff.step);
const include_nethermind_diff = b.option(bool, "nethermind-diff", "Run Nethermind diff during zig build test") orelse true;
if (include_nethermind_diff) {
test_step.dependOn(&run_nethermind_trie_diff.step);
}
// Client State module (world state journal + snapshot/restore)
const client_state_mod = b.addModule("client_state", .{
.root_source_file = b.path("client/state/root.zig"),
.target = target,
.optimize = optimize,
.imports = &.{
.{ .name = "voltaire", .module = primitives_mod },
},
});
const client_state_tests = b.addTest(.{
.root_module = client_state_mod,
});
const run_client_state_tests = b.addRunArtifact(client_state_tests);
test_step.dependOn(&run_client_state_tests.step);
unit_test_step.dependOn(&run_client_state_tests.step);
const client_state_test_step = b.step("test-state", "Run world state journal tests");
client_state_test_step.dependOn(&run_client_state_tests.step);
// Client Network module (devp2p networking)
const client_network_mod = b.addModule("client_network", .{
.root_source_file = b.path("client/network/root.zig"),
.target = target,
.optimize = optimize,
.imports = &.{
.{ .name = "voltaire", .module = primitives_mod },
.{ .name = "crypto", .module = crypto_mod },
},
});
const client_network_tests = b.addTest(.{
.root_module = client_network_mod,
});
const run_client_network_tests = b.addRunArtifact(client_network_tests);
test_step.dependOn(&run_client_network_tests.step);
unit_test_step.dependOn(&run_client_network_tests.step);
const client_network_test_step = b.step("test-network", "Run devp2p networking tests");
client_network_test_step.dependOn(&run_client_network_tests.step);
// Client Sync module (full + snap synchronization)
const client_sync_mod = b.addModule("client_sync", .{
.root_source_file = b.path("client/sync/root.zig"),
.target = target,
.optimize = optimize,
.imports = &.{
.{ .name = "voltaire", .module = primitives_mod },
},
});
const client_sync_tests = b.addTest(.{
.root_module = client_sync_mod,
});
const run_client_sync_tests = b.addRunArtifact(client_sync_tests);
test_step.dependOn(&run_client_sync_tests.step);
unit_test_step.dependOn(&run_client_sync_tests.step);
const client_sync_test_step = b.step("test-sync", "Run synchronization tests");
client_sync_test_step.dependOn(&run_client_sync_tests.step);
// Client Blockchain module (chain management)
const client_blockchain_mod = b.addModule("client_blockchain", .{
.root_source_file = b.path("client/blockchain/root.zig"),
.target = target,
.optimize = optimize,
.imports = &.{
.{ .name = "voltaire", .module = primitives_mod },
.{ .name = "blockchain", .module = blockchain_mod },
},
});
const client_blockchain_tests = b.addTest(.{
.root_module = client_blockchain_mod,
});
const run_client_blockchain_tests = b.addRunArtifact(client_blockchain_tests);
test_step.dependOn(&run_client_blockchain_tests.step);
unit_test_step.dependOn(&run_client_blockchain_tests.step);
const client_blockchain_test_step = b.step("test-blockchain", "Run chain management tests");
client_blockchain_test_step.dependOn(&run_client_blockchain_tests.step);
// Client TxPool module (transaction pool)
const client_txpool_mod = b.addModule("client_txpool", .{
.root_source_file = b.path("client/txpool/root.zig"),
.target = target,
.optimize = optimize,
.imports = &.{
.{ .name = "voltaire", .module = primitives_mod },
// Allow txpool code to access HostInterface via the core evm module
.{ .name = "guillotine", .module = mod },
},
});
const client_txpool_tests = b.addTest(.{
.root_module = client_txpool_mod,
});
const run_client_txpool_tests = b.addRunArtifact(client_txpool_tests);
test_step.dependOn(&run_client_txpool_tests.step);
unit_test_step.dependOn(&run_client_txpool_tests.step);
const client_txpool_test_step = b.step("test-txpool", "Run txpool tests");
client_txpool_test_step.dependOn(&run_client_txpool_tests.step);
// Client TxPool benchmark executable (added later after bench_utils_mod is defined)
// Client JSON-RPC module (HTTP/WebSocket server + namespaces)
const client_rpc_mod = b.addModule("client_rpc", .{
.root_source_file = b.path("client/rpc/root.zig"),
.target = target,
.optimize = optimize,
.imports = &.{
.{ .name = "voltaire", .module = primitives_mod },
.{ .name = "crypto", .module = crypto_mod },
.{ .name = "jsonrpc", .module = jsonrpc_mod },
},
});
const client_rpc_tests = b.addTest(.{
.root_module = client_rpc_mod,
});
const run_client_rpc_tests = b.addRunArtifact(client_rpc_tests);
test_step.dependOn(&run_client_rpc_tests.step);
unit_test_step.dependOn(&run_client_rpc_tests.step);
const client_rpc_test_step = b.step("test-rpc", "Run JSON-RPC server tests");
client_rpc_test_step.dependOn(&run_client_rpc_tests.step);
// Client Engine API module (Consensus Layer interface)
const client_engine_mod = b.addModule("client_engine", .{
.root_source_file = b.path("client/engine/root.zig"),
.target = target,
.optimize = optimize,
.imports = &.{
.{ .name = "voltaire", .module = primitives_mod },
.{ .name = "crypto", .module = crypto_mod },
.{ .name = "jsonrpc", .module = jsonrpc_mod },
},
});
const client_engine_tests = b.addTest(.{
.root_module = client_engine_mod,
});
const run_client_engine_tests = b.addRunArtifact(client_engine_tests);
test_step.dependOn(&run_client_engine_tests.step);
unit_test_step.dependOn(&run_client_engine_tests.step);
const client_engine_test_step = b.step("test-engine", "Run Engine API tests");
client_engine_test_step.dependOn(&run_client_engine_tests.step);
// Runner CLI (entry point)
const client_runner_mod = b.addModule("client_runner", .{
.root_source_file = b.path("client/main.zig"),
.target = target,
.optimize = optimize,
.imports = &.{
.{ .name = "voltaire", .module = primitives_mod },
.{ .name = "evm", .module = evm_mod },
},
});
const client_runner_tests = b.addTest(.{
.root_module = client_runner_mod,
});
const run_client_runner_tests = b.addRunArtifact(client_runner_tests);
test_step.dependOn(&run_client_runner_tests.step);
unit_test_step.dependOn(&run_client_runner_tests.step);
const client_runner_test_step = b.step("test-runner", "Run runner CLI tests");
client_runner_test_step.dependOn(&run_client_runner_tests.step);
// Client EVM module (EVM ↔ WorldState integration)
const state_manager_mod = primitives_dep.module("state-manager");
const client_evm_mod = b.addModule("client_evm", .{
.root_source_file = b.path("client/evm/root.zig"),
.target = target,
.optimize = optimize,
.imports = &.{
.{ .name = "voltaire", .module = primitives_mod },
.{ .name = "evm", .module = evm_mod },
.{ .name = "state-manager", .module = state_manager_mod },
},
});
const client_evm_tests = b.addTest(.{
.root_module = client_evm_mod,
});
const run_client_evm_tests = b.addRunArtifact(client_evm_tests);
test_step.dependOn(&run_client_evm_tests.step);
unit_test_step.dependOn(&run_client_evm_tests.step);
const client_evm_test_step = b.step("test-evm-adapter", "Run EVM ↔ WorldState integration tests");
client_evm_test_step.dependOn(&run_client_evm_tests.step);
const bench_utils_mod = b.addModule("bench_utils", .{
.root_source_file = b.path("client/bench_utils.zig"),
.target = target,
.optimize = optimize,
});
// Client Network benchmark (RLPx frame helpers)
const client_network_bench_mod = b.addModule("client_network_bench", .{
.root_source_file = b.path("client/network/rlpx/bench.zig"),
.target = target,
.optimize = optimize,
.imports = &.{
.{ .name = "bench_utils", .module = bench_utils_mod },
.{ .name = "client_network", .module = client_network_mod },
},
});
const client_network_bench = b.addExecutable(.{
.name = "bench_network_rlpx",
.root_module = client_network_bench_mod,
});
const run_client_network_bench = b.addRunArtifact(client_network_bench);
const bench_network_step = b.step("bench-network", "Run devp2p RLPx micro-benchmarks");
bench_network_step.dependOn(&run_client_network_bench.step);
// Client EVM benchmark executable
const client_evm_bench_mod = b.addModule("client_evm_bench", .{
.root_source_file = b.path("client/evm/bench.zig"),
.target = target,
.optimize = optimize,
.imports = &.{
.{ .name = "bench_utils", .module = bench_utils_mod },
.{ .name = "voltaire", .module = primitives_mod },
.{ .name = "evm", .module = evm_mod },
.{ .name = "state-manager", .module = state_manager_mod },
},
});
const client_evm_bench = b.addExecutable(.{
.name = "bench_evm",
.root_module = client_evm_bench_mod,
});
const run_client_evm_bench = b.addRunArtifact(client_evm_bench);
const bench_evm_step = b.step("bench-evm", "Run EVM ↔ WorldState integration benchmarks");
bench_evm_step.dependOn(&run_client_evm_bench.step);
// Client State benchmark executable
const client_state_bench_mod = b.addModule("client_state_bench", .{
.root_source_file = b.path("client/state/bench.zig"),
.target = target,
.optimize = optimize,
.imports = &.{
.{ .name = "bench_utils", .module = bench_utils_mod },
},
});
const client_state_bench = b.addExecutable(.{
.name = "bench_state",
.root_module = client_state_bench_mod,
});
const run_client_state_bench = b.addRunArtifact(client_state_bench);
const bench_state_step = b.step("bench-state", "Run world state journal benchmarks");
bench_state_step.dependOn(&run_client_state_bench.step);
// Client Blockchain benchmark executable
const client_blockchain_bench_mod = b.addModule("client_blockchain_bench", .{
.root_source_file = b.path("client/blockchain/bench.zig"),
.target = target,
.optimize = optimize,
.imports = &.{
.{ .name = "voltaire", .module = primitives_mod },
.{ .name = "blockchain", .module = blockchain_mod },
.{ .name = "bench_utils", .module = bench_utils_mod },
},
});
const client_blockchain_bench = b.addExecutable(.{
.name = "bench_blockchain",
.root_module = client_blockchain_bench_mod,
});
const run_client_blockchain_bench = b.addRunArtifact(client_blockchain_bench);
const bench_blockchain_step = b.step("bench-blockchain", "Run chain management benchmarks");
bench_blockchain_step.dependOn(&run_client_blockchain_bench.step);
// Client DB benchmark executable
const client_db_bench_mod = b.addModule("client_db_bench", .{
.root_source_file = b.path("client/db/bench.zig"),
.target = target,
.optimize = optimize,
.imports = &.{
.{ .name = "voltaire", .module = primitives_mod },
.{ .name = "bench_utils", .module = bench_utils_mod },
},
});
const client_db_bench = b.addExecutable(.{
.name = "bench_db",
.root_module = client_db_bench_mod,
});
const run_client_db_bench = b.addRunArtifact(client_db_bench);
const bench_db_step = b.step("bench-db", "Run database abstraction layer benchmarks");
bench_db_step.dependOn(&run_client_db_bench.step);
// Client DB-006 sorted view benchmark executable
const client_db006_bench_mod = b.addModule("client_db006_bench", .{
.root_source_file = b.path("client/db/bench_db006.zig"),
.target = target,
.optimize = optimize,
.imports = &.{
.{ .name = "voltaire", .module = primitives_mod },
},
});
const client_db006_bench = b.addExecutable(.{
.name = "bench_db006",
.root_module = client_db006_bench_mod,
});
const run_client_db006_bench = b.addRunArtifact(client_db006_bench);
const bench_db006_step = b.step("bench-db006", "Run DB-006 sorted view / range query benchmarks");
bench_db006_step.dependOn(&run_client_db006_bench.step);
// Client DB-007 ordered iteration benchmark executable
const client_db007_bench_mod = b.addModule("client_db007_bench", .{
.root_source_file = b.path("client/db/bench_db007.zig"),
.target = target,
.optimize = optimize,
.imports = &.{
.{ .name = "voltaire", .module = primitives_mod },
},
});
const client_db007_bench = b.addExecutable(.{
.name = "bench_db007",
.root_module = client_db007_bench_mod,
});
const run_client_db007_bench = b.addRunArtifact(client_db007_bench);
const bench_db007_step = b.step("bench-db007", "Run DB-007 ordered iteration / MergeSortIterator benchmarks");
bench_db007_step.dependOn(&run_client_db007_bench.step);
// Client Trie benchmark executable
const client_trie_bench_mod = b.addModule("client_trie_bench", .{
.root_source_file = b.path("client/trie/bench.zig"),
.target = target,
.optimize = optimize,
.imports = &.{
.{ .name = "voltaire", .module = primitives_mod },
.{ .name = "crypto", .module = crypto_mod },
},
});
const client_trie_bench = b.addExecutable(.{
.name = "bench_trie",
.root_module = client_trie_bench_mod,
});
const run_client_trie_bench = b.addRunArtifact(client_trie_bench);
const bench_trie_step = b.step("bench-trie", "Run Merkle Patricia Trie benchmarks");
bench_trie_step.dependOn(&run_client_trie_bench.step);
// Client TxPool benchmark executable (depends on bench_utils)
const client_txpool_bench_mod = b.addModule("client_txpool_bench", .{
.root_source_file = b.path("client/txpool/bench.zig"),
.target = target,
.optimize = optimize,
.imports = &.{
.{ .name = "bench_utils", .module = bench_utils_mod },
.{ .name = "voltaire", .module = primitives_mod },
},
});
const client_txpool_bench = b.addExecutable(.{
.name = "bench_txpool",
.root_module = client_txpool_bench_mod,
});
const run_client_txpool_bench = b.addRunArtifact(client_txpool_bench);
const bench_txpool_step = b.step("bench-txpool", "Run transaction pool benchmarks");
bench_txpool_step.dependOn(&run_client_txpool_bench.step);
const install_client_txpool_bench = b.addInstallArtifact(client_txpool_bench, .{});
bench_txpool_step.dependOn(&install_client_txpool_bench.step);
const client_txpool_bench_tests = b.addTest(.{
.root_module = client_txpool_bench_mod,
});
const run_client_txpool_bench_tests = b.addRunArtifact(client_txpool_bench_tests);
test_step.dependOn(&run_client_txpool_bench_tests.step);
unit_test_step.dependOn(&run_client_txpool_bench_tests.step);
const client_txpool_bench_test_step = b.step("test-txpool-bench", "Run txpool benchmark module tests");
client_txpool_bench_test_step.dependOn(&run_client_txpool_bench_tests.step);
// Add execution-specs tests
// Build option to force refreshing the generated Python fixtures
const refresh_specs_opt = b.option(bool, "refresh-specs", "Force refresh of execution-specs fixtures");
const force_refresh = refresh_specs_opt orelse false;
// First, add a build step to generate test fixtures using Python fill command
const fill_specs = if (force_refresh)
b.addSystemCommand(&.{
"sh",
"-c",
// Force refresh: always run fill (with --clean) for all deployed forks
"cd execution-specs && " ++ "uv run --extra fill --extra test fill tests/eest --output tests/eest/static/state_tests --clean",
})
else
b.addSystemCommand(&.{
"sh",
"-c",
// No-op only if all fork fixtures are present; otherwise fill all
"OUT_DIR=execution-specs/tests/eest/static/state_tests; " ++ "if [ -d \"$OUT_DIR\" ] && find \"$OUT_DIR\" -type f -name '*.json' | grep -q .; then " ++ "echo 'Specs already built, skipping fill'; " ++ "else cd execution-specs && " ++ "uv run --extra fill --extra test fill tests/eest --output tests/eest/static/state_tests --clean; fi",
});
// Generate Zig test wrappers from JSON fixtures for STATE TESTS
const generate_zig_state_tests = b.addSystemCommand(&.{
"python3",
"scripts/generate_spec_tests.py",
"state",
});
generate_zig_state_tests.step.dependOn(&fill_specs.step);
// Generate Zig test wrappers from JSON fixtures for BLOCKCHAIN TESTS
const generate_zig_blockchain_tests = b.addSystemCommand(&.{
"python3",
"scripts/generate_spec_tests.py",
"blockchain",
});
generate_zig_blockchain_tests.step.dependOn(&fill_specs.step);
// Update test/specs/root.zig with generated test imports for STATE TESTS
const update_spec_root_state = b.addSystemCommand(&.{
"python3",
"scripts/update_spec_root.py",
"state",
});
update_spec_root_state.step.dependOn(&generate_zig_state_tests.step);
// Update test/specs/root.zig with generated test imports for BLOCKCHAIN TESTS
const update_spec_root_blockchain = b.addSystemCommand(&.{
"python3",
"scripts/update_spec_root.py",
"blockchain",
});
update_spec_root_blockchain.step.dependOn(&generate_zig_blockchain_tests.step);
const spec_runner_mod = b.addModule("spec_runner", .{
.root_source_file = b.path("test/specs/root.zig"),
.target = target,
.optimize = optimize,
.imports = &.{
.{ .name = "evm", .module = evm_mod },
.{ .name = "voltaire", .module = primitives_mod },
.{ .name = "client_blockchain", .module = client_blockchain_mod },
},
});
// Create separate test executables for state tests and blockchain tests
const spec_tests_state = b.addTest(.{
.root_module = spec_runner_mod,
.test_runner = .{
.path = b.path("guillotine-mini/test_runner.zig"),
.mode = .simple,
},
});
const spec_tests_blockchain = b.addTest(.{
.root_module = spec_runner_mod,
.test_runner = .{
.path = b.path("guillotine-mini/test_runner.zig"),
.mode = .simple,
},
});
// Make spec test compilation depend on test generation pipeline
spec_tests_state.step.dependOn(&update_spec_root_state.step);
spec_tests_blockchain.step.dependOn(&update_spec_root_blockchain.step);
// Run artifacts for state tests
const run_spec_tests_state = b.addRunArtifact(spec_tests_state);
run_spec_tests_state.setCwd(b.path(".")); // Set working directory to project root for test file paths
run_spec_tests_state.setEnvironmentVariable("TEST_TYPE", "state");
// Run artifacts for blockchain tests
const run_spec_tests_blockchain = b.addRunArtifact(spec_tests_blockchain);
run_spec_tests_blockchain.setCwd(b.path(".")); // Set working directory to project root for test file paths
run_spec_tests_blockchain.setEnvironmentVariable("TEST_TYPE", "blockchain");
// Main spec test step - runs STATE TESTS ONLY by default
const spec_test_step = b.step("specs", "Run execution-specs STATE tests");
spec_test_step.dependOn(&run_spec_tests_state.step);
// Blockchain test step - runs BLOCKCHAIN TESTS ONLY
const spec_blockchain_test_step = b.step("specs-blockchain", "Run execution-specs BLOCKCHAIN tests");
spec_blockchain_test_step.dependOn(&run_spec_tests_blockchain.step);
// Add state tests to main test step (default behavior)
test_step.dependOn(&run_spec_tests_state.step);
// Create hardfork-specific test suites
const hardforks = [_]struct { name: []const u8, desc: []const u8 }{
.{ .name = "frontier", .desc = "Frontier hardfork tests - runs all frontier-* sub-targets" },
.{ .name = "homestead", .desc = "Homestead hardfork tests" },
.{ .name = "byzantium", .desc = "Byzantium hardfork tests" },
.{ .name = "constantinople", .desc = "Constantinople hardfork tests" },
.{ .name = "istanbul", .desc = "Istanbul hardfork tests" },
.{ .name = "berlin", .desc = "Berlin hardfork tests (EIP-2929, EIP-2930) - runs all berlin-* sub-targets" },
.{ .name = "paris", .desc = "Paris/Merge hardfork tests" },
.{ .name = "shanghai", .desc = "Shanghai hardfork tests (EIP-3651, EIP-3855, EIP-3860, EIP-4895)" },
.{ .name = "cancun", .desc = "Cancun hardfork tests (EIP-1153, EIP-4788, EIP-4844, EIP-5656, EIP-6780, EIP-7516) - runs all cancun-* sub-targets" },
.{ .name = "prague", .desc = "Prague hardfork tests - runs all prague-* sub-targets" },
.{ .name = "osaka", .desc = "Osaka hardfork tests - runs all osaka-* sub-targets" },
};
// Break up large hardforks into smaller sub-targets for faster test iteration
// Define a common struct type for all sub-targets
const SubTarget = struct { name: []const u8, filter: []const u8, desc: []const u8 };
// Berlin has 2772 tests in tx_intrinsic_gas alone
const berlin_sub_targets = [_]SubTarget{
.{ .name = "berlin-acl", .filter = "berlin.*acl.*account_storage_warm_cold_state", .desc = "Berlin EIP-2930 access list account storage tests" },
.{ .name = "berlin-intrinsic-gas-cost", .filter = "berlin.*acl.*transaction_intrinsic_gas_cost", .desc = "Berlin EIP-2930 transaction intrinsic gas cost tests" },
.{ .name = "berlin-intrinsic-type0", .filter = "berlin.*tx_intrinsic_gas.*tx_type_0", .desc = "Berlin EIP-2930 intrinsic gas type 0 transaction tests" },
.{ .name = "berlin-intrinsic-type1", .filter = "berlin.*tx_intrinsic_gas.*tx_type_1", .desc = "Berlin EIP-2930 intrinsic gas type 1 transaction tests" },
};
// Frontier has 12k+ lines in stack_overflow.zig and 6k+ in push.zig
const frontier_sub_targets = [_]SubTarget{
.{ .name = "frontier-precompiles", .filter = "frontier.*precompile", .desc = "Frontier precompile tests" },
.{ .name = "frontier-identity", .filter = "frontier.*identity", .desc = "Frontier identity precompile tests" },
.{ .name = "frontier-create", .filter = "frontier.*create", .desc = "Frontier CREATE tests" },
.{ .name = "frontier-call", .filter = "frontier.*call", .desc = "Frontier CALL/CALLCODE tests" },
.{ .name = "frontier-calldata", .filter = "frontier.*calldata", .desc = "Frontier calldata opcode tests" },
.{ .name = "frontier-dup", .filter = "frontier.*dup", .desc = "Frontier DUP tests" },
.{ .name = "frontier-push", .filter = "frontier.*push", .desc = "Frontier PUSH tests" },
.{ .name = "frontier-stack", .filter = "frontier.*stack_overflow", .desc = "Frontier stack overflow tests" },
.{ .name = "frontier-opcodes", .filter = "frontier.*opcodes.*all_opcodes", .desc = "Frontier all opcodes tests" },
};
// Cancun has 20k+ lines in sufficient_balance_blob_tx.zig
// NOTE: Filters use simple substring matching, not regex
const cancun_sub_targets = [_]SubTarget{
.{ .name = "cancun-tstore-basic", .filter = "eip1153_tstore_test_tstorage_py", .desc = "Cancun EIP-1153 basic TLOAD/TSTORE tests" },
.{ .name = "cancun-tstore-reentrancy", .filter = "eip1153_tstore_test_tstore_reentrancy", .desc = "Cancun EIP-1153 reentrancy tests" },
// Split contexts into smaller chunks (was 410 tests, now ~60-80 each)
.{ .name = "cancun-tstore-contexts-execution", .filter = "tstorage_execution_contexts", .desc = "Cancun EIP-1153 execution context tests (60 tests)" },
.{ .name = "cancun-tstore-contexts-tload-reentrancy", .filter = "tload_reentrancy", .desc = "Cancun EIP-1153 tload reentrancy tests (48 tests)" },
.{ .name = "cancun-tstore-contexts-reentrancy", .filter = "tstorage_reentrancy_contexts", .desc = "Cancun EIP-1153 reentrancy context tests (20 tests)" },
.{ .name = "cancun-tstore-contexts-create", .filter = "tstorage_create_contexts", .desc = "Cancun EIP-1153 create context tests (20 tests)" },
.{ .name = "cancun-tstore-contexts-selfdestruct", .filter = "tstorage_selfdestruct", .desc = "Cancun EIP-1153 selfdestruct tests (12 tests)" },
.{ .name = "cancun-tstore-contexts-clear", .filter = "tstorage_clear_after_tx", .desc = "Cancun EIP-1153 clear after tx tests (4 tests)" },
.{ .name = "cancun-mcopy", .filter = "eip5656_mcopy", .desc = "Cancun EIP-5656 MCOPY tests" },
// Split selfdestruct into smaller chunks (was 1166 tests, now ~50-300 each)
.{ .name = "cancun-selfdestruct-basic", .filter = "test_selfdestruct_py", .desc = "Cancun EIP-6780 basic SELFDESTRUCT tests (306 tests)" },
.{ .name = "cancun-selfdestruct-collision", .filter = "dynamic_create2_selfdestruct_collision", .desc = "Cancun EIP-6780 create2 collision tests (52 tests)" },
.{ .name = "cancun-selfdestruct-reentrancy", .filter = "reentrancy_selfdestruct_revert", .desc = "Cancun EIP-6780 reentrancy revert tests (36 tests)" },
.{ .name = "cancun-selfdestruct-revert", .filter = "test_selfdestruct_revert_py", .desc = "Cancun EIP-6780 revert tests (12 tests)" },
.{ .name = "cancun-blobbasefee", .filter = "eip7516_blobgasfee", .desc = "Cancun EIP-7516 BLOBBASEFEE tests" },
// Split blob precompile into smaller chunks (was 1073 tests, now ~50-310 each)
.{ .name = "cancun-blob-precompile-basic", .filter = "test_point_evaluation_precompile_py", .desc = "Cancun EIP-4844 point evaluation basic tests (310 tests)" },
.{ .name = "cancun-blob-precompile-gas", .filter = "test_point_evaluation_precompile_gas_py", .desc = "Cancun EIP-4844 point evaluation gas tests (48 tests)" },
// Split blob opcodes into smaller chunks (was 282 tests, now ~25-75 each)
.{ .name = "cancun-blob-opcodes-basic", .filter = "test_blobhash_opcode_py__test_blobhash_", .desc = "Cancun EIP-4844 BLOBHASH basic tests (75 tests)" },
.{ .name = "cancun-blob-opcodes-contexts", .filter = "blobhash_opcode_contexts", .desc = "Cancun EIP-4844 BLOBHASH context tests (23 tests)" },
.{ .name = "cancun-blob-tx-small", .filter = "blob_tx_attribute", .desc = "Cancun EIP-4844 small blob transaction tests" },
.{ .name = "cancun-blob-tx-subtraction", .filter = "blob_gas_subtraction_tx", .desc = "Cancun EIP-4844 blob gas subtraction tests" },
.{ .name = "cancun-blob-tx-insufficient", .filter = "insufficient_balance_blob_tx", .desc = "Cancun EIP-4844 insufficient balance tests" },
.{ .name = "cancun-blob-tx-sufficient", .filter = "sufficient_balance_blob_tx", .desc = "Cancun EIP-4844 sufficient balance tests" },
.{ .name = "cancun-blob-tx-valid-combos", .filter = "valid_blob_tx_combinations", .desc = "Cancun EIP-4844 valid combinations tests" },
};
// Prague has 4540 lines in transaction_validity_type_1_type_2.zig and many BLS12-381 tests
const prague_sub_targets = [_]SubTarget{
.{ .name = "prague-calldata-cost-type0", .filter = "prague.*eip7623.*type_0", .desc = "Prague EIP-7623 calldata cost type 0 tests" },
.{ .name = "prague-calldata-cost-type1-2", .filter = "prague.*eip7623.*type_1_type_2", .desc = "Prague EIP-7623 calldata cost type 1/2 tests" },
.{ .name = "prague-calldata-cost-type3", .filter = "prague.*eip7623.*type_3", .desc = "Prague EIP-7623 calldata cost type 3 tests" },
.{ .name = "prague-calldata-cost-type4", .filter = "prague.*eip7623.*type_4", .desc = "Prague EIP-7623 calldata cost type 4 tests" },
.{ .name = "prague-calldata-cost-refunds", .filter = "prague.*eip7623.*(refunds|execution_gas)", .desc = "Prague EIP-7623 refunds and gas tests" },
.{ .name = "prague-bls-g1", .filter = "prague.*bls12.*(g1add|g1mul|g1msm)", .desc = "Prague EIP-2537 BLS12-381 G1 tests" },
.{ .name = "prague-bls-g2", .filter = "prague.*bls12.*(g2add|g2mul|g2msm)", .desc = "Prague EIP-2537 BLS12-381 G2 tests" },
.{ .name = "prague-bls-pairing", .filter = "prague.*bls12.*pairing", .desc = "Prague EIP-2537 BLS12-381 pairing tests" },
.{ .name = "prague-bls-map", .filter = "prague.*bls12.*map", .desc = "Prague EIP-2537 BLS12-381 map tests" },
.{ .name = "prague-bls-misc", .filter = "prague.*bls12.*(variable_length|before_fork)", .desc = "Prague EIP-2537 BLS12-381 misc tests" },
.{ .name = "prague-setcode-calls", .filter = "prague.*eip7702.*calls", .desc = "Prague EIP-7702 set code call tests" },
.{ .name = "prague-setcode-gas", .filter = "prague.*eip7702.*gas", .desc = "Prague EIP-7702 set code gas tests" },
.{ .name = "prague-setcode-txs", .filter = "prague.*eip7702.*set_code_txs[^_2]", .desc = "Prague EIP-7702 set code transaction tests" },
.{ .name = "prague-setcode-advanced", .filter = "prague.*eip7702.*set_code_txs_2", .desc = "Prague EIP-7702 advanced set code tests" },
};
// Osaka has 5836 lines in modexp_variable_gas_cost.zig
const osaka_sub_targets = [_]SubTarget{
.{ .name = "osaka-modexp-variable-gas", .filter = "osaka.*modexp_variable_gas_cost", .desc = "Osaka EIP-7883 modexp variable gas tests" },
.{ .name = "osaka-modexp-vectors-eip", .filter = "osaka.*vectors_from_eip", .desc = "Osaka EIP-7883 modexp vectors from EIP tests" },
.{ .name = "osaka-modexp-vectors-legacy", .filter = "osaka.*vectors_from_legacy", .desc = "Osaka EIP-7883 modexp vectors from legacy tests" },
.{ .name = "osaka-modexp-misc", .filter = "osaka.*modexp.*(call_operations|gas_usage|invalid|entry_points|exceed)", .desc = "Osaka EIP-7883 modexp misc tests" },
.{ .name = "osaka-other", .filter = "osaka.*(eip7823|eip7825)", .desc = "Osaka other EIP tests" },
};
// Shanghai has 558 tests - split initcode (was 558 tests, now ~160-180 each)
const shanghai_sub_targets = [_]SubTarget{
.{ .name = "shanghai-push0", .filter = "eip3855_push0", .desc = "Shanghai EIP-3855 PUSH0 tests" },
.{ .name = "shanghai-warmcoinbase", .filter = "eip3651_warm_coinbase", .desc = "Shanghai EIP-3651 warm coinbase tests" },
.{ .name = "shanghai-initcode-basic", .filter = "test_initcode_py", .desc = "Shanghai EIP-3860 initcode basic tests (162 tests)" },
.{ .name = "shanghai-initcode-eof", .filter = "with_eof", .desc = "Shanghai EIP-3860 initcode EOF tests (24 tests)" },
.{ .name = "shanghai-withdrawals", .filter = "eip4895_withdrawals", .desc = "Shanghai EIP-4895 withdrawal tests" },
};
// Byzantium has 352 tests - all modexp precompile
const byzantium_sub_targets = [_]SubTarget{
.{ .name = "byzantium-modexp", .filter = "eip198_modexp", .desc = "Byzantium EIP-198 modexp precompile tests (352 tests)" },
};
// Constantinople has 508 tests - split by EIP (was 508 tests, now ~250 each)
const constantinople_sub_targets = [_]SubTarget{
.{ .name = "constantinople-bitshift", .filter = "eip145_bitwise_shift", .desc = "Constantinople EIP-145 bitwise shift tests (~250 tests)" },
.{ .name = "constantinople-create2", .filter = "eip1014_create2", .desc = "Constantinople EIP-1014 CREATE2 tests (~250 tests)" },
};
// Istanbul has 2165 tests - split by EIP (was 2165 tests, now smaller chunks)
const istanbul_sub_targets = [_]SubTarget{
.{ .name = "istanbul-blake2", .filter = "eip152_blake2", .desc = "Istanbul EIP-152 BLAKE2 precompile tests" },
.{ .name = "istanbul-chainid", .filter = "eip1344_chainid", .desc = "Istanbul EIP-1344 CHAINID tests" },
};
// Helper to create sub-targets for a hardfork
const SubTargetConfig = struct {
targets: []const SubTarget,
fork_name: []const u8,
};
const sub_target_configs = [_]SubTargetConfig{
.{ .targets = &berlin_sub_targets, .fork_name = "berlin" },
.{ .targets = &frontier_sub_targets, .fork_name = "frontier" },
.{ .targets = &cancun_sub_targets, .fork_name = "cancun" },
.{ .targets = &prague_sub_targets, .fork_name = "prague" },
.{ .targets = &osaka_sub_targets, .fork_name = "osaka" },
.{ .targets = &shanghai_sub_targets, .fork_name = "shanghai" },
.{ .targets = &byzantium_sub_targets, .fork_name = "byzantium" },
.{ .targets = &constantinople_sub_targets, .fork_name = "constantinople" },
.{ .targets = &istanbul_sub_targets, .fork_name = "istanbul" },
};
var fork_sub_steps_map = std.StringHashMap(std.ArrayList(*std.Build.Step)).init(b.allocator);
defer {
var it = fork_sub_steps_map.iterator();
while (it.next()) |entry| {
entry.value_ptr.deinit(b.allocator);
}
fork_sub_steps_map.deinit();
}
// Initialize arrays for each fork
for (sub_target_configs) |config| {
const steps = std.ArrayList(*std.Build.Step){};
fork_sub_steps_map.put(config.fork_name, steps) catch @panic("OOM");
}
// Create all sub-targets
for (sub_target_configs) |config| {
const steps = fork_sub_steps_map.getPtr(config.fork_name).?;
for (config.targets) |sub_target| {
const sub_tests = b.addTest(.{
.root_module = spec_runner_mod,
.test_runner = .{
.path = b.path("guillotine-mini/test_runner.zig"),
.mode = .simple,
},
});
sub_tests.step.dependOn(&update_spec_root_state.step);
const run_sub_tests = b.addRunArtifact(sub_tests);
run_sub_tests.setCwd(b.path("."));
run_sub_tests.setEnvironmentVariable("TEST_FILTER", sub_target.filter);
run_sub_tests.setEnvironmentVariable("TEST_TYPE", "state");
const step_name = b.fmt("specs-{s}", .{sub_target.name});
const sub_step = b.step(step_name, sub_target.desc);
sub_step.dependOn(&run_sub_tests.step);
steps.append(b.allocator, &run_sub_tests.step) catch @panic("OOM");
}
}
for (hardforks) |fork| {
const fork_tests = b.addTest(.{
.root_module = spec_runner_mod,
.test_runner = .{
.path = b.path("guillotine-mini/test_runner.zig"),
.mode = .simple,
},
});
fork_tests.step.dependOn(&update_spec_root_state.step);
const run_fork_tests = b.addRunArtifact(fork_tests);
run_fork_tests.setCwd(b.path("."));
run_fork_tests.setEnvironmentVariable("TEST_FILTER", fork.name);
run_fork_tests.setEnvironmentVariable("TEST_TYPE", "state");
const step_name = b.fmt("specs-{s}", .{fork.name});
const fork_step = b.step(step_name, fork.desc);
// For hardforks with sub-targets, make the main target depend on all sub-targets
if (fork_sub_steps_map.get(fork.name)) |sub_steps| {
for (sub_steps.items) |sub_step| {
fork_step.dependOn(sub_step);
}
} else {
fork_step.dependOn(&run_fork_tests.step);
}
}
// Create EIP-specific test suites for hardforks without sub-targets
// (Berlin, Frontier, Cancun, Prague, Osaka, Shanghai, Byzantium, Constantinople, and Istanbul now have sub-targets defined above)
// This array is now empty - all test suites have been converted to use sub-targets for better granularity
const eip_suites = [_]struct { name: []const u8, filter: []const u8, desc: []const u8 }{};
for (eip_suites) |suite| {
const eip_tests = b.addTest(.{
.root_module = spec_runner_mod,
.test_runner = .{
.path = b.path("guillotine-mini/test_runner.zig"),
.mode = .simple,
},
});
eip_tests.step.dependOn(&update_spec_root_state.step);
const run_eip_tests = b.addRunArtifact(eip_tests);
run_eip_tests.setCwd(b.path("."));
run_eip_tests.setEnvironmentVariable("TEST_FILTER", suite.filter);
run_eip_tests.setEnvironmentVariable("TEST_TYPE", "state");
const step_name = b.fmt("specs-{s}", .{suite.name});
const eip_step = b.step(step_name, suite.desc);
eip_step.dependOn(&run_eip_tests.step);
}
// Add trace test executable
const trace_test_mod = b.addModule("trace_test_mod", .{
.root_source_file = b.path("test_trace.zig"),
.target = target,
.optimize = optimize,
.imports = &.{
.{ .name = "guillotine", .module = mod },
.{ .name = "voltaire", .module = primitives_mod },
},
});
const trace_test = b.addExecutable(.{
.name = "trace_test",
.root_module = trace_test_mod,
});
const run_trace_test = b.addRunArtifact(trace_test);
const trace_test_step = b.step("test-trace", "Run trace capture test");
trace_test_step.dependOn(&run_trace_test.step);
// Interactive test runner
const interactive_spec_tests = b.addTest(.{
.root_module = spec_runner_mod,
.test_runner = .{
.path = b.path("interactive_test_runner.zig"),
.mode = .simple,
},
});
const run_interactive_tests = b.addRunArtifact(interactive_spec_tests);
run_interactive_tests.setCwd(b.path(".")); // Set working directory to project root for test file paths
const interactive_test_step = b.step("test-watch", "Run interactive test runner");
interactive_test_step.dependOn(&run_interactive_tests.step);
// WASM build target with ReleaseSmall optimization
// Using wasi because primitives package includes C libraries (BLST, C-KZG, BN254)
const wasm_target = b.resolveTargetQuery(.{
.cpu_arch = .wasm32,
.os_tag = .wasi,
});
// Get WASM-specific primitives modules from dependency
const wasm_primitives_dep = b.dependency("voltaire", .{
.target = wasm_target,
.optimize = .ReleaseSmall,