From 22eb9acffc5a979579b30c417aa1999f622ac69a Mon Sep 17 00:00:00 2001 From: Justin Traglia <95511699+jtraglia@users.noreply.github.com> Date: Wed, 9 Oct 2024 22:16:42 -0500 Subject: [PATCH] Check that ExecutionRequests is not null in block body (#8697) Co-authored-by: Lucas Saldanha --- .../electra/BeaconBlockBodyElectra.java | 29 ++++++------------- .../BlindedBeaconBlockBodyElectra.java | 8 ++--- .../helpers/BeaconStateAccessorsElectra.java | 2 +- 3 files changed, 14 insertions(+), 25 deletions(-) diff --git a/data/serializer/src/main/java/tech/pegasys/teku/api/schema/electra/BeaconBlockBodyElectra.java b/data/serializer/src/main/java/tech/pegasys/teku/api/schema/electra/BeaconBlockBodyElectra.java index 18c78d7a68c..f8dcdd2772c 100644 --- a/data/serializer/src/main/java/tech/pegasys/teku/api/schema/electra/BeaconBlockBodyElectra.java +++ b/data/serializer/src/main/java/tech/pegasys/teku/api/schema/electra/BeaconBlockBodyElectra.java @@ -79,13 +79,13 @@ public BeaconBlockBodyElectra( deposits, voluntaryExits, syncAggregate); - checkNotNull(executionPayload, "Execution Payload is required for Electra blocks"); + checkNotNull(executionPayload, "ExecutionPayload is required for Electra blocks"); this.executionPayload = executionPayload; checkNotNull(blsToExecutionChanges, "BlsToExecutionChanges is required for Electra blocks"); this.blsToExecutionChanges = blsToExecutionChanges; - checkNotNull(blobKZGCommitments, "blobKZGCommitments is required for Electra blocks"); + checkNotNull(blobKZGCommitments, "BlobKZGCommitments is required for Electra blocks"); this.blobKZGCommitments = blobKZGCommitments; - checkNotNull(executionRequests, "Execution Requests is required for Electra blocks"); + checkNotNull(executionRequests, "ExecutionRequests is required for Electra blocks"); this.executionRequests = executionRequests; } @@ -94,33 +94,22 @@ public BeaconBlockBodyElectra( .BeaconBlockBodyElectra message) { super(message); - checkNotNull(message.getExecutionPayload(), "Execution Payload is required for Electra blocks"); + checkNotNull(message.getExecutionPayload(), "ExecutionPayload is required for Electra blocks"); this.executionPayload = new ExecutionPayloadDeneb(message.getExecutionPayload()); checkNotNull( - message.getBlsToExecutionChanges(), - "BlsToExecutionChanges are required for Electra blocks"); + message.getBlsToExecutionChanges(), "BlsToExecutionChanges is required for Electra blocks"); this.blsToExecutionChanges = message.getBlsToExecutionChanges().stream().map(SignedBlsToExecutionChange::new).toList(); checkNotNull( - message.getBlobKzgCommitments(), "BlobKzgCommitments are required for Electra blocks"); + message.getBlobKzgCommitments(), "BlobKzgCommitments is required for Electra blocks"); this.blobKZGCommitments = message.getBlobKzgCommitments().stream() .map(SszKZGCommitment::getKZGCommitment) .map(KZGCommitment::new) .toList(); - - final List depositRequests = - message.getExecutionRequests().getDeposits().stream().map(DepositRequest::new).toList(); - final List withdrawalRequests = - message.getExecutionRequests().getWithdrawals().stream() - .map(WithdrawalRequest::new) - .toList(); - final List consolidationRequests = - message.getExecutionRequests().getConsolidations().stream() - .map(ConsolidationRequest::new) - .toList(); - this.executionRequests = - new ExecutionRequests(depositRequests, withdrawalRequests, consolidationRequests); + checkNotNull( + message.getExecutionRequests(), "ExecutionRequests is required for Electra blocks"); + this.executionRequests = new ExecutionRequests(message.getExecutionRequests()); } @Override diff --git a/data/serializer/src/main/java/tech/pegasys/teku/api/schema/electra/BlindedBeaconBlockBodyElectra.java b/data/serializer/src/main/java/tech/pegasys/teku/api/schema/electra/BlindedBeaconBlockBodyElectra.java index f97d0e48caa..2e61c080721 100644 --- a/data/serializer/src/main/java/tech/pegasys/teku/api/schema/electra/BlindedBeaconBlockBodyElectra.java +++ b/data/serializer/src/main/java/tech/pegasys/teku/api/schema/electra/BlindedBeaconBlockBodyElectra.java @@ -84,15 +84,15 @@ public BlindedBeaconBlockBodyElectra( voluntaryExits, syncAggregate); checkNotNull( - executionPayloadHeader, "Execution Payload Header is required for Electra blinded blocks"); + executionPayloadHeader, "ExecutionPayloadHeader is required for Electra blinded blocks"); this.executionPayloadHeader = executionPayloadHeader; checkNotNull( - blsToExecutionChanges, "blsToExecutionChanges is required for Electra blinded blocks"); + blsToExecutionChanges, "BlsToExecutionChanges is required for Electra blinded blocks"); this.blsToExecutionChanges = blsToExecutionChanges; - checkNotNull(blobKZGCommitments, "blobKZGCommitments is required for Electra blinded blocks"); + checkNotNull(blobKZGCommitments, "BlobKZGCommitments is required for Electra blinded blocks"); this.blobKZGCommitments = blobKZGCommitments; checkNotNull( - executionRequestsRoot, "execution_requests_root is required for Electra blinded blocks"); + executionRequestsRoot, "ExecutionRequestsRoot is required for Electra blinded blocks"); this.executionRequestsRoot = executionRequestsRoot; } diff --git a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/versions/electra/helpers/BeaconStateAccessorsElectra.java b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/versions/electra/helpers/BeaconStateAccessorsElectra.java index 49bf6eca7ea..9aa6cc60272 100644 --- a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/versions/electra/helpers/BeaconStateAccessorsElectra.java +++ b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/versions/electra/helpers/BeaconStateAccessorsElectra.java @@ -70,7 +70,7 @@ public UInt64 getActiveBalance(final BeaconState state, final int validatorIndex * * @param state The state * @param validatorIndex The index of the validator - * @return The sum of the withdrawal amounts for the validator in the partial withdrawal queue + * @return The sum of the withdrawal amounts for the validator in the partial withdrawal queue. */ public UInt64 getPendingBalanceToWithdraw( final BeaconStateElectra state, final int validatorIndex) {