Don't Reject Local Transactions Below Gas Minimum (#1743)

We don't want to reject our own transactions.

Signed-off-by: Ratan Rai Sur <ratan.r.sur@gmail.com>
pull/1747/head
Ratan (Rai) Sur 4 years ago committed by GitHub
parent 6dd89a534a
commit 318a77f5cf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      CHANGELOG.md
  2. 15
      ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/TransactionPool.java
  3. 13
      ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/TransactionPoolTest.java

@ -9,6 +9,7 @@
* Added command line option --static-nodes-file. [#1644](https://github.com/hyperledger/besu/pull/1644)
### Bug Fixes
* Accept locally-sourced transactions below the minimum gas price. [#1480](https://github.com/hyperledger/besu/issues/1480) [#1743](https://github.com/hyperledger/besu/pull/1743)
#### Previously identified known issues

@ -42,7 +42,6 @@ import org.hyperledger.besu.ethereum.mainnet.TransactionValidationParams;
import org.hyperledger.besu.ethereum.mainnet.ValidationResult;
import org.hyperledger.besu.ethereum.transaction.TransactionInvalidReason;
import org.hyperledger.besu.metrics.BesuMetricCategory;
import org.hyperledger.besu.plugin.data.TransactionType;
import org.hyperledger.besu.plugin.services.MetricsSystem;
import org.hyperledger.besu.plugin.services.metrics.Counter;
import org.hyperledger.besu.plugin.services.metrics.LabelledMetric;
@ -143,18 +142,10 @@ public class TransactionPool implements BlockAddedObserver {
public ValidationResult<TransactionInvalidReason> addLocalTransaction(
final Transaction transaction) {
if (transaction.getType().equals(TransactionType.FRONTIER)
&& (!ExperimentalEIPs.eip1559Enabled || this.eip1559.isEmpty())) {
final Wei transactionGasPrice = minTransactionGasPrice(transaction);
if (transactionGasPrice.compareTo(minTransactionGasPrice) < 0) {
return ValidationResult.invalid(TransactionInvalidReason.GAS_PRICE_TOO_LOW);
}
if (!configuration.getTxFeeCap().isZero()
&& transactionGasPrice.compareTo(configuration.getTxFeeCap()) > 0) {
return ValidationResult.invalid(TransactionInvalidReason.TX_FEECAP_EXCEEDED);
}
if (!configuration.getTxFeeCap().isZero()
&& minTransactionGasPrice(transaction).compareTo(configuration.getTxFeeCap()) > 0) {
return ValidationResult.invalid(TransactionInvalidReason.TX_FEECAP_EXCEEDED);
}
final ValidationResult<TransactionInvalidReason> validationResult =
validateTransaction(transaction);
if (validationResult.isValid()) {

@ -21,8 +21,8 @@ import static java.util.Collections.singletonList;
import static java.util.stream.Collectors.toList;
import static org.assertj.core.api.Assertions.assertThat;
import static org.hyperledger.besu.ethereum.mainnet.ValidationResult.valid;
import static org.hyperledger.besu.ethereum.transaction.TransactionInvalidReason.CHAIN_HEAD_WORLD_STATE_NOT_AVAILABLE;
import static org.hyperledger.besu.ethereum.transaction.TransactionInvalidReason.EXCEEDS_BLOCK_GAS_LIMIT;
import static org.hyperledger.besu.ethereum.transaction.TransactionInvalidReason.GAS_PRICE_TOO_LOW;
import static org.hyperledger.besu.ethereum.transaction.TransactionInvalidReason.NONCE_TOO_LOW;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyLong;
@ -294,20 +294,21 @@ public class TransactionPoolTest {
}
@Test
public void shouldRejectLocalTransactionsWhenGasPriceBelowMinimum() {
public void shouldNotRejectLocalTransactionsWhenGasPriceBelowMinimum() {
final Transaction transaction =
new TransactionTestFixture()
.nonce(1)
.gasLimit(0)
.gasPrice(Wei.of(1))
.createTransaction(KEY_PAIR1);
when(transactionValidator.validate(eq(transaction), any(Optional.class)))
.thenReturn(ValidationResult.valid());
final ValidationResult<TransactionInvalidReason> result =
transactionPool.addLocalTransaction(transaction);
assertThat(result).isEqualTo(ValidationResult.invalid(GAS_PRICE_TOO_LOW));
assertTransactionNotPending(transaction);
verifyZeroInteractions(transactionValidator); // Reject before validation
assertThat(result).isEqualTo(ValidationResult.invalid(CHAIN_HEAD_WORLD_STATE_NOT_AVAILABLE));
}
@Test

Loading…
Cancel
Save