From dabfa2c6634cc70845f6875b86db48a1af74c98c Mon Sep 17 00:00:00 2001 From: David Date: Thu, 29 Aug 2019 13:19:55 +0200 Subject: [PATCH 1/6] EIP 1884 Re-pricing of trie-size dependent operations (#10992) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Add client-traits crate Move the BlockInfo trait to new crate * New crate `machine` Contains code extracted from ethcore that defines `Machine`, `Externalities` and other execution related code. * Use new machine and client-traits crates in ethcore * Use new crates machine and client-traits instead of ethcore where appropriate * Fix tests * Don't re-export so many types from ethcore::client * Fixing more fallout from removing re-export * fix test * More fallout from not re-exporting types * Add some docs * cleanup * import the macro edition style * Tweak docs * Add missing import * remove unused ethabi_derive imports * Use latest ethabi-contract * Move many traits from ethcore/client/traits to client-traits crate Initial version of extracted Engine trait * Move snapshot related traits to the engine crate (eew) * Move a few snapshot related types to common_types Cleanup Executed as exported from machine crate * fix warning * Gradually introduce new engine crate: snapshot * ethcore typechecks with new engine crate * Sort out types outside ethcore * Add an EpochVerifier to ethash and use that in Engine.epoch_verifier() Cleanup * Document pub members * Sort out tests Sort out default impls for EpochVerifier * Add test-helpers feature and move EngineSigner impl to the right place * Sort out tests * Sort out tests and refactor verification types * Fix missing traits * More missing traits Fix Histogram * Fix tests and cleanup * cleanup * Put back needed logger import * Don't rexport common_types from ethcore/src/client Don't export ethcore::client::* * Remove files no longer used Use types from the engine crate Explicit exports from engine::engine * Get rid of itertools * Move a few more traits from ethcore to client-traits: BlockChainReset, ScheduleInfo, StateClient * Move ProvingBlockChainClient to client-traits * Don't re-export ForkChoice and Transition from ethcore * Address grumbles: sort imports, remove commented out code * Fix merge resolution error * Extract the Clique engine to own crate * Extract NullEngine and the block_reward module from ethcore * Extract InstantSeal engine to own crate * Extract remaining engines * Extract executive_state to own crate so it can be used by engine crates * Remove snapshot stuff from the engine crate * Put snapshot traits back in ethcore * cleanup * Remove stuff from ethcore * Don't use itertools * itertools in aura is legit-ish * More post-merge fixes * Re-export less types in client * cleanup * Extract spec to own crate * Put back the test-helpers from basic-authority * Fix ethcore benchmarks * Reduce the public api of ethcore/verification * WIP * Add Cargo.toml * Fix compilation outside ethcore * Audit uses of import_verified_blocks() and remove unneeded calls Cleanup * cleanup * Remove unused imports from ethcore * Cleanup * remove double semi-colons * Add missing generic param * More missing generics * Update ethcore/block-reward/Cargo.toml Co-Authored-By: Tomasz Drwięga * Update ethcore/engines/basic-authority/Cargo.toml Co-Authored-By: Tomasz Drwięga * Update ethcore/engines/ethash/Cargo.toml Co-Authored-By: Tomasz Drwięga * Update ethcore/engines/clique/src/lib.rs Co-Authored-By: Tomasz Drwięga * signers is already a ref * Add an EngineType enum to tighten up Engine.name() * Add CHAINID opcode * Introduce Snapshotting enum to distinguish the type of snapshots a chain uses * Rename supports_warp to snapshot_mode * Missing import * Add chain_id wherever we instantiate EnvInfo * more missing chain_id * Tell serde to ignore the chain_id field on Env * Update ethcore/src/snapshot/consensus/mod.rs Co-Authored-By: Tomasz Drwięga * Use the chain_id from the machine by adding chain_id() to the Ext trait * cleanup * add missing impl cleanup * missing import * Fix import * Add transition marker for EIP 1344 * double semi * Fix merge problem * cleanup * reprice SLOAD to 800 gas * Reprice BALANCE and EXTCODEHASH * Add SELFBALANCE opcode * Add test for SELFBALANCE Use InstructionParams.address as the self-address * Use easier to read values in test * merge conflict error * Fix a few warnings * Update ethcore/vm/src/schedule.rs Co-Authored-By: Andronik Ordian * more merge fallout --- ethcore/evm/src/evm.rs | 18 ++++++++++++------ ethcore/evm/src/instructions.rs | 3 +++ ethcore/evm/src/interpreter/mod.rs | 15 ++++++++++++--- ethcore/evm/src/tests.rs | 26 ++++++++++++++++++++++++++ ethcore/types/src/engines/params.rs | 13 +++++++++++++ ethcore/vm/src/ext.rs | 2 +- ethcore/vm/src/return_data.rs | 6 +----- ethcore/vm/src/schedule.rs | 17 ++++++++++++++--- json/src/spec/params.rs | 2 ++ 9 files changed, 84 insertions(+), 18 deletions(-) diff --git a/ethcore/evm/src/evm.rs b/ethcore/evm/src/evm.rs index f8a08b2b2e3..3c88155f2f5 100644 --- a/ethcore/evm/src/evm.rs +++ b/ethcore/evm/src/evm.rs @@ -44,12 +44,18 @@ pub trait Finalize { impl Finalize for Result { fn finalize(self, ext: E) -> Result { match self { - Ok(GasLeft::Known(gas_left)) => Ok(FinalizationResult { gas_left: gas_left, apply_state: true, return_data: ReturnData::empty() }), - Ok(GasLeft::NeedsReturn { gas_left, data, apply_state }) => ext.ret(&gas_left, &data, apply_state).map(|gas_left| FinalizationResult { - gas_left: gas_left, - apply_state: apply_state, - return_data: data, - }), + Ok(GasLeft::Known(gas_left)) => { + Ok(FinalizationResult { + gas_left, + apply_state: true, + return_data: ReturnData::empty() + }) + }, + Ok(GasLeft::NeedsReturn { gas_left, data, apply_state }) => { + ext.ret(&gas_left, &data, apply_state).map(|gas_left| + FinalizationResult { gas_left, apply_state, return_data: data } + ) + }, Err(err) => Err(err), } } diff --git a/ethcore/evm/src/instructions.rs b/ethcore/evm/src/instructions.rs index 1580f7b591d..b0a66c159e3 100644 --- a/ethcore/evm/src/instructions.rs +++ b/ethcore/evm/src/instructions.rs @@ -151,6 +151,8 @@ enum_with_from_u8! { GASLIMIT = 0x45, #[doc = "get chain ID"] CHAINID = 0x46, + #[doc = "get balance of own account"] + SELFBALANCE = 0x47, #[doc = "remove item from stack"] POP = 0x50, @@ -502,6 +504,7 @@ lazy_static! { arr[DIFFICULTY as usize] = Some(InstructionInfo::new("DIFFICULTY", 0, 1, GasPriceTier::Base)); arr[GASLIMIT as usize] = Some(InstructionInfo::new("GASLIMIT", 0, 1, GasPriceTier::Base)); arr[CHAINID as usize] = Some(InstructionInfo::new("CHAINID", 0, 1, GasPriceTier::Base)); + arr[SELFBALANCE as usize] = Some(InstructionInfo::new("SELFBALANCE", 0, 1, GasPriceTier::Low)); arr[POP as usize] = Some(InstructionInfo::new("POP", 1, 0, GasPriceTier::Base)); arr[MLOAD as usize] = Some(InstructionInfo::new("MLOAD", 1, 1, GasPriceTier::VeryLow)); arr[MSTORE as usize] = Some(InstructionInfo::new("MSTORE", 2, 0, GasPriceTier::VeryLow)); diff --git a/ethcore/evm/src/interpreter/mod.rs b/ethcore/evm/src/interpreter/mod.rs index 85564385552..47260139521 100644 --- a/ethcore/evm/src/interpreter/mod.rs +++ b/ethcore/evm/src/interpreter/mod.rs @@ -299,7 +299,12 @@ impl Interpreter { let result = if self.gasometer.is_none() { InterpreterResult::Done(Err(vm::Error::OutOfGas)) } else if self.reader.len() == 0 { - InterpreterResult::Done(Ok(GasLeft::Known(self.gasometer.as_ref().expect("Gasometer None case is checked above; qed").current_gas.as_u256()))) + let current_gas = self.gasometer + .as_ref() + .expect("Gasometer None case is checked above; qed") + .current_gas + .as_u256(); + InterpreterResult::Done(Ok(GasLeft::Known(current_gas))) } else { self.step_inner(ext) }; @@ -308,7 +313,7 @@ impl Interpreter { self.done = true; self.informant.done(); } - return result; + result } /// Inner helper function for step. @@ -429,7 +434,8 @@ impl Interpreter { (instruction == instructions::REVERT && !schedule.have_revert) || ((instruction == instructions::SHL || instruction == instructions::SHR || instruction == instructions::SAR) && !schedule.have_bitwise_shifting) || (instruction == instructions::EXTCODEHASH && !schedule.have_extcodehash) || - (instruction == instructions::CHAINID && !schedule.have_chain_id) + (instruction == instructions::CHAINID && !schedule.have_chain_id) || + (instruction == instructions::SELFBALANCE && !schedule.have_selfbalance) { return Err(vm::Error::BadInstruction { instruction: instruction as u8 @@ -847,6 +853,9 @@ impl Interpreter { instructions::CHAINID => { self.stack.push(ext.chain_id().into()) }, + instructions::SELFBALANCE => { + self.stack.push(ext.balance(&self.params.address)?); + } // Stack instructions diff --git a/ethcore/evm/src/tests.rs b/ethcore/evm/src/tests.rs index 05a39e1b5a1..d226b7c1a25 100644 --- a/ethcore/evm/src/tests.rs +++ b/ethcore/evm/src/tests.rs @@ -124,6 +124,32 @@ fn test_origin(factory: super::Factory) { assert_store(&ext, 0, "000000000000000000000000cd1722f2947def4cf144679da39c4c32bdc35681"); } +evm_test!{test_selfbalance: test_selfbalance_int} +fn test_selfbalance(factory: super::Factory) { + let own_addr = Address::from_str("1337000000000000000000000000000000000000").unwrap(); + // 47 SELFBALANCE + // 60 ff PUSH ff + // 55 SSTORE + let code = hex!("47 60 ff 55").to_vec(); + + let mut params = ActionParams::default(); + params.address = own_addr.clone(); + params.gas = U256::from(100_000); + params.code = Some(Arc::new(code)); + let mut ext = FakeExt::new_istanbul(); + ext.balances = { + let mut x = HashMap::new(); + x.insert(own_addr, U256::from(1_025)); // 0x401 + x + }; + let gas_left = { + let vm = factory.create(params, ext.schedule(), ext.depth()); + test_finalize(vm.exec(&mut ext).ok().unwrap()).unwrap() + }; + assert_eq!(gas_left, U256::from(79_992)); // TODO[dvdplm]: do the sums here, SELFBALANCE-5 + PUSH1-3 + ONEBYTE-4 + SSTORE-?? = 100_000 - 79_992 + assert_store(&ext, 0xff, "0000000000000000000000000000000000000000000000000000000000000401"); +} + evm_test!{test_sender: test_sender_int} fn test_sender(factory: super::Factory) { let address = Address::from_str("0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6").unwrap(); diff --git a/ethcore/types/src/engines/params.rs b/ethcore/types/src/engines/params.rs index fc8eb96674c..7176093f34b 100644 --- a/ethcore/types/src/engines/params.rs +++ b/ethcore/types/src/engines/params.rs @@ -92,6 +92,8 @@ pub struct CommonParams { pub eip1014_transition: BlockNumber, /// Number of first block where EIP-1344 rules begin: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1344.md pub eip1344_transition: BlockNumber, + /// Number of first block where EIP-1884 rules begin:https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1884.md + pub eip1884_transition: BlockNumber, /// Number of first block where EIP-2028 rules begin. pub eip2028_transition: BlockNumber, /// Number of first block where dust cleanup rules (EIP-168 and EIP169) begin. @@ -165,6 +167,13 @@ impl CommonParams { schedule.have_extcodehash = block_number >= self.eip1052_transition; schedule.have_chain_id = block_number >= self.eip1344_transition; schedule.eip1283 = block_number >= self.eip1283_transition && !(block_number >= self.eip1283_disable_transition); + + if block_number >= self.eip1884_transition { + schedule.have_selfbalance = true; + schedule.sload_gas = 800; + schedule.balance_gas = 700; + schedule.extcodehash_gas = 700; + } if block_number >= self.eip2028_transition { schedule.tx_data_non_zero_gas = 16; } @@ -289,6 +298,10 @@ impl From for CommonParams { BlockNumber::max_value, Into::into, ), + eip1884_transition: p.eip1884_transition.map_or_else( + BlockNumber::max_value, + Into::into, + ), eip2028_transition: p.eip2028_transition.map_or_else( BlockNumber::max_value, Into::into, diff --git a/ethcore/vm/src/ext.rs b/ethcore/vm/src/ext.rs index 63d9595fb0a..68e5822e451 100644 --- a/ethcore/vm/src/ext.rs +++ b/ethcore/vm/src/ext.rs @@ -91,7 +91,7 @@ pub trait Ext { /// Creates new contract. /// - /// Returns gas_left and contract address if contract creation was succesfull. + /// Returns gas_left and contract address if contract creation was successful. fn create( &mut self, gas: &U256, diff --git a/ethcore/vm/src/return_data.rs b/ethcore/vm/src/return_data.rs index 85fdb361db5..38ac23ffdc8 100644 --- a/ethcore/vm/src/return_data.rs +++ b/ethcore/vm/src/return_data.rs @@ -44,11 +44,7 @@ impl ReturnData { } /// Create `ReturnData` from give buffer and slice. pub fn new(mem: Vec, offset: usize, size: usize) -> Self { - ReturnData { - mem: mem, - offset: offset, - size: size, - } + ReturnData { mem, offset, size } } } diff --git a/ethcore/vm/src/schedule.rs b/ethcore/vm/src/schedule.rs index e11603ecdaa..877ef145b65 100644 --- a/ethcore/vm/src/schedule.rs +++ b/ethcore/vm/src/schedule.rs @@ -19,11 +19,13 @@ use std::collections::HashMap; use ethereum_types::U256; /// Definition of schedules that can be applied to a version. +#[derive(Debug)] pub enum VersionedSchedule { PWasm, } /// Definition of the cost schedule and other parameterisations for the EVM. +#[derive(Debug)] pub struct Schedule { /// Does it support exceptional failed code deposit pub exceptional_failed_code_deposit: bool, @@ -124,6 +126,8 @@ pub struct Schedule { pub have_bitwise_shifting: bool, /// CHAINID opcode enabled. pub have_chain_id: bool, + /// SELFBALANCE opcode enabled. + pub have_selfbalance: bool, /// Kill basic accounts below this balance if touched. pub kill_dust: CleanDustMode, /// Enable EIP-1283 rules @@ -139,6 +143,7 @@ pub struct Schedule { } /// Wasm cost table +#[derive(Debug)] pub struct WasmCosts { /// Default opcode cost pub regular: u32, @@ -192,7 +197,7 @@ impl Default for WasmCosts { } /// Dust accounts cleanup mode. -#[derive(PartialEq, Eq)] +#[derive(Debug, PartialEq, Eq)] pub enum CleanDustMode { /// Dust cleanup is disabled. Off, @@ -223,6 +228,7 @@ impl Schedule { have_return_data: false, have_bitwise_shifting: false, have_chain_id: false, + have_selfbalance: false, have_extcodehash: false, stack_limit: 1024, max_depth: 1024, @@ -294,8 +300,12 @@ impl Schedule { /// Schedule for the Istanbul fork of the Ethereum main net. pub fn new_istanbul() -> Schedule { let mut schedule = Self::new_constantinople(); - schedule.have_chain_id = true; - schedule.tx_data_non_zero_gas = 16; + schedule.have_chain_id = true; // EIP 1344 + schedule.tx_data_non_zero_gas = 16; // EIP 2028 + schedule.sload_gas = 800; // EIP 1884 + schedule.balance_gas = 700; // EIP 1884 + schedule.extcodehash_gas = 700; // EIP 1884 + schedule.have_selfbalance = true; // EIP 1884 schedule } @@ -308,6 +318,7 @@ impl Schedule { have_return_data: false, have_bitwise_shifting: false, have_chain_id: false, + have_selfbalance: false, have_extcodehash: false, stack_limit: 1024, max_depth: 1024, diff --git a/json/src/spec/params.rs b/json/src/spec/params.rs index 29c842b87bb..7b1cd1c188c 100644 --- a/json/src/spec/params.rs +++ b/json/src/spec/params.rs @@ -96,6 +96,8 @@ pub struct Params { /// See `CommonParams` docs. pub eip1344_transition: Option, /// See `CommonParams` docs. + pub eip1884_transition: Option, + /// See `CommonParams` docs. pub eip2028_transition: Option, /// See `CommonParams` docs. pub dust_protection_transition: Option, From 00124b5a4bf8a38ad6c660b462a5e5addf13cab3 Mon Sep 17 00:00:00 2001 From: Wei Tang Date: Thu, 29 Aug 2019 21:31:52 +0200 Subject: [PATCH 2/6] Implement EIP-1283 reenable transition, EIP-1706 and EIP-2200 (#10191) * Add reentry protection for EIP-1283 * typo: should use <= * Put things behind flag eip1706 * Fix compile * Fix missing config in json and add eip1283_reenable_transition --- ethcore/evm/src/interpreter/gasometer.rs | 4 ++++ ethcore/types/src/engines/params.rs | 18 +++++++++++++++++- ethcore/vm/src/schedule.rs | 4 ++++ json/src/spec/params.rs | 4 ++++ 4 files changed, 29 insertions(+), 1 deletion(-) diff --git a/ethcore/evm/src/interpreter/gasometer.rs b/ethcore/evm/src/interpreter/gasometer.rs index 7c9d05915e7..1930ebf0343 100644 --- a/ethcore/evm/src/interpreter/gasometer.rs +++ b/ethcore/evm/src/interpreter/gasometer.rs @@ -121,6 +121,10 @@ impl Gasometer { Request::Gas(Gas::from(1)) }, instructions::SSTORE => { + if schedule.eip1706 && self.current_gas <= Gas::from(schedule.call_stipend) { + return Err(vm::Error::OutOfGas); + } + let address = BigEndianHash::from_uint(stack.peek(0)); let newval = stack.peek(1); let val = ext.storage_at(&address)?.into_uint(); diff --git a/ethcore/types/src/engines/params.rs b/ethcore/types/src/engines/params.rs index 7176093f34b..b8edebc94f5 100644 --- a/ethcore/types/src/engines/params.rs +++ b/ethcore/types/src/engines/params.rs @@ -88,8 +88,12 @@ pub struct CommonParams { pub eip1283_transition: BlockNumber, /// Number of first block where EIP-1283 rules end. pub eip1283_disable_transition: BlockNumber, + /// Number of first block where EIP-1283 rules re-enabled. + pub eip1283_reenable_transition: BlockNumber, /// Number of first block where EIP-1014 rules begin. pub eip1014_transition: BlockNumber, + /// Number of first block where EIP-1706 rules begin. + pub eip1706_transition: BlockNumber, /// Number of first block where EIP-1344 rules begin: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1344.md pub eip1344_transition: BlockNumber, /// Number of first block where EIP-1884 rules begin:https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1884.md @@ -166,7 +170,11 @@ impl CommonParams { schedule.have_bitwise_shifting = block_number >= self.eip145_transition; schedule.have_extcodehash = block_number >= self.eip1052_transition; schedule.have_chain_id = block_number >= self.eip1344_transition; - schedule.eip1283 = block_number >= self.eip1283_transition && !(block_number >= self.eip1283_disable_transition); + schedule.eip1283 = + (block_number >= self.eip1283_transition && + !(block_number >= self.eip1283_disable_transition)) || + block_number >= self.eip1283_reenable_transition; + schedule.eip1706 = block_number >= self.eip1706_transition; if block_number >= self.eip1884_transition { schedule.have_selfbalance = true; @@ -290,6 +298,14 @@ impl From for CommonParams { BlockNumber::max_value, Into::into, ), + eip1283_reenable_transition: p.eip1283_reenable_transition.map_or_else( + BlockNumber::max_value, + Into::into, + ), + eip1706_transition: p.eip1706_transition.map_or_else( + BlockNumber::max_value, + Into::into, + ), eip1014_transition: p.eip1014_transition.map_or_else( BlockNumber::max_value, Into::into, diff --git a/ethcore/vm/src/schedule.rs b/ethcore/vm/src/schedule.rs index 877ef145b65..f3b7afbf1d2 100644 --- a/ethcore/vm/src/schedule.rs +++ b/ethcore/vm/src/schedule.rs @@ -132,6 +132,8 @@ pub struct Schedule { pub kill_dust: CleanDustMode, /// Enable EIP-1283 rules pub eip1283: bool, + /// Enable EIP-1706 rules + pub eip1706: bool, /// VM execution does not increase null signed address nonce if this field is true. pub keep_unsigned_nonce: bool, /// Latest VM version for contract creation transaction. @@ -273,6 +275,7 @@ impl Schedule { have_static_call: false, kill_dust: CleanDustMode::Off, eip1283: false, + eip1706: false, keep_unsigned_nonce: false, latest_version: U256::zero(), versions: HashMap::new(), @@ -363,6 +366,7 @@ impl Schedule { have_static_call: false, kill_dust: CleanDustMode::Off, eip1283: false, + eip1706: false, keep_unsigned_nonce: false, latest_version: U256::zero(), versions: HashMap::new(), diff --git a/json/src/spec/params.rs b/json/src/spec/params.rs index 7b1cd1c188c..58adbd6a468 100644 --- a/json/src/spec/params.rs +++ b/json/src/spec/params.rs @@ -92,8 +92,12 @@ pub struct Params { /// See `CommonParams` docs. pub eip1283_disable_transition: Option, /// See `CommonParams` docs. + pub eip1283_reenable_transition: Option, + /// See `CommonParams` docs. pub eip1014_transition: Option, /// See `CommonParams` docs. + pub eip1706_transition: Option, + /// See `CommonParams` docs. pub eip1344_transition: Option, /// See `CommonParams` docs. pub eip1884_transition: Option, From 05f9606bf2fc9fb51a7dd3033d9fc2ce55f1a2e9 Mon Sep 17 00:00:00 2001 From: Atkins Date: Mon, 2 Sep 2019 16:56:08 +0800 Subject: [PATCH 3/6] Fix deadlock in `network-devp2p` (#11013) * Fix deadlock in `network-devp2p` * Add note for locking order in `network-devp2p` --- util/network-devp2p/src/host.rs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/util/network-devp2p/src/host.rs b/util/network-devp2p/src/host.rs index f409744307e..a16f9625229 100644 --- a/util/network-devp2p/src/host.rs +++ b/util/network-devp2p/src/host.rs @@ -261,6 +261,8 @@ struct ProtocolTimer { } /// Root IO handler. Manages protocol handlers, IO timers and network connections. +/// +/// NOTE: must keep the lock in order of: reserved_nodes (rwlock) -> session (mutex, from sessions) pub struct Host { pub info: RwLock, udp_socket: Mutex>, @@ -722,12 +724,13 @@ impl Host { let session_result = session.lock().readable(io, &self.info.read()); match session_result { Err(e) => { + let reserved_nodes = self.reserved_nodes.read(); let s = session.lock(); trace!(target: "network", "Session read error: {}:{:?} ({:?}) {:?}", token, s.id(), s.remote_addr(), e); match e { Error::Disconnect(DisconnectReason::IncompatibleProtocol) | Error::Disconnect(DisconnectReason::UselessPeer) => { if let Some(id) = s.id() { - if !self.reserved_nodes.read().contains(id) { + if !reserved_nodes.contains(id) { let mut nodes = self.nodes.write(); nodes.note_failure(&id); nodes.mark_as_useless(id); @@ -741,6 +744,7 @@ impl Host { }, Ok(SessionData::Ready) => { let (_, egress_count, ingress_count) = self.session_count(); + let reserved_nodes = self.reserved_nodes.read(); let mut s = session.lock(); let (min_peers, mut max_peers, reserved_only, self_id) = { let info = self.info.read(); @@ -765,7 +769,7 @@ impl Host { if reserved_only || (s.info.originated && egress_count > min_peers) || (!s.info.originated && ingress_count > max_ingress) { - if !self.reserved_nodes.read().contains(&id) { + if !reserved_nodes.contains(&id) { // only proceed if the connecting peer is reserved. trace!(target: "network", "Disconnecting non-reserved peer {:?}", id); s.disconnect(io, DisconnectReason::TooManyPeers); @@ -980,7 +984,8 @@ impl Host { for i in to_remove { trace!(target: "network", "Removed from node table: {}", i); } - self.nodes.write().update(node_changes, &*self.reserved_nodes.read()); + let reserved_nodes = self.reserved_nodes.read(); + self.nodes.write().update(node_changes, &*reserved_nodes); } pub fn with_context(&self, protocol: ProtocolId, io: &IoContext, action: F) where F: FnOnce(&dyn NetworkContextTrait) { @@ -1066,8 +1071,9 @@ impl IoHandler for Host { }, NODE_TABLE => { trace!(target: "network", "Refreshing node table"); - self.nodes.write().clear_useless(); - self.nodes.write().save(); + let mut nodes = self.nodes.write(); + nodes.clear_useless(); + nodes.save(); }, _ => match self.timers.read().get(&token).cloned() { Some(timer) => match self.handlers.read().get(&timer.protocol).cloned() { From a9cb5722383cb89ebf38ba4ea2fa2073f15d5f8b Mon Sep 17 00:00:00 2001 From: Niklas Adolfsson Date: Mon, 2 Sep 2019 11:38:27 +0200 Subject: [PATCH 4/6] EIP 1108: Reduce alt_bn128 precompile gas costs (#11008) * feat: implement eip1108 * doc nit: price per point pair Co-Authored-By: David * fix: test-build * fix: update chain specs * fix: basic_authority.json chain spec * fix: change `eip_transition == 0x7fffffffffffff` * add issue link to `TODO` --- ethcore/builtin/Cargo.toml | 1 - ethcore/builtin/src/lib.rs | 158 ++++++++++++++---- .../basic-authority/res/basic_authority.json | 47 +++++- ethcore/machine/Cargo.toml | 1 + ethcore/machine/src/executive.rs | 3 +- ethcore/res/authority_round.json | 47 +++++- ...authority_round_block_reward_contract.json | 47 +++++- ethcore/res/constructor.json | 47 +++++- ethcore/res/ethereum/byzantium_test.json | 44 ++++- ethcore/res/ethereum/callisto.json | 47 +++++- ethcore/res/ethereum/classic.json | 19 ++- ethcore/res/ethereum/constantinople_test.json | 44 ++++- ethcore/res/ethereum/eip210_test.json | 44 ++++- ethcore/res/ethereum/ellaism.json | 44 ++++- ethcore/res/ethereum/ewc.json | 23 ++- ethcore/res/ethereum/expanse.json | 44 ++++- ethcore/res/ethereum/foundation.json | 19 ++- ethcore/res/ethereum/goerli.json | 25 +-- ethcore/res/ethereum/kotti.json | 19 ++- ethcore/res/ethereum/kovan.json | 19 ++- ethcore/res/ethereum/kovan_wasm_test.json | 44 ++++- ethcore/res/ethereum/mcip3_test.json | 47 +++--- ethcore/res/ethereum/mix.json | 44 ++++- ethcore/res/ethereum/morden.json | 19 ++- ethcore/res/ethereum/musicoin.json | 47 +++--- ethcore/res/ethereum/poacore.json | 45 ++++- ethcore/res/ethereum/poasokol.json | 44 ++++- ethcore/res/ethereum/rinkeby.json | 22 +-- ethcore/res/ethereum/ropsten.json | 19 ++- ethcore/res/ethereum/st_peters_test.json | 44 ++++- ethcore/res/ethereum/transition_test.json | 45 ++++- ethcore/res/ethereum/volta.json | 27 +-- ethcore/res/ethereum/xdai.json | 21 ++- ethcore/res/instant_seal.json | 47 +++++- ethcore/res/null.json | 47 +++++- ethcore/types/Cargo.toml | 5 +- ethcore/types/src/engines/params.rs | 4 +- json/src/spec/builtin.rs | 18 ++ 38 files changed, 1107 insertions(+), 224 deletions(-) diff --git a/ethcore/builtin/Cargo.toml b/ethcore/builtin/Cargo.toml index 5080fd7a862..792efaed17e 100644 --- a/ethcore/builtin/Cargo.toml +++ b/ethcore/builtin/Cargo.toml @@ -18,4 +18,3 @@ parity-crypto = "0.4.0" [dev-dependencies] rustc-hex = "1.0" - diff --git a/ethcore/builtin/src/lib.rs b/ethcore/builtin/src/lib.rs index c06d3330f50..8fdb4cb3522 100644 --- a/ethcore/builtin/src/lib.rs +++ b/ethcore/builtin/src/lib.rs @@ -38,9 +38,10 @@ trait Implementation: Send + Sync { } /// A gas pricing scheme for built-in contracts. +// TODO: refactor this trait, see https://github.com/paritytech/parity-ethereum/issues/11014 trait Pricer: Send + Sync { - /// The gas cost of running this built-in for the given input data. - fn cost(&self, input: &[u8]) -> U256; + /// The gas cost of running this built-in for the given input data at block number `at` + fn cost(&self, input: &[u8], at: u64) -> U256; } /// A linear pricing model. This computes a price using a base cost and a cost per-word. @@ -55,26 +56,56 @@ struct ModexpPricer { } impl Pricer for Linear { - fn cost(&self, input: &[u8]) -> U256 { + fn cost(&self, input: &[u8], _at: u64) -> U256 { U256::from(self.base) + U256::from(self.word) * U256::from((input.len() + 31) / 32) } } -/// A alt_bn128_parinig pricing model. This computes a price using a base cost and a cost per pair. -struct AltBn128PairingPricer { +/// alt_bn128 constant operations (add and mul) pricing model. +struct AltBn128ConstOperations { + price: usize, + eip1108_transition_at: u64, + eip1108_transition_price: usize, +} + +impl Pricer for AltBn128ConstOperations { + fn cost(&self, _input: &[u8], at: u64) -> U256 { + if at >= self.eip1108_transition_at { + self.eip1108_transition_price.into() + } else { + self.price.into() + } + } +} + +/// alt_bn128 pairing price +#[derive(Debug, Copy, Clone)] +struct AltBn128PairingPrice { base: usize, pair: usize, } +/// alt_bn128_pairing pricing model. This computes a price using a base cost and a cost per pair. +struct AltBn128PairingPricer { + price: AltBn128PairingPrice, + eip1108_transition_at: u64, + eip1108_transition_price: AltBn128PairingPrice, +} + impl Pricer for AltBn128PairingPricer { - fn cost(&self, input: &[u8]) -> U256 { - let cost = U256::from(self.base) + U256::from(self.pair) * U256::from(input.len() / 192); - cost + fn cost(&self, input: &[u8], at: u64) -> U256 { + let price = if at >= self.eip1108_transition_at { + self.eip1108_transition_price + } else { + self.price + }; + + U256::from(price.base) + U256::from(price.pair) * U256::from(input.len() / 192) } } impl Pricer for ModexpPricer { - fn cost(&self, input: &[u8]) -> U256 { + fn cost(&self, input: &[u8], _at: u64) -> U256 { let mut reader = input.chain(io::repeat(0)); let mut buf = [0; 32]; @@ -150,8 +181,8 @@ pub struct Builtin { impl Builtin { /// Simple forwarder for cost. - pub fn cost(&self, input: &[u8]) -> U256 { - self.pricer.cost(input) + pub fn cost(&self, input: &[u8], at: u64) -> U256 { + self.pricer.cost(input, at) } /// Simple forwarder for execute. @@ -186,16 +217,30 @@ impl From for Builtin { } ethjson::spec::Pricing::AltBn128Pairing(pricer) => { Box::new(AltBn128PairingPricer { - base: pricer.base, - pair: pricer.pair, + price: AltBn128PairingPrice { + base: pricer.base, + pair: pricer.pair, + }, + eip1108_transition_at: b.eip1108_transition.map_or(u64::max_value(), Into::into), + eip1108_transition_price: AltBn128PairingPrice { + base: pricer.eip1108_transition_base, + pair: pricer.eip1108_transition_pair, + }, + }) + } + ethjson::spec::Pricing::AltBn128ConstOperations(pricer) => { + Box::new(AltBn128ConstOperations { + price: pricer.price, + eip1108_transition_price: pricer.eip1108_transition_price, + eip1108_transition_at: b.eip1108_transition.map_or(u64::max_value(), Into::into) }) } }; Builtin { - pricer: pricer, + pricer, native: ethereum_builtin(&b.name), - activate_at: b.activate_at.map(Into::into).unwrap_or(0), + activate_at: b.activate_at.map_or(0, Into::into), } } } @@ -477,7 +522,7 @@ impl Implementation for Bn128Pairing { /// - any of even points does not belong to the twisted bn128 curve over the field F_p^2 = F_p[i] / (i^2 + 1) fn execute(&self, input: &[u8], output: &mut BytesRef) -> Result<(), &'static str> { if input.len() % 192 != 0 { - return Err("Invalid input length, must be multiple of 192 (3 * (32*2))".into()) + return Err("Invalid input length, must be multiple of 192 (3 * (32*2))") } if let Err(err) = self.execute_with_error(input, output) { @@ -551,7 +596,7 @@ impl Bn128Pairing { #[cfg(test)] mod tests { use ethereum_types::U256; - use ethjson; + use ethjson::uint::Uint; use num::{BigUint, Zero, One}; use parity_bytes::BytesRef; use rustc_hex::FromHex; @@ -715,7 +760,7 @@ mod tests { { let input = FromHex::from_hex("0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000003b27bafd00000000000000000000000000000000000000000000000000000000503c8ac3").unwrap(); let expected_cost = U256::max_value(); - assert_eq!(f.cost(&input[..]), expected_cost.into()); + assert_eq!(f.cost(&input[..], 0), expected_cost.into()); } // test for potential exp len overflow @@ -732,7 +777,7 @@ mod tests { f.execute(&input[..], &mut BytesRef::Fixed(&mut output[..])).expect("Builtin should fail"); assert_eq!(output, expected); - assert_eq!(f.cost(&input[..]), expected_cost.into()); + assert_eq!(f.cost(&input[..], 0), expected_cost.into()); } // fermat's little theorem example. @@ -752,7 +797,7 @@ mod tests { f.execute(&input[..], &mut BytesRef::Fixed(&mut output[..])).expect("Builtin should not fail"); assert_eq!(output, expected); - assert_eq!(f.cost(&input[..]), expected_cost.into()); + assert_eq!(f.cost(&input[..], 0), expected_cost.into()); } // second example from EIP: zero base. @@ -771,7 +816,7 @@ mod tests { f.execute(&input[..], &mut BytesRef::Fixed(&mut output[..])).expect("Builtin should not fail"); assert_eq!(output, expected); - assert_eq!(f.cost(&input[..]), expected_cost.into()); + assert_eq!(f.cost(&input[..], 0), expected_cost.into()); } // another example from EIP: zero-padding @@ -791,7 +836,7 @@ mod tests { f.execute(&input[..], &mut BytesRef::Fixed(&mut output[..])).expect("Builtin should not fail"); assert_eq!(output, expected); - assert_eq!(f.cost(&input[..]), expected_cost.into()); + assert_eq!(f.cost(&input[..], 0), expected_cost.into()); } // zero-length modulus. @@ -809,7 +854,7 @@ mod tests { f.execute(&input[..], &mut BytesRef::Flexible(&mut output)).expect("Builtin should not fail"); assert_eq!(output.len(), 0); // shouldn't have written any output. - assert_eq!(f.cost(&input[..]), expected_cost.into()); + assert_eq!(f.cost(&input[..], 0), expected_cost.into()); } } @@ -1019,10 +1064,10 @@ mod tests { activate_at: 1, }; - assert_eq!(b.cost(&[0; 0]), U256::from(10)); - assert_eq!(b.cost(&[0; 1]), U256::from(30)); - assert_eq!(b.cost(&[0; 32]), U256::from(30)); - assert_eq!(b.cost(&[0; 33]), U256::from(50)); + assert_eq!(b.cost(&[0; 0], 0), U256::from(10)); + assert_eq!(b.cost(&[0; 1], 0), U256::from(30)); + assert_eq!(b.cost(&[0; 32], 0), U256::from(30)); + assert_eq!(b.cost(&[0; 33], 0), U256::from(50)); let i = [0u8, 1, 2, 3]; let mut o = [255u8; 4]; @@ -1039,16 +1084,67 @@ mod tests { word: 20, }), activate_at: None, + eip1108_transition: None, }); - assert_eq!(b.cost(&[0; 0]), U256::from(10)); - assert_eq!(b.cost(&[0; 1]), U256::from(30)); - assert_eq!(b.cost(&[0; 32]), U256::from(30)); - assert_eq!(b.cost(&[0; 33]), U256::from(50)); + assert_eq!(b.cost(&[0; 0], 0), U256::from(10)); + assert_eq!(b.cost(&[0; 1], 0), U256::from(30)); + assert_eq!(b.cost(&[0; 32], 0), U256::from(30)); + assert_eq!(b.cost(&[0; 33], 0), U256::from(50)); let i = [0u8, 1, 2, 3]; let mut o = [255u8; 4]; b.execute(&i[..], &mut BytesRef::Fixed(&mut o[..])).expect("Builtin should not fail"); assert_eq!(i, o); } + + #[test] + fn bn128_pairing_eip1108_transition() { + let b = Builtin::from(ethjson::spec::Builtin { + name: "alt_bn128_pairing".to_owned(), + pricing: ethjson::spec::Pricing::AltBn128Pairing(ethjson::spec::builtin::AltBn128Pairing { + base: 100_000, + pair: 80_000, + eip1108_transition_base: 45_000, + eip1108_transition_pair: 34_000, + }), + activate_at: Some(Uint(U256::from(10))), + eip1108_transition: Some(Uint(U256::from(20))), + }); + + assert_eq!(b.cost(&[0; 192 * 3], 10), U256::from(340_000), "80 000 * 3 + 100 000 == 340 000"); + assert_eq!(b.cost(&[0; 192 * 7], 20), U256::from(283_000), "34 000 * 7 + 45 000 == 283 000"); + } + + #[test] + fn bn128_add_eip1108_transition() { + let b = Builtin::from(ethjson::spec::Builtin { + name: "alt_bn128_add".to_owned(), + pricing: ethjson::spec::Pricing::AltBn128ConstOperations(ethjson::spec::builtin::AltBn128ConstOperations { + price: 500, + eip1108_transition_price: 150, + }), + activate_at: Some(Uint(U256::from(10))), + eip1108_transition: Some(Uint(U256::from(20))), + }); + + assert_eq!(b.cost(&[0; 192], 10), U256::from(500)); + assert_eq!(b.cost(&[0; 10], 20), U256::from(150), "after istanbul hardfork gas cost for add should be 150"); + } + + #[test] + fn bn128_mul_eip1108_transition() { + let b = Builtin::from(ethjson::spec::Builtin { + name: "alt_bn128_mul".to_owned(), + pricing: ethjson::spec::Pricing::AltBn128ConstOperations(ethjson::spec::builtin::AltBn128ConstOperations { + price: 40_000, + eip1108_transition_price: 6000, + }), + activate_at: Some(Uint(U256::from(10))), + eip1108_transition: Some(Uint(U256::from(20))), + }); + + assert_eq!(b.cost(&[0; 192], 10), U256::from(40_000)); + assert_eq!(b.cost(&[0; 10], 20), U256::from(6_000), "after istanbul hardfork gas cost for mul should be 6 000"); + } } diff --git a/ethcore/engines/basic-authority/res/basic_authority.json b/ethcore/engines/basic-authority/res/basic_authority.json index 35711be0112..2d92355e3af 100644 --- a/ethcore/engines/basic-authority/res/basic_authority.json +++ b/ethcore/engines/basic-authority/res/basic_authority.json @@ -38,9 +38,50 @@ "0000000000000000000000000000000000000003": { "balance": "1", "nonce": "1048576", "builtin": { "name": "ripemd160", "pricing": { "linear": { "base": 600, "word": 120 } } } }, "0000000000000000000000000000000000000004": { "balance": "1", "nonce": "1048576", "builtin": { "name": "identity", "pricing": { "linear": { "base": 15, "word": 3 } } } }, "0000000000000000000000000000000000000005": { "balance": "1", "builtin": { "name": "modexp", "activate_at": 0, "pricing": { "modexp": { "divisor": 20 } } } }, - "0000000000000000000000000000000000000006": { "balance": "1", "builtin": { "name": "alt_bn128_add", "activate_at": 0, "pricing": { "linear": { "base": 500, "word": 0 } } } }, - "0000000000000000000000000000000000000007": { "balance": "1", "builtin": { "name": "alt_bn128_mul", "activate_at": 0, "pricing": { "linear": { "base": 40000, "word": 0 } } } }, - "0000000000000000000000000000000000000008": { "balance": "1", "builtin": { "name": "alt_bn128_pairing", "activate_at": 0, "pricing": { "alt_bn128_pairing": { "base": 100000, "pair": 80000 } } } }, + "0000000000000000000000000000000000000006": { + "balance": "1", + "builtin": { + "name": "alt_bn128_add", + "activate_at": "0x0", + "eip1108_transition": "0x7fffffffffffff", + "pricing": { + "alt_bn128_const_operations": { + "price": 500, + "eip1108_transition_price": 150 + } + } + } + }, + "0000000000000000000000000000000000000007": { + "balance": "1", + "builtin": { + "name": "alt_bn128_mul", + "activate_at": "0x0", + "eip1108_transition": "0x7fffffffffffff", + "pricing": { + "alt_bn128_const_operations": { + "price": 40000, + "eip1108_transition_price": 6000 + } + } + } + }, + "0000000000000000000000000000000000000008": { + "balance": "1", + "builtin": { + "name": "alt_bn128_pairing", + "activate_at": "0x0", + "eip1108_transition": "0x7fffffffffffff", + "pricing": { + "alt_bn128_pairing": { + "base": 100000, + "pair": 80000, + "eip1108_transition_base": 45000, + "eip1108_transition_pair": 34000 + } + } + } + }, "9cce34f7ab185c7aba1b7c8140d620b4bda941d6": { "balance": "1606938044258990275541962092341162602522202993782792835301376", "nonce": "1048576" } } } diff --git a/ethcore/machine/Cargo.toml b/ethcore/machine/Cargo.toml index e349b4d077a..bfc9f583b1f 100644 --- a/ethcore/machine/Cargo.toml +++ b/ethcore/machine/Cargo.toml @@ -33,6 +33,7 @@ trie-vm-factories = { path = "../trie-vm-factories" } vm = { path = "../vm" } [dev-dependencies] +common-types = { path = "../types", features = ["test-helpers"] } ethcore = { path = "../", features = ["test-helpers"] } ethcore-io = { path = "../../util/io" } ethjson = { path = "../../json" } diff --git a/ethcore/machine/src/executive.rs b/ethcore/machine/src/executive.rs index 81b92599ca9..5be1842db8a 100644 --- a/ethcore/machine/src/executive.rs +++ b/ethcore/machine/src/executive.rs @@ -412,7 +412,8 @@ impl<'a> CallCreateExecutive<'a> { let default = []; let data = if let Some(ref d) = params.data { d as &[u8] } else { &default as &[u8] }; - let cost = builtin.cost(data); + // NOTE(niklasad1): block number is used by `builtin alt_bn128 ops` to enable eip1108 + let cost = builtin.cost(data, self.info.number); if cost <= params.gas { let mut builtin_out_buffer = Vec::new(); let result = { diff --git a/ethcore/res/authority_round.json b/ethcore/res/authority_round.json index 8d542443798..33afa45871c 100644 --- a/ethcore/res/authority_round.json +++ b/ethcore/res/authority_round.json @@ -46,9 +46,50 @@ "0000000000000000000000000000000000000003": { "balance": "1", "nonce": "1048576", "builtin": { "name": "ripemd160", "pricing": { "linear": { "base": 600, "word": 120 } } } }, "0000000000000000000000000000000000000004": { "balance": "1", "nonce": "1048576", "builtin": { "name": "identity", "pricing": { "linear": { "base": 15, "word": 3 } } } }, "0000000000000000000000000000000000000005": { "balance": "1", "builtin": { "name": "modexp", "activate_at": 0, "pricing": { "modexp": { "divisor": 20 } } } }, - "0000000000000000000000000000000000000006": { "balance": "1", "builtin": { "name": "alt_bn128_add", "activate_at": 0, "pricing": { "linear": { "base": 500, "word": 0 } } } }, - "0000000000000000000000000000000000000007": { "balance": "1", "builtin": { "name": "alt_bn128_mul", "activate_at": 0, "pricing": { "linear": { "base": 40000, "word": 0 } } } }, - "0000000000000000000000000000000000000008": { "balance": "1", "builtin": { "name": "alt_bn128_pairing", "activate_at": 0, "pricing": { "alt_bn128_pairing": { "base": 100000, "pair": 80000 } } } }, + "0000000000000000000000000000000000000006": { + "balance": "1", + "builtin": { + "name": "alt_bn128_add", + "activate_at": 0, + "eip1108_transition": "0x7fffffffffffff", + "pricing": { + "alt_bn128_const_operations": { + "price": 500, + "eip1108_transition_price": 150 + } + } + } + }, + "0000000000000000000000000000000000000007": { + "balance": "1", + "builtin": { + "name": "alt_bn128_mul", + "activate_at": 0, + "eip1108_transition": "0x7fffffffffffff", + "pricing": { + "alt_bn128_const_operations": { + "price": 40000, + "eip1108_transition_price": 6000 + } + } + } + }, + "0000000000000000000000000000000000000008": { + "balance": "1", + "builtin": { + "name": "alt_bn128_pairing", + "activate_at": 0, + "eip1108_transition": "0x7fffffffffffff", + "pricing": { + "alt_bn128_pairing": { + "base": 100000, + "pair": 80000, + "eip1108_transition_base": 45000, + "eip1108_transition_pair": 34000 + } + } + } + }, "9cce34f7ab185c7aba1b7c8140d620b4bda941d6": { "balance": "1606938044258990275541962092341162602522202993782792835301376", "nonce": "1048576" } } } diff --git a/ethcore/res/authority_round_block_reward_contract.json b/ethcore/res/authority_round_block_reward_contract.json index 31957731232..73893d44d1d 100644 --- a/ethcore/res/authority_round_block_reward_contract.json +++ b/ethcore/res/authority_round_block_reward_contract.json @@ -49,9 +49,50 @@ "0000000000000000000000000000000000000003": { "balance": "1", "nonce": "1048576", "builtin": { "name": "ripemd160", "pricing": { "linear": { "base": 600, "word": 120 } } } }, "0000000000000000000000000000000000000004": { "balance": "1", "nonce": "1048576", "builtin": { "name": "identity", "pricing": { "linear": { "base": 15, "word": 3 } } } }, "0000000000000000000000000000000000000005": { "balance": "1", "builtin": { "name": "modexp", "activate_at": 0, "pricing": { "modexp": { "divisor": 20 } } } }, - "0000000000000000000000000000000000000006": { "balance": "1", "builtin": { "name": "alt_bn128_add", "activate_at": 0, "pricing": { "linear": { "base": 500, "word": 0 } } } }, - "0000000000000000000000000000000000000007": { "balance": "1", "builtin": { "name": "alt_bn128_mul", "activate_at": 0, "pricing": { "linear": { "base": 40000, "word": 0 } } } }, - "0000000000000000000000000000000000000008": { "balance": "1", "builtin": { "name": "alt_bn128_pairing", "activate_at": 0, "pricing": { "alt_bn128_pairing": { "base": 100000, "pair": 80000 } } } }, + "0000000000000000000000000000000000000006": { + "balance": "1", + "builtin": { + "name": "alt_bn128_add", + "activate_at": 0, + "eip1108_transition": "0x7fffffffffffff", + "pricing": { + "alt_bn128_const_operations": { + "price": 500, + "eip1108_transition_price": 150 + } + } + } + }, + "0000000000000000000000000000000000000007": { + "balance": "1", + "builtin": { + "name": "alt_bn128_mul", + "activate_at": 0, + "eip1108_transition": "0x7fffffffffffff", + "pricing": { + "alt_bn128_const_operations": { + "price": 40000, + "eip1108_transition_price": 6000 + } + } + } + }, + "0000000000000000000000000000000000000008": { + "balance": "1", + "builtin": { + "name": "alt_bn128_pairing", + "activate_at": 0, + "eip1108_transition": "0x7fffffffffffff", + "pricing": { + "alt_bn128_pairing": { + "base": 100000, + "pair": 80000, + "eip1108_transition_base": 45000, + "eip1108_transition_pair": 34000 + } + } + } + }, "9cce34f7ab185c7aba1b7c8140d620b4bda941d6": { "balance": "1606938044258990275541962092341162602522202993782792835301376", "nonce": "1048576" }, "0000000000000000000000000000000000000042": { "balance": "1", diff --git a/ethcore/res/constructor.json b/ethcore/res/constructor.json index f4e22ea2d82..1383337351a 100644 --- a/ethcore/res/constructor.json +++ b/ethcore/res/constructor.json @@ -34,9 +34,50 @@ "0000000000000000000000000000000000000003": { "balance": "1", "builtin": { "name": "ripemd160", "pricing": { "linear": { "base": 600, "word": 120 } } } }, "0000000000000000000000000000000000000004": { "balance": "1", "builtin": { "name": "identity", "pricing": { "linear": { "base": 15, "word": 3 } } } }, "0000000000000000000000000000000000000005": { "balance": "1", "builtin": { "name": "modexp", "activate_at": 0, "pricing": { "modexp": { "divisor": 20 } } } }, - "0000000000000000000000000000000000000006": { "balance": "1", "builtin": { "name": "alt_bn128_add", "activate_at": 0, "pricing": { "linear": { "base": 500, "word": 0 } } } }, - "0000000000000000000000000000000000000007": { "balance": "1", "builtin": { "name": "alt_bn128_mul", "activate_at": 0, "pricing": { "linear": { "base": 40000, "word": 0 } } } }, - "0000000000000000000000000000000000000008": { "balance": "1", "builtin": { "name": "alt_bn128_pairing", "activate_at": 0, "pricing": { "alt_bn128_pairing": { "base": 100000, "pair": 80000 } } } }, + "0000000000000000000000000000000000000006": { + "balance": "1", + "builtin": { + "name": "alt_bn128_add", + "activate_at": 0, + "eip1108_transition": "0x7fffffffffffff", + "pricing": { + "alt_bn128_const_operations": { + "price": 500, + "eip1108_transition_price": 150 + } + } + } + }, + "0000000000000000000000000000000000000007": { + "balance": "1", + "builtin": { + "name": "alt_bn128_mul", + "activate_at": 0, + "eip1108_transition": "0x7fffffffffffff", + "pricing": { + "alt_bn128_const_operations": { + "price": 40000, + "eip1108_transition_price": 6000 + } + } + } + }, + "0000000000000000000000000000000000000008": { + "balance": "1", + "builtin": { + "name": "alt_bn128_pairing", + "activate_at": 0, + "eip1108_transition": "0x7fffffffffffff", + "pricing": { + "alt_bn128_pairing": { + "base": 100000, + "pair": 80000, + "eip1108_transition_base": 45000, + "eip1108_transition_pair": 34000 + } + } + } + }, "0000000000000000000000000000000000001337": { "balance": "1", "constructor": "60606040526000805460ff19166001179055346000575b6075806100246000396000f300606060405263ffffffff60e060020a60003504166394b91deb81146022575b6000565b34600057602c6040565b604080519115158252519081900360200190f35b60005460ff16815600a165627a7a723058207882eb60ebce23178b3fa06d4cd8e5adc17711937ccddacb18a04abca2a2c9ee0029" } } } diff --git a/ethcore/res/ethereum/byzantium_test.json b/ethcore/res/ethereum/byzantium_test.json index 9fdde9d13e5..b4df953739b 100644 --- a/ethcore/res/ethereum/byzantium_test.json +++ b/ethcore/res/ethereum/byzantium_test.json @@ -54,8 +54,46 @@ "0000000000000000000000000000000000000003": { "balance": "1", "builtin": { "name": "ripemd160", "pricing": { "linear": { "base": 600, "word": 120 } } } }, "0000000000000000000000000000000000000004": { "balance": "1", "builtin": { "name": "identity", "pricing": { "linear": { "base": 15, "word": 3 } } } }, "0000000000000000000000000000000000000005": { "builtin": { "name": "modexp", "activate_at": "0x00", "pricing": { "modexp": { "divisor": 20 } } } }, - "0000000000000000000000000000000000000006": { "builtin": { "name": "alt_bn128_add", "activate_at": "0x00", "pricing": { "linear": { "base": 500, "word": 0 } } } }, - "0000000000000000000000000000000000000007": { "builtin": { "name": "alt_bn128_mul", "activate_at": "0x00", "pricing": { "linear": { "base": 40000, "word": 0 } } } }, - "0000000000000000000000000000000000000008": { "builtin": { "name": "alt_bn128_pairing", "activate_at": "0x00", "pricing": { "alt_bn128_pairing": { "base": 100000, "pair": 80000 } } } } + "0000000000000000000000000000000000000006": { + "builtin": { + "name": "alt_bn128_add", + "activate_at": "0x00", + "eip1108_transition": "0x7fffffffffffff", + "pricing": { + "alt_bn128_const_operations": { + "price": 500, + "eip1108_transition_price": 150 + } + } + } + }, + "0000000000000000000000000000000000000007": { + "builtin": { + "name": "alt_bn128_mul", + "activate_at": "0x00", + "eip1108_transition": "0x7fffffffffffff", + "pricing": { + "alt_bn128_const_operations": { + "price": 40000, + "eip1108_transition_price": 6000 + } + } + } + }, + "0000000000000000000000000000000000000008": { + "builtin": { + "name": "alt_bn128_pairing", + "activate_at": "0x00", + "eip1108_transition": "0x7fffffffffffff", + "pricing": { + "alt_bn128_pairing": { + "base": 100000, + "pair": 80000, + "eip1108_transition_base": 45000, + "eip1108_transition_pair": 34000 + } + } + } + } } } diff --git a/ethcore/res/ethereum/callisto.json b/ethcore/res/ethereum/callisto.json index 3513e8bb761..02dc3d27638 100644 --- a/ethcore/res/ethereum/callisto.json +++ b/ethcore/res/ethereum/callisto.json @@ -72,9 +72,50 @@ "0000000000000000000000000000000000000003": { "balance": "1", "builtin": { "name": "ripemd160", "pricing": { "linear": { "base": 600, "word": 120 } } } }, "0000000000000000000000000000000000000004": { "balance": "1", "builtin": { "name": "identity", "pricing": { "linear": { "base": 15, "word": 3 } } } }, "0000000000000000000000000000000000000005": { "balance": "1", "builtin": { "name": "modexp", "activate_at": 20, "pricing": { "modexp": { "divisor": 20 } } } }, - "0000000000000000000000000000000000000006": { "balance": "1", "builtin": { "name": "alt_bn128_add", "activate_at": 20, "pricing": { "linear": { "base": 500, "word": 0 } } } }, - "0000000000000000000000000000000000000007": { "balance": "1", "builtin": { "name": "alt_bn128_mul", "activate_at": 20, "pricing": { "linear": { "base": 40000, "word": 0 } } } }, - "0000000000000000000000000000000000000008": { "balance": "1", "builtin": { "name": "alt_bn128_pairing", "activate_at": 20, "pricing": { "alt_bn128_pairing": { "base": 100000, "pair": 80000 } } } }, + "0000000000000000000000000000000000000006": { + "balance": "1", + "builtin": { + "name": "alt_bn128_add", + "activate_at": 20, + "eip1108_transition": "0x7fffffffffffff", + "pricing": { + "alt_bn128_const_operations": { + "price": 500, + "eip1108_transition_price": 150 + } + } + } + }, + "0000000000000000000000000000000000000007": { + "balance": "1", + "builtin": { + "name": "alt_bn128_mul", + "activate_at": 20, + "eip1108_transition": "0x7fffffffffffff", + "pricing": { + "alt_bn128_const_operations": { + "price": 40000, + "eip1108_transition_price": 6000 + } + } + } + }, + "0000000000000000000000000000000000000008": { + "balance": "1", + "builtin": { + "name": "alt_bn128_pairing", + "activate_at": 20, + "eip1108_transition": "0x7fffffffffffff", + "pricing": { + "alt_bn128_pairing": { + "base": 100000, + "pair": 80000, + "eip1108_transition_base": 45000, + "eip1108_transition_pair": 34000 + } + } + } + }, "183394f52b2c8c034835edba3bcececa6f60b5a8": { "balance": "100491852286952719463755404" } diff --git a/ethcore/res/ethereum/classic.json b/ethcore/res/ethereum/classic.json index 2750f6f6391..f824f7667d4 100644 --- a/ethcore/res/ethereum/classic.json +++ b/ethcore/res/ethereum/classic.json @@ -3917,10 +3917,11 @@ "builtin": { "name": "alt_bn128_add", "activate_at": "0x85d9a0", + "eip1108_transition": "0x7fffffffffffff", "pricing": { - "linear": { - "base": 500, - "word": 0 + "alt_bn128_const_operations": { + "price": 500, + "eip1108_transition_price": 150 } } } @@ -3929,10 +3930,11 @@ "builtin": { "name": "alt_bn128_mul", "activate_at": "0x85d9a0", + "eip1108_transition": "0x7fffffffffffff", "pricing": { - "linear": { - "base": 40000, - "word": 0 + "alt_bn128_const_operations": { + "price": 40000, + "eip1108_transition_price": 6000 } } } @@ -3941,10 +3943,13 @@ "builtin": { "name": "alt_bn128_pairing", "activate_at": "0x85d9a0", + "eip1108_transition": "0x7fffffffffffff", "pricing": { "alt_bn128_pairing": { "base": 100000, - "pair": 80000 + "pair": 80000, + "eip1108_transition_base": 45000, + "eip1108_transition_pair": 34000 } } } diff --git a/ethcore/res/ethereum/constantinople_test.json b/ethcore/res/ethereum/constantinople_test.json index b6db5cddb9b..c61711e7a7f 100644 --- a/ethcore/res/ethereum/constantinople_test.json +++ b/ethcore/res/ethereum/constantinople_test.json @@ -58,8 +58,46 @@ "0000000000000000000000000000000000000003": { "balance": "1", "builtin": { "name": "ripemd160", "pricing": { "linear": { "base": 600, "word": 120 } } } }, "0000000000000000000000000000000000000004": { "balance": "1", "builtin": { "name": "identity", "pricing": { "linear": { "base": 15, "word": 3 } } } }, "0000000000000000000000000000000000000005": { "builtin": { "name": "modexp", "activate_at": "0x00", "pricing": { "modexp": { "divisor": 20 } } } }, - "0000000000000000000000000000000000000006": { "builtin": { "name": "alt_bn128_add", "activate_at": "0x00", "pricing": { "linear": { "base": 500, "word": 0 } } } }, - "0000000000000000000000000000000000000007": { "builtin": { "name": "alt_bn128_mul", "activate_at": "0x00", "pricing": { "linear": { "base": 40000, "word": 0 } } } }, - "0000000000000000000000000000000000000008": { "builtin": { "name": "alt_bn128_pairing", "activate_at": "0x00", "pricing": { "alt_bn128_pairing": { "base": 100000, "pair": 80000 } } } } + "0000000000000000000000000000000000000006": { + "builtin": { + "name": "alt_bn128_add", + "activate_at": "0x00", + "eip1108_transition": "0x7fffffffffffff", + "pricing": { + "alt_bn128_const_operations": { + "price": 500, + "eip1108_transition_price": 150 + } + } + } + }, + "0000000000000000000000000000000000000007": { + "builtin": { + "name": "alt_bn128_mul", + "activate_at": "0x00", + "eip1108_transition": "0x7fffffffffffff", + "pricing": { + "alt_bn128_const_operations": { + "price": 40000, + "eip1108_transition_price": 6000 + } + } + } + }, + "0000000000000000000000000000000000000008": { + "builtin": { + "name": "alt_bn128_pairing", + "activate_at": "0x00", + "eip1108_transition": "0x7fffffffffffff", + "pricing": { + "alt_bn128_pairing": { + "base": 100000, + "pair": 80000, + "eip1108_transition_base": 45000, + "eip1108_transition_pair": 34000 + } + } + } + } } } diff --git a/ethcore/res/ethereum/eip210_test.json b/ethcore/res/ethereum/eip210_test.json index adf7f2964ec..782e99e5e9e 100644 --- a/ethcore/res/ethereum/eip210_test.json +++ b/ethcore/res/ethereum/eip210_test.json @@ -46,8 +46,46 @@ "0000000000000000000000000000000000000003": { "balance": "1", "builtin": { "name": "ripemd160", "pricing": { "linear": { "base": 600, "word": 120 } } } }, "0000000000000000000000000000000000000004": { "balance": "1", "builtin": { "name": "identity", "pricing": { "linear": { "base": 15, "word": 3 } } } }, "0000000000000000000000000000000000000005": { "builtin": { "name": "modexp", "activate_at": "0x00", "pricing": { "modexp": { "divisor": 100 } } } }, - "0000000000000000000000000000000000000006": { "builtin": { "name": "alt_bn128_add", "activate_at": "0x00", "pricing": { "linear": { "base": 500, "word": 0 } } } }, - "0000000000000000000000000000000000000007": { "builtin": { "name": "alt_bn128_mul", "activate_at": "0x00", "pricing": { "linear": { "base": 2000, "word": 0 } } } }, - "0000000000000000000000000000000000000008": { "builtin": { "name": "alt_bn128_pairing", "activate_at": "0x00", "pricing": { "alt_bn128_pairing": { "base": 100000, "pair": 80000 } } } } + "0000000000000000000000000000000000000006": { + "builtin": { + "name": "alt_bn128_add", + "activate_at": "0x00", + "eip1108_transition": "0x7fffffffffffff", + "pricing": { + "alt_bn128_const_operations": { + "price": 500, + "eip1108_transition_price": 150 + } + } + } + }, + "0000000000000000000000000000000000000007": { + "builtin": { + "name": "alt_bn128_mul", + "activate_at": "0x00", + "eip1108_transition": "0x7fffffffffffff", + "pricing": { + "alt_bn128_const_operations": { + "price": 40000, + "eip1108_transition_price": 6000 + } + } + } + }, + "0000000000000000000000000000000000000008": { + "builtin": { + "name": "alt_bn128_pairing", + "activate_at": "0x00", + "eip1108_transition": "0x7fffffffffffff", + "pricing": { + "alt_bn128_pairing": { + "base": 100000, + "pair": 80000, + "eip1108_transition_base": 45000, + "eip1108_transition_pair": 34000 + } + } + } + } } } diff --git a/ethcore/res/ethereum/ellaism.json b/ethcore/res/ethereum/ellaism.json index 946b340f933..d1333fb7f3a 100644 --- a/ethcore/res/ethereum/ellaism.json +++ b/ethcore/res/ethereum/ellaism.json @@ -66,8 +66,46 @@ "0000000000000000000000000000000000000003": { "builtin": { "name": "ripemd160", "pricing": { "linear": { "base": 600, "word": 120 } } } }, "0000000000000000000000000000000000000004": { "builtin": { "name": "identity", "pricing": { "linear": { "base": 15, "word": 3 } } } }, "0000000000000000000000000000000000000005": { "builtin": { "name": "modexp", "activate_at": 2000000, "pricing": { "modexp": { "divisor": 20 } } } }, - "0000000000000000000000000000000000000006": { "builtin": { "name": "alt_bn128_add", "activate_at": 2000000, "pricing": { "linear": { "base": 500, "word": 0 } } } }, - "0000000000000000000000000000000000000007": { "builtin": { "name": "alt_bn128_mul", "activate_at": 2000000, "pricing": { "linear": { "base": 40000, "word": 0 } } } }, - "0000000000000000000000000000000000000008": { "builtin": { "name": "alt_bn128_pairing", "activate_at": 2000000, "pricing": { "alt_bn128_pairing": { "base": 100000, "pair": 80000 } } } } + "0000000000000000000000000000000000000006": { + "builtin": { + "name": "alt_bn128_add", + "activate_at": 2000000, + "eip1108_transition": "0x7fffffffffffff", + "pricing": { + "alt_bn128_const_operations": { + "price": 500, + "eip1108_transition_price": 150 + } + } + } + }, + "0000000000000000000000000000000000000007": { + "builtin": { + "name": "alt_bn128_mul", + "activate_at": 2000000, + "eip1108_transition": "0x7fffffffffffff", + "pricing": { + "alt_bn128_const_operations": { + "price": 40000, + "eip1108_transition_price": 6000 + } + } + } + }, + "0000000000000000000000000000000000000008": { + "builtin": { + "name": "alt_bn128_pairing", + "activate_at": 2000000, + "eip1108_transition": "0x7fffffffffffff", + "pricing": { + "alt_bn128_pairing": { + "base": 100000, + "pair": 80000, + "eip1108_transition_base": 45000, + "eip1108_transition_pair": 34000 + } + } + } + } } } diff --git a/ethcore/res/ethereum/ewc.json b/ethcore/res/ethereum/ewc.json index d78e7c383c4..1290526504b 100644 --- a/ethcore/res/ethereum/ewc.json +++ b/ethcore/res/ethereum/ewc.json @@ -109,11 +109,12 @@ "builtin": { "name": "alt_bn128_add", "activate_at": "0", + "eip1108_transition": "0x7fffffffffffff", "pricing": { - "linear": { - "base": 500, - "word": 0 - } + "alt_bn128_const_operations": { + "price": 500, + "eip1108_transition_price": 150 + } } } }, @@ -122,10 +123,11 @@ "builtin": { "name": "alt_bn128_mul", "activate_at": "0", + "eip1108_transition": "0x7fffffffffffff", "pricing": { - "linear": { - "base": 40000, - "word": 0 + "alt_bn128_const_operations": { + "price": 40000, + "eip1108_transition_price": 6000 } } } @@ -135,12 +137,15 @@ "builtin": { "name": "alt_bn128_pairing", "activate_at": "0", + "eip1108_transition": "0x7fffffffffffff", "pricing": { "alt_bn128_pairing": { "base": 100000, - "pair": 80000 + "pair": 80000, + "eip1108_transition_base": 45000, + "eip1108_transition_pair": 34000 } - } + } } }, "0x1204700000000000000000000000000000000005": { diff --git a/ethcore/res/ethereum/expanse.json b/ethcore/res/ethereum/expanse.json index 073d8fe4836..5b950e28b02 100644 --- a/ethcore/res/ethereum/expanse.json +++ b/ethcore/res/ethereum/expanse.json @@ -76,9 +76,47 @@ "0000000000000000000000000000000000000003": { "builtin": { "name": "ripemd160", "pricing": { "linear": { "base": 600, "word": 120 } } } }, "0000000000000000000000000000000000000004": { "builtin": { "name": "identity", "pricing": { "linear": { "base": 15, "word": 3 } } } }, "0000000000000000000000000000000000000005": { "builtin": { "name": "modexp", "activate_at": "0xC3500", "pricing": { "modexp": { "divisor": 20 } } } }, - "0000000000000000000000000000000000000006": { "builtin": { "name": "alt_bn128_add", "activate_at": "0xC3500", "pricing": { "linear": { "base": 500, "word": 0 } } } }, - "0000000000000000000000000000000000000007": { "builtin": { "name": "alt_bn128_mul", "activate_at": "0xC3500", "pricing": { "linear": { "base": 40000, "word": 0 } } } }, - "0000000000000000000000000000000000000008": { "builtin": { "name": "alt_bn128_pairing", "activate_at": "0xC3500", "pricing": { "alt_bn128_pairing": { "base": 100000, "pair": 80000 } } } }, + "0000000000000000000000000000000000000006": { + "builtin": { + "name": "alt_bn128_add", + "activate_at": "0xC3500", + "eip1108_transition": "0x7fffffffffffff", + "pricing": { + "alt_bn128_const_operations": { + "price": 500, + "eip1108_transition_price": 150 + } + } + } + }, + "0000000000000000000000000000000000000007": { + "builtin": { + "name": "alt_bn128_mul", + "activate_at": "0xC3500", + "eip1108_transition": "0x7fffffffffffff", + "pricing": { + "alt_bn128_const_operations": { + "price": 40000, + "eip1108_transition_price": 6000 + } + } + } + }, + "0000000000000000000000000000000000000008": { + "builtin": { + "name": "alt_bn128_pairing", + "activate_at": "0xC3500", + "eip1108_transition": "0x7fffffffffffff", + "pricing": { + "alt_bn128_pairing": { + "base": 100000, + "pair": 80000, + "eip1108_transition_base": 45000, + "eip1108_transition_pair": 34000 + } + } + } + }, "bb94f0ceb32257275b2a7a9c094c13e469b4563e": { "balance": "10000000000000000000000000" }, diff --git a/ethcore/res/ethereum/foundation.json b/ethcore/res/ethereum/foundation.json index 5a7fd3be318..f55e5492b8f 100644 --- a/ethcore/res/ethereum/foundation.json +++ b/ethcore/res/ethereum/foundation.json @@ -3921,10 +3921,11 @@ "builtin": { "name": "alt_bn128_add", "activate_at": "0x42ae50", + "eip1108_transition": "0x7fffffffffffff", "pricing": { - "linear": { - "base": 500, - "word": 0 + "alt_bn128_const_operations": { + "price": 500, + "eip1108_transition_price": 150 } } } @@ -3933,10 +3934,11 @@ "builtin": { "name": "alt_bn128_mul", "activate_at": "0x42ae50", + "eip1108_transition": "0x7fffffffffffff", "pricing": { - "linear": { - "base": 40000, - "word": 0 + "alt_bn128_const_operations": { + "price": 40000, + "eip1108_transition_price": 6000 } } } @@ -3945,10 +3947,13 @@ "builtin": { "name": "alt_bn128_pairing", "activate_at": "0x42ae50", + "eip1108_transition": "0x7fffffffffffff", "pricing": { "alt_bn128_pairing": { "base": 100000, - "pair": 80000 + "pair": 80000, + "eip1108_transition_base": 45000, + "eip1108_transition_pair": 34000 } } } diff --git a/ethcore/res/ethereum/goerli.json b/ethcore/res/ethereum/goerli.json index 9717099385e..2a0fdc0cabd 100644 --- a/ethcore/res/ethereum/goerli.json +++ b/ethcore/res/ethereum/goerli.json @@ -125,11 +125,12 @@ "balance": "0x1", "builtin": { "name": "alt_bn128_add", - "activate_at": "0x0", + "activate_at": "0x00", + "eip1108_transition": "0x7fffffffffffff", "pricing": { - "linear": { - "base": 500, - "word": 0 + "alt_bn128_const_operations": { + "price": 500, + "eip1108_transition_price": 150 } } } @@ -138,11 +139,12 @@ "balance": "0x1", "builtin": { "name": "alt_bn128_mul", - "activate_at": "0x0", + "activate_at": "0x00", + "eip1108_transition": "0x7fffffffffffff", "pricing": { - "linear": { - "base": 40000, - "word": 0 + "alt_bn128_const_operations": { + "price": 40000, + "eip1108_transition_price": 6000 } } } @@ -151,11 +153,14 @@ "balance": "0x1", "builtin": { "name": "alt_bn128_pairing", - "activate_at": "0x0", + "activate_at": "0x00", + "eip1108_transition": "0x7fffffffffffff", "pricing": { "alt_bn128_pairing": { "base": 100000, - "pair": 80000 + "pair": 80000, + "eip1108_transition_base": 45000, + "eip1108_transition_pair": 34000 } } } diff --git a/ethcore/res/ethereum/kotti.json b/ethcore/res/ethereum/kotti.json index 690269625b0..bc696a7db5a 100644 --- a/ethcore/res/ethereum/kotti.json +++ b/ethcore/res/ethereum/kotti.json @@ -117,10 +117,11 @@ "builtin": { "name": "alt_bn128_add", "activate_at": "0xaef49", + "eip1108_transition": "0x7fffffffffffff", "pricing": { - "linear": { - "base": 500, - "word": 0 + "alt_bn128_const_operations": { + "price": 500, + "eip1108_transition_price": 150 } } } @@ -130,10 +131,11 @@ "builtin": { "name": "alt_bn128_mul", "activate_at": "0xaef49", + "eip1108_transition": "0x7fffffffffffff", "pricing": { - "linear": { - "base": 40000, - "word": 0 + "alt_bn128_const_operations": { + "price": 40000, + "eip1108_transition_price": 6000 } } } @@ -143,10 +145,13 @@ "builtin": { "name": "alt_bn128_pairing", "activate_at": "0xaef49", + "eip1108_transition": "0x7fffffffffffff", "pricing": { "alt_bn128_pairing": { "base": 100000, - "pair": 80000 + "pair": 80000, + "eip1108_transition_base": 45000, + "eip1108_transition_pair": 34000 } } } diff --git a/ethcore/res/ethereum/kovan.json b/ethcore/res/ethereum/kovan.json index 2afd6e433ed..7e9bf761697 100644 --- a/ethcore/res/ethereum/kovan.json +++ b/ethcore/res/ethereum/kovan.json @@ -5344,10 +5344,11 @@ "builtin": { "name": "alt_bn128_add", "activate_at": "0x4d50f8", + "eip1108_transition": "0x7fffffffffffff", "pricing": { - "linear": { - "base": 500, - "word": 0 + "alt_bn128_const_operations": { + "price": 500, + "eip1108_transition_price": 150 } } } @@ -5356,10 +5357,11 @@ "builtin": { "name": "alt_bn128_mul", "activate_at": "0x4d50f8", + "eip1108_transition": "0x7fffffffffffff", "pricing": { - "linear": { - "base": 40000, - "word": 0 + "alt_bn128_const_operations": { + "price": 40000, + "eip1108_transition_price": 6000 } } } @@ -5368,10 +5370,13 @@ "builtin": { "name": "alt_bn128_pairing", "activate_at": "0x4d50f8", + "eip1108_transition": "0x7fffffffffffff", "pricing": { "alt_bn128_pairing": { "base": 100000, - "pair": 80000 + "pair": 80000, + "eip1108_transition_base": 45000, + "eip1108_transition_pair": 34000 } } } diff --git a/ethcore/res/ethereum/kovan_wasm_test.json b/ethcore/res/ethereum/kovan_wasm_test.json index a4e19b5dd72..54c4a1b83f1 100644 --- a/ethcore/res/ethereum/kovan_wasm_test.json +++ b/ethcore/res/ethereum/kovan_wasm_test.json @@ -60,9 +60,47 @@ "0x0000000000000000000000000000000000000003": { "balance": "1", "builtin": { "name": "ripemd160", "pricing": { "linear": { "base": 600, "word": 120 } } } }, "0x0000000000000000000000000000000000000004": { "balance": "1", "builtin": { "name": "identity", "pricing": { "linear": { "base": 15, "word": 3 } } } }, "0x0000000000000000000000000000000000000005": { "builtin": { "name": "modexp", "activate_at": 5067000, "pricing": { "modexp": { "divisor": 20 } } } }, - "0x0000000000000000000000000000000000000006": { "builtin": { "name": "alt_bn128_add", "activate_at": 5067000, "pricing": { "linear": { "base": 500, "word": 0 } } } }, - "0x0000000000000000000000000000000000000007": { "builtin": { "name": "alt_bn128_mul", "activate_at": 5067000, "pricing": { "linear": { "base": 40000, "word": 0 } } } }, - "0x0000000000000000000000000000000000000008": { "builtin": { "name": "alt_bn128_pairing", "activate_at": 5067000, "pricing": { "alt_bn128_pairing": { "base": 100000, "pair": 80000 } } } }, + "0x0000000000000000000000000000000000000006": { + "builtin": { + "name": "alt_bn128_add", + "activate_at": 5067000, + "eip1108_transition": "0x7fffffffffffff", + "pricing": { + "alt_bn128_const_operations": { + "price": 500, + "eip1108_transition_price": 150 + } + } + } + }, + "0x0000000000000000000000000000000000000007": { + "builtin": { + "name": "alt_bn128_mul", + "activate_at": 5067000, + "eip1108_transition": "0x7fffffffffffff", + "pricing": { + "alt_bn128_const_operations": { + "price": 40000, + "eip1108_transition_price": 6000 + } + } + } + }, + "0x0000000000000000000000000000000000000008": { + "builtin": { + "name": "alt_bn128_pairing", + "activate_at": 5067000, + "eip1108_transition": "0x7fffffffffffff", + "pricing": { + "alt_bn128_pairing": { + "base": 100000, + "pair": 80000, + "eip1108_transition_base": 45000, + "eip1108_transition_pair": 34000 + } + } + } + }, "0x00521965e7bd230323c423d96c657db5b79d099f": { "balance": "1606938044258990275541962092341162602522202993782792835301376" } }, "nodes": [ diff --git a/ethcore/res/ethereum/mcip3_test.json b/ethcore/res/ethereum/mcip3_test.json index 4fafcb09d74..8f1426b992a 100644 --- a/ethcore/res/ethereum/mcip3_test.json +++ b/ethcore/res/ethereum/mcip3_test.json @@ -120,38 +120,43 @@ } } }, - "0000000000000000000000000000000000000006":{ - "builtin":{ - "name":"alt_bn128_add", + "0000000000000000000000000000000000000006": { + "builtin": { + "name": "alt_bn128_add", "activate_at":"0x7fffffffffffff", - "pricing":{ - "linear":{ - "base":500, - "word":0 + "eip1108_transition": "0x7fffffffffffff", + "pricing": { + "alt_bn128_const_operations": { + "price": 500, + "eip1108_transition_price": 150 } } } }, - "0000000000000000000000000000000000000007":{ - "builtin":{ - "name":"alt_bn128_mul", + "0000000000000000000000000000000000000007": { + "builtin": { + "name": "alt_bn128_mul", "activate_at":"0x7fffffffffffff", - "pricing":{ - "linear":{ - "base":40000, - "word":0 + "eip1108_transition": "0x7fffffffffffff", + "pricing": { + "alt_bn128_const_operations": { + "price": 40000, + "eip1108_transition_price": 6000 } } } }, - "0000000000000000000000000000000000000008":{ - "builtin":{ - "name":"alt_bn128_pairing", + "0000000000000000000000000000000000000008": { + "builtin": { + "name": "alt_bn128_pairing", "activate_at":"0x7fffffffffffff", - "pricing":{ - "alt_bn128_pairing":{ - "base":100000, - "pair":80000 + "eip1108_transition": "0x7fffffffffffff", + "pricing": { + "alt_bn128_pairing": { + "base": 100000, + "pair": 80000, + "eip1108_transition_base": 45000, + "eip1108_transition_pair": 34000 } } } diff --git a/ethcore/res/ethereum/mix.json b/ethcore/res/ethereum/mix.json index 7cdffdda273..f788191c96f 100644 --- a/ethcore/res/ethereum/mix.json +++ b/ethcore/res/ethereum/mix.json @@ -62,9 +62,47 @@ "0000000000000000000000000000000000000003": { "builtin": { "name": "ripemd160", "pricing": { "linear": { "base": 600, "word": 120 } } } }, "0000000000000000000000000000000000000004": { "builtin": { "name": "identity", "pricing": { "linear": { "base": 15, "word": 3 } } } }, "0000000000000000000000000000000000000005": { "builtin": { "name": "modexp", "activate_at": 3000000, "pricing": { "modexp": { "divisor": 20 } } } }, - "0000000000000000000000000000000000000006": { "builtin": { "name": "alt_bn128_add", "activate_at": 3000000, "pricing": { "linear": { "base": 500, "word": 0 } } } }, - "0000000000000000000000000000000000000007": { "builtin": { "name": "alt_bn128_mul", "activate_at": 3000000, "pricing": { "linear": { "base": 40000, "word": 0 } } } }, - "0000000000000000000000000000000000000008": { "builtin": { "name": "alt_bn128_pairing", "activate_at": 3000000, "pricing": { "alt_bn128_pairing": { "base": 100000, "pair": 80000 } } } }, + "0000000000000000000000000000000000000006": { + "builtin": { + "name": "alt_bn128_add", + "activate_at": 3000000, + "eip1108_transition": "0x7fffffffffffff", + "pricing": { + "alt_bn128_const_operations": { + "price": 500, + "eip1108_transition_price": 150 + } + } + } + }, + "0000000000000000000000000000000000000007": { + "builtin": { + "name": "alt_bn128_mul", + "activate_at": 3000000, + "eip1108_transition": "0x7fffffffffffff", + "pricing": { + "alt_bn128_const_operations": { + "price": 40000, + "eip1108_transition_price": 6000 + } + } + } + }, + "0000000000000000000000000000000000000008": { + "builtin": { + "name": "alt_bn128_pairing", + "activate_at": 3000000, + "eip1108_transition": "0x7fffffffffffff", + "pricing": { + "alt_bn128_pairing": { + "base": 100000, + "pair": 80000, + "eip1108_transition_base": 45000, + "eip1108_transition_pair": 34000 + } + } + } + }, "97c7f4f8f0bbf384578a9f5754ae73f37ff49ec2": { "balance": "55000000000000000000000000" } } } diff --git a/ethcore/res/ethereum/morden.json b/ethcore/res/ethereum/morden.json index 5ea0f211432..a4be222c16c 100644 --- a/ethcore/res/ethereum/morden.json +++ b/ethcore/res/ethereum/morden.json @@ -90,10 +90,11 @@ "builtin": { "name": "alt_bn128_add", "activate_at": "0x4829ba", + "eip1108_transition": "0x7fffffffffffff", "pricing": { - "linear": { - "base": 500, - "word": 0 + "alt_bn128_const_operations": { + "price": 500, + "eip1108_transition_price": 150 } } } @@ -102,10 +103,11 @@ "builtin": { "name": "alt_bn128_mul", "activate_at": "0x4829ba", + "eip1108_transition": "0x7fffffffffffff", "pricing": { - "linear": { - "base": 40000, - "word": 0 + "alt_bn128_const_operations": { + "price": 40000, + "eip1108_transition_price": 6000 } } } @@ -114,10 +116,13 @@ "builtin": { "name": "alt_bn128_pairing", "activate_at": "0x4829ba", + "eip1108_transition": "0x7fffffffffffff", "pricing": { "alt_bn128_pairing": { "base": 100000, - "pair": 80000 + "pair": 80000, + "eip1108_transition_base": 45000, + "eip1108_transition_pair": 34000 } } } diff --git a/ethcore/res/ethereum/musicoin.json b/ethcore/res/ethereum/musicoin.json index 109432e58fd..a7cc956b47d 100644 --- a/ethcore/res/ethereum/musicoin.json +++ b/ethcore/res/ethereum/musicoin.json @@ -128,38 +128,43 @@ } } }, - "0000000000000000000000000000000000000006":{ - "builtin":{ - "name":"alt_bn128_add", + "0000000000000000000000000000000000000006": { + "builtin": { + "name": "alt_bn128_add", "activate_at":"0x21e88e", - "pricing":{ - "linear":{ - "base":500, - "word":0 + "eip1108_transition": "0x7fffffffffffff", + "pricing": { + "alt_bn128_const_operations": { + "price": 500, + "eip1108_transition_price": 150 } } } }, - "0000000000000000000000000000000000000007":{ - "builtin":{ - "name":"alt_bn128_mul", + "0000000000000000000000000000000000000007": { + "builtin": { + "name": "alt_bn128_mul", "activate_at":"0x21e88e", - "pricing":{ - "linear":{ - "base":40000, - "word":0 + "eip1108_transition": "0x7fffffffffffff", + "pricing": { + "alt_bn128_const_operations": { + "price": 40000, + "eip1108_transition_price": 6000 } } } }, - "0000000000000000000000000000000000000008":{ - "builtin":{ - "name":"alt_bn128_pairing", + "0000000000000000000000000000000000000008": { + "builtin": { + "name": "alt_bn128_pairing", "activate_at":"0x21e88e", - "pricing":{ - "alt_bn128_pairing":{ - "base":100000, - "pair":80000 + "eip1108_transition": "0x7fffffffffffff", + "pricing": { + "alt_bn128_pairing": { + "base": 100000, + "pair": 80000, + "eip1108_transition_base": 45000, + "eip1108_transition_pair": 34000 } } } diff --git a/ethcore/res/ethereum/poacore.json b/ethcore/res/ethereum/poacore.json index d1e0581ae59..0b1f0f46779 100644 --- a/ethcore/res/ethereum/poacore.json +++ b/ethcore/res/ethereum/poacore.json @@ -59,10 +59,47 @@ ], "accounts": { "0000000000000000000000000000000000000005": { "builtin": { "name": "modexp", "activate_at": "0x0", "pricing": { "modexp": { "divisor": 20 } } } }, - "0000000000000000000000000000000000000006": { "builtin": { "name": "alt_bn128_add", "activate_at": "0x0", "pricing": { "linear": { "base": 500, "word": 0 } } } }, - "0000000000000000000000000000000000000007": { "builtin": { "name": "alt_bn128_mul", "activate_at": "0x0", "pricing": { "linear": { "base": 40000, "word": 0 } } } }, - "0000000000000000000000000000000000000008": { "builtin": { "name": "alt_bn128_pairing", "activate_at": "0x0", "pricing": { "alt_bn128_pairing": { "base": 100000, "pair": 80000 } } } }, - + "0000000000000000000000000000000000000006": { + "builtin": { + "name": "alt_bn128_add", + "activate_at": "0x0", + "eip1108_transition": "0x7fffffffffffff", + "pricing": { + "alt_bn128_const_operations": { + "price": 500, + "eip1108_transition_price": 150 + } + } + } + }, + "0000000000000000000000000000000000000007": { + "builtin": { + "name": "alt_bn128_mul", + "activate_at": "0x0", + "eip1108_transition": "0x7fffffffffffff", + "pricing": { + "alt_bn128_const_operations": { + "price": 40000, + "eip1108_transition_price": 6000 + } + } + } + }, + "0000000000000000000000000000000000000008": { + "builtin": { + "name": "alt_bn128_pairing", + "activate_at": "0x0", + "eip1108_transition": "0x7fffffffffffff", + "pricing": { + "alt_bn128_pairing": { + "base": 100000, + "pair": 80000, + "eip1108_transition_base": 45000, + "eip1108_transition_pair": 34000 + } + } + } + }, "0x0000000000000000000000000000000000000001": { "balance": "1", "builtin": { diff --git a/ethcore/res/ethereum/poasokol.json b/ethcore/res/ethereum/poasokol.json index c20b6a0817c..9caef0bc945 100644 --- a/ethcore/res/ethereum/poasokol.json +++ b/ethcore/res/ethereum/poasokol.json @@ -65,9 +65,47 @@ ], "accounts": { "0000000000000000000000000000000000000005": { "builtin": { "name": "modexp", "activate_at": "0x0", "pricing": { "modexp": { "divisor": 20 } } } }, - "0000000000000000000000000000000000000006": { "builtin": { "name": "alt_bn128_add", "activate_at": "0x0", "pricing": { "linear": { "base": 500, "word": 0 } } } }, - "0000000000000000000000000000000000000007": { "builtin": { "name": "alt_bn128_mul", "activate_at": "0x0", "pricing": { "linear": { "base": 40000, "word": 0 } } } }, - "0000000000000000000000000000000000000008": { "builtin": { "name": "alt_bn128_pairing", "activate_at": "0x0", "pricing": { "alt_bn128_pairing": { "base": 100000, "pair": 80000 } } } }, + "0000000000000000000000000000000000000006": { + "builtin": { + "name": "alt_bn128_add", + "activate_at": "0x0", + "eip1108_transition": "0x7fffffffffffff", + "pricing": { + "alt_bn128_const_operations": { + "price": 500, + "eip1108_transition_price": 150 + } + } + } + }, + "0000000000000000000000000000000000000007": { + "builtin": { + "name": "alt_bn128_mul", + "activate_at": "0x0", + "eip1108_transition": "0x7fffffffffffff", + "pricing": { + "alt_bn128_const_operations": { + "price": 40000, + "eip1108_transition_price": 6000 + } + } + } + }, + "0000000000000000000000000000000000000008": { + "builtin": { + "name": "alt_bn128_pairing", + "activate_at": "0x0", + "eip1108_transition": "0x7fffffffffffff", + "pricing": { + "alt_bn128_pairing": { + "base": 100000, + "pair": 80000, + "eip1108_transition_base": 45000, + "eip1108_transition_pair": 34000 + } + } + } + }, "0x0000000000000000000000000000000000000001": { "balance": "1", diff --git a/ethcore/res/ethereum/rinkeby.json b/ethcore/res/ethereum/rinkeby.json index 18736177672..b6c7abe20d7 100644 --- a/ethcore/res/ethereum/rinkeby.json +++ b/ethcore/res/ethereum/rinkeby.json @@ -117,40 +117,42 @@ } }, "0x0000000000000000000000000000000000000006": { - "balance": "0x1", "builtin": { "name": "alt_bn128_add", "activate_at": "0xfcc25", + "eip1108_transition": "0x7fffffffffffff", "pricing": { - "linear": { - "base": 500, - "word": 0 + "alt_bn128_const_operations": { + "price": 500, + "eip1108_transition_price": 150 } } } }, "0x0000000000000000000000000000000000000007": { - "balance": "0x1", "builtin": { "name": "alt_bn128_mul", "activate_at": "0xfcc25", + "eip1108_transition": "0x7fffffffffffff", "pricing": { - "linear": { - "base": 40000, - "word": 0 + "alt_bn128_const_operations": { + "price": 40000, + "eip1108_transition_price": 6000 } } } }, "0x0000000000000000000000000000000000000008": { - "balance": "0x1", "builtin": { "name": "alt_bn128_pairing", "activate_at": "0xfcc25", + "eip1108_transition": "0x7fffffffffffff", "pricing": { "alt_bn128_pairing": { "base": 100000, - "pair": 80000 + "pair": 80000, + "eip1108_transition_base": 45000, + "eip1108_transition_pair": 34000 } } } diff --git a/ethcore/res/ethereum/ropsten.json b/ethcore/res/ethereum/ropsten.json index b9416dfc273..2d23a0a2974 100644 --- a/ethcore/res/ethereum/ropsten.json +++ b/ethcore/res/ethereum/ropsten.json @@ -2735,10 +2735,11 @@ "builtin": { "name": "alt_bn128_add", "activate_at": "0x19f0a0", + "eip1108_transition": "0x7fffffffffffff", "pricing": { - "linear": { - "base": 500, - "word": 0 + "alt_bn128_const_operations": { + "price": 500, + "eip1108_transition_price": 150 } } } @@ -2749,10 +2750,11 @@ "builtin": { "name": "alt_bn128_mul", "activate_at": "0x19f0a0", + "eip1108_transition": "0x7fffffffffffff", "pricing": { - "linear": { - "base": 40000, - "word": 0 + "alt_bn128_const_operations": { + "price": 40000, + "eip1108_transition_price": 6000 } } } @@ -2763,10 +2765,13 @@ "builtin": { "name": "alt_bn128_pairing", "activate_at": "0x19f0a0", + "eip1108_transition": "0x7fffffffffffff", "pricing": { "alt_bn128_pairing": { "base": 100000, - "pair": 80000 + "pair": 80000, + "eip1108_transition_base": 45000, + "eip1108_transition_pair": 34000 } } } diff --git a/ethcore/res/ethereum/st_peters_test.json b/ethcore/res/ethereum/st_peters_test.json index ee88008f668..9ae2f748949 100644 --- a/ethcore/res/ethereum/st_peters_test.json +++ b/ethcore/res/ethereum/st_peters_test.json @@ -58,8 +58,46 @@ "0000000000000000000000000000000000000003": { "balance": "1", "builtin": { "name": "ripemd160", "pricing": { "linear": { "base": 600, "word": 120 } } } }, "0000000000000000000000000000000000000004": { "balance": "1", "builtin": { "name": "identity", "pricing": { "linear": { "base": 15, "word": 3 } } } }, "0000000000000000000000000000000000000005": { "builtin": { "name": "modexp", "activate_at": "0x00", "pricing": { "modexp": { "divisor": 20 } } } }, - "0000000000000000000000000000000000000006": { "builtin": { "name": "alt_bn128_add", "activate_at": "0x00", "pricing": { "linear": { "base": 500, "word": 0 } } } }, - "0000000000000000000000000000000000000007": { "builtin": { "name": "alt_bn128_mul", "activate_at": "0x00", "pricing": { "linear": { "base": 40000, "word": 0 } } } }, - "0000000000000000000000000000000000000008": { "builtin": { "name": "alt_bn128_pairing", "activate_at": "0x00", "pricing": { "alt_bn128_pairing": { "base": 100000, "pair": 80000 } } } } + "0000000000000000000000000000000000000006": { + "builtin": { + "name": "alt_bn128_add", + "activate_at": "0x0", + "eip1108_transition": "0x7fffffffffffff", + "pricing": { + "alt_bn128_const_operations": { + "price": 500, + "eip1108_transition_price": 150 + } + } + } + }, + "0000000000000000000000000000000000000007": { + "builtin": { + "name": "alt_bn128_mul", + "activate_at": "0x0", + "eip1108_transition": "0x7fffffffffffff", + "pricing": { + "alt_bn128_const_operations": { + "price": 40000, + "eip1108_transition_price": 6000 + } + } + } + }, + "0000000000000000000000000000000000000008": { + "builtin": { + "name": "alt_bn128_pairing", + "activate_at": "0x0", + "eip1108_transition": "0x7fffffffffffff", + "pricing": { + "alt_bn128_pairing": { + "base": 100000, + "pair": 80000, + "eip1108_transition_base": 45000, + "eip1108_transition_pair": 34000 + } + } + } + } } } diff --git a/ethcore/res/ethereum/transition_test.json b/ethcore/res/ethereum/transition_test.json index 3f1c420dd68..bc28ebd509b 100644 --- a/ethcore/res/ethereum/transition_test.json +++ b/ethcore/res/ethereum/transition_test.json @@ -57,9 +57,46 @@ "0000000000000000000000000000000000000002": { "balance": "1", "builtin": { "name": "sha256", "pricing": { "linear": { "base": 60, "word": 12 } } } }, "0000000000000000000000000000000000000003": { "balance": "1", "builtin": { "name": "ripemd160", "pricing": { "linear": { "base": 600, "word": 120 } } } }, "0000000000000000000000000000000000000004": { "balance": "1", "builtin": { "name": "identity", "pricing": { "linear": { "base": 15, "word": 3 } } } }, - "0000000000000000000000000000000000000005": { "builtin": { "name": "modexp", "activate_at": "5", "pricing": { "modexp": { "divisor": 100 } } } }, - "0000000000000000000000000000000000000006": { "builtin": { "name": "alt_bn128_add", "activate_at": "5", "pricing": { "linear": { "base": 500, "word": 0 } } } }, - "0000000000000000000000000000000000000007": { "builtin": { "name": "alt_bn128_mul", "activate_at": "5", "pricing": { "linear": { "base": 2000, "word": 0 } } } }, - "0000000000000000000000000000000000000008": { "builtin": { "name": "alt_bn128_pairing", "activate_at": "5", "pricing": { "alt_bn128_pairing": { "base": 100000, "pair": 80000 } } } } + "0000000000000000000000000000000000000006": { + "builtin": { + "name": "alt_bn128_add", + "activate_at": "5", + "eip1108_transition": "0x7fffffffffffff", + "pricing": { + "alt_bn128_const_operations": { + "price": 500, + "eip1108_transition_price": 150 + } + } + } + }, + "0000000000000000000000000000000000000007": { + "builtin": { + "name": "alt_bn128_mul", + "activate_at": "5", + "eip1108_transition": "0x7fffffffffffff", + "pricing": { + "alt_bn128_const_operations": { + "price": 40000, + "eip1108_transition_price": 6000 + } + } + } + }, + "0000000000000000000000000000000000000008": { + "builtin": { + "name": "alt_bn128_pairing", + "activate_at": "5", + "eip1108_transition": "0x7fffffffffffff", + "pricing": { + "alt_bn128_pairing": { + "base": 100000, + "pair": 80000, + "eip1108_transition_base": 45000, + "eip1108_transition_pair": 34000 + } + } + } + } } } diff --git a/ethcore/res/ethereum/volta.json b/ethcore/res/ethereum/volta.json index d43d6c06853..9ac6f9afa43 100644 --- a/ethcore/res/ethereum/volta.json +++ b/ethcore/res/ethereum/volta.json @@ -109,40 +109,45 @@ "builtin": { "name": "alt_bn128_add", "activate_at": "0", + "eip1108_transition": "0x7fffffffffffff", "pricing": { - "linear": { - "base": 500, - "word": 0 + "alt_bn128_const_operations": { + "price": 500, + "eip1108_transition_price": 150 } } } - }, - "0x0000000000000000000000000000000000000007": { + }, + "0x0000000000000000000000000000000000000007": { "balance": "1", "builtin": { "name": "alt_bn128_mul", "activate_at": "0", + "eip1108_transition": "0x7fffffffffffff", "pricing": { - "linear": { - "base": 40000, - "word": 0 + "alt_bn128_const_operations": { + "price": 40000, + "eip1108_transition_price": 6000 } } - } + } }, "0x0000000000000000000000000000000000000008": { "balance": "1", "builtin": { "name": "alt_bn128_pairing", "activate_at": "0", + "eip1108_transition": "0x7fffffffffffff", "pricing": { "alt_bn128_pairing": { "base": 100000, - "pair": 80000 + "pair": 80000, + "eip1108_transition_base": 45000, + "eip1108_transition_pair": 34000 } } } - }, + }, "0x1204700000000000000000000000000000000005": { "constructor": "0x606060405234156200001057600080fd5b6040516200240138038062002401833981016040528080518201919060200180519060200190919050505b600082518260328211158015620000525750818111155b801562000060575060008114155b80156200006e575060008214155b15156200007a57600080fd5b600092505b8451831015620001b6576002600086858151811015156200009c57fe5b9060200190602002015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161580156200012b5750600085848151811015156200010857fe5b9060200190602002015173ffffffffffffffffffffffffffffffffffffffff1614155b15156200013757600080fd5b60016002600087868151811015156200014c57fe5b9060200190602002015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055505b82806001019350506200007f565b8460039080519060200190620001ce929190620001e3565b50836004819055505b5b5050505050620002b8565b8280548282559060005260206000209081019282156200025f579160200282015b828111156200025e5782518260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055509160200191906001019062000204565b5b5090506200026e919062000272565b5090565b620002b591905b80821115620002b157600081816101000a81549073ffffffffffffffffffffffffffffffffffffffff02191690555060010162000279565b5090565b90565b61213980620002c86000396000f3006060604052361561011b576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063025e7c2714610177578063173825d9146101da57806320ea8d86146102135780632f54bf6e146102365780633411c81c1461028757806354741525146102e15780637065cb4814610325578063784547a71461035e5780638b51d13f146103995780639ace38c2146103d0578063a0e67e2b146104ce578063a8abe69a14610539578063b5dc40c3146105d1578063b77bf6001461064a578063ba51a6df14610673578063c01a8c8414610696578063c6427474146106b9578063d74f8edd14610752578063dc8452cd1461077b578063e20056e6146107a4578063ee22610b146107fc575b5b6000341115610174573373ffffffffffffffffffffffffffffffffffffffff167fe1fffcc4923d04b559f4d29a8bfc6cda04eb5b0d3c460751c2402c5c5cc9109c346040518082815260200191505060405180910390a25b5b005b341561018257600080fd5b610198600480803590602001909190505061081f565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34156101e557600080fd5b610211600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190505061085f565b005b341561021e57600080fd5b6102346004808035906020019091905050610b02565b005b341561024157600080fd5b61026d600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610cae565b604051808215151515815260200191505060405180910390f35b341561029257600080fd5b6102c7600480803590602001909190803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610cce565b604051808215151515815260200191505060405180910390f35b34156102ec57600080fd5b61030f600480803515159060200190919080351515906020019091905050610cfd565b6040518082815260200191505060405180910390f35b341561033057600080fd5b61035c600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610d91565b005b341561036957600080fd5b61037f6004808035906020019091905050610f99565b604051808215151515815260200191505060405180910390f35b34156103a457600080fd5b6103ba6004808035906020019091905050611081565b6040518082815260200191505060405180910390f35b34156103db57600080fd5b6103f16004808035906020019091905050611150565b604051808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200184815260200180602001831515151581526020018281038252848181546001816001161561010002031660029004815260200191508054600181600116156101000203166002900480156104bc5780601f10610491576101008083540402835291602001916104bc565b820191906000526020600020905b81548152906001019060200180831161049f57829003601f168201915b50509550505050505060405180910390f35b34156104d957600080fd5b6104e16111ac565b6040518080602001828103825283818151815260200191508051906020019060200280838360005b838110156105255780820151818401525b602081019050610509565b505050509050019250505060405180910390f35b341561054457600080fd5b610579600480803590602001909190803590602001909190803515159060200190919080351515906020019091905050611241565b6040518080602001828103825283818151815260200191508051906020019060200280838360005b838110156105bd5780820151818401525b6020810190506105a1565b505050509050019250505060405180910390f35b34156105dc57600080fd5b6105f260048080359060200190919050506113a2565b6040518080602001828103825283818151815260200191508051906020019060200280838360005b838110156106365780820151818401525b60208101905061061a565b505050509050019250505060405180910390f35b341561065557600080fd5b61065d6115d3565b6040518082815260200191505060405180910390f35b341561067e57600080fd5b61069460048080359060200190919050506115d9565b005b34156106a157600080fd5b6106b76004808035906020019091905050611696565b005b34156106c457600080fd5b61073c600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803590602001909190803590602001908201803590602001908080601f01602080910402602001604051908101604052809392919081815260200183838082843782019150505050505091905050611877565b6040518082815260200191505060405180910390f35b341561075d57600080fd5b610765611897565b6040518082815260200191505060405180910390f35b341561078657600080fd5b61078e61189c565b6040518082815260200191505060405180910390f35b34156107af57600080fd5b6107fa600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff169060200190919050506118a2565b005b341561080757600080fd5b61081d6004808035906020019091905050611bc0565b005b60038181548110151561082e57fe5b906000526020600020900160005b915054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60003073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561089b57600080fd5b81600260008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615156108f457600080fd5b6000600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff021916908315150217905550600091505b600160038054905003821015610a80578273ffffffffffffffffffffffffffffffffffffffff1660038381548110151561098757fe5b906000526020600020900160005b9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161415610a725760036001600380549050038154811015156109e757fe5b906000526020600020900160005b9054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600383815481101515610a2357fe5b906000526020600020900160005b6101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550610a80565b5b8180600101925050610951565b6001600381818054905003915081610a989190611fe8565b506003805490506004541115610ab757610ab66003805490506115d9565b5b8273ffffffffffffffffffffffffffffffffffffffff167f8001553a916ef2f495d26a907cc54d96ed840d7bda71e73194bf5a9df7a76b9060405160405180910390a25b5b505b5050565b33600260008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161515610b5b57600080fd5b81336001600083815260200190815260200160002060008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161515610bc657600080fd5b8360008082815260200190815260200160002060030160009054906101000a900460ff16151515610bf657600080fd5b60006001600087815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff021916908315150217905550843373ffffffffffffffffffffffffffffffffffffffff167ff6a317157440607f36269043eb55f1287a5a19ba2216afeab88cd46cbcfb88e960405160405180910390a35b5b505b50505b5050565b60026020528060005260406000206000915054906101000a900460ff1681565b60016020528160005260406000206020528060005260406000206000915091509054906101000a900460ff1681565b600080600090505b600554811015610d8957838015610d3c575060008082815260200190815260200160002060030160009054906101000a900460ff16155b80610d6f5750828015610d6e575060008082815260200190815260200160002060030160009054906101000a900460ff165b5b15610d7b576001820191505b5b8080600101915050610d05565b5b5092915050565b3073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610dcb57600080fd5b80600260008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16151515610e2557600080fd5b8160008173ffffffffffffffffffffffffffffffffffffffff1614151515610e4c57600080fd5b60016003805490500160045460328211158015610e695750818111155b8015610e76575060008114155b8015610e83575060008214155b1515610e8e57600080fd5b6001600260008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555060038054806001018281610efa9190612014565b916000526020600020900160005b87909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550508473ffffffffffffffffffffffffffffffffffffffff167ff39e6e1eb0edcf53c221607b54b00cd28f3196fed0a24994dc308b8f611b682d60405160405180910390a25b5b50505b505b505b50565b6000806000809150600090505b60038054905081101561107957600160008581526020019081526020016000206000600383815481101515610fd757fe5b906000526020600020900160005b9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615611058576001820191505b60045482141561106b576001925061107a565b5b8080600101915050610fa6565b5b5050919050565b600080600090505b600380549050811015611149576001600084815260200190815260200160002060006003838154811015156110ba57fe5b906000526020600020900160005b9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161561113b576001820191505b5b8080600101915050611089565b5b50919050565b60006020528060005260406000206000915090508060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169080600101549080600201908060030160009054906101000a900460ff16905084565b6111b4612040565b600380548060200260200160405190810160405280929190818152602001828054801561123657602002820191906000526020600020905b8160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190600101908083116111ec575b505050505090505b90565b611249612054565b611251612054565b6000806005546040518059106112645750595b908082528060200260200182016040525b50925060009150600090505b600554811015611322578580156112b8575060008082815260200190815260200160002060030160009054906101000a900460ff16155b806112eb57508480156112ea575060008082815260200190815260200160002060030160009054906101000a900460ff165b5b15611314578083838151811015156112ff57fe5b90602001906020020181815250506001820191505b5b8080600101915050611281565b8787036040518059106113325750595b908082528060200260200182016040525b5093508790505b8681101561139657828181518110151561136057fe5b906020019060200201518489830381518110151561137a57fe5b90602001906020020181815250505b808060010191505061134a565b5b505050949350505050565b6113aa612040565b6113b2612040565b6000806003805490506040518059106113c85750595b908082528060200260200182016040525b50925060009150600090505b60038054905081101561152b5760016000868152602001908152602001600020600060038381548110151561141657fe5b906000526020600020900160005b9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161561151d5760038181548110151561149f57fe5b906000526020600020900160005b9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1683838151811015156114da57fe5b9060200190602002019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250506001820191505b5b80806001019150506113e5565b816040518059106115395750595b908082528060200260200182016040525b509350600090505b818110156115ca57828181518110151561156857fe5b90602001906020020151848281518110151561158057fe5b9060200190602002019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250505b8080600101915050611552565b5b505050919050565b60055481565b3073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561161357600080fd5b600380549050816032821115801561162b5750818111155b8015611638575060008114155b8015611645575060008214155b151561165057600080fd5b826004819055507fa3f1ee9126a074d9326c682f561767f710e927faa811f7a99829d49dc421797a836040518082815260200191505060405180910390a15b5b50505b50565b33600260008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615156116ef57600080fd5b81600080600083815260200190815260200160002060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161415151561174b57600080fd5b82336001600083815260200190815260200160002060008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161515156117b757600080fd5b600180600087815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff021916908315150217905550843373ffffffffffffffffffffffffffffffffffffffff167f4a504a94899432a9846e1aa406dceb1bcfd538bb839071d49d1e5e23f5be30ef60405160405180910390a361186c85611bc0565b5b5b50505b505b5050565b6000611884848484611e6c565b905061188f81611696565b5b9392505050565b603281565b60045481565b60003073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156118de57600080fd5b82600260008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16151561193757600080fd5b82600260008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615151561199157600080fd5b600092505b600380549050831015611a7f578473ffffffffffffffffffffffffffffffffffffffff166003848154811015156119c957fe5b906000526020600020900160005b9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161415611a715783600384815481101515611a2257fe5b906000526020600020900160005b6101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550611a7f565b5b8280600101935050611996565b6000600260008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506001600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508473ffffffffffffffffffffffffffffffffffffffff167f8001553a916ef2f495d26a907cc54d96ed840d7bda71e73194bf5a9df7a76b9060405160405180910390a28373ffffffffffffffffffffffffffffffffffffffff167ff39e6e1eb0edcf53c221607b54b00cd28f3196fed0a24994dc308b8f611b682d60405160405180910390a25b5b505b505b505050565b600033600260008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161515611c1b57600080fd5b82336001600083815260200190815260200160002060008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161515611c8657600080fd5b8460008082815260200190815260200160002060030160009054906101000a900460ff16151515611cb657600080fd5b611cbf86610f99565b15611e6057600080878152602001908152602001600020945060018560030160006101000a81548160ff021916908315150217905550611ddd8560000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16866001015487600201805460018160011615610100020316600290049050886002018054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015611dd35780601f10611da857610100808354040283529160200191611dd3565b820191906000526020600020905b815481529060010190602001808311611db657829003601f168201915b5050505050611fc0565b15611e1457857f33e13ecb54c3076d8e8bb8c2881800a4d972b792045ffae98fdf46df365fed7560405160405180910390a2611e5f565b857f526441bb6c1aba3c9a4a6ca1d6545da9c2333c8c48343ef398eb858d72b7923660405160405180910390a260008560030160006101000a81548160ff0219169083151502179055505b5b5b5b505b50505b505050565b60008360008173ffffffffffffffffffffffffffffffffffffffff1614151515611e9557600080fd5b60055491506080604051908101604052808673ffffffffffffffffffffffffffffffffffffffff1681526020018581526020018481526020016000151581525060008084815260200190815260200160002060008201518160000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550602082015181600101556040820151816002019080519060200190611f54929190612068565b5060608201518160030160006101000a81548160ff0219169083151502179055509050506001600560008282540192505081905550817fc0ba8fe4b176c1714197d43b9cc6bcf797a4a7461c5fe8d0ef6e184ae7601e5160405160405180910390a25b5b509392505050565b6000806040516020840160008287838a8c6187965a03f1925050508091505b50949350505050565b81548183558181151161200f5781836000526020600020918201910161200e91906120e8565b5b505050565b81548183558181151161203b5781836000526020600020918201910161203a91906120e8565b5b505050565b602060405190810160405280600081525090565b602060405190810160405280600081525090565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106120a957805160ff19168380011785556120d7565b828001600101855582156120d7579182015b828111156120d65782518255916020019190600101906120bb565b5b5090506120e491906120e8565b5090565b61210a91905b808211156121065760008160009055506001016120ee565b5090565b905600a165627a7a72305820f1129b699b3017535535a920e15503cd06af1f5c77637c0637cc29355b1dad3400290000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000040000000000000000000000000cb1437200aea736788f1fc56f327c0456c3598d00000000000000000000000074dd76e24b2cfb43c1b1a4498295d553d0843746000000000000000000000000eeb4ceee443f9e0d17bdbd6daa241681ee5e51c2000000000000000000000000a005caea55375ae20e3aaef746113535503abc19" }, diff --git a/ethcore/res/ethereum/xdai.json b/ethcore/res/ethereum/xdai.json index ad2aa395eea..ac2a40e1489 100644 --- a/ethcore/res/ethereum/xdai.json +++ b/ethcore/res/ethereum/xdai.json @@ -65,10 +65,11 @@ "builtin": { "name": "alt_bn128_add", "activate_at": "0x0", + "eip1108_transition": "0x7fffffffffffff", "pricing": { - "linear": { - "base": 500, - "word": 0 + "alt_bn128_const_operations": { + "price": 500, + "eip1108_transition_price": 150 } } } @@ -77,10 +78,11 @@ "builtin": { "name": "alt_bn128_mul", "activate_at": "0x0", + "eip1108_transition": "0x7fffffffffffff", "pricing": { - "linear": { - "base": 40000, - "word": 0 + "alt_bn128_const_operations": { + "price": 40000, + "eip1108_transition_price": 6000 } } } @@ -89,10 +91,13 @@ "builtin": { "name": "alt_bn128_pairing", "activate_at": "0x0", + "eip1108_transition": "0x7fffffffffffff", "pricing": { "alt_bn128_pairing": { "base": 100000, - "pair": 80000 + "pair": 80000, + "eip1108_transition_base": 45000, + "eip1108_transition_pair": 34000 } } } @@ -147,6 +152,6 @@ } }, "nodes": [ - "enode://66786c15390cb4fef3743571e12ec54ca343e7f119018136d68b670edd93604eedf74e5013dc5c2439f89e0e05593e29c409a97e155ea4165c6b832de131ef1e@3.214.113.185:30303" + "enode://66786c15390cb4fef3743571e12ec54ca343e7f119018136d68b670edd93604eedf74e5013dc5c2439f89e0e05593e29c409a97e155ea4165c6b832de131ef1e@3.214.113.185:30303" ] } diff --git a/ethcore/res/instant_seal.json b/ethcore/res/instant_seal.json index 0a46f07ff67..0bd79204fb9 100644 --- a/ethcore/res/instant_seal.json +++ b/ethcore/res/instant_seal.json @@ -46,9 +46,50 @@ "0000000000000000000000000000000000000003": { "balance": "1", "builtin": { "name": "ripemd160", "pricing": { "linear": { "base": 600, "word": 120 } } } }, "0000000000000000000000000000000000000004": { "balance": "1", "builtin": { "name": "identity", "pricing": { "linear": { "base": 15, "word": 3 } } } }, "0000000000000000000000000000000000000005": { "balance": "1", "builtin": { "name": "modexp", "activate_at": 0, "pricing": { "modexp": { "divisor": 20 } } } }, - "0000000000000000000000000000000000000006": { "balance": "1", "builtin": { "name": "alt_bn128_add", "activate_at": 0, "pricing": { "linear": { "base": 500, "word": 0 } } } }, - "0000000000000000000000000000000000000007": { "balance": "1", "builtin": { "name": "alt_bn128_mul", "activate_at": 0, "pricing": { "linear": { "base": 40000, "word": 0 } } } }, - "0000000000000000000000000000000000000008": { "balance": "1", "builtin": { "name": "alt_bn128_pairing", "activate_at": 0, "pricing": { "alt_bn128_pairing": { "base": 100000, "pair": 80000 } } } }, + "0000000000000000000000000000000000000006": { + "balance": "1", + "builtin": { + "name": "alt_bn128_add", + "activate_at": 0, + "eip1108_transition": "0x7fffffffffffff", + "pricing": { + "alt_bn128_const_operations": { + "price": 500, + "eip1108_transition_price": 150 + } + } + } + }, + "0000000000000000000000000000000000000007": { + "balance": "1", + "builtin": { + "name": "alt_bn128_mul", + "activate_at": 0, + "eip1108_transition": "0x7fffffffffffff", + "pricing": { + "alt_bn128_const_operations": { + "price": 40000, + "eip1108_transition_price": 6000 + } + } + } + }, + "0000000000000000000000000000000000000008": { + "balance": "1", + "builtin": { + "name": "alt_bn128_pairing", + "activate_at": 0, + "eip1108_transition": "0x7fffffffffffff", + "pricing": { + "alt_bn128_pairing": { + "base": 100000, + "pair": 80000, + "eip1108_transition_base": 45000, + "eip1108_transition_pair": 34000 + } + } + } + }, "0000000000000000000000000000000000001337": { "balance": "1", "constructor": "0x606060405233600060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550670de0b6b3a764000060035534610000575b612904806100666000396000f3006060604052361561013c576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306b2ff471461014157806313af40351461018c57806319362a28146101bf5780633f3935d114610248578063432ced04146102b75780634f39ca59146102eb5780636795dbcd1461032457806369fe0e2d146103c857806379ce9fac146103fd5780638da5cb5b1461045557806390b97fc1146104a457806392698814146105245780639890220b1461055d578063ac4e73f914610584578063ac72c12014610612578063c3a358251461064b578063ddca3f43146106c3578063deb931a2146106e6578063df57b74214610747578063e30bd740146107a8578063eadf976014610862578063ef5454d6146108e7578063f25eb5c114610975578063f6d339e414610984575b610000565b3461000057610172600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610a1f565b604051808215151515815260200191505060405180910390f35b34610000576101bd600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610a81565b005b346100005761022e60048080356000191690602001909190803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509190803560001916906020019091905050610ba2565b604051808215151515815260200191505060405180910390f35b346100005761029d600480803590602001908201803590602001908080601f01602080910402602001604051908101604052809392919081815260200183838082843782019150505050505091905050610dc9565b604051808215151515815260200191505060405180910390f35b6102d1600480803560001916906020019091905050611035565b604051808215151515815260200191505060405180910390f35b346100005761030a60048080356000191690602001909190505061115f565b604051808215151515815260200191505060405180910390f35b346100005761038660048080356000191690602001909190803590602001908201803590602001908080601f01602080910402602001604051908101604052809392919081815260200183838082843782019150505050505091905050611378565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34610000576103e3600480803590602001909190505061140d565b604051808215151515815260200191505060405180910390f35b346100005761043b60048080356000191690602001909190803573ffffffffffffffffffffffffffffffffffffffff169060200190919050506114b4565b604051808215151515815260200191505060405180910390f35b34610000576104626115fb565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b346100005761050660048080356000191690602001909190803590602001908201803590602001908080601f01602080910402602001604051908101604052809392919081815260200183838082843782019150505050505091905050611621565b60405180826000191660001916815260200191505060405180910390f35b34610000576105436004808035600019169060200190919050506116b2565b604051808215151515815260200191505060405180910390f35b346100005761056a611715565b604051808215151515815260200191505060405180910390f35b34610000576105f8600480803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509190803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050611824565b604051808215151515815260200191505060405180910390f35b3461000057610631600480803560001916906020019091905050611d8b565b604051808215151515815260200191505060405180910390f35b34610000576106ad60048080356000191690602001909190803590602001908201803590602001908080601f01602080910402602001604051908101604052809392919081815260200183838082843782019150505050505091905050611dee565b6040518082815260200191505060405180910390f35b34610000576106d0611e83565b6040518082815260200191505060405180910390f35b3461000057610705600480803560001916906020019091905050611e89565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3461000057610766600480803560001916906020019091905050611ed2565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34610000576107d9600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050611f1b565b6040518080602001828103825283818151815260200191508051906020019080838360008314610828575b80518252602083111561082857602082019150602081019050602083039250610804565b505050905090810190601f1680156108545780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34610000576108cd60048080356000191690602001909190803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509190803590602001909190505061200c565b604051808215151515815260200191505060405180910390f35b346100005761095b600480803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509190803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050612236565b604051808215151515815260200191505060405180910390f35b3461000057610982612425565b005b3461000057610a0560048080356000191690602001909190803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509190803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050612698565b604051808215151515815260200191505060405180910390f35b60006000600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020805460018160011615610100020316600290049050141590505b919050565b600060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610add57610b9f565b8073ffffffffffffffffffffffffffffffffffffffff16600060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f70aea8d848e8a90fb7661b227dc522eb6395c3dac71b63cb59edd5c9899b236460405180905060405180910390a380600060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505b5b50565b6000833373ffffffffffffffffffffffffffffffffffffffff1660016000836000191660001916815260200190815260200160002060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16141515610c1d57610dc1565b82600160008760001916600019168152602001908152602001600020600201856040518082805190602001908083835b60208310610c705780518252602082019150602081019050602083039250610c4d565b6001836020036101000a03801982511681845116808217855250505050505090500191505090815260200160405180910390208160001916905550836040518082805190602001908083835b60208310610cdf5780518252602082019150602081019050602083039250610cbc565b6001836020036101000a038019825116818451168082178552505050505050905001915050604051809103902085600019167fb829c3e412537bbe794c048ccb9e4605bb4aaaa8e4d4c15c1a6e0c2adc1716ea866040518080602001828103825283818151815260200191508051906020019080838360008314610d82575b805182526020831115610d8257602082019150602081019050602083039250610d5e565b505050905090810190601f168015610dae5780820380516001836020036101000a031916815260200191505b509250505060405180910390a3600191505b5b509392505050565b6000813373ffffffffffffffffffffffffffffffffffffffff1660016000836040518082805190602001908083835b60208310610e1b5780518252602082019150602081019050602083039250610df8565b6001836020036101000a03801982511681845116808217855250505050505090500191505060405180910390206000191660001916815260200190815260200160002060010160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16141515610ea45761102f565b82600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000209080519060200190828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f10610f2d57805160ff1916838001178555610f5b565b82800160010185558215610f5b579182015b82811115610f5a578251825591602001919060010190610f3f565b5b509050610f8091905b80821115610f7c576000816000905550600101610f64565b5090565b50503373ffffffffffffffffffffffffffffffffffffffff16836040518082805190602001908083835b60208310610fcd5780518252602082019150602081019050602083039250610faa565b6001836020036101000a03801982511681845116808217855250505050505090500191505060405180910390207f098ae8581bb8bd9af1beaf7f2e9f51f31a8e5a8bfada4e303a645d71d9c9192060405180905060405180910390a3600191505b5b50919050565b600081600060016000836000191660001916815260200190815260200160002060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614151561109b57611159565b6003543410156110aa57611158565b3360016000856000191660001916815260200190815260200160002060000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055503373ffffffffffffffffffffffffffffffffffffffff1683600019167f4963513eca575aba66fdcd25f267aae85958fe6fb97e75fa25d783f1a091a22160405180905060405180910390a3600191505b5b5b50919050565b6000813373ffffffffffffffffffffffffffffffffffffffff1660016000836000191660001916815260200190815260200160002060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161415156111da57611372565b6002600060016000866000191660001916815260200190815260200160002060010160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020805460018160011615610100020316600290046000825580601f1061127c57506112b3565b601f0160209004906000526020600020908101906112b291905b808211156112ae576000816000905550600101611296565b5090565b5b5060016000846000191660001916815260200190815260200160002060006000820160006101000a81549073ffffffffffffffffffffffffffffffffffffffff02191690556001820160006101000a81549073ffffffffffffffffffffffffffffffffffffffff021916905550503373ffffffffffffffffffffffffffffffffffffffff1683600019167fef1961b4d2909dc23643b309bfe5c3e5646842d98c3a58517037ef3871185af360405180905060405180910390a3600191505b5b50919050565b6000600160008460001916600019168152602001908152602001600020600201826040518082805190602001908083835b602083106113cc57805182526020820191506020810190506020830392506113a9565b6001836020036101000a0380198251168184511680821785525050505050509050019150509081526020016040518091039020546001900490505b92915050565b6000600060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561146b576114af565b816003819055507f6bbc57480a46553fa4d156ce702beef5f3ad66303b0ed1a5d4cb44966c6584c3826040518082815260200191505060405180910390a1600190505b5b919050565b6000823373ffffffffffffffffffffffffffffffffffffffff1660016000836000191660001916815260200190815260200160002060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614151561152f576115f4565b8260016000866000191660001916815260200190815260200160002060000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1685600019167f7b97c62130aa09acbbcbf7482630e756592496f1759eaf702f469cf64dfb779460405180905060405180910390a4600191505b5b5092915050565b600060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000600160008460001916600019168152602001908152602001600020600201826040518082805190602001908083835b602083106116755780518252602082019150602081019050602083039250611652565b6001836020036101000a03801982511681845116808217855250505050505090500191505090815260200160405180910390205490505b92915050565b6000600060016000846000191660001916815260200190815260200160002060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16141590505b919050565b6000600060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561177357611821565b7fdef931299fe61d176f949118058530c1f3f539dcb6950b4e372c9b835c33ca073073ffffffffffffffffffffffffffffffffffffffff16316040518082815260200191505060405180910390a13373ffffffffffffffffffffffffffffffffffffffff166108fc3073ffffffffffffffffffffffffffffffffffffffff16319081150290604051809050600060405180830381858888f19350505050151561181b57610000565b600190505b5b90565b60006000836040518082805190602001908083835b6020831061185c5780518252602082019150602081019050602083039250611839565b6001836020036101000a03801982511681845116808217855250505050505090500191505060405180910390203373ffffffffffffffffffffffffffffffffffffffff1660016000836000191660001916815260200190815260200160002060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614151561190157611d83565b846040518082805190602001908083835b602083106119355780518252602082019150602081019050602083039250611912565b6001836020036101000a03801982511681845116808217855250505050505090500191505060405180910390209150600060016000846000191660001916815260200190815260200160002060010160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614158015611ab4575081600019166002600060016000866000191660001916815260200190815260200160002060010160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206040518082805460018160011615610100020316600290048015611aa15780601f10611a7f576101008083540402835291820191611aa1565b820191906000526020600020905b815481529060010190602001808311611a8d575b5050915050604051809103902060001916145b15611c79576002600060016000856000191660001916815260200190815260200160002060010160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020805460018160011615610100020316600290046000825580601f10611b5b5750611b92565b601f016020900490600052602060002090810190611b9191905b80821115611b8d576000816000905550600101611b75565b5090565b5b5060016000836000191660001916815260200190815260200160002060010160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16856040518082805190602001908083835b60208310611c1c5780518252602082019150602081019050602083039250611bf9565b6001836020036101000a03801982511681845116808217855250505050505090500191505060405180910390207f12491ad95fd945e444d88a894ffad3c21959880a4dcd8af99d4ae4ffc71d4abd60405180905060405180910390a35b8360016000846000191660001916815260200190815260200160002060010160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508373ffffffffffffffffffffffffffffffffffffffff16856040518082805190602001908083835b60208310611d215780518252602082019150602081019050602083039250611cfe565b6001836020036101000a03801982511681845116808217855250505050505090500191505060405180910390207f728435a0031f6a04538fcdd24922a7e06bc7bc945db03e83d22122d1bc5f28df60405180905060405180910390a3600192505b5b505092915050565b6000600060016000846000191660001916815260200190815260200160002060010160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16141590505b919050565b6000600160008460001916600019168152602001908152602001600020600201826040518082805190602001908083835b60208310611e425780518252602082019150602081019050602083039250611e1f565b6001836020036101000a0380198251168184511680821785525050505050509050019150509081526020016040518091039020546001900490505b92915050565b60035481565b600060016000836000191660001916815260200190815260200160002060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1690505b919050565b600060016000836000191660001916815260200190815260200160002060010160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1690505b919050565b6020604051908101604052806000815250600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015611fff5780601f10611fd457610100808354040283529160200191611fff565b820191906000526020600020905b815481529060010190602001808311611fe257829003601f168201915b505050505090505b919050565b6000833373ffffffffffffffffffffffffffffffffffffffff1660016000836000191660001916815260200190815260200160002060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161415156120875761222e565b82600102600160008760001916600019168152602001908152602001600020600201856040518082805190602001908083835b602083106120dd57805182526020820191506020810190506020830392506120ba565b6001836020036101000a03801982511681845116808217855250505050505090500191505090815260200160405180910390208160001916905550836040518082805190602001908083835b6020831061214c5780518252602082019150602081019050602083039250612129565b6001836020036101000a038019825116818451168082178552505050505050905001915050604051809103902085600019167fb829c3e412537bbe794c048ccb9e4605bb4aaaa8e4d4c15c1a6e0c2adc1716ea8660405180806020018281038252838181518152602001915080519060200190808383600083146121ef575b8051825260208311156121ef576020820191506020810190506020830392506121cb565b505050905090810190601f16801561221b5780820380516001836020036101000a031916815260200191505b509250505060405180910390a3600191505b5b509392505050565b6000600060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156122945761241f565b82600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000209080519060200190828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061231d57805160ff191683800117855561234b565b8280016001018555821561234b579182015b8281111561234a57825182559160200191906001019061232f565b5b50905061237091905b8082111561236c576000816000905550600101612354565b5090565b50508173ffffffffffffffffffffffffffffffffffffffff16836040518082805190602001908083835b602083106123bd578051825260208201915060208101905060208303925061239a565b6001836020036101000a03801982511681845116808217855250505050505090500191505060405180910390207f098ae8581bb8bd9af1beaf7f2e9f51f31a8e5a8bfada4e303a645d71d9c9192060405180905060405180910390a3600190505b5b92915050565b3373ffffffffffffffffffffffffffffffffffffffff16600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060405180828054600181600116156101000203166002900480156124d65780601f106124b45761010080835404028352918201916124d6565b820191906000526020600020905b8154815290600101906020018083116124c2575b505091505060405180910390207f12491ad95fd945e444d88a894ffad3c21959880a4dcd8af99d4ae4ffc71d4abd60405180905060405180910390a360016000600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060405180828054600181600116156101000203166002900480156125b05780601f1061258e5761010080835404028352918201916125b0565b820191906000526020600020905b81548152906001019060200180831161259c575b505091505060405180910390206000191660001916815260200190815260200160002060010160006101000a81549073ffffffffffffffffffffffffffffffffffffffff0219169055600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020805460018160011615610100020316600290046000825580601f1061265d5750612694565b601f01602090049060005260206000209081019061269391905b8082111561268f576000816000905550600101612677565b5090565b5b505b565b6000833373ffffffffffffffffffffffffffffffffffffffff1660016000836000191660001916815260200190815260200160002060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16141515612713576128d0565b8273ffffffffffffffffffffffffffffffffffffffff16600102600160008760001916600019168152602001908152602001600020600201856040518082805190602001908083835b6020831061277f578051825260208201915060208101905060208303925061275c565b6001836020036101000a03801982511681845116808217855250505050505090500191505090815260200160405180910390208160001916905550836040518082805190602001908083835b602083106127ee57805182526020820191506020810190506020830392506127cb565b6001836020036101000a038019825116818451168082178552505050505050905001915050604051809103902085600019167fb829c3e412537bbe794c048ccb9e4605bb4aaaa8e4d4c15c1a6e0c2adc1716ea866040518080602001828103825283818151815260200191508051906020019080838360008314612891575b8051825260208311156128915760208201915060208101905060208303925061286d565b505050905090810190601f1680156128bd5780820380516001836020036101000a031916815260200191505b509250505060405180910390a3600191505b5b5093925050505600a165627a7a7230582066b2da4773a0f1d81efe071c66b51c46868a871661efd18c0f629353ff4c1f9b0029" }, "00a329c0648769a73afac7f9381e08fb43dbea72": { "balance": "1606938044258990275541962092341162602522202993782792835301376" } } diff --git a/ethcore/res/null.json b/ethcore/res/null.json index 7fa41a8def5..5128f26c59c 100644 --- a/ethcore/res/null.json +++ b/ethcore/res/null.json @@ -36,9 +36,50 @@ "0000000000000000000000000000000000000003": { "balance": "1", "nonce": "0", "builtin": { "name": "ripemd160", "pricing": { "linear": { "base": 600, "word": 120 } } } }, "0000000000000000000000000000000000000004": { "balance": "1", "nonce": "0", "builtin": { "name": "identity", "pricing": { "linear": { "base": 15, "word": 3 } } } }, "0000000000000000000000000000000000000005": { "balance": "1", "builtin": { "name": "modexp", "activate_at": 0, "pricing": { "modexp": { "divisor": 20 } } } }, - "0000000000000000000000000000000000000006": { "balance": "1", "builtin": { "name": "alt_bn128_add", "activate_at": 0, "pricing": { "linear": { "base": 500, "word": 0 } } } }, - "0000000000000000000000000000000000000007": { "balance": "1", "builtin": { "name": "alt_bn128_mul", "activate_at": 0, "pricing": { "linear": { "base": 40000, "word": 0 } } } }, - "0000000000000000000000000000000000000008": { "balance": "1", "builtin": { "name": "alt_bn128_pairing", "activate_at": 0, "pricing": { "alt_bn128_pairing": { "base": 100000, "pair": 80000 } } } }, + "0000000000000000000000000000000000000006": { + "balance": "1", + "builtin": { + "name": "alt_bn128_add", + "activate_at": 0, + "eip1108_transition": "0x7fffffffffffff", + "pricing": { + "alt_bn128_const_operations": { + "price": 500, + "eip1108_transition_price": 150 + } + } + } + }, + "0000000000000000000000000000000000000007": { + "balance": "1", + "builtin": { + "name": "alt_bn128_mul", + "activate_at": 0, + "eip1108_transition": "0x7fffffffffffff", + "pricing": { + "alt_bn128_const_operations": { + "price": 40000, + "eip1108_transition_price": 6000 + } + } + } + }, + "0000000000000000000000000000000000000008": { + "balance": "1", + "builtin": { + "name": "alt_bn128_pairing", + "activate_at": 0, + "eip1108_transition": "0x7fffffffffffff", + "pricing": { + "alt_bn128_pairing": { + "base": 100000, + "pair": 80000, + "eip1108_transition_base": 45000, + "eip1108_transition_pair": 34000 + } + } + } + }, "9cce34f7ab185c7aba1b7c8140d620b4bda941d6": { "balance": "1606938044258990275541962092341162602522202993782792835301376", "nonce": "0" } } } diff --git a/ethcore/types/Cargo.toml b/ethcore/types/Cargo.toml index a77a88206a5..b7a2719a435 100644 --- a/ethcore/types/Cargo.toml +++ b/ethcore/types/Cargo.toml @@ -22,4 +22,7 @@ unexpected = { path = "../../util/unexpected" } vm = { path = "../vm"} [dev-dependencies] -rustc-hex= "1.0" +rustc-hex = "1.0" + +[features] +test-helpers = [] diff --git a/ethcore/types/src/engines/params.rs b/ethcore/types/src/engines/params.rs index b8edebc94f5..be44bb21319 100644 --- a/ethcore/types/src/engines/params.rs +++ b/ethcore/types/src/engines/params.rs @@ -31,8 +31,8 @@ const MAX_TRANSACTION_SIZE: usize = 300 * 1024; /// /// we define a "bugfix" hard fork as any hard fork which /// you would put on-by-default in a new chain. -// NOTE [dvdplm]: `Clone` is needed only for tests. -#[derive(Debug, PartialEq, Default, Clone)] +#[derive(Debug, PartialEq, Default)] +#[cfg_attr(any(test, feature = "test-helpers"), derive(Clone))] pub struct CommonParams { /// Account start nonce. pub account_start_nonce: U256, diff --git a/json/src/spec/builtin.rs b/json/src/spec/builtin.rs index 930e0bc9a1b..df0414d0f65 100644 --- a/json/src/spec/builtin.rs +++ b/json/src/spec/builtin.rs @@ -36,6 +36,16 @@ pub struct Modexp { pub divisor: usize, } +/// Pricing for constant alt_bn128 operations (ECADD and ECMUL) +#[derive(Debug, PartialEq, Deserialize, Clone)] +#[serde(deny_unknown_fields)] +pub struct AltBn128ConstOperations { + /// price + pub price: usize, + /// EIP 1108 transition price + pub eip1108_transition_price: usize, +} + /// Pricing for alt_bn128_pairing. #[derive(Debug, PartialEq, Deserialize, Clone)] #[serde(deny_unknown_fields)] @@ -44,6 +54,10 @@ pub struct AltBn128Pairing { pub base: usize, /// Price per point pair. pub pair: usize, + /// EIP 1108 transition base price + pub eip1108_transition_base: usize, + /// EIP 1108 transition price per point pair + pub eip1108_transition_pair: usize, } /// Pricing variants. @@ -57,6 +71,8 @@ pub enum Pricing { Modexp(Modexp), /// Pricing for alt_bn128_pairing exponentiation. AltBn128Pairing(AltBn128Pairing), + /// Pricing for constant alt_bn128 operations + AltBn128ConstOperations(AltBn128ConstOperations), } /// Spec builtin. @@ -69,6 +85,8 @@ pub struct Builtin { pub pricing: Pricing, /// Activation block. pub activate_at: Option, + /// EIP 1108 + pub eip1108_transition: Option, } #[cfg(test)] From 396ccdbcc1ad91567b3a88d95fb8187461b39e37 Mon Sep 17 00:00:00 2001 From: s3krit Date: Tue, 3 Sep 2019 10:37:21 +0200 Subject: [PATCH 5/6] Edit publish-onchain.sh to use https (#11016) `update.parity.io` supports HTTPS, so it makes sense to use it. --- scripts/gitlab/publish-onchain.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/gitlab/publish-onchain.sh b/scripts/gitlab/publish-onchain.sh index 9c7b866fb49..9c2ac1dbbc1 100755 --- a/scripts/gitlab/publish-onchain.sh +++ b/scripts/gitlab/publish-onchain.sh @@ -7,7 +7,7 @@ echo "__________Register Release__________" DATA="secret=$RELEASES_SECRET" echo "Pushing release to Mainnet" -./tools/safe-curl.sh $DATA "http://update.parity.io:1337/push-release/${SCHEDULE_TAG:-${CI_COMMIT_REF_NAME}}/$CI_COMMIT_SHA" +./tools/safe-curl.sh $DATA "https://update.parity.io/push-release/${SCHEDULE_TAG:-${CI_COMMIT_REF_NAME}}/$CI_COMMIT_SHA" cd artifacts ls -l | sort -k9 @@ -26,7 +26,7 @@ do case $DIR in x86_64* ) DATA="commit=$CI_COMMIT_SHA&sha3=$sha3&filename=parity$WIN&secret=$RELEASES_SECRET" - ../../tools/safe-curl.sh $DATA "http://update.parity.io:1337/push-build/${SCHEDULE_TAG:-${CI_COMMIT_REF_NAME}}/$DIR" + ../../tools/safe-curl.sh $DATA "https://update.parity.io/push-build/${SCHEDULE_TAG:-${CI_COMMIT_REF_NAME}}/$DIR" ;; esac cd .. From d193ddde19dbf3574aca8638c1a4041cc06472d7 Mon Sep 17 00:00:00 2001 From: David Date: Tue, 3 Sep 2019 11:29:25 +0200 Subject: [PATCH 6/6] Extract snapshot to own crate (#11010) * Move snapshot to own crate Sort out imports * WIP cargo toml * Make snapshotting generic over the client Sort out tests * Sort out types from blockchain and client * Sort out sync * Sort out imports and generics * Sort out main binary * Fix sync test-helpers * Sort out import for secret-store * Sort out more imports * Fix easy todos * cleanup * Cleanup * remove unneded workspace member * cleanup * Sort out test-helpers dependency on account-db * Update ethcore/client-traits/src/lib.rs Co-Authored-By: Niklas Adolfsson * Update ethcore/snapshot/Cargo.toml --- Cargo.lock | 58 ++++++++++- Cargo.toml | 1 + ethcore/Cargo.toml | 24 +++-- ethcore/blockchain/src/block_info.rs | 54 ----------- ethcore/blockchain/src/blockchain.rs | 31 +++--- ethcore/blockchain/src/lib.rs | 3 - ethcore/blockchain/src/update.rs | 11 ++- ethcore/client-traits/src/lib.rs | 40 +++++++- ethcore/node-filter/src/lib.rs | 10 +- ethcore/private-tx/src/lib.rs | 7 +- ethcore/service/Cargo.toml | 7 +- ethcore/service/src/lib.rs | 1 + ethcore/service/src/service.rs | 18 ++-- ethcore/snapshot/Cargo.toml | 54 +++++++++++ .../{src/snapshot => snapshot/src}/account.rs | 24 ++--- .../{src/snapshot => snapshot/src}/block.rs | 28 +++--- .../src}/consensus/authority.rs | 18 ++-- .../src}/consensus/mod.rs | 4 +- .../src}/consensus/work.rs | 32 ++++--- ethcore/{src/snapshot => snapshot/src}/io.rs | 17 ++-- .../snapshot/mod.rs => snapshot/src/lib.rs} | 42 ++++---- .../{src/snapshot => snapshot/src}/service.rs | 95 +++++++++---------- .../src}/tests/helpers.rs | 29 +++--- .../snapshot => snapshot/src}/tests/mod.rs | 2 +- .../src}/tests/proof_of_authority.rs | 24 +++-- .../src}/tests/proof_of_work.rs | 28 +++--- .../src}/tests/service.rs | 39 ++++---- .../snapshot => snapshot/src}/tests/state.rs | 37 ++++---- .../src}/tests/test_validator_contract.json | 0 .../{src/snapshot => snapshot/src}/traits.rs | 7 +- .../{src/snapshot => snapshot/src}/watcher.rs | 48 +++++----- ethcore/src/client/client.rs | 16 ++-- ethcore/src/client/mod.rs | 2 - ethcore/src/lib.rs | 10 +- ethcore/src/test_helpers.rs | 5 +- ethcore/state-db/src/lib.rs | 6 +- ethcore/sync/Cargo.toml | 11 ++- ethcore/sync/src/api.rs | 13 +-- ethcore/sync/src/chain/handler.rs | 10 +- ethcore/sync/src/chain/mod.rs | 6 +- ethcore/sync/src/lib.rs | 7 +- .../src/{snapshot.rs => snapshot_sync.rs} | 2 +- ethcore/sync/src/sync_io.rs | 2 +- ethcore/sync/src/tests/helpers.rs | 16 +++- ethcore/sync/src/tests/snapshot.rs | 2 +- ethcore/types/src/block.rs | 39 ++++++++ .../{src/client => types/src}/chain_notify.rs | 50 ++-------- ethcore/types/src/client_types.rs | 4 +- .../{blockchain => types}/src/import_route.rs | 6 +- ethcore/types/src/lib.rs | 2 + parity/configuration.rs | 8 +- parity/informant.rs | 21 ++-- parity/lib.rs | 5 +- parity/modules.rs | 5 +- parity/rpc_apis.rs | 2 +- parity/run.rs | 2 +- parity/{snapshot.rs => snapshot_cmd.rs} | 10 +- rpc/Cargo.toml | 1 + rpc/src/lib.rs | 1 + rpc/src/v1/impls/eth.rs | 2 +- rpc/src/v1/impls/eth_pubsub.rs | 4 +- rpc/src/v1/impls/parity.rs | 2 +- rpc/src/v1/tests/helpers/snapshot_service.rs | 2 +- rpc/src/v1/tests/mocked/eth_pubsub.rs | 5 +- secret-store/src/acl_storage.rs | 7 +- secret-store/src/key_server_set.rs | 9 +- .../src/listener/service_contract_listener.rs | 7 +- updater/src/updater.rs | 4 +- 68 files changed, 620 insertions(+), 479 deletions(-) delete mode 100644 ethcore/blockchain/src/block_info.rs create mode 100644 ethcore/snapshot/Cargo.toml rename ethcore/{src/snapshot => snapshot/src}/account.rs (97%) rename ethcore/{src/snapshot => snapshot/src}/block.rs (94%) rename ethcore/{src/snapshot => snapshot/src}/consensus/authority.rs (99%) rename ethcore/{src/snapshot => snapshot/src}/consensus/mod.rs (94%) rename ethcore/{src/snapshot => snapshot/src}/consensus/work.rs (95%) rename ethcore/{src/snapshot => snapshot/src}/io.rs (98%) rename ethcore/{src/snapshot/mod.rs => snapshot/src/lib.rs} (98%) rename ethcore/{src/snapshot => snapshot/src}/service.rs (96%) rename ethcore/{src/snapshot => snapshot/src}/tests/helpers.rs (91%) rename ethcore/{src/snapshot => snapshot/src}/tests/mod.rs (96%) rename ethcore/{src/snapshot => snapshot/src}/tests/proof_of_authority.rs (94%) rename ethcore/{src/snapshot => snapshot/src}/tests/proof_of_work.rs (88%) rename ethcore/{src/snapshot => snapshot/src}/tests/service.rs (91%) rename ethcore/{src/snapshot => snapshot/src}/tests/state.rs (87%) rename ethcore/{src/snapshot => snapshot/src}/tests/test_validator_contract.json (100%) rename ethcore/{src/snapshot => snapshot/src}/traits.rs (99%) rename ethcore/{src/snapshot => snapshot/src}/watcher.rs (87%) rename ethcore/sync/src/{snapshot.rs => snapshot_sync.rs} (99%) rename ethcore/{src/client => types/src}/chain_notify.rs (79%) rename ethcore/{blockchain => types}/src/import_route.rs (95%) rename parity/{snapshot.rs => snapshot_cmd.rs} (96%) diff --git a/Cargo.lock b/Cargo.lock index 98940990fae..59ef08be579 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1020,7 +1020,6 @@ dependencies = [ "client-traits 0.1.0", "common-types 0.1.0", "criterion 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", - "crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "engine 0.1.0", "env_logger 0.5.13 (registry+https://github.com/rust-lang/crates.io-index)", "ethabi 8.0.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1029,7 +1028,6 @@ dependencies = [ "ethash 1.12.0", "ethcore-accounts 0.1.0", "ethcore-blockchain 0.1.0", - "ethcore-bloom-journal 0.1.0", "ethcore-builtin 0.1.0", "ethcore-call-contract 0.1.0", "ethcore-db 0.1.0", @@ -1047,7 +1045,6 @@ dependencies = [ "itertools 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)", "journaldb 0.2.0", "keccak-hash 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "keccak-hasher 0.1.1", "kvdb 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "kvdb-memorydb 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "kvdb-rocksdb 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1057,10 +1054,8 @@ dependencies = [ "macros 0.1.0", "memory-cache 0.1.0", "null-engine 0.1.0", - "num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)", "parity-bytes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-runtime 0.1.0", - "parity-snappy 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "patricia-trie-ethereum 0.1.0", "pod 0.1.0", @@ -1074,6 +1069,7 @@ dependencies = [ "serde 1.0.99 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", + "snapshot 0.1.0", "spec 0.1.0", "state-db 0.1.0", "stats 0.1.0", @@ -1462,6 +1458,7 @@ dependencies = [ "kvdb 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "kvdb-rocksdb 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "snapshot 0.1.0", "spec 0.1.0", "tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", "trace-time 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1518,6 +1515,7 @@ dependencies = [ "rand_xorshift 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "rlp 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "snapshot 0.1.0", "spec 0.1.0", "trace-time 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "triehash-ethereum 0.2.0", @@ -3034,6 +3032,7 @@ dependencies = [ "serde 1.0.99 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", + "snapshot 0.1.0", "spec 0.1.0", "tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", "term_size 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3182,6 +3181,7 @@ dependencies = [ "serde 1.0.99 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", + "snapshot 0.1.0", "spec 0.1.0", "stats 0.1.0", "tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4202,6 +4202,54 @@ name = "smallvec" version = "0.6.10" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "snapshot" +version = "0.1.0" +dependencies = [ + "account-db 0.1.0", + "account-state 0.1.0", + "client-traits 0.1.0", + "common-types 0.1.0", + "crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", + "engine 0.1.0", + "env_logger 0.5.13 (registry+https://github.com/rust-lang/crates.io-index)", + "ethabi 8.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "ethabi-contract 8.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "ethabi-derive 8.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "ethcore 1.12.0", + "ethcore-accounts 0.1.0", + "ethcore-blockchain 0.1.0", + "ethcore-bloom-journal 0.1.0", + "ethcore-db 0.1.0", + "ethcore-io 1.12.0", + "ethereum-types 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "ethkey 0.3.0", + "hash-db 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", + "itertools 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)", + "journaldb 0.2.0", + "keccak-hash 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "keccak-hasher 0.1.1", + "kvdb 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "kvdb-rocksdb 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-bytes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-snappy 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "patricia-trie-ethereum 0.1.0", + "rand 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_xorshift 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rlp 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "rlp_derive 0.1.0", + "spec 0.1.0", + "state-db 0.1.0", + "tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", + "trie-db 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", + "trie-standardmap 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", + "triehash-ethereum 0.2.0", +] + [[package]] name = "socket2" version = "0.3.8" diff --git a/Cargo.toml b/Cargo.toml index 298c1542e8f..3a18c6c9e69 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -69,6 +69,7 @@ semver = "0.9" serde = "1.0" serde_derive = "1.0" serde_json = "1.0" +snapshot = { path = "ethcore/snapshot" } spec = { path = "ethcore/spec" } term_size = "0.3" textwrap = "0.9" diff --git a/ethcore/Cargo.toml b/ethcore/Cargo.toml index cf27c1a6585..b2ac1c8e9d0 100644 --- a/ethcore/Cargo.toml +++ b/ethcore/Cargo.toml @@ -7,14 +7,13 @@ version = "1.12.0" authors = ["Parity Technologies "] [dependencies] -account-db = { path = "account-db" } +account-db = { path = "account-db", optional = true } account-state = { path = "account-state" } ansi_term = "0.11" basic-authority = { path = "./engines/basic-authority", optional = true} # used by test-helpers feature blooms-db = { path = "../util/blooms-db", optional = true } client-traits = { path = "./client-traits" } common-types = { path = "types" } -crossbeam-utils = "0.6" engine = { path = "./engine" } env_logger = { version = "0.5", optional = true } ethabi = "8.0" @@ -24,7 +23,6 @@ ethash = { path = "../ethash", optional = true } ethjson = { path = "../json", optional = true } ethkey = { path = "../accounts/ethkey", optional = true } ethcore-blockchain = { path = "./blockchain" } -ethcore-bloom-journal = { path = "../util/bloom" } ethcore-call-contract = { path = "./call-contract" } ethcore-db = { path = "./db" } ethcore-io = { path = "../util/io" } @@ -38,7 +36,6 @@ hash-db = "0.15.0" itertools = "0.5" journaldb = { path = "../util/journaldb" } keccak-hash = "0.2.0" -keccak-hasher = { path = "../util/keccak-hasher" } kvdb = "0.1" kvdb-memorydb = { version = "0.1", optional = true } kvdb-rocksdb = { version = "0.1.3", optional = true } @@ -47,9 +44,7 @@ log = "0.4" macros = { path = "../util/macros", optional = true } machine = { path = "./machine" } memory-cache = { path = "../util/memory-cache" } -num_cpus = "1.2" parity-bytes = "0.1" -parity-snappy = "0.1" parking_lot = "0.8" pod = { path = "pod", optional = true } trie-db = "0.15.0" @@ -62,6 +57,7 @@ rlp_derive = { path = "../util/rlp-derive" } rustc-hex = { version = "1", optional = true } serde = "1.0" serde_derive = "1.0" +snapshot = { path = "snapshot" } spec = { path = "spec" } state-db = { path = "state-db" } tempdir = { version = "0.3", optional = true } @@ -75,6 +71,7 @@ verification = { path = "./verification" } vm = { path = "vm" } [dev-dependencies] +account-db = { path = "account-db" } blooms-db = { path = "../util/blooms-db" } ethcore-builtin = { path = "./builtin" } criterion = "0.2" @@ -129,7 +126,20 @@ ci-skip-tests = [] test-heavy = [] # Compile test helpers # note[dvdplm]: "basic-authority/test-helpers" is needed so that `generate_dummy_client_with_spec` works -test-helpers = ["tempdir", "kvdb-memorydb", "kvdb-rocksdb", "blooms-db", "ethash", "ethjson", "ethkey", "macros", "pod", "rustc-hex", "basic-authority/test-helpers"] +test-helpers = [ + "account-db", + "blooms-db", + "ethash", + "ethjson", + "ethkey", + "kvdb-memorydb", + "kvdb-rocksdb", + "macros", + "pod", + "rustc-hex", + "tempdir", + "basic-authority/test-helpers" + ] [[bench]] name = "builtin" diff --git a/ethcore/blockchain/src/block_info.rs b/ethcore/blockchain/src/block_info.rs deleted file mode 100644 index 15f71ecb855..00000000000 --- a/ethcore/blockchain/src/block_info.rs +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright 2015-2019 Parity Technologies (UK) Ltd. -// This file is part of Parity Ethereum. - -// Parity Ethereum is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Parity Ethereum is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Parity Ethereum. If not, see . - -use ethereum_types::{H256, U256}; -use common_types::BlockNumber; - -/// Brief info about inserted block. -#[derive(Clone)] -pub struct BlockInfo { - /// Block hash. - pub hash: H256, - /// Block number. - pub number: BlockNumber, - /// Total block difficulty. - pub total_difficulty: U256, - /// Block location in blockchain. - pub location: BlockLocation -} - -/// Describes location of newly inserted block. -#[derive(Debug, Clone, PartialEq)] -pub enum BlockLocation { - /// It's part of the canon chain. - CanonChain, - /// It's not a part of the canon chain. - Branch, - /// It's part of the fork which should become canon chain, - /// because its total difficulty is higher than current - /// canon chain difficulty. - BranchBecomingCanonChain(BranchBecomingCanonChainData), -} - -#[derive(Debug, Clone, PartialEq)] -pub struct BranchBecomingCanonChainData { - /// Hash of the newest common ancestor with old canon chain. - pub ancestor: H256, - /// Hashes of the blocks between ancestor and this block. - pub enacted: Vec, - /// Hashes of the blocks which were invalidated. - pub retracted: Vec, -} diff --git a/ethcore/blockchain/src/blockchain.rs b/ethcore/blockchain/src/blockchain.rs index a85de546dfd..05aae018a52 100644 --- a/ethcore/blockchain/src/blockchain.rs +++ b/ethcore/blockchain/src/blockchain.rs @@ -23,18 +23,22 @@ use std::sync::Arc; use ansi_term::Colour; use blooms_db; -use common_types::BlockNumber; -use common_types::blockchain_info::BlockChainInfo; -use common_types::encoded; -use common_types::engines::ForkChoice; -use common_types::engines::epoch::{Transition as EpochTransition, PendingTransition as PendingEpochTransition}; -use common_types::header::{Header, ExtendedHeader}; -use common_types::log_entry::{LogEntry, LocalizedLogEntry}; -use common_types::receipt::Receipt; -use common_types::transaction::LocalizedTransaction; -use common_types::tree_route::TreeRoute; -use common_types::view; -use common_types::views::{BlockView, HeaderView}; +use common_types::{ + BlockNumber, + blockchain_info::BlockChainInfo, + block::{BlockInfo, BlockLocation, BranchBecomingCanonChainData}, + encoded, + engines::ForkChoice, + engines::epoch::{Transition as EpochTransition, PendingTransition as PendingEpochTransition}, + header::{Header, ExtendedHeader}, + import_route::ImportRoute, + log_entry::{LogEntry, LocalizedLogEntry}, + receipt::Receipt, + transaction::LocalizedTransaction, + tree_route::TreeRoute, + view, + views::{BlockView, HeaderView}, +}; use ethcore_db::cache_manager::CacheManager; use ethcore_db::keys::{BlockReceipts, BlockDetails, TransactionAddress, EPOCH_KEY_PREFIX, EpochTransitions}; use ethcore_db::{self as db, Writable, Readable, CacheUpdatePolicy}; @@ -50,9 +54,8 @@ use rlp::RlpStream; use rlp_compress::{compress, decompress, blocks_swapper}; use crate::best_block::{BestBlock, BestAncientBlock}; -use crate::block_info::{BlockInfo, BlockLocation, BranchBecomingCanonChainData}; use crate::update::{ExtrasUpdate, ExtrasInsert}; -use crate::{CacheSize, ImportRoute, Config}; +use crate::{CacheSize, Config}; /// Database backing `BlockChain`. pub trait BlockChainDB: Send + Sync { diff --git a/ethcore/blockchain/src/lib.rs b/ethcore/blockchain/src/lib.rs index 77933922eaf..ceada247c7a 100644 --- a/ethcore/blockchain/src/lib.rs +++ b/ethcore/blockchain/src/lib.rs @@ -22,11 +22,9 @@ extern crate parity_util_mem as util_mem; extern crate parity_util_mem as malloc_size_of; mod best_block; -mod block_info; mod blockchain; mod cache; mod config; -mod import_route; mod update; pub mod generator; @@ -35,7 +33,6 @@ pub use crate::{ blockchain::{BlockProvider, BlockChain, BlockChainDB, BlockChainDBHandler}, cache::CacheSize, config::Config, - import_route::ImportRoute, update::ExtrasInsert, }; pub use ethcore_db::keys::{BlockReceipts, BlockDetails, TransactionAddress, BlockNumberKey}; diff --git a/ethcore/blockchain/src/update.rs b/ethcore/blockchain/src/update.rs index 959f55fdff5..24d04cab8e9 100644 --- a/ethcore/blockchain/src/update.rs +++ b/ethcore/blockchain/src/update.rs @@ -16,14 +16,15 @@ use std::collections::HashMap; -use common_types::BlockNumber; -use common_types::encoded::Block; -use common_types::engines::ForkChoice; +use common_types::{ + BlockNumber, + encoded::Block, + engines::ForkChoice, + block::BlockInfo, +}; use ethcore_db::keys::{BlockDetails, BlockReceipts, TransactionAddress}; use ethereum_types::{H256, Bloom}; -use crate::block_info::BlockInfo; - /// Block extras update info. pub struct ExtrasUpdate { /// Block info. diff --git a/ethcore/client-traits/src/lib.rs b/ethcore/client-traits/src/lib.rs index 896f9515b8b..2a04a7cec52 100644 --- a/ethcore/client-traits/src/lib.rs +++ b/ethcore/client-traits/src/lib.rs @@ -29,6 +29,7 @@ use common_types::{ blockchain_info::BlockChainInfo, BlockNumber, call_analytics::CallAnalytics, + chain_notify::{NewBlocks, ChainMessageType}, client_types::Mode, encoded, engines::{epoch::Transition as EpochTransition, machine::Executed}, @@ -40,7 +41,7 @@ use common_types::{ pruning_info::PruningInfo, receipt::LocalizedReceipt, trace_filter::Filter as TraceFilter, - transaction::{self, LocalizedTransaction, CallError, SignedTransaction}, + transaction::{self, LocalizedTransaction, CallError, SignedTransaction, UnverifiedTransaction}, tree_route::TreeRoute, verification::{VerificationQueueInfo, Unverified}, }; @@ -119,7 +120,7 @@ pub trait ChainInfo { } /// Provides various information on a block by it's ID -pub trait BlockInfo { +pub trait BlockInfo: Send + Sync { /// Get raw block header data by block id. fn block_header(&self, id: BlockId) -> Option; @@ -474,3 +475,38 @@ pub trait SnapshotWriter { /// with the chunks written. fn finish(self, manifest: common_types::snapshot::ManifestData) -> std::io::Result<()> where Self: Sized; } + + +/// Represents what has to be handled by actor listening to chain events +pub trait ChainNotify: Send + Sync { + /// fires when chain has new blocks. + fn new_blocks(&self, _new_blocks: NewBlocks) { + // does nothing by default + } + + /// fires when chain achieves active mode + fn start(&self) { + // does nothing by default + } + + /// fires when chain achieves passive mode + fn stop(&self) { + // does nothing by default + } + + /// fires when chain broadcasts a message + fn broadcast(&self, _message_type: ChainMessageType) { + // does nothing by default + } + + /// fires when new block is about to be imported + /// implementations should be light + fn block_pre_import(&self, _bytes: &Bytes, _hash: &H256, _difficulty: &U256) { + // does nothing by default + } + + /// fires when new transactions are received from a peer + fn transactions_received(&self, _txs: &[UnverifiedTransaction], _peer_id: usize) { + // does nothing by default + } +} diff --git a/ethcore/node-filter/src/lib.rs b/ethcore/node-filter/src/lib.rs index f34b6571b58..332b93fc163 100644 --- a/ethcore/node-filter/src/lib.rs +++ b/ethcore/node-filter/src/lib.rs @@ -42,9 +42,11 @@ extern crate log; use std::collections::{HashMap, VecDeque}; use std::sync::Weak; -use common_types::ids::BlockId; -use ethcore::client::{ChainNotify, NewBlocks}; -use client_traits::BlockChainClient; +use common_types::{ + ids::BlockId, + chain_notify::NewBlocks, +}; +use client_traits::{BlockChainClient, ChainNotify}; use ethereum_types::{H256, Address}; use ethabi::FunctionOutputDecoder; use network::{ConnectionFilter, ConnectionDirection}; @@ -159,7 +161,7 @@ mod test { Arc::new(Miner::new_for_tests(&spec, None)), IoChannel::disconnected(), ).unwrap(); - let filter = NodeFilter::new(Arc::downgrade(&client) as Weak, contract_addr); + let filter = NodeFilter::new(Arc::downgrade(&client) as Weak, contract_addr); let self1 = NodeId::from_str("00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002").unwrap(); let self2 = NodeId::from_str("00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000003").unwrap(); let node1 = NodeId::from_str("00000000000000000000000000000000000000000000000000000000000000110000000000000000000000000000000000000000000000000000000000000012").unwrap(); diff --git a/ethcore/private-tx/src/lib.rs b/ethcore/private-tx/src/lib.rs index 8673d4be7c3..fc0686541a8 100644 --- a/ethcore/private-tx/src/lib.rs +++ b/ethcore/private-tx/src/lib.rs @@ -103,15 +103,14 @@ use machine::{ executed::Executed as FlatExecuted, }; use types::{ + chain_notify::{NewBlocks, ChainMessageType}, ids::BlockId, io_message::ClientIoMessage, transaction::{SignedTransaction, Transaction, Action, UnverifiedTransaction}, engines::machine::Executed, }; -use ethcore::client::{ - Client, ChainNotify, NewBlocks, ChainMessageType, Call -}; -use client_traits::BlockInfo; +use ethcore::client::{Client, Call}; +use client_traits::{BlockInfo, ChainNotify}; use ethcore::miner::{self, Miner, MinerService, pool_client::NonceCache}; use state_db::StateDB; use account_state::State; diff --git a/ethcore/service/Cargo.toml b/ethcore/service/Cargo.toml index f333e979d06..4956d9c7535 100644 --- a/ethcore/service/Cargo.toml +++ b/ethcore/service/Cargo.toml @@ -6,8 +6,8 @@ authors = ["Parity Technologies "] [dependencies] ansi_term = "0.11" -common-types = { path = "../types" } client-traits = { path = "../client-traits" } +common-types = { path = "../types" } ethcore = { path = ".." } ethcore-blockchain = { path = "../blockchain" } ethcore-io = { path = "../../util/io" } @@ -16,11 +16,12 @@ ethcore-sync = { path = "../sync" } ethereum-types = "0.6.0" kvdb = "0.1" log = "0.4" +snapshot = { path = "../snapshot" } spec = { path = "../spec" } trace-time = "0.1" [dev-dependencies] -ethcore-db = { path = "../db" } ethcore = { path = "..", features = ["test-helpers"] } -tempdir = "0.3" +ethcore-db = { path = "../db" } kvdb-rocksdb = "0.1.3" +tempdir = "0.3" diff --git a/ethcore/service/src/lib.rs b/ethcore/service/src/lib.rs index 662a2567669..ed82c7dfad0 100644 --- a/ethcore/service/src/lib.rs +++ b/ethcore/service/src/lib.rs @@ -25,6 +25,7 @@ extern crate ethcore_sync as sync; extern crate ethereum_types; extern crate kvdb; extern crate spec; +extern crate snapshot; #[macro_use] extern crate log; diff --git a/ethcore/service/src/service.rs b/ethcore/service/src/service.rs index add9eb1d0d6..786b8b8db06 100644 --- a/ethcore/service/src/service.rs +++ b/ethcore/service/src/service.rs @@ -23,13 +23,13 @@ use std::time::Duration; use ansi_term::Colour; use ethereum_types::H256; use io::{IoContext, TimerToken, IoHandler, IoService, IoError}; - +use client_traits::ChainNotify; use sync::PrivateTxHandler; use blockchain::{BlockChainDB, BlockChainDBHandler}; -use ethcore::client::{Client, ClientConfig, ChainNotify}; +use ethcore::client::{Client, ClientConfig}; use ethcore::miner::Miner; -use ethcore::snapshot::service::{Service as SnapshotService, ServiceParams as SnapServiceParams}; -use ethcore::snapshot::{SnapshotService as _SnapshotService}; +use snapshot::service::{Service as SnapshotService, ServiceParams as SnapServiceParams}; +use snapshot::{SnapshotService as _SnapshotService}; use spec::Spec; use common_types::{ io_message::ClientIoMessage, @@ -94,7 +94,7 @@ impl PrivateTxHandler for PrivateTxService { pub struct ClientService { io_service: Arc>>, client: Arc, - snapshot: Arc, + snapshot: Arc>, private_tx: Arc, database: Arc, } @@ -185,7 +185,7 @@ impl ClientService { } /// Get snapshot interface. - pub fn snapshot_service(&self) -> Arc { + pub fn snapshot_service(&self) -> Arc> { self.snapshot.clone() } @@ -215,9 +215,9 @@ impl ClientService { } /// IO interface for the Client handler -struct ClientIoHandler { +struct ClientIoHandler { client: Arc, - snapshot: Arc, + snapshot: Arc>, } const CLIENT_TICK_TIMER: TimerToken = 0; @@ -239,7 +239,7 @@ where trace_time!("service::read"); match timer { CLIENT_TICK_TIMER => { - use ethcore::snapshot::SnapshotService; + use snapshot::SnapshotService; let snapshot_restoration = if let RestorationStatus::Ongoing{..} = self.snapshot.status() { true } else { false }; self.client.tick(snapshot_restoration) }, diff --git a/ethcore/snapshot/Cargo.toml b/ethcore/snapshot/Cargo.toml new file mode 100644 index 00000000000..57722f13a0d --- /dev/null +++ b/ethcore/snapshot/Cargo.toml @@ -0,0 +1,54 @@ +[package] +description = "Take and restore snapshots of the blockchain and read/write it in chunks from/to disk" +name = "snapshot" +version = "0.1.0" +authors = ["Parity Technologies "] +edition = "2018" +license = "GPL-3.0" + +[dependencies] +account-db = { path = "../account-db" } +account-state = { path = "../account-state" } +blockchain = { package = "ethcore-blockchain", path = "../blockchain" } +bloom-journal = { package = "ethcore-bloom-journal", path = "../../util/bloom" } +bytes = { package = "parity-bytes", version = "0.1.0" } +client-traits = { path = "../client-traits" } +common-types = { path = "../types" } +crossbeam-utils = "0.6" +engine = { path = "../engine" } +ethcore-db = { path = "../db" } +ethcore-io = { path = "../../util/io" } +ethereum-types = "0.6.0" +ethtrie = { package = "patricia-trie-ethereum", path = "../../util/patricia-trie-ethereum" } +hash-db = "0.15.0" +itertools = "0.5" +journaldb = { path = "../../util/journaldb" } +keccak-hash = "0.2.0" +keccak-hasher = { path = "../../util/keccak-hasher" } +kvdb = "0.1.0" +log = "0.4.8" +num_cpus = "1.10.1" +parking_lot = "0.8.0" +rand = "0.6" +rand_xorshift = "0.1.1" +rlp = "0.4.2" +rlp_derive = { path = "../../util/rlp-derive" } +snappy = { package = "parity-snappy", version ="0.1.0" } +state-db = { path = "../state-db" } +trie-db = "0.15.0" +triehash = { package = "triehash-ethereum", version = "0.2", path = "../../util/triehash-ethereum" } + +[dev-dependencies] +accounts = { package = "ethcore-accounts", path = "../../accounts" } +engine = { path = "../engine", features = ["test-helpers"] } +env_logger = "0.5" +ethabi = "8.0" +ethabi-contract = "8.0" +ethabi-derive = "8.0" +ethcore = { path = "..", features = ["test-helpers"] } +ethkey = { path = "../../accounts/ethkey" } +kvdb-rocksdb = { version = "0.1.3" } +lazy_static = { version = "1.3" } +spec = { path = "../spec" } +tempdir = "0.3" +trie-standardmap = "0.15.0" diff --git a/ethcore/src/snapshot/account.rs b/ethcore/snapshot/src/account.rs similarity index 97% rename from ethcore/src/snapshot/account.rs rename to ethcore/snapshot/src/account.rs index 62d9ac71d0d..760576e370b 100644 --- a/ethcore/src/snapshot/account.rs +++ b/ethcore/snapshot/src/account.rs @@ -16,21 +16,23 @@ //! Account state encoding and decoding +use std::collections::HashSet; +use std::sync::atomic::Ordering; + use account_db::{AccountDB, AccountDBMut}; -use types::{ +use bytes::Bytes; +use common_types::{ basic_account::BasicAccount, snapshot::Progress, errors::SnapshotError as Error, }; -use bytes::Bytes; use ethereum_types::{H256, U256}; use ethtrie::{TrieDB, TrieDBMut}; -use hash::{KECCAK_EMPTY, KECCAK_NULL_RLP}; use hash_db::HashDB; +use keccak_hash::{KECCAK_EMPTY, KECCAK_NULL_RLP}; +use log::{trace, warn}; use rlp::{RlpStream, Rlp}; -use std::collections::HashSet; -use trie::{Trie, TrieMut}; -use std::sync::atomic::Ordering; +use trie_db::{Trie, TrieMut}; // An empty account -- these were replaced with RLP null data for a space optimization in v1. const ACC_EMPTY: BasicAccount = BasicAccount { @@ -246,12 +248,12 @@ pub fn from_fat_rlp( #[cfg(test)] mod tests { use account_db::{AccountDB, AccountDBMut}; - use types::basic_account::BasicAccount; - use test_helpers::get_temp_state_db; - use snapshot::tests::helpers::fill_storage; - use snapshot::Progress; + use common_types::basic_account::BasicAccount; + use ethcore::test_helpers::get_temp_state_db; + use crate::tests::helpers::fill_storage; + use common_types::snapshot::Progress; - use hash::{KECCAK_EMPTY, KECCAK_NULL_RLP, keccak}; + use keccak_hash::{KECCAK_EMPTY, KECCAK_NULL_RLP, keccak}; use ethereum_types::{H256, Address}; use hash_db::{HashDB, EMPTY_PREFIX}; use kvdb::DBValue; diff --git a/ethcore/src/snapshot/block.rs b/ethcore/snapshot/src/block.rs similarity index 94% rename from ethcore/src/snapshot/block.rs rename to ethcore/snapshot/src/block.rs index f19b2611be4..fbc5d320742 100644 --- a/ethcore/src/snapshot/block.rs +++ b/ethcore/snapshot/src/block.rs @@ -17,18 +17,20 @@ //! Block RLP compression. use bytes::Bytes; +use common_types::{ + block::Block, + header::Header, + views::BlockView, +}; use ethereum_types::H256; -use hash::keccak; +use keccak_hash::keccak; use rlp::{DecoderError, RlpStream, Rlp}; use triehash::ordered_trie_root; -use types::block::Block; -use types::header::Header; -use types::views::BlockView; const HEADER_FIELDS: usize = 8; const BLOCK_FIELDS: usize = 2; -pub struct AbridgedBlock { +pub(crate) struct AbridgedBlock { rlp: Bytes, } @@ -122,11 +124,7 @@ impl AbridgedBlock { header.set_seal(seal_fields); - Ok(Block { - header: header, - transactions: transactions, - uncles: uncles, - }) + Ok(Block { header, transactions, uncles }) } } @@ -136,10 +134,12 @@ mod tests { use bytes::Bytes; use ethereum_types::{H256, U256, Address}; - use types::transaction::{Action, Transaction}; - use types::block::Block; - use types::view; - use types::views::BlockView; + use common_types::{ + transaction::{Action, Transaction}, + block::Block, + view, + views::BlockView, + }; fn encode_block(b: &Block) -> Bytes { b.rlp_bytes() diff --git a/ethcore/src/snapshot/consensus/authority.rs b/ethcore/snapshot/src/consensus/authority.rs similarity index 99% rename from ethcore/src/snapshot/consensus/authority.rs rename to ethcore/snapshot/src/consensus/authority.rs index 426ca1e54d2..6135ba8820f 100644 --- a/ethcore/src/snapshot/consensus/authority.rs +++ b/ethcore/snapshot/src/consensus/authority.rs @@ -22,14 +22,9 @@ use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::Arc; -use engine::{Engine, EpochVerifier}; use blockchain::{BlockChain, BlockChainDB, BlockProvider}; use bytes::Bytes; -use ethereum_types::{H256, U256}; -use itertools::{Position, Itertools}; -use kvdb::KeyValueDB; -use rlp::{RlpStream, Rlp}; -use types::{ +use common_types::{ encoded, engines::epoch::Transition as EpochTransition, header::Header, @@ -38,8 +33,15 @@ use types::{ receipt::Receipt, snapshot::{ChunkSink, Progress, ManifestData} }; +use engine::{Engine, EpochVerifier}; +use ethereum_types::{H256, U256}; +use itertools::{Position, Itertools}; +use kvdb::KeyValueDB; +use log::trace; +use rlp::{RlpStream, Rlp}; + +use crate::{SnapshotComponents, Rebuilder}; -use snapshot::{SnapshotComponents, Rebuilder}; /// Snapshot creation and restoration for PoA chains. /// Chunk format: @@ -320,7 +322,7 @@ impl Rebuilder for ChunkRebuilder { } if is_last_chunk { - use types::block::Block; + use common_types::block::Block; let last_rlp = rlp.at(num_items - 1)?; let block = Block { diff --git a/ethcore/src/snapshot/consensus/mod.rs b/ethcore/snapshot/src/consensus/mod.rs similarity index 94% rename from ethcore/src/snapshot/consensus/mod.rs rename to ethcore/snapshot/src/consensus/mod.rs index aa323b6afd6..280ebd8a759 100644 --- a/ethcore/src/snapshot/consensus/mod.rs +++ b/ethcore/snapshot/src/consensus/mod.rs @@ -23,8 +23,8 @@ mod work; pub use self::authority::*; pub use self::work::*; -use snapshot::SnapshotComponents; -use types::snapshot::Snapshotting::{self, *}; +use crate::SnapshotComponents; +use common_types::snapshot::Snapshotting::{self, *}; /// Create a factory for building snapshot chunks and restoring from them. /// `None` indicates that the engine doesn't support snapshot creation. diff --git a/ethcore/src/snapshot/consensus/work.rs b/ethcore/snapshot/src/consensus/work.rs similarity index 95% rename from ethcore/src/snapshot/consensus/work.rs rename to ethcore/snapshot/src/consensus/work.rs index ee52f85ba4a..eb035fb7734 100644 --- a/ethcore/src/snapshot/consensus/work.rs +++ b/ethcore/snapshot/src/consensus/work.rs @@ -25,21 +25,27 @@ use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::Arc; use blockchain::{BlockChain, BlockChainDB, BlockProvider}; -use engine::Engine; -use snapshot::block::AbridgedBlock; -use ethereum_types::H256; -use kvdb::KeyValueDB; use bytes::Bytes; -use rlp::{RlpStream, Rlp}; -use rand::rngs::OsRng; -use types::{ +use common_types::{ encoded, engines::epoch::Transition as EpochTransition, errors::{SnapshotError, EthcoreError}, snapshot::{ChunkSink, ManifestData, Progress}, + receipt::Receipt, }; +use engine::Engine; +use ethereum_types::{H256, U256}; +use kvdb::KeyValueDB; +use log::trace; +use rand::rngs::OsRng; +use rlp::{RlpStream, Rlp}; +use triehash::ordered_trie_root; -use snapshot::{SnapshotComponents, Rebuilder}; +use crate::{ + SnapshotComponents, Rebuilder, + block::AbridgedBlock, + verify_old_block +}; /// Snapshot creation and restoration for PoW chains. /// This includes blocks from the head of the chain as a @@ -93,8 +99,8 @@ impl SnapshotComponents for PowSnapshot { ).map(|r| Box::new(r) as Box<_>) } - fn min_supported_version(&self) -> u64 { ::snapshot::MIN_SUPPORTED_STATE_CHUNK_VERSION } - fn current_version(&self) -> u64 { ::snapshot::STATE_CHUNK_VERSION } + fn min_supported_version(&self) -> u64 { crate::MIN_SUPPORTED_STATE_CHUNK_VERSION } + fn current_version(&self) -> u64 { crate::STATE_CHUNK_VERSION } } /// Used to build block chunks. @@ -231,10 +237,6 @@ impl Rebuilder for PowRebuilder { /// Feed the rebuilder an uncompressed block chunk. /// Returns the number of blocks fed or any errors. fn feed(&mut self, chunk: &[u8], engine: &dyn Engine, abort_flag: &AtomicBool) -> Result<(), EthcoreError> { - use snapshot::verify_old_block; - use ethereum_types::U256; - use triehash::ordered_trie_root; - let rlp = Rlp::new(chunk); let item_count = rlp.item_count()?; let num_blocks = (item_count - 3) as u64; @@ -256,7 +258,7 @@ impl Rebuilder for PowRebuilder { let pair = rlp.at(idx)?; let abridged_rlp = pair.at(0)?.as_raw().to_owned(); let abridged_block = AbridgedBlock::from_raw(abridged_rlp); - let receipts: Vec<::types::receipt::Receipt> = pair.list_at(1)?; + let receipts: Vec = pair.list_at(1)?; let receipts_root = ordered_trie_root(pair.at(1)?.iter().map(|r| r.as_raw())); let block = abridged_block.to_block(parent_hash, cur_number, receipts_root)?; diff --git a/ethcore/src/snapshot/io.rs b/ethcore/snapshot/src/io.rs similarity index 98% rename from ethcore/src/snapshot/io.rs rename to ethcore/snapshot/src/io.rs index b996651bcf5..1afba21fb37 100644 --- a/ethcore/src/snapshot/io.rs +++ b/ethcore/snapshot/src/io.rs @@ -27,16 +27,17 @@ use std::path::{Path, PathBuf}; use bytes::Bytes; use client_traits::SnapshotWriter; -use ethereum_types::H256; -use rlp::{RlpStream, Rlp}; -use types::{ +use common_types::{ errors::{SnapshotError, EthcoreError}, snapshot::ManifestData, }; +use ethereum_types::H256; +use log::trace; +use rlp::{RlpStream, Rlp}; +use rlp_derive::*; const SNAPSHOT_VERSION: u64 = 2; - // (hash, len, offset) #[derive(RlpEncodable, RlpDecodable)] struct ChunkInfo(H256, u64, u64); @@ -320,9 +321,9 @@ impl SnapshotReader for LooseReader { #[cfg(test)] mod tests { use tempdir::TempDir; - use hash::keccak; + use keccak_hash::keccak; - use snapshot::ManifestData; + use common_types::snapshot::ManifestData; use super::{SnapshotWriter, SnapshotReader, PackedWriter, PackedReader, LooseWriter, LooseReader, SNAPSHOT_VERSION}; const STATE_CHUNKS: &'static [&'static [u8]] = &[b"dog", b"cat", b"hello world", b"hi", b"notarealchunk"]; @@ -351,8 +352,8 @@ mod tests { let manifest = ManifestData { version: SNAPSHOT_VERSION, - state_hashes: state_hashes, - block_hashes: block_hashes, + state_hashes, + block_hashes, state_root: keccak(b"notarealroot"), block_number: 12345678987654321, block_hash: keccak(b"notarealblock"), diff --git a/ethcore/src/snapshot/mod.rs b/ethcore/snapshot/src/lib.rs similarity index 98% rename from ethcore/src/snapshot/mod.rs rename to ethcore/snapshot/src/lib.rs index 66a97719648..76d48ba569e 100644 --- a/ethcore/src/snapshot/mod.rs +++ b/ethcore/snapshot/src/lib.rs @@ -23,46 +23,44 @@ use std::collections::{HashMap, HashSet}; use std::cmp; use std::sync::Arc; use std::sync::atomic::{AtomicBool, Ordering}; -use hash::{keccak, KECCAK_NULL_RLP, KECCAK_EMPTY}; + +use keccak_hash::{keccak, KECCAK_NULL_RLP, KECCAK_EMPTY}; use account_db::{AccountDB, AccountDBMut}; +use account_state::Account as StateAccount; use blockchain::{BlockChain, BlockProvider}; -use types::{ +use bloom_journal::Bloom; +use bytes::Bytes; +// todo[dvdplm] put back in snapshots once it's extracted +use client_traits::SnapshotWriter; +use common_types::{ ids::BlockId, header::Header, errors::{SnapshotError as Error, EthcoreError}, - snapshot::Progress, + snapshot::{Progress, ManifestData}, }; +use crossbeam_utils::thread; +use engine::Engine; use ethereum_types::{H256, U256}; +use ethtrie::{TrieDB, TrieDBMut}; use hash_db::HashDB; +use journaldb::{self, Algorithm, JournalDB}; use keccak_hasher::KeccakHasher; -use snappy; -use bytes::Bytes; use parking_lot::Mutex; -use journaldb::{self, Algorithm, JournalDB}; use kvdb::{KeyValueDB, DBValue}; -use trie::{Trie, TrieMut}; -use ethtrie::{TrieDB, TrieDBMut}; -use rlp::{RlpStream, Rlp}; -use bloom_journal::Bloom; +use log::{debug, info, trace}; use num_cpus; -use types::snapshot::ManifestData; - -// todo[dvdplm] put back in snapshots once it's extracted -use client_traits::SnapshotWriter; - -use super::state_db::StateDB; -use account_state::Account as StateAccount; -use engine::Engine; - -use crossbeam_utils::thread; use rand::{Rng, rngs::OsRng}; +use rlp::{RlpStream, Rlp}; +use snappy; +use state_db::StateDB; +use trie_db::{Trie, TrieMut}; pub use self::consensus::*; pub use self::service::Service; pub use self::traits::{SnapshotService, SnapshotComponents, Rebuilder}; pub use self::watcher::Watcher; -pub use types::basic_account::BasicAccount; +pub use common_types::basic_account::BasicAccount; pub mod io; pub mod service; @@ -377,7 +375,7 @@ impl StateRebuilder { /// Create a new state rebuilder to write into the given backing DB. pub fn new(db: Arc, pruning: Algorithm) -> Self { StateRebuilder { - db: journaldb::new(db.clone(), pruning, ::db::COL_STATE), + db: journaldb::new(db.clone(), pruning, ethcore_db::COL_STATE), state_root: KECCAK_NULL_RLP, known_code: HashMap::new(), missing_code: HashMap::new(), diff --git a/ethcore/src/snapshot/service.rs b/ethcore/snapshot/src/service.rs similarity index 96% rename from ethcore/src/snapshot/service.rs rename to ethcore/snapshot/src/service.rs index 6ca50d70636..747c987dbd0 100644 --- a/ethcore/src/snapshot/service.rs +++ b/ethcore/snapshot/src/service.rs @@ -24,39 +24,35 @@ use std::sync::Arc; use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering}; use std::cmp; -use super::{ - StateRebuilder, - SnapshotService, - Rebuilder, - MAX_CHUNK_SIZE, - io::{SnapshotReader, LooseReader, LooseWriter}, - chunker, -}; - use blockchain::{BlockChain, BlockChainDB, BlockChainDBHandler}; -use client::Client; -// todo[dvdplm] put SnapshotWriter back in snapshots once extracted -use client_traits::{ - BlockInfo, BlockChainClient, ChainInfo, - SnapshotClient, SnapshotWriter, DatabaseRestore, -}; -use engine::Engine; -use hash::keccak; -use types::{ +use bytes::Bytes; +use common_types::{ io_message::ClientIoMessage, errors::{EthcoreError as Error, SnapshotError, SnapshotError::UnlinkedAncientBlockChain}, ids::BlockId, snapshot::{ManifestData, Progress, RestorationStatus}, }; - -use io::IoChannel; - +// todo[dvdplm] put SnapshotWriter back in snapshots once extracted +use client_traits::{ChainInfo, SnapshotClient, SnapshotWriter}; +use engine::Engine; use ethereum_types::H256; -use parking_lot::{Mutex, RwLock, RwLockReadGuard}; -use bytes::Bytes; +use ethcore_io::IoChannel; use journaldb::Algorithm; +use keccak_hash::keccak; use kvdb::DBTransaction; +use log::{error, info, trace, warn}; +use parking_lot::{Mutex, RwLock, RwLockReadGuard}; use snappy; +use trie_db::TrieError; + +use super::{ + StateRebuilder, + SnapshotService, + Rebuilder, + MAX_CHUNK_SIZE, + io::{SnapshotReader, LooseReader, LooseWriter}, + chunker, +}; /// Helper for removing directories in case of error. struct Guard(bool, PathBuf); @@ -140,7 +136,7 @@ impl Restoration { let expected_len = snappy::decompressed_len(chunk)?; if expected_len > MAX_CHUNK_SIZE { trace!(target: "snapshot", "Discarding large chunk: {} vs {}", expected_len, MAX_CHUNK_SIZE); - return Err(::snapshot::Error::ChunkTooLarge.into()); + return Err(SnapshotError::ChunkTooLarge.into()); } let len = snappy::decompress_into(chunk, &mut self.snappy_buffer)?; @@ -162,7 +158,7 @@ impl Restoration { let expected_len = snappy::decompressed_len(chunk)?; if expected_len > MAX_CHUNK_SIZE { trace!(target: "snapshot", "Discarding large chunk: {} vs {}", expected_len, MAX_CHUNK_SIZE); - return Err(::snapshot::Error::ChunkTooLarge.into()); + return Err(SnapshotError::ChunkTooLarge.into()); } let len = snappy::decompress_into(chunk, &mut self.snappy_buffer)?; @@ -179,8 +175,6 @@ impl Restoration { // finish up restoration. fn finalize(mut self) -> Result<(), Error> { - use trie::TrieError; - if !self.is_done() { return Ok(()) } // verify final state root. @@ -212,10 +206,10 @@ impl Restoration { } /// Type alias for client io channel. -pub type Channel = IoChannel>; +pub type Channel = IoChannel>; /// Snapshot service parameters. -pub struct ServiceParams { +pub struct ServiceParams { /// The consensus engine this is built on. pub engine: Arc, /// The chain's genesis block. @@ -225,21 +219,21 @@ pub struct ServiceParams { /// Handler for opening a restoration DB. pub restoration_db_handler: Box, /// Async IO channel for sending messages. - pub channel: Channel, + pub channel: Channel, /// The directory to put snapshots in. /// Usually "/snapshot" pub snapshot_root: PathBuf, /// A handle for database restoration. - pub client: Arc, + pub client: Arc, } /// `SnapshotService` implementation. /// This controls taking snapshots and restoring from them. -pub struct Service { +pub struct Service { restoration: Mutex>, restoration_db_handler: Box, snapshot_root: PathBuf, - io_channel: Mutex, + io_channel: Mutex>, pruning: Algorithm, status: Mutex, reader: RwLock>, @@ -247,15 +241,15 @@ pub struct Service { genesis_block: Bytes, state_chunks: AtomicUsize, block_chunks: AtomicUsize, - client: Arc, + client: Arc, progress: Progress, taking_snapshot: AtomicBool, restoring_snapshot: AtomicBool, } -impl Service { +impl Service where C: SnapshotClient + ChainInfo { /// Create a new snapshot service from the given parameters. - pub fn new(params: ServiceParams) -> Result { + pub fn new(params: ServiceParams) -> Result { let mut service = Service { restoration: Mutex::new(None), restoration_db_handler: params.restoration_db_handler, @@ -479,10 +473,7 @@ impl Service { /// calling this while a restoration is in progress or vice versa /// will lead to a race condition where the first one to finish will /// have their produced snapshot overwritten. - pub fn take_snapshot(&self, client: &C, num: u64) -> Result<(), Error> - where - C: ChainInfo + SnapshotClient - { + pub fn take_snapshot(&self, client: &C, num: u64) -> Result<(), Error> { if self.taking_snapshot.compare_and_swap(false, true, Ordering::SeqCst) { info!("Skipping snapshot at #{} as another one is currently in-progress.", num); return Ok(()); @@ -797,7 +788,7 @@ impl Service { } } -impl SnapshotService for Service { +impl SnapshotService for Service { fn manifest(&self) -> Option { self.reader.read().as_ref().map(|r| r.manifest().clone()) } @@ -807,10 +798,6 @@ impl SnapshotService for Service { .map(|c| (c.min_supported_version(), c.current_version())) } - fn chunk(&self, hash: H256) -> Option { - self.reader.read().as_ref().and_then(|r| r.chunk(hash).ok()) - } - fn completed_chunks(&self) -> Option> { let restoration = self.restoration.lock(); @@ -833,6 +820,10 @@ impl SnapshotService for Service { } } + fn chunk(&self, hash: H256) -> Option { + self.reader.read().as_ref().and_then(|r| r.chunk(hash).ok()) + } + fn status(&self) -> RestorationStatus { let mut cur_status = self.status.lock(); @@ -892,7 +883,7 @@ impl SnapshotService for Service { } } -impl Drop for Service { +impl Drop for Service { fn drop(&mut self) { trace!(target: "shutdown", "Dropping Service"); self.abort_restore(); @@ -904,18 +895,18 @@ impl Drop for Service { #[cfg(test)] mod tests { - use client::Client; - use io::{IoService}; + use ethcore::client::Client; + use ethcore_io::IoService; use spec; use journaldb::Algorithm; - use snapshot::SnapshotService; + use crate::SnapshotService; use super::*; - use types::{ + use common_types::{ io_message::ClientIoMessage, snapshot::{ManifestData, RestorationStatus} }; use tempdir::TempDir; - use test_helpers::{generate_dummy_client_with_spec_and_data, restoration_db_handler}; + use ethcore::test_helpers::{generate_dummy_client_with_spec_and_data, restoration_db_handler}; #[test] fn sends_async_messages() { @@ -968,7 +959,7 @@ mod tests { let state_hashes: Vec<_> = (0..5).map(|_| H256::random()).collect(); let block_hashes: Vec<_> = (0..5).map(|_| H256::random()).collect(); - let db_config = DatabaseConfig::with_columns(::db::NUM_COLUMNS); + let db_config = DatabaseConfig::with_columns(ethcore_db::NUM_COLUMNS); let gb = spec.genesis_block(); let flag = ::std::sync::atomic::AtomicBool::new(true); diff --git a/ethcore/src/snapshot/tests/helpers.rs b/ethcore/snapshot/src/tests/helpers.rs similarity index 91% rename from ethcore/src/snapshot/tests/helpers.rs rename to ethcore/snapshot/src/tests/helpers.rs index 3f23377a5f4..98b206ed4e2 100644 --- a/ethcore/src/snapshot/tests/helpers.rs +++ b/ethcore/snapshot/src/tests/helpers.rs @@ -17,32 +17,33 @@ //! Snapshot test helpers. These are used to build blockchains and state tries //! which can be queried before and after a full snapshot/restore cycle. -extern crate trie_standardmap; - use std::sync::Arc; -use hash::{KECCAK_NULL_RLP}; +use std::sync::atomic::AtomicBool; +use keccak_hash::{KECCAK_NULL_RLP}; use account_db::AccountDBMut; -use types::basic_account::BasicAccount; +use common_types::basic_account::BasicAccount; use blockchain::{BlockChain, BlockChainDB}; -use client::Client; +use ethcore::client::Client; use client_traits::{ChainInfo, SnapshotClient}; use engine::Engine; -use snapshot::{StateRebuilder}; -use snapshot::io::{SnapshotReader, PackedWriter, PackedReader}; +use crate::{ + StateRebuilder, + io::{SnapshotReader, PackedWriter, PackedReader}, +}; use tempdir::TempDir; use rand::Rng; - +use log::trace; use kvdb::DBValue; use ethereum_types::H256; use hash_db::HashDB; use keccak_hasher::KeccakHasher; use journaldb; -use trie::{TrieMut, Trie}; +use trie_db::{TrieMut, Trie}; use ethtrie::{SecTrieDBMut, TrieDB, TrieDBMut}; -use self::trie_standardmap::{Alphabet, StandardMap, ValueMode}; -use types::errors::EthcoreError; +use trie_standardmap::{Alphabet, StandardMap, ValueMode}; +use common_types::errors::EthcoreError; // the proportion of accounts we will alter each tick. const ACCOUNT_CHURN: f32 = 0.01; @@ -135,7 +136,7 @@ pub fn fill_storage(mut db: AccountDBMut, root: &mut H256, seed: &mut H256) { /// Take a snapshot from the given client into a temporary file. /// Return a snapshot reader for it. pub fn snap(client: &Client) -> (Box, TempDir) { - use types::ids::BlockId; + use common_types::ids::BlockId; let tempdir = TempDir::new("").unwrap(); let path = tempdir.path().join("file"); @@ -158,10 +159,8 @@ pub fn restore( reader: &dyn SnapshotReader, genesis: &[u8], ) -> Result<(), EthcoreError> { - use std::sync::atomic::AtomicBool; - let flag = AtomicBool::new(true); - let chunker = crate::snapshot::chunker(engine.snapshot_mode()).expect("the engine used here supports snapshots"); + let chunker = crate::chunker(engine.snapshot_mode()).expect("the engine used here supports snapshots"); let manifest = reader.manifest(); let mut state = StateRebuilder::new(db.key_value().clone(), journaldb::Algorithm::Archive); diff --git a/ethcore/src/snapshot/tests/mod.rs b/ethcore/snapshot/src/tests/mod.rs similarity index 96% rename from ethcore/src/snapshot/tests/mod.rs rename to ethcore/snapshot/src/tests/mod.rs index f25fd03b258..c1139e7b5fa 100644 --- a/ethcore/src/snapshot/tests/mod.rs +++ b/ethcore/snapshot/src/tests/mod.rs @@ -23,7 +23,7 @@ mod service; pub mod helpers; -use super::ManifestData; +use common_types::snapshot::ManifestData; #[test] fn manifest_rlp() { diff --git a/ethcore/src/snapshot/tests/proof_of_authority.rs b/ethcore/snapshot/src/tests/proof_of_authority.rs similarity index 94% rename from ethcore/src/snapshot/tests/proof_of_authority.rs rename to ethcore/snapshot/src/tests/proof_of_authority.rs index a0161acdf98..7b9437625a2 100644 --- a/ethcore/src/snapshot/tests/proof_of_authority.rs +++ b/ethcore/snapshot/src/tests/proof_of_authority.rs @@ -21,26 +21,32 @@ use std::sync::Arc; use std::str::FromStr; use accounts::AccountProvider; -use client::Client; +use ethcore::client::Client; use client_traits::{BlockChainClient, ChainInfo}; use ethkey::Secret; -use snapshot::tests::helpers as snapshot_helpers; +use crate::tests::helpers as snapshot_helpers; use spec::Spec; -use test_helpers::generate_dummy_client_with_spec; -use types::transaction::{Transaction, Action, SignedTransaction}; +use ethcore::test_helpers::generate_dummy_client_with_spec; +use common_types::transaction::{Transaction, Action, SignedTransaction}; use tempdir::TempDir; - +use log::trace; use ethereum_types::Address; -use test_helpers; +use ethcore::{ + test_helpers, + miner::{self, MinerService}, +}; +use keccak_hash::keccak; +use ethabi_contract::use_contract; +use lazy_static::lazy_static; -use_contract!(test_validator_set, "res/contracts/test_validator_set.json"); +use_contract!(test_validator_set, "../res/contracts/test_validator_set.json"); const PASS: &'static str = ""; const TRANSITION_BLOCK_1: usize = 2; // block at which the contract becomes activated. const TRANSITION_BLOCK_2: usize = 10; // block at which the second contract activates. macro_rules! secret { - ($e: expr) => { Secret::from($crate::hash::keccak($e).0) } + ($e: expr) => { Secret::from(keccak($e).0) } } lazy_static! { @@ -100,8 +106,6 @@ fn make_chain(accounts: Arc, blocks_beyond: usize, transitions: { // push a block with given number, signed by one of the signers, with given transactions. let push_block = |signers: &[Address], n, txs: Vec| { - use miner::{self, MinerService}; - let idx = n as usize % signers.len(); trace!(target: "snapshot", "Pushing block #{}, {} txs, author={}", n, txs.len(), signers[idx]); diff --git a/ethcore/src/snapshot/tests/proof_of_work.rs b/ethcore/snapshot/src/tests/proof_of_work.rs similarity index 88% rename from ethcore/src/snapshot/tests/proof_of_work.rs rename to ethcore/snapshot/src/tests/proof_of_work.rs index 3b6106313c7..53dc071423a 100644 --- a/ethcore/src/snapshot/tests/proof_of_work.rs +++ b/ethcore/snapshot/src/tests/proof_of_work.rs @@ -18,25 +18,29 @@ use std::sync::atomic::AtomicBool; use tempdir::TempDir; -use types::{ +use common_types::{ errors::EthcoreError as Error, engines::ForkChoice, - snapshot::Progress, + snapshot::{Progress, ManifestData}, }; use blockchain::generator::{BlockGenerator, BlockBuilder}; use blockchain::{BlockChain, ExtrasInsert}; use client_traits::SnapshotWriter; -use snapshot::{chunk_secondary, Error as SnapshotError, SnapshotComponents}; -use snapshot::io::{PackedReader, PackedWriter, SnapshotReader}; - +use crate::{ + chunk_secondary, + Error as SnapshotError, SnapshotComponents, + io::{PackedReader, PackedWriter, SnapshotReader}, + PowSnapshot, +}; use parking_lot::Mutex; use snappy; +use keccak_hash::KECCAK_NULL_RLP; use kvdb::DBTransaction; -use test_helpers; +use ethcore::test_helpers; use spec; -const SNAPSHOT_MODE: ::snapshot::PowSnapshot = ::snapshot::PowSnapshot { blocks: 30000, max_restore_blocks: 30000 }; +const SNAPSHOT_MODE: PowSnapshot = PowSnapshot { blocks: 30000, max_restore_blocks: 30000 }; fn chunk_and_restore(amount: u64) { let genesis = BlockBuilder::genesis(); @@ -75,11 +79,11 @@ fn chunk_and_restore(amount: u64) { &Progress::default() ).unwrap(); - let manifest = ::snapshot::ManifestData { + let manifest = ManifestData { version: 2, state_hashes: Vec::new(), - block_hashes: block_hashes, - state_root: ::hash::KECCAK_NULL_RLP, + block_hashes, + state_root: KECCAK_NULL_RLP, block_number: amount, block_hash: best_hash, }; @@ -137,11 +141,11 @@ fn checks_flag() { let engine = spec::new_test().engine; let chain = BlockChain::new(Default::default(), genesis.last().encoded().raw(), db.clone()); - let manifest = ::snapshot::ManifestData { + let manifest = ManifestData { version: 2, state_hashes: Vec::new(), block_hashes: Vec::new(), - state_root: ::hash::KECCAK_NULL_RLP, + state_root: KECCAK_NULL_RLP, block_number: 102, block_hash: H256::zero(), }; diff --git a/ethcore/src/snapshot/tests/service.rs b/ethcore/snapshot/src/tests/service.rs similarity index 91% rename from ethcore/src/snapshot/tests/service.rs rename to ethcore/snapshot/src/tests/service.rs index aed14e9b456..05a2322b8cf 100644 --- a/ethcore/src/snapshot/tests/service.rs +++ b/ethcore/snapshot/src/tests/service.rs @@ -21,22 +21,28 @@ use std::sync::Arc; use tempdir::TempDir; use blockchain::BlockProvider; -use client::{Client, ClientConfig}; +use ethcore::client::{Client, ClientConfig}; use client_traits::{BlockInfo, ImportBlock, SnapshotWriter}; -use types::{ +use common_types::{ ids::BlockId, snapshot::Progress, verification::Unverified, snapshot::{ManifestData, RestorationStatus}, }; -use snapshot::io::{PackedReader, PackedWriter, SnapshotReader}; -use snapshot::service::{Service, ServiceParams}; -use snapshot::{chunk_state, chunk_secondary, SnapshotService}; +use crate::{ + chunk_state, chunk_secondary, SnapshotService, + io::{PackedReader, PackedWriter, SnapshotReader}, + service::{Service, ServiceParams}, + PowSnapshot, +}; use spec; -use test_helpers::{new_db, new_temp_db, generate_dummy_client_with_spec_and_data, restoration_db_handler}; +use ethcore::{ + miner, + test_helpers::{new_db, new_temp_db, generate_dummy_client_with_spec_and_data, restoration_db_handler} +}; use parking_lot::Mutex; -use io::IoChannel; +use ethcore_io::IoChannel; use kvdb_rocksdb::DatabaseConfig; #[test] @@ -53,7 +59,7 @@ fn restored_is_equivalent() { let client_db = tempdir.path().join("client_db"); let path = tempdir.path().join("snapshot"); - let db_config = DatabaseConfig::with_columns(::db::NUM_COLUMNS); + let db_config = DatabaseConfig::with_columns(ethcore_db::NUM_COLUMNS); let restoration = restoration_db_handler(db_config); let blockchain_db = restoration.open(&client_db).unwrap(); @@ -62,7 +68,7 @@ fn restored_is_equivalent() { Default::default(), &spec, blockchain_db, - Arc::new(::miner::Miner::new_for_tests(&spec, None)), + Arc::new(miner::Miner::new_for_tests(&spec, None)), IoChannel::disconnected(), ).unwrap(); @@ -118,7 +124,7 @@ fn guards_delete_folders() { let service_params = ServiceParams { engine: spec.engine.clone(), genesis_block: spec.genesis_block(), - restoration_db_handler: restoration_db_handler(DatabaseConfig::with_columns(::db::NUM_COLUMNS)), + restoration_db_handler: restoration_db_handler(DatabaseConfig::with_columns(ethcore_db::NUM_COLUMNS)), pruning: ::journaldb::Algorithm::Archive, channel: IoChannel::disconnected(), snapshot_root: tempdir.path().to_owned(), @@ -157,11 +163,10 @@ fn guards_delete_folders() { #[test] fn keep_ancient_blocks() { let _ = ::env_logger::try_init(); - // Test variables const NUM_BLOCKS: u64 = 500; const NUM_SNAPSHOT_BLOCKS: u64 = 300; - const SNAPSHOT_MODE: ::snapshot::PowSnapshot = ::snapshot::PowSnapshot { blocks: NUM_SNAPSHOT_BLOCKS, max_restore_blocks: NUM_SNAPSHOT_BLOCKS }; + const SNAPSHOT_MODE: PowSnapshot = PowSnapshot { blocks: NUM_SNAPSHOT_BLOCKS, max_restore_blocks: NUM_SNAPSHOT_BLOCKS }; // Temporary folders let tempdir = TempDir::new("").unwrap(); @@ -197,7 +202,7 @@ fn keep_ancient_blocks() { 0 ).unwrap(); - let manifest = ::snapshot::ManifestData { + let manifest = ManifestData { version: 2, state_hashes, state_root, @@ -209,13 +214,13 @@ fn keep_ancient_blocks() { writer.into_inner().finish(manifest.clone()).unwrap(); // Initialize the Client - let db_config = DatabaseConfig::with_columns(::db::NUM_COLUMNS); + let db_config = DatabaseConfig::with_columns(ethcore_db::NUM_COLUMNS); let client_db = new_temp_db(&tempdir.path()); let client2 = Client::new( ClientConfig::default(), &spec, client_db, - Arc::new(::miner::Miner::new_for_tests(&spec, None)), + Arc::new(miner::Miner::new_for_tests(&spec, None)), IoChannel::disconnected(), ).unwrap(); @@ -283,13 +288,13 @@ fn recover_aborted_recovery() { let spec = spec::new_null(); let tempdir = TempDir::new("").unwrap(); - let db_config = DatabaseConfig::with_columns(::db::NUM_COLUMNS); + let db_config = DatabaseConfig::with_columns(ethcore_db::NUM_COLUMNS); let client_db = new_db(); let client2 = Client::new( Default::default(), &spec, client_db, - Arc::new(::miner::Miner::new_for_tests(&spec, None)), + Arc::new(miner::Miner::new_for_tests(&spec, None)), IoChannel::disconnected(), ).unwrap(); let service_params = ServiceParams { diff --git a/ethcore/src/snapshot/tests/state.rs b/ethcore/snapshot/src/tests/state.rs similarity index 87% rename from ethcore/src/snapshot/tests/state.rs rename to ethcore/snapshot/src/tests/state.rs index 50a505e3e71..0be36554977 100644 --- a/ethcore/src/snapshot/tests/state.rs +++ b/ethcore/snapshot/src/tests/state.rs @@ -18,17 +18,20 @@ use std::sync::Arc; use std::sync::atomic::AtomicBool; -use hash::{KECCAK_NULL_RLP, keccak}; +use keccak_hash::{KECCAK_NULL_RLP, keccak}; -use types::{ +use common_types::{ basic_account::BasicAccount, errors::EthcoreError as Error, + snapshot::ManifestData, }; use client_traits::SnapshotWriter; -use snapshot::account; -use snapshot::{chunk_state, Error as SnapshotError, Progress, StateRebuilder, SNAPSHOT_SUBPARTS}; -use snapshot::io::{PackedReader, PackedWriter, SnapshotReader}; -use super::helpers::StateProducer; +use crate::{ + account, + {chunk_state, Error as SnapshotError, Progress, StateRebuilder, SNAPSHOT_SUBPARTS}, + io::{PackedReader, PackedWriter, SnapshotReader}, + tests::helpers::StateProducer, +}; use rand::SeedableRng; use rand_xorshift::XorShiftRng; use ethereum_types::H256; @@ -45,7 +48,7 @@ fn snap_and_restore() { let mut producer = StateProducer::new(); let mut rng = XorShiftRng::from_seed(RNG_SEED); let mut old_db = journaldb::new_memory_db(); - let db_cfg = DatabaseConfig::with_columns(::db::NUM_COLUMNS); + let db_cfg = DatabaseConfig::with_columns(ethcore_db::NUM_COLUMNS); for _ in 0..150 { producer.tick(&mut rng, &mut old_db); @@ -63,11 +66,11 @@ fn snap_and_restore() { state_hashes.append(&mut hashes); } - writer.into_inner().finish(::snapshot::ManifestData { + writer.into_inner().finish(ManifestData { version: 2, - state_hashes: state_hashes, + state_hashes, block_hashes: Vec::new(), - state_root: state_root, + state_root, block_number: 1000, block_hash: H256::zero(), }).unwrap(); @@ -82,7 +85,7 @@ fn snap_and_restore() { for chunk_hash in &reader.manifest().state_hashes { let raw = reader.chunk(*chunk_hash).unwrap(); - let chunk = ::snappy::decompress(&raw).unwrap(); + let chunk = snappy::decompress(&raw).unwrap(); rebuilder.feed(&chunk, &flag).unwrap(); } @@ -93,7 +96,7 @@ fn snap_and_restore() { new_db }; - let new_db = journaldb::new(db, Algorithm::OverlayRecent, ::db::COL_STATE); + let new_db = journaldb::new(db, Algorithm::OverlayRecent, ethcore_db::COL_STATE); assert_eq!(new_db.earliest_era(), Some(1000)); let keys = old_db.keys(); @@ -141,7 +144,7 @@ fn get_code_from_prev_chunk() { let chunk2 = make_chunk(acc, h2); let tempdir = TempDir::new("").unwrap(); - let db_cfg = DatabaseConfig::with_columns(::db::NUM_COLUMNS); + let db_cfg = DatabaseConfig::with_columns(ethcore_db::NUM_COLUMNS); let new_db = Arc::new(Database::open(&db_cfg, tempdir.path().to_str().unwrap()).unwrap()); { @@ -154,7 +157,7 @@ fn get_code_from_prev_chunk() { rebuilder.finalize(1000, H256::random()).unwrap(); } - let state_db = journaldb::new(new_db, Algorithm::OverlayRecent, ::db::COL_STATE); + let state_db = journaldb::new(new_db, Algorithm::OverlayRecent, ethcore_db::COL_STATE); assert_eq!(state_db.earliest_era(), Some(1000)); } @@ -163,7 +166,7 @@ fn checks_flag() { let mut producer = StateProducer::new(); let mut rng = XorShiftRng::from_seed(RNG_SEED); let mut old_db = journaldb::new_memory_db(); - let db_cfg = DatabaseConfig::with_columns(::db::NUM_COLUMNS); + let db_cfg = DatabaseConfig::with_columns(ethcore_db::NUM_COLUMNS); for _ in 0..10 { producer.tick(&mut rng, &mut old_db); @@ -177,7 +180,7 @@ fn checks_flag() { let state_hashes = chunk_state(&old_db, &state_root, &writer, &Progress::default(), None, 0).unwrap(); - writer.into_inner().finish(::snapshot::ManifestData { + writer.into_inner().finish(ManifestData { version: 2, state_hashes, block_hashes: Vec::new(), @@ -197,7 +200,7 @@ fn checks_flag() { for chunk_hash in &reader.manifest().state_hashes { let raw = reader.chunk(*chunk_hash).unwrap(); - let chunk = ::snappy::decompress(&raw).unwrap(); + let chunk = snappy::decompress(&raw).unwrap(); match rebuilder.feed(&chunk, &flag) { Err(Error::Snapshot(SnapshotError::RestorationAborted)) => {}, diff --git a/ethcore/src/snapshot/tests/test_validator_contract.json b/ethcore/snapshot/src/tests/test_validator_contract.json similarity index 100% rename from ethcore/src/snapshot/tests/test_validator_contract.json rename to ethcore/snapshot/src/tests/test_validator_contract.json diff --git a/ethcore/src/snapshot/traits.rs b/ethcore/snapshot/src/traits.rs similarity index 99% rename from ethcore/src/snapshot/traits.rs rename to ethcore/snapshot/src/traits.rs index 3eb2542bcba..7425ada6375 100644 --- a/ethcore/src/snapshot/traits.rs +++ b/ethcore/snapshot/src/traits.rs @@ -18,11 +18,12 @@ use std::sync::{Arc, atomic::AtomicBool}; use blockchain::{BlockChain, BlockChainDB}; use bytes::Bytes; -use ethereum_types::H256; -use types::{ +use common_types::{ errors::{EthcoreError as Error, SnapshotError}, snapshot::{ManifestData, ChunkSink, Progress, RestorationStatus}, }; +use engine::Engine; +use ethereum_types::H256; /// The interface for a snapshot network service. @@ -69,8 +70,6 @@ pub trait SnapshotService : Sync + Send { fn shutdown(&self); } -use crate::engine::Engine; - /// Restore from secondary snapshot chunks. pub trait Rebuilder: Send { /// Feed a chunk, potentially out of order. diff --git a/ethcore/src/snapshot/watcher.rs b/ethcore/snapshot/src/watcher.rs similarity index 87% rename from ethcore/src/snapshot/watcher.rs rename to ethcore/snapshot/src/watcher.rs index 828fb8d4d45..864efd356ea 100644 --- a/ethcore/src/snapshot/watcher.rs +++ b/ethcore/snapshot/src/watcher.rs @@ -16,18 +16,18 @@ //! Watcher for snapshot-related chain events. -use parking_lot::Mutex; -use client::{Client, ChainNotify, NewBlocks}; -use client_traits::BlockInfo; -use types::{ +use std::sync::Arc; + +use client_traits::{BlockInfo, ChainNotify}; +use common_types::{ ids::BlockId, io_message::ClientIoMessage, + chain_notify::NewBlocks, }; - -use io::IoChannel; use ethereum_types::H256; - -use std::sync::Arc; +use ethcore_io::IoChannel; +use log::{trace, warn}; +use parking_lot::Mutex; // helper trait for transforming hashes to numbers and checking if syncing. trait Oracle: Send + Sync { @@ -37,7 +37,7 @@ trait Oracle: Send + Sync { } struct StandardOracle where F: 'static + Send + Sync + Fn() -> bool { - client: Arc, + client: Arc, sync_status: F, } @@ -58,7 +58,7 @@ trait Broadcast: Send + Sync { fn take_at(&self, num: Option); } -impl Broadcast for Mutex>> { +impl Broadcast for Mutex>> { fn take_at(&self, num: Option) { let num = match num { Some(n) => n, @@ -86,17 +86,16 @@ impl Watcher { /// Create a new `Watcher` which will trigger a snapshot event /// once every `period` blocks, but only after that block is /// `history` blocks old. - pub fn new(client: Arc, sync_status: F, channel: IoChannel>, period: u64, history: u64) -> Self - where F: 'static + Send + Sync + Fn() -> bool + pub fn new(client: Arc, sync_status: F, channel: IoChannel>, period: u64, history: u64) -> Self + where + F: 'static + Send + Sync + Fn() -> bool, + C: 'static + Send + Sync, { Watcher { - oracle: Box::new(StandardOracle { - client: client, - sync_status: sync_status, - }), + oracle: Box::new(StandardOracle { client, sync_status }), broadcast: Box::new(Mutex::new(channel)), - period: period, - history: history, + period, + history, } } } @@ -123,14 +122,15 @@ impl ChainNotify for Watcher { #[cfg(test)] mod tests { - use super::{Broadcast, Oracle, Watcher}; + use std::collections::HashMap; + use std::time::Duration; - use client::{ChainNotify, NewBlocks, ChainRoute}; + use client_traits::ChainNotify; + use common_types::chain_notify::{NewBlocks, ChainRoute}; use ethereum_types::{H256, U256, BigEndianHash}; - use std::collections::HashMap; - use std::time::Duration; + use super::{Broadcast, Oracle, Watcher}; struct TestOracle(HashMap); @@ -161,8 +161,8 @@ mod tests { let watcher = Watcher { oracle: Box::new(TestOracle(map)), broadcast: Box::new(TestBroadcast(expected)), - period: period, - history: history, + period, + history, }; watcher.new_blocks(NewBlocks::new( diff --git a/ethcore/src/client/client.rs b/ethcore/src/client/client.rs index bb4855e189e..000a0cd7583 100644 --- a/ethcore/src/client/client.rs +++ b/ethcore/src/client/client.rs @@ -21,7 +21,7 @@ use std::sync::{Arc, Weak}; use std::time::{Instant, Duration}; use account_state::state::StateInfo; -use blockchain::{BlockReceipts, BlockChain, BlockChainDB, BlockProvider, TreeRoute, ImportRoute, TransactionAddress, ExtrasInsert, BlockNumberKey}; +use blockchain::{BlockReceipts, BlockChain, BlockChainDB, BlockProvider, TreeRoute, TransactionAddress, ExtrasInsert, BlockNumberKey}; use bytes::Bytes; use call_contract::{CallContract, RegistryInfo}; use ethcore_miner::pool::VerifiedTransaction; @@ -41,15 +41,15 @@ use block::{LockedBlock, Drain, ClosedBlock, OpenBlock, enact_verified, SealedBl use client::ancient_import::AncientVerifier; use client::{ ReopenBlock, PrepareOpenBlock, ImportSealedBlock, BroadcastProposalBlock, - Call, BlockProducer, SealedBlockImporter, ChainNotify, EngineInfo, - ClientConfig, NewBlocks, ChainRoute, ChainMessageType, bad_blocks, + Call, BlockProducer, SealedBlockImporter, EngineInfo, + ClientConfig, bad_blocks, }; use client_traits::{ BlockInfo, ScheduleInfo, StateClient, BlockChainReset, Nonce, Balance, ChainInfo, TransactionInfo, ImportBlock, AccountData, BlockChain as BlockChainTrait, BlockChainClient, IoClient, BadBlocks, ProvingBlockChainClient, SnapshotClient, - DatabaseRestore, SnapshotWriter, Tick, + DatabaseRestore, SnapshotWriter, Tick, ChainNotify, StateOrBlock, }; use engine::Engine; @@ -72,7 +72,9 @@ use types::{ block::PreverifiedBlock, block_status::BlockStatus, blockchain_info::BlockChainInfo, + chain_notify::{NewBlocks, ChainRoute, ChainMessageType}, client_types::ClientReport, + import_route::ImportRoute, io_message::ClientIoMessage, encoded, engines::{ @@ -986,12 +988,14 @@ impl Client { self.importer.miner.clone() } - #[cfg(test)] + /// Access state from tests + #[cfg(any(test, feature = "test-helpers"))] pub fn state_db(&self) -> ::parking_lot::RwLockReadGuard { self.state_db.read() } - #[cfg(test)] + /// Access the BlockChain from tests + #[cfg(any(test, feature = "test-helpers"))] pub fn chain(&self) -> Arc { self.chain.read().clone() } diff --git a/ethcore/src/client/mod.rs b/ethcore/src/client/mod.rs index 58b8b7ffa65..c6b338444ef 100644 --- a/ethcore/src/client/mod.rs +++ b/ethcore/src/client/mod.rs @@ -31,7 +31,6 @@ pub use self::config::{ClientConfig, DatabaseCompactionProfile, BlockChainConfig pub use self::evm_test_client::{EvmTestClient, EvmTestError, TransactErr, TransactSuccess}; #[cfg(any(test, feature = "test-helpers"))] pub use self::test_client::{TestBlockChainClient, EachBlockWith, TestState}; -pub use self::chain_notify::{ChainNotify, NewBlocks, ChainRoute, ChainRouteType, ChainMessageType}; pub use self::traits::{ ReopenBlock, PrepareOpenBlock, ImportSealedBlock, BroadcastProposalBlock, Call, EngineInfo, BlockProducer, SealedBlockImporter, @@ -40,4 +39,3 @@ pub use self::traits::{ pub use verification::VerifierType; mod traits; -mod chain_notify; diff --git a/ethcore/src/lib.rs b/ethcore/src/lib.rs index 8beaf991f53..727665a6c00 100644 --- a/ethcore/src/lib.rs +++ b/ethcore/src/lib.rs @@ -53,16 +53,13 @@ //! cargo build --release //! ``` -extern crate account_db; extern crate account_state; extern crate ansi_term; extern crate client_traits; extern crate common_types as types; -extern crate crossbeam_utils; extern crate engine; extern crate ethabi; extern crate ethcore_blockchain as blockchain; -extern crate ethcore_bloom_journal as bloom_journal; extern crate ethcore_call_contract as call_contract; extern crate ethcore_db as db; extern crate ethcore_io as io; @@ -74,13 +71,10 @@ extern crate hash_db; extern crate itertools; extern crate journaldb; extern crate keccak_hash as hash; -extern crate keccak_hasher; extern crate kvdb; extern crate machine; extern crate memory_cache; -extern crate num_cpus; extern crate parity_bytes as bytes; -extern crate parity_snappy as snappy; extern crate parking_lot; extern crate trie_db as trie; extern crate patricia_trie_ethereum as ethtrie; @@ -88,6 +82,7 @@ extern crate rand; extern crate rayon; extern crate rlp; extern crate serde; +extern crate snapshot; extern crate spec; extern crate state_db; extern crate trace; @@ -107,6 +102,8 @@ extern crate ethcore_stratum; #[cfg(any(test, feature = "stratum"))] extern crate ethash; +#[cfg(any(test, feature = "test-helpers"))] +extern crate account_db; #[cfg(any(test, feature = "test-helpers"))] extern crate ethkey; #[cfg(any(test, feature = "test-helpers"))] @@ -157,7 +154,6 @@ extern crate parity_runtime; pub mod block; pub mod client; pub mod miner; -pub mod snapshot; #[cfg(test)] mod tests; diff --git a/ethcore/src/test_helpers.rs b/ethcore/src/test_helpers.rs index a89b342def5..30484bf0d45 100644 --- a/ethcore/src/test_helpers.rs +++ b/ethcore/src/test_helpers.rs @@ -34,6 +34,7 @@ use parking_lot::RwLock; use rlp::{self, RlpStream}; use tempdir::TempDir; use types::{ + chain_notify::ChainMessageType, transaction::{Action, Transaction, SignedTransaction}, encoded, engines::ForkChoice, @@ -44,8 +45,8 @@ use types::{ }; use block::{OpenBlock, Drain}; -use client::{Client, ClientConfig, ChainNotify, ChainMessageType, PrepareOpenBlock}; -use client_traits::{ChainInfo, ImportBlock}; +use client::{Client, ClientConfig, PrepareOpenBlock}; +use client_traits::{ChainInfo, ChainNotify, ImportBlock}; use trie_vm_factories::Factories; use miner::Miner; use spec::{Spec, self}; diff --git a/ethcore/state-db/src/lib.rs b/ethcore/state-db/src/lib.rs index 67d70343aad..7b121dfb7b1 100644 --- a/ethcore/state-db/src/lib.rs +++ b/ethcore/state-db/src/lib.rs @@ -207,9 +207,9 @@ impl StateDB { /// Journal all recent operations under the given era and ID. pub fn journal_under(&mut self, batch: &mut DBTransaction, now: u64, id: &H256) -> io::Result { { - let mut bloom_lock = self.account_bloom.lock(); - Self::commit_bloom(batch, bloom_lock.drain_journal())?; - } + let mut bloom_lock = self.account_bloom.lock(); + Self::commit_bloom(batch, bloom_lock.drain_journal())?; + } let records = self.db.journal_under(batch, now, id)?; self.commit_hash = Some(id.clone()); self.commit_number = Some(now); diff --git a/ethcore/sync/Cargo.toml b/ethcore/sync/Cargo.toml index 7216148876e..c60b2cb030c 100644 --- a/ethcore/sync/Cargo.toml +++ b/ethcore/sync/Cargo.toml @@ -17,11 +17,12 @@ ethcore-io = { path = "../../util/io" } ethcore-light = { path = "../light" } ethcore-network = { path = "../../util/network" } ethcore-network-devp2p = { path = "../../util/network-devp2p" } -ethereum-types = "0.6.0" ethcore-private-tx = { path = "../private-tx" } +ethereum-types = "0.6.0" ethkey = { path = "../../accounts/ethkey" } ethstore = { path = "../../accounts/ethstore" } fastmap = { path = "../../util/fastmap" } +futures = "0.1" hash-db = "0.15.0" keccak-hash = "0.2.0" keccak-hasher = { path = "../../util/keccak-hasher" } @@ -30,20 +31,20 @@ log = "0.4" machine = { path = "../machine" } macros = { path = "../../util/macros" } parity-bytes = "0.1" -parking_lot = "0.8" +parity-runtime = { path = "../../util/runtime" } parity-util-mem = "0.2.0" +parking_lot = "0.8" rand = "0.6" rlp = "0.4.0" +snapshot = { path = "../snapshot" } trace-time = "0.1" triehash-ethereum = {version = "0.2", path = "../../util/triehash-ethereum" } -futures = "0.1" -parity-runtime = { path = "../../util/runtime" } [dev-dependencies] env_logger = "0.5" ethcore = { path = "..", features = ["test-helpers"] } ethcore-io = { path = "../../util/io", features = ["mio"] } kvdb-memorydb = "0.1" -rustc-hex = "1.0" rand_xorshift = "0.1.1" +rustc-hex = "1.0" spec = { path = "../spec" } diff --git a/ethcore/sync/src/api.rs b/ethcore/sync/src/api.rs index eeb6cb41d42..75f9634ad69 100644 --- a/ethcore/sync/src/api.rs +++ b/ethcore/sync/src/api.rs @@ -25,16 +25,13 @@ use network::{NetworkProtocolHandler, NetworkContext, PeerId, ProtocolId, NetworkConfiguration as BasicNetworkConfiguration, NonReservedPeerMode, Error, ConnectionFilter}; use network::client_version::ClientVersion; - -use types::pruning_info::PruningInfo; use ethereum_types::{H256, H512, U256}; use futures::sync::mpsc as futures_mpsc; use futures::Stream; use io::{TimerToken}; use ethkey::Secret; -use ethcore::client::{ChainNotify, NewBlocks, ChainMessageType}; -use client_traits::BlockChainClient; -use ethcore::snapshot::SnapshotService; +use client_traits::{BlockChainClient, ChainNotify}; +use snapshot::SnapshotService; use ethcore_private_tx::PrivateStateDB; use types::BlockNumber; use sync_io::NetSyncIo; @@ -55,7 +52,11 @@ use parity_runtime::Executor; use std::sync::atomic::{AtomicBool, Ordering}; use network::IpFilter; use private_tx::PrivateTxHandler; -use types::transaction::UnverifiedTransaction; +use types::{ + chain_notify::{NewBlocks, ChainMessageType}, + pruning_info::PruningInfo, + transaction::UnverifiedTransaction, +}; use super::light_sync::SyncInfo; diff --git a/ethcore/sync/src/chain/handler.rs b/ethcore/sync/src/chain/handler.rs index e7a54fa95be..8c0ab8741d0 100644 --- a/ethcore/sync/src/chain/handler.rs +++ b/ethcore/sync/src/chain/handler.rs @@ -23,10 +23,12 @@ use hash::keccak; use network::PeerId; use network::client_version::ClientVersion; use rlp::Rlp; -use snapshot::ChunkType; +use crate::{ + snapshot_sync::ChunkType, + sync_io::SyncIo, +}; use std::time::Instant; use std::{mem, cmp}; -use sync_io::SyncIo; use types::{ BlockNumber, block_status::BlockStatus, @@ -711,7 +713,7 @@ impl SyncHandler { Err(e) => { trace!(target: "privatetx", "Ignoring the message, error queueing: {}", e); } - } + } Ok(()) } @@ -739,7 +741,7 @@ impl SyncHandler { Err(e) => { trace!(target: "privatetx", "Ignoring the message, error queueing: {}", e); } - } + } Ok(()) } diff --git a/ethcore/sync/src/chain/mod.rs b/ethcore/sync/src/chain/mod.rs index 07be14f7fe0..ed0f867169b 100644 --- a/ethcore/sync/src/chain/mod.rs +++ b/ethcore/sync/src/chain/mod.rs @@ -109,11 +109,13 @@ use rlp::{RlpStream, DecoderError}; use network::{self, PeerId, PacketId}; use network::client_version::ClientVersion; use client_traits::BlockChainClient; -use sync_io::SyncIo; +use crate::{ + sync_io::SyncIo, + snapshot_sync::Snapshot, +}; use super::{WarpSync, SyncConfig}; use block_sync::{BlockDownloader, DownloadAction}; use rand::{Rng, seq::SliceRandom}; -use snapshot::{Snapshot}; use api::{EthProtocolInfo as PeerInfoDigest, WARP_SYNC_PROTOCOL_ID, PriorityTask}; use private_tx::PrivateTxHandler; use transactions_stats::{TransactionsStats, Stats as TransactionStats}; diff --git a/ethcore/sync/src/lib.rs b/ethcore/sync/src/lib.rs index 32baddec0d7..54e013fd453 100644 --- a/ethcore/sync/src/lib.rs +++ b/ethcore/sync/src/lib.rs @@ -27,19 +27,20 @@ extern crate ethcore; extern crate ethcore_io as io; extern crate ethcore_network as network; extern crate ethcore_network_devp2p as devp2p; +extern crate ethcore_private_tx; extern crate ethereum_types; extern crate ethkey; extern crate ethstore; extern crate fastmap; +extern crate futures; extern crate keccak_hash as hash; extern crate parity_bytes as bytes; extern crate parity_runtime; extern crate parking_lot; -extern crate ethcore_private_tx; extern crate rand; extern crate rlp; +extern crate snapshot; extern crate triehash_ethereum; -extern crate futures; extern crate ethcore_light as light; @@ -69,7 +70,7 @@ mod blocks; mod block_sync; mod sync_io; mod private_tx; -mod snapshot; +mod snapshot_sync; mod transactions_stats; pub mod light_sync; diff --git a/ethcore/sync/src/snapshot.rs b/ethcore/sync/src/snapshot_sync.rs similarity index 99% rename from ethcore/sync/src/snapshot.rs rename to ethcore/sync/src/snapshot_sync.rs index 882ee188091..6aa00738031 100644 --- a/ethcore/sync/src/snapshot.rs +++ b/ethcore/sync/src/snapshot_sync.rs @@ -14,7 +14,7 @@ // You should have received a copy of the GNU General Public License // along with Parity Ethereum. If not, see . -use ethcore::snapshot::SnapshotService; +use snapshot::SnapshotService; use ethereum_types::H256; use hash::keccak; use types::snapshot::ManifestData; diff --git a/ethcore/sync/src/sync_io.rs b/ethcore/sync/src/sync_io.rs index 5c974e712fe..0f92220af6e 100644 --- a/ethcore/sync/src/sync_io.rs +++ b/ethcore/sync/src/sync_io.rs @@ -23,7 +23,7 @@ use bytes::Bytes; use client_traits::BlockChainClient; use ethcore_private_tx::PrivateStateDB; use types::BlockNumber; -use ethcore::snapshot::SnapshotService; +use snapshot::SnapshotService; use parking_lot::RwLock; /// IO interface for the syncing handler. diff --git a/ethcore/sync/src/tests/helpers.rs b/ethcore/sync/src/tests/helpers.rs index 666d362ebb5..938569f5603 100644 --- a/ethcore/sync/src/tests/helpers.rs +++ b/ethcore/sync/src/tests/helpers.rs @@ -22,11 +22,17 @@ use bytes::Bytes; use network::{self, PeerId, ProtocolId, PacketId, SessionInfo}; use network::client_version::ClientVersion; use tests::snapshot::*; -use types::io_message::ClientIoMessage; -use client_traits::BlockChainClient; -use ethcore::client::{TestBlockChainClient, Client as EthcoreClient, - ClientConfig, ChainNotify, NewBlocks, ChainMessageType}; -use ethcore::snapshot::SnapshotService; +use types::{ + chain_notify::{NewBlocks, ChainMessageType}, + io_message::ClientIoMessage, +}; +use client_traits::{BlockChainClient, ChainNotify}; +use ethcore::client::{ + TestBlockChainClient, + Client as EthcoreClient, + ClientConfig, +}; +use snapshot::SnapshotService; use spec::{self, Spec}; use ethcore_private_tx::PrivateStateDB; use ethcore::miner::Miner; diff --git a/ethcore/sync/src/tests/snapshot.rs b/ethcore/sync/src/tests/snapshot.rs index 8136dc50c41..8152bc69ca2 100644 --- a/ethcore/sync/src/tests/snapshot.rs +++ b/ethcore/sync/src/tests/snapshot.rs @@ -20,7 +20,7 @@ use hash::keccak; use ethereum_types::H256; use parking_lot::Mutex; use bytes::Bytes; -use ethcore::snapshot::SnapshotService; +use snapshot::SnapshotService; use ethcore::client::EachBlockWith; use types::{ BlockNumber, diff --git a/ethcore/types/src/block.rs b/ethcore/types/src/block.rs index e110fc7dc99..334ab691c0e 100644 --- a/ethcore/types/src/block.rs +++ b/ethcore/types/src/block.rs @@ -21,8 +21,10 @@ //! Other block types are found in `ethcore` use bytes::Bytes; +use ethereum_types::{H256, U256}; use parity_util_mem::MallocSizeOf; +use BlockNumber; use header::Header; use rlp::{Rlp, RlpStream, Decodable, DecoderError}; use transaction::{UnverifiedTransaction, SignedTransaction}; @@ -77,3 +79,40 @@ pub struct PreverifiedBlock { /// Block bytes pub bytes: Bytes, } + +/// Brief info about inserted block. +#[derive(Clone)] +pub struct BlockInfo { + /// Block hash. + pub hash: H256, + /// Block number. + pub number: BlockNumber, + /// Total block difficulty. + pub total_difficulty: U256, + /// Block location in blockchain. + pub location: BlockLocation +} + +/// Describes location of newly inserted block. +#[derive(Debug, Clone, PartialEq)] +pub enum BlockLocation { + /// It's part of the canon chain. + CanonChain, + /// It's not a part of the canon chain. + Branch, + /// It's part of the fork which should become canon chain, + /// because its total difficulty is higher than current + /// canon chain difficulty. + BranchBecomingCanonChain(BranchBecomingCanonChainData), +} + +/// Info about heaviest fork +#[derive(Debug, Clone, PartialEq)] +pub struct BranchBecomingCanonChainData { + /// Hash of the newest common ancestor with old canon chain. + pub ancestor: H256, + /// Hashes of the blocks between ancestor and this block. + pub enacted: Vec, + /// Hashes of the blocks which were invalidated. + pub retracted: Vec, +} diff --git a/ethcore/src/client/chain_notify.rs b/ethcore/types/src/chain_notify.rs similarity index 79% rename from ethcore/src/client/chain_notify.rs rename to ethcore/types/src/chain_notify.rs index 1567f6c5c9e..fe41644efa4 100644 --- a/ethcore/src/client/chain_notify.rs +++ b/ethcore/types/src/chain_notify.rs @@ -14,10 +14,14 @@ // You should have received a copy of the GNU General Public License // along with Parity Ethereum. If not, see . +//! Types pertaining to sending messages and finding routes through the chain. Used mostly by the +//! ChainNotify trait. + use bytes::Bytes; -use ethereum_types::{H256, U256}; -use types::transaction::UnverifiedTransaction; -use blockchain::ImportRoute; +use ethereum_types::H256; +use crate::{ + import_route::ImportRoute, +}; use std::time::Duration; use std::collections::HashMap; @@ -116,7 +120,8 @@ impl ChainRoute { } } -/// Used by `ChainNotify` `new_blocks()` +/// Used by `ChainNotify` `new_blocks()` and contains information about new blocks imported to the +/// chain. pub struct NewBlocks { /// Imported blocks pub imported: Vec, @@ -156,40 +161,3 @@ impl NewBlocks { } } } - -/// Represents what has to be handled by actor listening to chain events -pub trait ChainNotify : Send + Sync { - /// fires when chain has new blocks. - fn new_blocks(&self, _new_blocks: NewBlocks) { - // does nothing by default - } - - /// fires when chain achieves active mode - fn start(&self) { - // does nothing by default - } - - /// fires when chain achieves passive mode - fn stop(&self) { - // does nothing by default - } - - /// fires when chain broadcasts a message - fn broadcast(&self, _message_type: ChainMessageType) { - // does nothing by default - } - - /// fires when new block is about to be imported - /// implementations should be light - fn block_pre_import(&self, _bytes: &Bytes, _hash: &H256, _difficulty: &U256) { - // does nothing by default - } - - /// fires when new transactions are received from a peer - fn transactions_received(&self, - _txs: &[UnverifiedTransaction], - _peer_id: usize, - ) { - // does nothing by default - } -} diff --git a/ethcore/types/src/client_types.rs b/ethcore/types/src/client_types.rs index a67eebcab1f..00fcd91be40 100644 --- a/ethcore/types/src/client_types.rs +++ b/ethcore/types/src/client_types.rs @@ -17,11 +17,12 @@ //! Client related types. use std::{ + cmp, fmt::{Display, Formatter, Error as FmtError}, ops, - cmp, time::Duration, }; + use ethereum_types::U256; use crate::header::Header; @@ -88,4 +89,3 @@ impl<'a> ops::Sub<&'a ClientReport> for ClientReport { self } } - diff --git a/ethcore/blockchain/src/import_route.rs b/ethcore/types/src/import_route.rs similarity index 95% rename from ethcore/blockchain/src/import_route.rs rename to ethcore/types/src/import_route.rs index 46ebc254b4e..3261b418c2a 100644 --- a/ethcore/blockchain/src/import_route.rs +++ b/ethcore/types/src/import_route.rs @@ -14,10 +14,10 @@ // You should have received a copy of the GNU General Public License // along with Parity Ethereum. If not, see . -//! Import route. +//! Calculate import route for newly inserted blocks. use ethereum_types::H256; -use crate::block_info::{BlockInfo, BlockLocation}; +use crate::block::{BlockInfo, BlockLocation}; /// Import route for newly inserted block. #[derive(Debug, PartialEq, Clone)] @@ -69,7 +69,7 @@ impl From for ImportRoute { #[cfg(test)] mod tests { use ethereum_types::{U256, BigEndianHash}; - use crate::block_info::{BlockInfo, BlockLocation, BranchBecomingCanonChainData}; + use crate::block::{BlockInfo, BlockLocation, BranchBecomingCanonChainData}; use super::ImportRoute; #[test] diff --git a/ethcore/types/src/lib.rs b/ethcore/types/src/lib.rs index fb39ad6eb7c..3b5f1f68ad6 100644 --- a/ethcore/types/src/lib.rs +++ b/ethcore/types/src/lib.rs @@ -64,6 +64,7 @@ pub mod block; pub mod block_status; pub mod blockchain_info; pub mod call_analytics; +pub mod chain_notify; pub mod client_types; pub mod encoded; pub mod engines; @@ -72,6 +73,7 @@ pub mod filter; pub mod header; pub mod ids; pub mod io_message; +pub mod import_route; pub mod log_entry; pub mod pruning_info; pub mod receipt; diff --git a/parity/configuration.rs b/parity/configuration.rs index 2066d590854..d19e39fa433 100644 --- a/parity/configuration.rs +++ b/parity/configuration.rs @@ -31,7 +31,7 @@ use sync::{NetworkConfiguration, validate_node_url, self}; use ethkey::{Secret, Public}; use ethcore::client::{VMType}; use ethcore::miner::{stratum, MinerOptions}; -use ethcore::snapshot::SnapshotConfiguration; +use snapshot::SnapshotConfiguration; use miner::pool; use verification::queue::VerifierSettings; @@ -52,7 +52,7 @@ use blockchain::{BlockchainCmd, ImportBlockchain, ExportBlockchain, KillBlockcha use export_hardcoded_sync::ExportHsyncCmd; use presale::ImportWallet; use account::{AccountCmd, NewAccount, ListAccounts, ImportAccounts, ImportFromGethAccounts}; -use snapshot::{self, SnapshotCommand}; +use snapshot_cmd::{self, SnapshotCommand}; use network::{IpFilter}; const DEFAULT_MAX_PEERS: u16 = 50; @@ -321,7 +321,7 @@ impl Configuration { fat_db: fat_db, compaction: compaction, file_path: self.args.arg_snapshot_file.clone(), - kind: snapshot::Kind::Take, + kind: snapshot_cmd::Kind::Take, block_at: to_block_id(&self.args.arg_snapshot_at)?, max_round_blocks_to_import: self.args.arg_max_round_blocks_to_import, snapshot_conf: snapshot_conf, @@ -339,7 +339,7 @@ impl Configuration { fat_db: fat_db, compaction: compaction, file_path: self.args.arg_restore_file.clone(), - kind: snapshot::Kind::Restore, + kind: snapshot_cmd::Kind::Restore, block_at: to_block_id("latest")?, // unimportant. max_round_blocks_to_import: self.args.arg_max_round_blocks_to_import, snapshot_conf: snapshot_conf, diff --git a/parity/informant.rs b/parity/informant.rs index e4511aff483..38f02d45859 100644 --- a/parity/informant.rs +++ b/parity/informant.rs @@ -23,10 +23,11 @@ use std::sync::atomic::{AtomicUsize, AtomicBool, Ordering as AtomicOrdering}; use std::time::{Instant, Duration}; use atty; -use ethcore::client::{ChainNotify, NewBlocks, Client}; -use client_traits::{BlockInfo, ChainInfo, BlockChainClient}; +use ethcore::client::Client; +use client_traits::{BlockInfo, ChainInfo, BlockChainClient, ChainNotify}; use types::{ BlockNumber, + chain_notify::NewBlocks, client_types::ClientReport, ids::BlockId, io_message::ClientIoMessage, @@ -34,8 +35,8 @@ use types::{ verification::VerificationQueueInfo as BlockQueueInfo, snapshot::RestorationStatus, }; -use ethcore::snapshot::SnapshotService as SS; -use ethcore::snapshot::service::Service as SnapshotService; +use snapshot::SnapshotService as SS; +use snapshot::service::Service as SnapshotService; use sync::{LightSyncProvider, LightSync, SyncProvider, ManageNetwork}; use io::{TimerToken, IoContext, IoHandler}; use light::Cache as LightDataCache; @@ -224,7 +225,7 @@ pub struct Informant { last_tick: RwLock, with_color: bool, target: T, - snapshot: Option>, + snapshot: Option>>, rpc_stats: Option>, last_import: Mutex, skipped: AtomicUsize, @@ -237,16 +238,16 @@ impl Informant { /// Make a new instance potentially `with_color` output. pub fn new( target: T, - snapshot: Option>, + snapshot: Option>>, rpc_stats: Option>, with_color: bool, ) -> Self { Informant { last_tick: RwLock::new(Instant::now()), - with_color: with_color, - target: target, - snapshot: snapshot, - rpc_stats: rpc_stats, + with_color, + target, + snapshot, + rpc_stats, last_import: Mutex::new(Instant::now()), skipped: AtomicUsize::new(0), skipped_txs: AtomicUsize::new(0), diff --git a/parity/lib.rs b/parity/lib.rs index 2ea24c0bfc8..3ecf1e84c5a 100644 --- a/parity/lib.rs +++ b/parity/lib.rs @@ -73,6 +73,7 @@ extern crate parity_runtime; extern crate parity_updater as updater; extern crate parity_version; extern crate registrar; +extern crate snapshot; extern crate spec; extern crate verification; @@ -112,7 +113,7 @@ mod rpc_apis; mod run; mod secretstore; mod signer; -mod snapshot; +mod snapshot_cmd; mod upgrade; mod user_defaults; mod db; @@ -213,7 +214,7 @@ fn execute( Cmd::SignerSign { id, pwfile, port, authfile } => cli_signer::signer_sign(id, pwfile, port, authfile).map(|s| ExecutionAction::Instant(Some(s))), Cmd::SignerList { port, authfile } => cli_signer::signer_list(port, authfile).map(|s| ExecutionAction::Instant(Some(s))), Cmd::SignerReject { id, port, authfile } => cli_signer::signer_reject(id, port, authfile).map(|s| ExecutionAction::Instant(Some(s))), - Cmd::Snapshot(snapshot_cmd) => snapshot::execute(snapshot_cmd).map(|s| ExecutionAction::Instant(Some(s))), + Cmd::Snapshot(snapshot_cmd) => snapshot_cmd::execute(snapshot_cmd).map(|s| ExecutionAction::Instant(Some(s))), Cmd::ExportHardcodedSync(export_hs_cmd) => export_hardcoded_sync::execute(export_hs_cmd).map(|s| ExecutionAction::Instant(Some(s))), } } diff --git a/parity/modules.rs b/parity/modules.rs index 783d6fcb177..28ba663162d 100644 --- a/parity/modules.rs +++ b/parity/modules.rs @@ -16,15 +16,14 @@ use std::sync::{Arc, mpsc}; -use client_traits::BlockChainClient; +use client_traits::{BlockChainClient, ChainNotify}; use sync::{self, SyncConfig, NetworkConfiguration, Params, ConnectionFilter}; -use ethcore::snapshot::SnapshotService; +use snapshot::SnapshotService; use ethcore_private_tx::PrivateStateDB; use light::Provider; use parity_runtime::Executor; pub use sync::{EthSync, SyncProvider, ManageNetwork, PrivateTxHandler}; -pub use ethcore::client::ChainNotify; use ethcore_logger::Config as LogConfig; pub type SyncModules = ( diff --git a/parity/rpc_apis.rs b/parity/rpc_apis.rs index 35e65c8ada9..a3f1836f114 100644 --- a/parity/rpc_apis.rs +++ b/parity/rpc_apis.rs @@ -24,7 +24,7 @@ pub use parity_rpc::signer::SignerService; use account_utils::{self, AccountProvider}; use ethcore::client::Client; use ethcore::miner::Miner; -use ethcore::snapshot::SnapshotService; +use snapshot::SnapshotService; use client_traits::BlockChainClient; use sync::SyncState; use ethcore_logger::RotatingLogger; diff --git a/parity/run.rs b/parity/run.rs index 7b88747374c..400541336ce 100644 --- a/parity/run.rs +++ b/parity/run.rs @@ -25,7 +25,7 @@ use call_contract::CallContract; use client_traits::{BlockInfo, BlockChainClient}; use ethcore::client::{Client, DatabaseCompactionProfile, VMType}; use ethcore::miner::{self, stratum, Miner, MinerService, MinerOptions}; -use ethcore::snapshot::{self, SnapshotConfiguration}; +use snapshot::{self, SnapshotConfiguration}; use spec::SpecParams; use verification::queue::VerifierSettings; use ethcore_logger::{Config as LogConfig, RotatingLogger}; diff --git a/parity/snapshot.rs b/parity/snapshot_cmd.rs similarity index 96% rename from parity/snapshot.rs rename to parity/snapshot_cmd.rs index c9657b2d6ac..8c4a1cb10c9 100644 --- a/parity/snapshot.rs +++ b/parity/snapshot_cmd.rs @@ -22,10 +22,10 @@ use std::sync::Arc; use client_traits::SnapshotClient; use hash::keccak; -use ethcore::snapshot::{SnapshotConfiguration, SnapshotService as SS}; -use ethcore::snapshot::io::{SnapshotReader, PackedReader, PackedWriter}; -use ethcore::snapshot::service::Service as SnapshotService; -use ethcore::client::{DatabaseCompactionProfile, VMType}; +use snapshot::{SnapshotConfiguration, SnapshotService as SS}; +use snapshot::io::{SnapshotReader, PackedReader, PackedWriter}; +use snapshot::service::Service as SnapshotService; +use ethcore::client::{Client, DatabaseCompactionProfile, VMType}; use ethcore::miner::Miner; use ethcore_service::ClientService; use types::{ @@ -73,7 +73,7 @@ pub struct SnapshotCommand { // helper for reading chunks from arbitrary reader and feeding them into the // service. -fn restore_using(snapshot: Arc, reader: &R, recover: bool) -> Result<(), String> { +fn restore_using(snapshot: Arc>, reader: &R, recover: bool) -> Result<(), String> { let manifest = reader.manifest(); info!("Restoring to block #{} (0x{:?})", manifest.block_number, manifest.block_hash); diff --git a/rpc/Cargo.toml b/rpc/Cargo.toml index 27b2b6fda47..aa555d75fdf 100644 --- a/rpc/Cargo.toml +++ b/rpc/Cargo.toml @@ -64,6 +64,7 @@ parity-updater = { path = "../updater" } parity-version = { path = "../util/version" } rlp = "0.4.0" account-state = { path = "../ethcore/account-state" } +snapshot = { path = "../ethcore/snapshot" } stats = { path = "../util/stats" } trace = { path = "../ethcore/trace" } vm = { path = "../ethcore/vm" } diff --git a/rpc/src/lib.rs b/rpc/src/lib.rs index 5cb96fa1f14..955947339c8 100644 --- a/rpc/src/lib.rs +++ b/rpc/src/lib.rs @@ -87,6 +87,7 @@ extern crate rlp; extern crate account_state; extern crate stats; +extern crate snapshot; extern crate tempdir; extern crate trace; extern crate vm; diff --git a/rpc/src/v1/impls/eth.rs b/rpc/src/v1/impls/eth.rs index 5c572b8ee48..1e6b088472f 100644 --- a/rpc/src/v1/impls/eth.rs +++ b/rpc/src/v1/impls/eth.rs @@ -29,7 +29,7 @@ use client_traits::{BlockChainClient, StateClient, ProvingBlockChainClient, Stat use ethash::{self, SeedHashCompute}; use ethcore::client::{Call, EngineInfo}; use ethcore::miner::{self, MinerService}; -use ethcore::snapshot::SnapshotService; +use snapshot::SnapshotService; use hash::keccak; use miner::external::ExternalMinerService; use sync::SyncProvider; diff --git a/rpc/src/v1/impls/eth_pubsub.rs b/rpc/src/v1/impls/eth_pubsub.rs index 7841827e934..57f7d7e1aa0 100644 --- a/rpc/src/v1/impls/eth_pubsub.rs +++ b/rpc/src/v1/impls/eth_pubsub.rs @@ -31,8 +31,7 @@ use v1::traits::EthPubSub; use v1::types::{pubsub, RichHeader, Log}; use sync::{SyncState, Notification}; -use ethcore::client::{ChainNotify, NewBlocks, ChainRouteType}; -use client_traits::BlockChainClient; +use client_traits::{BlockChainClient, ChainNotify}; use ethereum_types::H256; use light::cache::Cache; use light::client::{LightChainClient, LightChainNotify}; @@ -43,6 +42,7 @@ use parking_lot::{RwLock, Mutex}; use sync::{LightSyncProvider, LightNetworkDispatcher, ManageNetwork}; use types::{ + chain_notify::{NewBlocks, ChainRouteType}, ids::BlockId, encoded, filter::Filter as EthFilter, diff --git a/rpc/src/v1/impls/parity.rs b/rpc/src/v1/impls/parity.rs index 3503af586b1..2905324d65d 100644 --- a/rpc/src/v1/impls/parity.rs +++ b/rpc/src/v1/impls/parity.rs @@ -23,7 +23,7 @@ use ethereum_types::{H64, H160, H256, H512, U64, U256}; use ethcore::client::Call; use client_traits::{BlockChainClient, StateClient}; use ethcore::miner::{self, MinerService, FilterOptions}; -use ethcore::snapshot::SnapshotService; +use snapshot::SnapshotService; use account_state::state::StateInfo; use ethcore_logger::RotatingLogger; use ethkey::{crypto::ecies, Brain, Generator}; diff --git a/rpc/src/v1/tests/helpers/snapshot_service.rs b/rpc/src/v1/tests/helpers/snapshot_service.rs index aee9a6681c1..7f049ab2094 100644 --- a/rpc/src/v1/tests/helpers/snapshot_service.rs +++ b/rpc/src/v1/tests/helpers/snapshot_service.rs @@ -14,7 +14,7 @@ // You should have received a copy of the GNU General Public License // along with Parity Ethereum. If not, see . -use ethcore::snapshot::SnapshotService; +use snapshot::SnapshotService; use bytes::Bytes; use ethereum_types::H256; diff --git a/rpc/src/v1/tests/mocked/eth_pubsub.rs b/rpc/src/v1/tests/mocked/eth_pubsub.rs index a2bfa118de2..c3563475aea 100644 --- a/rpc/src/v1/tests/mocked/eth_pubsub.rs +++ b/rpc/src/v1/tests/mocked/eth_pubsub.rs @@ -23,11 +23,12 @@ use jsonrpc_pubsub::Session; use std::time::Duration; use v1::{EthPubSub, EthPubSubClient, Metadata}; -use ethcore::client::{TestBlockChainClient, EachBlockWith, ChainNotify, NewBlocks, ChainRoute, ChainRouteType}; +use ethcore::client::{TestBlockChainClient, EachBlockWith}; use parity_runtime::Runtime; use ethereum_types::{Address, H256}; -use client_traits::BlockInfo; +use client_traits::{BlockInfo, ChainNotify}; use types::{ + chain_notify::{NewBlocks, ChainRoute, ChainRouteType}, log_entry::{LocalizedLogEntry, LogEntry}, ids::BlockId, }; diff --git a/secret-store/src/acl_storage.rs b/secret-store/src/acl_storage.rs index 110ce3d5ce6..f8f295ecc66 100644 --- a/secret-store/src/acl_storage.rs +++ b/secret-store/src/acl_storage.rs @@ -16,10 +16,13 @@ use std::sync::Arc; use std::collections::{HashMap, HashSet}; -use common_types::ids::BlockId; +use common_types::{ + chain_notify::NewBlocks, + ids::BlockId +}; use parking_lot::{Mutex, RwLock}; use call_contract::CallContract; -use ethcore::client::{ChainNotify, NewBlocks}; +use client_traits::ChainNotify; use ethereum_types::Address; use ethabi::FunctionOutputDecoder; use trusted_client::TrustedClient; diff --git a/secret-store/src/key_server_set.rs b/secret-store/src/key_server_set.rs index 5ffaa7fb767..c69be8ce7ea 100644 --- a/secret-store/src/key_server_set.rs +++ b/secret-store/src/key_server_set.rs @@ -20,9 +20,12 @@ use std::collections::{BTreeMap, HashSet}; use parking_lot::Mutex; use call_contract::CallContract; use ethabi::FunctionOutputDecoder; -use ethcore::client::{Client, ChainNotify, NewBlocks}; -use client_traits::BlockChainClient; -use common_types::ids::BlockId; +use ethcore::client::Client; +use client_traits::{BlockChainClient, ChainNotify}; +use common_types::{ + chain_notify::NewBlocks, + ids::BlockId, +}; use ethereum_types::{H256, Address}; use ethkey::public_to_address; use bytes::Bytes; diff --git a/secret-store/src/listener/service_contract_listener.rs b/secret-store/src/listener/service_contract_listener.rs index 1b6a6afdfef..c0b30605071 100644 --- a/secret-store/src/listener/service_contract_listener.rs +++ b/secret-store/src/listener/service_contract_listener.rs @@ -18,10 +18,10 @@ use std::collections::HashSet; use std::sync::Arc; use std::sync::atomic::{AtomicUsize, Ordering}; use std::thread; -use parking_lot::Mutex; -use ethcore::client::{ChainNotify, NewBlocks}; -use ethkey::{Public, public_to_address}; +use client_traits::ChainNotify; +use common_types::chain_notify::NewBlocks; use bytes::Bytes; +use ethkey::{Public, public_to_address}; use ethereum_types::{H256, U256, Address, BigEndianHash as _}; use key_server_set::KeyServerSet; use key_server_cluster::{NodeId, ClusterClient, ClusterSessionsListener, ClusterSession}; @@ -32,6 +32,7 @@ use key_server_cluster::decryption_session::SessionImpl as DecryptionSession; use key_server_cluster::key_version_negotiation_session::{SessionImpl as KeyVersionNegotiationSession, IsolatedSessionTransport as KeyVersionNegotiationTransport, FailedContinueAction}; use key_storage::KeyStorage; +use parking_lot::Mutex; use acl_storage::AclStorage; use listener::service_contract::ServiceContract; use listener::tasks_queue::TasksQueue; diff --git a/updater/src/updater.rs b/updater/src/updater.rs index c675fef9417..561f2c3356a 100644 --- a/updater/src/updater.rs +++ b/updater/src/updater.rs @@ -29,9 +29,9 @@ use common_types::{ BlockNumber, ids::BlockId, filter::Filter, + chain_notify::NewBlocks, }; -use ethcore::client::{ChainNotify, NewBlocks}; -use client_traits::BlockChainClient; +use client_traits::{BlockChainClient, ChainNotify}; use ethereum_types::{H256, H160}; use hash_fetch::{self as fetch, HashFetch}; use parity_path::restrict_permissions_owner;