Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
MallocSizeOf impl on transaction pool broke stuff because wasm_timer:…
Browse files Browse the repository at this point in the history
…:Instant doesnt impl it so just revert the transaction pool to master
  • Loading branch information
expenses committed Feb 7, 2020
1 parent ad1dfb1 commit baa4ffc
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 23 deletions.
3 changes: 1 addition & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions client/informant/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ sc-network = { version = "0.8", path = "../network" }
sc-service = { version = "0.8", default-features = false, path = "../service" }
sp-blockchain = { version = "2.0.0", path = "../../primitives/blockchain" }
sp-runtime = { version = "2.0.0", path = "../../primitives/runtime" }
parity-util-mem = { version = "0.5.1", default-features = false, features = ["primitive-types"] }
1 change: 0 additions & 1 deletion client/transaction-pool/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ futures = { version = "0.3.1", features = ["compat"] }
futures-diagnose = "1.0"
log = "0.4.8"
parking_lot = "0.10.0"
wasm-timer = "0.2"
sp-core = { version = "2.0.0", path = "../../primitives/core" }
sp-api = { version = "2.0.0", path = "../../primitives/api" }
sp-runtime = { version = "2.0.0", path = "../../primitives/runtime" }
Expand Down
1 change: 0 additions & 1 deletion client/transaction-pool/graph/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ futures = "0.3.1"
log = "0.4.8"
parking_lot = "0.10.0"
serde = { version = "1.0.101", features = ["derive"] }
wasm-timer = "0.2"
sp-core = { version = "2.0.0", path = "../../../primitives/core" }
sp-runtime = { version = "2.0.0", path = "../../../primitives/runtime" }
sp-transaction-pool = { version = "2.0.0", path = "../../../primitives/transaction-pool" }
Expand Down
6 changes: 3 additions & 3 deletions client/transaction-pool/graph/src/future.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ use std::{
fmt,
hash,
sync::Arc,
time,
};

use sp_core::hexdisplay::HexDisplay;
use sp_runtime::transaction_validity::{
TransactionTag as Tag,
};
use wasm_timer::Instant;

use crate::base_pool::Transaction;

Expand All @@ -37,7 +37,7 @@ pub struct WaitingTransaction<Hash, Ex> {
/// Tags that are required and have not been satisfied yet by other transactions in the pool.
pub missing_tags: HashSet<Tag>,
/// Time of import to the Future Queue.
pub imported_at: Instant,
pub imported_at: time::Instant,
}

impl<Hash: fmt::Debug, Ex: fmt::Debug> fmt::Debug for WaitingTransaction<Hash, Ex> {
Expand Down Expand Up @@ -91,7 +91,7 @@ impl<Hash, Ex> WaitingTransaction<Hash, Ex> {
WaitingTransaction {
transaction: Arc::new(transaction),
missing_tags,
imported_at: Instant::now(),
imported_at: time::Instant::now(),
}
}

Expand Down
10 changes: 6 additions & 4 deletions client/transaction-pool/graph/src/pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ use sp_runtime::{
transaction_validity::{TransactionValidity, TransactionTag as Tag, TransactionValidityError},
};
use sp_transaction_pool::{error, PoolStatus};
use wasm_timer::Instant;

use crate::validated_pool::{ValidatedPool, ValidatedTransaction};

Expand Down Expand Up @@ -190,6 +189,7 @@ impl<B: ChainApi> Pool<B> {
at: &BlockId<B::Block>,
max: Option<usize>,
) -> Result<(), B::Error> {
use std::time::Instant;
log::debug!(target: "txpool",
"Fetching ready transactions (up to: {})",
max.map(|x| format!("{}", x)).unwrap_or_else(|| "all".into())
Expand Down Expand Up @@ -317,7 +317,7 @@ impl<B: ChainApi> Pool<B> {
// Make sure that we don't revalidate extrinsics that were part of the recently
// imported block. This is especially important for UTXO-like chains cause the
// inputs are pruned so such transaction would go to future again.
self.validated_pool.ban(&Instant::now(), known_imported_hashes.clone().into_iter());
self.validated_pool.ban(&std::time::Instant::now(), known_imported_hashes.clone().into_iter());

// Try to re-validate pruned transactions since some of them might be still valid.
// note that `known_imported_hashes` will be rejected here due to temporary ban.
Expand Down Expand Up @@ -469,7 +469,10 @@ impl<B: ChainApi> Clone for Pool<B> {

#[cfg(test)]
mod tests {
use std::collections::{HashMap, HashSet};
use std::{
collections::{HashMap, HashSet},
time::Instant,
};
use parking_lot::Mutex;
use futures::executor::block_on;
use super::*;
Expand All @@ -478,7 +481,6 @@ mod tests {
use codec::Encode;
use substrate_test_runtime::{Block, Extrinsic, Transfer, H256, AccountId};
use assert_matches::assert_matches;
use wasm_timer::Instant;
use crate::base_pool::Limit;

const INVALID_NONCE: u64 = 254;
Expand Down
3 changes: 1 addition & 2 deletions client/transaction-pool/graph/src/rotator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,9 @@ use std::{
collections::HashMap,
hash,
iter,
time::Duration,
time::{Duration, Instant},
};
use parking_lot::RwLock;
use wasm_timer::Instant;

use crate::base_pool::Transaction;

Expand Down
14 changes: 7 additions & 7 deletions client/transaction-pool/graph/src/validated_pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use std::{
fmt,
hash,
sync::Arc,
time,
};

use crate::base_pool as base;
Expand All @@ -36,7 +37,6 @@ use sp_runtime::{
transaction_validity::TransactionTag as Tag,
};
use sp_transaction_pool::{error, PoolStatus};
use wasm_timer::Instant;

use crate::base_pool::PruneStatus;
use crate::pool::{EventStream, Options, ChainApi, BlockHash, ExHash, ExtrinsicFor, TransactionFor};
Expand Down Expand Up @@ -100,7 +100,7 @@ impl<B: ChainApi> ValidatedPool<B> {
}

/// Bans given set of hashes.
pub fn ban(&self, now: &Instant, hashes: impl IntoIterator<Item=ExHash<B>>) {
pub fn ban(&self, now: &std::time::Instant, hashes: impl IntoIterator<Item=ExHash<B>>) {
self.rotator.ban(now, hashes)
}

Expand Down Expand Up @@ -145,7 +145,7 @@ impl<B: ChainApi> ValidatedPool<B> {
Ok(imported.hash().clone())
}
ValidatedTransaction::Invalid(hash, err) => {
self.rotator.ban(&Instant::now(), std::iter::once(hash));
self.rotator.ban(&std::time::Instant::now(), std::iter::once(hash));
Err(err.into())
},
ValidatedTransaction::Unknown(hash, err) => {
Expand Down Expand Up @@ -177,7 +177,7 @@ impl<B: ChainApi> ValidatedPool<B> {
let removed = pool.enforce_limits(ready_limit, future_limit)
.into_iter().map(|x| x.hash.clone()).collect::<HashSet<_>>();
// ban all removed transactions
self.rotator.ban(&Instant::now(), removed.iter().map(|x| x.clone()));
self.rotator.ban(&std::time::Instant::now(), removed.iter().map(|x| x.clone()));
removed
};
// run notifications
Expand Down Expand Up @@ -208,7 +208,7 @@ impl<B: ChainApi> ValidatedPool<B> {
.map(|_| watcher)
},
ValidatedTransaction::Invalid(hash, err) => {
self.rotator.ban(&Instant::now(), std::iter::once(hash));
self.rotator.ban(&std::time::Instant::now(), std::iter::once(hash));
Err(err.into())
},
ValidatedTransaction::Unknown(_, err) => Err(err.into()),
Expand Down Expand Up @@ -430,7 +430,7 @@ impl<B: ChainApi> ValidatedPool<B> {
let block_number = self.api.block_id_to_number(at)?
.ok_or_else(|| error::Error::InvalidBlockId(format!("{:?}", at)).into())?
.saturated_into::<u64>();
let now = Instant::now();
let now = time::Instant::now();
let to_remove = {
self.ready()
.filter(|tx| self.rotator.ban_if_stale(&now, block_number, &tx))
Expand Down Expand Up @@ -497,7 +497,7 @@ impl<B: ChainApi> ValidatedPool<B> {
debug!(target: "txpool", "Removing invalid transactions: {:?}", hashes);

// temporarily ban invalid transactions
self.rotator.ban(&Instant::now(), hashes.iter().cloned());
self.rotator.ban(&time::Instant::now(), hashes.iter().cloned());

let invalid = self.pool.write().remove_subtree(hashes);

Expand Down
5 changes: 2 additions & 3 deletions client/transaction-pool/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub mod testing;
pub use sc_transaction_graph as txpool;
pub use crate::api::{FullChainApi, LightChainApi};

use std::{collections::HashMap, sync::Arc, pin::Pin};
use std::{collections::HashMap, sync::Arc, pin::Pin, time::Instant};
use futures::{Future, FutureExt, future::ready};
use parking_lot::Mutex;

Expand All @@ -41,7 +41,6 @@ use sp_transaction_pool::{
TxHash, TransactionFor, TransactionStatusStreamFor, BlockHash,
MaintainedTransactionPool, PoolFuture,
};
use wasm_timer::Instant;

/// Basic implementation of transaction pool that can be customized by providing PoolApi.
pub struct BasicPool<PoolApi, Block>
Expand Down Expand Up @@ -206,7 +205,7 @@ enum RevalidationStatus<N> {
/// The revalidation has never been completed.
NotScheduled,
/// The revalidation is scheduled.
Scheduled(Option<Instant>, Option<N>),
Scheduled(Option<std::time::Instant>, Option<N>),
/// The revalidation is in progress.
InProgress,
}
Expand Down

0 comments on commit baa4ffc

Please sign in to comment.