From 6f516642799dc24e3b1774cc323e766a073c5786 Mon Sep 17 00:00:00 2001 From: Hellblazer Date: Sat, 25 May 2024 18:32:52 -0700 Subject: [PATCH] reduce beacon publishing logging --- .../java/com/salesforce/apollo/choam/CHOAM.java | 16 +++++++++++----- .../salesforce/apollo/choam/GenesisAssembly.java | 2 +- .../com/salesforce/apollo/choam/Producer.java | 8 ++++---- .../com/salesforce/apollo/choam/ViewContext.java | 4 ++-- .../apollo/choam/GenesisAssemblyTest.java | 2 +- 5 files changed, 19 insertions(+), 13 deletions(-) diff --git a/choam/src/main/java/com/salesforce/apollo/choam/CHOAM.java b/choam/src/main/java/com/salesforce/apollo/choam/CHOAM.java index b7e3da907..b9e494963 100644 --- a/choam/src/main/java/com/salesforce/apollo/choam/CHOAM.java +++ b/choam/src/main/java/com/salesforce/apollo/choam/CHOAM.java @@ -542,10 +542,16 @@ public Block produce(ULong height, Digest prev, Executions executions, HashedBlo } @Override - public void publish(Digest hash, CertifiedBlock cb) { - log.info("Publishing: {} hash: {} height: {} certifications: {} on: {}", cb.getBlock().getBodyCase(), - hash, ULong.valueOf(cb.getBlock().getHeader().getHeight()), cb.getCertificationsCount(), - params.member().getId()); + public void publish(Digest hash, CertifiedBlock cb, boolean beacon) { + if (beacon) { + log.trace("Publishing beacon: {} hash: {} height: {} certifications: {} on: {}", + cb.getBlock().getBodyCase(), hash, ULong.valueOf(cb.getBlock().getHeader().getHeight()), + cb.getCertificationsCount(), params.member().getId()); + } else { + log.info("Publishing: {} hash: {} height: {} certifications: {} on: {}", + cb.getBlock().getBodyCase(), hash, ULong.valueOf(cb.getBlock().getHeader().getHeight()), + cb.getCertificationsCount(), params.member().getId()); + } combine.publish(cb, true); } @@ -1022,7 +1028,7 @@ public interface BlockProducer { Block produce(ULong height, Digest prev, Executions executions, HashedBlock checkpoint); - void publish(Digest hash, CertifiedBlock cb); + void publish(Digest hash, CertifiedBlock cb, boolean beacon); Block reconfigure(Map joining, Digest nextViewId, HashedBlock previous, HashedBlock checkpoint); } diff --git a/choam/src/main/java/com/salesforce/apollo/choam/GenesisAssembly.java b/choam/src/main/java/com/salesforce/apollo/choam/GenesisAssembly.java index c8d4e41a4..cebbb1d38 100644 --- a/choam/src/main/java/com/salesforce/apollo/choam/GenesisAssembly.java +++ b/choam/src/main/java/com/salesforce/apollo/choam/GenesisAssembly.java @@ -207,7 +207,7 @@ public void publish() { .sorted(Comparator.comparing(e -> e.getKey().getId())) .map(Map.Entry::getValue) .forEach(v -> b.addCertifications(v.getWitness())); - view.publish(new HashedCertifiedBlock(params().digestAlgorithm(), b.build())); + view.publish(new HashedCertifiedBlock(params().digestAlgorithm(), b.build()), false); controller.completeIt(); log.info("Genesis block: {} published with {} witnesses for: {} on: {}", reconfiguration.hash, witnesses.size(), view.context().getId(), params().member().getId()); diff --git a/choam/src/main/java/com/salesforce/apollo/choam/Producer.java b/choam/src/main/java/com/salesforce/apollo/choam/Producer.java index ebdb26d26..28519e234 100644 --- a/choam/src/main/java/com/salesforce/apollo/choam/Producer.java +++ b/choam/src/main/java/com/salesforce/apollo/choam/Producer.java @@ -312,15 +312,15 @@ private void publish(PendingBlock p) { this.publish(p, false); } - private void publish(PendingBlock p, boolean force) { + private void publish(PendingBlock p, boolean beacon) { assert p.witnesses.size() >= params().majority() : "Publishing non majority block"; var publish = p.published.compareAndSet(false, true); - if (!publish && !force) { + if (!publish && !beacon) { log.trace("Already published: {} hash: {} height: {} witnesses: {} on: {}", p.block.block.getBodyCase(), p.block.hash, p.block.height(), p.witnesses.values().size(), params().member().getId()); return; } - log.trace("Publishing {}pending: {} hash: {} height: {} witnesses: {} on: {}", force ? "(forced) " : "", + log.trace("Publishing {}pending: {} hash: {} height: {} witnesses: {} on: {}", beacon ? "(beacon) " : "", p.block.block.getBodyCase(), p.block.hash, p.block.height(), p.witnesses.values().size(), params().member().getId()); final var cb = CertifiedBlock.newBuilder() @@ -328,7 +328,7 @@ private void publish(PendingBlock p, boolean force) { .addAllCertifications( p.witnesses.values().stream().map(Validate::getWitness).toList()) .build(); - view.publish(new HashedCertifiedBlock(params().digestAlgorithm(), cb)); + view.publish(new HashedCertifiedBlock(params().digestAlgorithm(), cb), beacon); } private void reconfigure() { diff --git a/choam/src/main/java/com/salesforce/apollo/choam/ViewContext.java b/choam/src/main/java/com/salesforce/apollo/choam/ViewContext.java index 696933e4e..a9678206d 100644 --- a/choam/src/main/java/com/salesforce/apollo/choam/ViewContext.java +++ b/choam/src/main/java/com/salesforce/apollo/choam/ViewContext.java @@ -158,8 +158,8 @@ public Block produce(ULong height, Digest prev, Assemble assemble, HashedBlock c return blockProducer.produce(height, prev, assemble, checkpoint); } - public void publish(HashedCertifiedBlock block) { - blockProducer.publish(block.hash, block.certifiedBlock); + public void publish(HashedCertifiedBlock block, boolean beacon) { + blockProducer.publish(block.hash, block.certifiedBlock, beacon); } public Block reconfigure(Map aggregate, Digest nextViewId, HashedBlock lastBlock, diff --git a/choam/src/test/java/com/salesforce/apollo/choam/GenesisAssemblyTest.java b/choam/src/test/java/com/salesforce/apollo/choam/GenesisAssemblyTest.java index 8e8f8ac2d..079dbe402 100644 --- a/choam/src/test/java/com/salesforce/apollo/choam/GenesisAssemblyTest.java +++ b/choam/src/test/java/com/salesforce/apollo/choam/GenesisAssemblyTest.java @@ -149,7 +149,7 @@ public Block produce(ULong height, Digest prev, Executions executions, HashedBlo } @Override - public void publish(Digest hash, CertifiedBlock cb) { + public void publish(Digest hash, CertifiedBlock cb, boolean beacon) { complete.countDown(); }