Minimal Transaction Pool (#1067)

* verify a tx like we verify a block (experimental)

* first minimal_pool test up and running but not testing what we need to

* rework tx_pool validation to use txhashset extension

* minimal tx pool wired up but rough

* works locally (rough statew though)
delete "legacy" pool and graph code

* rework the new pool into TransactionPool and Pool impls

* rework pool to store pool entries
with associated timer and source etc.

* all_transactions

* extra_txs so we can validate stempool against existing txpool

* rework reconcile_block

* txhashset apply_raw_tx can now rewind to a checkpoint (prev raw tx)

* wip - txhashset tx tests

* more flexible rewind on MMRs

* add tests to cover apply_raw_txs on txhashset extension

* add_to_stempool and add_to_txpool

* deaggregate multi kernel tx when adding to txpoool

* handle freshness in stempool
handle propagation of stempool txs via dandelion monitor

* patience timer and fluff if we cannot propagate
to next relay

* aggregate and fluff stempool is we have no relay

* refactor coinbase maturity

* rewrote basic tx pool tests to use a real txhashset via chain adapter

* rework dandelion monitor to reflect recent discussion
works locally but needs a cleanup

* refactor dandelion_monitor - split out phases

* more pool test coverage

* remove old test code from pool (still wip)

* block_building and block_reconciliation tests

* tracked down chain test failure...

* fix test_coinbase_maturity

* dandelion_monitor now runs...

* refactor dandelion config, shared across p2p and pool components

* fix pool tests with new config

* fix p2p tests

* rework tx pool to deal with duplicate commitments (testnet2 limitation)

* cleanup and address some PR feedback

* add big comment about pre_tx...
This commit is contained in:
Antioch Peverell
2018-05-30 16:57:13 -04:00
committed by GitHub
parent b6c31ebc78
commit 4fda7a6899
61 changed files with 2265 additions and 3569 deletions
+9 -22
View File
@@ -614,10 +614,9 @@ where
fn handle(&self, _req: &mut Request) -> IronResult<Response> {
let pool_arc = w(&self.tx_pool);
let pool = pool_arc.read().unwrap();
json_response(&PoolInfo {
pool_size: pool.pool_size(),
orphans_size: pool.orphans_size(),
total_size: pool.total_size(),
pool_size: pool.total_size(),
})
}
}
@@ -628,10 +627,8 @@ struct TxWrapper {
tx_hex: String,
}
// Push new transactions to our stem transaction pool, that should broadcast it
// to the network if valid.
// Push new transaction to our local transaction pool.
struct PoolPushHandler<T> {
peers: Weak<p2p::Peers>,
tx_pool: Weak<RwLock<pool::TransactionPool<T>>>,
}
@@ -667,21 +664,12 @@ where
}
}
// Will not do a stem transaction if our dandelion peer relay is empty
if !fluff && w(&self.peers).get_dandelion_relay().is_empty() {
debug!(
LOGGER,
"Missing Dandelion relay: will push stem transaction normally"
);
fluff = true;
}
// Push into the pool or stempool
let pool_arc = w(&self.tx_pool);
let res = pool_arc
.write()
.unwrap()
.add_to_memory_pool(source, tx, !fluff);
// Push to tx pool.
let res = {
let pool_arc = w(&self.tx_pool);
let mut tx_pool = pool_arc.write().unwrap();
tx_pool.add_to_pool(source, tx, !fluff)
};
match res {
Ok(()) => Ok(Response::with(status::Ok)),
@@ -764,7 +752,6 @@ pub fn start_rest_apis<T>(
tx_pool: tx_pool.clone(),
};
let pool_push_handler = PoolPushHandler {
peers: peers.clone(),
tx_pool: tx_pool.clone(),
};
let peers_all_handler = PeersAllHandler {
+8 -12
View File
@@ -14,23 +14,23 @@
use std::sync::Arc;
use core::{core, ser};
use chain;
use core::core::hash::Hashed;
use core::core::pmmr::MerkleProof;
use chain;
use core::{core, ser};
use p2p;
use serde;
use serde::de::MapAccess;
use serde::ser::SerializeStruct;
use std::fmt;
use util;
use util::secp::pedersen;
use serde;
use serde::ser::SerializeStruct;
use serde::de::MapAccess;
use std::fmt;
macro_rules! no_dup {
($field: ident) => {
($field:ident) => {
if $field.is_some() {
return Err(serde::de::Error::duplicate_field("$field"));
}
}
};
}
@@ -616,10 +616,6 @@ pub struct OutputListing {
pub struct PoolInfo {
/// Size of the pool
pub pool_size: usize,
/// Size of orphans
pub orphans_size: usize,
/// Total size of pool + orphans
pub total_size: usize,
}
#[cfg(test)]