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

EIPs 155, 160, 161 #2976

Merged
merged 29 commits into from
Nov 3, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
8a33788
The front-end for each hard-fork, also EIP-160.
gavofyork Oct 29, 2016
2775113
Address EIP161 a/c
gavofyork Oct 29, 2016
f52c588
Include EIP-161b
gavofyork Oct 29, 2016
9a75688
EIP-161 part d.
gavofyork Oct 29, 2016
416fe19
Fix test build.
gavofyork Oct 29, 2016
335949a
Fix one test, add another.
gavofyork Oct 29, 2016
c63e33f
Fix use of bloom & renaming.
gavofyork Oct 29, 2016
18f2150
Merge remote-tracking branch 'origin/master' into next-hardfork
gavofyork Oct 29, 2016
8d7728c
Initial groundwork for EIP-155
gavofyork Oct 30, 2016
3354369
Fix minor bug.
gavofyork Oct 30, 2016
7072f3e
Merge remote-tracking branch 'origin/master' into next-hardfork
gavofyork Oct 30, 2016
8d8599c
Fix all tests finally.
gavofyork Oct 30, 2016
c98a518
Rest of EIP-155.
gavofyork Oct 30, 2016
841f8dd
Add tests for EIP-155 algorithm.
gavofyork Oct 30, 2016
3f6f8e7
Merge remote-tracking branch 'origin/master' into next-hardfork
gavofyork Oct 30, 2016
22b7d6d
Minor reformat.
gavofyork Oct 30, 2016
d9103e3
Address grumbles.
gavofyork Oct 30, 2016
ed876a9
merge branch 'master' into next-hardfork
gavofyork Oct 31, 2016
eb00982
Remove unused code.
gavofyork Oct 31, 2016
5c7ece8
Merge remote-tracking branch 'origin/master' into next-hardfork
gavofyork Oct 31, 2016
3615c24
Merge remote-tracking branch 'origin/master' into next-hardfork
gavofyork Oct 31, 2016
8b31b74
Merge remote-tracking branch 'origin/master' into next-hardfork
gavofyork Oct 31, 2016
8d0a808
Fix SUICIDE gas mechanism and add consensus tests.
gavofyork Nov 1, 2016
95b717f
Remove commented code.
gavofyork Nov 2, 2016
cdfbeac
Merge branch 'master' into next-hardfork
gavofyork Nov 2, 2016
b916f41
Set Frontier hardfork block number
gavofyork Nov 3, 2016
f23be18
Fix warning.
gavofyork Nov 3, 2016
4c1d6b6
Merge remote-tracking branch 'origin/master' into next-hardfork
gavofyork Nov 3, 2016
99b0437
Transaction tests,
gavofyork Nov 3, 2016
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
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": "0x52dff57a8a1532e6afb3dc07e2af58bb9eb05b3d",
"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
14 changes: 7 additions & 7 deletions ethcore/src/blockchain/blockchain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1468,7 +1468,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 @@ -1532,7 +1532,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 @@ -1541,7 +1541,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 @@ -1550,7 +1550,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 Expand Up @@ -1856,23 +1856,23 @@ mod tests {
action: Action::Create,
value: 101.into(),
data: "601080600c6000396000f3006000355415600957005b60203560003555".from_hex().unwrap(),
}.sign(&"".sha3());
}.sign(&"".sha3(), None);
let t2 = Transaction {
nonce: 0.into(),
gas_price: 0.into(),
gas: 100_000.into(),
action: Action::Create,
value: 102.into(),
data: "601080600c6000396000f3006000355415600957005b60203560003555".from_hex().unwrap(),
}.sign(&"".sha3());
}.sign(&"".sha3(), None);
let t3 = Transaction {
nonce: 0.into(),
gas_price: 0.into(),
gas: 100_000.into(),
action: Action::Create,
value: 103.into(),
data: "601080600c6000396000f3006000355415600957005b60203560003555".from_hex().unwrap(),
}.sign(&"".sha3());
}.sign(&"".sha3(), None);
let tx_hash1 = t1.hash();
let tx_hash2 = t2.hash();
let tx_hash3 = t3.hash();
Expand Down
38 changes: 23 additions & 15 deletions ethcore/src/client/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ use io::*;
use views::{HeaderView, BodyView, BlockView};
use error::{ImportError, ExecutionError, CallError, BlockError, ImportResult, Error as EthcoreError};
use header::BlockNumber;
use state::State;
use state::{State, CleanupMode};
use spec::Spec;
use basic_types::Seal;
use engines::Engine;
Expand Down Expand Up @@ -268,6 +268,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 @@ -790,7 +806,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.factories.vm).transact(t, options));
Expand Down Expand Up @@ -1167,24 +1183,16 @@ impl BlockChainClient for Client {
fn pending_transactions(&self) -> Vec<SignedTransaction> {
self.miner.pending_transactions(self.chain.read().best_block_number())
}

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

impl MiningBlockChainClient for Client {

fn latest_schedule(&self) -> Schedule {
let header_data = self.best_block_header();
let view = HeaderView::new(&header_data);

let env_info = 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(),
};
self.engine.schedule(&env_info)
self.engine.schedule(&self.latest_env_info())
}

fn prepare_open_block(&self, author: Address, gas_range_target: (U256, U256), extra_data: Bytes) -> OpenBlock {
Expand Down
8 changes: 5 additions & 3 deletions ethcore/src/client/test_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,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 @@ -293,7 +293,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);
self.set_balance(signed_tx.sender().unwrap(), 10_000_000.into());
let res = self.miner.import_external_transactions(self, vec![signed_tx]);
let res = res.into_iter().next().unwrap().expect("Successful import");
Expand All @@ -314,7 +314,7 @@ pub fn get_temp_state_db() -> GuardedTempResult<StateDB> {

impl MiningBlockChainClient for TestBlockChainClient {
fn latest_schedule(&self) -> Schedule {
Schedule::new_homestead_gas_fix()
Schedule::new_post_eip150(true, true, true)
}

fn prepare_open_block(&self, author: Address, gas_range_target: (U256, U256), extra_data: Bytes) -> OpenBlock {
Expand Down Expand Up @@ -633,6 +633,8 @@ impl BlockChainClient for TestBlockChainClient {
self.miner.pending_transactions(self.chain_info().best_block_number)
}

fn signing_network_id(&self) -> Option<u8> { None }

fn mode(&self) -> Mode { Mode::Active }

fn set_mode(&self, _: Mode) { unimplemented!(); }
Expand Down
9 changes: 7 additions & 2 deletions ethcore/src/client/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,20 +215,25 @@ pub trait BlockChainClient : Sync + Send {
/// Calculate median gas price from recent blocks if they have any transactions.
fn gas_price_median(&self, sample_size: usize) -> Option<U256> {
let corpus = self.gas_price_corpus(sample_size);
corpus.get(corpus.len()/2).cloned()
corpus.get(corpus.len() / 2).cloned()
}

/// Get the gas price distribution based on recent blocks if they have any transactions.
fn gas_price_histogram(&self, sample_size: usize, bucket_number: usize) -> Option<Histogram> {
let raw_corpus = self.gas_price_corpus(sample_size);
let raw_len = raw_corpus.len();
// Throw out outliers.
let (corpus, _) = raw_corpus.split_at(raw_len-raw_len/40);
let (corpus, _) = raw_corpus.split_at(raw_len - raw_len / 40);
Histogram::new(corpus, bucket_number)
}

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

/// Get the mode.
fn mode(&self) -> Mode;

/// Set the mode.
fn set_mode(&self, mode: Mode);
}

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 @@ -108,6 +108,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