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

Commit edba366

Browse files
debrisarkpar
authored andcommitted
eip214, #4833
1 parent 62f170c commit edba366

File tree

23 files changed

+185
-103
lines changed

23 files changed

+185
-103
lines changed

ethcore/res/ethereum/frontier_like_test.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"homesteadTransition": "0x118c30",
1313
"daoHardforkTransition": "0x1d4c00",
1414
"daoHardforkBeneficiary": "0xbf4ed7b27f1d666546e30d74d50d173d20bca754",
15-
"daoHardforkAccounts": [
15+
"daoHardforkAccounts": [
1616
"0xd4fe7bc31cedb7bfb8a345f31e668033056b2728",
1717
"0xb3fb0e5aba0e20e5c49d252dfd30e102b171a425",
1818
"0x2c19c7f9ae8b751e37aeb2d93a699722395ae18f",

ethcore/res/ethereum/transition_test.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"homesteadTransition": "0x5",
1313
"daoHardforkTransition": "0x8",
1414
"daoHardforkBeneficiary": "0xbf4ed7b27f1d666546e30d74d50d173d20bca754",
15-
"daoHardforkAccounts": [
15+
"daoHardforkAccounts": [
1616
"0xd4fe7bc31cedb7bfb8a345f31e668033056b2728",
1717
"0xb3fb0e5aba0e20e5c49d252dfd30e102b171a425",
1818
"0x2c19c7f9ae8b751e37aeb2d93a699722395ae18f",

ethcore/src/client/test_client.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ pub struct TestBlockChainClient {
5555
/// Blocks.
5656
pub blocks: RwLock<HashMap<H256, Bytes>>,
5757
/// Mapping of numbers to hashes.
58-
pub numbers: RwLock<HashMap<usize, H256>>,
58+
pub numbers: RwLock<HashMap<usize, H256>>,
5959
/// Genesis block hash.
6060
pub genesis_hash: H256,
6161
/// Last block hash.
@@ -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, true)
356+
Schedule::new_post_eip150(24576, true, true, true)
357357
}
358358

359359
fn prepare_open_block(&self, author: Address, gas_range_target: (U256, U256), extra_data: Bytes) -> OpenBlock {

ethcore/src/engines/authority_round.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,8 @@ use account_provider::AccountProvider;
2626
use block::*;
2727
use spec::CommonParams;
2828
use engines::{Call, Engine, Seal, EngineError};
29-
use header::{Header, BlockNumber};
29+
use header::Header;
3030
use error::{Error, TransactionError, BlockError};
31-
use evm::Schedule;
3231
use ethjson;
3332
use io::{IoContext, IoHandler, TimerToken, IoService};
3433
use builtin::Builtin;
@@ -293,11 +292,6 @@ impl Engine for AuthorityRound {
293292
]
294293
}
295294

296-
fn schedule(&self, block_number: BlockNumber) -> Schedule {
297-
let eip86 = block_number >= self.params.eip86_transition;
298-
Schedule::new_post_eip150(usize::max_value(), true, true, true, eip86)
299-
}
300-
301295
fn populate_from_parent(&self, header: &mut Header, parent: &Header, gas_floor_target: U256, _gas_ceil_target: U256) {
302296
// Chain scoring: total weight is sqrt(U256::max_value())*height - step
303297
let new_difficulty = U256::from(U128::max_value()) + header_step(parent).expect("Header has been verified; qed").into() - self.step.load().into();

ethcore/src/engines/instant_seal.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@ use util::{Address, HashMap};
1919
use builtin::Builtin;
2020
use engines::{Engine, Seal};
2121
use spec::CommonParams;
22-
use evm::Schedule;
2322
use block::ExecutedBlock;
24-
use header::BlockNumber;
2523

2624
/// An engine which does not provide any consensus mechanism, just seals blocks internally.
2725
pub struct InstantSeal {
@@ -58,11 +56,6 @@ impl Engine for InstantSeal {
5856
&self.builtins
5957
}
6058

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)
64-
}
65-
6659
fn seals_internally(&self) -> Option<bool> { Some(true) }
6760

6861
fn generate_seal(&self, _block: &ExecutedBlock) -> Seal {

ethcore/src/engines/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,9 @@ pub trait Engine : Sync + Send {
147147
fn params(&self) -> &CommonParams;
148148

149149
/// Get the EVM schedule for the given `block_number`.
150-
fn schedule(&self, block_number: BlockNumber) -> Schedule;
150+
fn schedule(&self, block_number: BlockNumber) -> Schedule {
151+
Schedule::from_params(block_number, self.params())
152+
}
151153

152154
/// Builtin-contracts we would like to see in the chain.
153155
/// (In principle these are just hints for the engine since that has the last word on them.)

ethcore/src/engines/tendermint/mod.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ use account_provider::AccountProvider;
3838
use block::*;
3939
use spec::CommonParams;
4040
use engines::{Engine, Seal, EngineError};
41-
use evm::Schedule;
4241
use state::CleanupMode;
4342
use io::IoService;
4443
use super::signer::EngineSigner;
@@ -404,11 +403,6 @@ impl Engine for Tendermint {
404403
]
405404
}
406405

407-
fn schedule(&self, block_number: BlockNumber) -> Schedule {
408-
let eip86 = block_number >= self.params.eip86_transition;
409-
Schedule::new_post_eip150(usize::max_value(), true, true, true, eip86)
410-
}
411-
412406
fn populate_from_parent(&self, header: &mut Header, parent: &Header, gas_floor_target: U256, _gas_ceil_target: U256) {
413407
// Chain scoring: total weight is sqrt(U256::max_value())*height - view
414408
let new_difficulty = U256::from(U128::max_value()) + consensus_view(parent).expect("Header has been verified; qed").into() - self.view.load(AtomicOrdering::SeqCst).into();

ethcore/src/ethereum/ethash.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -196,13 +196,13 @@ impl Engine for Arc<Ethash> {
196196
} else if block_number < self.ethash_params.eip150_transition {
197197
Schedule::new_homestead()
198198
} else {
199-
Schedule::new_post_eip150(
199+
let mut schedule = Schedule::new_post_eip150(
200200
self.ethash_params.max_code_size as usize,
201201
block_number >= self.ethash_params.eip160_transition,
202202
block_number >= self.ethash_params.eip161abc_transition,
203-
block_number >= self.ethash_params.eip161d_transition,
204-
block_number >= self.params.eip86_transition
205-
)
203+
block_number >= self.ethash_params.eip161d_transition);
204+
schedule.apply_params(block_number, self.params());
205+
schedule
206206
}
207207
}
208208

ethcore/src/evm/evm.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ pub enum Error {
6262
},
6363
/// Built-in contract failed on given input
6464
BuiltIn(&'static str),
65-
/// Returned on evm internal error. Should never be ignored during development.
65+
/// When execution tries to modify the state in static context
66+
MutableCallInStaticContext,
6667
/// Likely to cause consensus issues.
6768
Internal(String),
6869
}
@@ -90,6 +91,7 @@ impl fmt::Display for Error {
9091
OutOfStack { instruction, wanted, limit } => write!(f, "Out of stack {} {}/{}", instruction, wanted, limit),
9192
BuiltIn(name) => write!(f, "Built-in failed: {}", name),
9293
Internal(ref msg) => write!(f, "Internal error: {}", msg),
94+
MutableCallInStaticContext => write!(f, "Mutable call in static context"),
9395
}
9496
}
9597
}

ethcore/src/evm/ext.rs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -53,25 +53,24 @@ pub enum CreateContractAddress {
5353
}
5454

5555
/// Externalities interface for EVMs
56-
// TODO: [rob] associated error type instead of `trie::Result`. Not all EVMs are trie powered.
5756
pub trait Ext {
5857
/// Returns a value for given key.
59-
fn storage_at(&self, key: &H256) -> trie::Result<H256>;
58+
fn storage_at(&self, key: &H256) -> evm::Result<H256>;
6059

6160
/// Stores a value for given key.
62-
fn set_storage(&mut self, key: H256, value: H256) -> trie::Result<()>;
61+
fn set_storage(&mut self, key: H256, value: H256) -> evm::Result<()>;
6362

6463
/// Determine whether an account exists.
65-
fn exists(&self, address: &Address) -> trie::Result<bool>;
64+
fn exists(&self, address: &Address) -> evm::Result<bool>;
6665

6766
/// Determine whether an account exists and is not null (zero balance/nonce, no code).
68-
fn exists_and_not_null(&self, address: &Address) -> trie::Result<bool>;
67+
fn exists_and_not_null(&self, address: &Address) -> evm::Result<bool>;
6968

7069
/// Balance of the origin account.
71-
fn origin_balance(&self) -> trie::Result<U256>;
70+
fn origin_balance(&self) -> evm::Result<U256>;
7271

7372
/// Returns address balance.
74-
fn balance(&self, address: &Address) -> trie::Result<U256>;
73+
fn balance(&self, address: &Address) -> evm::Result<U256>;
7574

7675
/// Returns the hash of one of the 256 most recent complete blocks.
7776
fn blockhash(&mut self, number: &U256) -> H256;
@@ -99,21 +98,21 @@ pub trait Ext {
9998
) -> MessageCallResult;
10099

101100
/// Returns code at given address
102-
fn extcode(&self, address: &Address) -> trie::Result<Arc<Bytes>>;
101+
fn extcode(&self, address: &Address) -> evm::Result<Arc<Bytes>>;
103102

104103
/// Returns code size at given address
105-
fn extcodesize(&self, address: &Address) -> trie::Result<usize>;
104+
fn extcodesize(&self, address: &Address) -> evm::Result<usize>;
106105

107106
/// Creates log entry with given topics and data
108-
fn log(&mut self, topics: Vec<H256>, data: &[u8]);
107+
fn log(&mut self, topics: Vec<H256>, data: &[u8]) -> evm::Result<()>;
109108

110109
/// Should be called when transaction calls `RETURN` opcode.
111110
/// Returns gas_left if cost of returning the data is not too high.
112111
fn ret(self, gas: &U256, data: &ReturnData) -> evm::Result<U256>;
113112

114113
/// Should be called when contract commits suicide.
115114
/// Address to which funds should be refunded.
116-
fn suicide(&mut self, refund_address: &Address) -> trie::Result<()> ;
115+
fn suicide(&mut self, refund_address: &Address) -> evm::Result<()> ;
117116

118117
/// Returns schedule.
119118
fn schedule(&self) -> &Schedule;

0 commit comments

Comments
 (0)