Skip to content

Commit

Permalink
[Decoupling] Remove all references to coupled blobs (#7135)
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanBratanov committed May 15, 2023
1 parent b3304e1 commit fccbaf1
Show file tree
Hide file tree
Showing 33 changed files with 159 additions and 895 deletions.
Expand Up @@ -30,7 +30,7 @@
import tech.pegasys.teku.beacon.sync.events.SyncStateTracker;
import tech.pegasys.teku.infrastructure.async.SafeFuture;
import tech.pegasys.teku.infrastructure.unsigned.UInt64;
import tech.pegasys.teku.networking.eth2.gossip.BlockAndBlobsSidecarGossipChannel;
import tech.pegasys.teku.networking.eth2.gossip.BlobSidecarGossipChannel;
import tech.pegasys.teku.networking.eth2.gossip.BlockGossipChannel;
import tech.pegasys.teku.networking.eth2.gossip.subnets.AttestationTopicSubscriber;
import tech.pegasys.teku.networking.eth2.gossip.subnets.SyncCommitteeSubscriptionManager;
Expand All @@ -41,6 +41,7 @@
import tech.pegasys.teku.spec.datastructures.state.Checkpoint;
import tech.pegasys.teku.statetransition.attestation.AggregatingAttestationPool;
import tech.pegasys.teku.statetransition.attestation.AttestationManager;
import tech.pegasys.teku.statetransition.blobs.BlobSidecarPool;
import tech.pegasys.teku.statetransition.block.BlockImportChannel;
import tech.pegasys.teku.statetransition.forkchoice.ForkChoiceTrigger;
import tech.pegasys.teku.statetransition.forkchoice.ProposersDataManager;
Expand Down Expand Up @@ -74,8 +75,9 @@ public class ValidatorApiHandlerIntegrationTest {
mock(DefaultPerformanceTracker.class);
private final BlockImportChannel blockImportChannel = mock(BlockImportChannel.class);
private final BlockGossipChannel blockGossipChannel = mock(BlockGossipChannel.class);
private final BlockAndBlobsSidecarGossipChannel blockAndBlobsSidecarGossipChannel =
mock(BlockAndBlobsSidecarGossipChannel.class);
private final BlobSidecarPool blobSidecarPool = mock(BlobSidecarPool.class);
private final BlobSidecarGossipChannel blobSidecarGossipChannel =
mock(BlobSidecarGossipChannel.class);
private final ChainDataProvider chainDataProvider = mock(ChainDataProvider.class);
private final NodeDataProvider nodeDataProvider = mock(NodeDataProvider.class);
private final ForkChoiceTrigger forkChoiceTrigger = mock(ForkChoiceTrigger.class);
Expand All @@ -97,7 +99,8 @@ public class ValidatorApiHandlerIntegrationTest {
blockFactory,
blockImportChannel,
blockGossipChannel,
blockAndBlobsSidecarGossipChannel,
blobSidecarPool,
blobSidecarGossipChannel,
attestationPool,
attestationManager,
attestationTopicSubscriber,
Expand Down
Expand Up @@ -24,7 +24,6 @@
import tech.pegasys.teku.spec.datastructures.blocks.BeaconBlock;
import tech.pegasys.teku.spec.datastructures.blocks.BeaconBlockAndState;
import tech.pegasys.teku.spec.datastructures.blocks.SignedBeaconBlock;
import tech.pegasys.teku.spec.datastructures.blocks.blockbody.versions.deneb.SignedBeaconBlockAndBlobsSidecar;
import tech.pegasys.teku.spec.datastructures.state.beaconstate.BeaconState;

public class BlockFactory {
Expand Down Expand Up @@ -73,14 +72,6 @@ public SafeFuture<SignedBeaconBlock> unblindSignedBeaconBlockIfBlinded(
return SafeFuture.completedFuture(blindedSignedBeaconBlock);
}

public SafeFuture<SignedBeaconBlockAndBlobsSidecar> supplementBlockWithSidecar(
final SignedBeaconBlock unblindedSignedBeaconBlock) {
if (unblindedSignedBeaconBlock.isBlinded()) {
throw new IllegalArgumentException("Block should be unblinded");
}
return operationSelector.createSidecarSupplementSelector().apply(unblindedSignedBeaconBlock);
}

public SignedBeaconBlock blindSignedBeaconBlockIfUnblinded(
final SignedBeaconBlock unblindedSignedBeaconBlock) {
if (unblindedSignedBeaconBlock.getMessage().getBody().isBlinded()) {
Expand Down
Expand Up @@ -17,7 +17,6 @@
import java.util.Optional;
import java.util.Set;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Supplier;
import java.util.stream.Collectors;
import org.apache.tuweni.bytes.Bytes32;
Expand All @@ -26,13 +25,10 @@
import tech.pegasys.teku.infrastructure.ssz.SszList;
import tech.pegasys.teku.infrastructure.unsigned.UInt64;
import tech.pegasys.teku.spec.Spec;
import tech.pegasys.teku.spec.datastructures.blobs.versions.deneb.BlobsSidecar;
import tech.pegasys.teku.spec.datastructures.blocks.BeaconBlock;
import tech.pegasys.teku.spec.datastructures.blocks.Eth1Data;
import tech.pegasys.teku.spec.datastructures.blocks.SignedBeaconBlock;
import tech.pegasys.teku.spec.datastructures.blocks.SignedBeaconBlockUnblinder;
import tech.pegasys.teku.spec.datastructures.blocks.blockbody.BeaconBlockBodyBuilder;
import tech.pegasys.teku.spec.datastructures.blocks.blockbody.versions.deneb.SignedBeaconBlockAndBlobsSidecar;
import tech.pegasys.teku.spec.datastructures.execution.ExecutionPayload;
import tech.pegasys.teku.spec.datastructures.execution.ExecutionPayloadContext;
import tech.pegasys.teku.spec.datastructures.execution.ExecutionPayloadHeader;
Expand Down Expand Up @@ -284,7 +280,7 @@ private void builderSetKzgCommitments(
executionPayloadResultFuture.thenCompose(
executionPayloadResult ->
executionPayloadResult
.getCommitments()
.getCommitmentsFuture()
.orElseThrow()
.thenApply(
commitments ->
Expand Down Expand Up @@ -325,30 +321,4 @@ public Consumer<SignedBeaconBlockUnblinder> createUnblinderSelector() {
}
};
}

public Function<SignedBeaconBlock, SafeFuture<SignedBeaconBlockAndBlobsSidecar>>
createSidecarSupplementSelector() {
return signedBeaconBlock -> {
final SchemaDefinitionsDeneb schemaDefinitionsDeneb =
spec.atSlot(signedBeaconBlock.getSlot())
.getSchemaDefinitions()
.toVersionDeneb()
.orElseThrow();
return executionLayerBlockProductionManager
.getCachedPayloadResult(signedBeaconBlock.getSlot())
.orElseThrow(() -> new IllegalStateException("payloadResult is required"))
.getBlobs()
.orElseThrow(() -> new IllegalStateException("blobs are required"))
.thenApply(
blobs ->
new SignedBeaconBlockAndBlobsSidecar(
schemaDefinitionsDeneb.getSignedBeaconBlockAndBlobsSidecarSchema(),
signedBeaconBlock,
createBlobsSidecar()));
};
}

private BlobsSidecar createBlobsSidecar() {
throw new UnsupportedOperationException("Deprecated");
}
}
Expand Up @@ -47,7 +47,7 @@
import tech.pegasys.teku.infrastructure.async.SafeFuture;
import tech.pegasys.teku.infrastructure.ssz.SszList;
import tech.pegasys.teku.infrastructure.unsigned.UInt64;
import tech.pegasys.teku.networking.eth2.gossip.BlockAndBlobsSidecarGossipChannel;
import tech.pegasys.teku.networking.eth2.gossip.BlobSidecarGossipChannel;
import tech.pegasys.teku.networking.eth2.gossip.BlockGossipChannel;
import tech.pegasys.teku.networking.eth2.gossip.subnets.AttestationTopicSubscriber;
import tech.pegasys.teku.networking.eth2.gossip.subnets.SyncCommitteeSubscriptionManager;
Expand Down Expand Up @@ -75,6 +75,7 @@
import tech.pegasys.teku.spec.logic.common.util.SyncCommitteeUtil;
import tech.pegasys.teku.statetransition.attestation.AggregatingAttestationPool;
import tech.pegasys.teku.statetransition.attestation.AttestationManager;
import tech.pegasys.teku.statetransition.blobs.BlobSidecarPool;
import tech.pegasys.teku.statetransition.block.BlockImportChannel;
import tech.pegasys.teku.statetransition.forkchoice.ForkChoiceTrigger;
import tech.pegasys.teku.statetransition.forkchoice.ProposersDataManager;
Expand Down Expand Up @@ -135,7 +136,8 @@ public ValidatorApiHandler(
final BlockFactory blockFactory,
final BlockImportChannel blockImportChannel,
final BlockGossipChannel blockGossipChannel,
final BlockAndBlobsSidecarGossipChannel blockAndBlobsSidecarGossipChannel,
final BlobSidecarPool blobSidecarPool,
final BlobSidecarGossipChannel blobSidecarGossipChannel,
final AggregatingAttestationPool attestationPool,
final AttestationManager attestationManager,
final AttestationTopicSubscriber attestationTopicSubscriber,
Expand Down Expand Up @@ -171,7 +173,8 @@ public ValidatorApiHandler(
blockFactory,
blockImportChannel,
blockGossipChannel,
blockAndBlobsSidecarGossipChannel,
blobSidecarPool,
blobSidecarGossipChannel,
performanceTracker,
dutyMetrics);
}
Expand Down
Expand Up @@ -14,37 +14,40 @@
package tech.pegasys.teku.validator.coordinator.publisher;

import tech.pegasys.teku.infrastructure.async.SafeFuture;
import tech.pegasys.teku.networking.eth2.gossip.BlockAndBlobsSidecarGossipChannel;
import tech.pegasys.teku.networking.eth2.gossip.BlobSidecarGossipChannel;
import tech.pegasys.teku.networking.eth2.gossip.BlockGossipChannel;
import tech.pegasys.teku.spec.datastructures.blocks.SignedBeaconBlock;
import tech.pegasys.teku.spec.datastructures.blocks.blockbody.versions.deneb.SignedBeaconBlockAndBlobsSidecar;
import tech.pegasys.teku.spec.logic.common.statetransition.results.BlockImportResult;
import tech.pegasys.teku.statetransition.blobs.BlobSidecarPool;
import tech.pegasys.teku.statetransition.block.BlockImportChannel;
import tech.pegasys.teku.validator.coordinator.BlockFactory;
import tech.pegasys.teku.validator.coordinator.DutyMetrics;
import tech.pegasys.teku.validator.coordinator.performance.PerformanceTracker;

@SuppressWarnings("unused")
public class BlockPublisherDeneb extends AbstractBlockPublisher {
private final BlockAndBlobsSidecarGossipChannel blockAndBlobsSidecarGossipChannel;

private final BlobSidecarPool blobSidecarPool;
private final BlockGossipChannel blockGossipChannel;
private final BlobSidecarGossipChannel blobSidecarGossipChannel;

public BlockPublisherDeneb(
final BlockFactory blockFactory,
final BlockImportChannel blockImportChannel,
final BlockAndBlobsSidecarGossipChannel blockAndBlobsSidecarGossipChannel,
final BlockGossipChannel blockGossipChannel,
final BlobSidecarPool blobSidecarPool,
final BlobSidecarGossipChannel blobSidecarGossipChannel,
final PerformanceTracker performanceTracker,
final DutyMetrics dutyMetrics) {
super(blockFactory, blockImportChannel, performanceTracker, dutyMetrics);
this.blockAndBlobsSidecarGossipChannel = blockAndBlobsSidecarGossipChannel;
this.blobSidecarPool = blobSidecarPool;
this.blockGossipChannel = blockGossipChannel;
this.blobSidecarGossipChannel = blobSidecarGossipChannel;
}

@Override
protected SafeFuture<BlockImportResult> gossipAndImportUnblindedSignedBlock(
final SignedBeaconBlock block) {
final SafeFuture<SignedBeaconBlockAndBlobsSidecar> blockAndBlobsSidecarSafeFuture =
blockFactory.supplementBlockWithSidecar(block);
return blockAndBlobsSidecarSafeFuture
.thenPeek(blockAndBlobsSidecarGossipChannel::publishBlockAndBlobsSidecar)
.thenCompose(
blockAndBlobsSidecar ->
blockImportChannel.importBlock(blockAndBlobsSidecar.getSignedBeaconBlock()));
throw new UnsupportedOperationException("Not yet implemented");
}
}
Expand Up @@ -18,11 +18,12 @@
import java.util.Map;
import java.util.function.Supplier;
import tech.pegasys.teku.infrastructure.async.SafeFuture;
import tech.pegasys.teku.networking.eth2.gossip.BlockAndBlobsSidecarGossipChannel;
import tech.pegasys.teku.networking.eth2.gossip.BlobSidecarGossipChannel;
import tech.pegasys.teku.networking.eth2.gossip.BlockGossipChannel;
import tech.pegasys.teku.spec.Spec;
import tech.pegasys.teku.spec.SpecMilestone;
import tech.pegasys.teku.spec.datastructures.blocks.SignedBeaconBlock;
import tech.pegasys.teku.statetransition.blobs.BlobSidecarPool;
import tech.pegasys.teku.statetransition.block.BlockImportChannel;
import tech.pegasys.teku.validator.api.SendSignedBlockResult;
import tech.pegasys.teku.validator.coordinator.BlockFactory;
Expand All @@ -39,7 +40,8 @@ public MilestoneBasedBlockPublisher(
final BlockFactory blockFactory,
final BlockImportChannel blockImportChannel,
final BlockGossipChannel blockGossipChannel,
final BlockAndBlobsSidecarGossipChannel blockAndBlobsSidecarGossipChannel,
final BlobSidecarPool blobSidecarPool,
final BlobSidecarGossipChannel blobSidecarGossipChannel,
final PerformanceTracker performanceTracker,
final DutyMetrics dutyMetrics) {
this.spec = spec;
Expand All @@ -48,13 +50,15 @@ public MilestoneBasedBlockPublisher(
blockFactory, blockGossipChannel, blockImportChannel, performanceTracker, dutyMetrics);

// Not needed for all milestones
final Supplier<BlockPublisherDeneb> blockAndBlobsSidecarPublisherSupplier =
final Supplier<BlockPublisherDeneb> blockAndBlobSidecarsPublisherSupplier =
Suppliers.memoize(
() ->
new BlockPublisherDeneb(
blockFactory,
blockImportChannel,
blockAndBlobsSidecarGossipChannel,
blockGossipChannel,
blobSidecarPool,
blobSidecarGossipChannel,
performanceTracker,
dutyMetrics));

Expand All @@ -64,7 +68,7 @@ public MilestoneBasedBlockPublisher(
forkAndSpecMilestone -> {
final SpecMilestone milestone = forkAndSpecMilestone.getSpecMilestone();
if (milestone.isGreaterThanOrEqualTo(SpecMilestone.DENEB)) {
registeredPublishers.put(milestone, blockAndBlobsSidecarPublisherSupplier.get());
registeredPublishers.put(milestone, blockAndBlobSidecarsPublisherSupplier.get());
} else {
registeredPublishers.put(milestone, blockPublisherPhase0);
}
Expand Down

0 comments on commit fccbaf1

Please sign in to comment.