Skip to content

Commit

Permalink
add null validations when deserializing DepositRequestV1 (Consensys#8312
Browse files Browse the repository at this point in the history
)
  • Loading branch information
StefanBratanov authored May 14, 2024
1 parent a88fd41 commit bc0873e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

package tech.pegasys.teku.ethereum.executionclient.schema;

import static com.google.common.base.Preconditions.checkNotNull;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
Expand Down Expand Up @@ -54,6 +56,11 @@ public DepositRequestV1(
@JsonProperty("amount") final UInt64 amount,
@JsonProperty("signature") final Bytes signature,
@JsonProperty("index") final UInt64 index) {
checkNotNull(pubkey, "pubkey");
checkNotNull(withdrawalCredentials, "withdrawalCredentials");
checkNotNull(amount, "amount");
checkNotNull(signature, "signature");
checkNotNull(index, "index");
this.pubkey = pubkey;
this.withdrawalCredentials = withdrawalCredentials;
this.amount = amount;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ private void reducePendingWithdrawals(final MutableBeaconStateElectra state) {
private static void assertWithdrawalsInExecutionPayloadMatchExpected(
final ExecutionPayloadSummary payloadSummary, final SszList<Withdrawal> expectedWithdrawals)
throws BlockProcessingException {
// the spec does a element-to-element comparison but Teku is comparing the hash of the tree
// the spec does an element-to-element comparison but Teku is comparing the hash of the tree
if (payloadSummary.getOptionalWithdrawalsRoot().isEmpty()
|| !expectedWithdrawals
.hashTreeRoot()
Expand Down

0 comments on commit bc0873e

Please sign in to comment.