Skip to content

Commit

Permalink
Check that ExecutionRequests is not null in block body (Consensys#8697)
Browse files Browse the repository at this point in the history
Co-authored-by: Lucas Saldanha <lucas.saldanha@consensys.net>
  • Loading branch information
jtraglia and lucassaldanha authored Oct 10, 2024
1 parent a416449 commit 22eb9ac
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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<DepositRequest> depositRequests =
message.getExecutionRequests().getDeposits().stream().map(DepositRequest::new).toList();
final List<WithdrawalRequest> withdrawalRequests =
message.getExecutionRequests().getWithdrawals().stream()
.map(WithdrawalRequest::new)
.toList();
final List<ConsolidationRequest> 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

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

0 comments on commit 22eb9ac

Please sign in to comment.