Skip to content

Commit

Permalink
Remove block size and transaction size riders from EIP 1559. (#1147)
Browse files Browse the repository at this point in the history
Signed-off-by: Abdelhamid Bakhta <[email protected]>
  • Loading branch information
AbdelStark authored Jun 25, 2020
1 parent 79ed3f6 commit a9bdd29
Show file tree
Hide file tree
Showing 8 changed files with 6 additions and 69 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -257,12 +257,7 @@ private List<BlockHeader> selectOmmers() {

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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,6 @@ public boolean isValidTransaction(final long blockNumber, final Transaction tran
: 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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ public interface FeeMarket {

long getInitialBasefee();

long getPerTxGaslimit();

long getSlackCoefficient();

static FeeMarket eip1559() {
Expand All @@ -40,7 +38,6 @@ static FeeMarket eip1559() {
ExperimentalEIPs.targetGasUsed,
ExperimentalEIPs.slackCoefficient,
ExperimentalEIPs.decayRange,
ExperimentalEIPs.initialBasefee,
ExperimentalEIPs.perTxGasLimit);
ExperimentalEIPs.initialBasefee);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -29,14 +28,12 @@ public FeeMarketConfig(
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;
}
Expand Down Expand Up @@ -71,11 +68,6 @@ public long getInitialBasefee() {
return initialBasefee;
}

@Override
public long getPerTxGaslimit() {
return perTxGaslimit;
}

@Override
public long getSlackCoefficient() {
return slackCoefficient;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public boolean validateBodyLight(
return false;
}

if (!validatePerTransactionGasLimit(block)) {
if (!validateTransactionGasPrice(block)) {
return false;
}

Expand Down Expand Up @@ -271,7 +271,7 @@ private boolean isOmmerSiblingOfAncestor(
return false;
}

private boolean validatePerTransactionGasLimit(final Block block) {
private boolean validateTransactionGasPrice(final Block block) {
if (!ExperimentalEIPs.eip1559Enabled || maybeEip1559.isEmpty()) {
return true;
}
Expand All @@ -284,12 +284,6 @@ private boolean validatePerTransactionGasLimit(final Block block) {
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<Long> baseFee = block.getHeader().getBaseFee();
final Wei price = transactionPriceCalculator.price(transaction, baseFee);
if (price.compareTo(Wei.of(baseFee.orElseThrow())) < 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
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;
Expand Down Expand Up @@ -102,7 +101,6 @@ static BlockHeaderValidator.Builder createEip1559Validator(final EIP1559 eip1559
.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)));
}

Expand All @@ -115,7 +113,6 @@ static BlockHeaderValidator.Builder createEip1559OmmerValidator(final EIP1559 ei
.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)));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,6 @@ public ValidationResult<TransactionInvalidReason> validate(final Transaction tra
"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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,30 +237,6 @@ public void shouldNotCheckAccountPermissionIfBothValidationParamsCheckPermission
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;
Expand All @@ -275,7 +251,7 @@ public void shouldRejectTransactionIfLegacyAfterEIP1559Finalized() {
AcceptedTransactionTypes.FEE_MARKET_TRANSACTIONS);
final Transaction transaction =
new TransactionTestFixture()
.gasLimit(feeMarket.getPerTxGaslimit() + 1)
.gasLimit(21000)
.chainId(Optional.empty())
.createTransaction(senderKeys);
assertThat(validator.validate(transaction))
Expand Down

0 comments on commit a9bdd29

Please sign in to comment.