From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Aere Network Date: Thu, 10 Sep 2026 21:47:56 +0300 Subject: [PATCH] Aere Network: base-fee floor for chain 2800 (production form) Regenerated 2026-09-10 from the production tree (overlay applied) over the same file set. diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/feemarket/LondonFeeMarket.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/feemarket/LondonFeeMarket.java index 0ee4f7409..558076166 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/feemarket/LondonFeeMarket.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/feemarket/LondonFeeMarket.java @@ -34,11 +34,36 @@ public class LondonFeeMarket implements BaseFeeMarket { private static final Wei DEFAULT_BASEFEE_FLOOR = Wei.of(7L); + // AERE base-fee-floor fork (fork-gated, no-op until an operator activates it). + // + // Raises the consensus EIP-1559 base-fee floor from the emergent 7-wei integer-division floor + // to a configurable value (default 1 Gwei) at and after a chosen fork block, so the public RPC + // can serve a TRUE, block-hash-verifiable baseFeePerGas instead of a proxy-faked constant. + // + // Activation is read once at fee-market construction (node start) from a JVM system property + // with an environment-variable fallback, mirroring how the AERE PQC/Block-STM fork reads its + // own JVM-level configuration: + // -Daere.basefee.floor.forkBlock= (env AERE_BASEFEE_FLOOR_FORKBLOCK) default Long.MAX_VALUE (UNSET => no-op) + // -Daere.basefee.floor.value= (env AERE_BASEFEE_FLOOR_VALUE) default 1_000_000_000 (1 Gwei) + // + // UNSET (default) means the fork block is Long.MAX_VALUE, so no real block ever reaches it and + // every code path below is byte-identical to upstream London behaviour (7-wei emergent floor). + static final long DEFAULT_AERE_BASEFEE_FLOOR_VALUE = 1_000_000_000L; // 1 Gwei in wei + private static final String AERE_FLOOR_FORK_BLOCK_PROPERTY = "aere.basefee.floor.forkBlock"; + private static final String AERE_FLOOR_FORK_BLOCK_ENV = "AERE_BASEFEE_FLOOR_FORKBLOCK"; + private static final String AERE_FLOOR_VALUE_PROPERTY = "aere.basefee.floor.value"; + private static final String AERE_FLOOR_VALUE_ENV = "AERE_BASEFEE_FLOOR_VALUE"; + protected final Wei baseFeeInitialValue; private final long londonForkBlockNumber; private final TransactionPriceCalculator txPriceCalculator; private final Wei baseFeeFloor; + // Activation block for the AERE base-fee floor. Long.MAX_VALUE == UNSET == no-op. + private final long aereBaseFeeFloorForkBlock; + // Floor value applied at and after aereBaseFeeFloorForkBlock (wei). + private final long aereBaseFeeFloorValue; + LondonFeeMarket(final long londonForkBlockNumber, final Optional baseFeePerGasOverride) { this(TransactionPriceCalculator.eip1559(), londonForkBlockNumber, baseFeePerGasOverride); } @@ -47,10 +72,94 @@ public class LondonFeeMarket implements BaseFeeMarket { final TransactionPriceCalculator txPriceCalculator, final long londonForkBlockNumber, final Optional baseFeePerGasOverride) { + // Production path: resolve the AERE base-fee-floor fork activation from JVM configuration. + this( + txPriceCalculator, + londonForkBlockNumber, + baseFeePerGasOverride, + readAereFloorForkBlockConfig(), + readAereFloorValueConfig()); + } + + // Package-private constructor taking explicit AERE floor-fork parameters. Used by the + // production constructor above (after resolving JVM config) and by unit tests so the fork can be + // exercised deterministically without mutating global JVM system properties / environment. + LondonFeeMarket( + final TransactionPriceCalculator txPriceCalculator, + final long londonForkBlockNumber, + final Optional baseFeePerGasOverride, + final long aereBaseFeeFloorForkBlock, + final long aereBaseFeeFloorValue) { this.txPriceCalculator = txPriceCalculator; this.londonForkBlockNumber = londonForkBlockNumber; this.baseFeeInitialValue = baseFeePerGasOverride.orElse(DEFAULT_BASEFEE_INITIAL_VALUE); this.baseFeeFloor = baseFeeInitialValue.isZero() ? Wei.ZERO : DEFAULT_BASEFEE_FLOOR; + this.aereBaseFeeFloorForkBlock = aereBaseFeeFloorForkBlock; + this.aereBaseFeeFloorValue = aereBaseFeeFloorValue; + } + + private static long readAereFloorForkBlockConfig() { + return readLongConfig( + AERE_FLOOR_FORK_BLOCK_PROPERTY, AERE_FLOOR_FORK_BLOCK_ENV, Long.MAX_VALUE); + } + + private static long readAereFloorValueConfig() { + return readLongConfig( + AERE_FLOOR_VALUE_PROPERTY, AERE_FLOOR_VALUE_ENV, DEFAULT_AERE_BASEFEE_FLOOR_VALUE); + } + + private static long readLongConfig( + final String systemProperty, final String envVar, final long defaultValue) { + String raw = System.getProperty(systemProperty); + if (raw == null || raw.isBlank()) { + raw = System.getenv(envVar); + } + if (raw == null || raw.isBlank()) { + return defaultValue; + } + try { + final long parsed = Long.parseLong(raw.trim()); + if (parsed < 0L) { + LOG.warn( + "Ignoring negative {}/{} value '{}', using default {}", + systemProperty, + envVar, + raw, + defaultValue); + return defaultValue; + } + return parsed; + } catch (final NumberFormatException e) { + LOG.warn( + "Ignoring unparseable {}/{} value '{}', using default {}", + systemProperty, + envVar, + raw, + defaultValue); + return defaultValue; + } + } + + // Clamp a computed baseFee up to the active AERE floor at and after the fork block. Before the + // fork block (and when UNSET, since Long.MAX_VALUE is never reached) this returns baseFee + // unchanged, keeping pre-fork behaviour byte-identical to upstream. + private Wei applyAereBaseFeeFloor(final long blockNumber, final Wei baseFee) { + if (blockNumber >= aereBaseFeeFloorForkBlock) { + return UInt256s.max(baseFee, Wei.of(aereBaseFeeFloorValue)); + } + return baseFee; + } + + // Effective tx-pool minimum-fee floor. Pre-fork (UNSET) this is exactly the legacy baseFeeFloor + // (7 wei, or 0 on a zero-basefee chain), so tx-pool acceptance is byte-identical. Once an + // operator activates the AERE base-fee-floor fork, the tx-pool floor rises to the active AERE + // floor so tx-pool pricing agrees with the >= 1 Gwei header baseFee produced by computeBaseFee. + // A zero-basefee chain (baseFeeFloor == 0) is never raised. + private Wei effectiveBaseFeeFloor() { + if (baseFeeFloor.isZero() || aereBaseFeeFloorForkBlock == Long.MAX_VALUE) { + return baseFeeFloor; + } + return UInt256s.max(baseFeeFloor, Wei.of(aereBaseFeeFloorValue)); } @Override @@ -79,7 +188,7 @@ public class LondonFeeMarket implements BaseFeeMarket { return txn.getGasPrice() .map(Optional::of) .orElse(txn.getMaxFeePerGas()) - .filter(fee -> fee.greaterOrEqualThan(baseFeeFloor)) + .filter(fee -> fee.greaterOrEqualThan(effectiveBaseFeeFloor())) .isPresent(); } @@ -90,13 +199,13 @@ public class LondonFeeMarket implements BaseFeeMarket { final long parentBlockGasUsed, final long targetGasUsed) { if (londonForkBlockNumber == blockNumber) { - return getInitialBasefee(); + return applyAereBaseFeeFloor(blockNumber, getInitialBasefee()); } long gasDelta; Wei feeDelta, baseFee; if (parentBlockGasUsed == targetGasUsed) { - return parentBaseFee; + return applyAereBaseFeeFloor(blockNumber, parentBaseFee); } else if (parentBlockGasUsed > targetGasUsed) { gasDelta = parentBlockGasUsed - targetGasUsed; final long denominator = getBasefeeMaxChangeDenominator(); @@ -117,7 +226,7 @@ public class LondonFeeMarket implements BaseFeeMarket { parentBlockGasUsed, targetGasUsed, baseFee); - return baseFee; + return applyAereBaseFeeFloor(blockNumber, baseFee); } @Override