Added --tx-queue-no-early-reject flag to disable early tx queue rejects (#9143)
* Added --tx-queue-no-early-reject flag to disable early tx queue rejects because of low gas price * Fixed failing tests, clarified comments and simplified no_early_reject field name. * Added test case for the --tx-queue-no-early-reject flag
This commit is contained in:
committed by
Andronik Ordian
parent
4848c384cd
commit
1b1941a896
@@ -37,6 +37,7 @@ fn new_queue() -> TransactionQueue {
|
||||
minimal_gas_price: 1.into(),
|
||||
block_gas_limit: 1_000_000.into(),
|
||||
tx_gas_limit: 1_000_000.into(),
|
||||
no_early_reject: false,
|
||||
},
|
||||
PrioritizationStrategy::GasPriceOnly,
|
||||
)
|
||||
@@ -54,6 +55,7 @@ fn should_return_correct_nonces_when_dropped_because_of_limit() {
|
||||
minimal_gas_price: 1.into(),
|
||||
block_gas_limit: 1_000_000.into(),
|
||||
tx_gas_limit: 1_000_000.into(),
|
||||
no_early_reject: false,
|
||||
},
|
||||
PrioritizationStrategy::GasPriceOnly,
|
||||
);
|
||||
@@ -105,6 +107,7 @@ fn should_never_drop_local_transactions_from_different_senders() {
|
||||
minimal_gas_price: 1.into(),
|
||||
block_gas_limit: 1_000_000.into(),
|
||||
tx_gas_limit: 1_000_000.into(),
|
||||
no_early_reject: false,
|
||||
},
|
||||
PrioritizationStrategy::GasPriceOnly,
|
||||
);
|
||||
@@ -478,6 +481,7 @@ fn should_prefer_current_transactions_when_hitting_the_limit() {
|
||||
minimal_gas_price: 1.into(),
|
||||
block_gas_limit: 1_000_000.into(),
|
||||
tx_gas_limit: 1_000_000.into(),
|
||||
no_early_reject: false,
|
||||
},
|
||||
PrioritizationStrategy::GasPriceOnly,
|
||||
);
|
||||
@@ -890,6 +894,7 @@ fn should_include_local_transaction_to_a_full_pool() {
|
||||
minimal_gas_price: 1.into(),
|
||||
block_gas_limit: 1_000_000.into(),
|
||||
tx_gas_limit: 1_000_000.into(),
|
||||
no_early_reject: false,
|
||||
},
|
||||
PrioritizationStrategy::GasPriceOnly,
|
||||
);
|
||||
@@ -921,6 +926,7 @@ fn should_avoid_verifying_transaction_already_in_pool() {
|
||||
minimal_gas_price: 1.into(),
|
||||
block_gas_limit: 1_000_000.into(),
|
||||
tx_gas_limit: 1_000_000.into(),
|
||||
no_early_reject: false,
|
||||
},
|
||||
PrioritizationStrategy::GasPriceOnly,
|
||||
);
|
||||
@@ -955,6 +961,7 @@ fn should_avoid_reverifying_recently_rejected_transactions() {
|
||||
minimal_gas_price: 1.into(),
|
||||
block_gas_limit: 1_000_000.into(),
|
||||
tx_gas_limit: 1_000_000.into(),
|
||||
no_early_reject: false,
|
||||
},
|
||||
PrioritizationStrategy::GasPriceOnly,
|
||||
);
|
||||
@@ -996,6 +1003,7 @@ fn should_reject_early_in_case_gas_price_is_less_than_min_effective() {
|
||||
minimal_gas_price: 1.into(),
|
||||
block_gas_limit: 1_000_000.into(),
|
||||
tx_gas_limit: 1_000_000.into(),
|
||||
no_early_reject: false,
|
||||
},
|
||||
PrioritizationStrategy::GasPriceOnly,
|
||||
);
|
||||
@@ -1020,3 +1028,42 @@ fn should_reject_early_in_case_gas_price_is_less_than_min_effective() {
|
||||
// then
|
||||
assert_eq!(txq.status().status.transaction_count, 1);
|
||||
}
|
||||
|
||||
|
||||
#[test]
|
||||
fn should_not_reject_early_in_case_gas_price_is_less_than_min_effective() {
|
||||
// given
|
||||
let txq = TransactionQueue::new(
|
||||
txpool::Options {
|
||||
max_count: 1,
|
||||
max_per_sender: 2,
|
||||
max_mem_usage: 50
|
||||
},
|
||||
verifier::Options {
|
||||
minimal_gas_price: 1.into(),
|
||||
block_gas_limit: 1_000_000.into(),
|
||||
tx_gas_limit: 1_000_000.into(),
|
||||
no_early_reject: true,
|
||||
},
|
||||
PrioritizationStrategy::GasPriceOnly,
|
||||
);
|
||||
// when
|
||||
let tx1 = Tx::gas_price(2).signed();
|
||||
let client = TestClient::new().with_local(&tx1.sender());
|
||||
let res = txq.import(client.clone(), vec![tx1.unverified()]);
|
||||
|
||||
// then
|
||||
assert_eq!(res, vec![Ok(())]);
|
||||
assert_eq!(txq.status().status.transaction_count, 1);
|
||||
assert!(client.was_verification_triggered());
|
||||
|
||||
// when
|
||||
let tx1 = Tx::gas_price(1).signed();
|
||||
let client = TestClient::new().with_local(&tx1.sender());
|
||||
let res = txq.import(client.clone(), vec![tx1.unverified()]);
|
||||
|
||||
// then
|
||||
assert_eq!(res, vec![Ok(())]);
|
||||
assert_eq!(txq.status().status.transaction_count, 2);
|
||||
assert!(client.was_verification_triggered());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user