* EIP-86

* Disable EIP-86 auto activation for now
This commit is contained in:
Arkadiy Paronyan
2017-04-19 14:30:00 +02:00
committed by GitHub
parent 0180b21dd1
commit b50fb71dd1
59 changed files with 433 additions and 289 deletions

View File

@@ -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)
@@ -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,
}
@@ -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 {
@@ -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();
@@ -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,
@@ -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};
@@ -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();
@@ -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 {

View File

@@ -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 {
@@ -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 {

View File

@@ -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 { }