Skip to content
This repository was archived by the owner on Nov 6, 2020. It is now read-only.

Commit 6f48370

Browse files
committed
Merge branch 'master' into refactor/hashdb-generic
* master: Fix subcrate test compile (#8862) network-devp2p: downgrade logging to debug, add target (#8784) Clearing up a comment about the prefix for signing (#8828) Disable parallel verification and skip verifiying already imported txs. (#8834) devp2p: Move UDP socket handling from Discovery to Host. (#8790) Fixed AuthorityRound deadlock on shutdown, closes #8088 (#8803) Specify critical release flag per network (#8821) Fix `deadlock_detection` feature branch compilation (#8824) Use system allocator when profiling memory (#8831) added from and to to Receipt (#8756)
2 parents 494e58f + 09ee6e1 commit 6f48370

File tree

26 files changed

+301
-166
lines changed

26 files changed

+301
-166
lines changed

Cargo.lock

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,13 @@ slow-blocks = ["ethcore/slow-blocks"]
9898
secretstore = ["ethcore-secretstore"]
9999
final = ["parity-version/final"]
100100
deadlock_detection = ["parking_lot/deadlock_detection"]
101+
# to create a memory profile (requires nightly rust), use e.g.
102+
# `heaptrack /path/to/parity <parity params>`,
103+
# to visualize a memory profile, use `heaptrack_gui`
104+
# or
105+
# `valgrind --tool=massif /path/to/parity <parity params>`
106+
# and `massif-visualizer` for visualization
107+
memory_profiling = []
101108

102109
[lib]
103110
path = "parity/lib.rs"

ethcore/light/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ memory-cache = { path = "../../util/memory_cache" }
3838
error-chain = { version = "0.11", default-features = false }
3939

4040
[dev-dependencies]
41+
ethcore = { path = "..", features = ["test-helpers"] }
4142
kvdb-memorydb = { path = "../../util/kvdb-memorydb" }
4243
tempdir = "0.3"
4344

ethcore/node_filter/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ ethabi-contract = "5.0"
1919
lru-cache = "0.1"
2020

2121
[dev-dependencies]
22+
ethcore = { path = "..", features = ["test-helpers"] }
2223
kvdb-memorydb = { path = "../../util/kvdb-memorydb" }
2324
ethcore-io = { path = "../../util/io" }
2425
tempdir = "0.3"

ethcore/service/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,6 @@ stop-guard = { path = "../../util/stop-guard" }
1616
trace-time = { path = "../../util/trace-time" }
1717

1818
[dev-dependencies]
19+
ethcore = { path = "..", features = ["test-helpers"] }
1920
tempdir = "0.3"
2021
kvdb-rocksdb = { path = "../../util/kvdb-rocksdb" }

ethcore/src/client/client.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2339,6 +2339,11 @@ fn transaction_receipt(machine: &::machine::EthereumMachine, mut tx: LocalizedTr
23392339
let transaction_index = tx.transaction_index;
23402340

23412341
LocalizedReceipt {
2342+
from: sender,
2343+
to: match tx.action {
2344+
Action::Create => None,
2345+
Action::Call(ref address) => Some(address.clone().into())
2346+
},
23422347
transaction_hash: transaction_hash,
23432348
transaction_index: transaction_index,
23442349
block_hash: block_hash,
@@ -2464,6 +2469,11 @@ mod tests {
24642469

24652470
// then
24662471
assert_eq!(receipt, LocalizedReceipt {
2472+
from: tx1.sender().into(),
2473+
to: match tx1.action {
2474+
Action::Create => None,
2475+
Action::Call(ref address) => Some(address.clone().into())
2476+
},
24672477
transaction_hash: tx1.hash(),
24682478
transaction_index: 1,
24692479
block_hash: block_hash,

ethcore/src/engines/authority_round/mod.rs

Lines changed: 51 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -382,12 +382,16 @@ impl Decodable for SealedEmptyStep {
382382
}
383383
}
384384

385+
struct PermissionedStep {
386+
inner: Step,
387+
can_propose: AtomicBool,
388+
}
389+
385390
/// Engine using `AuthorityRound` proof-of-authority BFT consensus.
386391
pub struct AuthorityRound {
387392
transition_service: IoService<()>,
388-
step: Arc<Step>,
389-
can_propose: AtomicBool,
390-
client: RwLock<Option<Weak<EngineClient>>>,
393+
step: Arc<PermissionedStep>,
394+
client: Arc<RwLock<Option<Weak<EngineClient>>>>,
391395
signer: RwLock<EngineSigner>,
392396
validators: Box<ValidatorSet>,
393397
validate_score_transition: u64,
@@ -407,15 +411,15 @@ pub struct AuthorityRound {
407411

408412
// header-chain validator.
409413
struct EpochVerifier {
410-
step: Arc<Step>,
414+
step: Arc<PermissionedStep>,
411415
subchain_validators: SimpleList,
412416
empty_steps_transition: u64,
413417
}
414418

415419
impl super::EpochVerifier<EthereumMachine> for EpochVerifier {
416420
fn verify_light(&self, header: &Header) -> Result<(), Error> {
417421
// Validate the timestamp
418-
verify_timestamp(&*self.step, header_step(header, self.empty_steps_transition)?)?;
422+
verify_timestamp(&self.step.inner, header_step(header, self.empty_steps_transition)?)?;
419423
// always check the seal since it's fast.
420424
// nothing heavier to do.
421425
verify_external(header, &self.subchain_validators, self.empty_steps_transition)
@@ -615,13 +619,15 @@ impl AuthorityRound {
615619
let engine = Arc::new(
616620
AuthorityRound {
617621
transition_service: IoService::<()>::start()?,
618-
step: Arc::new(Step {
619-
inner: AtomicUsize::new(initial_step),
620-
calibrate: our_params.start_step.is_none(),
621-
duration: our_params.step_duration,
622+
step: Arc::new(PermissionedStep {
623+
inner: Step {
624+
inner: AtomicUsize::new(initial_step),
625+
calibrate: our_params.start_step.is_none(),
626+
duration: our_params.step_duration,
627+
},
628+
can_propose: AtomicBool::new(true),
622629
}),
623-
can_propose: AtomicBool::new(true),
624-
client: RwLock::new(None),
630+
client: Arc::new(RwLock::new(None)),
625631
signer: Default::default(),
626632
validators: our_params.validators,
627633
validate_score_transition: our_params.validate_score_transition,
@@ -641,7 +647,10 @@ impl AuthorityRound {
641647

642648
// Do not initialize timeouts for tests.
643649
if should_timeout {
644-
let handler = TransitionHandler { engine: Arc::downgrade(&engine) };
650+
let handler = TransitionHandler {
651+
step: engine.step.clone(),
652+
client: engine.client.clone(),
653+
};
645654
engine.transition_service.register_handler(Arc::new(handler))?;
646655
}
647656
Ok(engine)
@@ -666,7 +675,7 @@ impl AuthorityRound {
666675
}
667676

668677
fn generate_empty_step(&self, parent_hash: &H256) {
669-
let step = self.step.load();
678+
let step = self.step.inner.load();
670679
let empty_step_rlp = empty_step_rlp(step, parent_hash);
671680

672681
if let Ok(signature) = self.sign(keccak(&empty_step_rlp)).map(Into::into) {
@@ -698,34 +707,37 @@ fn unix_now() -> Duration {
698707
}
699708

700709
struct TransitionHandler {
701-
engine: Weak<AuthorityRound>,
710+
step: Arc<PermissionedStep>,
711+
client: Arc<RwLock<Option<Weak<EngineClient>>>>,
702712
}
703713

704714
const ENGINE_TIMEOUT_TOKEN: TimerToken = 23;
705715

706716
impl IoHandler<()> for TransitionHandler {
707717
fn initialize(&self, io: &IoContext<()>) {
708-
if let Some(engine) = self.engine.upgrade() {
709-
let remaining = engine.step.duration_remaining().as_millis();
710-
io.register_timer_once(ENGINE_TIMEOUT_TOKEN, Duration::from_millis(remaining))
711-
.unwrap_or_else(|e| warn!(target: "engine", "Failed to start consensus step timer: {}.", e))
712-
}
718+
let remaining = self.step.inner.duration_remaining().as_millis();
719+
io.register_timer_once(ENGINE_TIMEOUT_TOKEN, Duration::from_millis(remaining))
720+
.unwrap_or_else(|e| warn!(target: "engine", "Failed to start consensus step timer: {}.", e))
713721
}
714722

715723
fn timeout(&self, io: &IoContext<()>, timer: TimerToken) {
716724
if timer == ENGINE_TIMEOUT_TOKEN {
717-
if let Some(engine) = self.engine.upgrade() {
718-
// NOTE we might be lagging by couple of steps in case the timeout
719-
// has not been called fast enough.
720-
// Make sure to advance up to the actual step.
721-
while engine.step.duration_remaining().as_millis() == 0 {
722-
engine.step();
725+
// NOTE we might be lagging by couple of steps in case the timeout
726+
// has not been called fast enough.
727+
// Make sure to advance up to the actual step.
728+
while self.step.inner.duration_remaining().as_millis() == 0 {
729+
self.step.inner.increment();
730+
self.step.can_propose.store(true, AtomicOrdering::SeqCst);
731+
if let Some(ref weak) = *self.client.read() {
732+
if let Some(c) = weak.upgrade() {
733+
c.update_sealing();
734+
}
723735
}
724-
725-
let next_run_at = engine.step.duration_remaining().as_millis() >> 2;
726-
io.register_timer_once(ENGINE_TIMEOUT_TOKEN, Duration::from_millis(next_run_at))
727-
.unwrap_or_else(|e| warn!(target: "engine", "Failed to restart consensus step timer: {}.", e))
728736
}
737+
738+
let next_run_at = self.step.inner.duration_remaining().as_millis() >> 2;
739+
io.register_timer_once(ENGINE_TIMEOUT_TOKEN, Duration::from_millis(next_run_at))
740+
.unwrap_or_else(|e| warn!(target: "engine", "Failed to restart consensus step timer: {}.", e))
729741
}
730742
}
731743
}
@@ -742,8 +754,8 @@ impl Engine<EthereumMachine> for AuthorityRound {
742754
}
743755

744756
fn step(&self) {
745-
self.step.increment();
746-
self.can_propose.store(true, AtomicOrdering::SeqCst);
757+
self.step.inner.increment();
758+
self.step.can_propose.store(true, AtomicOrdering::SeqCst);
747759
if let Some(ref weak) = *self.client.read() {
748760
if let Some(c) = weak.upgrade() {
749761
c.update_sealing();
@@ -790,7 +802,7 @@ impl Engine<EthereumMachine> for AuthorityRound {
790802

791803
fn populate_from_parent(&self, header: &mut Header, parent: &Header) {
792804
let parent_step = header_step(parent, self.empty_steps_transition).expect("Header has been verified; qed");
793-
let current_step = self.step.load();
805+
let current_step = self.step.inner.load();
794806

795807
let current_empty_steps_len = if header.number() >= self.empty_steps_transition {
796808
self.empty_steps(parent_step.into(), current_step.into(), parent.hash()).len()
@@ -816,7 +828,7 @@ impl Engine<EthereumMachine> for AuthorityRound {
816828
let empty_step: EmptyStep = rlp.as_val().map_err(fmt_err)?;;
817829

818830
if empty_step.verify(&*self.validators).unwrap_or(false) {
819-
if self.step.check_future(empty_step.step).is_ok() {
831+
if self.step.inner.check_future(empty_step.step).is_ok() {
820832
trace!(target: "engine", "handle_message: received empty step message {:?}", empty_step);
821833
self.handle_empty_step_message(empty_step);
822834
} else {
@@ -836,7 +848,7 @@ impl Engine<EthereumMachine> for AuthorityRound {
836848
fn generate_seal(&self, block: &ExecutedBlock, parent: &Header) -> Seal {
837849
// first check to avoid generating signature most of the time
838850
// (but there's still a race to the `compare_and_swap`)
839-
if !self.can_propose.load(AtomicOrdering::SeqCst) {
851+
if !self.step.can_propose.load(AtomicOrdering::SeqCst) {
840852
trace!(target: "engine", "Aborting seal generation. Can't propose.");
841853
return Seal::None;
842854
}
@@ -845,7 +857,7 @@ impl Engine<EthereumMachine> for AuthorityRound {
845857
let parent_step: U256 = header_step(parent, self.empty_steps_transition)
846858
.expect("Header has been verified; qed").into();
847859

848-
let step = self.step.load();
860+
let step = self.step.inner.load();
849861

850862
// filter messages from old and future steps and different parents
851863
let empty_steps = if header.number() >= self.empty_steps_transition {
@@ -922,7 +934,7 @@ impl Engine<EthereumMachine> for AuthorityRound {
922934
trace!(target: "engine", "generate_seal: Issuing a block for step {}.", step);
923935

924936
// only issue the seal if we were the first to reach the compare_and_swap.
925-
if self.can_propose.compare_and_swap(true, false, AtomicOrdering::SeqCst) {
937+
if self.step.can_propose.compare_and_swap(true, false, AtomicOrdering::SeqCst) {
926938

927939
self.clear_empty_steps(parent_step);
928940

@@ -999,7 +1011,7 @@ impl Engine<EthereumMachine> for AuthorityRound {
9991011
.decode()?;
10001012

10011013
let parent_step = header_step(&parent, self.empty_steps_transition)?;
1002-
let current_step = self.step.load();
1014+
let current_step = self.step.inner.load();
10031015
self.empty_steps(parent_step.into(), current_step.into(), parent.hash())
10041016
} else {
10051017
// we're verifying a block, extract empty steps from the seal
@@ -1052,7 +1064,7 @@ impl Engine<EthereumMachine> for AuthorityRound {
10521064
// If yes then probably benign reporting needs to be moved further in the verification.
10531065
let set_number = header.number();
10541066

1055-
match verify_timestamp(&*self.step, header_step(header, self.empty_steps_transition)?) {
1067+
match verify_timestamp(&self.step.inner, header_step(header, self.empty_steps_transition)?) {
10561068
Err(BlockError::InvalidSeal) => {
10571069
self.validators.report_benign(header.author(), set_number, header.number());
10581070
Err(BlockError::InvalidSeal.into())
@@ -1294,7 +1306,7 @@ impl Engine<EthereumMachine> for AuthorityRound {
12941306
// This way, upon encountering an epoch change, the proposer from the
12951307
// new set will be forced to wait until the next step to avoid sealing a
12961308
// block that breaks the invariant that the parent's step < the block's step.
1297-
self.can_propose.store(false, AtomicOrdering::SeqCst);
1309+
self.step.can_propose.store(false, AtomicOrdering::SeqCst);
12981310
return Some(combine_proofs(signal_number, &pending.proof, &*finality_proof));
12991311
}
13001312
}

ethcore/types/src/receipt.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
//! Receipt
1818
19-
use ethereum_types::{H256, U256, Address, Bloom};
19+
use ethereum_types::{H160, H256, U256, Address, Bloom};
2020
use heapsize::HeapSizeOf;
2121
use rlp::{Rlp, RlpStream, Encodable, Decodable, DecoderError};
2222

@@ -157,6 +157,10 @@ pub struct LocalizedReceipt {
157157
pub log_bloom: Bloom,
158158
/// Transaction outcome.
159159
pub outcome: TransactionOutcome,
160+
/// Receiver address
161+
pub to: Option<H160>,
162+
/// Sender
163+
pub from: H160
160164
}
161165

162166
#[cfg(test)]

ipfs/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,6 @@ rlp = { path = "../util/rlp" }
1515
cid = "0.2"
1616
multihash = "0.7"
1717
unicase = "2.0"
18+
19+
[dev-dependencies]
20+
ethcore = { path = "../ethcore", features = ["test-helpers"] }

local-store/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,6 @@ serde_derive = "1.0"
1616
serde_json = "1.0"
1717

1818
[dev-dependencies]
19+
ethcore = { path = "../ethcore", features = ["test-helpers"] }
1920
ethkey = { path = "../ethkey" }
2021
kvdb-memorydb = { path = "../util/kvdb-memorydb" }

miner/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ linked-hash-map = "0.5"
2727
log = "0.3"
2828
parking_lot = "0.5"
2929
price-info = { path = "../price-info" }
30-
rayon = "1.0"
3130
rlp = { path = "../util/rlp" }
3231
trace-time = { path = "../util/trace-time" }
3332
transaction-pool = { path = "../transaction-pool" }

miner/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ extern crate keccak_hash as hash;
2929
extern crate linked_hash_map;
3030
extern crate parking_lot;
3131
extern crate price_info;
32-
extern crate rayon;
3332
extern crate rlp;
3433
extern crate trace_time;
3534
extern crate transaction_pool as txpool;

miner/src/pool/queue.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ use std::collections::BTreeMap;
2323

2424
use ethereum_types::{H256, U256, Address};
2525
use parking_lot::RwLock;
26-
use rayon::prelude::*;
2726
use transaction;
2827
use txpool::{self, Verifier};
2928

@@ -179,8 +178,14 @@ impl TransactionQueue {
179178

180179
let verifier = verifier::Verifier::new(client, options, self.insertion_id.clone());
181180
let results = transactions
182-
.into_par_iter()
183-
.map(|transaction| verifier.verify_transaction(transaction))
181+
.into_iter()
182+
.map(|transaction| {
183+
if self.pool.read().find(&transaction.hash()).is_some() {
184+
bail!(transaction::Error::AlreadyImported)
185+
}
186+
187+
verifier.verify_transaction(transaction)
188+
})
184189
.map(|result| result.and_then(|verified| {
185190
self.pool.write().import(verified)
186191
.map(|_imported| ())

0 commit comments

Comments
 (0)