Skip to content

Commit

Permalink
Publish local headers to p2p layer
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanBratanov committed Sep 5, 2024
1 parent e1203f6 commit 2a33fc7
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import tech.pegasys.teku.networking.p2p.peer.NodeId;
import tech.pegasys.teku.networking.p2p.peer.PeerConnectedSubscriber;
import tech.pegasys.teku.spec.Spec;
import tech.pegasys.teku.spec.datastructures.execution.SignedExecutionPayloadHeader;
import tech.pegasys.teku.spec.datastructures.networking.libp2p.rpc.metadata.MetadataMessage;
import tech.pegasys.teku.spec.datastructures.operations.AttesterSlashing;
import tech.pegasys.teku.spec.datastructures.operations.ProposerSlashing;
Expand Down Expand Up @@ -367,6 +368,12 @@ public void publishSignedBlsToExecutionChange(
gossipForkManager.publishSignedBlsToExecutionChanges(signedBlsToExecutionChange);
}

@Override
public void publishSignedExecutionPayloadHeader(
final SignedExecutionPayloadHeader signedExecutionPayloadHeader) {
gossipForkManager.publishSignedExecutionPayloadHeader(signedExecutionPayloadHeader);
}

@VisibleForTesting
Eth2PeerManager getPeerManager() {
return peerManager;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import tech.pegasys.teku.infrastructure.unsigned.UInt64;
import tech.pegasys.teku.networking.eth2.peers.Eth2Peer;
import tech.pegasys.teku.networking.p2p.network.P2PNetwork;
import tech.pegasys.teku.spec.datastructures.execution.SignedExecutionPayloadHeader;
import tech.pegasys.teku.spec.datastructures.networking.libp2p.rpc.metadata.MetadataMessage;
import tech.pegasys.teku.spec.datastructures.operations.AttesterSlashing;
import tech.pegasys.teku.spec.datastructures.operations.ProposerSlashing;
Expand Down Expand Up @@ -53,4 +54,7 @@ public interface Eth2P2PNetwork extends P2PNetwork<Eth2Peer> {
void publishVoluntaryExit(SignedVoluntaryExit signedVoluntaryExit);

void publishSignedBlsToExecutionChange(SignedBlsToExecutionChange signedBlsToExecutionChange);

void publishSignedExecutionPayloadHeader(
SignedExecutionPayloadHeader signedExecutionPayloadHeader);
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import tech.pegasys.teku.spec.datastructures.attestation.ValidatableAttestation;
import tech.pegasys.teku.spec.datastructures.blobs.versions.deneb.BlobSidecar;
import tech.pegasys.teku.spec.datastructures.blocks.SignedBeaconBlock;
import tech.pegasys.teku.spec.datastructures.execution.SignedExecutionPayloadHeader;
import tech.pegasys.teku.spec.datastructures.operations.AttesterSlashing;
import tech.pegasys.teku.spec.datastructures.operations.ProposerSlashing;
import tech.pegasys.teku.spec.datastructures.operations.SignedBlsToExecutionChange;
Expand Down Expand Up @@ -227,6 +228,14 @@ public void publishSignedBlsToExecutionChanges(final SignedBlsToExecutionChange
GossipForkSubscriptions::publishSignedBlsToExecutionChangeMessage);
}

public void publishSignedExecutionPayloadHeader(final SignedExecutionPayloadHeader message) {
publishMessage(
spec.computeStartSlotAtEpoch(currentEpoch.orElseThrow()),
message,
"signed execution payload header",
GossipForkSubscriptions::publishExecutionPayloadHeaderMessage);
}

private <T> void publishMessage(
final UInt64 slot,
final T message,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import tech.pegasys.teku.networking.eth2.peers.Eth2Peer;
import tech.pegasys.teku.networking.p2p.mock.MockP2PNetwork;
import tech.pegasys.teku.spec.Spec;
import tech.pegasys.teku.spec.datastructures.execution.SignedExecutionPayloadHeader;
import tech.pegasys.teku.spec.datastructures.networking.libp2p.rpc.metadata.MetadataMessage;
import tech.pegasys.teku.spec.datastructures.operations.AttesterSlashing;
import tech.pegasys.teku.spec.datastructures.operations.ProposerSlashing;
Expand Down Expand Up @@ -78,4 +79,8 @@ public void publishVoluntaryExit(final SignedVoluntaryExit signedVoluntaryExit)
@Override
public void publishSignedBlsToExecutionChange(
final SignedBlsToExecutionChange signedBlsToExecutionChange) {}

@Override
public void publishSignedExecutionPayloadHeader(
final SignedExecutionPayloadHeader signedExecutionPayloadHeader) {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1170,6 +1170,8 @@ protected void initP2PNetwork() {
new LocalOperationAcceptedFilter<>(p2pNetwork::publishVoluntaryExit));
blsToExecutionChangePool.subscribeOperationAdded(
new LocalOperationAcceptedFilter<>(p2pNetwork::publishSignedBlsToExecutionChange));
executionPayloadHeaderPool.subscribeOperationAdded(
new LocalOperationAcceptedFilter<>(p2pNetwork::publishSignedExecutionPayloadHeader));
}

protected Eth2P2PNetworkBuilder createEth2P2PNetworkBuilder() {
Expand Down

0 comments on commit 2a33fc7

Please sign in to comment.