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

Commit 52d6bcd

Browse files
committed
EIP-86
1 parent 1e6674f commit 52d6bcd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+433
-289
lines changed

ethcore/light/src/client/mod.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,9 @@ pub trait LightChainClient: Send + Sync {
106106

107107
/// Get the `i`th CHT root.
108108
fn cht_root(&self, i: usize) -> Option<H256>;
109+
110+
/// Get the EIP-86 transition block number.
111+
fn eip86_transition(&self) -> u64;
109112
}
110113

111114
/// Something which can be treated as a `LightChainClient`.
@@ -384,4 +387,8 @@ impl LightChainClient for Client {
384387
fn cht_root(&self, i: usize) -> Option<H256> {
385388
Client::cht_root(self, i)
386389
}
390+
391+
fn eip86_transition(&self) -> u64 {
392+
self.engine().params().eip86_transition
393+
}
387394
}

ethcore/res/ethereum/classic.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@
3030
"chainID": "0x3d",
3131
"forkBlock": "0x1d4c00",
3232
"forkCanonHash": "0x94365e3a8c0b35089c1d1195081fe7489b528a84b22199c916180db8b28ade7f",
33-
"eip98Transition": "0x7fffffffffffff"
33+
"eip98Transition": "0x7fffffffffffff",
34+
"eip86Transition": "0x7fffffffffffff"
3435
},
3536
"genesis": {
3637
"seal": {

ethcore/res/ethereum/eip150_test.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
"maximumExtraDataSize": "0x20",
2525
"minGasLimit": "0x1388",
2626
"networkID" : "0x1",
27-
"eip98Transition": "0x7fffffffffffffff"
27+
"eip98Transition": "0x7fffffffffffffff",
28+
"eip86Transition": "0x7fffffffffffffff"
2829
},
2930
"genesis": {
3031
"seal": {

ethcore/res/ethereum/eip161_test.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
"maximumExtraDataSize": "0x20",
2525
"minGasLimit": "0x1388",
2626
"networkID" : "0x1",
27-
"eip98Transition": "0x7fffffffffffffff"
27+
"eip98Transition": "0x7fffffffffffffff",
28+
"eip86Transition": "0x7fffffffffffffff"
2829
},
2930
"genesis": {
3031
"seal": {

ethcore/res/ethereum/expanse.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@
3030
"networkID": "0x1",
3131
"chainID": "0x2",
3232
"subprotocolName": "exp",
33-
"eip98Transition": "0x7fffffffffffff"
33+
"eip98Transition": "0x7fffffffffffff",
34+
"eip86Transition": "0x7fffffffffffff"
3435
},
3536
"genesis": {
3637
"seal": {

ethcore/res/ethereum/foundation.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,8 @@
147147
"networkID" : "0x1",
148148
"forkBlock": "0x1d4c00",
149149
"forkCanonHash": "0x4985f5ca3d2afbec36529aa96f74de3cc10a2a4a6c44f2157a57d2c6059a11bb",
150-
"eip98Transition": "0x7fffffffffffff"
150+
"eip98Transition": "0x7fffffffffffff",
151+
"eip86Transition": "0x7fffffffffffff"
151152
},
152153
"genesis": {
153154
"seal": {

ethcore/res/ethereum/frontier_like_test.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,8 @@
143143
"maximumExtraDataSize": "0x20",
144144
"minGasLimit": "0x1388",
145145
"networkID" : "0x1",
146-
"eip98Transition": "0x7fffffffffffff"
146+
"eip98Transition": "0x7fffffffffffff",
147+
"eip86Transition": "0x7fffffffffffff"
147148
},
148149
"genesis": {
149150
"seal": {

ethcore/res/ethereum/frontier_test.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
"maximumExtraDataSize": "0x20",
2424
"minGasLimit": "0x1388",
2525
"networkID" : "0x1",
26-
"eip98Transition": "0x7fffffffffffff"
26+
"eip98Transition": "0x7fffffffffffff",
27+
"eip86Transition": "0x7fffffffffffff"
2728
},
2829
"genesis": {
2930
"seal": {

ethcore/res/ethereum/homestead_test.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
"maximumExtraDataSize": "0x20",
2424
"minGasLimit": "0x1388",
2525
"networkID" : "0x1",
26-
"eip98Transition": "0x7fffffffffffff"
26+
"eip98Transition": "0x7fffffffffffff",
27+
"eip86Transition": "0x7fffffffffffff"
2728
},
2829
"genesis": {
2930
"seal": {

ethcore/res/ethereum/morden.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@
3030
"chainID": "0x3e",
3131
"forkBlock": "0x1b34d8",
3232
"forkCanonHash": "0xf376243aeff1f256d970714c3de9fd78fa4e63cf63e32a51fe1169e375d98145",
33-
"eip98Transition": "0x7fffffffffffff"
33+
"eip98Transition": "0x7fffffffffffff",
34+
"eip86Transition": "0x7fffffffffffff"
3435
},
3536
"genesis": {
3637
"seal": {

ethcore/res/ethereum/olympic.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
"maximumExtraDataSize": "0x0400",
2424
"minGasLimit": "125000",
2525
"networkID" : "0x0",
26-
"eip98Transition": "0x7fffffffffffff"
26+
"eip98Transition": "0x7fffffffffffff",
27+
"eip86Transition": "0x7fffffffffffff"
2728
},
2829
"genesis": {
2930
"seal": {

ethcore/res/ethereum/ropsten.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@
2727
"networkID" : "0x3",
2828
"forkBlock": 641350,
2929
"forkCanonHash": "0x8033403e9fe5811a7b6d6b469905915de1c59207ce2172cbcf5d6ff14fa6a2eb",
30-
"eip98Transition": "0x7fffffffffffff"
30+
"eip98Transition": "0x7fffffffffffff",
31+
"eip86Transition": "0x7fffffffffffff"
3132
},
3233
"genesis": {
3334
"seal": {

ethcore/res/ethereum/tests

Submodule tests updated 23 files

ethcore/res/ethereum/transition_test.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,11 +139,12 @@
139139
}
140140
},
141141
"params": {
142-
"eip98Transition": "0x7fffffffffffffff",
143142
"accountStartNonce": "0x00",
144143
"maximumExtraDataSize": "0x20",
145144
"minGasLimit": "0x1388",
146-
"networkID" : "0x1"
145+
"networkID" : "0x1",
146+
"eip98Transition": "0x7fffffffffffff",
147+
"eip86Transition": "0x7fffffffffffff"
147148
},
148149
"genesis": {
149150
"seal": {

ethcore/res/null.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
"accountStartNonce": "0x0",
88
"maximumExtraDataSize": "0x20",
99
"minGasLimit": "0x1388",
10-
"networkID" : "0x2"
10+
"networkID" : "0x2",
11+
"eip86Transition": "0x7fffffffffffff"
1112
},
1213
"genesis": {
1314
"seal": {

ethcore/src/client/client.rs

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -960,7 +960,7 @@ impl BlockChainClient for Client {
960960
return Err(err.into())
961961
}
962962
}
963-
let lower = t.gas_required(&self.engine.schedule(&env_info)).into();
963+
let lower = t.gas_required(&self.engine.schedule(env_info.number)).into();
964964
if cond(lower)? {
965965
trace!(target: "estimate_gas", "estimate_gas succeeded with {}", lower);
966966
return Ok(lower)
@@ -1259,7 +1259,8 @@ impl BlockChainClient for Client {
12591259
.collect();
12601260
match (transaction, previous_receipts) {
12611261
(Some(transaction), Some(previous_receipts)) => {
1262-
Some(transaction_receipt(transaction, previous_receipts))
1262+
let schedule = self.engine().schedule(block_number);
1263+
Some(transaction_receipt(&schedule, transaction, previous_receipts))
12631264
},
12641265
_ => None,
12651266
}
@@ -1501,11 +1502,15 @@ impl BlockChainClient for Client {
15011502
})
15021503
.and_then(|a| if a.is_zero() { None } else { Some(a) })
15031504
}
1505+
1506+
fn eip86_transition(&self) -> u64 {
1507+
self.engine().params().eip86_transition
1508+
}
15041509
}
15051510

15061511
impl MiningBlockChainClient for Client {
15071512
fn latest_schedule(&self) -> Schedule {
1508-
self.engine.schedule(&self.latest_env_info())
1513+
self.engine.schedule(self.latest_env_info().number)
15091514
}
15101515

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

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

16611666
let sender = tx.sender();
@@ -1674,12 +1679,12 @@ fn transaction_receipt(mut tx: LocalizedTransaction, mut receipts: Vec<Receipt>)
16741679
transaction_hash: transaction_hash,
16751680
transaction_index: transaction_index,
16761681
block_hash: block_hash,
1677-
block_number:block_number,
1682+
block_number: block_number,
16781683
cumulative_gas_used: receipt.gas_used,
16791684
gas_used: receipt.gas_used - prior_gas_used,
16801685
contract_address: match tx.action {
16811686
Action::Call(_) => None,
1682-
Action::Create => Some(contract_address(&sender, &tx.nonce))
1687+
Action::Create => Some(contract_address(schedule.create_address, &sender, &tx.nonce, &tx.data.sha3()))
16831688
},
16841689
logs: receipt.logs.into_iter().enumerate().map(|(i, log)| LocalizedLogEntry {
16851690
entry: log,
@@ -1734,6 +1739,7 @@ mod tests {
17341739
#[test]
17351740
fn should_return_correct_log_index() {
17361741
use super::transaction_receipt;
1742+
use evm::schedule::Schedule;
17371743
use ethkey::KeyPair;
17381744
use log_entry::{LogEntry, LocalizedLogEntry};
17391745
use receipt::{Receipt, LocalizedReceipt};
@@ -1743,6 +1749,7 @@ mod tests {
17431749
// given
17441750
let key = KeyPair::from_secret_slice(&"test".sha3()).unwrap();
17451751
let secret = key.secret();
1752+
let schedule = Schedule::new_homestead();
17461753

17471754
let block_number = 1;
17481755
let block_hash = 5.into();
@@ -1786,7 +1793,7 @@ mod tests {
17861793
}];
17871794

17881795
// when
1789-
let receipt = transaction_receipt(transaction, receipts);
1796+
let receipt = transaction_receipt(&schedule, transaction, receipts);
17901797

17911798
// then
17921799
assert_eq!(receipt, LocalizedReceipt {

ethcore/src/client/test_client.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ pub fn get_temp_state_db() -> GuardedTempResult<StateDB> {
353353

354354
impl MiningBlockChainClient for TestBlockChainClient {
355355
fn latest_schedule(&self) -> Schedule {
356-
Schedule::new_post_eip150(24576, true, true, true)
356+
Schedule::new_post_eip150(24576, true, true, true, true)
357357
}
358358

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

758758
fn registry_address(&self, _name: String) -> Option<Address> { None }
759+
760+
fn eip86_transition(&self) -> u64 { u64::max_value() }
759761
}
760762

761763
impl ProvingBlockChainClient for TestBlockChainClient {

ethcore/src/client/traits.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,9 @@ pub trait BlockChainClient : Sync + Send {
272272

273273
/// Get the address of a particular blockchain service, if available.
274274
fn registry_address(&self, name: String) -> Option<Address>;
275+
276+
/// Get the EIP-86 transition block number.
277+
fn eip86_transition(&self) -> u64;
275278
}
276279

277280
impl IpcConfig for BlockChainClient { }

ethcore/src/engines/authority_round.rs

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,11 @@ use account_provider::AccountProvider;
2626
use block::*;
2727
use spec::CommonParams;
2828
use engines::{Engine, Seal, EngineError};
29-
use header::Header;
29+
use header::{Header, BlockNumber};
3030
use error::{Error, TransactionError, BlockError};
3131
use evm::Schedule;
3232
use ethjson;
3333
use io::{IoContext, IoHandler, TimerToken, IoService};
34-
use env_info::EnvInfo;
3534
use builtin::Builtin;
3635
use transaction::UnverifiedTransaction;
3736
use client::{Client, EngineClient};
@@ -241,8 +240,9 @@ impl Engine for AuthorityRound {
241240
]
242241
}
243242

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

248248
fn populate_from_parent(&self, header: &mut Header, parent: &Header, gas_floor_target: U256, _gas_ceil_target: U256) {
@@ -387,7 +387,6 @@ impl Engine for AuthorityRound {
387387
#[cfg(test)]
388388
mod tests {
389389
use util::*;
390-
use env_info::EnvInfo;
391390
use header::Header;
392391
use error::{Error, BlockError};
393392
use ethkey::Secret;
@@ -408,15 +407,7 @@ mod tests {
408407
#[test]
409408
fn can_return_schedule() {
410409
let engine = Spec::new_test_round().engine;
411-
let schedule = engine.schedule(&EnvInfo {
412-
number: 10000000,
413-
author: 0.into(),
414-
timestamp: 0,
415-
difficulty: 0.into(),
416-
last_hashes: Arc::new(vec![]),
417-
gas_used: 0.into(),
418-
gas_limit: 0.into(),
419-
});
410+
let schedule = engine.schedule(10000000);
420411

421412
assert!(schedule.stack_limit > 0);
422413
}

ethcore/src/engines/basic_authority.rs

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,10 @@ use block::*;
2424
use builtin::Builtin;
2525
use spec::CommonParams;
2626
use engines::{Engine, Seal};
27-
use env_info::EnvInfo;
2827
use error::{BlockError, Error};
2928
use evm::Schedule;
3029
use ethjson;
31-
use header::Header;
30+
use header::{Header, BlockNumber};
3231
use client::Client;
3332
use super::signer::EngineSigner;
3433
use super::validator_set::{ValidatorSet, new_validator_set};
@@ -86,7 +85,7 @@ impl Engine for BasicAuthority {
8685
/// Additional engine-specific information for the user/developer concerning `header`.
8786
fn extra_info(&self, _header: &Header) -> BTreeMap<String, String> { map!["signature".to_owned() => "TODO".to_owned()] }
8887

89-
fn schedule(&self, _env_info: &EnvInfo) -> Schedule {
88+
fn schedule(&self, _block_number: BlockNumber) -> Schedule {
9089
Schedule::new_homestead()
9190
}
9291

@@ -181,7 +180,6 @@ impl Engine for BasicAuthority {
181180
mod tests {
182181
use util::*;
183182
use block::*;
184-
use env_info::EnvInfo;
185183
use error::{BlockError, Error};
186184
use tests::helpers::*;
187185
use account_provider::AccountProvider;
@@ -206,16 +204,7 @@ mod tests {
206204
#[test]
207205
fn can_return_schedule() {
208206
let engine = new_test_authority().engine;
209-
let schedule = engine.schedule(&EnvInfo {
210-
number: 10000000,
211-
author: 0.into(),
212-
timestamp: 0,
213-
difficulty: 0.into(),
214-
last_hashes: Arc::new(vec![]),
215-
gas_used: 0.into(),
216-
gas_limit: 0.into(),
217-
});
218-
207+
let schedule = engine.schedule(10000000);
219208
assert!(schedule.stack_limit > 0);
220209
}
221210

ethcore/src/engines/instant_seal.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ use std::collections::BTreeMap;
1818
use util::{Address, HashMap};
1919
use builtin::Builtin;
2020
use engines::{Engine, Seal};
21-
use env_info::EnvInfo;
2221
use spec::CommonParams;
2322
use evm::Schedule;
2423
use block::ExecutedBlock;
24+
use header::BlockNumber;
2525

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

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

6566
fn seals_internally(&self) -> Option<bool> { Some(true) }

0 commit comments

Comments
 (0)