use of tech.pegasys.teku.spec.logic.common.operations.validation.OperationInvalidReason in project teku by ConsenSys.
the class AbstractBlockProcessor method processVoluntaryExitsNoValidation.
protected void processVoluntaryExitsNoValidation(MutableBeaconState state, SszList<SignedVoluntaryExit> exits) throws BlockProcessingException {
safelyProcess(() -> {
// For each exit in block.body.voluntaryExits:
for (SignedVoluntaryExit signedExit : exits) {
Optional<OperationInvalidReason> invalidReason = operationValidator.validateVoluntaryExit(state.getFork(), state, signedExit);
checkArgument(invalidReason.isEmpty(), "process_voluntary_exits: %s", invalidReason.map(OperationInvalidReason::describe).orElse(""));
// - Run initiate_validator_exit(state, exit.validator_index)
beaconStateMutators.initiateValidatorExit(state, toIntExact(signedExit.getMessage().getValidatorIndex().longValue()));
}
});
}
use of tech.pegasys.teku.spec.logic.common.operations.validation.OperationInvalidReason in project teku by ConsenSys.
the class AbstractBlockProcessor method processProposerSlashingsNoValidation.
protected void processProposerSlashingsNoValidation(MutableBeaconState state, SszList<ProposerSlashing> proposerSlashings) throws BlockProcessingException {
safelyProcess(() -> {
// For each proposer_slashing in block.body.proposer_slashings:
for (ProposerSlashing proposerSlashing : proposerSlashings) {
Optional<OperationInvalidReason> invalidReason = operationValidator.validateProposerSlashing(state.getFork(), state, proposerSlashing);
checkArgument(invalidReason.isEmpty(), "process_proposer_slashings: %s", invalidReason.map(OperationInvalidReason::describe).orElse(""));
beaconStateMutators.slashValidator(state, toIntExact(proposerSlashing.getHeader_1().getMessage().getProposerIndex().longValue()));
}
});
}
use of tech.pegasys.teku.spec.logic.common.operations.validation.OperationInvalidReason in project teku by ConsenSys.
the class AbstractBlockProcessor method assertAttestationValid.
protected void assertAttestationValid(final MutableBeaconState state, final Attestation attestation) {
final AttestationData data = attestation.getData();
final Optional<OperationInvalidReason> invalidReason = validateAttestation(state, data);
checkArgument(invalidReason.isEmpty(), "process_attestations: %s", invalidReason.map(OperationInvalidReason::describe).orElse(""));
IntList committee = beaconStateAccessors.getBeaconCommittee(state, data.getSlot(), data.getIndex());
checkArgument(attestation.getAggregationBits().size() == committee.size(), "process_attestations: Attestation aggregation bits and committee don't have the same length");
}
use of tech.pegasys.teku.spec.logic.common.operations.validation.OperationInvalidReason in project teku by ConsenSys.
the class AbstractBlockProcessor method processAttesterSlashings.
@Override
public void processAttesterSlashings(MutableBeaconState state, SszList<AttesterSlashing> attesterSlashings) throws BlockProcessingException {
safelyProcess(() -> {
// For each attester_slashing in block.body.attester_slashings:
for (AttesterSlashing attesterSlashing : attesterSlashings) {
List<UInt64> indicesToSlash = new ArrayList<>();
final Optional<OperationInvalidReason> invalidReason = operationValidator.validateAttesterSlashing(state.getFork(), state, attesterSlashing, indicesToSlash::add);
checkArgument(invalidReason.isEmpty(), "process_attester_slashings: %s", invalidReason.map(OperationInvalidReason::describe).orElse(""));
indicesToSlash.forEach(indexToSlash -> beaconStateMutators.slashValidator(state, toIntExact(indexToSlash.longValue())));
}
});
}
Aggregations