Skip to content

Commit

Permalink
Avoid unnecessary ssz conversions when signing block for Deneb (Conse…
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanBratanov authored Nov 22, 2023
1 parent cdf0c7a commit 4c20f78
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public SignedBlockContents(
final SignedBeaconBlock signedBeaconBlock,
final List<KZGProof> kzgProofs,
final List<Blob> blobs) {
super(
this(
schema,
signedBeaconBlock,
schema
Expand All @@ -46,6 +46,14 @@ public SignedBlockContents(
schema.getBlobsSchema().createFromElements(blobs));
}

public SignedBlockContents(
final SignedBlockContentsSchema schema,
final SignedBeaconBlock signedBeaconBlock,
final SszList<SszKZGProof> kzgProofs,
final SszList<Blob> blobs) {
super(schema, signedBeaconBlock, kzgProofs, blobs);
}

@Override
public SignedBeaconBlock getSignedBlock() {
return getField0();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,13 @@ public SignedBlockContents create(
return new SignedBlockContents(this, signedBeaconBlock, kzgProofs, blobs);
}

public SignedBlockContents create(
final SignedBeaconBlock signedBeaconBlock,
final SszList<SszKZGProof> kzgProofs,
final SszList<Blob> blobs) {
return new SignedBlockContents(this, signedBeaconBlock, kzgProofs, blobs);
}

@Override
public SignedBlockContents createFromBackingNode(final TreeNode node) {
return new SignedBlockContents(this, node);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,8 @@

package tech.pegasys.teku.validator.client.signer;

import java.util.List;
import tech.pegasys.teku.infrastructure.async.SafeFuture;
import tech.pegasys.teku.infrastructure.ssz.SszCollection;
import tech.pegasys.teku.kzg.KZGProof;
import tech.pegasys.teku.infrastructure.ssz.SszList;
import tech.pegasys.teku.spec.Spec;
import tech.pegasys.teku.spec.datastructures.blobs.versions.deneb.Blob;
import tech.pegasys.teku.spec.datastructures.blocks.BeaconBlock;
Expand Down Expand Up @@ -51,24 +49,18 @@ public SafeFuture<SignedBlockContainer> sign(
if (signedBlock.isBlinded()) {
return signedBlock;
} else {
final List<KZGProof> kzgProofs =
final SszList<SszKZGProof> kzgProofs =
unsignedBlockContainer
.getKzgProofs()
.map(
sszKzgProofs ->
sszKzgProofs.asList().stream()
.map(SszKZGProof::getKZGProof)
.toList())
.orElseThrow(
() ->
new RuntimeException(
String.format(
"Unable to get KZG Proofs when signing Deneb block at slot %d",
unsignedBlockContainer.getSlot().longValue())));
final List<Blob> blobs =
final SszList<Blob> blobs =
unsignedBlockContainer
.getBlobs()
.map(SszCollection::asList)
.orElseThrow(
() ->
new RuntimeException(
Expand Down

0 comments on commit 4c20f78

Please sign in to comment.