Skip to content

Commit

Permalink
Remove deprecated methods from (Signed)BlockContainer (Consensys#7700)
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanBratanov authored Nov 14, 2023
1 parent c81d7cc commit 708788f
Show file tree
Hide file tree
Showing 12 changed files with 31 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ private SafeFuture<BlockImportResult> 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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ private SafeFuture<Void> 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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ void shouldNotDisconnectPeersWhenServiceOffline() {

private void blobSidecarsImportedSuccessfully(
final SignedBeaconBlock block, final List<BlobSidecarOld> blobSidecars) {
verify(blobSidecarPool).onCompletedBlockAndBlobSidecars(block, blobSidecars);
verify(blobSidecarPool).onCompletedBlockAndBlobSidecarsOld(block, blobSidecars);
verifyNoMoreInteractions(blobSidecarPool);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,8 @@ protected SafeFuture<BlockImportAndBroadcastValidationResults> 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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()));
Expand All @@ -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)
Expand All @@ -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()));
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -37,11 +35,6 @@ default UInt64 getSlot() {
return getBlock().getSlot();
}

@Deprecated
default Optional<List<BlobSidecarOld>> getBlobSidecars() {
return Optional.empty();
}

default Optional<SszList<SszKZGProof>> getKzgProofs() {
return Optional.empty();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,13 @@

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;
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.SignedBlobSidecarOld;
import tech.pegasys.teku.spec.datastructures.blocks.versions.deneb.SignedBlockContents;
import tech.pegasys.teku.spec.datastructures.type.SszKZGProof;

Expand All @@ -42,11 +40,6 @@ default Bytes32 getRoot() {
return getSignedBlock().getRoot();
}

@Deprecated
default Optional<List<SignedBlobSidecarOld>> getSignedBlobSidecars() {
return Optional.empty();
}

default Optional<SszList<SszKZGProof>> getKzgProofs() {
return Optional.empty();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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<BlobSidecarOld> blobSidecars) {}

@Override
public void onCompletedBlockAndBlobSidecars(
final SignedBeaconBlock block, final List<BlobSidecar> blobSidecars) {}

@Override
public void removeAllForBlock(final Bytes32 blockRoot) {}

Expand Down Expand Up @@ -96,13 +100,11 @@ public void subscribeNewBlobSidecar(NewBlobSidecarSubscriber newBlobSidecarSubsc

void onNewBlock(SignedBeaconBlock block);

default void onCompletedBlockAndSignedBlobSidecars(
SignedBeaconBlock block, List<SignedBlobSidecarOld> signedBlobSidecars) {
onCompletedBlockAndBlobSidecars(
block, signedBlobSidecars.stream().map(SignedBlobSidecarOld::getBlobSidecar).toList());
}
@Deprecated
void onCompletedBlockAndBlobSidecarsOld(
SignedBeaconBlock block, List<BlobSidecarOld> blobSidecars);

void onCompletedBlockAndBlobSidecars(SignedBeaconBlock block, List<BlobSidecarOld> blobSidecars);
void onCompletedBlockAndBlobSidecars(SignedBeaconBlock block, List<BlobSidecar> blobSidecars);

void removeAllForBlock(Bytes32 blockRoot);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -186,7 +187,7 @@ public synchronized Optional<BlockBlobSidecarsTracker> getBlockBlobSidecarsTrack
}

@Override
public synchronized void onCompletedBlockAndBlobSidecars(
public synchronized void onCompletedBlockAndBlobSidecarsOld(
final SignedBeaconBlock block, final List<BlobSidecarOld> blobSidecars) {
final SlotAndBlockRoot slotAndBlockRoot = block.getSlotAndBlockRoot();

Expand Down Expand Up @@ -216,6 +217,12 @@ public synchronized void onCompletedBlockAndBlobSidecars(
}
}

@Override
public void onCompletedBlockAndBlobSidecars(
final SignedBeaconBlock block, final List<BlobSidecar> blobSidecars) {
throw new UnsupportedOperationException("Not yet implemented");
}

@Override
public synchronized void removeAllForBlock(final Bytes32 blockRoot) {
final BlockBlobSidecarsTracker removedTracker = blockBlobSidecarsTrackers.remove(blockRoot);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ public void onCompletedBlockAndBlobSidecars_shouldCreateTrackerIgnoringHistorica

final List<BlobSidecarOld> blobSidecars = dataStructureUtil.randomBlobSidecarsForBlock(block);

blobSidecarPool.onCompletedBlockAndBlobSidecars(block, blobSidecars);
blobSidecarPool.onCompletedBlockAndBlobSidecarsOld(block, blobSidecars);

assertThat(asyncRunner.hasDelayedActions()).isFalse();

Expand Down Expand Up @@ -331,7 +331,7 @@ public void onCompletedBlockAndBlobSidecars_shouldNotTriggerFetch() {

final List<BlobSidecarOld> blobSidecars = List.of();

blobSidecarPool.onCompletedBlockAndBlobSidecars(block, blobSidecars);
blobSidecarPool.onCompletedBlockAndBlobSidecarsOld(block, blobSidecars);

assertThat(asyncRunner.hasDelayedActions()).isFalse();

Expand Down

0 comments on commit 708788f

Please sign in to comment.