class IbftCoinbaseValidationRule implements AttachedBlockHeaderValidationRule {

  @Override
  public boolean validate(
      final BlockHeader header, final BlockHeader parent, final ProtocolContext context) {

    final ValidatorProvider validatorProvider =
        context
            .getConsensusState(IbftContext.class)
            .getVoteTallyCache()
            .getVoteTallyAfterBlock(parent);
    final Address proposer = header.getCoinbase();

    final Collection<Address> storedValidators = validatorProvider.getValidators();

    if (!storedValidators.contains(proposer)) {
      LOGGER.trace(
          "Block proposer is not a member of the validators. proposer={}, validators={}",
          proposer,
          storedValidators);
      return false;
    }

    return true;
  }

}