Skip to content

Commit

Permalink
changes
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanBratanov committed Oct 23, 2024
1 parent 2d611ec commit 3aa904f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -666,15 +666,15 @@ private SafeFuture<InternalValidationResult> processAggregateAndProof(
public SafeFuture<SendSignedBlockResult> sendSignedBlock(
final SignedBlockContainer maybeBlindedBlockContainer,
final BroadcastValidationLevel broadcastValidationLevel) {
final UInt64 slot = maybeBlindedBlockContainer.getSlot();
final BlockPublishingPerformance blockPublishingPerformance =
blockProductionAndPublishingPerformanceFactory.createForPublishing(slot);
blockProductionAndPublishingPerformanceFactory.createForPublishing(
maybeBlindedBlockContainer.getSlot());
return blockPublisher
.sendSignedBlock(
maybeBlindedBlockContainer,
// do only EQUIVOCATION validation when GOSSIP validation has been requested and the
// block has been locally created
broadcastValidationLevel == GOSSIP && isLocallyCreatedBlock(slot)
broadcastValidationLevel == GOSSIP && isLocallyCreatedBlock(maybeBlindedBlockContainer)
? EQUIVOCATION
: broadcastValidationLevel,
blockPublishingPerformance)
Expand Down Expand Up @@ -883,13 +883,21 @@ private List<ProposerDuty> getProposalSlotsForEpoch(final BeaconState state, fin
return proposerSlots;
}

private boolean isLocallyCreatedBlock(final UInt64 slot) {
private boolean isLocallyCreatedBlock(final SignedBlockContainer signedBlockContainer) {
final SafeFuture<Optional<BlockContainerAndMetaData>> localBlockProduction =
localBlockProductionBySlotCache.get(slot);
if (localBlockProduction == null) {
localBlockProductionBySlotCache.get(signedBlockContainer.getSlot());
if (localBlockProduction == null || !localBlockProduction.isCompletedNormally()) {
return false;
}
return localBlockProduction.isCompletedNormally();
return localBlockProduction
.join()
.map(
blockContainerAndMetaData ->
blockContainerAndMetaData
.blockContainer()
.getRoot()
.equals(signedBlockContainer.getRoot()))
.orElse(false);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
package tech.pegasys.teku.spec.datastructures.blocks;

import java.util.Optional;
import org.apache.tuweni.bytes.Bytes32;
import tech.pegasys.teku.infrastructure.ssz.SszContainer;
import tech.pegasys.teku.infrastructure.ssz.SszData;
import tech.pegasys.teku.infrastructure.ssz.SszList;
Expand All @@ -35,6 +36,10 @@ default UInt64 getSlot() {
return getBlock().getSlot();
}

default Bytes32 getRoot() {
return getBlock().getRoot();
}

default Optional<SszList<SszKZGProof>> getKzgProofs() {
return Optional.empty();
}
Expand Down

0 comments on commit 3aa904f

Please sign in to comment.