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

EIP-86 #4697

Merged
merged 2 commits into from
Apr 19, 2017
Merged

EIP-86 #4697

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
7 changes: 7 additions & 0 deletions ethcore/light/src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ pub trait LightChainClient: Send + Sync {

/// Get the `i`th CHT root.
fn cht_root(&self, i: usize) -> Option<H256>;

/// Get the EIP-86 transition block number.
fn eip86_transition(&self) -> u64;
}

/// Something which can be treated as a `LightChainClient`.
Expand Down Expand Up @@ -384,4 +387,8 @@ impl LightChainClient for Client {
fn cht_root(&self, i: usize) -> Option<H256> {
Client::cht_root(self, i)
}

fn eip86_transition(&self) -> u64 {
self.engine().params().eip86_transition
}
}
3 changes: 2 additions & 1 deletion ethcore/res/ethereum/classic.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
"chainID": "0x3d",
"forkBlock": "0x1d4c00",
"forkCanonHash": "0x94365e3a8c0b35089c1d1195081fe7489b528a84b22199c916180db8b28ade7f",
"eip98Transition": "0x7fffffffffffff"
"eip98Transition": "0x7fffffffffffff",
"eip86Transition": "0x7fffffffffffff"
},
"genesis": {
"seal": {
Expand Down
3 changes: 2 additions & 1 deletion ethcore/res/ethereum/eip150_test.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
"maximumExtraDataSize": "0x20",
"minGasLimit": "0x1388",
"networkID" : "0x1",
"eip98Transition": "0x7fffffffffffffff"
"eip98Transition": "0x7fffffffffffffff",
"eip86Transition": "0x7fffffffffffffff"
},
"genesis": {
"seal": {
Expand Down
3 changes: 2 additions & 1 deletion ethcore/res/ethereum/eip161_test.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
"maximumExtraDataSize": "0x20",
"minGasLimit": "0x1388",
"networkID" : "0x1",
"eip98Transition": "0x7fffffffffffffff"
"eip98Transition": "0x7fffffffffffffff",
"eip86Transition": "0x7fffffffffffffff"
},
"genesis": {
"seal": {
Expand Down
3 changes: 2 additions & 1 deletion ethcore/res/ethereum/expanse.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
"networkID": "0x1",
"chainID": "0x2",
"subprotocolName": "exp",
"eip98Transition": "0x7fffffffffffff"
"eip98Transition": "0x7fffffffffffff",
"eip86Transition": "0x7fffffffffffff"
},
"genesis": {
"seal": {
Expand Down
3 changes: 2 additions & 1 deletion ethcore/res/ethereum/foundation.json
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,8 @@
"networkID" : "0x1",
"forkBlock": "0x1d4c00",
"forkCanonHash": "0x4985f5ca3d2afbec36529aa96f74de3cc10a2a4a6c44f2157a57d2c6059a11bb",
"eip98Transition": "0x7fffffffffffff"
"eip98Transition": "0x7fffffffffffff",
"eip86Transition": "0x7fffffffffffff"
},
"genesis": {
"seal": {
Expand Down
3 changes: 2 additions & 1 deletion ethcore/res/ethereum/frontier_like_test.json
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,8 @@
"maximumExtraDataSize": "0x20",
"minGasLimit": "0x1388",
"networkID" : "0x1",
"eip98Transition": "0x7fffffffffffff"
"eip98Transition": "0x7fffffffffffff",
"eip86Transition": "0x7fffffffffffff"
},
"genesis": {
"seal": {
Expand Down
3 changes: 2 additions & 1 deletion ethcore/res/ethereum/frontier_test.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
"maximumExtraDataSize": "0x20",
"minGasLimit": "0x1388",
"networkID" : "0x1",
"eip98Transition": "0x7fffffffffffff"
"eip98Transition": "0x7fffffffffffff",
"eip86Transition": "0x7fffffffffffff"
},
"genesis": {
"seal": {
Expand Down
3 changes: 2 additions & 1 deletion ethcore/res/ethereum/homestead_test.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
"maximumExtraDataSize": "0x20",
"minGasLimit": "0x1388",
"networkID" : "0x1",
"eip98Transition": "0x7fffffffffffff"
"eip98Transition": "0x7fffffffffffff",
"eip86Transition": "0x7fffffffffffff"
},
"genesis": {
"seal": {
Expand Down
3 changes: 2 additions & 1 deletion ethcore/res/ethereum/morden.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
"chainID": "0x3e",
"forkBlock": "0x1b34d8",
"forkCanonHash": "0xf376243aeff1f256d970714c3de9fd78fa4e63cf63e32a51fe1169e375d98145",
"eip98Transition": "0x7fffffffffffff"
"eip98Transition": "0x7fffffffffffff",
"eip86Transition": "0x7fffffffffffff"
},
"genesis": {
"seal": {
Expand Down
3 changes: 2 additions & 1 deletion ethcore/res/ethereum/olympic.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
"maximumExtraDataSize": "0x0400",
"minGasLimit": "125000",
"networkID" : "0x0",
"eip98Transition": "0x7fffffffffffff"
"eip98Transition": "0x7fffffffffffff",
"eip86Transition": "0x7fffffffffffff"
},
"genesis": {
"seal": {
Expand Down
3 changes: 2 additions & 1 deletion ethcore/res/ethereum/ropsten.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
"networkID" : "0x3",
"forkBlock": 641350,
"forkCanonHash": "0x8033403e9fe5811a7b6d6b469905915de1c59207ce2172cbcf5d6ff14fa6a2eb",
"eip98Transition": "0x7fffffffffffff"
"eip98Transition": "0x7fffffffffffff",
"eip86Transition": "0x7fffffffffffff"
},
"genesis": {
"seal": {
Expand Down
2 changes: 1 addition & 1 deletion ethcore/res/ethereum/tests
Submodule tests updated 23 files
+2 −2 GeneralStateTests/stTransactionTest/TransactionToAddressh160minusOne.json
+374 −0 GeneralStateTests/stTransactionTest/zeroSigTransacrionCreate.json
+374 −0 GeneralStateTests/stTransactionTest/zeroSigTransacrionCreatePrice0.json
+702 −0 GeneralStateTests/stTransactionTest/zeroSigTransaction.json
+702 −0 GeneralStateTests/stTransactionTest/zeroSigTransaction0Price.json
+541 −0 GeneralStateTests/stTransactionTest/zeroSigTransactionInvChainID.json
+541 −0 GeneralStateTests/stTransactionTest/zeroSigTransactionInvNonce.json
+541 −0 GeneralStateTests/stTransactionTest/zeroSigTransactionInvNonce2.json
+702 −0 GeneralStateTests/stTransactionTest/zeroSigTransactionOOG.json
+3 −6 TransactionTests/EIP155/ttTransactionTestEip155VitaliksTests.json
+3 −6 TransactionTests/Homestead/ttTransactionTestEip155VitaliksTests.json
+67 −31 TransactionTests/Metropolis/ttMetropolisTest.json
+167 −182 TransactionTests/Metropolis/ttTransactionTestZeroSig.json
+105 −0 src/GeneralStateTestsFiller/stTransactionTest/zeroSigTransacrionCreateFiller.json
+105 −0 src/GeneralStateTestsFiller/stTransactionTest/zeroSigTransacrionCreatePrice0Filler.json
+119 −0 src/GeneralStateTestsFiller/stTransactionTest/zeroSigTransaction0PriceFiller.json
+119 −0 src/GeneralStateTestsFiller/stTransactionTest/zeroSigTransactionFiller.json
+65 −0 src/GeneralStateTestsFiller/stTransactionTest/zeroSigTransactionInvChainIDFiller.json
+83 −0 src/GeneralStateTestsFiller/stTransactionTest/zeroSigTransactionInvNonce2Filler.json
+83 −0 src/GeneralStateTestsFiller/stTransactionTest/zeroSigTransactionInvNonceFiller.json
+83 −0 src/GeneralStateTestsFiller/stTransactionTest/zeroSigTransactionOOGFiller.json
+201 −3 src/TransactionTestsFiller/Metropolis/ttMetropolisTestFiller.json
+412 −91 src/TransactionTestsFiller/Metropolis/ttTransactionTestZeroSigFiller.json
5 changes: 3 additions & 2 deletions ethcore/res/ethereum/transition_test.json
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,12 @@
}
},
"params": {
"eip98Transition": "0x7fffffffffffffff",
"accountStartNonce": "0x00",
"maximumExtraDataSize": "0x20",
"minGasLimit": "0x1388",
"networkID" : "0x1"
"networkID" : "0x1",
"eip98Transition": "0x7fffffffffffff",
"eip86Transition": "0x7fffffffffffff"
},
"genesis": {
"seal": {
Expand Down
3 changes: 2 additions & 1 deletion ethcore/res/null.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"accountStartNonce": "0x0",
"maximumExtraDataSize": "0x20",
"minGasLimit": "0x1388",
"networkID" : "0x2"
"networkID" : "0x2",
"eip86Transition": "0x7fffffffffffff"
},
"genesis": {
"seal": {
Expand Down
21 changes: 14 additions & 7 deletions ethcore/src/client/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -960,7 +960,7 @@ impl BlockChainClient for Client {
return Err(err.into())
}
}
let lower = t.gas_required(&self.engine.schedule(&env_info)).into();
let lower = t.gas_required(&self.engine.schedule(env_info.number)).into();
if cond(lower)? {
trace!(target: "estimate_gas", "estimate_gas succeeded with {}", lower);
return Ok(lower)
Expand Down Expand Up @@ -1259,7 +1259,8 @@ impl BlockChainClient for Client {
.collect();
match (transaction, previous_receipts) {
(Some(transaction), Some(previous_receipts)) => {
Some(transaction_receipt(transaction, previous_receipts))
let schedule = self.engine().schedule(block_number);
Some(transaction_receipt(&schedule, transaction, previous_receipts))
},
_ => None,
}
Expand Down Expand Up @@ -1501,11 +1502,15 @@ impl BlockChainClient for Client {
})
.and_then(|a| if a.is_zero() { None } else { Some(a) })
}

fn eip86_transition(&self) -> u64 {
self.engine().params().eip86_transition
}
}

impl MiningBlockChainClient for Client {
fn latest_schedule(&self) -> Schedule {
self.engine.schedule(&self.latest_env_info())
self.engine.schedule(self.latest_env_info().number)
}

fn prepare_open_block(&self, author: Address, gas_range_target: (U256, U256), extra_data: Bytes) -> OpenBlock {
Expand Down Expand Up @@ -1655,7 +1660,7 @@ impl Drop for Client {

/// Returns `LocalizedReceipt` given `LocalizedTransaction`
/// and a vector of receipts from given block up to transaction index.
fn transaction_receipt(mut tx: LocalizedTransaction, mut receipts: Vec<Receipt>) -> LocalizedReceipt {
fn transaction_receipt(schedule: &Schedule, mut tx: LocalizedTransaction, mut receipts: Vec<Receipt>) -> LocalizedReceipt {
assert_eq!(receipts.len(), tx.transaction_index + 1, "All previous receipts are provided.");

let sender = tx.sender();
Expand All @@ -1674,12 +1679,12 @@ fn transaction_receipt(mut tx: LocalizedTransaction, mut receipts: Vec<Receipt>)
transaction_hash: transaction_hash,
transaction_index: transaction_index,
block_hash: block_hash,
block_number:block_number,
block_number: block_number,
cumulative_gas_used: receipt.gas_used,
gas_used: receipt.gas_used - prior_gas_used,
contract_address: match tx.action {
Action::Call(_) => None,
Action::Create => Some(contract_address(&sender, &tx.nonce))
Action::Create => Some(contract_address(schedule.create_address, &sender, &tx.nonce, &tx.data.sha3()))
},
logs: receipt.logs.into_iter().enumerate().map(|(i, log)| LocalizedLogEntry {
entry: log,
Expand Down Expand Up @@ -1734,6 +1739,7 @@ mod tests {
#[test]
fn should_return_correct_log_index() {
use super::transaction_receipt;
use evm::schedule::Schedule;
use ethkey::KeyPair;
use log_entry::{LogEntry, LocalizedLogEntry};
use receipt::{Receipt, LocalizedReceipt};
Expand All @@ -1743,6 +1749,7 @@ mod tests {
// given
let key = KeyPair::from_secret_slice(&"test".sha3()).unwrap();
let secret = key.secret();
let schedule = Schedule::new_homestead();

let block_number = 1;
let block_hash = 5.into();
Expand Down Expand Up @@ -1786,7 +1793,7 @@ mod tests {
}];

// when
let receipt = transaction_receipt(transaction, receipts);
let receipt = transaction_receipt(&schedule, transaction, receipts);

// then
assert_eq!(receipt, LocalizedReceipt {
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 @@ -353,7 +353,7 @@ pub fn get_temp_state_db() -> GuardedTempResult<StateDB> {

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

fn prepare_open_block(&self, author: Address, gas_range_target: (U256, U256), extra_data: Bytes) -> OpenBlock {
Expand Down Expand Up @@ -756,6 +756,8 @@ impl BlockChainClient for TestBlockChainClient {
fn registrar_address(&self) -> Option<Address> { None }

fn registry_address(&self, _name: String) -> Option<Address> { None }

fn eip86_transition(&self) -> u64 { u64::max_value() }
}

impl ProvingBlockChainClient for TestBlockChainClient {
Expand Down
3 changes: 3 additions & 0 deletions ethcore/src/client/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,9 @@ pub trait BlockChainClient : Sync + Send {

/// Get the address of a particular blockchain service, if available.
fn registry_address(&self, name: String) -> Option<Address>;

/// Get the EIP-86 transition block number.
fn eip86_transition(&self) -> u64;
}

impl IpcConfig for BlockChainClient { }
Expand Down
19 changes: 5 additions & 14 deletions ethcore/src/engines/authority_round.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,11 @@ use account_provider::AccountProvider;
use block::*;
use spec::CommonParams;
use engines::{Engine, Seal, EngineError};
use header::Header;
use header::{Header, BlockNumber};
use error::{Error, TransactionError, BlockError};
use evm::Schedule;
use ethjson;
use io::{IoContext, IoHandler, TimerToken, IoService};
use env_info::EnvInfo;
use builtin::Builtin;
use transaction::UnverifiedTransaction;
use client::{Client, EngineClient};
Expand Down Expand Up @@ -241,8 +240,9 @@ impl Engine for AuthorityRound {
]
}

fn schedule(&self, _env_info: &EnvInfo) -> Schedule {
Schedule::new_post_eip150(usize::max_value(), true, true, true)
fn schedule(&self, block_number: BlockNumber) -> Schedule {
Copy link
Contributor

Choose a reason for hiding this comment

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

why &EnvInfo -> BlockNumber?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

There's a number of places where Schedule is created from the block number number. This PR introduces quite a few more. Creating a fake EnvInfo struct seems wasteful. And furthermore since all of the data except for the block number is unreliable it may introduce subtle bugs if any future implementation will have to rely on any other field.

let eip86 = block_number >= self.params.eip86_transition;
Schedule::new_post_eip150(usize::max_value(), true, true, true, eip86)
}

fn populate_from_parent(&self, header: &mut Header, parent: &Header, gas_floor_target: U256, _gas_ceil_target: U256) {
Expand Down Expand Up @@ -387,7 +387,6 @@ impl Engine for AuthorityRound {
#[cfg(test)]
mod tests {
use util::*;
use env_info::EnvInfo;
use header::Header;
use error::{Error, BlockError};
use ethkey::Secret;
Expand All @@ -408,15 +407,7 @@ mod tests {
#[test]
fn can_return_schedule() {
let engine = Spec::new_test_round().engine;
let schedule = engine.schedule(&EnvInfo {
number: 10000000,
author: 0.into(),
timestamp: 0,
difficulty: 0.into(),
last_hashes: Arc::new(vec![]),
gas_used: 0.into(),
gas_limit: 0.into(),
});
let schedule = engine.schedule(10000000);

assert!(schedule.stack_limit > 0);
}
Expand Down
17 changes: 3 additions & 14 deletions ethcore/src/engines/basic_authority.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,10 @@ use block::*;
use builtin::Builtin;
use spec::CommonParams;
use engines::{Engine, Seal};
use env_info::EnvInfo;
use error::{BlockError, Error};
use evm::Schedule;
use ethjson;
use header::Header;
use header::{Header, BlockNumber};
use client::Client;
use super::signer::EngineSigner;
use super::validator_set::{ValidatorSet, new_validator_set};
Expand Down Expand Up @@ -86,7 +85,7 @@ impl Engine for BasicAuthority {
/// Additional engine-specific information for the user/developer concerning `header`.
fn extra_info(&self, _header: &Header) -> BTreeMap<String, String> { map!["signature".to_owned() => "TODO".to_owned()] }

fn schedule(&self, _env_info: &EnvInfo) -> Schedule {
fn schedule(&self, _block_number: BlockNumber) -> Schedule {
Schedule::new_homestead()
}

Expand Down Expand Up @@ -181,7 +180,6 @@ impl Engine for BasicAuthority {
mod tests {
use util::*;
use block::*;
use env_info::EnvInfo;
use error::{BlockError, Error};
use tests::helpers::*;
use account_provider::AccountProvider;
Expand All @@ -206,16 +204,7 @@ mod tests {
#[test]
fn can_return_schedule() {
let engine = new_test_authority().engine;
let schedule = engine.schedule(&EnvInfo {
number: 10000000,
author: 0.into(),
timestamp: 0,
difficulty: 0.into(),
last_hashes: Arc::new(vec![]),
gas_used: 0.into(),
gas_limit: 0.into(),
});

let schedule = engine.schedule(10000000);
assert!(schedule.stack_limit > 0);
}

Expand Down
7 changes: 4 additions & 3 deletions ethcore/src/engines/instant_seal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ use std::collections::BTreeMap;
use util::{Address, HashMap};
use builtin::Builtin;
use engines::{Engine, Seal};
use env_info::EnvInfo;
use spec::CommonParams;
use evm::Schedule;
use block::ExecutedBlock;
use header::BlockNumber;

/// An engine which does not provide any consensus mechanism, just seals blocks internally.
pub struct InstantSeal {
Expand Down Expand Up @@ -58,8 +58,9 @@ impl Engine for InstantSeal {
&self.builtins
}

fn schedule(&self, _env_info: &EnvInfo) -> Schedule {
Schedule::new_post_eip150(usize::max_value(), true, true, true)
fn schedule(&self, block_number: BlockNumber) -> Schedule {
let eip86 = block_number >= self.params.eip86_transition;
Schedule::new_post_eip150(usize::max_value(), true, true, true, eip86)
}

fn seals_internally(&self) -> Option<bool> { Some(true) }
Expand Down
Loading