@ -14,12 +14,13 @@
* /
* /
package org.hyperledger.besu.ethereum.core.fees ;
package org.hyperledger.besu.ethereum.core.fees ;
import static java.lang.Math.floorDiv ;
import static java.lang.Math.max ;
import static java.lang.Math.max ;
import org.hyperledger.besu.config.experimental.ExperimentalEIPs ;
import org.hyperledger.besu.config.experimental.ExperimentalEIPs ;
import org.hyperledger.besu.ethereum.core.BlockHeader ;
import org.hyperledger.besu.ethereum.core.BlockHeader ;
import java.math.BigInteger ;
import org.apache.logging.log4j.LogManager ;
import org.apache.logging.log4j.LogManager ;
import org.apache.logging.log4j.Logger ;
import org.apache.logging.log4j.Logger ;
@ -45,19 +46,19 @@ public class EIP1559 {
return parentBaseFee ;
return parentBaseFee ;
} else if ( parentBlockGasUsed > targetGasUsed ) {
} else if ( parentBlockGasUsed > targetGasUsed ) {
gasDelta = parentBlockGasUsed - targetGasUsed ;
gasDelta = parentBlockGasUsed - targetGasUsed ;
feeDelta =
final BigInteger pBaseFee = BigInteger . valueOf ( parentBaseFee ) ;
max (
final BigInteger gDelta = BigInteger . valueOf ( gasDelta ) ;
floorDiv (
final BigInteger target = BigInteger . valueOf ( targetGasUsed ) ;
floorDiv ( parentBaseFee * gasDelta , targetGasUsed ) ,
final BigInteger denominator = BigInteger . valueOf ( feeMarket . getBasefeeMaxChangeDenominator ( ) ) ;
feeMarket . getBasefeeMaxChangeDenominator ( ) ) ,
feeDelta = max ( pBaseFee . multiply ( gDelta ) . divide ( target ) . divide ( denominator ) . longValue ( ) , 1 ) ;
1 ) ;
baseFee = parentBaseFee + feeDelta ;
baseFee = parentBaseFee + feeDelta ;
} else {
} else {
gasDelta = targetGasUsed - parentBlockGasUsed ;
gasDelta = targetGasUsed - parentBlockGasUsed ;
feeDelta =
final BigInteger pBaseFee = BigInteger . valueOf ( parentBaseFee ) ;
floorDiv (
final BigInteger gDelta = BigInteger . valueOf ( gasDelta ) ;
floorDiv ( parentBaseFee * gasDelta , targetGasUsed ) ,
final BigInteger target = BigInteger . valueOf ( targetGasUsed ) ;
feeMarket . getBasefeeMaxChangeDenominator ( ) ) ;
final BigInteger denominator = BigInteger . valueOf ( feeMarket . getBasefeeMaxChangeDenominator ( ) ) ;
feeDelta = pBaseFee . multiply ( gDelta ) . divide ( target ) . divide ( denominator ) . longValue ( ) ;
baseFee = parentBaseFee - feeDelta ;
baseFee = parentBaseFee - feeDelta ;
}
}
LOG . trace (
LOG . trace (