From a9bdd29128eca70d1922b282aa2b479ab492b563 Mon Sep 17 00:00:00 2001 From: Abdelhamid Bakhta <45264458+abdelhamidbakhta@users.noreply.github.com> Date: Thu, 25 Jun 2020 19:06:12 +0200 Subject: [PATCH] Remove block size and transaction size riders from EIP 1559. (#1147) Signed-off-by: Abdelhamid Bakhta --- .../blockcreation/AbstractBlockCreator.java | 7 +---- .../besu/ethereum/core/fees/EIP1559.java | 7 ----- .../besu/ethereum/core/fees/FeeMarket.java | 5 +--- .../ethereum/core/fees/FeeMarketConfig.java | 10 +------ .../mainnet/MainnetBlockBodyValidator.java | 10 ++----- .../mainnet/MainnetBlockHeaderValidator.java | 3 --- .../mainnet/MainnetTransactionValidator.java | 7 ----- .../MainnetTransactionValidatorTest.java | 26 +------------------ 8 files changed, 6 insertions(+), 69 deletions(-) diff --git a/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/AbstractBlockCreator.java b/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/AbstractBlockCreator.java index 9bb1c749b9..17d239f077 100644 --- a/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/AbstractBlockCreator.java +++ b/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/AbstractBlockCreator.java @@ -257,12 +257,7 @@ public abstract class AbstractBlockCreator implements AsyncBlockCreator { private ProcessableBlockHeader createPendingBlockHeader(final long timestamp) { final long newBlockNumber = parentHeader.getNumber() + 1; - final long gasLimit; - if (ExperimentalEIPs.eip1559Enabled && protocolSpec.isEip1559()) { - gasLimit = protocolSpec.getEip1559().orElseThrow().eip1559GasPool(newBlockNumber); - } else { - gasLimit = gasLimitCalculator.apply(parentHeader.getGasLimit()); - } + final long gasLimit = gasLimitCalculator.apply(parentHeader.getGasLimit()); final DifficultyCalculator difficultyCalculator = protocolSpec.getDifficultyCalculator(); final BigInteger difficulty = difficultyCalculator.nextDifficulty(timestamp, parentHeader, protocolContext); diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/fees/EIP1559.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/fees/EIP1559.java index 133c42f9ee..4d1221d281 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/fees/EIP1559.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/fees/EIP1559.java @@ -130,13 +130,6 @@ public class EIP1559 { : FRONTIER_TRANSACTIONS); } - public boolean isValidGasLimit(final Transaction transaction) { - if (transaction == null) { - return false; - } - return transaction.getGasLimit() <= feeMarket.getPerTxGaslimit(); - } - private void guardActivation() { if (!ExperimentalEIPs.eip1559Enabled) { throw new RuntimeException("EIP-1559 is not enabled"); diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/fees/FeeMarket.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/fees/FeeMarket.java index a63e9e9689..191ecf89ff 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/fees/FeeMarket.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/fees/FeeMarket.java @@ -30,8 +30,6 @@ public interface FeeMarket { long getInitialBasefee(); - long getPerTxGaslimit(); - long getSlackCoefficient(); static FeeMarket eip1559() { @@ -40,7 +38,6 @@ public interface FeeMarket { ExperimentalEIPs.targetGasUsed, ExperimentalEIPs.slackCoefficient, ExperimentalEIPs.decayRange, - ExperimentalEIPs.initialBasefee, - ExperimentalEIPs.perTxGasLimit); + ExperimentalEIPs.initialBasefee); } } diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/fees/FeeMarketConfig.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/fees/FeeMarketConfig.java index b5d8a95b46..1c0adfb326 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/fees/FeeMarketConfig.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/fees/FeeMarketConfig.java @@ -19,7 +19,6 @@ public class FeeMarketConfig implements FeeMarket { private final long targetGasUsed; private final long decayRange; private final long initialBasefee; - private final long perTxGaslimit; private final long slackCoefficient; private final long maxGas; private final long gasIncrementAmount; @@ -29,14 +28,12 @@ public class FeeMarketConfig implements FeeMarket { final long targetGasUsed, final long slackCoefficient, final long decayRange, - final long initialBasefee, - final long perTxGaslimit) { + final long initialBasefee) { this.basefeeMaxChangeDenominator = basefeeMaxChangeDenominator; this.targetGasUsed = targetGasUsed; this.slackCoefficient = slackCoefficient; this.decayRange = decayRange; this.initialBasefee = initialBasefee; - this.perTxGaslimit = perTxGaslimit; this.maxGas = slackCoefficient * targetGasUsed; this.gasIncrementAmount = this.maxGas / 2 / this.decayRange; } @@ -71,11 +68,6 @@ public class FeeMarketConfig implements FeeMarket { return initialBasefee; } - @Override - public long getPerTxGaslimit() { - return perTxGaslimit; - } - @Override public long getSlackCoefficient() { return slackCoefficient; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetBlockBodyValidator.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetBlockBodyValidator.java index 8798227b26..2255f92233 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetBlockBodyValidator.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetBlockBodyValidator.java @@ -112,7 +112,7 @@ public class MainnetBlockBodyValidator implements BlockBodyValidator { return false; } - if (!validatePerTransactionGasLimit(block)) { + if (!validateTransactionGasPrice(block)) { return false; } @@ -271,7 +271,7 @@ public class MainnetBlockBodyValidator implements BlockBodyValidator { return false; } - private boolean validatePerTransactionGasLimit(final Block block) { + private boolean validateTransactionGasPrice(final Block block) { if (!ExperimentalEIPs.eip1559Enabled || maybeEip1559.isEmpty()) { return true; } @@ -284,12 +284,6 @@ public class MainnetBlockBodyValidator implements BlockBodyValidator { final TransactionPriceCalculator transactionPriceCalculator = TransactionPriceCalculator.eip1559(); for (final Transaction transaction : transactions) { - if (!eip1559.isValidGasLimit(transaction)) { - LOG.warn( - "Invalid block: transaction gas limit {} exceeds per transaction gas limit", - transaction.getGasLimit()); - return false; - } final Optional baseFee = block.getHeader().getBaseFee(); final Wei price = transactionPriceCalculator.price(transaction, baseFee); if (price.compareTo(Wei.of(baseFee.orElseThrow())) < 0) { diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetBlockHeaderValidator.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetBlockHeaderValidator.java index f864deb122..ec1f8bbfbf 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetBlockHeaderValidator.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetBlockHeaderValidator.java @@ -20,7 +20,6 @@ import org.hyperledger.besu.ethereum.core.fees.EIP1559; import org.hyperledger.besu.ethereum.mainnet.headervalidationrules.AncestryValidationRule; import org.hyperledger.besu.ethereum.mainnet.headervalidationrules.CalculatedDifficultyValidationRule; import org.hyperledger.besu.ethereum.mainnet.headervalidationrules.ConstantFieldValidationRule; -import org.hyperledger.besu.ethereum.mainnet.headervalidationrules.EIP1559BlockHeaderGasLimitValidationRule; import org.hyperledger.besu.ethereum.mainnet.headervalidationrules.EIP1559BlockHeaderGasPriceValidationRule; import org.hyperledger.besu.ethereum.mainnet.headervalidationrules.ExtraDataMaxLengthValidationRule; import org.hyperledger.besu.ethereum.mainnet.headervalidationrules.GasLimitRangeAndDeltaValidationRule; @@ -102,7 +101,6 @@ public final class MainnetBlockHeaderValidator { .addRule(new TimestampBoundedByFutureParameter(TIMESTAMP_TOLERANCE_S)) .addRule(new ExtraDataMaxLengthValidationRule(BlockHeader.MAX_EXTRA_DATA_BYTES)) .addRule(new ProofOfWorkValidationRule(true)) - .addRule(new EIP1559BlockHeaderGasLimitValidationRule(eip1559)) .addRule((new EIP1559BlockHeaderGasPriceValidationRule(eip1559))); } @@ -115,7 +113,6 @@ public final class MainnetBlockHeaderValidator { .addRule(new TimestampMoreRecentThanParent(MINIMUM_SECONDS_SINCE_PARENT)) .addRule(new ExtraDataMaxLengthValidationRule(BlockHeader.MAX_EXTRA_DATA_BYTES)) .addRule(new ProofOfWorkValidationRule(true)) - .addRule(new EIP1559BlockHeaderGasLimitValidationRule(eip1559)) .addRule((new EIP1559BlockHeaderGasPriceValidationRule(eip1559))); } } diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetTransactionValidator.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetTransactionValidator.java index f745709d32..d427507569 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetTransactionValidator.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetTransactionValidator.java @@ -88,13 +88,6 @@ public class MainnetTransactionValidator implements TransactionValidator { "transaction format is invalid, accepted transaction types are %s", acceptedTransactionTypes.toString())); } - if (!eip1559.isValidGasLimit(transaction)) { - return ValidationResult.invalid( - TransactionInvalidReason.EXCEEDS_PER_TRANSACTION_GAS_LIMIT, - String.format( - "transaction gas limit %s exceeds per transaction gas limit", - transaction.getGasLimit())); - } } final Gas intrinsicGasCost = gasCalculator.transactionIntrinsicGasCost(transaction); diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/MainnetTransactionValidatorTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/MainnetTransactionValidatorTest.java index 1606baf5c0..8c2a8201dc 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/MainnetTransactionValidatorTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/MainnetTransactionValidatorTest.java @@ -237,30 +237,6 @@ public class MainnetTransactionValidatorTest { verifyZeroInteractions(transactionFilter); } - @Test - public void shouldRejectTransactionIfGasLimitExceedsPerTransactionGasLimit() { - final long forkBlock = 845L; - final EIP1559 eip1559 = new EIP1559(forkBlock); - ExperimentalEIPs.eip1559Enabled = true; - final MainnetTransactionValidator validator = - new MainnetTransactionValidator( - gasCalculator, - false, - Optional.empty(), - Optional.of(eip1559), - AcceptedTransactionTypes.FEE_MARKET_TRANSITIONAL_TRANSACTIONS); - final Transaction transaction = - new TransactionTestFixture() - .gasLimit(feeMarket.getPerTxGaslimit() + 1) - .chainId(Optional.empty()) - .createTransaction(senderKeys); - assertThat(validator.validate(transaction)) - .isEqualTo( - ValidationResult.invalid( - TransactionValidator.TransactionInvalidReason.EXCEEDS_PER_TRANSACTION_GAS_LIMIT)); - ExperimentalEIPs.eip1559Enabled = false; - } - @Test public void shouldRejectTransactionIfLegacyAfterEIP1559Finalized() { final long forkBlock = 845L; @@ -275,7 +251,7 @@ public class MainnetTransactionValidatorTest { AcceptedTransactionTypes.FEE_MARKET_TRANSACTIONS); final Transaction transaction = new TransactionTestFixture() - .gasLimit(feeMarket.getPerTxGaslimit() + 1) + .gasLimit(21000) .chainId(Optional.empty()) .createTransaction(senderKeys); assertThat(validator.validate(transaction))