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

Commit c220631

Browse files
author
keorn
committed
Merge branch 'master' into blockscompression
Conflicts: ethcore/src/blockchain/blockchain.rs
2 parents cede71e + c65ee93 commit c220631

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

112 files changed

+4057
-1705
lines changed

Cargo.lock

+7-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

-4
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,6 @@ ipc = ["ethcore/ipc"]
6565
path = "parity/main.rs"
6666
name = "parity"
6767

68-
[[bin]]
69-
path = "parity/sync/main.rs"
70-
name = "sync"
71-
7268
[profile.release]
7369
debug = true
7470
lto = false

appveyor.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ install:
3131
build: off
3232

3333
test_script:
34-
- cargo test --verbose --release --no-default-features
34+
- cargo test --verbose --release
3535

3636
after_test:
37-
- cargo build --verbose --release --no-default-features
37+
- cargo build --verbose --release
3838
- ps: if($env:cert) { Start-FileDownload $env:cert -FileName $env:keyfile }
3939
- ps: if($env:cert) { signtool sign /f $env:keyfile /p $env:certpass target\release\parity.exe }
4040
- makensis.exe nsis\installer.nsi

docker/ubuntu/Dockerfile

+2-1
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,5 @@ RUN git clone https://github.com/ethcore/parity && \
3232
cargo build --release --verbose && \
3333
ls /build/parity/target/release/parity && \
3434
strip /build/parity/target/release/parity
35-
RUN file /build/parity/target/release/parity
35+
36+
ENTRYPOINT ["/build/parity/target/release/parity"]

ethcore/res/ethereum/frontier-dogmatic.json ethcore/res/ethereum/classic.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
2-
"name": "Frontier/Homestead",
2+
"name": "Ethereum Classic",
3+
"forkName": "classic",
34
"engine": {
45
"Ethash": {
56
"params": {

ethcore/src/account.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ impl Account {
6161
nonce: pod.nonce,
6262
storage_root: SHA3_NULL_RLP,
6363
storage_overlay: RefCell::new(pod.storage.into_iter().map(|(k, v)| (k, (Filth::Dirty, v))).collect()),
64-
code_hash: Some(pod.code.sha3()),
65-
code_cache: pod.code,
64+
code_hash: pod.code.as_ref().map(|c| c.sha3()),
65+
code_cache: pod.code.as_ref().map_or_else(|| { warn!("POD account with unknown code is being created! Assuming no code."); vec![] }, |c| c.clone()),
6666
filth: Filth::Dirty,
6767
}
6868
}

ethcore/src/account_provider.rs

+56-2
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,8 @@ impl KeyDirectory for NullDir {
114114
Ok(vec![])
115115
}
116116

117-
fn insert(&self, _account: SafeAccount) -> Result<(), SSError> {
118-
Ok(())
117+
fn insert(&self, account: SafeAccount) -> Result<SafeAccount, SSError> {
118+
Ok(account)
119119
}
120120

121121
fn remove(&self, _address: &SSAddress) -> Result<(), SSError> {
@@ -130,6 +130,27 @@ pub struct AccountProvider {
130130
sstore: Box<SecretStore>,
131131
}
132132

133+
/// Collected account metadata
134+
#[derive(Clone, Debug, PartialEq)]
135+
pub struct AccountMeta {
136+
/// The name of the account.
137+
pub name: String,
138+
/// The rest of the metadata of the account.
139+
pub meta: String,
140+
/// The 128-bit UUID of the account, if it has one (brain-wallets don't).
141+
pub uuid: Option<String>,
142+
}
143+
144+
impl Default for AccountMeta {
145+
fn default() -> Self {
146+
AccountMeta {
147+
name: String::new(),
148+
meta: "{}".to_owned(),
149+
uuid: None,
150+
}
151+
}
152+
}
153+
133154
impl AccountProvider {
134155
/// Creates new account provider.
135156
pub fn new(sstore: Box<SecretStore>) -> Self {
@@ -167,6 +188,39 @@ impl AccountProvider {
167188
self.sstore.accounts().into_iter().map(|a| H160(a.into())).collect()
168189
}
169190

191+
/// Returns each account along with name and meta.
192+
pub fn accounts_info(&self) -> Result<HashMap<H160, AccountMeta>, Error> {
193+
let r: HashMap<H160, AccountMeta> = self.sstore.accounts()
194+
.into_iter()
195+
.map(|a| (H160(a.clone().into()), self.account_meta(a).unwrap_or_else(|_| Default::default())))
196+
.collect();
197+
Ok(r)
198+
}
199+
200+
/// Returns each account along with name and meta.
201+
pub fn account_meta<A>(&self, account: A) -> Result<AccountMeta, Error> where Address: From<A> {
202+
let account = Address::from(account).into();
203+
Ok(AccountMeta {
204+
name: try!(self.sstore.name(&account)),
205+
meta: try!(self.sstore.meta(&account)),
206+
uuid: self.sstore.uuid(&account).ok().map(Into::into), // allowed to not have a UUID
207+
})
208+
}
209+
210+
/// Returns each account along with name and meta.
211+
pub fn set_account_name<A>(&self, account: A, name: String) -> Result<(), Error> where Address: From<A> {
212+
let account = Address::from(account).into();
213+
try!(self.sstore.set_name(&account, name));
214+
Ok(())
215+
}
216+
217+
/// Returns each account along with name and meta.
218+
pub fn set_account_meta<A>(&self, account: A, meta: String) -> Result<(), Error> where Address: From<A> {
219+
let account = Address::from(account).into();
220+
try!(self.sstore.set_meta(&account, meta));
221+
Ok(())
222+
}
223+
170224
/// Helper method used for unlocking accounts.
171225
fn unlock_account<A>(&self, account: A, password: String, unlock: Unlock) -> Result<(), Error> where Address: From<A> {
172226
let a = Address::from(account);

ethcore/src/block.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ impl<'x> OpenBlock<'x> {
339339
let t = outcome.trace;
340340
self.block.traces.as_mut().map(|traces| traces.push(t.expect("self.block.traces.is_some(): so we must be tracing: qed")));
341341
self.block.receipts.push(outcome.receipt);
342-
Ok(&self.block.receipts.last().unwrap())
342+
Ok(self.block.receipts.last().unwrap())
343343
}
344344
Err(x) => Err(From::from(x))
345345
}

ethcore/src/block_queue.rs

+23-17
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
//! Sorts them ready for blockchain insertion.
1919
use std::thread::{JoinHandle, self};
2020
use std::sync::atomic::{AtomicBool, Ordering as AtomicOrdering};
21+
use std::sync::{Condvar as SCondvar, Mutex as SMutex};
2122
use util::*;
2223
use verification::*;
2324
use error::*;
@@ -36,7 +37,7 @@ const MIN_MEM_LIMIT: usize = 16384;
3637
const MIN_QUEUE_LIMIT: usize = 512;
3738

3839
/// Block queue configuration
39-
#[derive(Debug)]
40+
#[derive(Debug, PartialEq)]
4041
pub struct BlockQueueConfig {
4142
/// Maximum number of blocks to keep in unverified queue.
4243
/// When the limit is reached, is_full returns true.
@@ -80,12 +81,12 @@ impl BlockQueueInfo {
8081
pub struct BlockQueue {
8182
panic_handler: Arc<PanicHandler>,
8283
engine: Arc<Box<Engine>>,
83-
more_to_verify: Arc<Condvar>,
84+
more_to_verify: Arc<SCondvar>,
8485
verification: Arc<Verification>,
8586
verifiers: Vec<JoinHandle<()>>,
8687
deleting: Arc<AtomicBool>,
8788
ready_signal: Arc<QueueSignal>,
88-
empty: Arc<Condvar>,
89+
empty: Arc<SCondvar>,
8990
processing: RwLock<HashSet<H256>>,
9091
max_queue_size: usize,
9192
max_mem_use: usize,
@@ -133,6 +134,8 @@ struct Verification {
133134
verified: Mutex<VecDeque<PreverifiedBlock>>,
134135
verifying: Mutex<VecDeque<VerifyingBlock>>,
135136
bad: Mutex<HashSet<H256>>,
137+
more_to_verify: SMutex<()>,
138+
empty: SMutex<()>,
136139
}
137140

138141
impl BlockQueue {
@@ -143,15 +146,18 @@ impl BlockQueue {
143146
verified: Mutex::new(VecDeque::new()),
144147
verifying: Mutex::new(VecDeque::new()),
145148
bad: Mutex::new(HashSet::new()),
149+
more_to_verify: SMutex::new(()),
150+
empty: SMutex::new(()),
151+
146152
});
147-
let more_to_verify = Arc::new(Condvar::new());
153+
let more_to_verify = Arc::new(SCondvar::new());
148154
let deleting = Arc::new(AtomicBool::new(false));
149155
let ready_signal = Arc::new(QueueSignal {
150156
deleting: deleting.clone(),
151157
signalled: AtomicBool::new(false),
152158
message_channel: message_channel
153159
});
154-
let empty = Arc::new(Condvar::new());
160+
let empty = Arc::new(SCondvar::new());
155161
let panic_handler = PanicHandler::new_in_arc();
156162

157163
let mut verifiers: Vec<JoinHandle<()>> = Vec::new();
@@ -190,17 +196,17 @@ impl BlockQueue {
190196
}
191197
}
192198

193-
fn verify(verification: Arc<Verification>, engine: Arc<Box<Engine>>, wait: Arc<Condvar>, ready: Arc<QueueSignal>, deleting: Arc<AtomicBool>, empty: Arc<Condvar>) {
199+
fn verify(verification: Arc<Verification>, engine: Arc<Box<Engine>>, wait: Arc<SCondvar>, ready: Arc<QueueSignal>, deleting: Arc<AtomicBool>, empty: Arc<SCondvar>) {
194200
while !deleting.load(AtomicOrdering::Acquire) {
195201
{
196-
let mut unverified = verification.unverified.lock();
202+
let mut more_to_verify = verification.more_to_verify.lock().unwrap();
197203

198-
if unverified.is_empty() && verification.verifying.lock().is_empty() {
204+
if verification.unverified.lock().is_empty() && verification.verifying.lock().is_empty() {
199205
empty.notify_all();
200206
}
201207

202-
while unverified.is_empty() && !deleting.load(AtomicOrdering::Acquire) {
203-
wait.wait(&mut unverified);
208+
while verification.unverified.lock().is_empty() && !deleting.load(AtomicOrdering::Acquire) {
209+
more_to_verify = wait.wait(more_to_verify).unwrap();
204210
}
205211

206212
if deleting.load(AtomicOrdering::Acquire) {
@@ -276,18 +282,18 @@ impl BlockQueue {
276282

277283
/// Wait for unverified queue to be empty
278284
pub fn flush(&self) {
279-
let mut unverified = self.verification.unverified.lock();
280-
while !unverified.is_empty() || !self.verification.verifying.lock().is_empty() {
281-
self.empty.wait(&mut unverified);
285+
let mut lock = self.verification.empty.lock().unwrap();
286+
while !self.verification.unverified.lock().is_empty() || !self.verification.verifying.lock().is_empty() {
287+
lock = self.empty.wait(lock).unwrap();
282288
}
283289
}
284290

285291
/// Check if the block is currently in the queue
286292
pub fn block_status(&self, hash: &H256) -> BlockStatus {
287-
if self.processing.read().contains(&hash) {
293+
if self.processing.read().contains(hash) {
288294
return BlockStatus::Queued;
289295
}
290-
if self.verification.bad.lock().contains(&hash) {
296+
if self.verification.bad.lock().contains(hash) {
291297
return BlockStatus::Bad;
292298
}
293299
BlockStatus::Unknown
@@ -340,7 +346,7 @@ impl BlockQueue {
340346
bad.reserve(block_hashes.len());
341347
for hash in block_hashes {
342348
bad.insert(hash.clone());
343-
processing.remove(&hash);
349+
processing.remove(hash);
344350
}
345351

346352
let mut new_verified = VecDeque::new();
@@ -362,7 +368,7 @@ impl BlockQueue {
362368
}
363369
let mut processing = self.processing.write();
364370
for hash in block_hashes {
365-
processing.remove(&hash);
371+
processing.remove(hash);
366372
}
367373
}
368374

0 commit comments

Comments
 (0)