From 708788fd54787ce161d282d032ee2c5f09d17391 Mon Sep 17 00:00:00 2001 From: Stefan Bratanov Date: Tue, 14 Nov 2023 19:19:42 +0000 Subject: [PATCH] Remove deprecated methods from (Signed)BlockContainer (#7700) --- .../sync/forward/multipeer/BatchImporter.java | 2 +- .../sync/forward/singlepeer/PeerSync.java | 2 +- .../forward/multipeer/BatchImporterTest.java | 2 +- .../sync/forward/singlepeer/PeerSyncTest.java | 2 +- .../publisher/BlockPublisherDeneb.java | 8 ++------ .../coordinator/BlockFactoryDenebTest.java | 3 +-- .../coordinator/ValidatorApiHandlerTest.java | 8 ++++---- .../datastructures/blocks/BlockContainer.java | 7 ------- .../blocks/SignedBlockContainer.java | 7 ------- .../statetransition/blobs/BlobSidecarPool.java | 18 ++++++++++-------- .../util/BlobSidecarPoolImpl.java | 9 ++++++++- .../util/BlobSidecarPoolImplTest.java | 4 ++-- 12 files changed, 31 insertions(+), 41 deletions(-) diff --git a/beacon/sync/src/main/java/tech/pegasys/teku/beacon/sync/forward/multipeer/BatchImporter.java b/beacon/sync/src/main/java/tech/pegasys/teku/beacon/sync/forward/multipeer/BatchImporter.java index ad9b7b7fa39..c7d29ea1950 100644 --- a/beacon/sync/src/main/java/tech/pegasys/teku/beacon/sync/forward/multipeer/BatchImporter.java +++ b/beacon/sync/src/main/java/tech/pegasys/teku/beacon/sync/forward/multipeer/BatchImporter.java @@ -116,7 +116,7 @@ private SafeFuture importBlockAndBlobSidecars( blockRoot); // Add blob sidecars to the pool in order for them to be available when the block is being // imported - blobSidecarPool.onCompletedBlockAndBlobSidecars(block, blobSidecars); + blobSidecarPool.onCompletedBlockAndBlobSidecarsOld(block, blobSidecars); return importBlock(block, source); } diff --git a/beacon/sync/src/main/java/tech/pegasys/teku/beacon/sync/forward/singlepeer/PeerSync.java b/beacon/sync/src/main/java/tech/pegasys/teku/beacon/sync/forward/singlepeer/PeerSync.java index daf27944bb6..6f9238ec216 100644 --- a/beacon/sync/src/main/java/tech/pegasys/teku/beacon/sync/forward/singlepeer/PeerSync.java +++ b/beacon/sync/src/main/java/tech/pegasys/teku/beacon/sync/forward/singlepeer/PeerSync.java @@ -343,7 +343,7 @@ private SafeFuture importBlock( // Add blob sidecars to the pool in order for them to be available when the block is being // imported maybeBlobSidecars.ifPresent( - blobSidecars -> blobSidecarPool.onCompletedBlockAndBlobSidecars(block, blobSidecars)); + blobSidecars -> blobSidecarPool.onCompletedBlockAndBlobSidecarsOld(block, blobSidecars)); return blockImporter .importBlock(block) diff --git a/beacon/sync/src/test/java/tech/pegasys/teku/beacon/sync/forward/multipeer/BatchImporterTest.java b/beacon/sync/src/test/java/tech/pegasys/teku/beacon/sync/forward/multipeer/BatchImporterTest.java index ac35a5e8a27..08cfe32c5e3 100644 --- a/beacon/sync/src/test/java/tech/pegasys/teku/beacon/sync/forward/multipeer/BatchImporterTest.java +++ b/beacon/sync/src/test/java/tech/pegasys/teku/beacon/sync/forward/multipeer/BatchImporterTest.java @@ -250,7 +250,7 @@ void shouldNotDisconnectPeersWhenServiceOffline() { private void blobSidecarsImportedSuccessfully( final SignedBeaconBlock block, final List blobSidecars) { - verify(blobSidecarPool).onCompletedBlockAndBlobSidecars(block, blobSidecars); + verify(blobSidecarPool).onCompletedBlockAndBlobSidecarsOld(block, blobSidecars); verifyNoMoreInteractions(blobSidecarPool); } diff --git a/beacon/sync/src/test/java/tech/pegasys/teku/beacon/sync/forward/singlepeer/PeerSyncTest.java b/beacon/sync/src/test/java/tech/pegasys/teku/beacon/sync/forward/singlepeer/PeerSyncTest.java index 9e717273d3f..c1462847d5e 100644 --- a/beacon/sync/src/test/java/tech/pegasys/teku/beacon/sync/forward/singlepeer/PeerSyncTest.java +++ b/beacon/sync/src/test/java/tech/pegasys/teku/beacon/sync/forward/singlepeer/PeerSyncTest.java @@ -558,7 +558,7 @@ private void verifyBlobSidecarsAddedToPool( Assertions.fail("Blob sidecars for slot %s is missing", slot); } verify(blobSidecarPool) - .onCompletedBlockAndBlobSidecars(any(), eq(blobSidecarsBySlot.get(slot))); + .onCompletedBlockAndBlobSidecarsOld(any(), eq(blobSidecarsBySlot.get(slot))); } } 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 7d332cd77c4..4a00c927cb7 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 @@ -52,12 +52,8 @@ protected SafeFuture importBlock( final SignedBlockContainer blockContainer, final BroadcastValidationLevel broadcastValidationLevel) { final SignedBeaconBlock block = blockContainer.getSignedBlock(); - - blockContainer - .getSignedBlobSidecars() - .ifPresent( - signedBlobSidecars -> - blobSidecarPool.onCompletedBlockAndSignedBlobSidecars(block, signedBlobSidecars)); + // TODO: import blob sidecars with inclusion proof + blobSidecarPool.onCompletedBlockAndBlobSidecars(block, List.of()); return blockImportChannel.importBlock(block, broadcastValidationLevel); } diff --git a/beacon/validator/src/test/java/tech/pegasys/teku/validator/coordinator/BlockFactoryDenebTest.java b/beacon/validator/src/test/java/tech/pegasys/teku/validator/coordinator/BlockFactoryDenebTest.java index dce58ac255f..dba06f87a68 100644 --- a/beacon/validator/src/test/java/tech/pegasys/teku/validator/coordinator/BlockFactoryDenebTest.java +++ b/beacon/validator/src/test/java/tech/pegasys/teku/validator/coordinator/BlockFactoryDenebTest.java @@ -109,8 +109,7 @@ void unblindSignedBlock_shouldUnblindBeaconBlock() { assertThat(unblindedBlockContainer).isInstanceOf(SignedBlockContents.class); assertThat(unblindedBlockContainer.isBlinded()).isFalse(); assertThat(unblindedBlockContainer.getSignedBlock()).isEqualTo(unblindedBeaconBlock); - assertThat(unblindedBlockContainer.getSignedBlobSidecars()) - .hasValueSatisfying(blobSidecars -> assertThat(blobSidecars).isEmpty()); + // TODO: add assertions for blobs and proofs } @Override 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 e8162383181..999dffb26b2 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 @@ -839,7 +839,7 @@ public void sendSignedBlock_shouldConvertBlockContentsSuccessfulResult() { // TODO: fix assertion for blob sidecars verify(blobSidecarGossipChannel).publishBlobSidecars(List.of()); - + verify(blobSidecarPool).onCompletedBlockAndBlobSidecars(block, List.of()); verify(blockGossipChannel).publishBlock(block); verify(blockImportChannel).importBlock(block, NOT_REQUIRED); assertThat(result).isCompletedWithValue(SendSignedBlockResult.success(block.getRoot())); @@ -859,7 +859,7 @@ public void sendSignedBlock_shouldConvertBlockContentsFailedResult() { // TODO: fix assertion for blob sidecars verify(blobSidecarGossipChannel).publishBlobSidecars(List.of()); - + verify(blobSidecarPool).onCompletedBlockAndBlobSidecars(block, List.of()); verify(blockGossipChannel).publishBlock(block); verify(blockImportChannel).importBlock(block, NOT_REQUIRED); assertThat(result) @@ -881,7 +881,7 @@ public void sendSignedBlockForDeneb_shouldConvertBlockContentsKnownBlockResult() // TODO: fix assertion for blob sidecars verify(blobSidecarGossipChannel).publishBlobSidecars(List.of()); - + verify(blobSidecarPool).onCompletedBlockAndBlobSidecars(block, List.of()); verify(blockGossipChannel).publishBlock(block); verify(blockImportChannel).importBlock(block, NOT_REQUIRED); assertThat(result).isCompletedWithValue(SendSignedBlockResult.success(block.getRoot())); @@ -898,8 +898,8 @@ public void sendSignedBlock_shoulNotGossipAndImportBlobsWhenBlobsDoNotExist() { validatorApiHandler.sendSignedBlock(block, NOT_REQUIRED); safeJoin(result); - verifyNoInteractions(blobSidecarPool); // TODO: fix assertion for blob sidecars (there should be no interactions) + verify(blobSidecarPool).onCompletedBlockAndBlobSidecars(block, List.of()); verify(blobSidecarGossipChannel).publishBlobSidecars(List.of()); verify(blockGossipChannel).publishBlock(block); verify(blockImportChannel).importBlock(block, NOT_REQUIRED); diff --git a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/blocks/BlockContainer.java b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/blocks/BlockContainer.java index 85cadbba771..8a7e6c7f798 100644 --- a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/blocks/BlockContainer.java +++ b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/blocks/BlockContainer.java @@ -13,14 +13,12 @@ package tech.pegasys.teku.spec.datastructures.blocks; -import java.util.List; import java.util.Optional; import tech.pegasys.teku.infrastructure.ssz.SszContainer; import tech.pegasys.teku.infrastructure.ssz.SszData; import tech.pegasys.teku.infrastructure.ssz.SszList; 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.BlobSidecarOld; import tech.pegasys.teku.spec.datastructures.blocks.versions.deneb.BlockContents; import tech.pegasys.teku.spec.datastructures.type.SszKZGProof; @@ -37,11 +35,6 @@ default UInt64 getSlot() { return getBlock().getSlot(); } - @Deprecated - default Optional> getBlobSidecars() { - return Optional.empty(); - } - default Optional> getKzgProofs() { return Optional.empty(); } diff --git a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/blocks/SignedBlockContainer.java b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/blocks/SignedBlockContainer.java index 4ced0c310ac..fa8dccf4457 100644 --- a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/blocks/SignedBlockContainer.java +++ b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/blocks/SignedBlockContainer.java @@ -13,7 +13,6 @@ package tech.pegasys.teku.spec.datastructures.blocks; -import java.util.List; import java.util.Optional; import org.apache.tuweni.bytes.Bytes32; import tech.pegasys.teku.infrastructure.ssz.SszContainer; @@ -21,7 +20,6 @@ import tech.pegasys.teku.infrastructure.ssz.SszList; 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.SignedBlobSidecarOld; import tech.pegasys.teku.spec.datastructures.blocks.versions.deneb.SignedBlockContents; import tech.pegasys.teku.spec.datastructures.type.SszKZGProof; @@ -42,11 +40,6 @@ default Bytes32 getRoot() { return getSignedBlock().getRoot(); } - @Deprecated - default Optional> getSignedBlobSidecars() { - return Optional.empty(); - } - default Optional> getKzgProofs() { return Optional.empty(); } diff --git a/ethereum/statetransition/src/main/java/tech/pegasys/teku/statetransition/blobs/BlobSidecarPool.java b/ethereum/statetransition/src/main/java/tech/pegasys/teku/statetransition/blobs/BlobSidecarPool.java index 4323806c0bf..acd58f8188c 100644 --- a/ethereum/statetransition/src/main/java/tech/pegasys/teku/statetransition/blobs/BlobSidecarPool.java +++ b/ethereum/statetransition/src/main/java/tech/pegasys/teku/statetransition/blobs/BlobSidecarPool.java @@ -20,8 +20,8 @@ import org.apache.tuweni.bytes.Bytes32; import tech.pegasys.teku.ethereum.events.SlotEventsChannel; import tech.pegasys.teku.infrastructure.unsigned.UInt64; +import tech.pegasys.teku.spec.datastructures.blobs.versions.deneb.BlobSidecar; import tech.pegasys.teku.spec.datastructures.blobs.versions.deneb.BlobSidecarOld; -import tech.pegasys.teku.spec.datastructures.blobs.versions.deneb.SignedBlobSidecarOld; import tech.pegasys.teku.spec.datastructures.blocks.SignedBeaconBlock; import tech.pegasys.teku.spec.datastructures.networking.libp2p.rpc.BlobIdentifier; @@ -39,9 +39,13 @@ public void onNewBlobSidecar(final BlobSidecarOld blobSidecar) {} public void onNewBlock(final SignedBeaconBlock block) {} @Override - public void onCompletedBlockAndBlobSidecars( + public void onCompletedBlockAndBlobSidecarsOld( final SignedBeaconBlock block, final List blobSidecars) {} + @Override + public void onCompletedBlockAndBlobSidecars( + final SignedBeaconBlock block, final List blobSidecars) {} + @Override public void removeAllForBlock(final Bytes32 blockRoot) {} @@ -96,13 +100,11 @@ public void subscribeNewBlobSidecar(NewBlobSidecarSubscriber newBlobSidecarSubsc void onNewBlock(SignedBeaconBlock block); - default void onCompletedBlockAndSignedBlobSidecars( - SignedBeaconBlock block, List signedBlobSidecars) { - onCompletedBlockAndBlobSidecars( - block, signedBlobSidecars.stream().map(SignedBlobSidecarOld::getBlobSidecar).toList()); - } + @Deprecated + void onCompletedBlockAndBlobSidecarsOld( + SignedBeaconBlock block, List blobSidecars); - void onCompletedBlockAndBlobSidecars(SignedBeaconBlock block, List blobSidecars); + void onCompletedBlockAndBlobSidecars(SignedBeaconBlock block, List blobSidecars); void removeAllForBlock(Bytes32 blockRoot); diff --git a/ethereum/statetransition/src/main/java/tech/pegasys/teku/statetransition/util/BlobSidecarPoolImpl.java b/ethereum/statetransition/src/main/java/tech/pegasys/teku/statetransition/util/BlobSidecarPoolImpl.java index 14789494859..44c01b7a730 100644 --- a/ethereum/statetransition/src/main/java/tech/pegasys/teku/statetransition/util/BlobSidecarPoolImpl.java +++ b/ethereum/statetransition/src/main/java/tech/pegasys/teku/statetransition/util/BlobSidecarPoolImpl.java @@ -36,6 +36,7 @@ import tech.pegasys.teku.infrastructure.time.TimeProvider; import tech.pegasys.teku.infrastructure.unsigned.UInt64; import tech.pegasys.teku.spec.Spec; +import tech.pegasys.teku.spec.datastructures.blobs.versions.deneb.BlobSidecar; import tech.pegasys.teku.spec.datastructures.blobs.versions.deneb.BlobSidecarOld; import tech.pegasys.teku.spec.datastructures.blocks.SignedBeaconBlock; import tech.pegasys.teku.spec.datastructures.blocks.SlotAndBlockRoot; @@ -186,7 +187,7 @@ public synchronized Optional getBlockBlobSidecarsTrack } @Override - public synchronized void onCompletedBlockAndBlobSidecars( + public synchronized void onCompletedBlockAndBlobSidecarsOld( final SignedBeaconBlock block, final List blobSidecars) { final SlotAndBlockRoot slotAndBlockRoot = block.getSlotAndBlockRoot(); @@ -216,6 +217,12 @@ public synchronized void onCompletedBlockAndBlobSidecars( } } + @Override + public void onCompletedBlockAndBlobSidecars( + final SignedBeaconBlock block, final List blobSidecars) { + throw new UnsupportedOperationException("Not yet implemented"); + } + @Override public synchronized void removeAllForBlock(final Bytes32 blockRoot) { final BlockBlobSidecarsTracker removedTracker = blockBlobSidecarsTrackers.remove(blockRoot); 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 3ad2a99464f..23373931969 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 @@ -301,7 +301,7 @@ public void onCompletedBlockAndBlobSidecars_shouldCreateTrackerIgnoringHistorica final List blobSidecars = dataStructureUtil.randomBlobSidecarsForBlock(block); - blobSidecarPool.onCompletedBlockAndBlobSidecars(block, blobSidecars); + blobSidecarPool.onCompletedBlockAndBlobSidecarsOld(block, blobSidecars); assertThat(asyncRunner.hasDelayedActions()).isFalse(); @@ -331,7 +331,7 @@ public void onCompletedBlockAndBlobSidecars_shouldNotTriggerFetch() { final List blobSidecars = List.of(); - blobSidecarPool.onCompletedBlockAndBlobSidecars(block, blobSidecars); + blobSidecarPool.onCompletedBlockAndBlobSidecarsOld(block, blobSidecars); assertThat(asyncRunner.hasDelayedActions()).isFalse();