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

Commit aabe7dd

Browse files
committed
Merge remote-tracking branch 'origin/master' into refactor/hashdb-generic
* origin/master: Fix local transactions policy. (#8691) Shutdown the Snapshot Service early (#8658) network-devp2p: handle UselessPeer disconnect (#8686) Fix compilation error on nightly rust (#8707) Add a test for decoding corrupt data (#8713) Update dev chain (#8717) Remove unused imports (#8722)
2 parents 013666f + 1620eab commit aabe7dd

File tree

15 files changed

+183
-62
lines changed

15 files changed

+183
-62
lines changed

Cargo.lock

Lines changed: 44 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ members = [
136136
"transaction-pool",
137137
"whisper",
138138
"whisper/cli",
139+
"util/learn-generics",
139140
]
140141

141142
[patch.crates-io]

ethcore/res/instant_seal.json

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,20 @@
1010
"minGasLimit": "0x1388",
1111
"networkID" : "0x11",
1212
"registrar" : "0x0000000000000000000000000000000000001337",
13+
"eip150Transition": "0x0",
14+
"eip160Transition": "0x0",
15+
"eip161abcTransition": "0x0",
16+
"eip161dTransition": "0x0",
17+
"eip155Transition": "0x0",
18+
"eip98Transition": "0x7fffffffffffff",
19+
"eip86Transition": "0x7fffffffffffff",
20+
"maxCodeSize": 24576,
21+
"maxCodeSizeTransition": "0x0",
1322
"eip140Transition": "0x0",
1423
"eip211Transition": "0x0",
1524
"eip214Transition": "0x0",
16-
"eip658Transition": "0x0"
25+
"eip658Transition": "0x0",
26+
"wasmActivationTransition": "0x0"
1727
},
1828
"genesis": {
1929
"seal": {

ethcore/service/src/service.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ use sync::PrivateTxHandler;
2929
use ethcore::client::{Client, ClientConfig, ChainNotify, ClientIoMessage};
3030
use ethcore::miner::Miner;
3131
use ethcore::snapshot::service::{Service as SnapshotService, ServiceParams as SnapServiceParams};
32-
use ethcore::snapshot::{RestorationStatus};
32+
use ethcore::snapshot::{SnapshotService as _SnapshotService, RestorationStatus};
3333
use ethcore::spec::Spec;
3434
use ethcore::account_provider::AccountProvider;
3535

@@ -168,6 +168,11 @@ impl ClientService {
168168

169169
/// Get a handle to the database.
170170
pub fn db(&self) -> Arc<KeyValueDB> { self.database.clone() }
171+
172+
/// Shutdown the Client Service
173+
pub fn shutdown(&self) {
174+
self.snapshot.shutdown();
175+
}
171176
}
172177

173178
/// IO interface for the Client handler

ethcore/src/snapshot/service.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -743,6 +743,10 @@ impl SnapshotService for Service {
743743
trace!("Error sending snapshot service message: {:?}", e);
744744
}
745745
}
746+
747+
fn shutdown(&self) {
748+
self.abort_restore();
749+
}
746750
}
747751

748752
impl Drop for Service {

ethcore/src/snapshot/traits.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,7 @@ pub trait SnapshotService : Sync + Send {
5454
/// Feed a raw block chunk to the service to be processed asynchronously.
5555
/// no-op if currently restoring.
5656
fn restore_block_chunk(&self, hash: H256, chunk: Bytes);
57+
58+
/// Shutdown the Snapshot Service by aborting any ongoing restore
59+
fn shutdown(&self);
5760
}

ethcore/sync/src/tests/snapshot.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,10 @@ impl SnapshotService for TestSnapshotService {
133133
self.block_restoration_chunks.lock().insert(hash, chunk);
134134
}
135135
}
136+
137+
fn shutdown(&self) {
138+
self.abort_restore();
139+
}
136140
}
137141

138142
#[test]

miner/src/pool/scoring.rs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,15 @@ impl txpool::Scoring<VerifiedTransaction> for NonceAndGasPrice {
107107
}
108108
}
109109

110+
// Always kick out non-local transactions in favour of local ones.
111+
if new.priority().is_local() && !old.priority().is_local() {
112+
return true;
113+
}
114+
// And never kick out local transactions in favour of external ones.
115+
if !new.priority().is_local() && old.priority.is_local() {
116+
return false;
117+
}
118+
110119
self.choose(old, new) == txpool::scoring::Choice::ReplaceOld
111120
}
112121
}
@@ -119,6 +128,30 @@ mod tests {
119128
use pool::tests::tx::{Tx, TxExt};
120129
use txpool::Scoring;
121130

131+
#[test]
132+
fn should_replace_non_local_transaction_with_local_one() {
133+
// given
134+
let scoring = NonceAndGasPrice(PrioritizationStrategy::GasPriceOnly);
135+
let tx1 = {
136+
let tx = Tx::default().signed().verified();
137+
txpool::Transaction {
138+
insertion_id: 0,
139+
transaction: Arc::new(tx),
140+
}
141+
};
142+
let tx2 = {
143+
let mut tx = Tx::default().signed().verified();
144+
tx.priority = ::pool::Priority::Local;
145+
txpool::Transaction {
146+
insertion_id: 0,
147+
transaction: Arc::new(tx),
148+
}
149+
};
150+
151+
assert!(scoring.should_replace(&tx1, &tx2));
152+
assert!(!scoring.should_replace(&tx2, &tx1));
153+
}
154+
122155
#[test]
123156
fn should_calculate_score_correctly() {
124157
// given

miner/src/pool/tests/mod.rs

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -766,4 +766,35 @@ fn should_reject_big_transaction() {
766766
verifier::Transaction::Local(PendingTransaction::new(big_tx, transaction::Condition::Timestamp(1000).into()))
767767
]);
768768
assert_eq!(res, vec![Err(transaction::Error::TooBig)]);
769-
}
769+
}
770+
771+
#[test]
772+
fn should_include_local_transaction_to_a_full_pool() {
773+
// given
774+
let txq = TransactionQueue::new(
775+
txpool::Options {
776+
max_count: 1,
777+
max_per_sender: 2,
778+
max_mem_usage: 50
779+
},
780+
verifier::Options {
781+
minimal_gas_price: 1.into(),
782+
block_gas_limit: 1_000_000.into(),
783+
tx_gas_limit: 1_000_000.into(),
784+
},
785+
PrioritizationStrategy::GasPriceOnly,
786+
);
787+
let tx1 = Tx::gas_price(10_000).signed().unverified();
788+
let tx2 = Tx::gas_price(1).signed().local();
789+
790+
let res = txq.import(TestClient::new().with_balance(1_000_000_000), vec![tx1]);
791+
assert_eq!(res, vec![Ok(())]);
792+
assert_eq!(txq.status().status.transaction_count, 1);
793+
794+
// when
795+
let res = txq.import(TestClient::new(), vec![tx2]);
796+
assert_eq!(res, vec![Ok(())]);
797+
798+
// then
799+
assert_eq!(txq.status().status.transaction_count, 1);
800+
}

parity/run.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -885,7 +885,8 @@ fn execute_impl<Cr, Rr>(cmd: RunCmd, logger: Arc<RotatingLogger>, on_client_rq:
885885
rpc: rpc_direct,
886886
informant,
887887
client,
888-
keep_alive: Box::new((watcher, service, updater, ws_server, http_server, ipc_server, ui_server, secretstore_key_server, ipfs_server, event_loop)),
888+
client_service: Arc::new(service),
889+
keep_alive: Box::new((watcher, updater, ws_server, http_server, ipc_server, ui_server, secretstore_key_server, ipfs_server, event_loop)),
889890
}
890891
})
891892
}
@@ -909,6 +910,7 @@ enum RunningClientInner {
909910
rpc: jsonrpc_core::MetaIoHandler<Metadata, informant::Middleware<informant::ClientNotifier>>,
910911
informant: Arc<Informant<FullNodeInformantData>>,
911912
client: Arc<Client>,
913+
client_service: Arc<ClientService>,
912914
keep_alive: Box<Any>,
913915
},
914916
}
@@ -946,11 +948,14 @@ impl RunningClient {
946948
drop(client);
947949
wait_for_drop(weak_client);
948950
},
949-
RunningClientInner::Full { rpc, informant, client, keep_alive } => {
951+
RunningClientInner::Full { rpc, informant, client, client_service, keep_alive } => {
950952
info!("Finishing work, please wait...");
951953
// Create a weak reference to the client so that we can wait on shutdown
952954
// until it is dropped
953955
let weak_client = Arc::downgrade(&client);
956+
// Shutdown and drop the ServiceClient
957+
client_service.shutdown();
958+
drop(client_service);
954959
// drop this stuff as soon as exit detected.
955960
drop(rpc);
956961
drop(keep_alive);

0 commit comments

Comments
 (0)