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

Backporting to beta #3149

Merged
merged 25 commits into from
Nov 3, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,5 @@

# Build artifacts
out/

.vscode
4 changes: 2 additions & 2 deletions ethcore/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ extern crate ethcore_ipc_codegen;

fn main() {
ethcore_ipc_codegen::derive_binary("src/types/mod.rs.in").unwrap();
ethcore_ipc_codegen::derive_ipc("src/client/traits.rs").unwrap();
ethcore_ipc_codegen::derive_ipc("src/client/chain_notify.rs").unwrap();
ethcore_ipc_codegen::derive_ipc_cond("src/client/traits.rs", cfg!(feature="ipc")).unwrap();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't remember changing this file...

ethcore_ipc_codegen::derive_ipc_cond("src/client/chain_notify.rs", cfg!(feature="ipc")).unwrap();
}
6 changes: 5 additions & 1 deletion ethcore/res/ethereum/classic.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@
"blockReward": "0x4563918244F40000",
"registrar" : "0xc6d9d2cd449a754c494264e1809c50e34d64562b",
"homesteadTransition": "0x118c30",
"eip150Transition": "0x2625a0"
"eip150Transition": "0x2625a0",
"eip155Transition": "0x7fffffffffffffff",
"eip160Transition": "0x7fffffffffffffff",
"eip161abcTransition": "0x7fffffffffffffff",
"eip161dTransition": "0x7fffffffffffffff"
}
}
},
Expand Down
6 changes: 5 additions & 1 deletion ethcore/res/ethereum/eip150_test.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@
"blockReward": "0x4563918244F40000",
"registrar" : "0xc6d9d2cd449a754c494264e1809c50e34d64562b",
"homesteadTransition": "0x0",
"eip150Transition": "0x0"
"eip150Transition": "0x0",
"eip155Transition": "0x7fffffffffffffff",
"eip160Transition": "0x7fffffffffffffff",
"eip161abcTransition": "0x7fffffffffffffff",
"eip161dTransition": "0x7fffffffffffffff"
}
}
},
Expand Down
47 changes: 47 additions & 0 deletions ethcore/res/ethereum/eip161_test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"name": "Homestead (Test)",
"engine": {
"Ethash": {
"params": {
"gasLimitBoundDivisor": "0x0400",
"minimumDifficulty": "0x020000",
"difficultyBoundDivisor": "0x0800",
"durationLimit": "0x0d",
"blockReward": "0x4563918244F40000",
"registrar" : "0xc6d9d2cd449a754c494264e1809c50e34d64562b",
"homesteadTransition": "0x0",
"eip150Transition": "0x0",
"eip155Transition": "0x7fffffffffffffff",
"eip160Transition": "0x0",
"eip161abcTransition": "0x0",
"eip161dTransition": "0x0"
}
}
},
"params": {
"accountStartNonce": "0x00",
"maximumExtraDataSize": "0x20",
"minGasLimit": "0x1388",
"networkID" : "0x1"
},
"genesis": {
"seal": {
"ethereum": {
"nonce": "0x0000000000000042",
"mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000"
}
},
"difficulty": "0x400000000",
"author": "0x0000000000000000000000000000000000000000",
"timestamp": "0x00",
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"extraData": "0x11bbe8db4e347b4e8c937c1c8370e4b5ed33adb3db69cbdb7a38e1e50b1b82fa",
"gasLimit": "0x1388"
},
"accounts": {
"0000000000000000000000000000000000000001": { "balance": "1", "builtin": { "name": "ecrecover", "pricing": { "linear": { "base": 3000, "word": 0 } } } },
"0000000000000000000000000000000000000002": { "balance": "1", "builtin": { "name": "sha256", "pricing": { "linear": { "base": 60, "word": 12 } } } },
"0000000000000000000000000000000000000003": { "balance": "1", "builtin": { "name": "ripemd160", "pricing": { "linear": { "base": 600, "word": 120 } } } },
"0000000000000000000000000000000000000004": { "balance": "1", "builtin": { "name": "identity", "pricing": { "linear": { "base": 15, "word": 3 } } } }
}
}
6 changes: 5 additions & 1 deletion ethcore/res/ethereum/expanse.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@
"difficultyHardforkTransition": "0x59d9",
"difficultyHardforkBoundDivisor": "0x0200",
"bombDefuseTransition": "0x30d40",
"eip150Transition": "0x7fffffffffffffff"
"eip150Transition": "0x7fffffffffffffff",
"eip155Transition": "0x7fffffffffffffff",
"eip160Transition": "0x7fffffffffffffff",
"eip161abcTransition": "0x7fffffffffffffff",
"eip161dTransition": "0x7fffffffffffffff"
}
}
},
Expand Down
6 changes: 5 additions & 1 deletion ethcore/res/ethereum/frontier.json
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,11 @@
"0xbb9bc244d798123fde783fcc1c72d3bb8c189413",
"0x807640a13483f8ac783c557fcdf27be11ea4ac7a"
],
"eip150Transition": "0x259518"
"eip150Transition": "0x259518",
"eip155Transition": 2642462,
"eip160Transition": 2642462,
"eip161abcTransition": 2642462,
"eip161dTransition": 2642462
}
}
},
Expand Down
6 changes: 5 additions & 1 deletion ethcore/res/ethereum/frontier_like_test.json
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,11 @@
"0xbb9bc244d798123fde783fcc1c72d3bb8c189413",
"0x807640a13483f8ac783c557fcdf27be11ea4ac7a"
],
"eip150Transition": "0x7fffffffffffffff"
"eip150Transition": "0x7fffffffffffffff",
"eip155Transition": "0x7fffffffffffffff",
"eip160Transition": "0x7fffffffffffffff",
"eip161abcTransition": "0x7fffffffffffffff",
"eip161dTransition": "0x7fffffffffffffff"
}
}
},
Expand Down
6 changes: 5 additions & 1 deletion ethcore/res/ethereum/frontier_test.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@
"blockReward": "0x4563918244F40000",
"registrar" : "0xc6d9d2cd449a754c494264e1809c50e34d64562b",
"homesteadTransition": "0x7fffffffffffffff",
"eip150Transition": "0x7fffffffffffffff"
"eip150Transition": "0x7fffffffffffffff",
"eip155Transition": "0x7fffffffffffffff",
"eip160Transition": "0x7fffffffffffffff",
"eip161abcTransition": "0x7fffffffffffffff",
"eip161dTransition": "0x7fffffffffffffff"
}
}
},
Expand Down
6 changes: 5 additions & 1 deletion ethcore/res/ethereum/homestead_test.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@
"blockReward": "0x4563918244F40000",
"registrar" : "0xc6d9d2cd449a754c494264e1809c50e34d64562b",
"homesteadTransition": "0x0",
"eip150Transition": "0x7fffffffffffffff"
"eip150Transition": "0x7fffffffffffffff",
"eip155Transition": "0x7fffffffffffffff",
"eip160Transition": "0x7fffffffffffffff",
"eip161abcTransition": "0x7fffffffffffffff",
"eip161dTransition": "0x7fffffffffffffff"
}
}
},
Expand Down
6 changes: 5 additions & 1 deletion ethcore/res/ethereum/morden.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@
"blockReward": "0x4563918244F40000",
"registrar": "0x8e4e9b13d4b45cb0befc93c3061b1408f67316b2",
"homesteadTransition": "0x789b0",
"eip150Transition": "0x1b34d8"
"eip150Transition": "0x1b34d8",
"eip155Transition": "0x7fffffffffffffff",
"eip160Transition": "0x7fffffffffffffff",
"eip161abcTransition": "0x7fffffffffffffff",
"eip161dTransition": "0x7fffffffffffffff"
}
}
},
Expand Down
6 changes: 5 additions & 1 deletion ethcore/res/ethereum/olympic.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@
"blockReward": "0x14D1120D7B160000",
"registrar": "5e70c0bbcd5636e0f9f9316e9f8633feb64d4050",
"homesteadTransition": "0x7fffffffffffffff",
"eip150Transition": "0x7fffffffffffffff"
"eip150Transition": "0x7fffffffffffffff",
"eip155Transition": "0x7fffffffffffffff",
"eip160Transition": "0x7fffffffffffffff",
"eip161abcTransition": "0x7fffffffffffffff",
"eip161dTransition": "0x7fffffffffffffff"
}
}
},
Expand Down
2 changes: 1 addition & 1 deletion ethcore/res/ethereum/tests
Submodule tests updated 40 files
+1 −0 BlockchainTests/EIP150/README.md
+1 −0 BlockchainTests/Homestead/README.md
+6 −6 StateTests/EIP150/Homestead/stDelegatecallTest.json
+12 −12 StateTests/EIP150/Homestead/stPreCompiledContracts.json
+89 −90 StateTests/EIP150/Homestead/stSystemOperationsTest.json
+2,974 −0 StateTests/EIP158/EIP150/stChangedTests.json
+1,065 −0 StateTests/EIP158/EIP150/stEIPSpecificTest.json
+2,228 −0 StateTests/EIP158/EIP150/stEIPsingleCodeGasPrices.json
+688 −0 StateTests/EIP158/EIP150/stMemExpandingEIPCalls.json
+3,310 −0 StateTests/EIP158/Homestead/stBoundsTest.json
+7,159 −0 StateTests/EIP158/Homestead/stCallCodes.json
+2,649 −0 StateTests/EIP158/Homestead/stCallCreateCallCodeTest.json
+5,861 −0 StateTests/EIP158/Homestead/stCallDelegateCodes.json
+5,842 −0 StateTests/EIP158/Homestead/stCallDelegateCodesCallCode.json
+2,561 −0 StateTests/EIP158/Homestead/stDelegatecallTest.json
+320 −0 StateTests/EIP158/Homestead/stHomeSteadSpecific.json
+1,086 −0 StateTests/EIP158/Homestead/stInitCodeTest.json
+3,855 −0 StateTests/EIP158/Homestead/stLogTests.json
+4,091 −0 StateTests/EIP158/Homestead/stMemoryTest.json
+5,683 −0 StateTests/EIP158/Homestead/stPreCompiledContracts.json
+8,066 −0 StateTests/EIP158/Homestead/stQuadraticComplexityTest.json
+3,100 −0 StateTests/EIP158/Homestead/stRecursiveCreate.json
+1,307 −0 StateTests/EIP158/Homestead/stRefundTest.json
+527 −0 StateTests/EIP158/Homestead/stSpecialTest.json
+8,693 −0 StateTests/EIP158/Homestead/stSystemOperationsTest.json
+2,583 −0 StateTests/EIP158/Homestead/stTransactionTest.json
+3,286 −0 StateTests/EIP158/Homestead/stWalletTest.json
+1,281 −0 StateTests/EIP158/stCreateTest.json
+361 −0 StateTests/EIP158/stEIP158SpecificTest.json
+1,677 −0 StateTests/EIP158/stNonZeroCallsTest.json
+1,591 −0 StateTests/EIP158/stZeroCallsTest.json
+6 −6 StateTests/Homestead/stDelegatecallTest.json
+12 −12 StateTests/Homestead/stPreCompiledContracts.json
+15 −92 StateTests/Homestead/stSystemOperationsTest.json
+12 −12 StateTests/stPreCompiledContracts.json
+152 −153 StateTests/stSystemOperationsTest.json
+4 −4 VMTests/vmEnvironmentalInfoTest.json
+2 −2 VMTests/vmIOandFlowOperationsTest.json
+43 −0 VMTests/vmPushDupSwapTest.json
+44 −18 VMTests/vmSystemOperationsTest.json
6 changes: 5 additions & 1 deletion ethcore/res/ethereum/transition_test.json
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,11 @@
"0xbb9bc244d798123fde783fcc1c72d3bb8c189413",
"0x807640a13483f8ac783c557fcdf27be11ea4ac7a"
],
"eip150Transition": "0xa"
"eip150Transition": "0xa",
"eip155Transition": "0x7fffffffffffffff",
"eip160Transition": "0x7fffffffffffffff",
"eip161abcTransition": "0x7fffffffffffffff",
"eip161dTransition": "0x7fffffffffffffff"
}
}
},
Expand Down
10 changes: 8 additions & 2 deletions ethcore/src/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -289,11 +289,17 @@ impl Account {
pub fn storage_is_clean(&self) -> bool { self.storage_changes.is_empty() }

/// Check if account has zero nonce, balance, no code and no storage.
///
/// NOTE: Will panic if `!self.storage_is_clean()`
pub fn is_empty(&self) -> bool {
self.storage_changes.is_empty() &&
assert!(self.storage_is_clean(), "Account::is_empty() may only legally be called when storage is clean.");
self.is_null() && self.storage_root == SHA3_NULL_RLP
}

/// Check if account has zero nonce, balance, no code.
pub fn is_null(&self) -> bool {
self.balance.is_zero() &&
self.nonce.is_zero() &&
self.storage_root == SHA3_NULL_RLP &&
self.code_hash == SHA3_EMPTY
}

Expand Down
8 changes: 4 additions & 4 deletions ethcore/src/blockchain/blockchain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1279,7 +1279,7 @@ mod tests {
action: Action::Create,
value: 100.into(),
data: "601080600c6000396000f3006000355415600957005b60203560003555".from_hex().unwrap(),
}.sign(&"".sha3());
}.sign(&"".sha3(), None);


let b1a = canon_chain
Expand Down Expand Up @@ -1343,7 +1343,7 @@ mod tests {
action: Action::Create,
value: 100.into(),
data: "601080600c6000396000f3006000355415600957005b60203560003555".from_hex().unwrap(),
}.sign(&"".sha3());
}.sign(&"".sha3(), None);

let t2 = Transaction {
nonce: 1.into(),
Expand All @@ -1352,7 +1352,7 @@ mod tests {
action: Action::Create,
value: 100.into(),
data: "601080600c6000396000f3006000355415600957005b60203560003555".from_hex().unwrap(),
}.sign(&"".sha3());
}.sign(&"".sha3(), None);

let t3 = Transaction {
nonce: 2.into(),
Expand All @@ -1361,7 +1361,7 @@ mod tests {
action: Action::Create,
value: 100.into(),
data: "601080600c6000396000f3006000355415600957005b60203560003555".from_hex().unwrap(),
}.sign(&"".sha3());
}.sign(&"".sha3(), None);

let b1a = canon_chain
.with_transaction(t1.clone())
Expand Down
6 changes: 2 additions & 4 deletions ethcore/src/client/chain_notify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,10 @@
// along with Parity. If not, see <http://www.gnu.org/licenses/>.

use util::numbers::*;
use ipc::{IpcConfig, BinaryConvertError};
use std::collections::VecDeque;
use std::mem;
use ipc::{IpcConfig};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't remember changing this file


/// Represents what has to be handled by actor listening to chain events
#[derive(Ipc)]
#[ipc]
pub trait ChainNotify : Send + Sync {
/// fires when chain has new blocks
fn new_blocks(&self,
Expand Down
24 changes: 22 additions & 2 deletions ethcore/src/client/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ use io::*;
use views::{BlockView, HeaderView, BodyView};
use error::{ImportError, ExecutionError, CallError, BlockError, ImportResult};
use header::BlockNumber;
use state::State;
use state::{State, CleanupMode};
use spec::Spec;
use basic_types::Seal;
use engines::Engine;
Expand Down Expand Up @@ -259,6 +259,22 @@ impl Client {
}
}

/// The env info as of the best block.
fn latest_env_info(&self) -> EnvInfo {
let header_data = self.best_block_header();
let view = HeaderView::new(&header_data);

EnvInfo {
number: view.number(),
author: view.author(),
timestamp: view.timestamp(),
difficulty: view.difficulty(),
last_hashes: self.build_last_hashes(view.hash()),
gas_used: U256::default(),
gas_limit: view.gas_limit(),
}
}

fn build_last_hashes(&self, parent_hash: H256) -> Arc<LastHashes> {
{
let hashes = self.last_hashes.read();
Expand Down Expand Up @@ -714,7 +730,7 @@ impl BlockChainClient for Client {
let needed_balance = t.value + t.gas * t.gas_price;
if balance < needed_balance {
// give the sender a sufficient balance
state.add_balance(&sender, &(needed_balance - balance));
state.add_balance(&sender, &(needed_balance - balance), CleanupMode::NoEmpty);
}
let options = TransactOptions { tracing: analytics.transaction_tracing, vm_tracing: analytics.vm_tracing, check_nonce: false };
let mut ret = try!(Executive::new(&mut state, &env_info, &*self.engine, &self.vm_factory).transact(t, options));
Expand Down Expand Up @@ -1051,6 +1067,10 @@ impl BlockChainClient for Client {
fn pending_transactions(&self) -> Vec<SignedTransaction> {
self.miner.pending_transactions(self.chain.best_block_number())
}

fn signing_network_id(&self) -> Option<u8> {
self.engine.signing_network_id(&self.latest_env_info())
}
}

impl MiningBlockChainClient for Client {
Expand Down
8 changes: 6 additions & 2 deletions ethcore/src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,17 @@ pub use self::test_client::{TestBlockChainClient, EachBlockWith};
pub use types::trace_filter::Filter as TraceFilter;
pub use executive::{Executed, Executive, TransactOptions};
pub use env_info::{LastHashes, EnvInfo};
pub use self::chain_notify::{ChainNotify, ChainNotifyClient};
pub use self::chain_notify::ChainNotify;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't remember these changes.

#[cfg(feature="ipc")]
pub use self::chain_notify::ChainNotifyClient;
#[cfg(feature="ipc")]
pub use self::traits::RemoteClient;

pub use types::call_analytics::CallAnalytics;
pub use block_import_error::BlockImportError;
pub use transaction_import::TransactionImportResult;
pub use transaction_import::TransactionImportError;
pub use self::traits::{BlockChainClient, MiningBlockChainClient, RemoteClient};
pub use self::traits::{BlockChainClient, MiningBlockChainClient};

mod traits {
#![allow(dead_code, unused_assignments, unused_variables, missing_docs)] // codegen issues
Expand Down
4 changes: 3 additions & 1 deletion ethcore/src/client/test_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ impl TestBlockChainClient {
gas_price: U256::one(),
nonce: U256::zero()
};
let signed_tx = tx.sign(keypair.secret());
let signed_tx = tx.sign(keypair.secret(), None);
txs.append(&signed_tx);
txs.out()
},
Expand Down Expand Up @@ -569,4 +569,6 @@ impl BlockChainClient for TestBlockChainClient {
fn pending_transactions(&self) -> Vec<SignedTransaction> {
self.miner.pending_transactions(self.chain_info().best_block_number)
}

fn signing_network_id(&self) -> Option<u8> { None }
}
8 changes: 4 additions & 4 deletions ethcore/src/client/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,10 @@ use executive::Executed;
use env_info::LastHashes;
use types::call_analytics::CallAnalytics;
use block_import_error::BlockImportError;
use std::mem;
use std::collections::VecDeque;
use ipc::{IpcConfig, BinaryConvertError};
use ipc::{IpcConfig};
use types::blockchain_info::BlockChainInfo;
use types::block_status::BlockStatus;

#[derive(Ipc)]
#[ipc(client_ident="RemoteClient")]
/// Blockchain database client. Owns and manages a blockchain and a block queue.
pub trait BlockChainClient : Sync + Send {
Expand Down Expand Up @@ -215,6 +212,9 @@ pub trait BlockChainClient : Sync + Send {
Err(())
}
}

/// Get the preferred network ID to sign on
fn signing_network_id(&self) -> Option<u8> { None }
}

/// Extended client interface used for mining
Expand Down
3 changes: 3 additions & 0 deletions ethcore/src/engines/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ pub trait Engine : Sync + Send {
/// Verify a particular transaction is valid.
fn verify_transaction(&self, _t: &SignedTransaction, _header: &Header) -> Result<(), Error> { Ok(()) }

/// The network ID that transactions should be signed with.
fn signing_network_id(&self, _env_info: &EnvInfo) -> Option<u8> { None }

/// Verify the seal of a block. This is an auxilliary method that actually just calls other `verify_` methods
/// to get the job done. By default it must pass `verify_basic` and `verify_block_unordered`. If more or fewer
/// methods are needed for an Engine, this may be overridden.
Expand Down
Loading