Skip to content

Commit 7ca50bc

Browse files
yewmanUbuntu
andauthored
chore(cmd): utils to support slot hash debug tooling (#1203)
# Summary - Add option to specify validator directory - Support genesis downloads instead of relying on local copies - Add ledger tool for checking ledger bounds and trimming to range - Add flag to log the highest completed slot in the shred tracker --------- Co-authored-by: Ubuntu <ubuntu@ip-172-31-33-159.ap-southeast-2.compute.internal>
1 parent 574c10e commit 7ca50bc

File tree

15 files changed

+702
-47
lines changed

15 files changed

+702
-47
lines changed

build.zig

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,12 +286,14 @@ pub fn build(b: *Build) !void {
286286
.target = config.target,
287287
.optimize = config.optimize,
288288
}).module("blst");
289+
const bzip2_mod = genBzip2(b, config.target, config.optimize);
289290

290291
// zig fmt: off
291292
const imports: []const Build.Module.Import = &.{
292293
.{ .name = "base58", .module = base58_mod },
293294
.{ .name = "blst", .module = blst_mod },
294295
.{ .name = "build-options", .module = build_options.createModule() },
296+
.{ .name = "bzip2", .module = bzip2_mod },
295297
.{ .name = "httpz", .module = httpz_mod },
296298
.{ .name = "lsquic", .module = lsquic_mod },
297299
.{ .name = "poseidon", .module = poseidon_mod },
@@ -546,6 +548,47 @@ fn genSqlite(
546548
return mod;
547549
}
548550

551+
fn genBzip2(
552+
b: *Build,
553+
target: std.Build.ResolvedTarget,
554+
optimize: std.builtin.OptimizeMode,
555+
) *Build.Module {
556+
const dep = b.dependency("bzip2", .{});
557+
558+
const lib = b.addLibrary(.{
559+
.name = "bz",
560+
.linkage = .static,
561+
.root_module = b.createModule(.{
562+
.target = target,
563+
.optimize = optimize,
564+
}),
565+
});
566+
lib.addCSourceFiles(.{
567+
.root = dep.path("."),
568+
.files = &.{
569+
"bzlib.c",
570+
"blocksort.c",
571+
"compress.c",
572+
"crctable.c",
573+
"decompress.c",
574+
"huffman.c",
575+
"randtable.c",
576+
},
577+
});
578+
lib.linkLibC();
579+
580+
const translate_c = b.addTranslateC(.{
581+
.root_source_file = dep.path("bzlib.h"),
582+
.target = target,
583+
.optimize = optimize,
584+
.link_libc = true,
585+
});
586+
const mod = translate_c.createModule();
587+
mod.linkLibrary(lib);
588+
589+
return mod;
590+
}
591+
549592
/// Reference/inspiration: https://kristoff.it/blog/improving-your-zls-experience/
550593
fn disableEmitBin(b: *Build) void {
551594
for (b.install_tls.step.dependencies.items) |*install_step_dep| {

build.zig.zon

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,5 +57,9 @@
5757
.url = "git+https://github.com/supranational/blst#806515251de5cfb9761ad12eb2f2f151b1ad0277",
5858
.hash = "blst-0.3.16-fvxk1c82MABYUm65ch0-wpo2CSs1x5TCuBLvgQng0uRC",
5959
},
60+
.bzip2 = .{
61+
.url = "https://github.com/libarchive/bzip2/archive/refs/tags/bzip2-1.0.8.zip",
62+
.hash = "N-V-__8AANChDwAITDmkzIqB-9m_iaOXSquhghM2-AqDFcX8",
63+
},
6064
},
6165
}

src/accountsdb/snapshot/data.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1114,7 +1114,7 @@ pub const SnapshotFiles = struct {
11141114

11151115
var dir_iter = search_dir.iterate();
11161116
while (try dir_iter.next()) |dir_entry| {
1117-
if (dir_entry.kind != .file) continue;
1117+
if (dir_entry.kind != .file and dir_entry.kind != .sym_link) continue;
11181118
const filename = dir_entry.name;
11191119

11201120
if (IncrementalSnapshotFileInfo.parseFileNameTarZst(filename)) |_incremental| {

src/accountsdb/snapshot/load.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ fn insertFromSnapshotArchive(
355355
defer account_data_buf.deinit(allocator);
356356

357357
while (try tar_iter.next()) |tar_file| {
358-
if (tar_file.kind != .file) continue;
358+
if (tar_file.kind != .file and tar_file.kind != .sym_link) continue;
359359

360360
// Read /version
361361
if (std.mem.eql(u8, tar_file.name, "version")) {

0 commit comments

Comments
 (0)