From 71cc199202ec0e00884bb1126a9714f6faea6a3e Mon Sep 17 00:00:00 2001 From: Stefan Bratanov Date: Thu, 12 Sep 2024 21:15:48 +0300 Subject: [PATCH] more changes --- .../ExecutionPayloadHeaderFactory.java | 21 +++++++++++++------ .../ExecutionPayloadEnvelopeSchema.java | 7 ------- .../eip7732/helpers/MiscHelpersEip7732.java | 1 - 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/beacon/validator/src/main/java/tech/pegasys/teku/validator/coordinator/ExecutionPayloadHeaderFactory.java b/beacon/validator/src/main/java/tech/pegasys/teku/validator/coordinator/ExecutionPayloadHeaderFactory.java index 7aea77a185c..2d24e9c53f4 100644 --- a/beacon/validator/src/main/java/tech/pegasys/teku/validator/coordinator/ExecutionPayloadHeaderFactory.java +++ b/beacon/validator/src/main/java/tech/pegasys/teku/validator/coordinator/ExecutionPayloadHeaderFactory.java @@ -18,6 +18,7 @@ import tech.pegasys.teku.bls.BLSPublicKey; import tech.pegasys.teku.ethereum.performance.trackers.BlockProductionPerformance; 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.spec.Spec; import tech.pegasys.teku.spec.datastructures.execution.ExecutionPayloadContext; @@ -26,6 +27,7 @@ import tech.pegasys.teku.spec.datastructures.execution.GetPayloadResponse; import tech.pegasys.teku.spec.datastructures.state.beaconstate.BeaconState; import tech.pegasys.teku.spec.datastructures.state.beaconstate.BeaconStateCache; +import tech.pegasys.teku.spec.datastructures.type.SszKZGCommitment; import tech.pegasys.teku.spec.executionlayer.ExecutionLayerBlockProductionManager; import tech.pegasys.teku.spec.schemas.SchemaDefinitionsEip7732; import tech.pegasys.teku.statetransition.forkchoice.ForkChoiceNotifier; @@ -57,9 +59,10 @@ public SafeFuture createUnsignedHeader( if (maybeBuilderIndex.isEmpty()) { return SafeFuture.failedFuture( new IllegalArgumentException( - "There is no index assigned to a builder with a public key " + builderPublicKey)); + "There is no validator index assigned to a builder with a public key " + + builderPublicKey)); } - final int builderIndex = maybeBuilderIndex.get(); + final UInt64 builderIndex = UInt64.valueOf(maybeBuilderIndex.get()); return forkChoiceNotifier .getPayloadId(parentRoot, slot) .thenCompose( @@ -89,11 +92,17 @@ public SafeFuture createUnsignedHeader( private ExecutionPayloadHeader createLocalBid( final UInt64 slot, - final int builderIndex, + final UInt64 builderIndex, final Bytes32 parentRoot, final ExecutionPayloadContext executionPayloadContext, final GetPayloadResponse getPayloadResponse) { - return SchemaDefinitionsEip7732.required(spec.atSlot(slot).getSchemaDefinitions()) + final SchemaDefinitionsEip7732 schemaDefinitions = + SchemaDefinitionsEip7732.required(spec.atSlot(slot).getSchemaDefinitions()); + final SszList blobKzgCommitments = + schemaDefinitions + .getBlobKzgCommitmentsSchema() + .createFromBlobsBundle(getPayloadResponse.getBlobsBundle().orElseThrow()); + return schemaDefinitions .getExecutionPayloadHeaderSchema() .createExecutionPayloadHeader( builder -> @@ -102,11 +111,11 @@ private ExecutionPayloadHeader createLocalBid( .parentBlockRoot(() -> parentRoot) .blockHash(getPayloadResponse.getExecutionPayload().getBlockHash()) .gasLimit(getPayloadResponse.getExecutionPayload().getGasLimit()) - .builderIndex(() -> UInt64.valueOf(builderIndex)) + .builderIndex(() -> builderIndex) .slot(() -> slot) .value( () -> UInt64.valueOf(getPayloadResponse.getExecutionPayloadValue().toLong())) - .blobKzgCommitmentsRoot(() -> Bytes32.ZERO)); + .blobKzgCommitmentsRoot(blobKzgCommitments::hashTreeRoot)); } } diff --git a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/execution/ExecutionPayloadEnvelopeSchema.java b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/execution/ExecutionPayloadEnvelopeSchema.java index 4b1d4e75ecb..a421168a3af 100644 --- a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/execution/ExecutionPayloadEnvelopeSchema.java +++ b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/execution/ExecutionPayloadEnvelopeSchema.java @@ -19,7 +19,6 @@ import tech.pegasys.teku.infrastructure.ssz.primitive.SszBit; import tech.pegasys.teku.infrastructure.ssz.primitive.SszBytes32; import tech.pegasys.teku.infrastructure.ssz.primitive.SszUInt64; -import tech.pegasys.teku.infrastructure.ssz.schema.SszListSchema; import tech.pegasys.teku.infrastructure.ssz.schema.SszPrimitiveSchemas; import tech.pegasys.teku.infrastructure.ssz.schema.SszSchema; import tech.pegasys.teku.infrastructure.ssz.tree.TreeNode; @@ -67,12 +66,6 @@ public ExecutionPayloadEnvelope create( stateRoot); } - @SuppressWarnings("unchecked") - public SszListSchema getBlobKzgCommitmentsSchema() { - return (SszListSchema) - getChildSchema(getFieldIndex("blob_kzg_commitments")); - } - @Override public ExecutionPayloadEnvelope createFromBackingNode(final TreeNode node) { return new ExecutionPayloadEnvelope(this, node); diff --git a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/versions/eip7732/helpers/MiscHelpersEip7732.java b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/versions/eip7732/helpers/MiscHelpersEip7732.java index 2b39c9dd531..650fe470c52 100644 --- a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/versions/eip7732/helpers/MiscHelpersEip7732.java +++ b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/versions/eip7732/helpers/MiscHelpersEip7732.java @@ -61,7 +61,6 @@ public int getBlobSidecarKzgCommitmentGeneralizedIndex(final UInt64 blobSidecarI .getBlobKzgCommitmentsRootGeneralizedIndex(); final long commitmentGeneralizedIndex = schemaDefinitions - .getExecutionPayloadEnvelopeSchema() .getBlobKzgCommitmentsSchema() .getChildGeneralizedIndex(blobSidecarIndex.longValue()); return (int)