Remove block size and transaction size riders from EIP 1559. (#1147)

Signed-off-by: Abdelhamid Bakhta <abdelhamid.bakhta@consensys.net>
pull/1155/head
Abdelhamid Bakhta 4 years ago committed by GitHub
parent 79ed3f642a
commit a9bdd29128
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 7
      ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/AbstractBlockCreator.java
  2. 7
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/fees/EIP1559.java
  3. 5
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/fees/FeeMarket.java
  4. 10
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/fees/FeeMarketConfig.java
  5. 10
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetBlockBodyValidator.java
  6. 3
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetBlockHeaderValidator.java
  7. 7
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetTransactionValidator.java
  8. 26
      ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/MainnetTransactionValidatorTest.java

@ -257,12 +257,7 @@ public abstract class AbstractBlockCreator implements AsyncBlockCreator {
private ProcessableBlockHeader createPendingBlockHeader(final long timestamp) { private ProcessableBlockHeader createPendingBlockHeader(final long timestamp) {
final long newBlockNumber = parentHeader.getNumber() + 1; final long newBlockNumber = parentHeader.getNumber() + 1;
final long gasLimit; final long gasLimit = gasLimitCalculator.apply(parentHeader.getGasLimit());
if (ExperimentalEIPs.eip1559Enabled && protocolSpec.isEip1559()) {
gasLimit = protocolSpec.getEip1559().orElseThrow().eip1559GasPool(newBlockNumber);
} else {
gasLimit = gasLimitCalculator.apply(parentHeader.getGasLimit());
}
final DifficultyCalculator difficultyCalculator = protocolSpec.getDifficultyCalculator(); final DifficultyCalculator difficultyCalculator = protocolSpec.getDifficultyCalculator();
final BigInteger difficulty = final BigInteger difficulty =
difficultyCalculator.nextDifficulty(timestamp, parentHeader, protocolContext); difficultyCalculator.nextDifficulty(timestamp, parentHeader, protocolContext);

@ -130,13 +130,6 @@ public class EIP1559 {
: FRONTIER_TRANSACTIONS); : FRONTIER_TRANSACTIONS);
} }
public boolean isValidGasLimit(final Transaction transaction) {
if (transaction == null) {
return false;
}
return transaction.getGasLimit() <= feeMarket.getPerTxGaslimit();
}
private void guardActivation() { private void guardActivation() {
if (!ExperimentalEIPs.eip1559Enabled) { if (!ExperimentalEIPs.eip1559Enabled) {
throw new RuntimeException("EIP-1559 is not enabled"); throw new RuntimeException("EIP-1559 is not enabled");

@ -30,8 +30,6 @@ public interface FeeMarket {
long getInitialBasefee(); long getInitialBasefee();
long getPerTxGaslimit();
long getSlackCoefficient(); long getSlackCoefficient();
static FeeMarket eip1559() { static FeeMarket eip1559() {
@ -40,7 +38,6 @@ public interface FeeMarket {
ExperimentalEIPs.targetGasUsed, ExperimentalEIPs.targetGasUsed,
ExperimentalEIPs.slackCoefficient, ExperimentalEIPs.slackCoefficient,
ExperimentalEIPs.decayRange, ExperimentalEIPs.decayRange,
ExperimentalEIPs.initialBasefee, ExperimentalEIPs.initialBasefee);
ExperimentalEIPs.perTxGasLimit);
} }
} }

@ -19,7 +19,6 @@ public class FeeMarketConfig implements FeeMarket {
private final long targetGasUsed; private final long targetGasUsed;
private final long decayRange; private final long decayRange;
private final long initialBasefee; private final long initialBasefee;
private final long perTxGaslimit;
private final long slackCoefficient; private final long slackCoefficient;
private final long maxGas; private final long maxGas;
private final long gasIncrementAmount; private final long gasIncrementAmount;
@ -29,14 +28,12 @@ public class FeeMarketConfig implements FeeMarket {
final long targetGasUsed, final long targetGasUsed,
final long slackCoefficient, final long slackCoefficient,
final long decayRange, final long decayRange,
final long initialBasefee, final long initialBasefee) {
final long perTxGaslimit) {
this.basefeeMaxChangeDenominator = basefeeMaxChangeDenominator; this.basefeeMaxChangeDenominator = basefeeMaxChangeDenominator;
this.targetGasUsed = targetGasUsed; this.targetGasUsed = targetGasUsed;
this.slackCoefficient = slackCoefficient; this.slackCoefficient = slackCoefficient;
this.decayRange = decayRange; this.decayRange = decayRange;
this.initialBasefee = initialBasefee; this.initialBasefee = initialBasefee;
this.perTxGaslimit = perTxGaslimit;
this.maxGas = slackCoefficient * targetGasUsed; this.maxGas = slackCoefficient * targetGasUsed;
this.gasIncrementAmount = this.maxGas / 2 / this.decayRange; this.gasIncrementAmount = this.maxGas / 2 / this.decayRange;
} }
@ -71,11 +68,6 @@ public class FeeMarketConfig implements FeeMarket {
return initialBasefee; return initialBasefee;
} }
@Override
public long getPerTxGaslimit() {
return perTxGaslimit;
}
@Override @Override
public long getSlackCoefficient() { public long getSlackCoefficient() {
return slackCoefficient; return slackCoefficient;

@ -112,7 +112,7 @@ public class MainnetBlockBodyValidator implements BlockBodyValidator {
return false; return false;
} }
if (!validatePerTransactionGasLimit(block)) { if (!validateTransactionGasPrice(block)) {
return false; return false;
} }
@ -271,7 +271,7 @@ public class MainnetBlockBodyValidator implements BlockBodyValidator {
return false; return false;
} }
private boolean validatePerTransactionGasLimit(final Block block) { private boolean validateTransactionGasPrice(final Block block) {
if (!ExperimentalEIPs.eip1559Enabled || maybeEip1559.isEmpty()) { if (!ExperimentalEIPs.eip1559Enabled || maybeEip1559.isEmpty()) {
return true; return true;
} }
@ -284,12 +284,6 @@ public class MainnetBlockBodyValidator implements BlockBodyValidator {
final TransactionPriceCalculator transactionPriceCalculator = final TransactionPriceCalculator transactionPriceCalculator =
TransactionPriceCalculator.eip1559(); TransactionPriceCalculator.eip1559();
for (final Transaction transaction : transactions) { 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<Long> baseFee = block.getHeader().getBaseFee(); final Optional<Long> baseFee = block.getHeader().getBaseFee();
final Wei price = transactionPriceCalculator.price(transaction, baseFee); final Wei price = transactionPriceCalculator.price(transaction, baseFee);
if (price.compareTo(Wei.of(baseFee.orElseThrow())) < 0) { if (price.compareTo(Wei.of(baseFee.orElseThrow())) < 0) {

@ -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.AncestryValidationRule;
import org.hyperledger.besu.ethereum.mainnet.headervalidationrules.CalculatedDifficultyValidationRule; import org.hyperledger.besu.ethereum.mainnet.headervalidationrules.CalculatedDifficultyValidationRule;
import org.hyperledger.besu.ethereum.mainnet.headervalidationrules.ConstantFieldValidationRule; 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.EIP1559BlockHeaderGasPriceValidationRule;
import org.hyperledger.besu.ethereum.mainnet.headervalidationrules.ExtraDataMaxLengthValidationRule; import org.hyperledger.besu.ethereum.mainnet.headervalidationrules.ExtraDataMaxLengthValidationRule;
import org.hyperledger.besu.ethereum.mainnet.headervalidationrules.GasLimitRangeAndDeltaValidationRule; import org.hyperledger.besu.ethereum.mainnet.headervalidationrules.GasLimitRangeAndDeltaValidationRule;
@ -102,7 +101,6 @@ public final class MainnetBlockHeaderValidator {
.addRule(new TimestampBoundedByFutureParameter(TIMESTAMP_TOLERANCE_S)) .addRule(new TimestampBoundedByFutureParameter(TIMESTAMP_TOLERANCE_S))
.addRule(new ExtraDataMaxLengthValidationRule(BlockHeader.MAX_EXTRA_DATA_BYTES)) .addRule(new ExtraDataMaxLengthValidationRule(BlockHeader.MAX_EXTRA_DATA_BYTES))
.addRule(new ProofOfWorkValidationRule(true)) .addRule(new ProofOfWorkValidationRule(true))
.addRule(new EIP1559BlockHeaderGasLimitValidationRule(eip1559))
.addRule((new EIP1559BlockHeaderGasPriceValidationRule(eip1559))); .addRule((new EIP1559BlockHeaderGasPriceValidationRule(eip1559)));
} }
@ -115,7 +113,6 @@ public final class MainnetBlockHeaderValidator {
.addRule(new TimestampMoreRecentThanParent(MINIMUM_SECONDS_SINCE_PARENT)) .addRule(new TimestampMoreRecentThanParent(MINIMUM_SECONDS_SINCE_PARENT))
.addRule(new ExtraDataMaxLengthValidationRule(BlockHeader.MAX_EXTRA_DATA_BYTES)) .addRule(new ExtraDataMaxLengthValidationRule(BlockHeader.MAX_EXTRA_DATA_BYTES))
.addRule(new ProofOfWorkValidationRule(true)) .addRule(new ProofOfWorkValidationRule(true))
.addRule(new EIP1559BlockHeaderGasLimitValidationRule(eip1559))
.addRule((new EIP1559BlockHeaderGasPriceValidationRule(eip1559))); .addRule((new EIP1559BlockHeaderGasPriceValidationRule(eip1559)));
} }
} }

@ -88,13 +88,6 @@ public class MainnetTransactionValidator implements TransactionValidator {
"transaction format is invalid, accepted transaction types are %s", "transaction format is invalid, accepted transaction types are %s",
acceptedTransactionTypes.toString())); 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); final Gas intrinsicGasCost = gasCalculator.transactionIntrinsicGasCost(transaction);

@ -237,30 +237,6 @@ public class MainnetTransactionValidatorTest {
verifyZeroInteractions(transactionFilter); 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 @Test
public void shouldRejectTransactionIfLegacyAfterEIP1559Finalized() { public void shouldRejectTransactionIfLegacyAfterEIP1559Finalized() {
final long forkBlock = 845L; final long forkBlock = 845L;
@ -275,7 +251,7 @@ public class MainnetTransactionValidatorTest {
AcceptedTransactionTypes.FEE_MARKET_TRANSACTIONS); AcceptedTransactionTypes.FEE_MARKET_TRANSACTIONS);
final Transaction transaction = final Transaction transaction =
new TransactionTestFixture() new TransactionTestFixture()
.gasLimit(feeMarket.getPerTxGaslimit() + 1) .gasLimit(21000)
.chainId(Optional.empty()) .chainId(Optional.empty())
.createTransaction(senderKeys); .createTransaction(senderKeys);
assertThat(validator.validate(transaction)) assertThat(validator.validate(transaction))

Loading…
Cancel
Save