New Transaction Queue implementation (#8074)
* Implementation of Verifier, Scoring and Ready. * Queue in progress. * TransactionPool. * Prepare for txpool release. * Miner refactor [WiP] * WiP reworking miner. * Make it compile. * Add some docs. * Split blockchain access to a separate file. * Work on miner API. * Fix ethcore tests. * Refactor miner interface for sealing/work packages. * Implement next nonce. * RPC compiles. * Implement couple of missing methdods for RPC. * Add transaction queue listeners. * Compiles! * Clean-up and parallelize. * Get rid of RefCell in header. * Revert "Get rid of RefCell in header." This reverts commit 0f2424c9b7319a786e1565ea2a8a6d801a21b4fb. * Override Sync requirement. * Fix status display. * Unify logging. * Extract some cheap checks. * Measurements and optimizations. * Fix scoring bug, heap size of bug and add cache * Disable tx queueing and parallel verification. * Make ethcore and ethcore-miner compile again. * Make RPC compile again. * Bunch of txpool tests. * Migrate transaction queue tests. * Nonce Cap * Nonce cap cache and tests. * Remove stale future transactions from the queue. * Optimize scoring and write some tests. * Simple penalization. * Clean up and support for different scoring algorithms. * Add CLI parameters for the new queue. * Remove banning queue. * Disable debug build. * Change per_sender limit to be 1% instead of 5% * Avoid cloning when propagating transactions. * Remove old todo. * Post-review fixes. * Fix miner options default. * Implement back ready transactions for light client. * Get rid of from_pending_block * Pass rejection reason. * Add more details to drop. * Rollback heap size of. * Avoid cloning hashes when propagating and include more details on rejection. * Fix tests. * Introduce nonces cache. * Remove uneccessary hashes allocation. * Lower the mem limit. * Re-enable parallel verification. * Add miner log. Don't check the type if not below min_gas_price. * Add more traces, fix disabling miner. * Fix creating pending blocks twice on AuRa authorities. * Fix tests. * re-use pending blocks in AuRa * Use reseal_min_period to prevent too frequent update_sealing. * Fix log to contain hash not sender. * Optimize local transactions. * Fix aura tests. * Update locks comments. * Get rid of unsafe Sync impl. * Review fixes. * Remove excessive matches. * Fix compilation errors. * Use new pool in private transactions. * Fix private-tx test. * Fix secret store tests. * Actually use gas_floor_target * Fix config tests. * Fix pool tests. * Address grumbles.
This commit is contained in:
committed by
Marek Kotewicz
parent
03b96a7c0a
commit
1cd93e4ceb
@@ -337,8 +337,33 @@ impl<'x> OpenBlock<'x> {
|
||||
}
|
||||
|
||||
/// Push transactions onto the block.
|
||||
pub fn push_transactions(&mut self, transactions: &[SignedTransaction]) -> Result<(), Error> {
|
||||
push_transactions(self, transactions)
|
||||
#[cfg(not(feature = "slow-blocks"))]
|
||||
fn push_transactions(&mut self, transactions: Vec<SignedTransaction>) -> Result<(), Error> {
|
||||
for t in transactions {
|
||||
self.push_transaction(t, None)?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Push transactions onto the block.
|
||||
#[cfg(feature = "slow-blocks")]
|
||||
fn push_transactions(&mut self, transactions: Vec<SignedTransaction>) -> Result<(), Error> {
|
||||
use std::time;
|
||||
|
||||
let slow_tx = option_env!("SLOW_TX_DURATION").and_then(|v| v.parse().ok()).unwrap_or(100);
|
||||
for t in transactions {
|
||||
let hash = t.hash();
|
||||
let start = time::Instant::now();
|
||||
self.push_transaction(t, None)?;
|
||||
let took = start.elapsed();
|
||||
let took_ms = took.as_secs() * 1000 + took.subsec_nanos() as u64 / 1000000;
|
||||
if took > time::Duration::from_millis(slow_tx) {
|
||||
warn!("Heavy ({} ms) transaction in block {:?}: {:?}", took_ms, block.header().number(), hash);
|
||||
}
|
||||
debug!(target: "tx", "Transaction {:?} took: {} ms", hash, took_ms);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Populate self from a header.
|
||||
@@ -534,10 +559,10 @@ impl IsBlock for SealedBlock {
|
||||
}
|
||||
|
||||
/// Enact the block given by block header, transactions and uncles
|
||||
pub fn enact(
|
||||
header: &Header,
|
||||
transactions: &[SignedTransaction],
|
||||
uncles: &[Header],
|
||||
fn enact(
|
||||
header: Header,
|
||||
transactions: Vec<SignedTransaction>,
|
||||
uncles: Vec<Header>,
|
||||
engine: &EthEngine,
|
||||
tracing: bool,
|
||||
db: StateDB,
|
||||
@@ -568,11 +593,11 @@ pub fn enact(
|
||||
is_epoch_begin,
|
||||
)?;
|
||||
|
||||
b.populate_from(header);
|
||||
b.populate_from(&header);
|
||||
b.push_transactions(transactions)?;
|
||||
|
||||
for u in uncles {
|
||||
b.push_uncle(u.clone())?;
|
||||
b.push_uncle(u)?;
|
||||
}
|
||||
|
||||
if strip_receipts {
|
||||
@@ -584,38 +609,9 @@ pub fn enact(
|
||||
Ok(b.close_and_lock())
|
||||
}
|
||||
|
||||
#[inline]
|
||||
#[cfg(not(feature = "slow-blocks"))]
|
||||
fn push_transactions(block: &mut OpenBlock, transactions: &[SignedTransaction]) -> Result<(), Error> {
|
||||
for t in transactions {
|
||||
block.push_transaction(t.clone(), None)?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(feature = "slow-blocks")]
|
||||
fn push_transactions(block: &mut OpenBlock, transactions: &[SignedTransaction]) -> Result<(), Error> {
|
||||
use std::time;
|
||||
|
||||
let slow_tx = option_env!("SLOW_TX_DURATION").and_then(|v| v.parse().ok()).unwrap_or(100);
|
||||
for t in transactions {
|
||||
let hash = t.hash();
|
||||
let start = time::Instant::now();
|
||||
block.push_transaction(t.clone(), None)?;
|
||||
let took = start.elapsed();
|
||||
let took_ms = took.as_secs() * 1000 + took.subsec_nanos() as u64 / 1000000;
|
||||
if took > time::Duration::from_millis(slow_tx) {
|
||||
warn!("Heavy ({} ms) transaction in block {:?}: {:?}", took_ms, block.header().number(), hash);
|
||||
}
|
||||
debug!(target: "tx", "Transaction {:?} took: {} ms", hash, took_ms);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
// TODO [ToDr] Pass `PreverifiedBlock` by move, this will avoid unecessary allocation
|
||||
/// Enact the block given by `block_bytes` using `engine` on the database `db` with given `parent` block header
|
||||
pub fn enact_verified(
|
||||
block: &PreverifiedBlock,
|
||||
block: PreverifiedBlock,
|
||||
engine: &EthEngine,
|
||||
tracing: bool,
|
||||
db: StateDB,
|
||||
@@ -629,9 +625,9 @@ pub fn enact_verified(
|
||||
let view = BlockView::new(&block.bytes);
|
||||
|
||||
enact(
|
||||
&block.header,
|
||||
&block.transactions,
|
||||
&view.uncles(),
|
||||
block.header,
|
||||
block.transactions,
|
||||
view.uncles(),
|
||||
engine,
|
||||
tracing,
|
||||
db,
|
||||
@@ -700,7 +696,7 @@ mod tests {
|
||||
)?;
|
||||
|
||||
b.populate_from(&header);
|
||||
b.push_transactions(&transactions)?;
|
||||
b.push_transactions(transactions)?;
|
||||
|
||||
for u in &block.uncles() {
|
||||
b.push_uncle(u.clone())?;
|
||||
@@ -793,3 +789,4 @@ mod tests {
|
||||
assert!(orig_db.journal_db().keys().iter().filter(|k| orig_db.journal_db().get(k.0) != db.journal_db().get(k.0)).next() == None);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user