Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into initial-canonical…
Browse files Browse the repository at this point in the history
…-block-root
  • Loading branch information
rolfyone committed Mar 6, 2025
2 parents ca04ae4 + 678671a commit bf7ef5a
Showing 1 changed file with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,37 @@ public int dumpHotBlocks(
return 0;
}

@Command(
name = "get-hot-block-slot-to-root",
description = "Writes all the slots and roots of stored hot blocks, will be in hash order.",
mixinStandardHelpOptions = true,
showDefaultValues = true,
abbreviateSynopsis = true,
versionProvider = PicoCliVersionProvider.class,
synopsisHeading = "%n",
descriptionHeading = "%nDescription:%n%n",
optionListHeading = "%nOptions:%n",
footerHeading = "%n",
footer = "Teku is licensed under the Apache License 2.0")
public int getHotBlockSlotToRoot(
@Mixin final BeaconNodeDataOptions beaconNodeDataOptions,
@Mixin final Eth2NetworkOptions eth2NetworkOptions)
throws Exception {
try (final Database database = createDatabase(beaconNodeDataOptions, eth2NetworkOptions);
final Stream<Map.Entry<Bytes, Bytes>> hotBlockStream = database.streamHotBlocksAsSsz()) {
for (final Iterator<Map.Entry<Bytes, Bytes>> hotBlockIterator = hotBlockStream.iterator();
hotBlockIterator.hasNext(); ) {
final Map.Entry<Bytes, Bytes> rootAndHotBlock = hotBlockIterator.next();
final Bytes32 hotBlockRoot = Bytes32.wrap(rootAndHotBlock.getKey());
final Optional<SignedBeaconBlock> hotBlock = database.getHotBlock(hotBlockRoot);
System.out.println(
String.format(
"%s, %s", hotBlock.orElseThrow().getSlot().toString(), hotBlockRoot.toHexString()));
}
}
return 0;
}

@Command(
name = "dump-blob-sidecars",
description = "Writes all blob sidecars in the database as a zip of SSZ files",
Expand Down

0 comments on commit bf7ef5a

Please sign in to comment.