Skip to content

Commit

Permalink
Merge branch '19/snapshot-utils' of https://github.com/Syndica/sig in…
Browse files Browse the repository at this point in the history
…to 19/snapshot-appendvec
  • Loading branch information
0xNineteen committed Dec 1, 2023
2 parents eed2eec + d0b07d1 commit e4f9f2a
Show file tree
Hide file tree
Showing 10 changed files with 3,165 additions and 125 deletions.
96 changes: 58 additions & 38 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -123,43 +123,63 @@ pub fn build(b: *std.Build) void {
const run_step = b.step("run", "Run the app");
run_step.dependOn(&run_cmd.step);

// gossip fuzz testing
// find ./zig-cache/o/* | grep fuzz
// lldb $(above path)
const fuzz_exe = b.addExecutable(.{
.name = "fuzz",
.root_source_file = .{ .path = "src/gossip/fuzz.zig" },
.target = target,
.optimize = optimize,
.main_pkg_path = .{ .path = "src" },
});
fuzz_exe.addModule("base58-zig", base58_module);
fuzz_exe.addModule("zig-network", zig_network_module);
fuzz_exe.addModule("zig-cli", zig_cli_module);
fuzz_exe.addModule("getty", getty_mod);
b.installArtifact(fuzz_exe);
const fuzz_cmd = b.addRunArtifact(fuzz_exe);
b.step("fuzz_gossip", "fuzz gossip").dependOn(&fuzz_cmd.step);

// benchmarking
const benchmark_exe = b.addExecutable(.{
.name = "benchmark",
.root_source_file = .{ .path = "src/benchmarks.zig" },
.target = target,
// TODO: make it work
// .optimize = std.builtin.Mode.ReleaseSafe, // to get decent results - but things get optimized away
.optimize = optimize,
.main_pkg_path = .{ .path = "src" },
});
benchmark_exe.addModule("base58-zig", base58_module);
benchmark_exe.addModule("zig-network", zig_network_module);
benchmark_exe.addModule("zig-cli", zig_cli_module);
benchmark_exe.addModule("getty", getty_mod);
b.installArtifact(benchmark_exe);
const benchmark_cmd = b.addRunArtifact(benchmark_exe);
if (b.args) |args| {
benchmark_cmd.addArgs(args);
const ExecCommand = struct {
name: []const u8,
path: []const u8,
description: []const u8 = "",
};

const exec_commands = [_]ExecCommand{
ExecCommand {
.name = "fuzz",
.path = "src/gossip/fuzz.zig",
.description = "gossip fuzz testing",
},
ExecCommand {
.name = "benchmark",
.path = "src/benchmarks.zig",
.description = "benchmark client",
},
ExecCommand {
.name = "snapshot_utils",
.path = "src/cmd/snapshot_utils.zig",
.description = "snapshot utils",
},
ExecCommand {
.name = "snapshot_verify",
.path = "src/cmd/snapshot_verify.zig",
.description = "verify snapshot account hashes",
},
// tmp :: remove when done with
ExecCommand {
.name = "accounts",
.path = "src/core/accounts_db.zig",
.description = "tmp file",
},
};

for (exec_commands) |command_info| {
const exec = b.addExecutable(.{
.name = command_info.name,
.root_source_file = .{ .path = command_info.path },
.target = target,
.optimize = optimize,
.main_pkg_path = .{ .path = "src" },
});

// TODO: maybe we dont need all these for all bins
exec.addModule("base58-zig", base58_module);
exec.addModule("zig-network", zig_network_module);
exec.addModule("zig-cli", zig_cli_module);
exec.addModule("getty", getty_mod);

// this lets us run it as an exec
b.installArtifact(exec);

const cmd = b.addRunArtifact(exec);
if (b.args) |args| cmd.addArgs(args);
b
.step(command_info.name, command_info.description)
.dependOn(&cmd.step);
}

b.step("benchmark", "benchmark gossip").dependOn(&benchmark_cmd.step);
}
Loading

0 comments on commit e4f9f2a

Please sign in to comment.