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 1 commit
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
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 } } } }
}
}
2 changes: 1 addition & 1 deletion ethcore/res/ethereum/tests
Submodule tests updated 28 files
+1 −0 BlockchainTests/EIP150/README.md
+1 −0 BlockchainTests/Homestead/README.md
+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,694 −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
3 changes: 3 additions & 0 deletions ethcore/src/ethereum/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ pub fn new_homestead_test() -> Spec { load(include_bytes!("../../res/ethereum/ho
/// Create a new Homestead-EIP150 chain spec as though it never changed from Homestead/Frontier.
pub fn new_eip150_test() -> Spec { load(include_bytes!("../../res/ethereum/eip150_test.json")) }

/// Create a new Homestead-EIP150 chain spec as though it never changed from Homestead/Frontier.
pub fn new_eip161_test() -> Spec { load(include_bytes!("../../res/ethereum/eip161_test.json")) }

/// Create a new Frontier/Homestead/DAO chain spec with transition points at #5 and #8.
pub fn new_transition_test() -> Spec { load(include_bytes!("../../res/ethereum/transition_test.json")) }

Expand Down
3 changes: 3 additions & 0 deletions ethcore/src/evm/ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ pub trait Ext {
/// Determine whether an account exists and is not null (zero balance/nonce, no code).
fn exists_and_not_null(&self, address: &Address) -> bool;

/// Balance of the origin account.
fn origin_balance(&self) -> U256;

/// Returns address balance.
fn balance(&self, address: &Address) -> U256;

Expand Down
7 changes: 6 additions & 1 deletion ethcore/src/evm/interpreter/gasometer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,13 @@ impl<Gas: CostType> Gasometer<Gas> {
instructions::SUICIDE => {
let mut gas = Gas::from(schedule.suicide_gas);

let is_value_transfer = !ext.origin_balance().is_zero();
let address = u256_to_address(stack.peek(0));
if !ext.exists(&address) {
if (
!schedule.no_empty && !ext.exists(&address)
) || (
schedule.no_empty && is_value_transfer && !ext.exists_and_not_null(&address)
) {
gas = overflowing!(gas.overflow_add(schedule.suicide_to_new_account_cost.into()));
}

Expand Down
4 changes: 4 additions & 0 deletions ethcore/src/evm/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ impl Ext for FakeExt {
self.balances.get(address).map_or(false, |b| !b.is_zero())
}

fn origin_balance(&self) -> U256 {
unimplemented!()
}

fn balance(&self, address: &Address) -> U256 {
*self.balances.get(address).unwrap()
}
Expand Down
4 changes: 3 additions & 1 deletion ethcore/src/externalities.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ impl<'a, T, V> Ext for Externalities<'a, T, V> where T: 'a + Tracer, V: 'a + VMT
self.state.exists_and_not_null(address)
}

fn origin_balance(&self) -> U256 { self.balance(&self.origin_info.address) }

fn balance(&self, address: &Address) -> U256 {
self.state.balance(address)
}
Expand Down Expand Up @@ -276,7 +278,7 @@ impl<'a, T, V> Ext for Externalities<'a, T, V> where T: 'a + Tracer, V: 'a + VMT
// TODO [todr] To be consistent with CPP client we set balance to 0 in that case.
self.state.sub_balance(&address, &balance);
} else {
trace!("Suiciding {} -> {} (xfer: {})", address, refund_address, balance);
trace!(target: "ext", "Suiciding {} -> {} (xfer: {})", address, refund_address, balance);
self.state.transfer_balance(&address, refund_address, &balance, self.substate.to_cleanup_mode(&self.schedule));
}

Expand Down
1 change: 1 addition & 0 deletions ethcore/src/json_tests/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ pub fn json_chain_test(json_data: &[u8], era: ChainEra) -> Vec<String> {
ChainEra::Frontier => ethereum::new_frontier_test(),
ChainEra::Homestead => ethereum::new_homestead_test(),
ChainEra::Eip150 => ethereum::new_eip150_test(),
ChainEra::Eip161 => ethereum::new_eip161_test(),
ChainEra::TransitionTest => ethereum::new_transition_test(),
};
spec.set_genesis_state(state);
Expand Down
51 changes: 51 additions & 0 deletions ethcore/src/json_tests/eip161_state.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// Copyright 2015, 2016 Ethcore (UK) Ltd.
// This file is part of Parity.

// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// Parity is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.

use super::test_common::*;
use tests::helpers::*;
use super::state::json_chain_test;

fn do_json_test(json_data: &[u8]) -> Vec<String> {
json_chain_test(json_data, ChainEra::Eip161)
}

declare_test!{StateTests_EIP158_stEIP158SpecificTest, "StateTests/EIP158/stEIP158SpecificTest"}
declare_test!{StateTests_EIP158_stNonZeroCallsTest, "StateTests/EIP158/stNonZeroCallsTest"}
declare_test!{StateTests_EIP158_stZeroCallsTest, "StateTests/EIP158/stZeroCallsTest"}

declare_test!{StateTests_EIP158_EIP150_stMemExpandingEIPCalls, "StateTests/EIP158/EIP150/stMemExpandingEIPCalls"}
declare_test!{StateTests_EIP158_EIP150_stEIPSpecificTest, "StateTests/EIP158/EIP150/stEIPSpecificTest"}
declare_test!{StateTests_EIP158_EIP150_stEIPsingleCodeGasPrices, "StateTests/EIP158/EIP150/stEIPsingleCodeGasPrices"}
declare_test!{StateTests_EIP158_EIP150_stChangedTests, "StateTests/EIP158/EIP150/stChangedTests"}

declare_test!{StateTests_EIP158_Homestead_stBoundsTest, "StateTests/EIP158/Homestead/stBoundsTest"}
declare_test!{StateTests_EIP158_Homestead_stCallCodes, "StateTests/EIP158/Homestead/stCallCodes"}
declare_test!{StateTests_EIP158_Homestead_stCallCreateCallCodeTest, "StateTests/EIP158/Homestead/stCallCreateCallCodeTest"}
declare_test!{StateTests_EIP158_Homestead_stCallDelegateCodes, "StateTests/EIP158/Homestead/stCallDelegateCodes"}
declare_test!{StateTests_EIP158_Homestead_stCallDelegateCodesCallCode, "StateTests/EIP158/Homestead/stCallDelegateCodesCallCode"}
declare_test!{StateTests_EIP158_Homestead_stDelegatecallTest, "StateTests/EIP158/Homestead/stDelegatecallTest"}
declare_test!{StateTests_EIP158_Homestead_stHomeSteadSpecific, "StateTests/EIP158/Homestead/stHomeSteadSpecific"}
declare_test!{StateTests_EIP158_Homestead_stInitCodeTest, "StateTests/EIP158/Homestead/stInitCodeTest"}
declare_test!{StateTests_EIP158_Homestead_stLogTests, "StateTests/EIP158/Homestead/stLogTests"}
declare_test!{heavy => StateTests_EIP158_Homestead_stMemoryTest, "StateTests/EIP158/Homestead/stMemoryTest"}
declare_test!{StateTests_EIP158_Homestead_stPreCompiledContracts, "StateTests/EIP158/Homestead/stPreCompiledContracts"}
declare_test!{heavy => StateTests_EIP158_Homestead_stQuadraticComplexityTest, "StateTests/EIP158/Homestead/stQuadraticComplexityTest"}
declare_test!{StateTests_EIP158_Homestead_stRecursiveCreate, "StateTests/EIP158/Homestead/stRecursiveCreate"}
declare_test!{StateTests_EIP158_Homestead_stRefundTest, "StateTests/EIP158/Homestead/stRefundTest"}
declare_test!{StateTests_EIP158_Homestead_stSpecialTest, "StateTests/EIP158/Homestead/stSpecialTest"}
declare_test!{StateTests_EIP158_Homestead_stSystemOperationsTest, "StateTests/EIP158/Homestead/stSystemOperationsTest"}
declare_test!{StateTests_EIP158_Homestead_stTransactionTest, "StateTests/EIP158/Homestead/stTransactionTest"}
declare_test!{StateTests_EIP158_Homestead_stWalletTest, "StateTests/EIP158/Homestead/stWalletTest"}
4 changes: 4 additions & 0 deletions ethcore/src/json_tests/executive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ impl<'a, T, V> Ext for TestExt<'a, T, V> where T: Tracer, V: VMTracer {
self.ext.balance(address)
}

fn origin_balance(&self) -> U256 {
self.ext.origin_balance()
}

fn blockhash(&self, number: &U256) -> H256 {
self.ext.blockhash(number)
}
Expand Down
1 change: 1 addition & 0 deletions ethcore/src/json_tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,5 @@ mod chain;
mod homestead_state;
mod homestead_chain;
mod eip150_state;
mod eip161_state;
mod trie;
4 changes: 4 additions & 0 deletions ethcore/src/json_tests/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,14 @@ pub fn json_chain_test(json_data: &[u8], era: ChainEra) -> Vec<String> {
ChainEra::Frontier => ethereum::new_mainnet_like().engine,
ChainEra::Homestead => ethereum::new_homestead_test().engine,
ChainEra::Eip150 => ethereum::new_eip150_test().engine,
ChainEra::Eip161 => ethereum::new_eip161_test().engine,
ChainEra::TransitionTest => ethereum::new_transition_test().engine,
};

for (name, test) in tests.into_iter() {
/* if name != "ZeroValue_SUICIDE" {
continue;
}*/
Copy link
Contributor

Choose a reason for hiding this comment

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

commented code

let mut fail = false;
{
let mut fail_unless = |cond: bool| if !cond && !fail {
Expand Down
1 change: 1 addition & 0 deletions ethcore/src/tests/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ pub enum ChainEra {
Frontier,
Homestead,
Eip150,
Eip161,
TransitionTest,
}

Expand Down
8 changes: 8 additions & 0 deletions evmbin/src/ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ impl Ext for FakeExt {
unimplemented!();
}

fn exists_and_not_null(&self, address: &Address) -> bool {
unimplemented!();
}

fn origin_balance(&self) -> U256 {
unimplemented!();
}

fn balance(&self, _address: &Address) -> U256 {
unimplemented!();
}
Expand Down