From 2a33fc760d2bd5d9ece517ca4ef56941efd55512 Mon Sep 17 00:00:00 2001 From: Stefan Bratanov Date: Thu, 5 Sep 2024 17:51:21 +0300 Subject: [PATCH] Publish local headers to p2p layer --- .../teku/networking/eth2/ActiveEth2P2PNetwork.java | 7 +++++++ .../pegasys/teku/networking/eth2/Eth2P2PNetwork.java | 4 ++++ .../networking/eth2/gossip/forks/GossipForkManager.java | 9 +++++++++ .../teku/networking/eth2/mock/NoOpEth2P2PNetwork.java | 5 +++++ .../teku/services/beaconchain/BeaconChainController.java | 2 ++ 5 files changed, 27 insertions(+) diff --git a/networking/eth2/src/main/java/tech/pegasys/teku/networking/eth2/ActiveEth2P2PNetwork.java b/networking/eth2/src/main/java/tech/pegasys/teku/networking/eth2/ActiveEth2P2PNetwork.java index 4851bf01133..fa2e65564a7 100644 --- a/networking/eth2/src/main/java/tech/pegasys/teku/networking/eth2/ActiveEth2P2PNetwork.java +++ b/networking/eth2/src/main/java/tech/pegasys/teku/networking/eth2/ActiveEth2P2PNetwork.java @@ -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; @@ -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; diff --git a/networking/eth2/src/main/java/tech/pegasys/teku/networking/eth2/Eth2P2PNetwork.java b/networking/eth2/src/main/java/tech/pegasys/teku/networking/eth2/Eth2P2PNetwork.java index 0b7dbc34c49..9de9f642af9 100644 --- a/networking/eth2/src/main/java/tech/pegasys/teku/networking/eth2/Eth2P2PNetwork.java +++ b/networking/eth2/src/main/java/tech/pegasys/teku/networking/eth2/Eth2P2PNetwork.java @@ -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; @@ -53,4 +54,7 @@ public interface Eth2P2PNetwork extends P2PNetwork { void publishVoluntaryExit(SignedVoluntaryExit signedVoluntaryExit); void publishSignedBlsToExecutionChange(SignedBlsToExecutionChange signedBlsToExecutionChange); + + void publishSignedExecutionPayloadHeader( + SignedExecutionPayloadHeader signedExecutionPayloadHeader); } diff --git a/networking/eth2/src/main/java/tech/pegasys/teku/networking/eth2/gossip/forks/GossipForkManager.java b/networking/eth2/src/main/java/tech/pegasys/teku/networking/eth2/gossip/forks/GossipForkManager.java index 52462fa0390..0354cc76d71 100644 --- a/networking/eth2/src/main/java/tech/pegasys/teku/networking/eth2/gossip/forks/GossipForkManager.java +++ b/networking/eth2/src/main/java/tech/pegasys/teku/networking/eth2/gossip/forks/GossipForkManager.java @@ -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; @@ -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 void publishMessage( final UInt64 slot, final T message, diff --git a/networking/eth2/src/main/java/tech/pegasys/teku/networking/eth2/mock/NoOpEth2P2PNetwork.java b/networking/eth2/src/main/java/tech/pegasys/teku/networking/eth2/mock/NoOpEth2P2PNetwork.java index f80fab25fea..29d81942b39 100644 --- a/networking/eth2/src/main/java/tech/pegasys/teku/networking/eth2/mock/NoOpEth2P2PNetwork.java +++ b/networking/eth2/src/main/java/tech/pegasys/teku/networking/eth2/mock/NoOpEth2P2PNetwork.java @@ -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; @@ -78,4 +79,8 @@ public void publishVoluntaryExit(final SignedVoluntaryExit signedVoluntaryExit) @Override public void publishSignedBlsToExecutionChange( final SignedBlsToExecutionChange signedBlsToExecutionChange) {} + + @Override + public void publishSignedExecutionPayloadHeader( + final SignedExecutionPayloadHeader signedExecutionPayloadHeader) {} } diff --git a/services/beaconchain/src/main/java/tech/pegasys/teku/services/beaconchain/BeaconChainController.java b/services/beaconchain/src/main/java/tech/pegasys/teku/services/beaconchain/BeaconChainController.java index 8a2c82fdfa6..d49bf275970 100644 --- a/services/beaconchain/src/main/java/tech/pegasys/teku/services/beaconchain/BeaconChainController.java +++ b/services/beaconchain/src/main/java/tech/pegasys/teku/services/beaconchain/BeaconChainController.java @@ -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() {