diff --git a/beacon/validator/src/integrationTest/java/tech/pegasys/teku/validator/coordinator/ValidatorApiHandlerIntegrationTest.java b/beacon/validator/src/integrationTest/java/tech/pegasys/teku/validator/coordinator/ValidatorApiHandlerIntegrationTest.java index 529f393af15..8b97342437e 100644 --- a/beacon/validator/src/integrationTest/java/tech/pegasys/teku/validator/coordinator/ValidatorApiHandlerIntegrationTest.java +++ b/beacon/validator/src/integrationTest/java/tech/pegasys/teku/validator/coordinator/ValidatorApiHandlerIntegrationTest.java @@ -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; @@ -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; @@ -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); @@ -97,7 +99,8 @@ public class ValidatorApiHandlerIntegrationTest { blockFactory, blockImportChannel, blockGossipChannel, - blockAndBlobsSidecarGossipChannel, + blobSidecarPool, + blobSidecarGossipChannel, attestationPool, attestationManager, attestationTopicSubscriber, diff --git a/beacon/validator/src/main/java/tech/pegasys/teku/validator/coordinator/BlockFactory.java b/beacon/validator/src/main/java/tech/pegasys/teku/validator/coordinator/BlockFactory.java index d572ef7e0e3..3046cb9445c 100644 --- a/beacon/validator/src/main/java/tech/pegasys/teku/validator/coordinator/BlockFactory.java +++ b/beacon/validator/src/main/java/tech/pegasys/teku/validator/coordinator/BlockFactory.java @@ -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 { @@ -73,14 +72,6 @@ public SafeFuture unblindSignedBeaconBlockIfBlinded( return SafeFuture.completedFuture(blindedSignedBeaconBlock); } - public SafeFuture 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()) { diff --git a/beacon/validator/src/main/java/tech/pegasys/teku/validator/coordinator/BlockOperationSelectorFactory.java b/beacon/validator/src/main/java/tech/pegasys/teku/validator/coordinator/BlockOperationSelectorFactory.java index dfba1b9ef8a..ffa13e44767 100644 --- a/beacon/validator/src/main/java/tech/pegasys/teku/validator/coordinator/BlockOperationSelectorFactory.java +++ b/beacon/validator/src/main/java/tech/pegasys/teku/validator/coordinator/BlockOperationSelectorFactory.java @@ -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; @@ -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; @@ -284,7 +280,7 @@ private void builderSetKzgCommitments( executionPayloadResultFuture.thenCompose( executionPayloadResult -> executionPayloadResult - .getCommitments() + .getCommitmentsFuture() .orElseThrow() .thenApply( commitments -> @@ -325,30 +321,4 @@ public Consumer createUnblinderSelector() { } }; } - - public Function> - 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"); - } } diff --git a/beacon/validator/src/main/java/tech/pegasys/teku/validator/coordinator/ValidatorApiHandler.java b/beacon/validator/src/main/java/tech/pegasys/teku/validator/coordinator/ValidatorApiHandler.java index 8f6bd641e00..cd62d0fd875 100644 --- a/beacon/validator/src/main/java/tech/pegasys/teku/validator/coordinator/ValidatorApiHandler.java +++ b/beacon/validator/src/main/java/tech/pegasys/teku/validator/coordinator/ValidatorApiHandler.java @@ -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; @@ -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; @@ -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, @@ -171,7 +173,8 @@ public ValidatorApiHandler( blockFactory, blockImportChannel, blockGossipChannel, - blockAndBlobsSidecarGossipChannel, + blobSidecarPool, + blobSidecarGossipChannel, performanceTracker, dutyMetrics); } diff --git a/beacon/validator/src/main/java/tech/pegasys/teku/validator/coordinator/publisher/BlockPublisherDeneb.java b/beacon/validator/src/main/java/tech/pegasys/teku/validator/coordinator/publisher/BlockPublisherDeneb.java index eb3b0481222..613f22e76a4 100644 --- a/beacon/validator/src/main/java/tech/pegasys/teku/validator/coordinator/publisher/BlockPublisherDeneb.java +++ b/beacon/validator/src/main/java/tech/pegasys/teku/validator/coordinator/publisher/BlockPublisherDeneb.java @@ -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 gossipAndImportUnblindedSignedBlock( final SignedBeaconBlock block) { - final SafeFuture blockAndBlobsSidecarSafeFuture = - blockFactory.supplementBlockWithSidecar(block); - return blockAndBlobsSidecarSafeFuture - .thenPeek(blockAndBlobsSidecarGossipChannel::publishBlockAndBlobsSidecar) - .thenCompose( - blockAndBlobsSidecar -> - blockImportChannel.importBlock(blockAndBlobsSidecar.getSignedBeaconBlock())); + throw new UnsupportedOperationException("Not yet implemented"); } } diff --git a/beacon/validator/src/main/java/tech/pegasys/teku/validator/coordinator/publisher/MilestoneBasedBlockPublisher.java b/beacon/validator/src/main/java/tech/pegasys/teku/validator/coordinator/publisher/MilestoneBasedBlockPublisher.java index aa38cd62bc2..433db74621a 100644 --- a/beacon/validator/src/main/java/tech/pegasys/teku/validator/coordinator/publisher/MilestoneBasedBlockPublisher.java +++ b/beacon/validator/src/main/java/tech/pegasys/teku/validator/coordinator/publisher/MilestoneBasedBlockPublisher.java @@ -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; @@ -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; @@ -48,13 +50,15 @@ public MilestoneBasedBlockPublisher( blockFactory, blockGossipChannel, blockImportChannel, performanceTracker, dutyMetrics); // Not needed for all milestones - final Supplier blockAndBlobsSidecarPublisherSupplier = + final Supplier blockAndBlobSidecarsPublisherSupplier = Suppliers.memoize( () -> new BlockPublisherDeneb( blockFactory, blockImportChannel, - blockAndBlobsSidecarGossipChannel, + blockGossipChannel, + blobSidecarPool, + blobSidecarGossipChannel, performanceTracker, dutyMetrics)); @@ -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); } diff --git a/beacon/validator/src/test/java/tech/pegasys/teku/validator/coordinator/ValidatorApiHandlerTest.java b/beacon/validator/src/test/java/tech/pegasys/teku/validator/coordinator/ValidatorApiHandlerTest.java index badd880276d..cf0d0c36bf2 100644 --- a/beacon/validator/src/test/java/tech/pegasys/teku/validator/coordinator/ValidatorApiHandlerTest.java +++ b/beacon/validator/src/test/java/tech/pegasys/teku/validator/coordinator/ValidatorApiHandlerTest.java @@ -48,6 +48,7 @@ import java.util.stream.IntStream; import org.apache.tuweni.bytes.Bytes32; import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.mockito.ArgumentCaptor; import org.mockito.InOrder; @@ -65,7 +66,7 @@ import tech.pegasys.teku.infrastructure.ssz.SszList; import tech.pegasys.teku.infrastructure.ssz.SszMutableList; 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; @@ -75,10 +76,10 @@ import tech.pegasys.teku.spec.config.SpecConfig; import tech.pegasys.teku.spec.config.SpecConfigAltair; import tech.pegasys.teku.spec.datastructures.attestation.ValidateableAttestation; +import tech.pegasys.teku.spec.datastructures.blobs.versions.deneb.SignedBlobSidecar; import tech.pegasys.teku.spec.datastructures.blocks.BeaconBlock; import tech.pegasys.teku.spec.datastructures.blocks.SignedBeaconBlock; import tech.pegasys.teku.spec.datastructures.blocks.SignedBlockAndState; -import tech.pegasys.teku.spec.datastructures.blocks.blockbody.versions.deneb.SignedBeaconBlockAndBlobsSidecar; import tech.pegasys.teku.spec.datastructures.builder.SignedValidatorRegistration; import tech.pegasys.teku.spec.datastructures.builder.ValidatorRegistration; import tech.pegasys.teku.spec.datastructures.metadata.ObjectAndMetaData; @@ -96,6 +97,7 @@ import tech.pegasys.teku.spec.util.DataStructureUtil; 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; @@ -131,8 +133,9 @@ class ValidatorApiHandlerTest { private final ActiveValidatorTracker activeValidatorTracker = mock(ActiveValidatorTracker.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 DefaultPerformanceTracker performanceTracker = mock(DefaultPerformanceTracker.class); private final ChainDataProvider chainDataProvider = mock(ChainDataProvider.class); @@ -169,7 +172,8 @@ public void setUp() { blockFactory, blockImportChannel, blockGossipChannel, - blockAndBlobsSidecarGossipChannel, + blobSidecarPool, + blobSidecarGossipChannel, attestationPool, attestationManager, attestationTopicSubscriptions, @@ -421,7 +425,8 @@ void getSyncCommitteeDuties_shouldNotUseEpochPriorToFork() { blockFactory, blockImportChannel, blockGossipChannel, - blockAndBlobsSidecarGossipChannel, + blobSidecarPool, + blobSidecarGossipChannel, attestationPool, attestationManager, attestationTopicSubscriptions, @@ -812,49 +817,37 @@ public void sendSignedBlock_shouldConvertKnownBlockResult() { } @Test - public void sendSignedBlock_shouldConvertSuccessfulResultWithBlobsSidecar() { + @Disabled("Will enable or remove once block production for Deneb is implemented") + public void sendSignedBlock_shouldConvertSuccessfulResultWithBlobSidecars() { setupDeneb(); final SignedBeaconBlock block = dataStructureUtil.randomSignedBeaconBlock(5); - final SignedBeaconBlockAndBlobsSidecar blockAndBlobsSidecar = - new SignedBeaconBlockAndBlobsSidecar( - spec.getGenesisSchemaDefinitions() - .toVersionDeneb() - .orElseThrow() - .getSignedBeaconBlockAndBlobsSidecarSchema(), - block, - dataStructureUtil.randomBlobsSidecar()); - when(blockFactory.supplementBlockWithSidecar(block)) - .thenReturn(SafeFuture.completedFuture(blockAndBlobsSidecar)); + final List blobSidecars = + dataStructureUtil.randomSignedBlobSidecarsForBlock(block); when(blockImportChannel.importBlock(block)) .thenReturn(SafeFuture.completedFuture(BlockImportResult.successful(block))); final SafeFuture result = validatorApiHandler.sendSignedBlock(block); - verify(blockAndBlobsSidecarGossipChannel).publishBlockAndBlobsSidecar(blockAndBlobsSidecar); - verifyNoInteractions(blockGossipChannel); + verify(blockGossipChannel).publishBlock(block); + verify(blobSidecarGossipChannel).publishBlobSidecars(blobSidecars); + verify(blobSidecarPool).onCompletedBlockAndBlobSidecars(eq(block), any()); verify(blockImportChannel).importBlock(block); assertThat(result).isCompletedWithValue(SendSignedBlockResult.success(block.getRoot())); } @Test - public void sendSignedBlock_shouldConvertFailedResultWithBlobsSidecar() { + @Disabled("Will enable or remove once block production for Deneb is implemented") + public void sendSignedBlock_shouldConvertFailedResultWithBlobSidecars() { setupDeneb(); final SignedBeaconBlock block = dataStructureUtil.randomSignedBeaconBlock(5); - final SignedBeaconBlockAndBlobsSidecar blockAndBlobsSidecar = - new SignedBeaconBlockAndBlobsSidecar( - spec.getGenesisSchemaDefinitions() - .toVersionDeneb() - .orElseThrow() - .getSignedBeaconBlockAndBlobsSidecarSchema(), - block, - dataStructureUtil.randomBlobsSidecar()); - when(blockFactory.supplementBlockWithSidecar(block)) - .thenReturn(SafeFuture.completedFuture(blockAndBlobsSidecar)); + final List blobSidecars = + dataStructureUtil.randomSignedBlobSidecarsForBlock(block); when(blockImportChannel.importBlock(block)) .thenReturn(SafeFuture.completedFuture(BlockImportResult.FAILED_INVALID_ANCESTRY)); final SafeFuture result = validatorApiHandler.sendSignedBlock(block); - verify(blockAndBlobsSidecarGossipChannel).publishBlockAndBlobsSidecar(blockAndBlobsSidecar); - verifyNoInteractions(blockGossipChannel); + verify(blockGossipChannel).publishBlock(block); + verify(blobSidecarGossipChannel).publishBlobSidecars(blobSidecars); + verify(blobSidecarPool).onCompletedBlockAndBlobSidecars(eq(block), any()); verify(blockImportChannel).importBlock(block); assertThat(result) .isCompletedWithValue( @@ -862,40 +855,33 @@ public void sendSignedBlock_shouldConvertFailedResultWithBlobsSidecar() { } @Test - public void sendSignedBlock_shouldConvertKnownBlockResultWithBlobsSidecar() { + @Disabled("Will enable or remove once block production for Deneb is implemented") + public void sendSignedBlock_shouldConvertKnownBlockResultWithBlobSidecars() { setupDeneb(); final SignedBeaconBlock block = dataStructureUtil.randomSignedBeaconBlock(5); - final SignedBeaconBlockAndBlobsSidecar blockAndBlobsSidecar = - new SignedBeaconBlockAndBlobsSidecar( - spec.getGenesisSchemaDefinitions() - .toVersionDeneb() - .orElseThrow() - .getSignedBeaconBlockAndBlobsSidecarSchema(), - block, - dataStructureUtil.randomBlobsSidecar()); - when(blockFactory.supplementBlockWithSidecar(block)) - .thenReturn(SafeFuture.completedFuture(blockAndBlobsSidecar)); + final List blobSidecars = + dataStructureUtil.randomSignedBlobSidecarsForBlock(block); when(blockImportChannel.importBlock(block)) .thenReturn(SafeFuture.completedFuture(BlockImportResult.knownBlock(block, false))); final SafeFuture result = validatorApiHandler.sendSignedBlock(block); - verify(blockAndBlobsSidecarGossipChannel).publishBlockAndBlobsSidecar(blockAndBlobsSidecar); - verifyNoInteractions(blockGossipChannel); + verify(blockGossipChannel).publishBlock(block); + verify(blobSidecarGossipChannel).publishBlobSidecars(blobSidecars); + verify(blobSidecarPool).onCompletedBlockAndBlobSidecars(eq(block), any()); verify(blockImportChannel).importBlock(block); assertThat(result).isCompletedWithValue(SendSignedBlockResult.success(block.getRoot())); } @Test - public void sendSignedBlock_shouldBeRejectedWhenBlobsSidecarCannotBeRetrieved() { + @Disabled("Will enable or remove once block production for Deneb is implemented") + public void sendSignedBlock_shouldBeRejectedWhenBlobSidecarsCannotBeRetrieved() { setupDeneb(); final SignedBeaconBlock block = dataStructureUtil.randomSignedBeaconBlock(5); - when(blockFactory.supplementBlockWithSidecar(block)) - .thenThrow(new IllegalArgumentException("")); final SafeFuture result = validatorApiHandler.sendSignedBlock(block); result.join(); verifyNoInteractions(blockGossipChannel); - verifyNoInteractions(blockAndBlobsSidecarGossipChannel); + verifyNoInteractions(blobSidecarGossipChannel); verifyNoInteractions(blockImportChannel); assertThat(result) .isCompletedWithValueMatching( @@ -1161,14 +1147,14 @@ public void checkValidatorsDoppelganger_ShouldReturnDoppelgangerDetectionResult( List validatorIndices = List.of(firstIndex, secondIndex, thirdIndex); - List validatorLivenessAtEpoches = + List validatorLivenessAtEpochs = List.of( new ValidatorLivenessAtEpoch(firstIndex, epoch, false), new ValidatorLivenessAtEpoch(secondIndex, epoch, true), new ValidatorLivenessAtEpoch(thirdIndex, epoch, true)); when(nodeDataProvider.getValidatorLiveness(any(), any(), any())) - .thenReturn(SafeFuture.completedFuture(Optional.of(validatorLivenessAtEpoches))); + .thenReturn(SafeFuture.completedFuture(Optional.of(validatorLivenessAtEpochs))); when(chainDataProvider.getCurrentEpoch()).thenReturn(currentEpoch); @@ -1178,15 +1164,15 @@ public void checkValidatorsDoppelganger_ShouldReturnDoppelgangerDetectionResult( verify(nodeDataProvider).getValidatorLiveness(validatorIndices, epoch, currentEpoch); assertThat(result).isCompleted(); assertThat(result.get()).isPresent(); - List validatorLivenessAtEpochesResult = result.get().get(); - assertThat(validatorIsLive(validatorLivenessAtEpochesResult, firstIndex)).isFalse(); - assertThat(validatorIsLive(validatorLivenessAtEpochesResult, secondIndex)).isTrue(); - assertThat(validatorIsLive(validatorLivenessAtEpochesResult, thirdIndex)).isTrue(); + List validatorLivenessAtEpochsResult = result.get().get(); + assertThat(validatorIsLive(validatorLivenessAtEpochsResult, firstIndex)).isFalse(); + assertThat(validatorIsLive(validatorLivenessAtEpochsResult, secondIndex)).isTrue(); + assertThat(validatorIsLive(validatorLivenessAtEpochsResult, thirdIndex)).isTrue(); } private boolean validatorIsLive( - List validatorLivenessAtEpoches, UInt64 validatorIndex) { - return validatorLivenessAtEpoches.stream() + List validatorLivenessAtEpochs, UInt64 validatorIndex) { + return validatorLivenessAtEpochs.stream() .anyMatch( validatorLivenessAtEpoch -> validatorLivenessAtEpoch.getIndex().equals(validatorIndex) @@ -1275,7 +1261,8 @@ private void setupDeneb() { blockFactory, blockImportChannel, blockGossipChannel, - blockAndBlobsSidecarGossipChannel, + blobSidecarPool, + blobSidecarGossipChannel, attestationPool, attestationManager, attestationTopicSubscriptions, diff --git a/data/serializer/src/main/java/tech/pegasys/teku/api/schema/deneb/BlobsSidecar.java b/data/serializer/src/main/java/tech/pegasys/teku/api/schema/deneb/BlobsSidecar.java deleted file mode 100644 index 2695eb9a4a9..00000000000 --- a/data/serializer/src/main/java/tech/pegasys/teku/api/schema/deneb/BlobsSidecar.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright ConsenSys Software Inc., 2022 - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ - -package tech.pegasys.teku.api.schema.deneb; - -import static tech.pegasys.teku.api.schema.SchemaConstants.DESCRIPTION_BYTES48; - -import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.v3.oas.annotations.media.ArraySchema; -import io.swagger.v3.oas.annotations.media.Schema; -import java.util.List; -import java.util.stream.Collectors; -import org.apache.tuweni.bytes.Bytes; -import org.apache.tuweni.bytes.Bytes32; -import org.apache.tuweni.bytes.Bytes48; -import tech.pegasys.teku.infrastructure.unsigned.UInt64; -import tech.pegasys.teku.spec.datastructures.blobs.versions.deneb.Blob; -import tech.pegasys.teku.spec.datastructures.blobs.versions.deneb.BlobsSidecarSchema; - -public class BlobsSidecar { - - @JsonProperty("beacon_block_root") - private final Bytes32 beaconBlockRoot; - - @JsonProperty("beacon_block_slot") - private final UInt64 beaconBlockSlot; - - @ArraySchema(schema = @Schema(type = "string", format = "byte")) - public final List blobs; - - @Schema(type = "string", format = "byte", description = DESCRIPTION_BYTES48) - @JsonProperty("kzg_aggregated_proof") - private final Bytes kzgAggregatedProof; - - public BlobsSidecar( - @JsonProperty("beacon_block_root") final Bytes32 beaconBlockRoot, - @JsonProperty("beacon_block_slot") final UInt64 beaconBlockSlot, - @JsonProperty("blobs") final List blobs, - @JsonProperty("kzg_aggregated_proof") final Bytes kzgAggregatedProof) { - this.beaconBlockRoot = beaconBlockRoot; - this.beaconBlockSlot = beaconBlockSlot; - this.blobs = blobs; - this.kzgAggregatedProof = kzgAggregatedProof; - } - - public BlobsSidecar( - final tech.pegasys.teku.spec.datastructures.blobs.versions.deneb.BlobsSidecar blobSidecar) { - this.beaconBlockRoot = blobSidecar.getBeaconBlockRoot(); - this.beaconBlockSlot = blobSidecar.getBeaconBlockSlot(); - this.blobs = blobSidecar.getBlobs().stream().map(Blob::getBytes).collect(Collectors.toList()); - this.kzgAggregatedProof = blobSidecar.getKZGAggregatedProof().getBytesCompressed(); - } - - public static BlobsSidecar create( - final tech.pegasys.teku.spec.datastructures.blobs.versions.deneb.BlobsSidecar blobSidecar) { - return new BlobsSidecar(blobSidecar); - } - - public tech.pegasys.teku.spec.datastructures.blobs.versions.deneb.BlobsSidecar - asInternalBlobSidecar(final BlobsSidecarSchema schema) { - return schema.create(beaconBlockRoot, beaconBlockSlot, blobs, Bytes48.wrap(kzgAggregatedProof)); - } -} diff --git a/data/serializer/src/main/java/tech/pegasys/teku/api/schema/deneb/SignedBeaconBlockAndBlobsSidecar.java b/data/serializer/src/main/java/tech/pegasys/teku/api/schema/deneb/SignedBeaconBlockAndBlobsSidecar.java deleted file mode 100644 index ca070a0e1a5..00000000000 --- a/data/serializer/src/main/java/tech/pegasys/teku/api/schema/deneb/SignedBeaconBlockAndBlobsSidecar.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright ConsenSys Software Inc., 2022 - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ - -package tech.pegasys.teku.api.schema.deneb; - -import com.fasterxml.jackson.annotation.JsonProperty; -import tech.pegasys.teku.api.schema.SignedBeaconBlock; -import tech.pegasys.teku.spec.Spec; -import tech.pegasys.teku.spec.datastructures.blocks.blockbody.versions.deneb.SignedBeaconBlockAndBlobsSidecarSchema; - -public class SignedBeaconBlockAndBlobsSidecar { - - @JsonProperty("beacon_block") - private final SignedBeaconBlockDeneb signedBeaconBlock; - - @JsonProperty("blobs_sidecar") - private final BlobsSidecar blobsSidecar; - - public SignedBeaconBlockAndBlobsSidecar( - @JsonProperty("beacon_block") final SignedBeaconBlockDeneb signedBeaconBlock, - @JsonProperty("blobs_sidecar") final BlobsSidecar blobsSidecar) { - this.signedBeaconBlock = signedBeaconBlock; - this.blobsSidecar = blobsSidecar; - } - - public SignedBeaconBlockAndBlobsSidecar( - final tech.pegasys.teku.spec.datastructures.blocks.blockbody.versions.deneb - .SignedBeaconBlockAndBlobsSidecar - signedBeaconBlockAndBlobsSidecar) { - this.signedBeaconBlock = - (SignedBeaconBlockDeneb) - SignedBeaconBlock.create(signedBeaconBlockAndBlobsSidecar.getSignedBeaconBlock()); - this.blobsSidecar = BlobsSidecar.create(signedBeaconBlockAndBlobsSidecar.getBlobsSidecar()); - } - - public tech.pegasys.teku.spec.datastructures.blocks.blockbody.versions.deneb - .SignedBeaconBlockAndBlobsSidecar - asInternalSignedBeaconBlockAndBlobsSidecar( - final SignedBeaconBlockAndBlobsSidecarSchema schema, final Spec spec) { - return schema.create( - signedBeaconBlock.asInternalSignedBeaconBlock(spec), - blobsSidecar.asInternalBlobSidecar(schema.getBlobsSidecarSchema())); - } -} diff --git a/data/serializer/src/property-test/java/tech/pegasys/teku/provider/JsonProviderPropertyTest.java b/data/serializer/src/property-test/java/tech/pegasys/teku/provider/JsonProviderPropertyTest.java index c8fc5839876..de5434e52e8 100644 --- a/data/serializer/src/property-test/java/tech/pegasys/teku/provider/JsonProviderPropertyTest.java +++ b/data/serializer/src/property-test/java/tech/pegasys/teku/provider/JsonProviderPropertyTest.java @@ -56,8 +56,6 @@ import tech.pegasys.teku.api.schema.capella.BeaconStateCapella; import tech.pegasys.teku.api.schema.capella.SignedBeaconBlockCapella; import tech.pegasys.teku.api.schema.deneb.BeaconStateDeneb; -import tech.pegasys.teku.api.schema.deneb.BlobsSidecar; -import tech.pegasys.teku.api.schema.deneb.SignedBeaconBlockAndBlobsSidecar; import tech.pegasys.teku.api.schema.deneb.SignedBeaconBlockDeneb; import tech.pegasys.teku.api.schema.phase0.BeaconStatePhase0; import tech.pegasys.teku.api.schema.phase0.SignedBeaconBlockPhase0; @@ -69,7 +67,6 @@ import tech.pegasys.teku.spec.Spec; import tech.pegasys.teku.spec.SpecMilestone; import tech.pegasys.teku.spec.TestSpecFactory; -import tech.pegasys.teku.spec.datastructures.blocks.blockbody.versions.deneb.SignedBeaconBlockAndBlobsSidecarSchema; import tech.pegasys.teku.spec.networks.Eth2Network; import tech.pegasys.teku.spec.propertytest.suppliers.SpecSupplier; import tech.pegasys.teku.spec.util.DataStructureUtil; @@ -420,40 +417,4 @@ void roundTripKZGCommitment(@ForAll final int seed) throws JsonProcessingExcepti final KZGCommitment deserialized = jsonProvider.jsonToObject(serialized, KZGCommitment.class); assertThat(deserialized).isEqualTo(original); } - - @Property - void roundTripBlobsSidecar(@ForAll final int seed) throws JsonProcessingException { - final SpecMilestone specMilestone = SpecMilestone.DENEB; - final Spec spec = TestSpecFactory.create(specMilestone, Eth2Network.MINIMAL); - final DataStructureUtil dataStructureUtil = new DataStructureUtil(seed, spec); - final BlobsSidecar original = new BlobsSidecar(dataStructureUtil.randomBlobsSidecar()); - final String serialized = jsonProvider.objectToJSON(original); - final BlobsSidecar deserialized = jsonProvider.jsonToObject(serialized, BlobsSidecar.class); - assertThat(deserialized).usingRecursiveComparison().isEqualTo(original); - } - - @Property - void roundTripSignedBeaconBlockAndBlobsSidecar(@ForAll final int seed) - throws JsonProcessingException { - final SpecMilestone specMilestone = SpecMilestone.DENEB; - final Spec spec = TestSpecFactory.create(specMilestone, Eth2Network.MINIMAL); - final DataStructureUtil dataStructureUtil = new DataStructureUtil(seed, spec); - final SignedBeaconBlockAndBlobsSidecar original = - new SignedBeaconBlockAndBlobsSidecar( - dataStructureUtil.randomSignedBeaconBlockAndBlobsSidecar()); - final String serialized = jsonProvider.objectToJSON(original); - final SignedBeaconBlockAndBlobsSidecar deserialized = - jsonProvider.jsonToObject(serialized, SignedBeaconBlockAndBlobsSidecar.class); - final SignedBeaconBlockAndBlobsSidecarSchema signedBeaconBlockAndBlobsSidecarSchema = - spec.getGenesisSchemaDefinitions() - .toVersionDeneb() - .orElseThrow() - .getSignedBeaconBlockAndBlobsSidecarSchema(); - assertThat( - deserialized.asInternalSignedBeaconBlockAndBlobsSidecar( - signedBeaconBlockAndBlobsSidecarSchema, spec)) - .isEqualTo( - original.asInternalSignedBeaconBlockAndBlobsSidecar( - signedBeaconBlockAndBlobsSidecarSchema, spec)); - } } diff --git a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/blobs/versions/deneb/BlobsSidecar.java b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/blobs/versions/deneb/BlobsSidecar.java deleted file mode 100644 index d495ae00ba7..00000000000 --- a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/blobs/versions/deneb/BlobsSidecar.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright ConsenSys Software Inc., 2022 - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ - -package tech.pegasys.teku.spec.datastructures.blobs.versions.deneb; - -import java.util.List; -import org.apache.tuweni.bytes.Bytes32; -import tech.pegasys.teku.infrastructure.ssz.SszList; -import tech.pegasys.teku.infrastructure.ssz.containers.Container4; -import tech.pegasys.teku.infrastructure.ssz.primitive.SszBytes32; -import tech.pegasys.teku.infrastructure.ssz.primitive.SszUInt64; -import tech.pegasys.teku.infrastructure.ssz.tree.TreeNode; -import tech.pegasys.teku.infrastructure.unsigned.UInt64; -import tech.pegasys.teku.kzg.KZGProof; -import tech.pegasys.teku.spec.datastructures.type.SszKZGProof; - -public class BlobsSidecar - extends Container4, SszKZGProof> { - - BlobsSidecar(final BlobsSidecarSchema type, final TreeNode backingNode) { - super(type, backingNode); - } - - public BlobsSidecar( - final BlobsSidecarSchema schema, - final Bytes32 beaconBlockRoot, - final UInt64 beaconBlockSlot, - final List blobs, - final KZGProof kzgAggregatedProof) { - super( - schema, - SszBytes32.of(beaconBlockRoot), - SszUInt64.of(beaconBlockSlot), - schema.getBlobsSchema().createFromElements(blobs), - new SszKZGProof(kzgAggregatedProof)); - } - - public Bytes32 getBeaconBlockRoot() { - return getField0().get(); - } - - public UInt64 getBeaconBlockSlot() { - return getField1().get(); - } - - public List getBlobs() { - return getField2().asList(); - } - - public KZGProof getKZGAggregatedProof() { - return getField3().getKZGProof(); - } -} diff --git a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/blobs/versions/deneb/BlobsSidecarSchema.java b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/blobs/versions/deneb/BlobsSidecarSchema.java deleted file mode 100644 index 2becb74caad..00000000000 --- a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/blobs/versions/deneb/BlobsSidecarSchema.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright ConsenSys Software Inc., 2022 - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ - -package tech.pegasys.teku.spec.datastructures.blobs.versions.deneb; - -import java.util.List; -import java.util.stream.Collectors; -import org.apache.tuweni.bytes.Bytes; -import org.apache.tuweni.bytes.Bytes32; -import org.apache.tuweni.bytes.Bytes48; -import tech.pegasys.teku.infrastructure.ssz.SszList; -import tech.pegasys.teku.infrastructure.ssz.containers.ContainerSchema4; -import tech.pegasys.teku.infrastructure.ssz.primitive.SszBytes32; -import tech.pegasys.teku.infrastructure.ssz.primitive.SszUInt64; -import tech.pegasys.teku.infrastructure.ssz.schema.SszFieldName; -import tech.pegasys.teku.infrastructure.ssz.schema.SszListSchema; -import tech.pegasys.teku.infrastructure.ssz.schema.SszPrimitiveSchemas; -import tech.pegasys.teku.infrastructure.ssz.tree.TreeNode; -import tech.pegasys.teku.infrastructure.unsigned.UInt64; -import tech.pegasys.teku.kzg.KZGProof; -import tech.pegasys.teku.spec.config.SpecConfigDeneb; -import tech.pegasys.teku.spec.datastructures.type.SszKZGProof; -import tech.pegasys.teku.spec.datastructures.type.SszKZGProofSchema; - -public class BlobsSidecarSchema - extends ContainerSchema4, SszKZGProof> { - - static final SszFieldName FIELD_BLOBS = () -> "blobs"; - - BlobsSidecarSchema(final SpecConfigDeneb specConfig, final BlobSchema blobSchema) { - super( - "BlobsSidecar", - namedSchema("beacon_block_root", SszPrimitiveSchemas.BYTES32_SCHEMA), - namedSchema("beacon_block_slot", SszPrimitiveSchemas.UINT64_SCHEMA), - namedSchema( - FIELD_BLOBS, SszListSchema.create(blobSchema, specConfig.getMaxBlobsPerBlock())), - namedSchema("kzg_aggregated_proof", SszKZGProofSchema.INSTANCE)); - } - - @SuppressWarnings("unchecked") - public SszListSchema getBlobsSchema() { - return (SszListSchema) getChildSchema(getFieldIndex(FIELD_BLOBS)); - } - - public BlobSchema getBlobSchema() { - return (BlobSchema) getBlobsSchema().getElementSchema(); - } - - public BlobsSidecar create( - final Bytes32 beaconBlockRoot, - final UInt64 beaconBlockSlot, - final List blobs, - final Bytes48 kzgAggregatedProof) { - return new BlobsSidecar( - this, - beaconBlockRoot, - beaconBlockSlot, - blobs.stream().map(bytes -> new Blob(getBlobSchema(), bytes)).collect(Collectors.toList()), - KZGProof.fromBytesCompressed(kzgAggregatedProof)); - } - - public BlobsSidecar createEmpty(final Bytes32 beaconBlockRoot, final UInt64 beaconBlockSlot) { - return new BlobsSidecar(this, beaconBlockRoot, beaconBlockSlot, List.of(), KZGProof.INFINITY); - } - - public static BlobsSidecarSchema create( - final SpecConfigDeneb specConfig, final BlobSchema blobSchema) { - return new BlobsSidecarSchema(specConfig, blobSchema); - } - - @Override - public BlobsSidecar createFromBackingNode(final TreeNode node) { - return new BlobsSidecar(this, node); - } -} diff --git a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/blocks/blockbody/versions/deneb/SignedBeaconBlockAndBlobsSidecar.java b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/blocks/blockbody/versions/deneb/SignedBeaconBlockAndBlobsSidecar.java deleted file mode 100644 index c87f4437d9e..00000000000 --- a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/blocks/blockbody/versions/deneb/SignedBeaconBlockAndBlobsSidecar.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright ConsenSys Software Inc., 2022 - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ - -package tech.pegasys.teku.spec.datastructures.blocks.blockbody.versions.deneb; - -import tech.pegasys.teku.infrastructure.ssz.containers.Container2; -import tech.pegasys.teku.infrastructure.ssz.tree.TreeNode; -import tech.pegasys.teku.spec.datastructures.blobs.versions.deneb.BlobsSidecar; -import tech.pegasys.teku.spec.datastructures.blocks.SignedBeaconBlock; - -public class SignedBeaconBlockAndBlobsSidecar - extends Container2 { - - SignedBeaconBlockAndBlobsSidecar( - final SignedBeaconBlockAndBlobsSidecarSchema type, final TreeNode backingNode) { - super(type, backingNode); - } - - public SignedBeaconBlockAndBlobsSidecar( - final SignedBeaconBlockAndBlobsSidecarSchema schema, - final SignedBeaconBlock signedBeaconBlock, - final BlobsSidecar blobsSidecar) { - super(schema, signedBeaconBlock, blobsSidecar); - } - - public SignedBeaconBlock getSignedBeaconBlock() { - return getField0(); - } - - public BlobsSidecar getBlobsSidecar() { - return getField1(); - } -} diff --git a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/blocks/blockbody/versions/deneb/SignedBeaconBlockAndBlobsSidecarSchema.java b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/blocks/blockbody/versions/deneb/SignedBeaconBlockAndBlobsSidecarSchema.java deleted file mode 100644 index 449927d5ddc..00000000000 --- a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/blocks/blockbody/versions/deneb/SignedBeaconBlockAndBlobsSidecarSchema.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright ConsenSys Software Inc., 2022 - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ - -package tech.pegasys.teku.spec.datastructures.blocks.blockbody.versions.deneb; - -import tech.pegasys.teku.infrastructure.ssz.containers.ContainerSchema2; -import tech.pegasys.teku.infrastructure.ssz.tree.TreeNode; -import tech.pegasys.teku.spec.datastructures.blobs.versions.deneb.BlobsSidecar; -import tech.pegasys.teku.spec.datastructures.blobs.versions.deneb.BlobsSidecarSchema; -import tech.pegasys.teku.spec.datastructures.blocks.SignedBeaconBlock; -import tech.pegasys.teku.spec.datastructures.blocks.SignedBeaconBlockSchema; - -public class SignedBeaconBlockAndBlobsSidecarSchema - extends ContainerSchema2 { - - SignedBeaconBlockAndBlobsSidecarSchema( - final SignedBeaconBlockSchema signedBeaconBlockSchema, - final BlobsSidecarSchema blobsSidecarSchema) { - super( - "SignedBeaconBlockAndBlobsSidecar", - namedSchema("beacon_block", signedBeaconBlockSchema), - namedSchema("blobs_sidecar", blobsSidecarSchema)); - } - - public static SignedBeaconBlockAndBlobsSidecarSchema create( - final SignedBeaconBlockSchema signedBeaconBlockSchema, - final BlobsSidecarSchema blobsSidecarSchema) { - return new SignedBeaconBlockAndBlobsSidecarSchema(signedBeaconBlockSchema, blobsSidecarSchema); - } - - public SignedBeaconBlockAndBlobsSidecar create( - final SignedBeaconBlock signedBeaconBlock, final BlobsSidecar blobsSidecar) { - return new SignedBeaconBlockAndBlobsSidecar(this, signedBeaconBlock, blobsSidecar); - } - - @Override - public SignedBeaconBlockAndBlobsSidecar createFromBackingNode(final TreeNode node) { - return new SignedBeaconBlockAndBlobsSidecar(this, node); - } - - public BlobsSidecarSchema getBlobsSidecarSchema() { - return (BlobsSidecarSchema) getFieldSchema1(); - } -} diff --git a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/execution/ExecutionPayloadResult.java b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/execution/ExecutionPayloadResult.java index 5c8d38926d0..cd3fb74eeea 100644 --- a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/execution/ExecutionPayloadResult.java +++ b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/execution/ExecutionPayloadResult.java @@ -55,11 +55,11 @@ public Optional> getBlobsBundleFuture() { return blobsBundleFuture; } - public Optional>> getCommitments() { + public Optional>> getCommitmentsFuture() { return blobsBundleFuture.map(future -> future.thenApply(BlobsBundle::getCommitments)); } - public Optional>> getBlobs() { + public Optional>> getBlobsFuture() { return blobsBundleFuture.map(future -> future.thenApply(BlobsBundle::getBlobs)); } diff --git a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/schemas/SchemaDefinitionsDeneb.java b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/schemas/SchemaDefinitionsDeneb.java index 1b7e5c3b969..510b3c88f17 100644 --- a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/schemas/SchemaDefinitionsDeneb.java +++ b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/schemas/SchemaDefinitionsDeneb.java @@ -22,7 +22,6 @@ import tech.pegasys.teku.spec.datastructures.blobs.versions.deneb.BlobSchema; import tech.pegasys.teku.spec.datastructures.blobs.versions.deneb.BlobSidecarSchema; import tech.pegasys.teku.spec.datastructures.blobs.versions.deneb.BlobSidecarsSchema; -import tech.pegasys.teku.spec.datastructures.blobs.versions.deneb.BlobsSidecarSchema; import tech.pegasys.teku.spec.datastructures.blobs.versions.deneb.SignedBlindedBlobSidecarSchema; import tech.pegasys.teku.spec.datastructures.blobs.versions.deneb.SignedBlindedBlobSidecarsSchema; import tech.pegasys.teku.spec.datastructures.blobs.versions.deneb.SignedBlobSidecarSchema; @@ -34,7 +33,6 @@ import tech.pegasys.teku.spec.datastructures.blocks.blockbody.versions.deneb.BeaconBlockBodySchemaDenebImpl; import tech.pegasys.teku.spec.datastructures.blocks.blockbody.versions.deneb.BlindedBeaconBlockBodySchemaDeneb; import tech.pegasys.teku.spec.datastructures.blocks.blockbody.versions.deneb.BlindedBeaconBlockBodySchemaDenebImpl; -import tech.pegasys.teku.spec.datastructures.blocks.blockbody.versions.deneb.SignedBeaconBlockAndBlobsSidecarSchema; import tech.pegasys.teku.spec.datastructures.blocks.versions.deneb.BlindedBlockContentsSchema; import tech.pegasys.teku.spec.datastructures.blocks.versions.deneb.BlockContentsSchema; import tech.pegasys.teku.spec.datastructures.blocks.versions.deneb.SignedBlindedBlockContentsSchema; @@ -71,8 +69,6 @@ public class SchemaDefinitionsDeneb extends SchemaDefinitionsCapella { private final BlobSchema blobSchema; private final BlobSidecarSchema blobSidecarSchema; - private final BlobsSidecarSchema blobsSidecarSchema; - private final SignedBeaconBlockAndBlobsSidecarSchema signedBeaconBlockAndBlobsSidecarSchema; private final SignedBlobSidecarSchema signedBlobSidecarSchema; private final BlobSidecarsSchema blobSidecarsSchema; private final SignedBlobSidecarsSchema signedBlobSidecarsSchema; @@ -119,10 +115,7 @@ public SchemaDefinitionsDeneb(final SpecConfigDeneb specConfig) { new SignedBuilderBidSchema("SignedBuilderBidDeneb", builderBidSchemaDeneb); this.blobSchema = new BlobSchema(specConfig); - this.blobsSidecarSchema = BlobsSidecarSchema.create(specConfig, blobSchema); this.blobSidecarSchema = BlobSidecarSchema.create(blobSchema); - this.signedBeaconBlockAndBlobsSidecarSchema = - SignedBeaconBlockAndBlobsSidecarSchema.create(signedBeaconBlockSchema, blobsSidecarSchema); this.signedBlobSidecarSchema = SignedBlobSidecarSchema.create(blobSidecarSchema); this.signedBlobSidecarsSchema = SignedBlobSidecarsSchema.create(specConfig, signedBlobSidecarSchema); @@ -213,18 +206,10 @@ public BlobSchema getBlobSchema() { return blobSchema; } - public BlobsSidecarSchema getBlobsSidecarSchema() { - return blobsSidecarSchema; - } - public BlobSidecarSchema getBlobSidecarSchema() { return blobSidecarSchema; } - public SignedBeaconBlockAndBlobsSidecarSchema getSignedBeaconBlockAndBlobsSidecarSchema() { - return signedBeaconBlockAndBlobsSidecarSchema; - } - public SignedBlobSidecarSchema getSignedBlobSidecarSchema() { return signedBlobSidecarSchema; } diff --git a/ethereum/spec/src/property-test/java/tech/pegasys/teku/spec/datastructures/blocks/versions/deneb/SignedBeaconBlockAndBlobsSidecarPropertyTest.java b/ethereum/spec/src/property-test/java/tech/pegasys/teku/spec/datastructures/blocks/versions/deneb/SignedBeaconBlockAndBlobsSidecarPropertyTest.java deleted file mode 100644 index 7a82f5d03a2..00000000000 --- a/ethereum/spec/src/property-test/java/tech/pegasys/teku/spec/datastructures/blocks/versions/deneb/SignedBeaconBlockAndBlobsSidecarPropertyTest.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright ConsenSys Software Inc., 2022 - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ - -package tech.pegasys.teku.spec.datastructures.blocks.versions.deneb; - -import static tech.pegasys.teku.spec.propertytest.util.PropertyTestHelper.assertDeserializeMutatedThrowsExpected; -import static tech.pegasys.teku.spec.propertytest.util.PropertyTestHelper.assertRoundTrip; - -import com.fasterxml.jackson.core.JsonProcessingException; -import net.jqwik.api.ForAll; -import net.jqwik.api.Property; -import tech.pegasys.teku.spec.datastructures.blocks.blockbody.versions.deneb.SignedBeaconBlockAndBlobsSidecar; -import tech.pegasys.teku.spec.propertytest.suppliers.blocks.versions.deneb.SignedBeaconBlockAndBlobsSidecarSupplier; - -public class SignedBeaconBlockAndBlobsSidecarPropertyTest { - @Property - void roundTrip( - @ForAll(supplier = SignedBeaconBlockAndBlobsSidecarSupplier.class) - final SignedBeaconBlockAndBlobsSidecar signedBeaconBlockAndBlobsSidecar) - throws JsonProcessingException { - assertRoundTrip(signedBeaconBlockAndBlobsSidecar); - } - - @Property - void deserializeMutated( - @ForAll(supplier = SignedBeaconBlockAndBlobsSidecarSupplier.class) - final SignedBeaconBlockAndBlobsSidecar signedBeaconBlockAndBlobsSidecar, - @ForAll final int seed) { - assertDeserializeMutatedThrowsExpected(signedBeaconBlockAndBlobsSidecar, seed); - } -} diff --git a/ethereum/spec/src/test/java/tech/pegasys/teku/spec/datastructures/blobs/versions/deneb/BlobsSidecarTest.java b/ethereum/spec/src/test/java/tech/pegasys/teku/spec/datastructures/blobs/versions/deneb/BlobsSidecarTest.java deleted file mode 100644 index 0939da5e552..00000000000 --- a/ethereum/spec/src/test/java/tech/pegasys/teku/spec/datastructures/blobs/versions/deneb/BlobsSidecarTest.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright ConsenSys Software Inc., 2022 - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ - -package tech.pegasys.teku.spec.datastructures.blobs.versions.deneb; - -import static java.util.stream.Collectors.toList; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -import com.google.common.collect.Streams; -import java.util.List; -import java.util.stream.IntStream; -import java.util.stream.Stream; -import org.apache.tuweni.bytes.Bytes; -import org.apache.tuweni.bytes.Bytes32; -import org.apache.tuweni.bytes.Bytes48; -import org.junit.jupiter.api.Test; -import tech.pegasys.teku.infrastructure.unsigned.UInt64; -import tech.pegasys.teku.spec.SpecMilestone; -import tech.pegasys.teku.spec.TestSpecFactory; -import tech.pegasys.teku.spec.schemas.SchemaDefinitions; -import tech.pegasys.teku.spec.util.DataStructureUtil; - -class BlobsSidecarTest { - - private final DataStructureUtil dataStructureUtil = - new DataStructureUtil(TestSpecFactory.createMinimal(SpecMilestone.DENEB)); - final SchemaDefinitions schemaDefinitions = - dataStructureUtil.getSpec().getGenesisSchemaDefinitions(); - private final BlobsSidecarSchema blobsSidecarSchema = - schemaDefinitions.toVersionDeneb().orElseThrow().getBlobsSidecarSchema(); - - private final Bytes32 beaconBlockRoot = dataStructureUtil.randomBytes32(); - private final UInt64 beaconBlockSlot = dataStructureUtil.randomUInt64(); - private final List blobs = - IntStream.range(0, (int) blobsSidecarSchema.getBlobsSchema().getMaxLength()) - .mapToObj( - __ -> dataStructureUtil.randomBytes(blobsSidecarSchema.getBlobSchema().getLength())) - .collect(toList()); - private final Bytes48 kzgAggregatedProof = dataStructureUtil.randomBytes48(); - - @Test - public void objectEquality() { - final BlobsSidecar blobsSidecar1 = - blobsSidecarSchema.create(beaconBlockRoot, beaconBlockSlot, blobs, kzgAggregatedProof); - final BlobsSidecar blobsSidecar2 = - blobsSidecarSchema.create(beaconBlockRoot, beaconBlockSlot, blobs, kzgAggregatedProof); - - assertThat(blobsSidecar1).isEqualTo(blobsSidecar2); - } - - @Test - public void objectAccessorMethods() { - final BlobsSidecar blobsSidecar = - blobsSidecarSchema.create(beaconBlockRoot, beaconBlockSlot, blobs, kzgAggregatedProof); - - assertThat(blobsSidecar.getBeaconBlockRoot()).isEqualTo(beaconBlockRoot); - assertThat(blobsSidecar.getBeaconBlockSlot()).isEqualTo(beaconBlockSlot); - assertThat(blobsSidecar.getBlobs().stream().map(Blob::getBytes).collect(toList())) - .isEqualTo(blobs); - assertThat(blobsSidecar.getKZGAggregatedProof().getBytesCompressed()) - .isEqualTo(kzgAggregatedProof); - } - - @Test - public void moreBlobsThanAllowed() { - assertThatThrownBy( - () -> - blobsSidecarSchema.create( - beaconBlockRoot, - beaconBlockSlot, - Streams.concat(blobs.stream(), Stream.of(blobs.get(0))).collect(toList()), - kzgAggregatedProof)) - .isInstanceOf(IllegalArgumentException.class); - } - - @Test - public void roundTripSSZ() { - final BlobsSidecar blobsSidecar = - blobsSidecarSchema.create(beaconBlockRoot, beaconBlockSlot, blobs, kzgAggregatedProof); - - final Bytes sszBlobsSidecarBytes = blobsSidecar.sszSerialize(); - final BlobsSidecar deserializedObject = blobsSidecarSchema.sszDeserialize(sszBlobsSidecarBytes); - - assertThat(blobsSidecar).isEqualTo(deserializedObject); - } -} diff --git a/ethereum/spec/src/test/java/tech/pegasys/teku/spec/datastructures/blocks/blockbody/versions/deneb/SignedBeaconBlockAndBlobsSidecarTest.java b/ethereum/spec/src/test/java/tech/pegasys/teku/spec/datastructures/blocks/blockbody/versions/deneb/SignedBeaconBlockAndBlobsSidecarTest.java deleted file mode 100644 index 01308382db9..00000000000 --- a/ethereum/spec/src/test/java/tech/pegasys/teku/spec/datastructures/blocks/blockbody/versions/deneb/SignedBeaconBlockAndBlobsSidecarTest.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright ConsenSys Software Inc., 2022 - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ - -package tech.pegasys.teku.spec.datastructures.blocks.blockbody.versions.deneb; - -import static org.assertj.core.api.Assertions.assertThat; - -import org.apache.tuweni.bytes.Bytes; -import org.junit.jupiter.api.Test; -import tech.pegasys.teku.spec.SpecMilestone; -import tech.pegasys.teku.spec.TestSpecFactory; -import tech.pegasys.teku.spec.datastructures.blobs.versions.deneb.BlobsSidecar; -import tech.pegasys.teku.spec.datastructures.blocks.SignedBeaconBlock; -import tech.pegasys.teku.spec.schemas.SchemaDefinitions; -import tech.pegasys.teku.spec.util.DataStructureUtil; - -class SignedBeaconBlockAndBlobsSidecarTest { - - private final DataStructureUtil dataStructureUtil = - new DataStructureUtil(TestSpecFactory.createMinimal(SpecMilestone.DENEB)); - final SchemaDefinitions schemaDefinitions = - dataStructureUtil.getSpec().getGenesisSchemaDefinitions(); - private final SignedBeaconBlockAndBlobsSidecarSchema signedBeaconBlockAndBlobsSidecarSchema = - schemaDefinitions.toVersionDeneb().orElseThrow().getSignedBeaconBlockAndBlobsSidecarSchema(); - - private final SignedBeaconBlock signedBeaconBlock = dataStructureUtil.randomSignedBeaconBlock(); - private final BlobsSidecar blobsSidecar = dataStructureUtil.randomBlobsSidecar(); - - @Test - public void objectEquality() { - final SignedBeaconBlockAndBlobsSidecar signedBeaconBlockAndBlobsSidecar1 = - signedBeaconBlockAndBlobsSidecarSchema.create(signedBeaconBlock, blobsSidecar); - final SignedBeaconBlockAndBlobsSidecar signedBeaconBlockAndBlobsSidecar2 = - signedBeaconBlockAndBlobsSidecarSchema.create(signedBeaconBlock, blobsSidecar); - - assertThat(signedBeaconBlockAndBlobsSidecar1).isEqualTo(signedBeaconBlockAndBlobsSidecar2); - } - - @Test - public void objectAccessorMethods() { - final SignedBeaconBlockAndBlobsSidecar signedBeaconBlockAndBlobsSidecar = - signedBeaconBlockAndBlobsSidecarSchema.create(signedBeaconBlock, blobsSidecar); - - assertThat(signedBeaconBlockAndBlobsSidecar.getSignedBeaconBlock()) - .isEqualTo(signedBeaconBlock); - assertThat(signedBeaconBlockAndBlobsSidecar.getBlobsSidecar()).isEqualTo(blobsSidecar); - } - - @Test - public void roundTripSSZ() { - final SignedBeaconBlockAndBlobsSidecar signedBeaconBlockAndBlobsSidecar = - signedBeaconBlockAndBlobsSidecarSchema.create(signedBeaconBlock, blobsSidecar); - - final Bytes sszSignedBeaconBlockAndBlobsSidecarBytes = - signedBeaconBlockAndBlobsSidecar.sszSerialize(); - final SignedBeaconBlockAndBlobsSidecar deserializedObject = - signedBeaconBlockAndBlobsSidecarSchema.sszDeserialize( - sszSignedBeaconBlockAndBlobsSidecarBytes); - - assertThat(signedBeaconBlockAndBlobsSidecar).isEqualTo(deserializedObject); - } -} diff --git a/ethereum/spec/src/testFixtures/java/tech/pegasys/teku/spec/generator/ChainBuilder.java b/ethereum/spec/src/testFixtures/java/tech/pegasys/teku/spec/generator/ChainBuilder.java index 65469330888..ebdc58206c5 100644 --- a/ethereum/spec/src/testFixtures/java/tech/pegasys/teku/spec/generator/ChainBuilder.java +++ b/ethereum/spec/src/testFixtures/java/tech/pegasys/teku/spec/generator/ChainBuilder.java @@ -304,7 +304,7 @@ private SignedBlockAndState addGenesisBlock(final BeaconState genesisState) { final SignedBlockAndState blockAndState = new SignedBlockAndState(signedBlock, genesisState); trackBlock(blockAndState); - // add an empty blobs sidecar to the genesis block if genesis is in the Deneb milestone + // add an empty list of blob sidecars to the genesis block if genesis is in the Deneb milestone spec.getGenesisSchemaDefinitions() .toVersionDeneb() .ifPresent( diff --git a/ethereum/spec/src/testFixtures/java/tech/pegasys/teku/spec/propertytest/suppliers/blocks/versions/deneb/SignedBeaconBlockAndBlobsSidecarSupplier.java b/ethereum/spec/src/testFixtures/java/tech/pegasys/teku/spec/propertytest/suppliers/blocks/versions/deneb/SignedBeaconBlockAndBlobsSidecarSupplier.java deleted file mode 100644 index 1c8b086711f..00000000000 --- a/ethereum/spec/src/testFixtures/java/tech/pegasys/teku/spec/propertytest/suppliers/blocks/versions/deneb/SignedBeaconBlockAndBlobsSidecarSupplier.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright ConsenSys Software Inc., 2022 - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ - -package tech.pegasys.teku.spec.propertytest.suppliers.blocks.versions.deneb; - -import tech.pegasys.teku.spec.SpecMilestone; -import tech.pegasys.teku.spec.datastructures.blocks.blockbody.versions.deneb.SignedBeaconBlockAndBlobsSidecar; -import tech.pegasys.teku.spec.propertytest.suppliers.DataStructureUtilSupplier; -import tech.pegasys.teku.spec.util.DataStructureUtil; - -public class SignedBeaconBlockAndBlobsSidecarSupplier - extends DataStructureUtilSupplier { - public SignedBeaconBlockAndBlobsSidecarSupplier() { - super(DataStructureUtil::randomSignedBeaconBlockAndBlobsSidecar, SpecMilestone.DENEB); - } -} diff --git a/ethereum/spec/src/testFixtures/java/tech/pegasys/teku/spec/util/DataStructureUtil.java b/ethereum/spec/src/testFixtures/java/tech/pegasys/teku/spec/util/DataStructureUtil.java index 17b69f9fd1b..a8910c7779c 100644 --- a/ethereum/spec/src/testFixtures/java/tech/pegasys/teku/spec/util/DataStructureUtil.java +++ b/ethereum/spec/src/testFixtures/java/tech/pegasys/teku/spec/util/DataStructureUtil.java @@ -92,8 +92,6 @@ import tech.pegasys.teku.spec.datastructures.blobs.versions.deneb.BlobSidecarSchema; import tech.pegasys.teku.spec.datastructures.blobs.versions.deneb.BlobSidecars; import tech.pegasys.teku.spec.datastructures.blobs.versions.deneb.BlobsBundle; -import tech.pegasys.teku.spec.datastructures.blobs.versions.deneb.BlobsSidecar; -import tech.pegasys.teku.spec.datastructures.blobs.versions.deneb.BlobsSidecarSchema; import tech.pegasys.teku.spec.datastructures.blobs.versions.deneb.SignedBlindedBlobSidecar; import tech.pegasys.teku.spec.datastructures.blobs.versions.deneb.SignedBlindedBlobSidecarSchema; import tech.pegasys.teku.spec.datastructures.blobs.versions.deneb.SignedBlindedBlobSidecars; @@ -115,7 +113,6 @@ import tech.pegasys.teku.spec.datastructures.blocks.blockbody.versions.altair.SyncAggregateSchema; import tech.pegasys.teku.spec.datastructures.blocks.blockbody.versions.deneb.BeaconBlockBodyDeneb; import tech.pegasys.teku.spec.datastructures.blocks.blockbody.versions.deneb.BeaconBlockBodySchemaDeneb; -import tech.pegasys.teku.spec.datastructures.blocks.blockbody.versions.deneb.SignedBeaconBlockAndBlobsSidecar; import tech.pegasys.teku.spec.datastructures.blocks.versions.deneb.BlindedBlockContents; import tech.pegasys.teku.spec.datastructures.blocks.versions.deneb.BlockContents; import tech.pegasys.teku.spec.datastructures.blocks.versions.deneb.SignedBlindedBlockContents; @@ -2053,20 +2050,13 @@ public Bytes randomBlobBytes() { return randomBlob().getBytes(); } - public BlobsSidecar randomBlobsSidecar() { - return randomBlobsSidecar(randomBytes32(), randomUInt64()); - } - - public BlobsSidecar randomBlobsSidecar(final Bytes32 blockRoot, final UInt64 slot) { - final BlobsSidecarSchema blobsSidecarSchema = - SchemaDefinitionsDeneb.required(spec.atSlot(slot).getSchemaDefinitions()) - .getBlobsSidecarSchema(); - - return randomBlobsSidecar( - blockRoot, slot, randomInt((int) blobsSidecarSchema.getBlobsSchema().getMaxLength())); + public List randomBlobSidecarsForBlock(final SignedBeaconBlock block) { + return randomSignedBlobSidecarsForBlock(block).stream() + .map(SignedBlobSidecar::getBlobSidecar) + .collect(toList()); } - public List randomBlobSidecarsForBlock(final SignedBeaconBlock block) { + public List randomSignedBlobSidecarsForBlock(final SignedBeaconBlock block) { final int numberOfKzgCommitments = BeaconBlockBodyDeneb.required(block.getBeaconBlock().orElseThrow().getBody()) .getBlobKzgCommitments() @@ -2078,7 +2068,7 @@ public List randomBlobSidecarsForBlock(final SignedBeaconBlock bloc .slot(block.getSlot()) .blockRoot(block.getRoot()) .index(UInt64.valueOf(index)) - .build()) + .buildSigned()) .collect(toList()); } @@ -2125,21 +2115,6 @@ public List randomBlobIdentifiers(final int count) { return IntStream.range(0, count).mapToObj(__ -> randomBlobIdentifier()).collect(toList()); } - public BlobsSidecar randomBlobsSidecar( - final Bytes32 blockRoot, final UInt64 slot, final int numberOfBlobs) { - final BlobsSidecarSchema blobsSidecarSchema = - SchemaDefinitionsDeneb.required(spec.atSlot(slot).getSchemaDefinitions()) - .getBlobsSidecarSchema(); - - return blobsSidecarSchema.create( - blockRoot, - slot, - IntStream.range(0, numberOfBlobs) - .mapToObj(__ -> randomBytes(blobsSidecarSchema.getBlobSchema().getLength())) - .collect(toList()), - randomBytes48()); - } - public BlobsBundle randomBlobsBundle() { final BlobSchema blobSchema = SchemaDefinitionsDeneb.required(spec.getGenesisSchemaDefinitions()).getBlobSchema(); @@ -2157,12 +2132,6 @@ public BlobsBundle randomBlobsBundle() { .collect(toList())); } - public SignedBeaconBlockAndBlobsSidecar randomSignedBeaconBlockAndBlobsSidecar() { - return SchemaDefinitionsDeneb.required(spec.getGenesisSchemaDefinitions()) - .getSignedBeaconBlockAndBlobsSidecarSchema() - .create(randomSignedBeaconBlock(), randomBlobsSidecar()); - } - public SignedBlobSidecar randomSignedBlobSidecar() { return new RandomBlobSidecarBuilder().buildSigned(); } diff --git a/ethereum/statetransition/src/main/java/tech/pegasys/teku/statetransition/blobs/BlobSidecarManagerImpl.java b/ethereum/statetransition/src/main/java/tech/pegasys/teku/statetransition/blobs/BlobSidecarManagerImpl.java index eee787bb00b..293297c53ca 100644 --- a/ethereum/statetransition/src/main/java/tech/pegasys/teku/statetransition/blobs/BlobSidecarManagerImpl.java +++ b/ethereum/statetransition/src/main/java/tech/pegasys/teku/statetransition/blobs/BlobSidecarManagerImpl.java @@ -125,16 +125,16 @@ public boolean isAvailabilityRequiredAtSlot(final UInt64 slot) { @Override public BlobSidecarsAvailabilityChecker createAvailabilityChecker(final SignedBeaconBlock block) { - // Block is pre-Deneb, BlobsSidecar is not supported yet + // Block is pre-Deneb, blobs are not supported yet if (block.getMessage().getBody().toVersionDeneb().isEmpty()) { return BlobSidecarsAvailabilityChecker.NOT_REQUIRED; } - final BlockBlobSidecarsTracker blockBlobsSidecarsTracker = + final BlockBlobSidecarsTracker blockBlobSidecarsTracker = blobSidecarPool.getOrCreateBlockBlobSidecarsTracker(block); return new ForkChoiceBlobSidecarsAvailabilityChecker( - spec, asyncRunner, recentChainData, blockBlobsSidecarsTracker); + spec, asyncRunner, recentChainData, blockBlobSidecarsTracker); } @Override diff --git a/ethereum/statetransition/src/main/java/tech/pegasys/teku/statetransition/forkchoice/ForkChoiceBlobSidecarsAvailabilityChecker.java b/ethereum/statetransition/src/main/java/tech/pegasys/teku/statetransition/forkchoice/ForkChoiceBlobSidecarsAvailabilityChecker.java index d73dc61c042..cc38c8c76e3 100644 --- a/ethereum/statetransition/src/main/java/tech/pegasys/teku/statetransition/forkchoice/ForkChoiceBlobSidecarsAvailabilityChecker.java +++ b/ethereum/statetransition/src/main/java/tech/pegasys/teku/statetransition/forkchoice/ForkChoiceBlobSidecarsAvailabilityChecker.java @@ -242,7 +242,7 @@ private SafeFuture completeValidation( /** * Knowing that: * - *

(1) `validatedBlobSidecars` contains already validated blobsSidecars + *

(1) `validatedBlobSidecars` contains already validated blobSidecars * *

(2) `blockBlobSidecarsTracker` is now completed * diff --git a/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/forkchoice/ForkChoiceTest.java b/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/forkchoice/ForkChoiceTest.java index 37c7bfc3489..ca5a411c8d0 100644 --- a/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/forkchoice/ForkChoiceTest.java +++ b/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/forkchoice/ForkChoiceTest.java @@ -39,7 +39,6 @@ import org.apache.tuweni.bytes.Bytes32; import org.apache.tuweni.units.bigints.UInt256; import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; @@ -60,6 +59,7 @@ import tech.pegasys.teku.spec.SpecMilestone; import tech.pegasys.teku.spec.TestSpecFactory; import tech.pegasys.teku.spec.datastructures.attestation.ValidateableAttestation; +import tech.pegasys.teku.spec.datastructures.blobs.versions.deneb.BlobSidecar; import tech.pegasys.teku.spec.datastructures.blocks.Eth1Data; import tech.pegasys.teku.spec.datastructures.blocks.MinimalBeaconBlockSummary; import tech.pegasys.teku.spec.datastructures.blocks.SignedBlockAndState; @@ -81,6 +81,7 @@ import tech.pegasys.teku.spec.generator.ChainBuilder.BlockOptions; import tech.pegasys.teku.spec.logic.common.statetransition.results.BlockImportResult; import tech.pegasys.teku.spec.logic.common.statetransition.results.BlockImportResult.FailureReason; +import tech.pegasys.teku.spec.logic.versions.deneb.blobs.BlobSidecarsAndValidationResult; import tech.pegasys.teku.spec.logic.versions.deneb.blobs.BlobSidecarsAvailabilityChecker; import tech.pegasys.teku.spec.util.DataStructureUtil; import tech.pegasys.teku.statetransition.blobs.BlobSidecarManager; @@ -100,6 +101,8 @@ class ForkChoiceTest { private final Spec spec = TestSpecFactory.createMinimalDeneb(); private final DataStructureUtil dataStructureUtil = new DataStructureUtil(spec); private final BlobSidecarManager blobSidecarManager = mock(BlobSidecarManager.class); + private final BlobSidecarsAvailabilityChecker blobSidecarsAvailabilityChecker = + mock(BlobSidecarsAvailabilityChecker.class); private final AttestationSchema attestationSchema = spec.getGenesisSchemaDefinitions().getAttestationSchema(); private final StorageSystem storageSystem = @@ -154,7 +157,12 @@ public void setup() { // blobs always available if (spec.isMilestoneSupported(SpecMilestone.DENEB)) { when(blobSidecarManager.createAvailabilityChecker(any())) - .thenReturn(BlobSidecarsAvailabilityChecker.NOOP); + .thenReturn(blobSidecarsAvailabilityChecker); + final List blobSidecars = dataStructureUtil.randomBlobSidecars(2); + when(blobSidecarsAvailabilityChecker.getAvailabilityCheckResult()) + .thenReturn( + SafeFuture.completedFuture( + BlobSidecarsAndValidationResult.validResult(blobSidecars))); } } @@ -173,7 +181,6 @@ void shouldNotTriggerReorgWhenEmptyHeadSlotFilled() { assertThat(reorgEvents).isEmpty(); } - @Disabled("enable and fix when decoupled blob fork choice changes are implemented") @Test void onBlock_shouldCheckBlobsAvailability() { final SignedBlockAndState blockAndState = chainBuilder.generateBlockAtSlot(ONE); @@ -181,42 +188,39 @@ void onBlock_shouldCheckBlobsAvailability() { importBlock(blockAndState); - // verify(blobSidecarManager).createAvailabilityChecker(blockAndState.getBlock()); - // verify(blobSidecarAvailabilityChecker).initiateDataAvailabilityCheck(); - // verify(blobSidecarAvailabilityChecker).getAvailabilityCheckResult(); + verify(blobSidecarManager).createAvailabilityChecker(blockAndState.getBlock()); + verify(blobSidecarsAvailabilityChecker).initiateDataAvailabilityCheck(); + verify(blobSidecarsAvailabilityChecker).getAvailabilityCheckResult(); } - @Disabled("enable and fix when decoupled blob fork choice changes are implemented") @Test void onBlock_shouldFailIfBlobsAreNotAvailable() { final SignedBlockAndState blockAndState = chainBuilder.generateBlockAtSlot(ONE); storageSystem.chainUpdater().advanceCurrentSlotToAtLeast(blockAndState.getSlot()); - // when(blobsSidecarAvailabilityChecker.getAvailabilityCheckResult()) - // - // .thenReturn(SafeFuture.completedFuture(BlobsSidecarAndValidationResult.NOT_AVAILABLE)); + when(blobSidecarsAvailabilityChecker.getAvailabilityCheckResult()) + .thenReturn(SafeFuture.completedFuture(BlobSidecarsAndValidationResult.NOT_AVAILABLE)); - importBlockWithError(blockAndState, FailureReason.FAILED_DATA_AVAILABILITY_CHECK_INVALID); + importBlockWithError(blockAndState, FailureReason.FAILED_DATA_AVAILABILITY_CHECK_NOT_AVAILABLE); - // verify(blobSidecarManager).createAvailabilityChecker(blockAndState.getBlock()); - // verify(blobSidecarAvailabilityChecker).initiateDataAvailabilityCheck(); - // verify(blobSidecarAvailabilityChecker).getAvailabilityCheckResult(); + verify(blobSidecarManager).createAvailabilityChecker(blockAndState.getBlock()); + verify(blobSidecarsAvailabilityChecker).initiateDataAvailabilityCheck(); + verify(blobSidecarsAvailabilityChecker).getAvailabilityCheckResult(); } - @Disabled("enable and fix when decoupled blob fork choice changes are implemented") @Test void onBlock_shouldImportIfBlobsAreNotRequired() { final SignedBlockAndState blockAndState = chainBuilder.generateBlockAtSlot(ONE); storageSystem.chainUpdater().advanceCurrentSlotToAtLeast(blockAndState.getSlot()); - // when(blobsSidecarAvailabilityChecker.getAvailabilityCheckResult()) - // .thenReturn(SafeFuture.completedFuture(BlobsSidecarAndValidationResult.NOT_REQUIRED)); + when(blobSidecarsAvailabilityChecker.getAvailabilityCheckResult()) + .thenReturn(SafeFuture.completedFuture(BlobSidecarsAndValidationResult.NOT_REQUIRED)); importBlock(blockAndState); - // verify(blobSidecarManager).createAvailabilityChecker(blockAndState.getBlock()); - // verify(blobSidecarAvailabilityChecker).initiateDataAvailabilityCheck(); - // verify(blobSidecarAvailabilityChecker).getAvailabilityCheckResult(); + verify(blobSidecarManager).createAvailabilityChecker(blockAndState.getBlock()); + verify(blobSidecarsAvailabilityChecker).initiateDataAvailabilityCheck(); + verify(blobSidecarsAvailabilityChecker).getAvailabilityCheckResult(); } @Test diff --git a/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/util/BlobSidecarPoolImplTest.java b/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/util/BlobSidecarPoolImplTest.java index 5b0b29c4191..29cb19cc427 100644 --- a/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/util/BlobSidecarPoolImplTest.java +++ b/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/util/BlobSidecarPoolImplTest.java @@ -265,14 +265,14 @@ public void onCompletedBlockAndBlobSidecars_shouldCreateTrackerIgnoringHistorica assertThat(requiredBlobSidecarEvents).isEmpty(); assertThat(requiredBlobSidecarDroppedEvents).isEmpty(); - final BlockBlobSidecarsTracker blobsSidecarsTracker = + final BlockBlobSidecarsTracker blockBlobSidecarsTracker = blobSidecarPool.getBlobSidecarsTracker(block.getSlotAndBlockRoot()); - assertThat(blobsSidecarsTracker.getBlobSidecars().values()) + assertThat(blockBlobSidecarsTracker.getBlobSidecars().values()) .containsExactlyInAnyOrderElementsOf(blobSidecars); - assertThat(blobsSidecarsTracker.getBlockBody()).isPresent(); - assertThat(blobsSidecarsTracker.isFetchTriggered()).isFalse(); - assertThatSafeFuture(blobsSidecarsTracker.getCompletionFuture()).isCompleted(); + assertThat(blockBlobSidecarsTracker.getBlockBody()).isPresent(); + assertThat(blockBlobSidecarsTracker.isFetchTriggered()).isFalse(); + assertThatSafeFuture(blockBlobSidecarsTracker.getCompletionFuture()).isCompleted(); assertBlobSidecarsCount(blobSidecars.size()); assertBlobSidecarsTrackersCount(1); @@ -294,14 +294,14 @@ public void onBlobSidecarsFromSync_shouldNotTriggerFetch() { assertThat(requiredBlobSidecarEvents).isEmpty(); assertThat(requiredBlobSidecarDroppedEvents).isEmpty(); - final BlockBlobSidecarsTracker blobsSidecarsTracker = + final BlockBlobSidecarsTracker blockBlobSidecarsTracker = blobSidecarPool.getBlobSidecarsTracker(block.getSlotAndBlockRoot()); - assertThat(blobsSidecarsTracker.getBlobSidecars().values()) + assertThat(blockBlobSidecarsTracker.getBlobSidecars().values()) .containsExactlyInAnyOrderElementsOf(blobSidecars); - assertThat(blobsSidecarsTracker.getBlockBody()).isPresent(); - assertThat(blobsSidecarsTracker.isFetchTriggered()).isFalse(); - assertThatSafeFuture(blobsSidecarsTracker.getCompletionFuture()).isNotCompleted(); + assertThat(blockBlobSidecarsTracker.getBlockBody()).isPresent(); + assertThat(blockBlobSidecarsTracker.isFetchTriggered()).isFalse(); + assertThatSafeFuture(blockBlobSidecarsTracker.getCompletionFuture()).isNotCompleted(); assertBlobSidecarsCount(0); assertBlobSidecarsTrackersCount(1); @@ -309,17 +309,17 @@ public void onBlobSidecarsFromSync_shouldNotTriggerFetch() { @Test public void - getOrCreateBlockBlobsSidecarsTracker_createATrackerWithBlockSetIgnoringHistoricalTolerance() { + getOrCreateBlockblockBlobSidecarsTracker_createATrackerWithBlockSetIgnoringHistoricalTolerance() { final UInt64 slot = currentSlot.minus(historicalTolerance).minus(UInt64.ONE); final SignedBeaconBlock block = dataStructureUtil.randomSignedBeaconBlock(slot); - final BlockBlobSidecarsTracker blobsSidecarsTracker = + final BlockBlobSidecarsTracker blockBlobSidecarsTracker = blobSidecarPool.getOrCreateBlockBlobSidecarsTracker(block); - assertThat(blobsSidecarsTracker.getBlockBody()).isPresent(); - assertThat(blobsSidecarsTracker.isFetchTriggered()).isFalse(); - assertThatSafeFuture(blobsSidecarsTracker.getCompletionFuture()).isNotCompleted(); + assertThat(blockBlobSidecarsTracker.getBlockBody()).isPresent(); + assertThat(blockBlobSidecarsTracker.isFetchTriggered()).isFalse(); + assertThatSafeFuture(blockBlobSidecarsTracker.getCompletionFuture()).isNotCompleted(); assertBlobSidecarsCount(0); assertBlobSidecarsTrackersCount(1); @@ -781,7 +781,7 @@ void calculateFetchDelay_shouldReturnZeroIfSlotIsOld() { } @Test - void getAllRequiredBlobSidecars_shouldReturnAllRequiredBlobsSidecars() { + void getAllRequiredBlobSidecars_shouldReturnAllRequiredBlobSidecars() { final SignedBeaconBlock block1 = dataStructureUtil.randomSignedBeaconBlock(currentSlot); final Set missingBlobs1 = diff --git a/networking/eth2/src/main/java/tech/pegasys/teku/networking/eth2/gossip/BlobSidecarGossipChannel.java b/networking/eth2/src/main/java/tech/pegasys/teku/networking/eth2/gossip/BlobSidecarGossipChannel.java index db4f02da33e..24e12a09cd9 100644 --- a/networking/eth2/src/main/java/tech/pegasys/teku/networking/eth2/gossip/BlobSidecarGossipChannel.java +++ b/networking/eth2/src/main/java/tech/pegasys/teku/networking/eth2/gossip/BlobSidecarGossipChannel.java @@ -13,10 +13,17 @@ package tech.pegasys.teku.networking.eth2.gossip; +import java.util.List; import tech.pegasys.teku.infrastructure.events.VoidReturningChannelInterface; import tech.pegasys.teku.spec.datastructures.blobs.versions.deneb.SignedBlobSidecar; public interface BlobSidecarGossipChannel extends VoidReturningChannelInterface { + BlobSidecarGossipChannel NOOP = blobSidecar -> {}; + + default void publishBlobSidecars(final List blobSidecars) { + blobSidecars.forEach(this::publishBlobSidecar); + } + void publishBlobSidecar(SignedBlobSidecar blobSidecar); } diff --git a/networking/eth2/src/main/java/tech/pegasys/teku/networking/eth2/gossip/BlockAndBlobsSidecarGossipChannel.java b/networking/eth2/src/main/java/tech/pegasys/teku/networking/eth2/gossip/BlockAndBlobsSidecarGossipChannel.java deleted file mode 100644 index eac042fba87..00000000000 --- a/networking/eth2/src/main/java/tech/pegasys/teku/networking/eth2/gossip/BlockAndBlobsSidecarGossipChannel.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright ConsenSys Software Inc., 2022 - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ - -package tech.pegasys.teku.networking.eth2.gossip; - -import tech.pegasys.teku.infrastructure.events.VoidReturningChannelInterface; -import tech.pegasys.teku.spec.datastructures.blocks.blockbody.versions.deneb.SignedBeaconBlockAndBlobsSidecar; - -// TODO: remove once the block publishing is switched to a decoupling version -public interface BlockAndBlobsSidecarGossipChannel extends VoidReturningChannelInterface { - void publishBlockAndBlobsSidecar(SignedBeaconBlockAndBlobsSidecar blockAndBlobsSidecar); -} diff --git a/networking/eth2/src/main/java/tech/pegasys/teku/networking/eth2/rpc/beaconchain/methods/BlobSidecarsByRangeMessageHandler.java b/networking/eth2/src/main/java/tech/pegasys/teku/networking/eth2/rpc/beaconchain/methods/BlobSidecarsByRangeMessageHandler.java index dca20eaa67b..b0c109967ad 100644 --- a/networking/eth2/src/main/java/tech/pegasys/teku/networking/eth2/rpc/beaconchain/methods/BlobSidecarsByRangeMessageHandler.java +++ b/networking/eth2/src/main/java/tech/pegasys/teku/networking/eth2/rpc/beaconchain/methods/BlobSidecarsByRangeMessageHandler.java @@ -187,7 +187,7 @@ private void handleProcessingRequestError( } else { if (rootCause instanceof StreamClosedException || rootCause instanceof ClosedChannelException) { - LOG.trace("Stream closed while sending requested blobs sidecars", error); + LOG.trace("Stream closed while sending requested blob sidecars", error); } else { LOG.error("Failed to process blob sidecars request", error); } 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 8acd3134aff..189095fa5a6 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 @@ -68,6 +68,7 @@ import tech.pegasys.teku.networking.eth2.Eth2P2PNetwork; import tech.pegasys.teku.networking.eth2.Eth2P2PNetworkBuilder; import tech.pegasys.teku.networking.eth2.P2PConfig; +import tech.pegasys.teku.networking.eth2.gossip.BlobSidecarGossipChannel; import tech.pegasys.teku.networking.eth2.gossip.BlockGossipChannel; import tech.pegasys.teku.networking.eth2.gossip.subnets.AllSubnetsSubscriber; import tech.pegasys.teku.networking.eth2.gossip.subnets.AllSyncCommitteeSubscriptions; @@ -768,6 +769,12 @@ public void initValidatorApiHandler() { eventChannels.getPublisher(BlockImportChannel.class, beaconAsyncRunner); final BlockGossipChannel blockGossipChannel = eventChannels.getPublisher(BlockGossipChannel.class); + final BlobSidecarGossipChannel blobSidecarGossipChannel; + if (spec.isMilestoneSupported(SpecMilestone.DENEB)) { + blobSidecarGossipChannel = eventChannels.getPublisher(BlobSidecarGossipChannel.class); + } else { + blobSidecarGossipChannel = BlobSidecarGossipChannel.NOOP; + } final ValidatorApiHandler validatorApiHandler = new ValidatorApiHandler( new ChainDataProvider(spec, recentChainData, combinedChainDataClient), @@ -777,7 +784,8 @@ public void initValidatorApiHandler() { blockFactory, blockImportChannel, blockGossipChannel, - __ -> {}, // TODO: remove once the block publishing is switched to a decoupling version + blobSidecarPool, + blobSidecarGossipChannel, attestationPool, attestationManager, attestationTopicSubscriber, diff --git a/storage/src/integration-test/java/tech/pegasys/teku/storage/server/kvstore/DatabaseTest.java b/storage/src/integration-test/java/tech/pegasys/teku/storage/server/kvstore/DatabaseTest.java index f68e5d637fc..4d92af27443 100644 --- a/storage/src/integration-test/java/tech/pegasys/teku/storage/server/kvstore/DatabaseTest.java +++ b/storage/src/integration-test/java/tech/pegasys/teku/storage/server/kvstore/DatabaseTest.java @@ -375,7 +375,7 @@ public void shouldPruneHotBlocksAddedOverMultipleSessions(final DatabaseContext // Add base blocks addBlocks(chainBuilder.streamBlocksAndStates().collect(toList())); - // add blobs sidecars + // add blob sidecars addBlobSidecars(chainBuilder.streamBlobSidecars().collect(toList())); // Set target slot at which to create duplicate blocks @@ -400,7 +400,7 @@ public void shouldPruneHotBlocksAddedOverMultipleSessions(final DatabaseContext add(List.of(blockB)); add(List.of(blockC)); - // Add corresponding blobs sidecars + // Add corresponding blob sidecars addBlobSidecars(forkA.getBlobSidecars(blockA.getRoot()).orElseThrow()); addBlobSidecars(forkB.getBlobSidecars(blockB.getRoot()).orElseThrow()); addBlobSidecars(chainBuilder.getBlobSidecars(blockC.getRoot()).orElseThrow()); @@ -413,7 +413,7 @@ public void shouldPruneHotBlocksAddedOverMultipleSessions(final DatabaseContext assertThat(store.retrieveBlock(blockC.getRoot())) .isCompletedWithValue(Optional.of(blockC.getBlock().getMessage())); - // verify we have all blobs sidecar are available + // verify all blob sidecars are available final List blocksWithAvailableSidecars = Stream.concat( Stream.concat( diff --git a/storage/src/test/java/tech/pegasys/teku/storage/server/ChainStorageTest.java b/storage/src/test/java/tech/pegasys/teku/storage/server/ChainStorageTest.java index cfc2d232066..5d6226d05fd 100644 --- a/storage/src/test/java/tech/pegasys/teku/storage/server/ChainStorageTest.java +++ b/storage/src/test/java/tech/pegasys/teku/storage/server/ChainStorageTest.java @@ -227,7 +227,7 @@ public void testOnFinalized( .map(Optional::get) .collect(Collectors.toList()))); if (testBlobSidecars) { - // verify blobs sidecar for a block is available + // verify blob sidecars for a block are available assertThatSafeFuture(sidecarsResult) .isCompletedWithValueMatching( list -> diff --git a/storage/src/testFixtures/java/tech/pegasys/teku/storage/store/StoreAssertions.java b/storage/src/testFixtures/java/tech/pegasys/teku/storage/store/StoreAssertions.java index 213307fe5a9..750e1005b88 100644 --- a/storage/src/testFixtures/java/tech/pegasys/teku/storage/store/StoreAssertions.java +++ b/storage/src/testFixtures/java/tech/pegasys/teku/storage/store/StoreAssertions.java @@ -39,7 +39,7 @@ public static void assertStoresMatch( "lock", "readLock", "blockProvider", - "blobsSidecarProvider", + "blobSidecarsProvider", "blocks", "blockMetadata", "stateRequestCachedCounter", @@ -52,8 +52,7 @@ public static void assertStoresMatch( "states", "stateProvider", "checkpointStates", - "forkChoiceStrategy", - "blobSidecarsProvider") + "forkChoiceStrategy") .isEqualTo(expectedState); assertThat(actualState.getOrderedBlockRoots()) .containsExactlyElementsOf(expectedState.getOrderedBlockRoots());