Recently rejected cache for transaction queue (#9005)

* Store recently rejected transactions.

* Don't cache AlreadyImported rejections.

* Make the size of transaction verification queue dependent on pool size.

* Add a test for recently rejected.

* Fix logging for recently rejected.

* Make rejection cache smaller.

* obsolete test removed

* obsolete test removed

* Construct cache with_capacity.
This commit is contained in:
Tomasz Drwięga
2018-07-02 19:00:06 +02:00
committed by André Silva
parent 9caa868603
commit 78e001284f
11 changed files with 167 additions and 58 deletions

View File

@@ -87,7 +87,6 @@ pub use verification::queue::QueueInfo as BlockQueueInfo;
use_contract!(registry, "Registry", "res/contracts/registrar.json");
const MAX_TX_QUEUE_SIZE: usize = 4096;
const MAX_ANCIENT_BLOCKS_QUEUE_SIZE: usize = 4096;
// Max number of blocks imported at once.
const MAX_ANCIENT_BLOCKS_TO_IMPORT: usize = 4;
@@ -760,13 +759,12 @@ impl Client {
tracedb: tracedb,
engine: engine,
pruning: config.pruning.clone(),
config: config,
db: RwLock::new(db.clone()),
state_db: RwLock::new(state_db),
report: RwLock::new(Default::default()),
io_channel: Mutex::new(message_channel),
notify: RwLock::new(Vec::new()),
queue_transactions: IoChannelQueue::new(MAX_TX_QUEUE_SIZE),
queue_transactions: IoChannelQueue::new(config.transaction_verification_queue_size),
queue_ancient_blocks: IoChannelQueue::new(MAX_ANCIENT_BLOCKS_QUEUE_SIZE),
queued_ancient_blocks: Default::default(),
ancient_blocks_import_lock: Default::default(),
@@ -779,6 +777,7 @@ impl Client {
registrar_address,
exit_handler: Mutex::new(None),
importer,
config,
});
// prune old states.

View File

@@ -70,12 +70,6 @@ pub enum Mode {
Off,
}
impl Default for Mode {
fn default() -> Self {
Mode::Active
}
}
impl Display for Mode {
fn fmt(&self, f: &mut Formatter) -> Result<(), FmtError> {
match *self {
@@ -88,7 +82,7 @@ impl Display for Mode {
}
/// Client configuration. Includes configs for all sub-systems.
#[derive(Debug, PartialEq, Default, Clone)]
#[derive(Debug, PartialEq, Clone)]
pub struct ClientConfig {
/// Block queue configuration.
pub queue: QueueConfig,
@@ -126,8 +120,36 @@ pub struct ClientConfig {
pub history_mem: usize,
/// Check seal valididity on block import
pub check_seal: bool,
/// Maximal number of transactions queued for verification in a separate thread.
pub transaction_verification_queue_size: usize,
}
impl Default for ClientConfig {
fn default() -> Self {
let mb = 1024 * 1024;
ClientConfig {
queue: Default::default(),
blockchain: Default::default(),
tracing: Default::default(),
vm_type: Default::default(),
fat_db: false,
pruning: journaldb::Algorithm::OverlayRecent,
name: "default".into(),
db_cache_size: None,
db_compaction: Default::default(),
db_wal: true,
mode: Mode::Active,
spec_name: "".into(),
verifier_type: VerifierType::Canon,
state_cache_size: 1 * mb,
jump_table_size: 1 * mb,
history: 64,
history_mem: 32 * mb,
check_seal: true,
transaction_verification_queue_size: 8192,
}
}
}
#[cfg(test)]
mod test {
use super::{DatabaseCompactionProfile, Mode};
@@ -143,9 +165,4 @@ mod test {
assert_eq!(DatabaseCompactionProfile::SSD, "ssd".parse().unwrap());
assert_eq!(DatabaseCompactionProfile::HDD, "hdd".parse().unwrap());
}
#[test]
fn test_mode_default() {
assert_eq!(Mode::default(), Mode::Active);
}
}

View File

@@ -42,12 +42,6 @@ pub enum VerifierType {
Noop,
}
impl Default for VerifierType {
fn default() -> Self {
VerifierType::Canon
}
}
/// Create a new verifier based on type.
pub fn new<C: BlockInfo + CallContract>(v: VerifierType) -> Box<Verifier<C>> {
match v {