Fixed tx queue limit for local transactions (#2616)
* Fixed tx queue limit for local tx * Fixing test * Increas gas limit to 20x
This commit is contained in:
parent
dbc25cf4e7
commit
f9440f20b8
@ -462,8 +462,8 @@ impl Miner {
|
|||||||
let mut queue = self.transaction_queue.lock();
|
let mut queue = self.transaction_queue.lock();
|
||||||
queue.set_gas_limit(gas_limit);
|
queue.set_gas_limit(gas_limit);
|
||||||
if let GasLimit::Auto = self.options.tx_queue_gas_limit {
|
if let GasLimit::Auto = self.options.tx_queue_gas_limit {
|
||||||
// Set total tx queue gas limit to be 2x the block gas limit.
|
// Set total tx queue gas limit to be 20x the block gas limit.
|
||||||
queue.set_total_gas_limit(gas_limit << 1);
|
queue.set_total_gas_limit(gas_limit * 20.into());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -326,14 +326,14 @@ impl TransactionSet {
|
|||||||
let to_drop : Vec<(Address, U256)> = {
|
let to_drop : Vec<(Address, U256)> = {
|
||||||
self.by_priority
|
self.by_priority
|
||||||
.iter()
|
.iter()
|
||||||
.skip_while(|order| {
|
.filter(|order| {
|
||||||
count = count + 1;
|
count = count + 1;
|
||||||
let r = gas.overflowing_add(order.gas);
|
let r = gas.overflowing_add(order.gas);
|
||||||
if r.1 { return false }
|
if r.1 { return false }
|
||||||
gas = r.0;
|
gas = r.0;
|
||||||
// Own and retracted transactions are allowed to go above the gas limit, bot not above the count limit.
|
// Own and retracted transactions are allowed to go above the gas limit, bot not above the count limit.
|
||||||
(gas <= self.gas_limit || order.origin == TransactionOrigin::Local || order.origin == TransactionOrigin::RetractedBlock) &&
|
(gas > self.gas_limit && order.origin != TransactionOrigin::Local && order.origin != TransactionOrigin::RetractedBlock) ||
|
||||||
count <= self.limit
|
count > self.limit
|
||||||
})
|
})
|
||||||
.map(|order| by_hash.get(&order.hash)
|
.map(|order| by_hash.get(&order.hash)
|
||||||
.expect("All transactions in `self.by_priority` and `self.by_address` are kept in sync with `by_hash`."))
|
.expect("All transactions in `self.by_priority` and `self.by_address` are kept in sync with `by_hash`."))
|
||||||
@ -345,6 +345,7 @@ impl TransactionSet {
|
|||||||
.fold(HashMap::new(), |mut removed, (sender, nonce)| {
|
.fold(HashMap::new(), |mut removed, (sender, nonce)| {
|
||||||
let order = self.drop(&sender, &nonce)
|
let order = self.drop(&sender, &nonce)
|
||||||
.expect("Transaction has just been found in `by_priority`; so it is in `by_address` also.");
|
.expect("Transaction has just been found in `by_priority`; so it is in `by_address` also.");
|
||||||
|
trace!(target: "txqueue", "Dropped out of limit transaction: {:?}", order.hash);
|
||||||
|
|
||||||
by_hash.remove(&order.hash)
|
by_hash.remove(&order.hash)
|
||||||
.expect("hash is in `by_priorty`; all hashes in `by_priority` must be in `by_hash`; qed");
|
.expect("hash is in `by_priorty`; all hashes in `by_priority` must be in `by_hash`; qed");
|
||||||
@ -1782,8 +1783,12 @@ mod test {
|
|||||||
let mut txq = TransactionQueue::with_limits(100, default_gas_val() * U256::from(2), !U256::zero());
|
let mut txq = TransactionQueue::with_limits(100, default_gas_val() * U256::from(2), !U256::zero());
|
||||||
let (tx1, tx2) = new_tx_pair_default(U256::from(1), U256::from(1));
|
let (tx1, tx2) = new_tx_pair_default(U256::from(1), U256::from(1));
|
||||||
let (tx3, tx4) = new_tx_pair_default(U256::from(1), U256::from(2));
|
let (tx3, tx4) = new_tx_pair_default(U256::from(1), U256::from(2));
|
||||||
|
let (tx5, tx6) = new_tx_pair_default(U256::from(1), U256::from(2));
|
||||||
txq.add(tx1.clone(), &default_account_details, TransactionOrigin::Local).unwrap();
|
txq.add(tx1.clone(), &default_account_details, TransactionOrigin::Local).unwrap();
|
||||||
txq.add(tx2.clone(), &default_account_details, TransactionOrigin::Local).unwrap();
|
txq.add(tx2.clone(), &default_account_details, TransactionOrigin::Local).unwrap();
|
||||||
|
txq.add(tx5.clone(), &default_account_details, TransactionOrigin::External).unwrap();
|
||||||
|
// Not accepted because of limit
|
||||||
|
txq.add(tx6.clone(), &default_account_details, TransactionOrigin::External).unwrap_err();
|
||||||
txq.add(tx3.clone(), &default_account_details, TransactionOrigin::Local).unwrap();
|
txq.add(tx3.clone(), &default_account_details, TransactionOrigin::Local).unwrap();
|
||||||
txq.add(tx4.clone(), &default_account_details, TransactionOrigin::Local).unwrap();
|
txq.add(tx4.clone(), &default_account_details, TransactionOrigin::Local).unwrap();
|
||||||
assert_eq!(txq.status().pending, 4);
|
assert_eq!(txq.status().pending, 4);
|
||||||
|
@ -186,7 +186,7 @@ Sealing/Mining Options:
|
|||||||
to be included in next block) (default: {flag_tx_queue_size}).
|
to be included in next block) (default: {flag_tx_queue_size}).
|
||||||
--tx-queue-gas LIMIT Maximum amount of total gas for external transactions in
|
--tx-queue-gas LIMIT Maximum amount of total gas for external transactions in
|
||||||
the queue. LIMIT can be either an amount of gas or
|
the queue. LIMIT can be either an amount of gas or
|
||||||
'auto' or 'off'. 'auto' sets the limit to be 2x
|
'auto' or 'off'. 'auto' sets the limit to be 20x
|
||||||
the current block gas limit. (default: {flag_tx_queue_gas}).
|
the current block gas limit. (default: {flag_tx_queue_gas}).
|
||||||
--remove-solved Move solved blocks from the work package queue
|
--remove-solved Move solved blocks from the work package queue
|
||||||
instead of cloning them. This gives a slightly
|
instead of cloning them. This gives a slightly
|
||||||
|
Loading…
Reference in New Issue
Block a user