Skip to content
This repository was archived by the owner on Nov 6, 2020. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
0041f5d
move common forks and parameters to common params
rphmeier Jul 24, 2017
87fdead
port specs over to new format
rphmeier Jul 24, 2017
92ff030
fix RPC tests
rphmeier Jul 24, 2017
13a859b
parity-machine skeleton
rphmeier Jul 25, 2017
2ddac26
Merge branch 'master' into general-engine
rphmeier Aug 29, 2017
f165a74
remove block type
rphmeier Aug 29, 2017
49e2c25
Merge branch 'master' into general-engine
rphmeier Aug 30, 2017
72b6e35
extract out ethereum-specific methods into EthereumMachine
rphmeier Aug 31, 2017
08237d4
beginning to integrate Machine into engines. dealing with stale trans…
rphmeier Aug 31, 2017
285d872
initial porting to machine
rphmeier Sep 11, 2017
39a2fbd
move block reward back into engine
rphmeier Sep 12, 2017
0310a64
abstract block reward logic
rphmeier Sep 12, 2017
107d35c
move last hash and DAO HF logic into machine
rphmeier Sep 12, 2017
36a1a15
begin making engine function parameters generic
rphmeier Sep 12, 2017
4177ee3
Merge branch 'master' into general-engine
rphmeier Sep 12, 2017
9c34d7c
abstract epoch verifier and ethash block reward logic
rphmeier Sep 13, 2017
b61d5b0
instantiate special ethereummachine for ethash in spec
rphmeier Sep 13, 2017
00ab947
optional full verification in verify_block_family
rphmeier Sep 15, 2017
3b4ef5d
re-instate tx_filter in a way that works for all engines
rphmeier Sep 15, 2017
2749062
fix warnings
rphmeier Sep 18, 2017
d70628c
Merge branch 'master' into general-engine
rphmeier Sep 18, 2017
5dc37e7
fix most tests, further generalize engine trait
rphmeier Sep 21, 2017
39cde1c
uncomment nullengine, get ethcore tests compiling
rphmeier Sep 21, 2017
4af29bf
fix warnings
rphmeier Sep 21, 2017
8c56f4a
update a bunch of specs
rphmeier Sep 21, 2017
76c75c6
re-enable engine signer, validator set, and transition handler
rphmeier Sep 21, 2017
bf7fde8
migrate basic_authority engine
rphmeier Sep 21, 2017
ab4ba88
move last hashes into executedblock
rphmeier Sep 22, 2017
78a02ea
port tendermint
rphmeier Sep 22, 2017
0b58a5c
make all ethcore tests pass
rphmeier Sep 25, 2017
07ac587
json-tests compilation
rphmeier Sep 25, 2017
50ca85c
fix RPC tests: change in gas limit for new block changed PoW hash
rphmeier Sep 25, 2017
4edc502
Merge branch 'master' into general-engine
rphmeier Sep 25, 2017
4351dd0
fix minor grumbles
rphmeier Sep 26, 2017
afeefdd
Merge branch 'master' into general-engine
rphmeier Sep 26, 2017
8d4597e
validate chainspecs
rphmeier Sep 26, 2017
ba63dcb
fix broken import
rphmeier Sep 26, 2017
76db1d8
fix transaction verification for pre-homestead
rphmeier Sep 26, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 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 ethcore/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ lru-cache = "0.1.0"
native-contracts = { path = "native_contracts" }
num = "0.1"
num_cpus = "1.2"
parity-machine = { path = "../machine" }
parking_lot = "0.4"
price-info = { path = "../price-info" }
rayon = "0.8"
Expand Down
17 changes: 14 additions & 3 deletions ethcore/light/src/client/fetch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
use std::sync::Arc;

use ethcore::encoded;
use ethcore::engines::{Engine, StateDependentProof};
use ethcore::engines::{EthEngine, StateDependentProof};
use ethcore::machine::EthereumMachine;
use ethcore::header::Header;
use ethcore::receipt::Receipt;
use futures::future::IntoFuture;
Expand All @@ -44,7 +45,12 @@ pub trait ChainDataFetcher: Send + Sync + 'static {
fn block_receipts(&self, header: &Header) -> Self::Receipts;

/// Fetch epoch transition proof at given header.
fn epoch_transition(&self, hash: H256, engine: Arc<Engine>, checker: Arc<StateDependentProof>) -> Self::Transition;
fn epoch_transition(
&self,
_hash: H256,
_engine: Arc<EthEngine>,
_checker: Arc<StateDependentProof<EthereumMachine>>
) -> Self::Transition;
}

/// Fetcher implementation which cannot fetch anything.
Expand All @@ -68,7 +74,12 @@ impl ChainDataFetcher for Unavailable {
Err("fetching block receipts unavailable")
}

fn epoch_transition(&self, _h: H256, _e: Arc<Engine>, _check: Arc<StateDependentProof>) -> Self::Transition {
fn epoch_transition(
&self,
_hash: H256,
_engine: Arc<EthEngine>,
_checker: Arc<StateDependentProof<EthereumMachine>>
) -> Self::Transition {
Err("fetching epoch transition proofs unavailable")
}
}
89 changes: 47 additions & 42 deletions ethcore/light/src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ use std::sync::{Weak, Arc};

use ethcore::block_status::BlockStatus;
use ethcore::client::{ClientReport, EnvInfo};
use ethcore::engines::{epoch, Engine, EpochChange, EpochTransition, Proof, Unsure};
use ethcore::engines::{epoch, EthEngine, EpochChange, EpochTransition, Proof};
use ethcore::machine::EthereumMachine;
use ethcore::error::BlockImportError;
use ethcore::ids::BlockId;
use ethcore::header::{BlockNumber, Header};
Expand Down Expand Up @@ -117,7 +118,7 @@ pub trait LightChainClient: Send + Sync {
fn env_info(&self, id: BlockId) -> Option<EnvInfo>;

/// Get a handle to the consensus engine.
fn engine(&self) -> &Arc<Engine>;
fn engine(&self) -> &Arc<EthEngine>;

/// Query whether a block is known.
fn is_known(&self, hash: &H256) -> bool;
Expand Down Expand Up @@ -165,7 +166,7 @@ impl<T: LightChainClient> AsLightClient for T {
/// Light client implementation.
pub struct Client<T> {
queue: HeaderQueue,
engine: Arc<Engine>,
engine: Arc<EthEngine>,
chain: HeaderChain,
report: RwLock<ClientReport>,
import_lock: Mutex<()>,
Expand Down Expand Up @@ -381,7 +382,7 @@ impl<T: ChainDataFetcher> Client<T> {
}

/// Get a handle to the verification engine.
pub fn engine(&self) -> &Arc<Engine> {
pub fn engine(&self) -> &Arc<EthEngine> {
&self.engine
}

Expand Down Expand Up @@ -444,7 +445,7 @@ impl<T: ChainDataFetcher> Client<T> {
};

// Verify Block Family
let verify_family_result = self.engine.verify_block_family(&verified_header, &parent_header.decode(), None);
let verify_family_result = self.engine.verify_block_family(&verified_header, &parent_header.decode());
if let Err(e) = verify_family_result {
warn!(target: "client", "Stage 3 block verification failed for #{} ({})\nError: {:?}",
verified_header.number(), verified_header.hash(), e);
Expand All @@ -453,7 +454,7 @@ impl<T: ChainDataFetcher> Client<T> {
};

// "external" verification.
let verify_external_result = self.engine.verify_block_external(&verified_header, None);
let verify_external_result = self.engine.verify_block_external(&verified_header);
if let Err(e) = verify_external_result {
warn!(target: "client", "Stage 4 block verification failed for #{} ({})\nError: {:?}",
verified_header.number(), verified_header.hash(), e);
Expand All @@ -465,50 +466,54 @@ impl<T: ChainDataFetcher> Client<T> {
true
}

fn check_epoch_signal(&self, verified_header: &Header) -> Result<Option<Proof>, T::Error> {
let (mut block, mut receipts) = (None, None);

// First, check without providing auxiliary data.
match self.engine.signals_epoch_end(verified_header, None, None) {
EpochChange::No => return Ok(None),
EpochChange::Yes(proof) => return Ok(Some(proof)),
EpochChange::Unsure(unsure) => {
let (b, r) = match unsure {
Unsure::NeedsBody =>
(Some(self.fetcher.block_body(verified_header)), None),
Unsure::NeedsReceipts =>
(None, Some(self.fetcher.block_receipts(verified_header))),
Unsure::NeedsBoth => (
Some(self.fetcher.block_body(verified_header)),
Some(self.fetcher.block_receipts(verified_header)),
),
fn check_epoch_signal(&self, verified_header: &Header) -> Result<Option<Proof<EthereumMachine>>, T::Error> {
use ethcore::machine::{AuxiliaryRequest, AuxiliaryData};

let mut block: Option<Vec<u8>> = None;
let mut receipts: Option<Vec<_>> = None;

loop {


let is_signal = {
let auxiliary = AuxiliaryData {
bytes: block.as_ref().map(|x| &x[..]),
receipts: receipts.as_ref().map(|x| &x[..]),
};

if let Some(b) = b {
block = Some(b.into_future().wait()?.into_inner());
}
self.engine.signals_epoch_end(verified_header, auxiliary)
};

if let Some(r) = r {
receipts = Some(r.into_future().wait()?);
// check with any auxiliary data fetched so far
match is_signal {
EpochChange::No => return Ok(None),
EpochChange::Yes(proof) => return Ok(Some(proof)),
EpochChange::Unsure(unsure) => {
let (b, r) = match unsure {
AuxiliaryRequest::Body =>
(Some(self.fetcher.block_body(verified_header)), None),
AuxiliaryRequest::Receipts =>
(None, Some(self.fetcher.block_receipts(verified_header))),
AuxiliaryRequest::Both => (
Some(self.fetcher.block_body(verified_header)),
Some(self.fetcher.block_receipts(verified_header)),
),
};

if let Some(b) = b {
block = Some(b.into_future().wait()?.into_inner());
}

if let Some(r) = r {
receipts = Some(r.into_future().wait()?);
}
}
}
}

let block = block.as_ref().map(|x| &x[..]);
let receipts = receipts.as_ref().map(|x| &x[..]);

// Check again now that required data has been fetched.
match self.engine.signals_epoch_end(verified_header, block, receipts) {
EpochChange::No => return Ok(None),
EpochChange::Yes(proof) => return Ok(Some(proof)),
EpochChange::Unsure(_) =>
panic!("Detected faulty engine implementation: requests additional \
data to check epoch end signal when everything necessary provided"),
}
}

// attempts to fetch the epoch proof from the network until successful.
fn write_pending_proof(&self, header: &Header, proof: Proof) -> Result<(), T::Error> {
fn write_pending_proof(&self, header: &Header, proof: Proof<EthereumMachine>) -> Result<(), T::Error> {
let proof = match proof {
Proof::Known(known) => known,
Proof::WithState(state_dependent) => {
Expand Down Expand Up @@ -568,7 +573,7 @@ impl<T: ChainDataFetcher> LightChainClient for Client<T> {
Client::env_info(self, id)
}

fn engine(&self) -> &Arc<Engine> {
fn engine(&self) -> &Arc<EthEngine> {
Client::engine(self)
}

Expand Down
17 changes: 9 additions & 8 deletions ethcore/light/src/on_demand/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ use std::sync::Arc;

use ethcore::basic_account::BasicAccount;
use ethcore::encoded;
use ethcore::engines::{Engine, StateDependentProof};
use ethcore::receipt::{Receipt, TransactionOutcome};
use ethcore::engines::{EthEngine, StateDependentProof};
use ethcore::machine::EthereumMachine;
use ethcore::receipt::Receipt;
use ethcore::state::{self, ProvedExecution};
use ethcore::transaction::SignedTransaction;
use vm::EnvInfo;
Expand Down Expand Up @@ -843,7 +844,7 @@ pub struct TransactionProof {
// TODO: it's not really possible to provide this if the header is unknown.
pub env_info: EnvInfo,
/// Consensus engine.
pub engine: Arc<Engine>,
pub engine: Arc<EthEngine>,
}

impl TransactionProof {
Expand All @@ -858,7 +859,7 @@ impl TransactionProof {
state_items,
root,
&self.tx,
&*self.engine,
self.engine.machine(),
&self.env_info,
);

Expand All @@ -877,15 +878,15 @@ pub struct Signal {
/// Block hash and number to fetch proof for.
pub hash: H256,
/// Consensus engine, used to check the proof.
pub engine: Arc<Engine>,
pub engine: Arc<EthEngine>,
/// Special checker for the proof.
pub proof_check: Arc<StateDependentProof>,
pub proof_check: Arc<StateDependentProof<EthereumMachine>>,
}

impl Signal {
/// Check the signal, returning the signal or indicate that it's bad.
pub fn check_response(&self, _: &Mutex<::cache::Cache>, signal: &[u8]) -> Result<Vec<u8>, Error> {
self.proof_check.check_proof(&*self.engine, signal)
self.proof_check.check_proof(self.engine.machine(), signal)
.map(|_| signal.to_owned())
.map_err(|_| Error::BadProof)
}
Expand All @@ -904,7 +905,7 @@ mod tests {
use ethcore::client::{BlockChainClient, TestBlockChainClient, EachBlockWith};
use ethcore::header::Header;
use ethcore::encoded;
use ethcore::receipt::Receipt;
use ethcore::receipt::{Receipt, TransactionOutcome};

fn make_cache() -> ::cache::Cache {
::cache::Cache::new(Default::default(), ::time::Duration::seconds(1))
Expand Down
4 changes: 3 additions & 1 deletion ethcore/res/constructor.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
{
"name": "GenesisConstructor",
"engine": {
"null": null
"null": {
"params": {}
}
},
"params": {
"gasLimitBoundDivisor": "0x0400",
Expand Down
4 changes: 2 additions & 2 deletions ethcore/res/ethereum/byzantium_test.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
"minimumDifficulty": "0x020000",
"difficultyBoundDivisor": "0x0800",
"durationLimit": "0x0d",
"blockReward": "0x4563918244F40000",
"homesteadTransition": "0x0",
"eip150Transition": "0x0",
"eip160Transition": "0x0",
"eip161abcTransition": "0x0",
"eip161dTransition": "0x0",
"maxCodeSize": 24576,
"eip649Reward": "0x29A2241AF62C0000",
"eip100bTransition": "0x0",
"eip649Transition": "0x0"
Expand All @@ -20,12 +20,12 @@
},
"params": {
"gasLimitBoundDivisor": "0x0400",
"blockReward": "0x4563918244F40000",
"registrar" : "0xc6d9d2cd449a754c494264e1809c50e34d64562b",
"accountStartNonce": "0x00",
"maximumExtraDataSize": "0x20",
"minGasLimit": "0x1388",
"networkID" : "0x1",
"maxCodeSize": 24576,
"eip98Transition": "0xffffffffffffffff",
"eip140Transition": "0x0",
"eip211Transition": "0x0",
Expand Down
2 changes: 1 addition & 1 deletion ethcore/res/ethereum/classic.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"minimumDifficulty": "0x020000",
"difficultyBoundDivisor": "0x0800",
"durationLimit": "0x0d",
"blockReward": "0x4563918244F40000",
"homesteadTransition": 1150000,
"eip150Transition": 2500000,
"eip160Transition": 3000000,
Expand All @@ -21,7 +22,6 @@
},
"params": {
"gasLimitBoundDivisor": "0x0400",
"blockReward": "0x4563918244F40000",
"registrar" : "0xc6d9d2cd449a754c494264e1809c50e34d64562b",
"accountStartNonce": "0x00",
"maximumExtraDataSize": "0x20",
Expand Down
4 changes: 2 additions & 2 deletions ethcore/res/ethereum/constantinople_test.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
"minimumDifficulty": "0x020000",
"difficultyBoundDivisor": "0x0800",
"durationLimit": "0x0d",
"blockReward": "0x4563918244F40000",
"homesteadTransition": "0x0",
"eip150Transition": "0x0",
"eip160Transition": "0x0",
"eip161abcTransition": "0x0",
"eip161dTransition": "0x0",
"maxCodeSize": 24576,
"eip649Reward": "0x29A2241AF62C0000",
"eip100bTransition": "0x0",
"eip649Transition": "0x0"
Expand All @@ -20,12 +20,12 @@
},
"params": {
"gasLimitBoundDivisor": "0x0400",
"blockReward": "0x4563918244F40000",
"registrar" : "0xc6d9d2cd449a754c494264e1809c50e34d64562b",
"accountStartNonce": "0x00",
"maximumExtraDataSize": "0x20",
"minGasLimit": "0x1388",
"networkID" : "0x1",
"maxCodeSize": 24576,
"eip98Transition": "0xffffffffffffffff",
"eip140Transition": "0x0",
"eip210Transition": "0x0",
Expand Down
8 changes: 4 additions & 4 deletions ethcore/res/ethereum/eip150_test.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,26 @@
"minimumDifficulty": "0x020000",
"difficultyBoundDivisor": "0x0800",
"durationLimit": "0x0d",
"blockReward": "0x4563918244F40000",
"homesteadTransition": "0x0",
"eip150Transition": "0x0",
"eip160Transition": "0x7fffffffffffffff",
"eip161abcTransition": "0x7fffffffffffffff",
"eip161dTransition": "0x7fffffffffffffff",
"maxCodeSize": 24576
"eip161dTransition": "0x7fffffffffffffff"
}
}
},
"params": {
"gasLimitBoundDivisor": "0x0400",
"blockReward": "0x4563918244F40000",
"registrar" : "0xc6d9d2cd449a754c494264e1809c50e34d64562b",
"accountStartNonce": "0x00",
"maximumExtraDataSize": "0x20",
"minGasLimit": "0x1388",
"networkID" : "0x1",
"eip98Transition": "0x7fffffffffffffff",
"eip86Transition": "0x7fffffffffffffff",
"eip155Transition": "0x7fffffffffffffff"
"eip155Transition": "0x7fffffffffffffff",
"maxCodeSize": 24576
},
"genesis": {
"seal": {
Expand Down
Loading