forked from Consensys/teku
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create DataColumnSidecars on block production and publish it (Consens…
- Loading branch information
Showing
11 changed files
with
196 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
.../validator/src/main/java/tech/pegasys/teku/validator/coordinator/BlockFactoryEip7594.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* Copyright Consensys Software Inc., 2023 | ||
* | ||
* 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.validator.coordinator; | ||
|
||
import java.util.List; | ||
import tech.pegasys.teku.kzg.KZG; | ||
import tech.pegasys.teku.spec.Spec; | ||
import tech.pegasys.teku.spec.datastructures.blobs.versions.eip7594.DataColumnSidecar; | ||
import tech.pegasys.teku.spec.datastructures.blocks.SignedBlockContainer; | ||
import tech.pegasys.teku.spec.logic.versions.eip7594.helpers.MiscHelpersEip7594; | ||
|
||
public class BlockFactoryEip7594 extends BlockFactoryDeneb { | ||
private final KZG kzg; | ||
|
||
public BlockFactoryEip7594( | ||
final Spec spec, final BlockOperationSelectorFactory operationSelector, final KZG kzg) { | ||
super(spec, operationSelector); | ||
this.kzg = kzg; | ||
} | ||
|
||
@Override | ||
public List<DataColumnSidecar> createDataColumnSidecars( | ||
final SignedBlockContainer blockContainer) { | ||
final MiscHelpersEip7594 miscHelpersEip7594 = | ||
MiscHelpersEip7594.required(spec.atSlot(blockContainer.getSlot()).miscHelpers()); | ||
return miscHelpersEip7594.constructDataColumnSidecars( | ||
blockContainer.getSignedBlock(), | ||
blockContainer.getBlobs().orElseThrow().asList(), | ||
blockContainer.getKzgProofs().orElseThrow(), | ||
kzg); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
...rc/main/java/tech/pegasys/teku/validator/coordinator/publisher/BlockPublisherEip7594.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/* | ||
* 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.validator.coordinator.publisher; | ||
|
||
import java.util.List; | ||
import tech.pegasys.teku.ethereum.performance.trackers.BlockPublishingPerformance; | ||
import tech.pegasys.teku.infrastructure.async.SafeFuture; | ||
import tech.pegasys.teku.networking.eth2.gossip.BlockGossipChannel; | ||
import tech.pegasys.teku.networking.eth2.gossip.DataColumnSidecarGossipChannel; | ||
import tech.pegasys.teku.spec.datastructures.blobs.versions.deneb.BlobSidecar; | ||
import tech.pegasys.teku.spec.datastructures.blobs.versions.eip7594.DataColumnSidecar; | ||
import tech.pegasys.teku.spec.datastructures.blocks.SignedBeaconBlock; | ||
import tech.pegasys.teku.spec.datastructures.validator.BroadcastValidationLevel; | ||
import tech.pegasys.teku.statetransition.blobs.BlockBlobSidecarsTrackersPool; | ||
import tech.pegasys.teku.statetransition.block.BlockImportChannel; | ||
import tech.pegasys.teku.statetransition.block.BlockImportChannel.BlockImportAndBroadcastValidationResults; | ||
import tech.pegasys.teku.validator.coordinator.BlockFactory; | ||
import tech.pegasys.teku.validator.coordinator.DutyMetrics; | ||
import tech.pegasys.teku.validator.coordinator.performance.PerformanceTracker; | ||
|
||
public class BlockPublisherEip7594 extends AbstractBlockPublisher { | ||
|
||
private final BlockBlobSidecarsTrackersPool blockBlobSidecarsTrackersPool; | ||
private final BlockGossipChannel blockGossipChannel; | ||
private final DataColumnSidecarGossipChannel dataColumnSidecarGossipChannel; | ||
|
||
public BlockPublisherEip7594( | ||
final BlockFactory blockFactory, | ||
final BlockImportChannel blockImportChannel, | ||
final BlockGossipChannel blockGossipChannel, | ||
final BlockBlobSidecarsTrackersPool blockBlobSidecarsTrackersPool, | ||
final DataColumnSidecarGossipChannel dataColumnSidecarGossipChannel, | ||
final PerformanceTracker performanceTracker, | ||
final DutyMetrics dutyMetrics) { | ||
super(blockFactory, blockImportChannel, performanceTracker, dutyMetrics); | ||
this.blockBlobSidecarsTrackersPool = blockBlobSidecarsTrackersPool; | ||
this.blockGossipChannel = blockGossipChannel; | ||
this.dataColumnSidecarGossipChannel = dataColumnSidecarGossipChannel; | ||
} | ||
|
||
@Override | ||
SafeFuture<BlockImportAndBroadcastValidationResults> importBlockAndBlobSidecars( | ||
final SignedBeaconBlock block, | ||
final List<BlobSidecar> blobSidecars, | ||
final BroadcastValidationLevel broadcastValidationLevel, | ||
final BlockPublishingPerformance blockPublishingPerformance) { | ||
// TODO: DataColumnSidecars pool fill up | ||
// provide blobs for the block before importing it | ||
blockBlobSidecarsTrackersPool.onCompletedBlockAndBlobSidecars(block, blobSidecars); | ||
return blockImportChannel | ||
.importBlock(block, broadcastValidationLevel) | ||
.thenPeek(__ -> blockPublishingPerformance.blockImportCompleted()); | ||
} | ||
|
||
@Override | ||
void publishBlockAndBlobSidecars( | ||
final SignedBeaconBlock block, | ||
final List<BlobSidecar> blobSidecars, | ||
BlockPublishingPerformance blockPublishingPerformance) { | ||
blockGossipChannel.publishBlock(block); | ||
final List<DataColumnSidecar> dataColumnSidecars = blockFactory.createDataColumnSidecars(block); | ||
dataColumnSidecarGossipChannel.publishDataColumnSidecars(dataColumnSidecars); | ||
blockPublishingPerformance.blockAndBlobSidecarsPublishingInitiated(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.