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

Commit

Permalink
Merge branch 'master' into dp/chore/extricate-account-db-into-own-crate
Browse files Browse the repository at this point in the history
* master:
  Extricate PodAccount and state Account to own crates (#10838)
  logs (#10817)
  refactor: whisper: Add type aliases and update rustdocs in message.rs (#10812)
  Break circular dependency between Client and Engine (part 1) (#10833)
  tests: Relates to #10655: Test instructions for Readme (#10835)
  refactor: Related #9459 - evmbin: replace untyped json! macro with fully typed serde serialization using Rust structs (#10657)
  • Loading branch information
dvdplm committed Jul 4, 2019
2 parents 7792810 + 9f96fa0 commit b7c7aae
Show file tree
Hide file tree
Showing 26 changed files with 453 additions and 278 deletions.
47 changes: 35 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@
3.2 [Building from Source Code](#chapter-0032)<br>
3.3 [Simple One-Line Installer for Mac and Linux](#chapter-0033)<br>
3.4 [Starting Parity Ethereum](#chapter-0034)
4. [Documentation](#chapter-004)
5. [Toolchain](#chapter-005)
6. [Community](#chapter-006)
7. [Contributing](#chapter-007)
8. [License](#chapter-008)
4. [Testing](#chapter-004)
5. [Documentation](#chapter-005)
6. [Toolchain](#chapter-006)
7. [Community](#chapter-007)
8. [Contributing](#chapter-008)
9. [License](#chapter-009)


## 1. Description <a id="chapter-001"></a>
Expand Down Expand Up @@ -148,7 +149,25 @@ To start Parity Ethereum as a regular user using `systemd` init:
2. Copy release to bin folder, write `sudo install ./target/release/parity /usr/bin/parity`
3. To configure Parity Ethereum, write a `/etc/parity/config.toml` config file, see [Configuring Parity Ethereum](https://paritytech.github.io/wiki/Configuring-Parity) for details.
## 4. Documentation <a id="chapter-004"></a>
## 4. Testing <a id="chapter-004"></a>
You can run tests with the following commands:
* **All** packages
```
cargo test --all
```
* Specific package
```
cargo test --package <spec>
```
Replace `<spec>` with one of the packages from the [package list](#package-list) (e.g. `cargo test --package evmbin`).
You can show your logs in the test output by passing `--nocapture` (i.e. `cargo test --package evmbin -- --nocapture`)
## 5. Documentation <a id="chapter-005"></a>
Official website: https://parity.io
Expand All @@ -160,16 +179,20 @@ You can generate documentation for Parity Ethereum Rust packages that automatica
* **All** packages
```
cargo doc --open
cargo doc --document-private-items --open
```
* Specific package
```
cargo doc --package <spec> --open
cargo doc --package <spec> -- --document-private-items --open
```
Use`--document-private-items` to also view private documentation and `--no-deps` to exclude building documentation for dependencies.
Replacing `<spec>` with one of the following from the details section below (i.e. `cargo doc --package parity-ethereum --open`):
<a id="package-list"></a>
**Package List**
<details><p>
* Parity Ethereum (EthCore) Client Application
Expand Down Expand Up @@ -330,7 +353,7 @@ Example (generic documentation comment):
///
```
## 5. Toolchain <a id="chapter-005"></a>
## 6. Toolchain <a id="chapter-006"></a>
In addition to the Parity Ethereum client, there are additional tools in this repository available:
Expand All @@ -342,7 +365,7 @@ In addition to the Parity Ethereum client, there are additional tools in this re
The following tool is available in a separate repository:
- [ethabi](https://github.com/paritytech/ethabi) - Parity Ethereum Encoding of Function Calls. [Docs here](https://crates.io/crates/ethabi)
## 6. Community <a id="chapter-006"></a>
## 7. Community <a id="chapter-007"></a>
### Join the chat!
Expand All @@ -355,14 +378,14 @@ Questions? Get in touch with us on Gitter:
Alternatively, join our community on Matrix:
[![Riot: +Parity](https://img.shields.io/badge/riot-%2Bparity%3Amatrix.parity.io-orange.svg)](https://riot.im/app/#/group/+parity:matrix.parity.io)
## 7. Contributing <a id="chapter-007"></a>
## 8. Contributing <a id="chapter-008"></a>
An introduction has been provided in the ["So You Want to be a Core Developer" presentation slides by Hernando Castano](http://tiny.cc/contrib-to-parity-eth). Additional guidelines are provided in [CONTRIBUTING](./.github/CONTRIBUTING.md).
### Contributor Code of Conduct
[CODE_OF_CONDUCT](./.github/CODE_OF_CONDUCT.md)
## 8. License <a id="chapter-008"></a>
## 9. License <a id="chapter-009"></a>
[LICENSE](./LICENSE)
2 changes: 1 addition & 1 deletion accounts/ethstore/src/json/crypto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ impl str::FromStr for Crypto {

impl From<Crypto> for String {
fn from(c: Crypto) -> Self {
serde_json::to_string(&c).expect("serialization cannot fail, cause all crypto keys are strings")
serde_json::to_string(&c).expect("Serialization cannot fail, because all crypto keys are strings")
}
}

Expand Down
49 changes: 21 additions & 28 deletions ethcore/src/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@
//! and can be appended to with transactions and uncles.
//!
//! When ready, `OpenBlock` can be closed and turned into a `ClosedBlock`. A `ClosedBlock` can
//! be reopend again by a miner under certain circumstances. On block close, state commit is
//! be re-opend again by a miner under certain circumstances. On block close, state commit is
//! performed.
//!
//! `LockedBlock` is a version of a `ClosedBlock` that cannot be reopened. It can be sealed
//! using an engine.
//!
//! `ExecutedBlock` is an underlaying data structure used by all structs above to store block
//! `ExecutedBlock` is an underlying data structure used by all structs above to store block
//! related info.

use std::{cmp, ops};
Expand All @@ -52,7 +52,7 @@ use vm::{EnvInfo, LastHashes};
use hash::keccak;
use rlp::{RlpStream, Encodable, encode_list};
use types::transaction::{SignedTransaction, Error as TransactionError};
use types::header::{Header, ExtendedHeader};
use types::header::Header;
use types::receipt::{Receipt, TransactionOutcome};

/// Block that is ready for transactions to be added.
Expand All @@ -62,6 +62,7 @@ use types::receipt::{Receipt, TransactionOutcome};
pub struct OpenBlock<'x> {
block: ExecutedBlock,
engine: &'x dyn Engine,
parent: Header,
}

/// Just like `OpenBlock`, except that we've applied `Engine::on_close_block`, finished up the non-seal header fields,
Expand All @@ -72,6 +73,7 @@ pub struct OpenBlock<'x> {
pub struct ClosedBlock {
block: ExecutedBlock,
unclosed_state: State<StateDB>,
parent: Header,
}

/// Just like `ClosedBlock` except that we can't reopen it and it's faster.
Expand Down Expand Up @@ -102,7 +104,7 @@ pub struct ExecutedBlock {
pub receipts: Vec<Receipt>,
/// Hashes of already executed transactions.
pub transactions_set: HashSet<H256>,
/// Underlaying state.
/// Underlying state.
pub state: State<StateDB>,
/// Transaction traces.
pub traces: Tracing,
Expand All @@ -119,13 +121,13 @@ impl ExecutedBlock {
uncles: Default::default(),
receipts: Default::default(),
transactions_set: Default::default(),
state: state,
state,
traces: if tracing {
Tracing::enabled()
} else {
Tracing::Disabled
},
last_hashes: last_hashes,
last_hashes,
}
}

Expand Down Expand Up @@ -162,7 +164,7 @@ pub trait Drain {

impl<'x> OpenBlock<'x> {
/// Create a new `OpenBlock` ready for transaction pushing.
pub fn new<'a, I: IntoIterator<Item = ExtendedHeader>>(
pub fn new<'a>(
engine: &'x dyn Engine,
factories: Factories,
tracing: bool,
Expand All @@ -173,14 +175,11 @@ impl<'x> OpenBlock<'x> {
gas_range_target: (U256, U256),
extra_data: Bytes,
is_epoch_begin: bool,
ancestry: I,
) -> Result<Self, Error> {
let number = parent.number() + 1;
let state = State::from_existing(db, parent.state_root().clone(), engine.account_start_nonce(number), factories)?;
let mut r = OpenBlock {
block: ExecutedBlock::new(state, last_hashes, tracing),
engine: engine,
};

let mut r = OpenBlock { block: ExecutedBlock::new(state, last_hashes, tracing), engine, parent: parent.clone() };

r.block.header.set_parent_hash(parent.hash());
r.block.header.set_number(number);
Expand All @@ -195,7 +194,7 @@ impl<'x> OpenBlock<'x> {
engine.populate_from_parent(&mut r.block.header, parent);

engine.machine().on_new_block(&mut r.block)?;
engine.on_new_block(&mut r.block, is_epoch_begin, &mut ancestry.into_iter())?;
engine.on_new_block(&mut r.block, is_epoch_begin)?;

Ok(r)
}
Expand Down Expand Up @@ -297,19 +296,20 @@ impl<'x> OpenBlock<'x> {
/// Turn this into a `ClosedBlock`.
pub fn close(self) -> Result<ClosedBlock, Error> {
let unclosed_state = self.block.state.clone();
let parent = self.parent.clone();
let locked = self.close_and_lock()?;

Ok(ClosedBlock {
block: locked.block,
unclosed_state,
parent,
})
}

/// Turn this into a `LockedBlock`.
pub fn close_and_lock(self) -> Result<LockedBlock, Error> {
let mut s = self;

s.engine.on_close_block(&mut s.block)?;
s.engine.on_close_block(&mut s.block, &s.parent)?;
s.block.state.commit()?;

s.block.header.set_transactions_root(ordered_trie_root(s.block.transactions.iter().map(|e| e.rlp_bytes())));
Expand Down Expand Up @@ -378,10 +378,8 @@ impl ClosedBlock {
// revert rewards (i.e. set state back at last transaction's state).
let mut block = self.block;
block.state = self.unclosed_state;
OpenBlock {
block: block,
engine: engine,
}
let parent = self.parent;
OpenBlock { block, engine, parent }
}
}

Expand Down Expand Up @@ -479,7 +477,6 @@ pub(crate) fn enact(
last_hashes: Arc<LastHashes>,
factories: Factories,
is_epoch_begin: bool,
ancestry: &mut dyn Iterator<Item=ExtendedHeader>,
) -> Result<LockedBlock, Error> {
// For trace log
let trace_state = if log_enabled!(target: "enact", ::log::Level::Trace) {
Expand All @@ -501,7 +498,6 @@ pub(crate) fn enact(
(3141562.into(), 31415620.into()),
vec![],
is_epoch_begin,
ancestry,
)?;

if let Some(ref s) = trace_state {
Expand All @@ -522,7 +518,7 @@ pub(crate) fn enact(
b.close_and_lock()
}

/// Enact the block given by `block_bytes` using `engine` on the database `db` with given `parent` block header
/// Enact the block given by `block_bytes` using `engine` on the database `db` with the given `parent` block header
pub fn enact_verified(
block: PreverifiedBlock,
engine: &dyn Engine,
Expand All @@ -532,7 +528,6 @@ pub fn enact_verified(
last_hashes: Arc<LastHashes>,
factories: Factories,
is_epoch_begin: bool,
ancestry: &mut dyn Iterator<Item=ExtendedHeader>,
) -> Result<LockedBlock, Error> {

enact(
Expand All @@ -546,7 +541,6 @@ pub fn enact_verified(
last_hashes,
factories,
is_epoch_begin,
ancestry,
)
}

Expand Down Expand Up @@ -608,7 +602,6 @@ mod tests {
(3141562.into(), 31415620.into()),
vec![],
false,
None,
)?;

b.populate_from(&header);
Expand Down Expand Up @@ -643,7 +636,7 @@ mod tests {
let genesis_header = spec.genesis_header();
let db = spec.ensure_db_good(get_temp_state_db(), &Default::default()).unwrap();
let last_hashes = Arc::new(vec![genesis_header.hash()]);
let b = OpenBlock::new(&*spec.engine, Default::default(), false, db, &genesis_header, last_hashes, Address::zero(), (3141562.into(), 31415620.into()), vec![], false, None).unwrap();
let b = OpenBlock::new(&*spec.engine, Default::default(), false, db, &genesis_header, last_hashes, Address::zero(), (3141562.into(), 31415620.into()), vec![], false).unwrap();
let b = b.close_and_lock().unwrap();
let _ = b.seal(&*spec.engine, vec![]);
}
Expand All @@ -657,7 +650,7 @@ mod tests {

let db = spec.ensure_db_good(get_temp_state_db(), &Default::default()).unwrap();
let last_hashes = Arc::new(vec![genesis_header.hash()]);
let b = OpenBlock::new(engine, Default::default(), false, db, &genesis_header, last_hashes.clone(), Address::zero(), (3141562.into(), 31415620.into()), vec![], false, None).unwrap()
let b = OpenBlock::new(engine, Default::default(), false, db, &genesis_header, last_hashes.clone(), Address::zero(), (3141562.into(), 31415620.into()), vec![], false).unwrap()
.close_and_lock().unwrap().seal(engine, vec![]).unwrap();
let orig_bytes = b.rlp_bytes();
let orig_db = b.drain().state.drop().1;
Expand All @@ -682,7 +675,7 @@ mod tests {

let db = spec.ensure_db_good(get_temp_state_db(), &Default::default()).unwrap();
let last_hashes = Arc::new(vec![genesis_header.hash()]);
let mut open_block = OpenBlock::new(engine, Default::default(), false, db, &genesis_header, last_hashes.clone(), Address::zero(), (3141562.into(), 31415620.into()), vec![], false, None).unwrap();
let mut open_block = OpenBlock::new(engine, Default::default(), false, db, &genesis_header, last_hashes.clone(), Address::zero(), (3141562.into(), 31415620.into()), vec![], false).unwrap();
let mut uncle1_header = Header::new();
uncle1_header.set_extra_data(b"uncle1".to_vec());
let mut uncle2_header = Header::new();
Expand Down
2 changes: 0 additions & 2 deletions ethcore/src/client/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,6 @@ impl Importer {
last_hashes,
client.factories.clone(),
is_epoch_begin,
&mut chain.ancestry_with_metadata_iter(*header.parent_hash()),
);

let mut locked_block = match enact_result {
Expand Down Expand Up @@ -2361,7 +2360,6 @@ impl PrepareOpenBlock for Client {
gas_range_target,
extra_data,
is_epoch_begin,
chain.ancestry_with_metadata_iter(best_header.hash()),
)?;

// Add uncles
Expand Down
1 change: 0 additions & 1 deletion ethcore/src/client/test_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,6 @@ impl PrepareOpenBlock for TestBlockChainClient {
gas_range_target,
extra_data,
false,
None,
)?;
// TODO [todr] Override timestamp for predictability
open_block.set_timestamp(*self.latest_block_timestamp.read());
Expand Down
Loading

0 comments on commit b7c7aae

Please sign in to comment.