Skip to content

Commit

Permalink
fix ropsten consensus issue (hyperledger#2499)
Browse files Browse the repository at this point in the history
Signed-off-by: Karim TAAM <[email protected]>
Signed-off-by: Ratan Rai Sur <[email protected]>
  • Loading branch information
matkt authored and RatanRSur committed Jul 8, 2021
1 parent 8cecd33 commit 1cd6bc8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,6 @@ public long computeBaseFee(
return baseFee;
}

public boolean isValidBaseFee(final long parentBaseFee, final long baseFee) {
return Math.abs(baseFee - parentBaseFee)
<= Math.max(1, parentBaseFee / feeMarket.getBasefeeMaxChangeDenominator());
}

public boolean isEIP1559(final long blockNumber) {
return blockNumber >= initialForkBlknum;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,18 @@ public boolean validate(final BlockHeader header, final BlockHeader parent) {
final Long currentBaseFee =
header.getBaseFee().orElseThrow(EIP1559MissingBaseFeeFromBlockHeader::new);
final long targetGasUsed = eip1559.targetGasUsed(parent);
final long baseFee =
final long expectedBaseFee =
eip1559.computeBaseFee(
header.getNumber(), parentBaseFee, parent.getGasUsed(), targetGasUsed);
if (baseFee != header.getBaseFee().orElseThrow()) {
if (expectedBaseFee != currentBaseFee) {
LOG.info(
"Invalid block header: basefee {} does not equal expected basefee {}",
header.getBaseFee().orElseThrow(),
baseFee);
expectedBaseFee);
return false;
}
return baseFee == currentBaseFee && eip1559.isValidBaseFee(parentBaseFee, currentBaseFee);

return true;
} catch (final EIP1559MissingBaseFeeFromBlockHeader e) {
LOG.info("Invalid block header: " + e.getMessage());
return false;
Expand Down

0 comments on commit 1cd6bc8

Please sign in to comment.