class EIP1559BlockHeaderGasPriceValidationRule implements DetachedBlockHeaderValidationRule {

  @Override
  public boolean validate(final BlockHeader header, final BlockHeader parent) {
    try {
      if (!eip1559.isEIP1559(header.getNumber())) {
        return true;
      }
      if (eip1559.isForkBlock(header.getNumber())) {
        return feeMarket.getInitialBasefee()
            == header.getBaseFee().orElseThrow(EIP1559MissingBaseFeeFromBlockHeader::new);
      }

      final Long parentBaseFee =
          parent.getBaseFee().orElseThrow(EIP1559MissingBaseFeeFromBlockHeader::new);
      final Long currentBaseFee =
          header.getBaseFee().orElseThrow(EIP1559MissingBaseFeeFromBlockHeader::new);
      final long targetGasUsed = eip1559.targetGasUsed(parent);
      final long baseFee =
          eip1559.computeBaseFee(parentBaseFee, parent.getGasUsed(), targetGasUsed);
      if (baseFee != header.getBaseFee().orElseThrow()) {
        LOG.trace(
            "Invalid block header: basefee {} does not equal expected basefee {}",
            header.getBaseFee().orElseThrow(),
            baseFee);
        return false;
      }
      return baseFee == currentBaseFee && eip1559.isValidBaseFee(parentBaseFee, currentBaseFee);
    } catch (final EIP1559MissingBaseFeeFromBlockHeader e) {
      LOG.trace(e.getMessage());
      return false;
    }
  }

  public  EIP1559BlockHeaderGasPriceValidationRule(final EIP1559 eip1559);

}