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

Commit f492b79

Browse files
committed
EIP-86
1 parent b27138e commit f492b79

Some content is hidden

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

49 files changed

+344
-246
lines changed

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
@@ -23,7 +23,8 @@
2323
"maximumExtraDataSize": "0x20",
2424
"minGasLimit": "0x1388",
2525
"networkID" : "0x1",
26-
"eip98Transition": "0x7fffffffffffffff"
26+
"eip98Transition": "0x7fffffffffffffff",
27+
"eip86Transition": "0x7fffffffffffffff"
2728
},
2829
"genesis": {
2930
"seal": {

ethcore/res/ethereum/eip161_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": "0x7fffffffffffffff"
26+
"eip98Transition": "0x7fffffffffffffff",
27+
"eip86Transition": "0x7fffffffffffffff"
2728
},
2829
"genesis": {
2930
"seal": {

ethcore/res/ethereum/expanse.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@
2929
"minGasLimit": "0x1388",
3030
"networkID": "0x1",
3131
"subprotocolName": "exp",
32-
"eip98Transition": "0x7fffffffffffff"
32+
"eip98Transition": "0x7fffffffffffff",
33+
"eip86Transition": "0x7fffffffffffff"
3334
},
3435
"genesis": {
3536
"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": 333922,
2929
"forkCanonHash": "0x8737eb141d4f05db57af63fc8d3b4d4d8f9cddb0c4e1ab855de8c288fdc1924f",
30-
"eip98Transition": "0x7fffffffffffff"
30+
"eip98Transition": "0x7fffffffffffff",
31+
"eip86Transition": "0x7fffffffffffff"
3132
},
3233
"genesis": {
3334
"seal": {

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
@@ -956,7 +956,7 @@ impl BlockChainClient for Client {
956956
return Err(err.into())
957957
}
958958
}
959-
let lower = t.gas_required(&self.engine.schedule(&env_info)).into();
959+
let lower = t.gas_required(&self.engine.schedule(env_info.number)).into();
960960
if cond(lower)? {
961961
trace!(target: "estimate_gas", "estimate_gas succeeded with {}", lower);
962962
return Ok(lower)
@@ -1255,7 +1255,8 @@ impl BlockChainClient for Client {
12551255
.collect();
12561256
match (transaction, previous_receipts) {
12571257
(Some(transaction), Some(previous_receipts)) => {
1258-
Some(transaction_receipt(transaction, previous_receipts))
1258+
let schedule = self.engine().schedule(block_number);
1259+
Some(transaction_receipt(&schedule, transaction, previous_receipts))
12591260
},
12601261
_ => None,
12611262
}
@@ -1492,11 +1493,15 @@ impl BlockChainClient for Client {
14921493
.and_then(|r| r.get_address(&(name.as_bytes().sha3()), "A").ok())
14931494
.and_then(|a| if a.is_zero() { None } else { Some(a) })
14941495
}
1496+
1497+
fn eip86_transition(&self) -> u64 {
1498+
self.engine().params().eip86_transition
1499+
}
14951500
}
14961501

14971502
impl MiningBlockChainClient for Client {
14981503
fn latest_schedule(&self) -> Schedule {
1499-
self.engine.schedule(&self.latest_env_info())
1504+
self.engine.schedule(self.latest_env_info().number)
15001505
}
15011506

15021507
fn prepare_open_block(&self, author: Address, gas_range_target: (U256, U256), extra_data: Bytes) -> OpenBlock {
@@ -1654,7 +1659,7 @@ impl Drop for Client {
16541659

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

16601665
let sender = tx.sender();
@@ -1673,12 +1678,12 @@ fn transaction_receipt(mut tx: LocalizedTransaction, mut receipts: Vec<Receipt>)
16731678
transaction_hash: transaction_hash,
16741679
transaction_index: transaction_index,
16751680
block_hash: block_hash,
1676-
block_number:block_number,
1681+
block_number: block_number,
16771682
cumulative_gas_used: receipt.gas_used,
16781683
gas_used: receipt.gas_used - prior_gas_used,
16791684
contract_address: match tx.action {
16801685
Action::Call(_) => None,
1681-
Action::Create => Some(contract_address(&sender, &tx.nonce))
1686+
Action::Create => Some(contract_address(schedule.create_address, &sender, &tx.nonce, &tx.data.sha3()))
16821687
},
16831688
logs: receipt.logs.into_iter().enumerate().map(|(i, log)| LocalizedLogEntry {
16841689
entry: log,
@@ -1733,6 +1738,7 @@ mod tests {
17331738
#[test]
17341739
fn should_return_correct_log_index() {
17351740
use super::transaction_receipt;
1741+
use evm::schedule::Schedule;
17361742
use ethkey::KeyPair;
17371743
use log_entry::{LogEntry, LocalizedLogEntry};
17381744
use receipt::{Receipt, LocalizedReceipt};
@@ -1742,6 +1748,7 @@ mod tests {
17421748
// given
17431749
let key = KeyPair::from_secret_slice(&"test".sha3()).unwrap();
17441750
let secret = key.secret();
1751+
let schedule = Schedule::new_homestead();
17451752

17461753
let block_number = 1;
17471754
let block_hash = 5.into();
@@ -1785,7 +1792,7 @@ mod tests {
17851792
}];
17861793

17871794
// when
1788-
let receipt = transaction_receipt(transaction, receipts);
1795+
let receipt = transaction_receipt(&schedule, transaction, receipts);
17891796

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

ethcore/src/client/test_client.rs

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

353353
impl MiningBlockChainClient for TestBlockChainClient {
354354
fn latest_schedule(&self) -> Schedule {
355-
Schedule::new_post_eip150(24576, true, true, true)
355+
Schedule::new_post_eip150(24576, true, true, true, true)
356356
}
357357

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

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

760762
impl ProvingBlockChainClient for TestBlockChainClient {

ethcore/src/client/traits.rs

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

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

276279
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, 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 client::{Client, EngineClient};
3736
use state::CleanupMode;
@@ -230,8 +229,9 @@ impl Engine for AuthorityRound {
230229
]
231230
}
232231

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

237237
fn populate_from_parent(&self, header: &mut Header, parent: &Header, gas_floor_target: U256, _gas_ceil_target: U256) {
@@ -359,7 +359,6 @@ impl Engine for AuthorityRound {
359359
#[cfg(test)]
360360
mod tests {
361361
use util::*;
362-
use env_info::EnvInfo;
363362
use header::Header;
364363
use error::{Error, BlockError};
365364
use ethkey::Secret;
@@ -380,15 +379,7 @@ mod tests {
380379
#[test]
381380
fn can_return_schedule() {
382381
let engine = Spec::new_test_round().engine;
383-
let schedule = engine.schedule(&EnvInfo {
384-
number: 10000000,
385-
author: 0.into(),
386-
timestamp: 0,
387-
difficulty: 0.into(),
388-
last_hashes: Arc::new(vec![]),
389-
gas_used: 0.into(),
390-
gas_limit: 0.into(),
391-
});
382+
let schedule = engine.schedule(10000000);
392383

393384
assert!(schedule.stack_limit > 0);
394385
}

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) }

ethcore/src/engines/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ use env_info::EnvInfo;
4242
use error::Error;
4343
use spec::CommonParams;
4444
use evm::Schedule;
45-
use header::Header;
45+
use header::{Header, BlockNumber};
4646
use transaction::{UnverifiedTransaction, SignedTransaction};
4747
use client::Client;
4848

@@ -107,8 +107,8 @@ pub trait Engine : Sync + Send {
107107
/// Get the general parameters of the chain.
108108
fn params(&self) -> &CommonParams;
109109

110-
/// Get the EVM schedule for the given `env_info`.
111-
fn schedule(&self, env_info: &EnvInfo) -> Schedule;
110+
/// Get the EVM schedule for the given `block_number`.
111+
fn schedule(&self, block_number: BlockNumber) -> Schedule;
112112

113113
/// Builtin-contracts we would like to see in the chain.
114114
/// (In principle these are just hints for the engine since that has the last word on them.)
@@ -156,7 +156,7 @@ pub trait Engine : Sync + Send {
156156
// TODO: Add flags for which bits of the transaction to check.
157157
// TODO: consider including State in the params.
158158
fn verify_transaction_basic(&self, t: &UnverifiedTransaction, _header: &Header) -> Result<(), Error> {
159-
t.check_low_s()?;
159+
t.verify_basic(true, Some(self.params().network_id), true)?;
160160
Ok(())
161161
}
162162

0 commit comments

Comments
 (0)