Skip to content

Commit

Permalink
added eth1 check to consolidation change (Consensys#8274)
Browse files Browse the repository at this point in the history
  • Loading branch information
rolfyone authored May 1, 2024
1 parent ed763df commit dac5187
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -758,9 +758,14 @@ public void applyDeposit(
handleInvalidDeposit(pubkey, maybePubkeyToIndexMap);
}
} else {
// This validator already exists, increase their balance
applyDepositToValidatorIndex(
state, withdrawalCredentials, signatureAlreadyVerified, existingIndex.get(), amount);
state,
withdrawalCredentials,
signatureAlreadyVerified,
existingIndex.get(),
amount,
pubkey,
signature);
}
}

Expand All @@ -769,7 +774,9 @@ protected void applyDepositToValidatorIndex(
final Bytes32 withdrawalCredentials,
final boolean signatureAlreadyVerified,
final int validatorIndex,
final UInt64 amount) {
final UInt64 amount,
final BLSPublicKey pubkey,
final BLSSignature signature) {
beaconStateMutators.increaseBalance(state, validatorIndex, amount);
}

Expand All @@ -784,7 +791,7 @@ private void handleInvalidDeposit(
});
}

private boolean depositSignatureIsValid(
protected boolean depositSignatureIsValid(
final BLSPublicKey pubkey,
final Bytes32 withdrawalCredentials,
final UInt64 amount,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.apache.logging.log4j.Logger;
import org.apache.tuweni.bytes.Bytes32;
import tech.pegasys.teku.bls.BLSPublicKey;
import tech.pegasys.teku.bls.BLSSignature;
import tech.pegasys.teku.infrastructure.bytes.Bytes20;
import tech.pegasys.teku.infrastructure.ssz.SszList;
import tech.pegasys.teku.infrastructure.ssz.SszMutableList;
Expand Down Expand Up @@ -337,7 +338,9 @@ protected void applyDepositToValidatorIndex(
final Bytes32 withdrawalCredentials,
final boolean signatureAlreadyVerified,
final int validatorIndex,
final UInt64 amount) {
final UInt64 amount,
final BLSPublicKey pubkey,
final BLSSignature signature) {
final MutableBeaconStateElectra stateElectra = MutableBeaconStateElectra.required(state);
final SszMutableList<PendingBalanceDeposit> pendingBalanceDeposits =
MutableBeaconStateElectra.required(state).getPendingBalanceDeposits();
Expand All @@ -346,8 +349,11 @@ protected void applyDepositToValidatorIndex(
.getPendingBalanceDepositSchema()
.create(SszUInt64.of(UInt64.fromLongBits(validatorIndex)), SszUInt64.of(amount)));
stateElectra.setPendingBalanceDeposits(pendingBalanceDeposits);
if (signatureAlreadyVerified
&& predicatesElectra.isCompoundingWithdrawalCredential(withdrawalCredentials)) {
if (predicatesElectra.isCompoundingWithdrawalCredential(withdrawalCredentials)
&& PredicatesElectra.isEth1WithdrawalCredential(
state.getValidators().get(validatorIndex).getWithdrawalCredentials())
&& (signatureAlreadyVerified
|| depositSignatureIsValid(pubkey, withdrawalCredentials, amount, signature))) {
beaconStateMutatorsElectra.switchToCompoundingValidator(stateElectra, validatorIndex);
}
}
Expand Down

0 comments on commit dac5187

Please sign in to comment.