From f0ef6ed01647c24b5629f14bee6aabdbf77e5b4f Mon Sep 17 00:00:00 2001 From: Tomusdrw Date: Tue, 16 Feb 2016 10:21:46 +0100 Subject: [PATCH 01/22] If-else in single line --- rustfmt.toml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 rustfmt.toml diff --git a/rustfmt.toml b/rustfmt.toml new file mode 100644 index 000000000..0b377a371 --- /dev/null +++ b/rustfmt.toml @@ -0,0 +1,14 @@ +verbose=false +max_width=150 +ideal_width=120 +tabs_spaces=4 +fn_call_width=100 +single_line_if_else=true +where_indent="Visual" +where_trailing_comma=true +chain_base_indent="Inherit" +chain_indent="Tabbed" +reorder_imports=true +format_strings=false +hard_tabs=true +wrap_match_arms=false From 771bcb5bda250cf5740d4d08bbe4f427a5fa402e Mon Sep 17 00:00:00 2001 From: Tomusdrw Date: Tue, 16 Feb 2016 10:36:15 +0100 Subject: [PATCH 02/22] Adding formatting script --- fmt.sh | 12 ++++++++++++ util/rustfmt.toml | 1 - 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100755 fmt.sh delete mode 100644 util/rustfmt.toml diff --git a/fmt.sh b/fmt.sh new file mode 100755 index 000000000..33edc3b0d --- /dev/null +++ b/fmt.sh @@ -0,0 +1,12 @@ +#!/bin/sh + +RUSTFMT="rustfmt --write-mode overwrite" + +$RUSTFMT ./util/src/lib.rs +$RUSTFMT ./ethcore/src/lib.rs +$RUSTFMT ./ethash/src/lib.rs +$RUSTFMT ./rpc/src/lib.rs +$RUSTFMT ./sync/src/lib.rs +$RUSTFMT ./evmjit/src/lib.rs +$RUSTFMT ./parity/main.rs + diff --git a/util/rustfmt.toml b/util/rustfmt.toml deleted file mode 100644 index 218e20321..000000000 --- a/util/rustfmt.toml +++ /dev/null @@ -1 +0,0 @@ -hard_tabs = true From 22e2458ce503e52e913baf5c4d96b89c320296c7 Mon Sep 17 00:00:00 2001 From: Tomusdrw Date: Tue, 16 Feb 2016 10:42:56 +0100 Subject: [PATCH 03/22] Adding rustfmt_skip and fixing couple of places that have troubles after formatting. --- ethash/src/sizes.rs | 2 ++ ethcore/src/evm/instructions.rs | 21 +++++++++++---------- util/src/crypto.rs | 2 +- util/src/rlp/rlpin.rs | 6 +++--- util/src/uint.rs | 18 +++++++++--------- 5 files changed, 26 insertions(+), 23 deletions(-) diff --git a/ethash/src/sizes.rs b/ethash/src/sizes.rs index b3a3c0d22..adb3f992b 100644 --- a/ethash/src/sizes.rs +++ b/ethash/src/sizes.rs @@ -29,6 +29,7 @@ // Floor[(CacheSizeBytesInit + CacheGrowth * j) / HashBytes]}, // While[! PrimeQ[i], i--]; // Sow[i*HashBytes]; j++]]]][[2]][[1]] +#[cfg_attr(rustfmt, rustfmt_skip)] pub const DAG_SIZES: [u64; 2048] = [ 1073739904u64, 1082130304u64, 1090514816u64, 1098906752u64, 1107293056u64, 1115684224u64, 1124070016u64, 1132461952u64, 1140849536u64, 1149232768u64, @@ -456,6 +457,7 @@ pub const DAG_SIZES: [u64; 2048] = [ // Module[{i = Floor[(DataSetSizeBytesInit + DataSetGrowth * j) / (CacheMultiplier * HashBytes)]}, // While[! PrimeQ[i], i--]; // Sow[i*HashBytes]; j++]]]][[2]][[1]] +#[cfg_attr(rustfmt, rustfmt_skip)] pub const CACHE_SIZES: [u64; 2048] = [ 16776896u64, 16907456u64, 17039296u64, 17170112u64, 17301056u64, 17432512u64, 17563072u64, 17693888u64, 17824192u64, 17955904u64, 18087488u64, 18218176u64, 18349504u64, 18481088u64, diff --git a/ethcore/src/evm/instructions.rs b/ethcore/src/evm/instructions.rs index 623868618..6a1a06ba9 100644 --- a/ethcore/src/evm/instructions.rs +++ b/ethcore/src/evm/instructions.rs @@ -137,6 +137,7 @@ impl InstructionInfo { } } +#[cfg_attr(rustfmt, rustfmt_skip)] /// Return details about specific instruction pub fn get_info (instruction: Instruction) -> InstructionInfo { match instruction { @@ -301,7 +302,7 @@ pub const EXP: Instruction = 0x0a; pub const SIGNEXTEND: Instruction = 0x0b; /// less-than comparision -pub const LT: Instruction = 0x10; +pub const LT: Instruction = 0x10; /// greater-than comparision pub const GT: Instruction = 0x11; /// signed less-than comparision @@ -324,10 +325,10 @@ pub const NOT: Instruction = 0x19; pub const BYTE: Instruction = 0x1a; /// compute SHA3-256 hash -pub const SHA3: Instruction = 0x20; +pub const SHA3: Instruction = 0x20; /// get address of currently executing account -pub const ADDRESS: Instruction = 0x30; +pub const ADDRESS: Instruction = 0x30; /// get balance of the given account pub const BALANCE: Instruction = 0x31; /// get execution origination address @@ -367,7 +368,7 @@ pub const DIFFICULTY: Instruction = 0x44; pub const GASLIMIT: Instruction = 0x45; /// remove item from stack -pub const POP: Instruction = 0x50; +pub const POP: Instruction = 0x50; /// load word from memory pub const MLOAD: Instruction = 0x51; /// save word to memory @@ -392,7 +393,7 @@ pub const GAS: Instruction = 0x5a; pub const JUMPDEST: Instruction = 0x5b; /// place 1 byte item on stack -pub const PUSH1: Instruction = 0x60; +pub const PUSH1: Instruction = 0x60; /// place 2 byte item on stack pub const PUSH2: Instruction = 0x61; /// place 3 byte item on stack @@ -457,7 +458,7 @@ pub const PUSH31: Instruction = 0x7e; pub const PUSH32: Instruction = 0x7f; /// copies the highest item in the stack to the top of the stack -pub const DUP1: Instruction = 0x80; +pub const DUP1: Instruction = 0x80; /// copies the second highest item in the stack to the top of the stack pub const DUP2: Instruction = 0x81; /// copies the third highest item in the stack to the top of the stack @@ -490,7 +491,7 @@ pub const DUP15: Instruction = 0x8e; pub const DUP16: Instruction = 0x8f; /// swaps the highest and second highest value on the stack -pub const SWAP1: Instruction = 0x90; +pub const SWAP1: Instruction = 0x90; /// swaps the highest and third highest value on the stack pub const SWAP2: Instruction = 0x91; /// swaps the highest and 4th highest value on the stack @@ -523,7 +524,7 @@ pub const SWAP15: Instruction = 0x9e; pub const SWAP16: Instruction = 0x9f; /// Makes a log entry; no topics. -pub const LOG0: Instruction = 0xa0; +pub const LOG0: Instruction = 0xa0; /// Makes a log entry; 1 topic. pub const LOG1: Instruction = 0xa1; /// Makes a log entry; 2 topics. @@ -536,7 +537,7 @@ pub const LOG4: Instruction = 0xa4; pub const MAX_NO_OF_TOPICS : usize = 4; /// create a new account with associated code -pub const CREATE: Instruction = 0xf0; +pub const CREATE: Instruction = 0xf0; /// message-call into an account pub const CALL: Instruction = 0xf1; /// message-call with another account's code only @@ -546,5 +547,5 @@ pub const RETURN: Instruction = 0xf3; /// like CALLCODE but keeps caller's value and sender pub const DELEGATECALL: Instruction = 0xf4; /// halt execution and register account for later deletion -pub const SUICIDE: Instruction = 0xff; +pub const SUICIDE: Instruction = 0xff; diff --git a/util/src/crypto.rs b/util/src/crypto.rs index 596265cd0..792a63ddd 100644 --- a/util/src/crypto.rs +++ b/util/src/crypto.rs @@ -202,7 +202,7 @@ pub mod ec { match context.verify(&try!(Message::from_slice(&message)), &sig, &publ) { Ok(_) => Ok(true), Err(Error::IncorrectSignature) => Ok(false), - Err(x) => Err(>::from(x)) + Err(x) => Err(CryptoError::from(x)) } } diff --git a/util/src/rlp/rlpin.rs b/util/src/rlp/rlpin.rs index d58fa95e8..8f3e26712 100644 --- a/util/src/rlp/rlpin.rs +++ b/util/src/rlp/rlpin.rs @@ -24,7 +24,7 @@ impl<'a> From> for Rlp<'a> { } /// Data-oriented view onto trusted rlp-slice. -/// +/// /// Unlikely to `UntrustedRlp` doesn't bother you with error /// handling. It assumes that you know what you are doing. #[derive(Debug)] @@ -44,7 +44,7 @@ impl<'a, 'view> View<'a, 'view> for Rlp<'a> where 'a: 'view { type Data = &'a [u8]; type Item = Rlp<'a>; type Iter = RlpIterator<'a, 'view>; - + /// Create a new instance of `Rlp` fn new(bytes: &'a [u8]) -> Rlp<'a> { Rlp { @@ -153,7 +153,7 @@ impl<'a, 'view> Iterator for RlpIterator<'a, 'view> { fn next(&mut self) -> Option> { let index = self.index; - let result = self.rlp.rlp.at(index).ok().map(| iter | { From::from(iter) }); + let result = self.rlp.rlp.at(index).ok().map(From::from); self.index += 1; result } diff --git a/util/src/uint.rs b/util/src/uint.rs index b3427f6bc..c3e15a581 100644 --- a/util/src/uint.rs +++ b/util/src/uint.rs @@ -31,7 +31,7 @@ // //! Big unsigned integer types -//! +//! //! Implementation of a various large-but-fixed sized unsigned integer types. //! The functions here are designed to be fast. //! @@ -102,7 +102,7 @@ pub trait Uint: Sized + Default + FromStr + From + FromJson + fmt::Debug + /// Conversion to u64 with overflow checking fn as_u64(&self) -> u64; - + /// Return the least number of bits needed to represent the number fn bits(&self) -> usize; /// Return if specific bit is set @@ -127,7 +127,7 @@ pub trait Uint: Sized + Default + FromStr + From + FromJson + fmt::Debug + /// Multiple this `Uint` with other returning result and possible overflow fn overflowing_mul(self, other: Self) -> (Self, bool); - + /// Divide this `Uint` by other returning result and possible overflow fn overflowing_div(self, other: Self) -> (Self, bool); @@ -136,7 +136,7 @@ pub trait Uint: Sized + Default + FromStr + From + FromJson + fmt::Debug + /// Returns negation of this `Uint` and overflow (always true) fn overflowing_neg(self) -> (Self, bool); - + /// Shifts this `Uint` and returns overflow fn overflowing_shl(self, shift: u32) -> (Self, bool); } @@ -180,7 +180,7 @@ macro_rules! construct_uint { fn as_u32(&self) -> u32 { let &$name(ref arr) = self; if (arr[0] & (0xffffffffu64 << 32)) != 0 { - panic!("Integer overflow when casting U256") + panic!("Integer overflow when casting U256") } self.as_u64() as u32 } @@ -191,7 +191,7 @@ macro_rules! construct_uint { let &$name(ref arr) = self; for i in 1..$n_words { if arr[i] != 0 { - panic!("Integer overflow when casting U256") + panic!("Integer overflow when casting U256") } } arr[0] @@ -325,7 +325,7 @@ macro_rules! construct_uint { if b_carry { let ret = overflowing!($name(ret).overflowing_add($name(carry)), overflow); (ret, overflow) - } else { + } else { ($name(ret), overflow) } } @@ -453,7 +453,7 @@ macro_rules! construct_uint { } impl serde::Serialize for $name { - fn serialize(&self, serializer: &mut S) -> Result<(), S::Error> + fn serialize(&self, serializer: &mut S) -> Result<(), S::Error> where S: serde::Serializer { let mut hex = "0x".to_owned(); let mut bytes = [0u8; 8 * $n_words]; @@ -1129,7 +1129,7 @@ mod tests { assert_eq!(U256::from(105u8) / U256::from(5u8), U256::from(21u8)); let div = mult / U256::from(300u16); assert_eq!(div, U256([0x9F30411021524112u64, 0x0001BD5B7DDFBD5A, 0, 0])); - //// TODO: bit inversion + // TODO: bit inversion } #[test] From 9a867ad277c664401e402e42d227f9f7cd5c9b80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Wed, 23 Mar 2016 18:20:06 +0100 Subject: [PATCH 04/22] Adding new crates --- fmt.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/fmt.sh b/fmt.sh index 33edc3b0d..a16d5ac1f 100755 --- a/fmt.sh +++ b/fmt.sh @@ -2,11 +2,13 @@ RUSTFMT="rustfmt --write-mode overwrite" -$RUSTFMT ./util/src/lib.rs -$RUSTFMT ./ethcore/src/lib.rs $RUSTFMT ./ethash/src/lib.rs +$RUSTFMT ./ethcore/src/lib.rs +$RUSTFMT ./evmjit/src/lib.rs +$RUSTFMT ./json/src/lib.rs +$RUSTFMT ./miner/src/lib.rs +$RUSTFMT ./parity/main.rs $RUSTFMT ./rpc/src/lib.rs $RUSTFMT ./sync/src/lib.rs -$RUSTFMT ./evmjit/src/lib.rs -$RUSTFMT ./parity/main.rs +$RUSTFMT ./util/src/lib.rs From 3352b0e916b1c903f7071f8900d3eec01858ec09 Mon Sep 17 00:00:00 2001 From: debris Date: Wed, 23 Mar 2016 18:36:05 +0100 Subject: [PATCH 05/22] json-tests vm loading --- json/src/lib.rs.in | 1 + json/src/vm/call.rs | 53 +++++++++++++++++++ json/src/vm/env.rs | 58 +++++++++++++++++++++ json/src/vm/log.rs | 54 ++++++++++++++++++++ json/src/vm/mod.rs | 29 +++++++++++ json/src/vm/transaction.rs | 64 +++++++++++++++++++++++ json/src/vm/vm.rs | 101 +++++++++++++++++++++++++++++++++++++ 7 files changed, 360 insertions(+) create mode 100644 json/src/vm/call.rs create mode 100644 json/src/vm/env.rs create mode 100644 json/src/vm/log.rs create mode 100644 json/src/vm/mod.rs create mode 100644 json/src/vm/transaction.rs create mode 100644 json/src/vm/vm.rs diff --git a/json/src/lib.rs.in b/json/src/lib.rs.in index 0d85ce569..20e7e35da 100644 --- a/json/src/lib.rs.in +++ b/json/src/lib.rs.in @@ -24,3 +24,4 @@ pub mod uint; pub mod bytes; pub mod blockchain; pub mod spec; +pub mod vm; diff --git a/json/src/vm/call.rs b/json/src/vm/call.rs new file mode 100644 index 000000000..ca955c7bd --- /dev/null +++ b/json/src/vm/call.rs @@ -0,0 +1,53 @@ +// Copyright 2015, 2016 Ethcore (UK) Ltd. +// This file is part of Parity. + +// Parity 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 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. If not, see . + +//! Vm call deserialization. + +use bytes::Bytes; +use hash::Address; +use uint::Uint; + +/// Vm call deserialization. +#[derive(Debug, PartialEq, Deserialize)] +pub struct Call { + /// Call data. + pub data: Bytes, + /// Call destination. + pub destination: Address, + /// Gas limit. + #[serde(rename="gasLimit")] + pub gas_limit: Uint, + /// Call value. + pub value: Uint, +} + +#[cfg(test)] +mod tests { + use serde_json; + use vm::Call; + + #[test] + fn call_deserialization() { + let s = r#"{ + "data" : "0x1111222233334444555566667777888899990000aaaabbbbccccddddeeeeffff", + "destination" : "", + "gasLimit" : "0x1748766aa5", + "value" : "0x00" + }"#; + let _deserialized: Call = serde_json::from_str(s).unwrap(); + // TODO: validate all fields + } +} diff --git a/json/src/vm/env.rs b/json/src/vm/env.rs new file mode 100644 index 000000000..547298988 --- /dev/null +++ b/json/src/vm/env.rs @@ -0,0 +1,58 @@ +// Copyright 2015, 2016 Ethcore (UK) Ltd. +// This file is part of Parity. + +// Parity 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 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. If not, see . + +//! Vm environment. +use hash::Address; +use uint::Uint; + +/// Vm environment. +#[derive(Debug, PartialEq, Deserialize)] +pub struct Env { + /// Address. + #[serde(rename="currentCoinbase")] + pub coinbase: Address, + /// Difficulty + #[serde(rename="currentDifficulty")] + pub difficulty: Uint, + /// Gas limit. + #[serde(rename="currentGasLimit")] + pub gas_limit: Uint, + /// Number. + #[serde(rename="currentNumber")] + pub number: Uint, + /// Timestamp. + #[serde(rename="currentTimestamp")] + pub timestamp: Uint, +} + +#[cfg(test)] +mod tests { + use serde_json; + use vm::Env; + + #[test] + fn env_deserialization() { + let s = r#"{ + "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", + "currentDifficulty" : "0x0100", + "currentGasLimit" : "0x0f4240", + "currentNumber" : "0x00", + "currentTimestamp" : "0x01" + }"#; + let _deserialized: Env = serde_json::from_str(s).unwrap(); + // TODO: validate all fields + } +} diff --git a/json/src/vm/log.rs b/json/src/vm/log.rs new file mode 100644 index 000000000..b29325738 --- /dev/null +++ b/json/src/vm/log.rs @@ -0,0 +1,54 @@ +// Copyright 2015, 2016 Ethcore (UK) Ltd. +// This file is part of Parity. + +// Parity 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 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. If not, see . + +//! Vm log deserialization. + +use hash::{Address, H256, Bloom}; +use bytes::Bytes; + +/// Vm log deserialization. +#[derive(Debug, PartialEq, Deserialize)] +pub struct Log { + /// Log address. + pub address: Address, + /// Log bloom. + pub bloom: Bloom, + /// Data. + pub data: Bytes, + /// Topics. + pub topics: Vec, +} + +#[cfg(test)] +mod tests { + use serde_json; + use vm::Log; + + #[test] + fn log_deserialization() { + let s = r#"{ + "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008800000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000800000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000", + "data" : "0xaabbffffffffffffffffffffffffffffffffffffffffffffffffffffffffccdd", + "topics" : [ + "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" + ] + }"#; + let _deserialized: Log = serde_json::from_str(s).unwrap(); + // TODO: validate all fields + } +} + diff --git a/json/src/vm/mod.rs b/json/src/vm/mod.rs new file mode 100644 index 000000000..cc4a9662e --- /dev/null +++ b/json/src/vm/mod.rs @@ -0,0 +1,29 @@ +// Copyright 2015, 2016 Ethcore (UK) Ltd. +// This file is part of Parity. + +// Parity 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 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. If not, see . + +//! Vm test loader. + +pub mod env; +pub mod transaction; +pub mod vm; +pub mod log; +pub mod call; + +pub use self::env::Env; +pub use self::transaction::Transaction; +pub use self::vm::Vm; +pub use self::log::Log; +pub use self::call::Call; diff --git a/json/src/vm/transaction.rs b/json/src/vm/transaction.rs new file mode 100644 index 000000000..d2ee8b89b --- /dev/null +++ b/json/src/vm/transaction.rs @@ -0,0 +1,64 @@ +// Copyright 2015, 2016 Ethcore (UK) Ltd. +// This file is part of Parity. + +// Parity 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 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. If not, see . + +//! Executed transaction. +use hash::Address; +use uint::Uint; +use bytes::Bytes; + +/// Executed transaction. +#[derive(Debug, PartialEq, Deserialize)] +pub struct Transaction { + /// Contract address. + pub address: Address, + /// Transaction sender. + #[serde(rename="caller")] + pub sender: Address, + /// Contract code. + pub code: Bytes, + /// Input data. + pub data: Bytes, + /// Gas. + pub gas: Uint, + /// Gas price. + #[serde(rename="gasPrice")] + pub gas_price: Uint, + /// Transaction origin. + pub origin: Address, + /// Sent value. + pub value: Uint, +} + +#[cfg(test)] +mod tests { + use serde_json; + use vm::Transaction; + + #[test] + fn transaction_deserialization() { + let s = r#"{ + "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", + "caller" : "cd1722f2947def4cf144679da39c4c32bdc35681", + "code" : "0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01600055", + "data" : "0x", + "gas" : "0x0186a0", + "gasPrice" : "0x5af3107a4000", + "origin" : "cd1722f2947def4cf144679da39c4c32bdc35681", + "value" : "0x0de0b6b3a7640000" + }"#; + let _deserialized: Transaction = serde_json::from_str(s).unwrap(); + } +} diff --git a/json/src/vm/vm.rs b/json/src/vm/vm.rs new file mode 100644 index 000000000..8e7a44986 --- /dev/null +++ b/json/src/vm/vm.rs @@ -0,0 +1,101 @@ +// Copyright 2015, 2016 Ethcore (UK) Ltd. +// This file is part of Parity. + +// Parity 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 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. If not, see . + +//! Vm execution env. + +use bytes::Bytes; +use uint::Uint; +use blockchain::State; +use vm::{Transaction, Log, Call}; + +/// Reporesents vm execution environment before and after exeuction of transaction. +#[derive(Debug, PartialEq, Deserialize)] +pub struct Vm { + /// Contract calls made internaly by executed transaction. + #[serde(rename="callcreates")] + pub calls: Option>, + /// Executed transaction + #[serde(rename="exec")] + pub exec: Transaction, + /// Gas. + pub gas: Uint, + /// Logs created during execution of transaction. + pub logs: Vec, + /// Transaction output. + pub out: Bytes, + /// Post execution vm state. + #[serde(rename="post")] + pub post_state: State, + /// Pre execution vm state. + #[serde(rename="pre")] + pub pre_state: State, +} + +#[cfg(test)] +mod tests { + use serde_json; + use vm::Vm; + + #[test] + fn vm_deserialization() { + let s = r#"{ + "callcreates" : [ + ], + "env" : { + "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", + "currentDifficulty" : "0x0100", + "currentGasLimit" : "0x0f4240", + "currentNumber" : "0x00", + "currentTimestamp" : "0x01" + }, + "exec" : { + "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", + "caller" : "cd1722f2947def4cf144679da39c4c32bdc35681", + "code" : "0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01600055", + "data" : "0x", + "gas" : "0x0186a0", + "gasPrice" : "0x5af3107a4000", + "origin" : "cd1722f2947def4cf144679da39c4c32bdc35681", + "value" : "0x0de0b6b3a7640000" + }, + "gas" : "0x013874", + "logs" : [ + ], + "out" : "0x", + "post" : { + "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { + "balance" : "0x0de0b6b3a7640000", + "code" : "0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01600055", + "nonce" : "0x00", + "storage" : { + "0x00" : "0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe" + } + } + }, + "pre" : { + "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { + "balance" : "0x0de0b6b3a7640000", + "code" : "0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01600055", + "nonce" : "0x00", + "storage" : { + } + } + } + }"#; + let _deserialized: Vm = serde_json::from_str(s).unwrap(); + // TODO: validate all fields + } +} From 1aa34e9dd46a53ec024cf84d253a4c9da78ffe8e Mon Sep 17 00:00:00 2001 From: debris Date: Thu, 24 Mar 2016 01:25:59 +0100 Subject: [PATCH 06/22] fixed loading of executive tests, unrevealed failing consensus tests --- ethcore/src/action_params.rs | 17 +++++ ethcore/src/env_info.rs | 16 +++++ ethcore/src/json_tests/chain.rs | 4 +- ethcore/src/json_tests/executive.rs | 103 +++++++++------------------- ethcore/src/pod_account.rs | 2 +- ethcore/src/state_diff.rs | 10 ++- json/src/blockchain/state.rs | 10 +-- json/src/blockchain/test.rs | 10 +-- json/src/hash.rs | 2 +- json/src/lib.rs.in | 1 + json/src/maybe.rs | 83 ++++++++++++++++++++++ json/src/vm/call.rs | 3 +- json/src/vm/env.rs | 2 +- json/src/vm/mod.rs | 2 + json/src/vm/test.rs | 43 ++++++++++++ json/src/vm/vm.rs | 25 +++++-- 16 files changed, 240 insertions(+), 93 deletions(-) create mode 100644 json/src/maybe.rs create mode 100644 json/src/vm/test.rs diff --git a/ethcore/src/action_params.rs b/ethcore/src/action_params.rs index fa40d30a0..2f5aa3340 100644 --- a/ethcore/src/action_params.rs +++ b/ethcore/src/action_params.rs @@ -16,6 +16,7 @@ //! Evm input params. use common::*; +use ethjson; /// Transaction value #[derive(Clone, Debug)] @@ -67,3 +68,19 @@ impl Default for ActionParams { } } } + +impl From for ActionParams { + fn from(t: ethjson::vm::Transaction) -> Self { + ActionParams { + code_address: Address::new(), + address: t.address.into(), + sender: t.sender.into(), + origin: t.origin.into(), + code: Some(t.code.into()), + data: Some(t.data.into()), + gas: t.gas.into(), + gas_price: t.gas_price.into(), + value: ActionValue::Transfer(t.value.into()), + } + } +} diff --git a/ethcore/src/env_info.rs b/ethcore/src/env_info.rs index 02fc5188c..1a4e71c67 100644 --- a/ethcore/src/env_info.rs +++ b/ethcore/src/env_info.rs @@ -16,6 +16,7 @@ use util::*; use header::BlockNumber; +use ethjson; /// Simple vector of hashes, should be at most 256 items large, can be smaller if being used /// for a block whose number is less than 257. @@ -69,6 +70,21 @@ impl FromJson for EnvInfo { } } +impl From for EnvInfo { + fn from(e: ethjson::vm::Env) -> Self { + let number = e.number.into(); + EnvInfo { + number: number, + author: e.author.into(), + difficulty: e.difficulty.into(), + gas_limit: e.gas_limit.into(), + timestamp: e.timestamp.into(), + last_hashes: (1..cmp::min(number + 1, 257)).map(|i| format!("{}", number - i).as_bytes().sha3()).collect(), + gas_used: U256::zero(), + } + } +} + #[cfg(test)] mod tests { extern crate rustc_serialize; diff --git a/ethcore/src/json_tests/chain.rs b/ethcore/src/json_tests/chain.rs index a2e6a5659..a1154f6a9 100644 --- a/ethcore/src/json_tests/chain.rs +++ b/ethcore/src/json_tests/chain.rs @@ -28,7 +28,7 @@ pub fn json_chain_test(json_data: &[u8], era: ChainEra) -> Vec { let tests = ethjson::blockchain::Test::load(json_data).unwrap(); let mut failed = Vec::new(); - for (name, blockchain) in tests.deref() { + for (name, blockchain) in tests.into_iter() { let mut fail = false; { let mut fail_unless = |cond: bool| if !cond && !fail { @@ -61,7 +61,7 @@ pub fn json_chain_test(json_data: &[u8], era: ChainEra) -> Vec { client.import_verified_blocks(&IoChannel::disconnected()); } } - fail_unless(client.chain_info().best_block_hash == blockchain.best_block.clone().into()); + fail_unless(client.chain_info().best_block_hash == blockchain.best_block.into()); } } diff --git a/ethcore/src/json_tests/executive.rs b/ethcore/src/json_tests/executive.rs index dbb9bb6ab..52f4d7981 100644 --- a/ethcore/src/json_tests/executive.rs +++ b/ethcore/src/json_tests/executive.rs @@ -25,6 +25,8 @@ use ethereum; use externalities::*; use substate::*; use tests::helpers::*; +use state_diff::StateDiff; +use ethjson; struct TestEngineFrontier { vm_factory: Factory, @@ -53,6 +55,7 @@ impl Engine for TestEngineFrontier { } } +#[derive(Debug, PartialEq)] struct CallCreate { data: Bytes, destination: Option
, @@ -60,6 +63,18 @@ struct CallCreate { value: U256 } +impl From for CallCreate { + fn from(c: ethjson::vm::Call) -> Self { + let dst: Option<_> = c.destination.into(); + CallCreate { + data: c.data.into(), + destination: dst.map(Into::into), + gas_limit: c.gas_limit.into(), + value: c.value.into() + } + } +} + /// Tiny wrapper around executive externalities. /// Stores callcreates. struct TestExt<'a> { @@ -174,58 +189,26 @@ fn do_json_test(json_data: &[u8]) -> Vec { .collect() } -fn do_json_test_for(vm: &VMType, json_data: &[u8]) -> Vec { - let json = Json::from_str(::std::str::from_utf8(json_data).unwrap()).expect("Json is invalid"); +fn do_json_test_for(vm_type: &VMType, json_data: &[u8]) -> Vec { + let tests = ethjson::vm::Test::load(json_data).unwrap(); let mut failed = Vec::new(); - for (name, test) in json.as_object().unwrap() { + + for (name, vm) in tests.into_iter() { println!("name: {:?}", name); - // sync io is usefull when something crashes in jit - // ::std::io::stdout().write(&name.as_bytes()); - // ::std::io::stdout().write(b"\n"); - // ::std::io::stdout().flush(); let mut fail = false; - //let mut fail_unless = |cond: bool| if !cond && !fail { failed.push(name.to_string()); fail = true }; + let mut fail_unless = |cond: bool, s: &str | if !cond && !fail { - failed.push(format!("[{}] {}: {}", vm, name, s)); + failed.push(format!("[{}] {}: {}", vm_type, name, s)); fail = true }; - // test env + let out_of_gas = vm.out_of_gas(); let mut state_result = get_temp_state(); let mut state = state_result.reference_mut(); - - test.find("pre").map(|pre| for (addr, s) in pre.as_object().unwrap() { - let address = Address::from(addr.as_ref()); - let balance = xjson!(&s["balance"]); - let code = xjson!(&s["code"]); - let _nonce: U256 = xjson!(&s["nonce"]); - - state.new_contract(&address, balance); - state.init_code(&address, code); - BTreeMap::from_json(&s["storage"]).into_iter().foreach(|(k, v)| state.set_storage(&address, k, v)); - }); - - let info = test.find("env").map(|env| { - EnvInfo::from_json(env) - }).unwrap_or_default(); - - let engine = TestEngineFrontier::new(1, vm.clone()); - - // params - let mut params = ActionParams::default(); - test.find("exec").map(|exec| { - params.address = xjson!(&exec["address"]); - params.sender = xjson!(&exec["caller"]); - params.origin = xjson!(&exec["origin"]); - params.code = xjson!(&exec["code"]); - params.data = xjson!(&exec["data"]); - params.gas = xjson!(&exec["gas"]); - params.gas_price = xjson!(&exec["gasPrice"]); - params.value = ActionValue::Transfer(xjson!(&exec["value"])); - }); - - let out_of_gas = test.find("callcreates").map(|_calls| { - }).is_none(); + state.populate_from(From::from(vm.pre_state.clone())); + let info = From::from(vm.env); + let engine = TestEngineFrontier::new(1, vm_type.clone()); + let params = ActionParams::from(vm.transaction); let mut substate = Substate::new(false); let mut output = vec![]; @@ -247,44 +230,26 @@ fn do_json_test_for(vm: &VMType, json_data: &[u8]) -> Vec { (res, ex.callcreates) }; - // then validate match res { Err(_) => fail_unless(out_of_gas, "didn't expect to run out of gas."), Ok(gas_left) => { - // println!("name: {}, gas_left : {:?}", name, gas_left); fail_unless(!out_of_gas, "expected to run out of gas."); - fail_unless(gas_left == xjson!(&test["gas"]), "gas_left is incorrect"); - fail_unless(output == Bytes::from_json(&test["out"]), "output is incorrect"); + fail_unless(Some(gas_left) == vm.gas_left.map(Into::into), "gas_left is incorrect"); + let vm_output: Option> = vm.output.map(Into::into); + fail_unless(Some(output) == vm_output, "output is incorrect"); - test.find("post").map(|pre| for (addr, s) in pre.as_object().unwrap() { - let address = Address::from(addr.as_ref()); - - fail_unless(state.code(&address).unwrap_or_else(|| vec![]) == Bytes::from_json(&s["code"]), "code is incorrect"); - fail_unless(state.balance(&address) == xjson!(&s["balance"]), "balance is incorrect"); - fail_unless(state.nonce(&address) == xjson!(&s["nonce"]), "nonce is incorrect"); - BTreeMap::from_json(&s["storage"]).iter().foreach(|(k, v)| fail_unless(&state.storage_at(&address, &k) == v, "storage is incorrect")); - }); - - let cc = test["callcreates"].as_array().unwrap(); - fail_unless(callcreates.len() == cc.len(), "callcreates does not match"); - for i in 0..cc.len() { - let callcreate = &callcreates[i]; - let expected = &cc[i]; - fail_unless(callcreate.data == Bytes::from_json(&expected["data"]), "callcreates data is incorrect"); - fail_unless(callcreate.destination == xjson!(&expected["destination"]), "callcreates destination is incorrect"); - fail_unless(callcreate.value == xjson!(&expected["value"]), "callcreates value is incorrect"); - fail_unless(callcreate.gas_limit == xjson!(&expected["gasLimit"]), "callcreates gas_limit is incorrect"); - } + let diff = StateDiff::diff_pod(&state.to_pod(), &From::from(vm.post_state.unwrap())); + fail_unless(diff.is_empty(), format!("diff should be empty!: {:?}", diff).as_ref()); + let calls: Option> = vm.calls.map(|c| c.into_iter().map(From::from).collect()); + fail_unless(Some(callcreates) == calls, "callcreates does not match"); } - } + }; } - for f in &failed { println!("FAILED: {:?}", f); } - //assert!(false); failed } diff --git a/ethcore/src/pod_account.rs b/ethcore/src/pod_account.rs index 387679da9..623211ae6 100644 --- a/ethcore/src/pod_account.rs +++ b/ethcore/src/pod_account.rs @@ -19,7 +19,7 @@ use account::*; use account_db::*; use ethjson; -#[derive(Debug,Clone,PartialEq,Eq)] +#[derive(Debug, Clone, PartialEq, Eq)] /// An account, expressed as Plain-Old-Data (hence the name). /// Does not have a DB overlay cache, code hash or anything like that. pub struct PodAccount { diff --git a/ethcore/src/state_diff.rs b/ethcore/src/state_diff.rs index 2f3a0c8c8..6c41d167c 100644 --- a/ethcore/src/state_diff.rs +++ b/ethcore/src/state_diff.rs @@ -20,7 +20,7 @@ use pod_state::*; use account_diff::*; #[derive(Debug,Clone,PartialEq,Eq)] -/// Expression for the delta between two system states. Encoded the +/// Expression for the delta between two system states. Encoded the /// delta of every altered account. pub struct StateDiff (BTreeMap); @@ -41,6 +41,14 @@ impl fmt::Display for StateDiff { } } +impl Deref for StateDiff { + type Target = BTreeMap; + + fn deref(&self) -> &Self::Target { + &self.0 + } +} + #[cfg(test)] mod test { use common::*; diff --git a/json/src/blockchain/state.rs b/json/src/blockchain/state.rs index 51e77e95e..7779bd861 100644 --- a/json/src/blockchain/state.rs +++ b/json/src/blockchain/state.rs @@ -17,7 +17,6 @@ //! Blockchain test state deserializer. use std::collections::BTreeMap; -use std::ops::Deref; use hash::Address; use blockchain::account::Account; @@ -25,10 +24,11 @@ use blockchain::account::Account; #[derive(Debug, PartialEq, Deserialize, Clone)] pub struct State(pub BTreeMap); -impl Deref for State { - type Target = BTreeMap; +impl IntoIterator for State { + type Item = as IntoIterator>::Item; + type IntoIter = as IntoIterator>::IntoIter; - fn deref(&self) -> &Self::Target { - &self.0 + fn into_iter(self) -> Self::IntoIter { + self.0.into_iter() } } diff --git a/json/src/blockchain/test.rs b/json/src/blockchain/test.rs index 1a6a63a71..301d921df 100644 --- a/json/src/blockchain/test.rs +++ b/json/src/blockchain/test.rs @@ -17,7 +17,6 @@ //! Blockchain test deserializer. use std::collections::BTreeMap; -use std::ops::Deref; use std::io::Read; use serde_json; use serde_json::Error; @@ -27,11 +26,12 @@ use blockchain::blockchain::BlockChain; #[derive(Debug, PartialEq, Deserialize)] pub struct Test(BTreeMap); -impl Deref for Test { - type Target = BTreeMap; +impl IntoIterator for Test { + type Item = as IntoIterator>::Item; + type IntoIter = as IntoIterator>::IntoIter; - fn deref(&self) -> &Self::Target { - &self.0 + fn into_iter(self) -> Self::IntoIter { + self.0.into_iter() } } diff --git a/json/src/hash.rs b/json/src/hash.rs index c555b6266..ad546fcab 100644 --- a/json/src/hash.rs +++ b/json/src/hash.rs @@ -26,7 +26,7 @@ macro_rules! impl_hash { ($name: ident, $inner: ident) => { /// Lenient hash json deserialization for test json files. #[derive(Default, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, Clone)] - pub struct $name($inner); + pub struct $name(pub $inner); impl Into<$inner> for $name { fn into(self) -> $inner { diff --git a/json/src/lib.rs.in b/json/src/lib.rs.in index 20e7e35da..aff685cb7 100644 --- a/json/src/lib.rs.in +++ b/json/src/lib.rs.in @@ -25,3 +25,4 @@ pub mod bytes; pub mod blockchain; pub mod spec; pub mod vm; +pub mod maybe; diff --git a/json/src/maybe.rs b/json/src/maybe.rs new file mode 100644 index 000000000..dd4d5d821 --- /dev/null +++ b/json/src/maybe.rs @@ -0,0 +1,83 @@ + +//! Deserializer of empty string values into optionals. + +use std::marker::PhantomData; +use serde::{Deserialize, Deserializer, Error}; +use serde::de::Visitor; +use serde_json::Value; +use serde_json::value; + +/// Deserializer of empty string values into optionals. +#[derive(Debug, PartialEq)] +pub enum MaybeEmpty { + /// Some. + Some(T), + /// None. + None, +} + +impl Deserialize for MaybeEmpty where T: Deserialize { + fn deserialize(deserializer: &mut D) -> Result + where D: Deserializer { + deserializer.deserialize(MaybeEmptyVisitor::new()) + } +} + +struct MaybeEmptyVisitor { + _phantom: PhantomData +} + +impl MaybeEmptyVisitor { + fn new() -> Self { + MaybeEmptyVisitor { + _phantom: PhantomData + } + } +} + +impl Visitor for MaybeEmptyVisitor where T: Deserialize { + type Value = MaybeEmpty; + + fn visit_str(&mut self, value: &str) -> Result where E: Error { + self.visit_string(value.to_owned()) + } + + fn visit_string(&mut self, value: String) -> Result where E: Error { + match value.is_empty() { + true => Ok(MaybeEmpty::None), + false => { + let value = Value::String(value); + T::deserialize(&mut value::Deserializer::new(value)).map(MaybeEmpty::Some).map_err(|_| Error::custom("failed")) + } + } + } +} + +impl Into> for MaybeEmpty { + fn into(self) -> Option { + match self { + MaybeEmpty::Some(s) => Some(s), + MaybeEmpty::None => None + } + } +} + +#[cfg(test)] +mod tests { + use std::str::FromStr; + use serde_json; + use util::hash; + use hash::H256; + use maybe::MaybeEmpty; + + #[test] + fn maybe_deserialization() { + let s = r#"["", "5a39ed1020c04d4d84539975b893a4e7c53eab6c2965db8bc3468093a31bc5ae"]"#; + let deserialized: Vec> = serde_json::from_str(s).unwrap(); + assert_eq!(deserialized, vec![ + MaybeEmpty::None, + MaybeEmpty::Some(H256(hash::H256::from_str("5a39ed1020c04d4d84539975b893a4e7c53eab6c2965db8bc3468093a31bc5ae").unwrap())) + ]); + } + +} diff --git a/json/src/vm/call.rs b/json/src/vm/call.rs index ca955c7bd..2fe6265aa 100644 --- a/json/src/vm/call.rs +++ b/json/src/vm/call.rs @@ -19,6 +19,7 @@ use bytes::Bytes; use hash::Address; use uint::Uint; +use maybe::MaybeEmpty; /// Vm call deserialization. #[derive(Debug, PartialEq, Deserialize)] @@ -26,7 +27,7 @@ pub struct Call { /// Call data. pub data: Bytes, /// Call destination. - pub destination: Address, + pub destination: MaybeEmpty
, /// Gas limit. #[serde(rename="gasLimit")] pub gas_limit: Uint, diff --git a/json/src/vm/env.rs b/json/src/vm/env.rs index 547298988..95365c0a8 100644 --- a/json/src/vm/env.rs +++ b/json/src/vm/env.rs @@ -23,7 +23,7 @@ use uint::Uint; pub struct Env { /// Address. #[serde(rename="currentCoinbase")] - pub coinbase: Address, + pub author: Address, /// Difficulty #[serde(rename="currentDifficulty")] pub difficulty: Uint, diff --git a/json/src/vm/mod.rs b/json/src/vm/mod.rs index cc4a9662e..ecc0d05a4 100644 --- a/json/src/vm/mod.rs +++ b/json/src/vm/mod.rs @@ -21,9 +21,11 @@ pub mod transaction; pub mod vm; pub mod log; pub mod call; +pub mod test; pub use self::env::Env; pub use self::transaction::Transaction; pub use self::vm::Vm; pub use self::log::Log; pub use self::call::Call; +pub use self::test::Test; diff --git a/json/src/vm/test.rs b/json/src/vm/test.rs new file mode 100644 index 000000000..e348826e1 --- /dev/null +++ b/json/src/vm/test.rs @@ -0,0 +1,43 @@ +// Copyright 2015, 2016 Ethcore (UK) Ltd. +// This file is part of Parity. + +// Parity 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 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. If not, see . + +//! Vm test deserializer. + +use std::collections::BTreeMap; +use std::io::Read; +use serde_json; +use serde_json::Error; +use vm::Vm; + +/// Vm test deserializer. +#[derive(Debug, PartialEq, Deserialize)] +pub struct Test(BTreeMap); + +impl IntoIterator for Test { + type Item = as IntoIterator>::Item; + type IntoIter = as IntoIterator>::IntoIter; + + fn into_iter(self) -> Self::IntoIter { + self.0.into_iter() + } +} + +impl Test { + /// Loads test from json. + pub fn load(reader: R) -> Result where R: Read { + serde_json::from_reader(reader) + } +} diff --git a/json/src/vm/vm.rs b/json/src/vm/vm.rs index 8e7a44986..b0a7c2a4b 100644 --- a/json/src/vm/vm.rs +++ b/json/src/vm/vm.rs @@ -19,7 +19,7 @@ use bytes::Bytes; use uint::Uint; use blockchain::State; -use vm::{Transaction, Log, Call}; +use vm::{Transaction, Log, Call, Env}; /// Reporesents vm execution environment before and after exeuction of transaction. #[derive(Debug, PartialEq, Deserialize)] @@ -27,23 +27,34 @@ pub struct Vm { /// Contract calls made internaly by executed transaction. #[serde(rename="callcreates")] pub calls: Option>, + /// Env info. + pub env: Env, /// Executed transaction #[serde(rename="exec")] - pub exec: Transaction, - /// Gas. - pub gas: Uint, + pub transaction: Transaction, + /// Gas left after transaction execution. + #[serde(rename="gas")] + pub gas_left: Option, /// Logs created during execution of transaction. - pub logs: Vec, + pub logs: Option>, /// Transaction output. - pub out: Bytes, + #[serde(rename="out")] + pub output: Option, /// Post execution vm state. #[serde(rename="post")] - pub post_state: State, + pub post_state: Option, /// Pre execution vm state. #[serde(rename="pre")] pub pre_state: State, } +impl Vm { + /// Returns true if transaction execution run out of gas. + pub fn out_of_gas(&self) -> bool { + self.calls.is_none() + } +} + #[cfg(test)] mod tests { use serde_json; From bc03040b0f246f154aa5c3f8167ee582ae3573eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Thu, 24 Mar 2016 11:50:33 +0100 Subject: [PATCH 07/22] Removing ethash sizes --- ethash/src/sizes.rs | 790 -------------------------------------------- 1 file changed, 790 deletions(-) delete mode 100644 ethash/src/sizes.rs diff --git a/ethash/src/sizes.rs b/ethash/src/sizes.rs deleted file mode 100644 index adb3f992b..000000000 --- a/ethash/src/sizes.rs +++ /dev/null @@ -1,790 +0,0 @@ -// Copyright 2015, 2016 Ethcore (UK) Ltd. -// This file is part of Parity. - -// Parity 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 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. If not, see . - -// 2048 Epochs (~20 years) worth of tabulated DAG sizes - -// Generated with the following Mathematica Code: - -// GetCacheSizes[n_] := Module[{ -// CacheSizeBytesInit = 2^24, -// CacheGrowth = 2^17, -// HashBytes = 64, -// j = 0}, -// Reap[ -// While[j < n, -// Module[{i = -// Floor[(CacheSizeBytesInit + CacheGrowth * j) / HashBytes]}, -// While[! PrimeQ[i], i--]; -// Sow[i*HashBytes]; j++]]]][[2]][[1]] -#[cfg_attr(rustfmt, rustfmt_skip)] -pub const DAG_SIZES: [u64; 2048] = [ - 1073739904u64, 1082130304u64, 1090514816u64, 1098906752u64, 1107293056u64, - 1115684224u64, 1124070016u64, 1132461952u64, 1140849536u64, 1149232768u64, - 1157627776u64, 1166013824u64, 1174404736u64, 1182786944u64, 1191180416u64, - 1199568512u64, 1207958912u64, 1216345216u64, 1224732032u64, 1233124736u64, - 1241513344u64, 1249902464u64, 1258290304u64, 1266673792u64, 1275067264u64, - 1283453312u64, 1291844992u64, 1300234112u64, 1308619904u64, 1317010048u64, - 1325397376u64, 1333787776u64, 1342176128u64, 1350561664u64, 1358954368u64, - 1367339392u64, 1375731584u64, 1384118144u64, 1392507008u64, 1400897408u64, - 1409284736u64, 1417673344u64, 1426062464u64, 1434451072u64, 1442839168u64, - 1451229056u64, 1459615616u64, 1468006016u64, 1476394112u64, 1484782976u64, - 1493171584u64, 1501559168u64, 1509948032u64, 1518337664u64, 1526726528u64, - 1535114624u64, 1543503488u64, 1551892096u64, 1560278656u64, 1568669056u64, - 1577056384u64, 1585446272u64, 1593831296u64, 1602219392u64, 1610610304u64, - 1619000192u64, 1627386752u64, 1635773824u64, 1644164224u64, 1652555648u64, - 1660943488u64, 1669332608u64, 1677721216u64, 1686109312u64, 1694497664u64, - 1702886272u64, 1711274624u64, 1719661184u64, 1728047744u64, 1736434816u64, - 1744829056u64, 1753218944u64, 1761606272u64, 1769995904u64, 1778382464u64, - 1786772864u64, 1795157888u64, 1803550592u64, 1811937664u64, 1820327552u64, - 1828711552u64, 1837102976u64, 1845488768u64, 1853879936u64, 1862269312u64, - 1870656896u64, 1879048064u64, 1887431552u64, 1895825024u64, 1904212096u64, - 1912601216u64, 1920988544u64, 1929379456u64, 1937765504u64, 1946156672u64, - 1954543232u64, 1962932096u64, 1971321728u64, 1979707264u64, 1988093056u64, - 1996487552u64, 2004874624u64, 2013262208u64, 2021653888u64, 2030039936u64, - 2038430848u64, 2046819968u64, 2055208576u64, 2063596672u64, 2071981952u64, - 2080373632u64, 2088762752u64, 2097149056u64, 2105539712u64, 2113928576u64, - 2122315136u64, 2130700672u64, 2139092608u64, 2147483264u64, 2155872128u64, - 2164257664u64, 2172642176u64, 2181035392u64, 2189426048u64, 2197814912u64, - 2206203008u64, 2214587264u64, 2222979712u64, 2231367808u64, 2239758208u64, - 2248145024u64, 2256527744u64, 2264922752u64, 2273312128u64, 2281701248u64, - 2290086272u64, 2298476672u64, 2306867072u64, 2315251072u64, 2323639168u64, - 2332032128u64, 2340420224u64, 2348808064u64, 2357196416u64, 2365580416u64, - 2373966976u64, 2382363008u64, 2390748544u64, 2399139968u64, 2407530368u64, - 2415918976u64, 2424307328u64, 2432695424u64, 2441084288u64, 2449472384u64, - 2457861248u64, 2466247808u64, 2474637184u64, 2483026816u64, 2491414144u64, - 2499803776u64, 2508191872u64, 2516582272u64, 2524970368u64, 2533359232u64, - 2541743488u64, 2550134144u64, 2558525056u64, 2566913408u64, 2575301504u64, - 2583686528u64, 2592073856u64, 2600467328u64, 2608856192u64, 2617240448u64, - 2625631616u64, 2634022016u64, 2642407552u64, 2650796416u64, 2659188352u64, - 2667574912u64, 2675965312u64, 2684352896u64, 2692738688u64, 2701130624u64, - 2709518464u64, 2717907328u64, 2726293376u64, 2734685056u64, 2743073152u64, - 2751462016u64, 2759851648u64, 2768232832u64, 2776625536u64, 2785017728u64, - 2793401984u64, 2801794432u64, 2810182016u64, 2818571648u64, 2826959488u64, - 2835349376u64, 2843734144u64, 2852121472u64, 2860514432u64, 2868900992u64, - 2877286784u64, 2885676928u64, 2894069632u64, 2902451584u64, 2910843008u64, - 2919234688u64, 2927622784u64, 2936011648u64, 2944400768u64, 2952789376u64, - 2961177728u64, 2969565568u64, 2977951616u64, 2986338944u64, 2994731392u64, - 3003120256u64, 3011508352u64, 3019895936u64, 3028287104u64, 3036675968u64, - 3045063808u64, 3053452928u64, 3061837696u64, 3070228352u64, 3078615424u64, - 3087003776u64, 3095394944u64, 3103782272u64, 3112173184u64, 3120562048u64, - 3128944768u64, 3137339264u64, 3145725056u64, 3154109312u64, 3162505088u64, - 3170893184u64, 3179280256u64, 3187669376u64, 3196056704u64, 3204445568u64, - 3212836736u64, 3221224064u64, 3229612928u64, 3238002304u64, 3246391168u64, - 3254778496u64, 3263165824u64, 3271556224u64, 3279944576u64, 3288332416u64, - 3296719232u64, 3305110912u64, 3313500032u64, 3321887104u64, 3330273152u64, - 3338658944u64, 3347053184u64, 3355440512u64, 3363827072u64, 3372220288u64, - 3380608384u64, 3388997504u64, 3397384576u64, 3405774208u64, 3414163072u64, - 3422551936u64, 3430937984u64, 3439328384u64, 3447714176u64, 3456104576u64, - 3464493952u64, 3472883584u64, 3481268864u64, 3489655168u64, 3498048896u64, - 3506434432u64, 3514826368u64, 3523213952u64, 3531603584u64, 3539987072u64, - 3548380288u64, 3556763264u64, 3565157248u64, 3573545344u64, 3581934464u64, - 3590324096u64, 3598712704u64, 3607098752u64, 3615488384u64, 3623877248u64, - 3632265856u64, 3640646528u64, 3649043584u64, 3657430144u64, 3665821568u64, - 3674207872u64, 3682597504u64, 3690984832u64, 3699367808u64, 3707764352u64, - 3716152448u64, 3724541056u64, 3732925568u64, 3741318016u64, 3749706368u64, - 3758091136u64, 3766481536u64, 3774872704u64, 3783260032u64, 3791650432u64, - 3800036224u64, 3808427648u64, 3816815488u64, 3825204608u64, 3833592704u64, - 3841981568u64, 3850370432u64, 3858755968u64, 3867147904u64, 3875536256u64, - 3883920512u64, 3892313728u64, 3900702592u64, 3909087872u64, 3917478784u64, - 3925868416u64, 3934256512u64, 3942645376u64, 3951032192u64, 3959422336u64, - 3967809152u64, 3976200064u64, 3984588416u64, 3992974976u64, 4001363584u64, - 4009751168u64, 4018141312u64, 4026530432u64, 4034911616u64, 4043308928u64, - 4051695488u64, 4060084352u64, 4068472448u64, 4076862848u64, 4085249408u64, - 4093640576u64, 4102028416u64, 4110413696u64, 4118805632u64, 4127194496u64, - 4135583104u64, 4143971968u64, 4152360832u64, 4160746112u64, 4169135744u64, - 4177525888u64, 4185912704u64, 4194303616u64, 4202691968u64, 4211076736u64, - 4219463552u64, 4227855488u64, 4236246656u64, 4244633728u64, 4253022848u64, - 4261412224u64, 4269799808u64, 4278184832u64, 4286578048u64, 4294962304u64, - 4303349632u64, 4311743104u64, 4320130432u64, 4328521088u64, 4336909184u64, - 4345295488u64, 4353687424u64, 4362073472u64, 4370458496u64, 4378852736u64, - 4387238528u64, 4395630208u64, 4404019072u64, 4412407424u64, 4420790656u64, - 4429182848u64, 4437571456u64, 4445962112u64, 4454344064u64, 4462738048u64, - 4471119232u64, 4479516544u64, 4487904128u64, 4496289664u64, 4504682368u64, - 4513068416u64, 4521459584u64, 4529846144u64, 4538232704u64, 4546619776u64, - 4555010176u64, 4563402112u64, 4571790208u64, 4580174464u64, 4588567936u64, - 4596957056u64, 4605344896u64, 4613734016u64, 4622119808u64, 4630511488u64, - 4638898816u64, 4647287936u64, 4655675264u64, 4664065664u64, 4672451968u64, - 4680842624u64, 4689231488u64, 4697620352u64, 4706007424u64, 4714397056u64, - 4722786176u64, 4731173248u64, 4739562368u64, 4747951744u64, 4756340608u64, - 4764727936u64, 4773114496u64, 4781504384u64, 4789894784u64, 4798283648u64, - 4806667648u64, 4815059584u64, 4823449472u64, 4831835776u64, 4840226176u64, - 4848612224u64, 4857003392u64, 4865391488u64, 4873780096u64, 4882169728u64, - 4890557312u64, 4898946944u64, 4907333248u64, 4915722368u64, 4924110976u64, - 4932499328u64, 4940889728u64, 4949276032u64, 4957666432u64, 4966054784u64, - 4974438016u64, 4982831488u64, 4991221376u64, 4999607168u64, 5007998848u64, - 5016386432u64, 5024763776u64, 5033164672u64, 5041544576u64, 5049941888u64, - 5058329728u64, 5066717056u64, 5075107456u64, 5083494272u64, 5091883904u64, - 5100273536u64, 5108662144u64, 5117048192u64, 5125436032u64, 5133827456u64, - 5142215296u64, 5150605184u64, 5158993024u64, 5167382144u64, 5175769472u64, - 5184157568u64, 5192543872u64, 5200936064u64, 5209324928u64, 5217711232u64, - 5226102656u64, 5234490496u64, 5242877312u64, 5251263872u64, 5259654016u64, - 5268040832u64, 5276434304u64, 5284819328u64, 5293209728u64, 5301598592u64, - 5309986688u64, 5318374784u64, 5326764416u64, 5335151488u64, 5343542144u64, - 5351929472u64, 5360319872u64, 5368706944u64, 5377096576u64, 5385484928u64, - 5393871232u64, 5402263424u64, 5410650496u64, 5419040384u64, 5427426944u64, - 5435816576u64, 5444205952u64, 5452594816u64, 5460981376u64, 5469367936u64, - 5477760896u64, 5486148736u64, 5494536832u64, 5502925952u64, 5511315328u64, - 5519703424u64, 5528089984u64, 5536481152u64, 5544869504u64, 5553256064u64, - 5561645696u64, 5570032768u64, 5578423936u64, 5586811264u64, 5595193216u64, - 5603585408u64, 5611972736u64, 5620366208u64, 5628750464u64, 5637143936u64, - 5645528192u64, 5653921408u64, 5662310272u64, 5670694784u64, 5679082624u64, - 5687474048u64, 5695864448u64, 5704251008u64, 5712641408u64, 5721030272u64, - 5729416832u64, 5737806208u64, 5746194304u64, 5754583936u64, 5762969984u64, - 5771358592u64, 5779748224u64, 5788137856u64, 5796527488u64, 5804911232u64, - 5813300608u64, 5821692544u64, 5830082176u64, 5838468992u64, 5846855552u64, - 5855247488u64, 5863636096u64, 5872024448u64, 5880411008u64, 5888799872u64, - 5897186432u64, 5905576832u64, 5913966976u64, 5922352768u64, 5930744704u64, - 5939132288u64, 5947522432u64, 5955911296u64, 5964299392u64, 5972688256u64, - 5981074304u64, 5989465472u64, 5997851008u64, 6006241408u64, 6014627968u64, - 6023015552u64, 6031408256u64, 6039796096u64, 6048185216u64, 6056574848u64, - 6064963456u64, 6073351808u64, 6081736064u64, 6090128768u64, 6098517632u64, - 6106906496u64, 6115289216u64, 6123680896u64, 6132070016u64, 6140459648u64, - 6148849024u64, 6157237376u64, 6165624704u64, 6174009728u64, 6182403712u64, - 6190792064u64, 6199176064u64, 6207569792u64, 6215952256u64, 6224345216u64, - 6232732544u64, 6241124224u64, 6249510272u64, 6257899136u64, 6266287744u64, - 6274676864u64, 6283065728u64, 6291454336u64, 6299843456u64, 6308232064u64, - 6316620928u64, 6325006208u64, 6333395584u64, 6341784704u64, 6350174848u64, - 6358562176u64, 6366951296u64, 6375337856u64, 6383729536u64, 6392119168u64, - 6400504192u64, 6408895616u64, 6417283456u64, 6425673344u64, 6434059136u64, - 6442444672u64, 6450837376u64, 6459223424u64, 6467613056u64, 6476004224u64, - 6484393088u64, 6492781952u64, 6501170048u64, 6509555072u64, 6517947008u64, - 6526336384u64, 6534725504u64, 6543112832u64, 6551500672u64, 6559888768u64, - 6568278656u64, 6576662912u64, 6585055616u64, 6593443456u64, 6601834112u64, - 6610219648u64, 6618610304u64, 6626999168u64, 6635385472u64, 6643777408u64, - 6652164224u64, 6660552832u64, 6668941952u64, 6677330048u64, 6685719424u64, - 6694107776u64, 6702493568u64, 6710882176u64, 6719274112u64, 6727662976u64, - 6736052096u64, 6744437632u64, 6752825984u64, 6761213824u64, 6769604224u64, - 6777993856u64, 6786383488u64, 6794770816u64, 6803158144u64, 6811549312u64, - 6819937664u64, 6828326528u64, 6836706176u64, 6845101696u64, 6853491328u64, - 6861880448u64, 6870269312u64, 6878655104u64, 6887046272u64, 6895433344u64, - 6903822208u64, 6912212864u64, 6920596864u64, 6928988288u64, 6937377152u64, - 6945764992u64, 6954149248u64, 6962544256u64, 6970928768u64, 6979317376u64, - 6987709312u64, 6996093824u64, 7004487296u64, 7012875392u64, 7021258624u64, - 7029652352u64, 7038038912u64, 7046427776u64, 7054818944u64, 7063207808u64, - 7071595136u64, 7079980928u64, 7088372608u64, 7096759424u64, 7105149824u64, - 7113536896u64, 7121928064u64, 7130315392u64, 7138699648u64, 7147092352u64, - 7155479168u64, 7163865728u64, 7172249984u64, 7180648064u64, 7189036672u64, - 7197424768u64, 7205810816u64, 7214196608u64, 7222589824u64, 7230975104u64, - 7239367552u64, 7247755904u64, 7256145536u64, 7264533376u64, 7272921472u64, - 7281308032u64, 7289694848u64, 7298088832u64, 7306471808u64, 7314864512u64, - 7323253888u64, 7331643008u64, 7340029568u64, 7348419712u64, 7356808832u64, - 7365196672u64, 7373585792u64, 7381973888u64, 7390362752u64, 7398750592u64, - 7407138944u64, 7415528576u64, 7423915648u64, 7432302208u64, 7440690304u64, - 7449080192u64, 7457472128u64, 7465860992u64, 7474249088u64, 7482635648u64, - 7491023744u64, 7499412608u64, 7507803008u64, 7516192384u64, 7524579968u64, - 7532967296u64, 7541358464u64, 7549745792u64, 7558134656u64, 7566524032u64, - 7574912896u64, 7583300992u64, 7591690112u64, 7600075136u64, 7608466816u64, - 7616854912u64, 7625244544u64, 7633629824u64, 7642020992u64, 7650410368u64, - 7658794112u64, 7667187328u64, 7675574912u64, 7683961984u64, 7692349568u64, - 7700739712u64, 7709130368u64, 7717519232u64, 7725905536u64, 7734295424u64, - 7742683264u64, 7751069056u64, 7759457408u64, 7767849088u64, 7776238208u64, - 7784626816u64, 7793014912u64, 7801405312u64, 7809792128u64, 7818179968u64, - 7826571136u64, 7834957184u64, 7843347328u64, 7851732352u64, 7860124544u64, - 7868512384u64, 7876902016u64, 7885287808u64, 7893679744u64, 7902067072u64, - 7910455936u64, 7918844288u64, 7927230848u64, 7935622784u64, 7944009344u64, - 7952400256u64, 7960786048u64, 7969176704u64, 7977565312u64, 7985953408u64, - 7994339968u64, 8002730368u64, 8011119488u64, 8019508096u64, 8027896192u64, - 8036285056u64, 8044674688u64, 8053062272u64, 8061448832u64, 8069838464u64, - 8078227328u64, 8086616704u64, 8095006592u64, 8103393664u64, 8111783552u64, - 8120171392u64, 8128560256u64, 8136949376u64, 8145336704u64, 8153726848u64, - 8162114944u64, 8170503296u64, 8178891904u64, 8187280768u64, 8195669632u64, - 8204058496u64, 8212444544u64, 8220834176u64, 8229222272u64, 8237612672u64, - 8246000768u64, 8254389376u64, 8262775168u64, 8271167104u64, 8279553664u64, - 8287944064u64, 8296333184u64, 8304715136u64, 8313108352u64, 8321497984u64, - 8329885568u64, 8338274432u64, 8346663296u64, 8355052928u64, 8363441536u64, - 8371828352u64, 8380217984u64, 8388606592u64, 8396996224u64, 8405384576u64, - 8413772672u64, 8422161536u64, 8430549376u64, 8438939008u64, 8447326592u64, - 8455715456u64, 8464104832u64, 8472492928u64, 8480882048u64, 8489270656u64, - 8497659776u64, 8506045312u64, 8514434944u64, 8522823808u64, 8531208832u64, - 8539602304u64, 8547990656u64, 8556378752u64, 8564768384u64, 8573154176u64, - 8581542784u64, 8589933952u64, 8598322816u64, 8606705024u64, 8615099264u64, - 8623487872u64, 8631876992u64, 8640264064u64, 8648653952u64, 8657040256u64, - 8665430656u64, 8673820544u64, 8682209152u64, 8690592128u64, 8698977152u64, - 8707374464u64, 8715763328u64, 8724151424u64, 8732540032u64, 8740928384u64, - 8749315712u64, 8757704576u64, 8766089344u64, 8774480768u64, 8782871936u64, - 8791260032u64, 8799645824u64, 8808034432u64, 8816426368u64, 8824812928u64, - 8833199488u64, 8841591424u64, 8849976448u64, 8858366336u64, 8866757248u64, - 8875147136u64, 8883532928u64, 8891923328u64, 8900306816u64, 8908700288u64, - 8917088384u64, 8925478784u64, 8933867392u64, 8942250368u64, 8950644608u64, - 8959032704u64, 8967420544u64, 8975809664u64, 8984197504u64, 8992584064u64, - 9000976256u64, 9009362048u64, 9017752448u64, 9026141312u64, 9034530688u64, - 9042917504u64, 9051307904u64, 9059694208u64, 9068084864u64, 9076471424u64, - 9084861824u64, 9093250688u64, 9101638528u64, 9110027648u64, 9118416512u64, - 9126803584u64, 9135188096u64, 9143581312u64, 9151969664u64, 9160356224u64, - 9168747136u64, 9177134464u64, 9185525632u64, 9193910144u64, 9202302848u64, - 9210690688u64, 9219079552u64, 9227465344u64, 9235854464u64, 9244244864u64, - 9252633472u64, 9261021824u64, 9269411456u64, 9277799296u64, 9286188928u64, - 9294574208u64, 9302965888u64, 9311351936u64, 9319740032u64, 9328131968u64, - 9336516736u64, 9344907392u64, 9353296768u64, 9361685888u64, 9370074752u64, - 9378463616u64, 9386849408u64, 9395239808u64, 9403629184u64, 9412016512u64, - 9420405376u64, 9428795008u64, 9437181568u64, 9445570688u64, 9453960832u64, - 9462346624u64, 9470738048u64, 9479121536u64, 9487515008u64, 9495903616u64, - 9504289664u64, 9512678528u64, 9521067904u64, 9529456256u64, 9537843584u64, - 9546233728u64, 9554621312u64, 9563011456u64, 9571398784u64, 9579788672u64, - 9588178304u64, 9596567168u64, 9604954496u64, 9613343104u64, 9621732992u64, - 9630121856u64, 9638508416u64, 9646898816u64, 9655283584u64, 9663675776u64, - 9672061312u64, 9680449664u64, 9688840064u64, 9697230464u64, 9705617536u64, - 9714003584u64, 9722393984u64, 9730772608u64, 9739172224u64, 9747561088u64, - 9755945344u64, 9764338816u64, 9772726144u64, 9781116544u64, 9789503872u64, - 9797892992u64, 9806282624u64, 9814670464u64, 9823056512u64, 9831439232u64, - 9839833984u64, 9848224384u64, 9856613504u64, 9865000576u64, 9873391232u64, - 9881772416u64, 9890162816u64, 9898556288u64, 9906940544u64, 9915333248u64, - 9923721088u64, 9932108672u64, 9940496512u64, 9948888448u64, 9957276544u64, - 9965666176u64, 9974048384u64, 9982441088u64, 9990830464u64, 9999219584u64, - 10007602816u64, 10015996544u64, 10024385152u64, 10032774016u64, 10041163648u64, - 10049548928u64, 10057940096u64, 10066329472u64, 10074717824u64, 10083105152u64, - 10091495296u64, 10099878784u64, 10108272256u64, 10116660608u64, 10125049216u64, - 10133437312u64, 10141825664u64, 10150213504u64, 10158601088u64, 10166991232u64, - 10175378816u64, 10183766144u64, 10192157312u64, 10200545408u64, 10208935552u64, - 10217322112u64, 10225712768u64, 10234099328u64, 10242489472u64, 10250876032u64, - 10259264896u64, 10267656064u64, 10276042624u64, 10284429184u64, 10292820352u64, - 10301209472u64, 10309598848u64, 10317987712u64, 10326375296u64, 10334763392u64, - 10343153536u64, 10351541632u64, 10359930752u64, 10368318592u64, 10376707456u64, - 10385096576u64, 10393484672u64, 10401867136u64, 10410262144u64, 10418647424u64, - 10427039104u64, 10435425664u64, 10443810176u64, 10452203648u64, 10460589952u64, - 10468982144u64, 10477369472u64, 10485759104u64, 10494147712u64, 10502533504u64, - 10510923392u64, 10519313536u64, 10527702656u64, 10536091264u64, 10544478592u64, - 10552867712u64, 10561255808u64, 10569642368u64, 10578032768u64, 10586423168u64, - 10594805632u64, 10603200128u64, 10611588992u64, 10619976064u64, 10628361344u64, - 10636754048u64, 10645143424u64, 10653531776u64, 10661920384u64, 10670307968u64, - 10678696832u64, 10687086464u64, 10695475072u64, 10703863168u64, 10712246144u64, - 10720639616u64, 10729026688u64, 10737414784u64, 10745806208u64, 10754190976u64, - 10762581376u64, 10770971264u64, 10779356288u64, 10787747456u64, 10796135552u64, - 10804525184u64, 10812915584u64, 10821301888u64, 10829692288u64, 10838078336u64, - 10846469248u64, 10854858368u64, 10863247232u64, 10871631488u64, 10880023424u64, - 10888412032u64, 10896799616u64, 10905188992u64, 10913574016u64, 10921964672u64, - 10930352768u64, 10938742912u64, 10947132544u64, 10955518592u64, 10963909504u64, - 10972298368u64, 10980687488u64, 10989074816u64, 10997462912u64, 11005851776u64, - 11014241152u64, 11022627712u64, 11031017344u64, 11039403904u64, 11047793024u64, - 11056184704u64, 11064570752u64, 11072960896u64, 11081343872u64, 11089737856u64, - 11098128256u64, 11106514816u64, 11114904448u64, 11123293568u64, 11131680128u64, - 11140065152u64, 11148458368u64, 11156845696u64, 11165236864u64, 11173624192u64, - 11182013824u64, 11190402688u64, 11198790784u64, 11207179136u64, 11215568768u64, - 11223957376u64, 11232345728u64, 11240734592u64, 11249122688u64, 11257511296u64, - 11265899648u64, 11274285952u64, 11282675584u64, 11291065472u64, 11299452544u64, - 11307842432u64, 11316231296u64, 11324616832u64, 11333009024u64, 11341395584u64, - 11349782656u64, 11358172288u64, 11366560384u64, 11374950016u64, 11383339648u64, - 11391721856u64, 11400117376u64, 11408504192u64, 11416893568u64, 11425283456u64, - 11433671552u64, 11442061184u64, 11450444672u64, 11458837888u64, 11467226752u64, - 11475611776u64, 11484003968u64, 11492392064u64, 11500780672u64, 11509169024u64, - 11517550976u64, 11525944448u64, 11534335616u64, 11542724224u64, 11551111808u64, - 11559500672u64, 11567890304u64, 11576277376u64, 11584667008u64, 11593056128u64, - 11601443456u64, 11609830016u64, 11618221952u64, 11626607488u64, 11634995072u64, - 11643387776u64, 11651775104u64, 11660161664u64, 11668552576u64, 11676940928u64, - 11685330304u64, 11693718656u64, 11702106496u64, 11710496128u64, 11718882688u64, - 11727273088u64, 11735660416u64, 11744050048u64, 11752437376u64, 11760824704u64, - 11769216128u64, 11777604736u64, 11785991296u64, 11794381952u64, 11802770048u64, - 11811157888u64, 11819548544u64, 11827932544u64, 11836324736u64, 11844713344u64, - 11853100928u64, 11861486464u64, 11869879936u64, 11878268032u64, 11886656896u64, - 11895044992u64, 11903433088u64, 11911822976u64, 11920210816u64, 11928600448u64, - 11936987264u64, 11945375872u64, 11953761152u64, 11962151296u64, 11970543488u64, - 11978928512u64, 11987320448u64, 11995708288u64, 12004095104u64, 12012486272u64, - 12020875136u64, 12029255552u64, 12037652096u64, 12046039168u64, 12054429568u64, - 12062813824u64, 12071206528u64, 12079594624u64, 12087983744u64, 12096371072u64, - 12104759936u64, 12113147264u64, 12121534592u64, 12129924992u64, 12138314624u64, - 12146703232u64, 12155091584u64, 12163481216u64, 12171864704u64, 12180255872u64, - 12188643968u64, 12197034112u64, 12205424512u64, 12213811328u64, 12222199424u64, - 12230590336u64, 12238977664u64, 12247365248u64, 12255755392u64, 12264143488u64, - 12272531584u64, 12280920448u64, 12289309568u64, 12297694592u64, 12306086528u64, - 12314475392u64, 12322865024u64, 12331253632u64, 12339640448u64, 12348029312u64, - 12356418944u64, 12364805248u64, 12373196672u64, 12381580928u64, 12389969024u64, - 12398357632u64, 12406750592u64, 12415138432u64, 12423527552u64, 12431916416u64, - 12440304512u64, 12448692352u64, 12457081216u64, 12465467776u64, 12473859968u64, - 12482245504u64, 12490636672u64, 12499025536u64, 12507411584u64, 12515801728u64, - 12524190592u64, 12532577152u64, 12540966272u64, 12549354368u64, 12557743232u64, - 12566129536u64, 12574523264u64, 12582911872u64, 12591299456u64, 12599688064u64, - 12608074624u64, 12616463488u64, 12624845696u64, 12633239936u64, 12641631616u64, - 12650019968u64, 12658407296u64, 12666795136u64, 12675183232u64, 12683574656u64, - 12691960192u64, 12700350592u64, 12708740224u64, 12717128576u64, 12725515904u64, - 12733906816u64, 12742295168u64, 12750680192u64, 12759071872u64, 12767460736u64, - 12775848832u64, 12784236928u64, 12792626816u64, 12801014656u64, 12809404288u64, - 12817789312u64, 12826181504u64, 12834568832u64, 12842954624u64, 12851345792u64, - 12859732352u64, 12868122496u64, 12876512128u64, 12884901248u64, 12893289088u64, - 12901672832u64, 12910067584u64, 12918455168u64, 12926842496u64, 12935232896u64, - 12943620736u64, 12952009856u64, 12960396928u64, 12968786816u64, 12977176192u64, - 12985563776u64, 12993951104u64, 13002341504u64, 13010730368u64, 13019115392u64, - 13027506304u64, 13035895168u64, 13044272512u64, 13052673152u64, 13061062528u64, - 13069446272u64, 13077838976u64, 13086227072u64, 13094613632u64, 13103000192u64, - 13111393664u64, 13119782528u64, 13128157568u64, 13136559232u64, 13144945024u64, - 13153329536u64, 13161724288u64, 13170111872u64, 13178502784u64, 13186884736u64, - 13195279744u64, 13203667072u64, 13212057472u64, 13220445824u64, 13228832128u64, - 13237221248u64, 13245610624u64, 13254000512u64, 13262388352u64, 13270777472u64, - 13279166336u64, 13287553408u64, 13295943296u64, 13304331904u64, 13312719488u64, - 13321108096u64, 13329494656u64, 13337885824u64, 13346274944u64, 13354663808u64, - 13363051136u64, 13371439232u64, 13379825024u64, 13388210816u64, 13396605056u64, - 13404995456u64, 13413380224u64, 13421771392u64, 13430159744u64, 13438546048u64, - 13446937216u64, 13455326848u64, 13463708288u64, 13472103808u64, 13480492672u64, - 13488875648u64, 13497269888u64, 13505657728u64, 13514045312u64, 13522435712u64, - 13530824576u64, 13539210112u64, 13547599232u64, 13555989376u64, 13564379008u64, - 13572766336u64, 13581154432u64, 13589544832u64, 13597932928u64, 13606320512u64, - 13614710656u64, 13623097472u64, 13631477632u64, 13639874944u64, 13648264064u64, - 13656652928u64, 13665041792u64, 13673430656u64, 13681818496u64, 13690207616u64, - 13698595712u64, 13706982272u64, 13715373184u64, 13723762048u64, 13732150144u64, - 13740536704u64, 13748926592u64, 13757316224u64, 13765700992u64, 13774090112u64, - 13782477952u64, 13790869376u64, 13799259008u64, 13807647872u64, 13816036736u64, - 13824425344u64, 13832814208u64, 13841202304u64, 13849591424u64, 13857978752u64, - 13866368896u64, 13874754688u64, 13883145344u64, 13891533184u64, 13899919232u64, - 13908311168u64, 13916692096u64, 13925085056u64, 13933473152u64, 13941866368u64, - 13950253696u64, 13958643584u64, 13967032192u64, 13975417216u64, 13983807616u64, - 13992197504u64, 14000582272u64, 14008973696u64, 14017363072u64, 14025752192u64, - 14034137984u64, 14042528384u64, 14050918016u64, 14059301504u64, 14067691648u64, - 14076083584u64, 14084470144u64, 14092852352u64, 14101249664u64, 14109635968u64, - 14118024832u64, 14126407552u64, 14134804352u64, 14143188608u64, 14151577984u64, - 14159968384u64, 14168357248u64, 14176741504u64, 14185127296u64, 14193521024u64, - 14201911424u64, 14210301824u64, 14218685056u64, 14227067264u64, 14235467392u64, - 14243855488u64, 14252243072u64, 14260630144u64, 14269021568u64, 14277409408u64, - 14285799296u64, 14294187904u64, 14302571392u64, 14310961792u64, 14319353728u64, - 14327738752u64, 14336130944u64, 14344518784u64, 14352906368u64, 14361296512u64, - 14369685376u64, 14378071424u64, 14386462592u64, 14394848128u64, 14403230848u64, - 14411627392u64, 14420013952u64, 14428402304u64, 14436793472u64, 14445181568u64, - 14453569664u64, 14461959808u64, 14470347904u64, 14478737024u64, 14487122816u64, - 14495511424u64, 14503901824u64, 14512291712u64, 14520677504u64, 14529064832u64, - 14537456768u64, 14545845632u64, 14554234496u64, 14562618496u64, 14571011456u64, - 14579398784u64, 14587789184u64, 14596172672u64, 14604564608u64, 14612953984u64, - 14621341312u64, 14629724288u64, 14638120832u64, 14646503296u64, 14654897536u64, - 14663284864u64, 14671675264u64, 14680061056u64, 14688447616u64, 14696835968u64, - 14705228416u64, 14713616768u64, 14722003328u64, 14730392192u64, 14738784128u64, - 14747172736u64, 14755561088u64, 14763947648u64, 14772336512u64, 14780725376u64, - 14789110144u64, 14797499776u64, 14805892736u64, 14814276992u64, 14822670208u64, - 14831056256u64, 14839444352u64, 14847836032u64, 14856222848u64, 14864612992u64, - 14872997504u64, 14881388672u64, 14889775744u64, 14898165376u64, 14906553472u64, - 14914944896u64, 14923329664u64, 14931721856u64, 14940109696u64, 14948497024u64, - 14956887424u64, 14965276544u64, 14973663616u64, 14982053248u64, 14990439808u64, - 14998830976u64, 15007216768u64, 15015605888u64, 15023995264u64, 15032385152u64, - 15040768384u64, 15049154944u64, 15057549184u64, 15065939072u64, 15074328448u64, - 15082715008u64, 15091104128u64, 15099493504u64, 15107879296u64, 15116269184u64, - 15124659584u64, 15133042304u64, 15141431936u64, 15149824384u64, 15158214272u64, - 15166602368u64, 15174991232u64, 15183378304u64, 15191760512u64, 15200154496u64, - 15208542592u64, 15216931712u64, 15225323392u64, 15233708416u64, 15242098048u64, - 15250489216u64, 15258875264u64, 15267265408u64, 15275654528u64, 15284043136u64, - 15292431488u64, 15300819584u64, 15309208192u64, 15317596544u64, 15325986176u64, - 15334374784u64, 15342763648u64, 15351151744u64, 15359540608u64, 15367929728u64, - 15376318336u64, 15384706432u64, 15393092992u64, 15401481856u64, 15409869952u64, - 15418258816u64, 15426649984u64, 15435037568u64, 15443425664u64, 15451815296u64, - 15460203392u64, 15468589184u64, 15476979328u64, 15485369216u64, 15493755776u64, - 15502146944u64, 15510534272u64, 15518924416u64, 15527311232u64, 15535699072u64, - 15544089472u64, 15552478336u64, 15560866688u64, 15569254528u64, 15577642624u64, - 15586031488u64, 15594419072u64, 15602809472u64, 15611199104u64, 15619586432u64, - 15627975296u64, 15636364928u64, 15644753792u64, 15653141888u64, 15661529216u64, - 15669918848u64, 15678305152u64, 15686696576u64, 15695083136u64, 15703474048u64, - 15711861632u64, 15720251264u64, 15728636288u64, 15737027456u64, 15745417088u64, - 15753804928u64, 15762194048u64, 15770582656u64, 15778971008u64, 15787358336u64, - 15795747712u64, 15804132224u64, 15812523392u64, 15820909696u64, 15829300096u64, - 15837691264u64, 15846071936u64, 15854466944u64, 15862855808u64, 15871244672u64, - 15879634816u64, 15888020608u64, 15896409728u64, 15904799104u64, 15913185152u64, - 15921577088u64, 15929966464u64, 15938354816u64, 15946743424u64, 15955129472u64, - 15963519872u64, 15971907968u64, 15980296064u64, 15988684928u64, 15997073024u64, - 16005460864u64, 16013851264u64, 16022241152u64, 16030629248u64, 16039012736u64, - 16047406976u64, 16055794816u64, 16064181376u64, 16072571264u64, 16080957824u64, - 16089346688u64, 16097737856u64, 16106125184u64, 16114514816u64, 16122904192u64, - 16131292544u64, 16139678848u64, 16148066944u64, 16156453504u64, 16164839552u64, - 16173236096u64, 16181623424u64, 16190012032u64, 16198401152u64, 16206790528u64, - 16215177344u64, 16223567744u64, 16231956352u64, 16240344704u64, 16248731008u64, - 16257117824u64, 16265504384u64, 16273898624u64, 16282281856u64, 16290668672u64, - 16299064192u64, 16307449216u64, 16315842176u64, 16324230016u64, 16332613504u64, - 16341006464u64, 16349394304u64, 16357783168u64, 16366172288u64, 16374561664u64, - 16382951296u64, 16391337856u64, 16399726208u64, 16408116352u64, 16416505472u64, - 16424892032u64, 16433282176u64, 16441668224u64, 16450058624u64, 16458448768u64, - 16466836864u64, 16475224448u64, 16483613056u64, 16492001408u64, 16500391808u64, - 16508779648u64, 16517166976u64, 16525555328u64, 16533944192u64, 16542330752u64, - 16550719616u64, 16559110528u64, 16567497088u64, 16575888512u64, 16584274816u64, - 16592665472u64, 16601051008u64, 16609442944u64, 16617832064u64, 16626218624u64, - 16634607488u64, 16642996096u64, 16651385728u64, 16659773824u64, 16668163712u64, - 16676552576u64, 16684938112u64, 16693328768u64, 16701718144u64, 16710095488u64, - 16718492288u64, 16726883968u64, 16735272832u64, 16743661184u64, 16752049792u64, - 16760436608u64, 16768827008u64, 16777214336u64, 16785599104u64, 16793992832u64, - 16802381696u64, 16810768768u64, 16819151744u64, 16827542656u64, 16835934848u64, - 16844323712u64, 16852711552u64, 16861101952u64, 16869489536u64, 16877876864u64, - 16886265728u64, 16894653056u64, 16903044736u64, 16911431296u64, 16919821696u64, - 16928207488u64, 16936592768u64, 16944987776u64, 16953375616u64, 16961763968u64, - 16970152832u64, 16978540928u64, 16986929536u64, 16995319168u64, 17003704448u64, - 17012096896u64, 17020481152u64, 17028870784u64, 17037262208u64, 17045649536u64, - 17054039936u64, 17062426496u64, 17070814336u64, 17079205504u64, 17087592064u64, - 17095978112u64, 17104369024u64, 17112759424u64, 17121147776u64, 17129536384u64, - 17137926016u64, 17146314368u64, 17154700928u64, 17163089792u64, 17171480192u64, - 17179864192u64, 17188256896u64, 17196644992u64, 17205033856u64, 17213423488u64, - 17221811072u64, 17230198912u64, 17238588032u64, 17246976896u64, 17255360384u64, - 17263754624u64, 17272143232u64, 17280530048u64, 17288918912u64, 17297309312u64, - 17305696384u64, 17314085504u64, 17322475136u64, 17330863744u64, 17339252096u64, - 17347640192u64, 17356026496u64, 17364413824u64, 17372796544u64, 17381190016u64, - 17389583488u64, 17397972608u64, 17406360704u64, 17414748544u64, 17423135872u64, - 17431527296u64, 17439915904u64, 17448303232u64, 17456691584u64, 17465081728u64, - 17473468288u64, 17481857408u64, 17490247552u64, 17498635904u64, 17507022464u64, - 17515409024u64, 17523801728u64, 17532189824u64, 17540577664u64, 17548966016u64, - 17557353344u64, 17565741184u64, 17574131584u64, 17582519168u64, 17590907008u64, - 17599296128u64, 17607687808u64, 17616076672u64, 17624455808u64, 17632852352u64, - 17641238656u64, 17649630848u64, 17658018944u64, 17666403968u64, 17674794112u64, - 17683178368u64, 17691573376u64, 17699962496u64, 17708350592u64, 17716739968u64, - 17725126528u64, 17733517184u64, 17741898112u64, 17750293888u64, 17758673024u64, - 17767070336u64, 17775458432u64, 17783848832u64, 17792236928u64, 17800625536u64, - 17809012352u64, 17817402752u64, 17825785984u64, 17834178944u64, 17842563968u64, - 17850955648u64, 17859344512u64, 17867732864u64, 17876119424u64, 17884511872u64, - 17892900224u64, 17901287296u64, 17909677696u64, 17918058112u64, 17926451072u64, - 17934843776u64, 17943230848u64, 17951609216u64, 17960008576u64, 17968397696u64, - 17976784256u64, 17985175424u64, 17993564032u64, 18001952128u64, 18010339712u64, - 18018728576u64, 18027116672u64, 18035503232u64, 18043894144u64, 18052283264u64, - 18060672128u64, 18069056384u64, 18077449856u64, 18085837184u64, 18094225792u64, - 18102613376u64, 18111004544u64, 18119388544u64, 18127781248u64, 18136170368u64, - 18144558976u64, 18152947328u64, 18161336192u64, 18169724288u64, 18178108544u64, - 18186498944u64, 18194886784u64, 18203275648u64, 18211666048u64, 18220048768u64, - 18228444544u64, 18236833408u64, 18245220736u64 -]; - -// Generated with the following Mathematica Code: - -// GetCacheSizes[n_] := Module[{ -// DataSetSizeBytesInit = 2^30, -// MixBytes = 128, -// DataSetGrowth = 2^23, -// HashBytes = 64, -// CacheMultiplier = 1024, -// j = 0}, -// Reap[ -// While[j < n, -// Module[{i = Floor[(DataSetSizeBytesInit + DataSetGrowth * j) / (CacheMultiplier * HashBytes)]}, -// While[! PrimeQ[i], i--]; -// Sow[i*HashBytes]; j++]]]][[2]][[1]] -#[cfg_attr(rustfmt, rustfmt_skip)] -pub const CACHE_SIZES: [u64; 2048] = [ - 16776896u64, 16907456u64, 17039296u64, 17170112u64, 17301056u64, 17432512u64, 17563072u64, - 17693888u64, 17824192u64, 17955904u64, 18087488u64, 18218176u64, 18349504u64, 18481088u64, - 18611392u64, 18742336u64, 18874304u64, 19004224u64, 19135936u64, 19267264u64, 19398208u64, - 19529408u64, 19660096u64, 19791424u64, 19922752u64, 20053952u64, 20184896u64, 20315968u64, - 20446912u64, 20576576u64, 20709184u64, 20840384u64, 20971072u64, 21102272u64, 21233216u64, - 21364544u64, 21494848u64, 21626816u64, 21757376u64, 21887552u64, 22019392u64, 22151104u64, - 22281536u64, 22412224u64, 22543936u64, 22675264u64, 22806464u64, 22935872u64, 23068096u64, - 23198272u64, 23330752u64, 23459008u64, 23592512u64, 23723968u64, 23854912u64, 23986112u64, - 24116672u64, 24247616u64, 24378688u64, 24509504u64, 24640832u64, 24772544u64, 24903488u64, - 25034432u64, 25165376u64, 25296704u64, 25427392u64, 25558592u64, 25690048u64, 25820096u64, - 25951936u64, 26081728u64, 26214208u64, 26345024u64, 26476096u64, 26606656u64, 26737472u64, - 26869184u64, 26998208u64, 27131584u64, 27262528u64, 27393728u64, 27523904u64, 27655744u64, - 27786688u64, 27917888u64, 28049344u64, 28179904u64, 28311488u64, 28441792u64, 28573504u64, - 28700864u64, 28835648u64, 28966208u64, 29096768u64, 29228608u64, 29359808u64, 29490752u64, - 29621824u64, 29752256u64, 29882816u64, 30014912u64, 30144448u64, 30273728u64, 30406976u64, - 30538432u64, 30670784u64, 30799936u64, 30932672u64, 31063744u64, 31195072u64, 31325248u64, - 31456192u64, 31588288u64, 31719232u64, 31850432u64, 31981504u64, 32110784u64, 32243392u64, - 32372672u64, 32505664u64, 32636608u64, 32767808u64, 32897344u64, 33029824u64, 33160768u64, - 33289664u64, 33423296u64, 33554368u64, 33683648u64, 33816512u64, 33947456u64, 34076992u64, - 34208704u64, 34340032u64, 34471744u64, 34600256u64, 34734016u64, 34864576u64, 34993984u64, - 35127104u64, 35258176u64, 35386688u64, 35518528u64, 35650624u64, 35782336u64, 35910976u64, - 36044608u64, 36175808u64, 36305728u64, 36436672u64, 36568384u64, 36699968u64, 36830656u64, - 36961984u64, 37093312u64, 37223488u64, 37355072u64, 37486528u64, 37617472u64, 37747904u64, - 37879232u64, 38009792u64, 38141888u64, 38272448u64, 38403392u64, 38535104u64, 38660672u64, - 38795584u64, 38925632u64, 39059264u64, 39190336u64, 39320768u64, 39452096u64, 39581632u64, - 39713984u64, 39844928u64, 39974848u64, 40107968u64, 40238144u64, 40367168u64, 40500032u64, - 40631744u64, 40762816u64, 40894144u64, 41023552u64, 41155904u64, 41286208u64, 41418304u64, - 41547712u64, 41680448u64, 41811904u64, 41942848u64, 42073792u64, 42204992u64, 42334912u64, - 42467008u64, 42597824u64, 42729152u64, 42860096u64, 42991552u64, 43122368u64, 43253696u64, - 43382848u64, 43515712u64, 43646912u64, 43777088u64, 43907648u64, 44039104u64, 44170432u64, - 44302144u64, 44433344u64, 44564288u64, 44694976u64, 44825152u64, 44956864u64, 45088448u64, - 45219008u64, 45350464u64, 45481024u64, 45612608u64, 45744064u64, 45874496u64, 46006208u64, - 46136768u64, 46267712u64, 46399424u64, 46529344u64, 46660672u64, 46791488u64, 46923328u64, - 47053504u64, 47185856u64, 47316928u64, 47447872u64, 47579072u64, 47710144u64, 47839936u64, - 47971648u64, 48103232u64, 48234176u64, 48365248u64, 48496192u64, 48627136u64, 48757312u64, - 48889664u64, 49020736u64, 49149248u64, 49283008u64, 49413824u64, 49545152u64, 49675712u64, - 49807168u64, 49938368u64, 50069056u64, 50200256u64, 50331584u64, 50462656u64, 50593472u64, - 50724032u64, 50853952u64, 50986048u64, 51117632u64, 51248576u64, 51379904u64, 51510848u64, - 51641792u64, 51773248u64, 51903296u64, 52035136u64, 52164032u64, 52297664u64, 52427968u64, - 52557376u64, 52690112u64, 52821952u64, 52952896u64, 53081536u64, 53213504u64, 53344576u64, - 53475776u64, 53608384u64, 53738816u64, 53870528u64, 54000832u64, 54131776u64, 54263744u64, - 54394688u64, 54525248u64, 54655936u64, 54787904u64, 54918592u64, 55049152u64, 55181248u64, - 55312064u64, 55442752u64, 55574336u64, 55705024u64, 55836224u64, 55967168u64, 56097856u64, - 56228672u64, 56358592u64, 56490176u64, 56621888u64, 56753728u64, 56884928u64, 57015488u64, - 57146816u64, 57278272u64, 57409216u64, 57540416u64, 57671104u64, 57802432u64, 57933632u64, - 58064576u64, 58195264u64, 58326976u64, 58457408u64, 58588864u64, 58720192u64, 58849984u64, - 58981696u64, 59113024u64, 59243456u64, 59375552u64, 59506624u64, 59637568u64, 59768512u64, - 59897792u64, 60030016u64, 60161984u64, 60293056u64, 60423872u64, 60554432u64, 60683968u64, - 60817216u64, 60948032u64, 61079488u64, 61209664u64, 61341376u64, 61471936u64, 61602752u64, - 61733696u64, 61865792u64, 61996736u64, 62127808u64, 62259136u64, 62389568u64, 62520512u64, - 62651584u64, 62781632u64, 62910784u64, 63045056u64, 63176128u64, 63307072u64, 63438656u64, - 63569216u64, 63700928u64, 63831616u64, 63960896u64, 64093888u64, 64225088u64, 64355392u64, - 64486976u64, 64617664u64, 64748608u64, 64879424u64, 65009216u64, 65142464u64, 65273792u64, - 65402816u64, 65535424u64, 65666752u64, 65797696u64, 65927744u64, 66060224u64, 66191296u64, - 66321344u64, 66453056u64, 66584384u64, 66715328u64, 66846656u64, 66977728u64, 67108672u64, - 67239104u64, 67370432u64, 67501888u64, 67631296u64, 67763776u64, 67895104u64, 68026304u64, - 68157248u64, 68287936u64, 68419264u64, 68548288u64, 68681408u64, 68811968u64, 68942912u64, - 69074624u64, 69205568u64, 69337024u64, 69467584u64, 69599168u64, 69729472u64, 69861184u64, - 69989824u64, 70122944u64, 70253888u64, 70385344u64, 70515904u64, 70647232u64, 70778816u64, - 70907968u64, 71040832u64, 71171648u64, 71303104u64, 71432512u64, 71564992u64, 71695168u64, - 71826368u64, 71958464u64, 72089536u64, 72219712u64, 72350144u64, 72482624u64, 72613568u64, - 72744512u64, 72875584u64, 73006144u64, 73138112u64, 73268672u64, 73400128u64, 73530944u64, - 73662272u64, 73793344u64, 73924544u64, 74055104u64, 74185792u64, 74316992u64, 74448832u64, - 74579392u64, 74710976u64, 74841664u64, 74972864u64, 75102784u64, 75233344u64, 75364544u64, - 75497024u64, 75627584u64, 75759296u64, 75890624u64, 76021696u64, 76152256u64, 76283072u64, - 76414144u64, 76545856u64, 76676672u64, 76806976u64, 76937792u64, 77070016u64, 77200832u64, - 77331392u64, 77462464u64, 77593664u64, 77725376u64, 77856448u64, 77987776u64, 78118336u64, - 78249664u64, 78380992u64, 78511424u64, 78642496u64, 78773056u64, 78905152u64, 79033664u64, - 79166656u64, 79297472u64, 79429568u64, 79560512u64, 79690816u64, 79822784u64, 79953472u64, - 80084672u64, 80214208u64, 80346944u64, 80477632u64, 80608576u64, 80740288u64, 80870848u64, - 81002048u64, 81133504u64, 81264448u64, 81395648u64, 81525952u64, 81657536u64, 81786304u64, - 81919808u64, 82050112u64, 82181312u64, 82311616u64, 82443968u64, 82573376u64, 82705984u64, - 82835776u64, 82967744u64, 83096768u64, 83230528u64, 83359552u64, 83491264u64, 83622464u64, - 83753536u64, 83886016u64, 84015296u64, 84147776u64, 84277184u64, 84409792u64, 84540608u64, - 84672064u64, 84803008u64, 84934336u64, 85065152u64, 85193792u64, 85326784u64, 85458496u64, - 85589312u64, 85721024u64, 85851968u64, 85982656u64, 86112448u64, 86244416u64, 86370112u64, - 86506688u64, 86637632u64, 86769344u64, 86900672u64, 87031744u64, 87162304u64, 87293632u64, - 87424576u64, 87555392u64, 87687104u64, 87816896u64, 87947968u64, 88079168u64, 88211264u64, - 88341824u64, 88473152u64, 88603712u64, 88735424u64, 88862912u64, 88996672u64, 89128384u64, - 89259712u64, 89390272u64, 89521984u64, 89652544u64, 89783872u64, 89914816u64, 90045376u64, - 90177088u64, 90307904u64, 90438848u64, 90569152u64, 90700096u64, 90832832u64, 90963776u64, - 91093696u64, 91223744u64, 91356992u64, 91486784u64, 91618496u64, 91749824u64, 91880384u64, - 92012224u64, 92143552u64, 92273344u64, 92405696u64, 92536768u64, 92666432u64, 92798912u64, - 92926016u64, 93060544u64, 93192128u64, 93322816u64, 93453632u64, 93583936u64, 93715136u64, - 93845056u64, 93977792u64, 94109504u64, 94240448u64, 94371776u64, 94501184u64, 94632896u64, - 94764224u64, 94895552u64, 95023424u64, 95158208u64, 95287744u64, 95420224u64, 95550016u64, - 95681216u64, 95811904u64, 95943872u64, 96075328u64, 96203584u64, 96337856u64, 96468544u64, - 96599744u64, 96731072u64, 96860992u64, 96992576u64, 97124288u64, 97254848u64, 97385536u64, - 97517248u64, 97647808u64, 97779392u64, 97910464u64, 98041408u64, 98172608u64, 98303168u64, - 98434496u64, 98565568u64, 98696768u64, 98827328u64, 98958784u64, 99089728u64, 99220928u64, - 99352384u64, 99482816u64, 99614272u64, 99745472u64, 99876416u64, 100007104u64, - 100138048u64, 100267072u64, 100401088u64, 100529984u64, 100662592u64, 100791872u64, - 100925248u64, 101056064u64, 101187392u64, 101317952u64, 101449408u64, 101580608u64, - 101711296u64, 101841728u64, 101973824u64, 102104896u64, 102235712u64, 102366016u64, - 102498112u64, 102628672u64, 102760384u64, 102890432u64, 103021888u64, 103153472u64, - 103284032u64, 103415744u64, 103545152u64, 103677248u64, 103808576u64, 103939648u64, - 104070976u64, 104201792u64, 104332736u64, 104462528u64, 104594752u64, 104725952u64, - 104854592u64, 104988608u64, 105118912u64, 105247808u64, 105381184u64, 105511232u64, - 105643072u64, 105774784u64, 105903296u64, 106037056u64, 106167872u64, 106298944u64, - 106429504u64, 106561472u64, 106691392u64, 106822592u64, 106954304u64, 107085376u64, - 107216576u64, 107346368u64, 107478464u64, 107609792u64, 107739712u64, 107872192u64, - 108003136u64, 108131392u64, 108265408u64, 108396224u64, 108527168u64, 108657344u64, - 108789568u64, 108920384u64, 109049792u64, 109182272u64, 109312576u64, 109444928u64, - 109572928u64, 109706944u64, 109837888u64, 109969088u64, 110099648u64, 110230976u64, - 110362432u64, 110492992u64, 110624704u64, 110755264u64, 110886208u64, 111017408u64, - 111148864u64, 111279296u64, 111410752u64, 111541952u64, 111673024u64, 111803456u64, - 111933632u64, 112066496u64, 112196416u64, 112328512u64, 112457792u64, 112590784u64, - 112715968u64, 112852672u64, 112983616u64, 113114944u64, 113244224u64, 113376448u64, - 113505472u64, 113639104u64, 113770304u64, 113901376u64, 114031552u64, 114163264u64, - 114294592u64, 114425536u64, 114556864u64, 114687424u64, 114818624u64, 114948544u64, - 115080512u64, 115212224u64, 115343296u64, 115473472u64, 115605184u64, 115736128u64, - 115867072u64, 115997248u64, 116128576u64, 116260288u64, 116391488u64, 116522944u64, - 116652992u64, 116784704u64, 116915648u64, 117046208u64, 117178304u64, 117308608u64, - 117440192u64, 117569728u64, 117701824u64, 117833024u64, 117964096u64, 118094656u64, - 118225984u64, 118357312u64, 118489024u64, 118617536u64, 118749632u64, 118882112u64, - 119012416u64, 119144384u64, 119275328u64, 119406016u64, 119537344u64, 119668672u64, - 119798464u64, 119928896u64, 120061376u64, 120192832u64, 120321728u64, 120454336u64, - 120584512u64, 120716608u64, 120848192u64, 120979136u64, 121109056u64, 121241408u64, - 121372352u64, 121502912u64, 121634752u64, 121764416u64, 121895744u64, 122027072u64, - 122157632u64, 122289088u64, 122421184u64, 122550592u64, 122682944u64, 122813888u64, - 122945344u64, 123075776u64, 123207488u64, 123338048u64, 123468736u64, 123600704u64, - 123731264u64, 123861952u64, 123993664u64, 124124608u64, 124256192u64, 124386368u64, - 124518208u64, 124649024u64, 124778048u64, 124911296u64, 125041088u64, 125173696u64, - 125303744u64, 125432896u64, 125566912u64, 125696576u64, 125829056u64, 125958592u64, - 126090304u64, 126221248u64, 126352832u64, 126483776u64, 126615232u64, 126746432u64, - 126876608u64, 127008704u64, 127139392u64, 127270336u64, 127401152u64, 127532224u64, - 127663552u64, 127794752u64, 127925696u64, 128055232u64, 128188096u64, 128319424u64, - 128449856u64, 128581312u64, 128712256u64, 128843584u64, 128973632u64, 129103808u64, - 129236288u64, 129365696u64, 129498944u64, 129629888u64, 129760832u64, 129892288u64, - 130023104u64, 130154048u64, 130283968u64, 130416448u64, 130547008u64, 130678336u64, - 130807616u64, 130939456u64, 131071552u64, 131202112u64, 131331776u64, 131464384u64, - 131594048u64, 131727296u64, 131858368u64, 131987392u64, 132120256u64, 132250816u64, - 132382528u64, 132513728u64, 132644672u64, 132774976u64, 132905792u64, 133038016u64, - 133168832u64, 133299392u64, 133429312u64, 133562048u64, 133692992u64, 133823296u64, - 133954624u64, 134086336u64, 134217152u64, 134348608u64, 134479808u64, 134607296u64, - 134741056u64, 134872384u64, 135002944u64, 135134144u64, 135265472u64, 135396544u64, - 135527872u64, 135659072u64, 135787712u64, 135921472u64, 136052416u64, 136182848u64, - 136313792u64, 136444864u64, 136576448u64, 136707904u64, 136837952u64, 136970048u64, - 137099584u64, 137232064u64, 137363392u64, 137494208u64, 137625536u64, 137755712u64, - 137887424u64, 138018368u64, 138149824u64, 138280256u64, 138411584u64, 138539584u64, - 138672832u64, 138804928u64, 138936128u64, 139066688u64, 139196864u64, 139328704u64, - 139460032u64, 139590208u64, 139721024u64, 139852864u64, 139984576u64, 140115776u64, - 140245696u64, 140376512u64, 140508352u64, 140640064u64, 140769856u64, 140902336u64, - 141032768u64, 141162688u64, 141294016u64, 141426496u64, 141556544u64, 141687488u64, - 141819584u64, 141949888u64, 142080448u64, 142212544u64, 142342336u64, 142474432u64, - 142606144u64, 142736192u64, 142868288u64, 142997824u64, 143129408u64, 143258944u64, - 143392448u64, 143523136u64, 143653696u64, 143785024u64, 143916992u64, 144045632u64, - 144177856u64, 144309184u64, 144440768u64, 144570688u64, 144701888u64, 144832448u64, - 144965056u64, 145096384u64, 145227584u64, 145358656u64, 145489856u64, 145620928u64, - 145751488u64, 145883072u64, 146011456u64, 146144704u64, 146275264u64, 146407232u64, - 146538176u64, 146668736u64, 146800448u64, 146931392u64, 147062336u64, 147193664u64, - 147324224u64, 147455936u64, 147586624u64, 147717056u64, 147848768u64, 147979456u64, - 148110784u64, 148242368u64, 148373312u64, 148503232u64, 148635584u64, 148766144u64, - 148897088u64, 149028416u64, 149159488u64, 149290688u64, 149420224u64, 149551552u64, - 149683136u64, 149814976u64, 149943616u64, 150076352u64, 150208064u64, 150338624u64, - 150470464u64, 150600256u64, 150732224u64, 150862784u64, 150993088u64, 151125952u64, - 151254976u64, 151388096u64, 151519168u64, 151649728u64, 151778752u64, 151911104u64, - 152042944u64, 152174144u64, 152304704u64, 152435648u64, 152567488u64, 152698816u64, - 152828992u64, 152960576u64, 153091648u64, 153222976u64, 153353792u64, 153484096u64, - 153616192u64, 153747008u64, 153878336u64, 154008256u64, 154139968u64, 154270912u64, - 154402624u64, 154533824u64, 154663616u64, 154795712u64, 154926272u64, 155057984u64, - 155188928u64, 155319872u64, 155450816u64, 155580608u64, 155712064u64, 155843392u64, - 155971136u64, 156106688u64, 156237376u64, 156367424u64, 156499264u64, 156630976u64, - 156761536u64, 156892352u64, 157024064u64, 157155008u64, 157284416u64, 157415872u64, - 157545536u64, 157677248u64, 157810496u64, 157938112u64, 158071744u64, 158203328u64, - 158334656u64, 158464832u64, 158596288u64, 158727616u64, 158858048u64, 158988992u64, - 159121216u64, 159252416u64, 159381568u64, 159513152u64, 159645632u64, 159776192u64, - 159906496u64, 160038464u64, 160169536u64, 160300352u64, 160430656u64, 160563008u64, - 160693952u64, 160822208u64, 160956352u64, 161086784u64, 161217344u64, 161349184u64, - 161480512u64, 161611456u64, 161742272u64, 161873216u64, 162002752u64, 162135872u64, - 162266432u64, 162397888u64, 162529216u64, 162660032u64, 162790976u64, 162922048u64, - 163052096u64, 163184576u64, 163314752u64, 163446592u64, 163577408u64, 163707968u64, - 163839296u64, 163969984u64, 164100928u64, 164233024u64, 164364224u64, 164494912u64, - 164625856u64, 164756672u64, 164887616u64, 165019072u64, 165150016u64, 165280064u64, - 165412672u64, 165543104u64, 165674944u64, 165805888u64, 165936832u64, 166067648u64, - 166198336u64, 166330048u64, 166461248u64, 166591552u64, 166722496u64, 166854208u64, - 166985408u64, 167116736u64, 167246656u64, 167378368u64, 167508416u64, 167641024u64, - 167771584u64, 167903168u64, 168034112u64, 168164032u64, 168295744u64, 168427456u64, - 168557632u64, 168688448u64, 168819136u64, 168951616u64, 169082176u64, 169213504u64, - 169344832u64, 169475648u64, 169605952u64, 169738048u64, 169866304u64, 169999552u64, - 170131264u64, 170262464u64, 170393536u64, 170524352u64, 170655424u64, 170782016u64, - 170917696u64, 171048896u64, 171179072u64, 171310784u64, 171439936u64, 171573184u64, - 171702976u64, 171835072u64, 171966272u64, 172097216u64, 172228288u64, 172359232u64, - 172489664u64, 172621376u64, 172747712u64, 172883264u64, 173014208u64, 173144512u64, - 173275072u64, 173407424u64, 173539136u64, 173669696u64, 173800768u64, 173931712u64, - 174063424u64, 174193472u64, 174325696u64, 174455744u64, 174586816u64, 174718912u64, - 174849728u64, 174977728u64, 175109696u64, 175242688u64, 175374272u64, 175504832u64, - 175636288u64, 175765696u64, 175898432u64, 176028992u64, 176159936u64, 176291264u64, - 176422592u64, 176552512u64, 176684864u64, 176815424u64, 176946496u64, 177076544u64, - 177209152u64, 177340096u64, 177470528u64, 177600704u64, 177731648u64, 177864256u64, - 177994816u64, 178126528u64, 178257472u64, 178387648u64, 178518464u64, 178650176u64, - 178781888u64, 178912064u64, 179044288u64, 179174848u64, 179305024u64, 179436736u64, - 179568448u64, 179698496u64, 179830208u64, 179960512u64, 180092608u64, 180223808u64, - 180354752u64, 180485696u64, 180617152u64, 180748096u64, 180877504u64, 181009984u64, - 181139264u64, 181272512u64, 181402688u64, 181532608u64, 181663168u64, 181795136u64, - 181926592u64, 182057536u64, 182190016u64, 182320192u64, 182451904u64, 182582336u64, - 182713792u64, 182843072u64, 182976064u64, 183107264u64, 183237056u64, 183368384u64, - 183494848u64, 183631424u64, 183762752u64, 183893824u64, 184024768u64, 184154816u64, - 184286656u64, 184417984u64, 184548928u64, 184680128u64, 184810816u64, 184941248u64, - 185072704u64, 185203904u64, 185335616u64, 185465408u64, 185596352u64, 185727296u64, - 185859904u64, 185989696u64, 186121664u64, 186252992u64, 186383552u64, 186514112u64, - 186645952u64, 186777152u64, 186907328u64, 187037504u64, 187170112u64, 187301824u64, - 187429184u64, 187562048u64, 187693504u64, 187825472u64, 187957184u64, 188087104u64, - 188218304u64, 188349376u64, 188481344u64, 188609728u64, 188743616u64, 188874304u64, - 189005248u64, 189136448u64, 189265088u64, 189396544u64, 189528128u64, 189660992u64, - 189791936u64, 189923264u64, 190054208u64, 190182848u64, 190315072u64, 190447424u64, - 190577984u64, 190709312u64, 190840768u64, 190971328u64, 191102656u64, 191233472u64, - 191364032u64, 191495872u64, 191626816u64, 191758016u64, 191888192u64, 192020288u64, - 192148928u64, 192282176u64, 192413504u64, 192542528u64, 192674752u64, 192805952u64, - 192937792u64, 193068608u64, 193198912u64, 193330496u64, 193462208u64, 193592384u64, - 193723456u64, 193854272u64, 193985984u64, 194116672u64, 194247232u64, 194379712u64, - 194508352u64, 194641856u64, 194772544u64, 194900672u64, 195035072u64, 195166016u64, - 195296704u64, 195428032u64, 195558592u64, 195690304u64, 195818176u64, 195952576u64, - 196083392u64, 196214336u64, 196345792u64, 196476736u64, 196607552u64, 196739008u64, - 196869952u64, 197000768u64, 197130688u64, 197262784u64, 197394368u64, 197523904u64, - 197656384u64, 197787584u64, 197916608u64, 198049472u64, 198180544u64, 198310208u64, - 198442432u64, 198573632u64, 198705088u64, 198834368u64, 198967232u64, 199097792u64, - 199228352u64, 199360192u64, 199491392u64, 199621696u64, 199751744u64, 199883968u64, - 200014016u64, 200146624u64, 200276672u64, 200408128u64, 200540096u64, 200671168u64, - 200801984u64, 200933312u64, 201062464u64, 201194944u64, 201326144u64, 201457472u64, - 201588544u64, 201719744u64, 201850816u64, 201981632u64, 202111552u64, 202244032u64, - 202374464u64, 202505152u64, 202636352u64, 202767808u64, 202898368u64, 203030336u64, - 203159872u64, 203292608u64, 203423296u64, 203553472u64, 203685824u64, 203816896u64, - 203947712u64, 204078272u64, 204208192u64, 204341056u64, 204472256u64, 204603328u64, - 204733888u64, 204864448u64, 204996544u64, 205125568u64, 205258304u64, 205388864u64, - 205517632u64, 205650112u64, 205782208u64, 205913536u64, 206044736u64, 206176192u64, - 206307008u64, 206434496u64, 206569024u64, 206700224u64, 206831168u64, 206961856u64, - 207093056u64, 207223616u64, 207355328u64, 207486784u64, 207616832u64, 207749056u64, - 207879104u64, 208010048u64, 208141888u64, 208273216u64, 208404032u64, 208534336u64, - 208666048u64, 208796864u64, 208927424u64, 209059264u64, 209189824u64, 209321792u64, - 209451584u64, 209582656u64, 209715136u64, 209845568u64, 209976896u64, 210106432u64, - 210239296u64, 210370112u64, 210501568u64, 210630976u64, 210763712u64, 210894272u64, - 211024832u64, 211156672u64, 211287616u64, 211418176u64, 211549376u64, 211679296u64, - 211812032u64, 211942592u64, 212074432u64, 212204864u64, 212334016u64, 212467648u64, - 212597824u64, 212727616u64, 212860352u64, 212991424u64, 213120832u64, 213253952u64, - 213385024u64, 213515584u64, 213645632u64, 213777728u64, 213909184u64, 214040128u64, - 214170688u64, 214302656u64, 214433728u64, 214564544u64, 214695232u64, 214826048u64, - 214956992u64, 215089088u64, 215219776u64, 215350592u64, 215482304u64, 215613248u64, - 215743552u64, 215874752u64, 216005312u64, 216137024u64, 216267328u64, 216399296u64, - 216530752u64, 216661696u64, 216790592u64, 216923968u64, 217054528u64, 217183168u64, - 217316672u64, 217448128u64, 217579072u64, 217709504u64, 217838912u64, 217972672u64, - 218102848u64, 218233024u64, 218364736u64, 218496832u64, 218627776u64, 218759104u64, - 218888896u64, 219021248u64, 219151936u64, 219281728u64, 219413056u64, 219545024u64, - 219675968u64, 219807296u64, 219938624u64, 220069312u64, 220200128u64, 220331456u64, - 220461632u64, 220592704u64, 220725184u64, 220855744u64, 220987072u64, 221117888u64, - 221249216u64, 221378368u64, 221510336u64, 221642048u64, 221772736u64, 221904832u64, - 222031808u64, 222166976u64, 222297536u64, 222428992u64, 222559936u64, 222690368u64, - 222820672u64, 222953152u64, 223083968u64, 223213376u64, 223345984u64, 223476928u64, - 223608512u64, 223738688u64, 223869376u64, 224001472u64, 224132672u64, 224262848u64, - 224394944u64, 224524864u64, 224657344u64, 224788288u64, 224919488u64, 225050432u64, - 225181504u64, 225312704u64, 225443776u64, 225574592u64, 225704768u64, 225834176u64, - 225966784u64, 226097216u64, 226229824u64, 226360384u64, 226491712u64, 226623424u64, - 226754368u64, 226885312u64, 227015104u64, 227147456u64, 227278528u64, 227409472u64, - 227539904u64, 227669696u64, 227802944u64, 227932352u64, 228065216u64, 228196288u64, - 228326464u64, 228457792u64, 228588736u64, 228720064u64, 228850112u64, 228981056u64, - 229113152u64, 229243328u64, 229375936u64, 229505344u64, 229636928u64, 229769152u64, - 229894976u64, 230030272u64, 230162368u64, 230292416u64, 230424512u64, 230553152u64, - 230684864u64, 230816704u64, 230948416u64, 231079616u64, 231210944u64, 231342016u64, - 231472448u64, 231603776u64, 231733952u64, 231866176u64, 231996736u64, 232127296u64, - 232259392u64, 232388672u64, 232521664u64, 232652608u64, 232782272u64, 232914496u64, - 233043904u64, 233175616u64, 233306816u64, 233438528u64, 233569984u64, 233699776u64, - 233830592u64, 233962688u64, 234092224u64, 234221888u64, 234353984u64, 234485312u64, - 234618304u64, 234749888u64, 234880832u64, 235011776u64, 235142464u64, 235274048u64, - 235403456u64, 235535936u64, 235667392u64, 235797568u64, 235928768u64, 236057152u64, - 236190272u64, 236322752u64, 236453312u64, 236583616u64, 236715712u64, 236846528u64, - 236976448u64, 237108544u64, 237239104u64, 237371072u64, 237501632u64, 237630784u64, - 237764416u64, 237895232u64, 238026688u64, 238157632u64, 238286912u64, 238419392u64, - 238548032u64, 238681024u64, 238812608u64, 238941632u64, 239075008u64, 239206336u64, - 239335232u64, 239466944u64, 239599168u64, 239730496u64, 239861312u64, 239992384u64, - 240122816u64, 240254656u64, 240385856u64, 240516928u64, 240647872u64, 240779072u64, - 240909632u64, 241040704u64, 241171904u64, 241302848u64, 241433408u64, 241565248u64, - 241696192u64, 241825984u64, 241958848u64, 242088256u64, 242220224u64, 242352064u64, - 242481856u64, 242611648u64, 242744896u64, 242876224u64, 243005632u64, 243138496u64, - 243268672u64, 243400384u64, 243531712u64, 243662656u64, 243793856u64, 243924544u64, - 244054592u64, 244187072u64, 244316608u64, 244448704u64, 244580032u64, 244710976u64, - 244841536u64, 244972864u64, 245104448u64, 245233984u64, 245365312u64, 245497792u64, - 245628736u64, 245759936u64, 245889856u64, 246021056u64, 246152512u64, 246284224u64, - 246415168u64, 246545344u64, 246675904u64, 246808384u64, 246939584u64, 247070144u64, - 247199552u64, 247331648u64, 247463872u64, 247593536u64, 247726016u64, 247857088u64, - 247987648u64, 248116928u64, 248249536u64, 248380736u64, 248512064u64, 248643008u64, - 248773312u64, 248901056u64, 249036608u64, 249167552u64, 249298624u64, 249429184u64, - 249560512u64, 249692096u64, 249822784u64, 249954112u64, 250085312u64, 250215488u64, - 250345792u64, 250478528u64, 250608704u64, 250739264u64, 250870976u64, 251002816u64, - 251133632u64, 251263552u64, 251395136u64, 251523904u64, 251657792u64, 251789248u64, - 251919424u64, 252051392u64, 252182464u64, 252313408u64, 252444224u64, 252575552u64, - 252706624u64, 252836032u64, 252968512u64, 253099712u64, 253227584u64, 253361728u64, - 253493056u64, 253623488u64, 253754432u64, 253885504u64, 254017216u64, 254148032u64, - 254279488u64, 254410432u64, 254541376u64, 254672576u64, 254803264u64, 254933824u64, - 255065792u64, 255196736u64, 255326528u64, 255458752u64, 255589952u64, 255721408u64, - 255851072u64, 255983296u64, 256114624u64, 256244416u64, 256374208u64, 256507712u64, - 256636096u64, 256768832u64, 256900544u64, 257031616u64, 257162176u64, 257294272u64, - 257424448u64, 257555776u64, 257686976u64, 257818432u64, 257949632u64, 258079552u64, - 258211136u64, 258342464u64, 258473408u64, 258603712u64, 258734656u64, 258867008u64, - 258996544u64, 259127744u64, 259260224u64, 259391296u64, 259522112u64, 259651904u64, - 259784384u64, 259915328u64, 260045888u64, 260175424u64, 260308544u64, 260438336u64, - 260570944u64, 260700992u64, 260832448u64, 260963776u64, 261092672u64, 261226304u64, - 261356864u64, 261487936u64, 261619648u64, 261750592u64, 261879872u64, 262011968u64, - 262143424u64, 262274752u64, 262404416u64, 262537024u64, 262667968u64, 262799296u64, - 262928704u64, 263061184u64, 263191744u64, 263322944u64, 263454656u64, 263585216u64, - 263716672u64, 263847872u64, 263978944u64, 264108608u64, 264241088u64, 264371648u64, - 264501184u64, 264632768u64, 264764096u64, 264895936u64, 265024576u64, 265158464u64, - 265287488u64, 265418432u64, 265550528u64, 265681216u64, 265813312u64, 265943488u64, - 266075968u64, 266206144u64, 266337728u64, 266468032u64, 266600384u64, 266731072u64, - 266862272u64, 266993344u64, 267124288u64, 267255616u64, 267386432u64, 267516992u64, - 267648704u64, 267777728u64, 267910592u64, 268040512u64, 268172096u64, 268302784u64, - 268435264u64, 268566208u64, 268696256u64, 268828096u64, 268959296u64, 269090368u64, - 269221312u64, 269352256u64, 269482688u64, 269614784u64, 269745856u64, 269876416u64, - 270007616u64, 270139328u64, 270270272u64, 270401216u64, 270531904u64, 270663616u64, - 270791744u64, 270924736u64, 271056832u64, 271186112u64, 271317184u64, 271449536u64, - 271580992u64, 271711936u64, 271843136u64, 271973056u64, 272105408u64, 272236352u64, - 272367296u64, 272498368u64, 272629568u64, 272759488u64, 272891456u64, 273022784u64, - 273153856u64, 273284672u64, 273415616u64, 273547072u64, 273677632u64, 273808448u64, - 273937088u64, 274071488u64, 274200896u64, 274332992u64, 274463296u64, 274595392u64, - 274726208u64, 274857536u64, 274988992u64, 275118656u64, 275250496u64, 275382208u64, - 275513024u64, 275643968u64, 275775296u64, 275906368u64, 276037184u64, 276167872u64, - 276297664u64, 276429376u64, 276560576u64, 276692672u64, 276822976u64, 276955072u64, - 277085632u64, 277216832u64, 277347008u64, 277478848u64, 277609664u64, 277740992u64, - 277868608u64, 278002624u64, 278134336u64, 278265536u64, 278395328u64, 278526784u64, - 278657728u64, 278789824u64, 278921152u64, 279052096u64, 279182912u64, 279313088u64, - 279443776u64, 279576256u64, 279706048u64, 279838528u64, 279969728u64, 280099648u64, - 280230976u64, 280361408u64, 280493632u64, 280622528u64, 280755392u64, 280887104u64, - 281018176u64, 281147968u64, 281278912u64, 281411392u64, 281542592u64, 281673152u64, - 281803712u64, 281935552u64, 282066496u64, 282197312u64, 282329024u64, 282458816u64, - 282590272u64, 282720832u64, 282853184u64, 282983744u64, 283115072u64, 283246144u64, - 283377344u64, 283508416u64, 283639744u64, 283770304u64, 283901504u64, 284032576u64, - 284163136u64, 284294848u64, 284426176u64, 284556992u64, 284687296u64, 284819264u64, - 284950208u64, 285081536u64 -]; - From a7ce6fca9eedcf22b6e57ba4a29e13122d4137fc Mon Sep 17 00:00:00 2001 From: debris Date: Thu, 24 Mar 2016 16:40:52 +0100 Subject: [PATCH 08/22] fixed checking if state is correct in executive tests --- ethcore/src/json_tests/executive.rs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/ethcore/src/json_tests/executive.rs b/ethcore/src/json_tests/executive.rs index 52f4d7981..283394204 100644 --- a/ethcore/src/json_tests/executive.rs +++ b/ethcore/src/json_tests/executive.rs @@ -25,7 +25,6 @@ use ethereum; use externalities::*; use substate::*; use tests::helpers::*; -use state_diff::StateDiff; use ethjson; struct TestEngineFrontier { @@ -238,8 +237,19 @@ fn do_json_test_for(vm_type: &VMType, json_data: &[u8]) -> Vec { let vm_output: Option> = vm.output.map(Into::into); fail_unless(Some(output) == vm_output, "output is incorrect"); - let diff = StateDiff::diff_pod(&state.to_pod(), &From::from(vm.post_state.unwrap())); - fail_unless(diff.is_empty(), format!("diff should be empty!: {:?}", diff).as_ref()); + for (address, account) in vm.post_state.unwrap().into_iter() { + let address = address.into(); + let code: Vec = account.code.into(); + fail_unless(state.code(&address).unwrap_or_else(Vec::new) == code, "code is incorrect"); + fail_unless(state.balance(&address) == account.balance.into(), "balance is incorrect"); + fail_unless(state.nonce(&address) == account.nonce.into(), "nonce is incorrect"); + account.storage.into_iter().foreach(|(k, v)| { + let key: U256 = k.into(); + let value: U256 = v.into(); + fail_unless(state.storage_at(&address, &From::from(key)) == From::from(value), "storage is incorrect"); + }); + } + let calls: Option> = vm.calls.map(|c| c.into_iter().map(From::from).collect()); fail_unless(Some(callcreates) == calls, "callcreates does not match"); } From aa7ecdbd65902974da3ea1fb49629c6702dd4820 Mon Sep 17 00:00:00 2001 From: NikVolf Date: Fri, 25 Mar 2016 00:07:01 +0300 Subject: [PATCH 09/22] initial commit --- ipc/codegen/Cargo.toml | 27 ++++ ipc/codegen/build.rs | 45 ++++++ ipc/codegen/src/codegen.rs | 284 +++++++++++++++++++++++++++++++++++++ ipc/codegen/src/lib.rs | 67 +++++++++ ipc/codegen/src/lib.rs.in | 17 +++ ipc/rpc/Cargo.toml | 9 ++ ipc/rpc/src/interface.rs | 24 ++++ ipc/rpc/src/lib.rs | 20 +++ ipc/tests/Cargo.toml | 18 +++ ipc/tests/build.rs | 44 ++++++ ipc/tests/examples.rs | 36 +++++ ipc/tests/run.rs | 23 +++ ipc/tests/service.rs | 17 +++ ipc/tests/service.rs.in | 45 ++++++ ipc/tests/socket.rs | 94 ++++++++++++ 15 files changed, 770 insertions(+) create mode 100644 ipc/codegen/Cargo.toml create mode 100644 ipc/codegen/build.rs create mode 100644 ipc/codegen/src/codegen.rs create mode 100644 ipc/codegen/src/lib.rs create mode 100644 ipc/codegen/src/lib.rs.in create mode 100644 ipc/rpc/Cargo.toml create mode 100644 ipc/rpc/src/interface.rs create mode 100644 ipc/rpc/src/lib.rs create mode 100644 ipc/tests/Cargo.toml create mode 100644 ipc/tests/build.rs create mode 100644 ipc/tests/examples.rs create mode 100644 ipc/tests/run.rs create mode 100644 ipc/tests/service.rs create mode 100644 ipc/tests/service.rs.in create mode 100644 ipc/tests/socket.rs diff --git a/ipc/codegen/Cargo.toml b/ipc/codegen/Cargo.toml new file mode 100644 index 000000000..09d6a14bb --- /dev/null +++ b/ipc/codegen/Cargo.toml @@ -0,0 +1,27 @@ +[package] +name = "ethcore-ipc-codegen" +version = "1.1.0" +authors = ["Nikolay Volf"] +license = "GPL-3.0" +description = "Macros to auto-generate implementations for ipc call" +build = "build.rs" +keywords = ["ipc", "codegen"] + +[features] +default = ["with-syntex"] +nightly = ["quasi_macros"] +nightly-testing = ["clippy"] +with-syntex = ["quasi/with-syntex", "quasi_codegen", "quasi_codegen/with-syntex", "syntex", "syntex_syntax"] + +[build-dependencies] +quasi_codegen = { version = "^0.8.0", optional = true } +syntex = { version = "^0.30.0", optional = true } + +[dependencies] +aster = { version = "^0.14.0", default-features = false } +clippy = { version = "^0.*", optional = true } +quasi = { version = "^0.8.0", default-features = false } +quasi_macros = { version = "^0.8.0", optional = true } +syntex = { version = "^0.30.0", optional = true } +syntex_syntax = { version = "^0.30.0", optional = true } +"ethcore-ipc" = { path = "../rpc"} diff --git a/ipc/codegen/build.rs b/ipc/codegen/build.rs new file mode 100644 index 000000000..db9f5ac7e --- /dev/null +++ b/ipc/codegen/build.rs @@ -0,0 +1,45 @@ +// Copyright 2015, 2016 Ethcore (UK) Ltd. +// This file is part of Parity. + +// Parity 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 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. If not, see . + + +#[cfg(feature = "with-syntex")] +mod inner { + extern crate syntex; + extern crate quasi_codegen; + + use std::env; + use std::path::Path; + + pub fn main() { + let out_dir = env::var_os("OUT_DIR").unwrap(); + let mut registry = syntex::Registry::new(); + quasi_codegen::register(&mut registry); + + let src = Path::new("src/lib.rs.in"); + let dst = Path::new(&out_dir).join("lib.rs"); + + registry.expand("", &src, &dst).unwrap(); + } +} + +#[cfg(not(feature = "with-syntex"))] +mod inner { + pub fn main() {} +} + +fn main() { + inner::main(); +} diff --git a/ipc/codegen/src/codegen.rs b/ipc/codegen/src/codegen.rs new file mode 100644 index 000000000..922fefb7b --- /dev/null +++ b/ipc/codegen/src/codegen.rs @@ -0,0 +1,284 @@ +// Copyright 2015, 2016 Ethcore (UK) Ltd. +// This file is part of Parity. + +// Parity 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 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. If not, see . + +use aster; + +use syntax::ast::{ + MetaItem, + Item, + ImplItemKind, + ImplItem, + MethodSig, + Arg, + PatKind, + FunctionRetTy, +}; + +use syntax::ast; +use syntax::codemap::Span; +use syntax::ext::base::{Annotatable, ExtCtxt}; +use syntax::ext::build::AstBuilder; +use syntax::ptr::P; + +pub struct Error; + +pub fn expand_ipc_implementation( + cx: &mut ExtCtxt, + span: Span, + meta_item: &MetaItem, + annotatable: &Annotatable, + push: &mut FnMut(Annotatable) +) { + let item = match *annotatable { + Annotatable::Item(ref item) => item, + _ => { + cx.span_err(meta_item.span, "`#[derive(Ipc)]` may only be applied to struct implementations"); + return; + } + }; + + let builder = aster::AstBuilder::new().span(span); + + let impl_item = match implement_interface(cx, &builder, &item, push) { + Ok(item) => item, + Err(Error) => { return; } + }; + + push(Annotatable::Item(impl_item)) +} + +fn field_name(builder: &aster::AstBuilder, arg: &Arg) -> ast::Ident { + match arg.pat.node { + PatKind::Ident(_, ref ident, _) => builder.id(ident.node), + _ => { panic!("unexpected param in interface: {:?}", arg.pat.node) } + } +} + +fn push_invoke_signature_aster ( + builder: &aster::AstBuilder, + implement: &ImplItem, + signature: &MethodSig, + push: &mut FnMut(Annotatable), +) -> Dispatch { + + let inputs = &signature.decl.inputs; + let (input_type_name, input_arg_names) = if inputs.len() > 0 { + let first_field_name = field_name(builder, &inputs[0]).name.as_str(); + if first_field_name == "self" && inputs.len() == 1 { (None, vec![]) } + else { + let skip = if first_field_name == "self" { 2 } else { 1 }; + let name_str = format!("{}_input", implement.ident.name.as_str()); + + let mut arg_names = Vec::new(); + let arg_name = format!("{}", field_name(builder, &inputs[skip-1]).name); + let mut tree = builder.item() + .attr().word("derive(Serialize, Deserialize)") + .attr().word("allow(non_camel_case_types)") + .struct_(name_str.as_str()) + .field(arg_name.as_str()).ty().build(inputs[skip-1].ty.clone()); + arg_names.push(arg_name); + for arg in inputs.iter().skip(skip) { + let arg_name = format!("{}", field_name(builder, &arg)); + tree = tree.field(arg_name.as_str()).ty().build(arg.ty.clone()); + arg_names.push(arg_name); + } + + push(Annotatable::Item(tree.build())); + (Some(name_str.to_owned()), arg_names) + } + } + else { + (None, vec![]) + }; + + let return_type_name = match signature.decl.output { + FunctionRetTy::Ty(ref ty) => { + let name_str = format!("{}_output", implement.ident.name.as_str()); + let tree = builder.item() + .attr().word("derive(Serialize, Deserialize)") + .attr().word("allow(non_camel_case_types)") + .struct_(name_str.as_str()) + .field(format!("payload")).ty().build(ty.clone()); + push(Annotatable::Item(tree.build())); + Some(name_str.to_owned()) + } + _ => None + }; + + Dispatch { + function_name: format!("{}", implement.ident.name.as_str()), + input_type_name: input_type_name, + input_arg_names: input_arg_names, + return_type_name: return_type_name, + } +} + +struct Dispatch { + function_name: String, + input_type_name: Option, + input_arg_names: Vec, + return_type_name: Option, +} + +fn implement_dispatch_arm_invoke( + cx: &ExtCtxt, + builder: &aster::AstBuilder, + dispatch: &Dispatch, +) -> P +{ + let deserialize_expr = quote_expr!(cx, ::bincode::serde::deserialize_from(r, ::bincode::SizeLimit::Infinite).expect("ipc deserialization error, aborting")); + let input_type_id = builder.id(dispatch.input_type_name.clone().unwrap().as_str()); + let function_name = builder.id(dispatch.function_name.as_str()); + let output_type_id = builder.id(dispatch.return_type_name.clone().unwrap().as_str()); + + let input_args_exprs = dispatch.input_arg_names.iter().map(|ref arg_name| { + let arg_ident = builder.id(arg_name); + quote_expr!(cx, input. $arg_ident) + }).collect::>>(); + + // This is the expanded version of this: + // + // let invoke_serialize_stmt = quote_stmt!(cx, { + // ::bincode::serde::serialize(& $output_type_id { payload: self. $function_name ($hand_param_a, $hand_param_b) }, ::bincode::SizeLimit::Infinite).unwrap() + // }); + // + // But the above does not allow comma-separated expressions for arbitrary number + // of parameters ...$hand_param_a, $hand_param_b, ... $hand_param_n + let invoke_serialize_stmt = { + let ext_cx = &*cx; + ::quasi::parse_stmt_panic(&mut ::syntax::parse::new_parser_from_tts( + ext_cx.parse_sess(), + ext_cx.cfg(), + { + let _sp = ext_cx.call_site(); + let mut tt = ::std::vec::Vec::new(); + tt.push(::syntax::ast::TokenTree::Token(_sp, ::syntax::parse::token::OpenDelim(::syntax::parse::token::Brace))); + tt.push(::syntax::ast::TokenTree::Token(_sp, ::syntax::parse::token::ModSep)); + tt.push(::syntax::ast::TokenTree::Token(_sp, ::syntax::parse::token::Ident(ext_cx.ident_of("bincode"), ::syntax::parse::token::ModName))); + tt.push(::syntax::ast::TokenTree::Token(_sp, ::syntax::parse::token::ModSep)); + tt.push(::syntax::ast::TokenTree::Token(_sp, ::syntax::parse::token::Ident(ext_cx.ident_of("serde"), ::syntax::parse::token::ModName))); + tt.push(::syntax::ast::TokenTree::Token(_sp, ::syntax::parse::token::ModSep)); + tt.push(::syntax::ast::TokenTree::Token(_sp, ::syntax::parse::token::Ident(ext_cx.ident_of("serialize"), ::syntax::parse::token::Plain))); + tt.push(::syntax::ast::TokenTree::Token(_sp, ::syntax::parse::token::OpenDelim(::syntax::parse::token::Paren))); + tt.push(::syntax::ast::TokenTree::Token(_sp, ::syntax::parse::token::BinOp(::syntax::parse::token::And))); + tt.extend(::quasi::ToTokens::to_tokens(&output_type_id, ext_cx).into_iter()); + tt.push(::syntax::ast::TokenTree::Token(_sp, ::syntax::parse::token::OpenDelim(::syntax::parse::token::Brace))); + tt.push(::syntax::ast::TokenTree::Token(_sp, ::syntax::parse::token::Ident(ext_cx.ident_of("payload"), ::syntax::parse::token::Plain))); + tt.push(::syntax::ast::TokenTree::Token(_sp, ::syntax::parse::token::Colon)); + tt.push(::syntax::ast::TokenTree::Token(_sp, ::syntax::parse::token::Ident(ext_cx.ident_of("self"), ::syntax::parse::token::Plain))); + tt.push(::syntax::ast::TokenTree::Token(_sp, ::syntax::parse::token::Dot)); + tt.extend(::quasi::ToTokens::to_tokens(&function_name, ext_cx).into_iter()); + tt.push(::syntax::ast::TokenTree::Token(_sp, ::syntax::parse::token::OpenDelim(::syntax::parse::token::Paren))); + + for arg_expr in input_args_exprs { + tt.extend(::quasi::ToTokens::to_tokens(&arg_expr, ext_cx).into_iter()); + tt.push(::syntax::ast::TokenTree::Token(_sp, ::syntax::parse::token::Comma)); + } + + tt.push(::syntax::ast::TokenTree::Token(_sp, ::syntax::parse::token::CloseDelim(::syntax::parse::token::Paren))); + tt.push(::syntax::ast::TokenTree::Token(_sp, ::syntax::parse::token::CloseDelim(::syntax::parse::token::Brace))); + tt.push(::syntax::ast::TokenTree::Token(_sp, ::syntax::parse::token::Comma)); + tt.push(::syntax::ast::TokenTree::Token(_sp, ::syntax::parse::token::ModSep)); + tt.push(::syntax::ast::TokenTree::Token(_sp, ::syntax::parse::token::Ident(ext_cx.ident_of("bincode"), ::syntax::parse::token::ModName))); + tt.push(::syntax::ast::TokenTree::Token(_sp, ::syntax::parse::token::ModSep)); + tt.push(::syntax::ast::TokenTree::Token(_sp, ::syntax::parse::token::Ident(ext_cx.ident_of("SizeLimit"), ::syntax::parse::token::ModName))); + tt.push(::syntax::ast::TokenTree::Token(_sp, ::syntax::parse::token::ModSep)); + tt.push(::syntax::ast::TokenTree::Token(_sp, ::syntax::parse::token::Ident(ext_cx.ident_of("Infinite"), ::syntax::parse::token::Plain))); + tt.push(::syntax::ast::TokenTree::Token(_sp, ::syntax::parse::token::CloseDelim(::syntax::parse::token::Paren))); + tt.push(::syntax::ast::TokenTree::Token(_sp, ::syntax::parse::token::Dot)); + tt.push(::syntax::ast::TokenTree::Token(_sp, ::syntax::parse::token::Ident(ext_cx.ident_of("unwrap"), ::syntax::parse::token::Plain))); + tt.push(::syntax::ast::TokenTree::Token(_sp, ::syntax::parse::token::OpenDelim(::syntax::parse::token::Paren))); + tt.push(::syntax::ast::TokenTree::Token(_sp, ::syntax::parse::token::CloseDelim(::syntax::parse::token::Paren))); + tt.push(::syntax::ast::TokenTree::Token(_sp, ::syntax::parse::token::CloseDelim(::syntax::parse::token::Brace))); + tt + })) + }; + quote_expr!(cx, { + let input: $input_type_id = $deserialize_expr; + $invoke_serialize_stmt + }) +} + +fn implement_dispatch_arm(cx: &ExtCtxt, builder: &aster::AstBuilder, index: u32, dispatch: &Dispatch) + -> ast::Arm +{ + let index_ident = builder.id(format!("{}", index).as_str()); + let invoke_expr = implement_dispatch_arm_invoke(cx, builder, dispatch); + quote_arm!(cx, $index_ident => { $invoke_expr } ) +} + +fn implement_interface( + cx: &ExtCtxt, + builder: &aster::AstBuilder, + item: &Item, + push: &mut FnMut(Annotatable), +) -> Result, Error> { + let (generics, impl_items) = match item.node { + ast::ItemKind::Impl(_, _, ref generics, _, _, ref impl_items) => (generics, impl_items), + _ => { + cx.span_err( + item.span, + "`#[derive(Ipc)]` may only be applied to item implementations"); + return Err(Error); + } + }; + + let impl_generics = builder.from_generics(generics.clone()) + .add_ty_param_bound( + builder.path().global().ids(&["ethcore_ipc"]).build() + ) + .build(); + + let ty = builder.ty().path() + .segment(item.ident).with_generics(impl_generics.clone()).build() + .build(); + + let where_clause = &impl_generics.where_clause; + + let mut dispatch_table = Vec::new(); + for impl_item in impl_items { + if let ImplItemKind::Method(ref signature, _) = impl_item.node { + dispatch_table.push(push_invoke_signature_aster(builder, &impl_item, signature, push)); + } + } + let mut index = -1; + let dispatch_arms: Vec<_> = dispatch_table.iter() + .map(|dispatch| { index = index + 1; implement_dispatch_arm(cx, builder, index as u32, dispatch) }).collect(); + + Ok(quote_item!(cx, + impl $impl_generics ::ipc::IpcInterface<$ty> for $ty $where_clause { + fn dispatch(&self, r: &mut R) -> Vec + where R: ::std::io::Read + { + let mut method_num = vec![0u8;2]; + match r.read(&mut method_num) { + Ok(size) if size == 0 => { panic!("method id not supplied" ); } + Err(e) => { panic!("ipc read error: {:?}, aborting", e); } + _ => { } + } + match method_num[0] as u16 + (method_num[1] as u16)*256 { + $dispatch_arms + _ => vec![] + } + } + fn invoke(&self, _method_num: u16, _payload: &Option>, _w: &mut W) + where W: ::std::io::Write + { + } + + } + ).unwrap()) +} diff --git a/ipc/codegen/src/lib.rs b/ipc/codegen/src/lib.rs new file mode 100644 index 000000000..8129842ba --- /dev/null +++ b/ipc/codegen/src/lib.rs @@ -0,0 +1,67 @@ +// Copyright 2015, 2016 Ethcore (UK) Ltd. +// This file is part of Parity. + +// Parity 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 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. If not, see . + +//! Codegen for IPC RPC + +#![cfg_attr(feature = "nightly-testing", plugin(clippy))] +#![cfg_attr(feature = "nightly-testing", feature(plugin))] +#![cfg_attr(feature = "nightly-testing", allow(used_underscore_binding))] +#![cfg_attr(not(feature = "with-syntex"), feature(rustc_private, plugin))] +#![cfg_attr(not(feature = "with-syntex"), plugin(quasi_macros))] + +extern crate aster; +extern crate quasi; + +#[cfg(feature = "with-syntex")] +extern crate syntex; + +#[cfg(feature = "with-syntex")] +#[macro_use] +extern crate syntex_syntax as syntax; + +#[cfg(not(feature = "with-syntex"))] +#[macro_use] +extern crate syntax; + +#[cfg(not(feature = "with-syntex"))] +extern crate rustc_plugin; + +extern crate ethcore_ipc as ipc; + +#[cfg(not(feature = "with-syntex"))] +use syntax::feature_gate::AttributeType; + +#[cfg(feature = "with-syntex")] +include!(concat!(env!("OUT_DIR"), "/lib.rs")); + +#[cfg(not(feature = "with-syntex"))] +include!("lib.rs.in"); + +#[cfg(feature = "with-syntex")] +pub fn register(reg: &mut syntex::Registry) { + reg.add_attr("feature(custom_derive)"); + reg.add_attr("feature(custom_attribute)"); + + reg.add_decorator("derive_Ipc", codegen::expand_ipc_implementation); +} + +#[cfg(not(feature = "with-syntex"))] +pub fn register(reg: &mut rustc_plugin::Registry) { + reg.register_syntax_extension( + syntax::parse::token::intern("derive_Ipc"), + syntax::ext::base::MultiDecorator( + Box::new(ser::expand_derive_serialize))); +} diff --git a/ipc/codegen/src/lib.rs.in b/ipc/codegen/src/lib.rs.in new file mode 100644 index 000000000..c942157b1 --- /dev/null +++ b/ipc/codegen/src/lib.rs.in @@ -0,0 +1,17 @@ +// Copyright 2015, 2016 Ethcore (UK) Ltd. +// This file is part of Parity. + +// Parity 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 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. If not, see . + +mod codegen; diff --git a/ipc/rpc/Cargo.toml b/ipc/rpc/Cargo.toml new file mode 100644 index 000000000..b8a05f543 --- /dev/null +++ b/ipc/rpc/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "ethcore-ipc" +version = "1.1.0" +authors = ["Nikolay Volf "] +license = "GPL-3.0" + +[features] + +[dependencies] diff --git a/ipc/rpc/src/interface.rs b/ipc/rpc/src/interface.rs new file mode 100644 index 000000000..111176b1f --- /dev/null +++ b/ipc/rpc/src/interface.rs @@ -0,0 +1,24 @@ +// Copyright 2015, 2016 Ethcore (UK) Ltd. +// This file is part of Parity. + +// Parity 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 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. If not, see . + +//! IPC RPC interface + +pub trait IpcInterface { + /// reads the message from io, dispatches the call and returns result + fn dispatch(&self, r: &mut R) -> Vec where R: ::std::io::Read; + /// encodes the invocation, writes payload and waits for result + fn invoke(&self, method_num: u16, params: &Option>, w: &mut W) where W: ::std::io::Write; +} diff --git a/ipc/rpc/src/lib.rs b/ipc/rpc/src/lib.rs new file mode 100644 index 000000000..5018a5cd2 --- /dev/null +++ b/ipc/rpc/src/lib.rs @@ -0,0 +1,20 @@ +// Copyright 2015, 2016 Ethcore (UK) Ltd. +// This file is part of Parity. + +// Parity 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 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. If not, see . + +//! IPC RPC interface + +pub mod interface; +pub use interface::IpcInterface; diff --git a/ipc/tests/Cargo.toml b/ipc/tests/Cargo.toml new file mode 100644 index 000000000..a4d07ae57 --- /dev/null +++ b/ipc/tests/Cargo.toml @@ -0,0 +1,18 @@ +[package] +name = "ethcore-ipc-tests" +version = "0.1.0" +authors = ["Nikolay Volf"] +build = "build.rs" + +[lib] +path = "run.rs" + +[dependencies] +"ethcore-ipc" = { path = "../rpc" } +bincode = "*" +serde = "0.7.0" + +[build-dependencies] +syntex = "0.30.0" +serde_codegen = "0.7.0" +"ethcore-ipc-codegen" = { path = "../codegen" } diff --git a/ipc/tests/build.rs b/ipc/tests/build.rs new file mode 100644 index 000000000..a960c4202 --- /dev/null +++ b/ipc/tests/build.rs @@ -0,0 +1,44 @@ +// Copyright 2015, 2016 Ethcore (UK) Ltd. +// This file is part of Parity. + +// Parity 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 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. If not, see . + +extern crate syntex; +extern crate ethcore_ipc_codegen as codegen; +extern crate serde_codegen; + +use std::env; +use std::path::Path; + +pub fn main() { + let out_dir = env::var_os("OUT_DIR").unwrap(); + + // ipc pass + { + let src = Path::new("service.rs.in"); + let dst = Path::new(&out_dir).join("service_ipc.rs"); + let mut registry = syntex::Registry::new(); + codegen::register(&mut registry); + registry.expand("", &src, &dst).unwrap(); + } + + // serde pass + { + let src = Path::new(&out_dir).join("service_ipc.rs"); + let dst = Path::new(&out_dir).join("service_cg.rs"); + let mut registry = syntex::Registry::new(); + serde_codegen::register(&mut registry); + registry.expand("", &src, &dst).unwrap(); + } +} diff --git a/ipc/tests/examples.rs b/ipc/tests/examples.rs new file mode 100644 index 000000000..5a6fc69bf --- /dev/null +++ b/ipc/tests/examples.rs @@ -0,0 +1,36 @@ +// Copyright 2015, 2016 Ethcore (UK) Ltd. +// This file is part of Parity. + +// Parity 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 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. If not, see . + +#[cfg(test)] +mod tests { + + use super::super::socket::*; + use super::super::service::*; + use ipc::*; + + #[test] + fn call_service() { + // method_num = 0, f = 10 (method Service::commit) + let mut socket = TestSocket::new_ready(vec![0, 0, 0, 0, 0, 10]); + + let service = Service::new(); + assert_eq!(0, *service.commits.read().unwrap()); + + service.dispatch(&mut socket); + + assert_eq!(10, *service.commits.read().unwrap()); + } +} diff --git a/ipc/tests/run.rs b/ipc/tests/run.rs new file mode 100644 index 000000000..187b52d9d --- /dev/null +++ b/ipc/tests/run.rs @@ -0,0 +1,23 @@ +// Copyright 2015, 2016 Ethcore (UK) Ltd. +// This file is part of Parity. + +// Parity 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 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. If not, see . + +extern crate bincode; +extern crate ethcore_ipc as ipc; +extern crate serde; + +pub mod socket; +pub mod service; +mod examples; diff --git a/ipc/tests/service.rs b/ipc/tests/service.rs new file mode 100644 index 000000000..ecd977f61 --- /dev/null +++ b/ipc/tests/service.rs @@ -0,0 +1,17 @@ +// Copyright 2015, 2016 Ethcore (UK) Ltd. +// This file is part of Parity. + +// Parity 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 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. If not, see . + +include!(concat!(env!("OUT_DIR"), "/service_cg.rs")); diff --git a/ipc/tests/service.rs.in b/ipc/tests/service.rs.in new file mode 100644 index 000000000..64b43c2ef --- /dev/null +++ b/ipc/tests/service.rs.in @@ -0,0 +1,45 @@ +// Copyright 2015, 2016 Ethcore (UK) Ltd. +// This file is part of Parity. + +// Parity 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 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. If not, see . + +use std::sync::RwLock; + +pub struct Service { + pub commits: RwLock, + pub rollbacks: RwLock, +} + +#[derive(Ipc)] +impl Service { + fn commit(&self, f: u32) -> u32 { + let mut lock = self.commits.write().unwrap(); + *lock = *lock + f as usize; + f + } + pub fn rollback(&self, a: u32, b: u32) -> i32 { + let mut lock = self.rollbacks.write().unwrap(); + *lock = *lock + a as usize - b as usize; + (a - b) as i32 + } +} + +impl Service { + pub fn new() -> Service { + Service { + commits: RwLock::new(0usize), + rollbacks: RwLock::new(0usize), + } + } +} diff --git a/ipc/tests/socket.rs b/ipc/tests/socket.rs new file mode 100644 index 000000000..c740e872a --- /dev/null +++ b/ipc/tests/socket.rs @@ -0,0 +1,94 @@ +// Copyright 2015, 2016 Ethcore (UK) Ltd. +// This file is part of Parity. + +// Parity 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 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. If not, see . + +use std::io::*; +use std::cmp; + +pub struct TestSocket { + pub read_buffer: Vec, + pub write_buffer: Vec, + pub cursor: usize, + pub buf_size: usize, +} + +impl Default for TestSocket { + fn default() -> Self { + TestSocket::new() + } +} + +impl TestSocket { + pub fn new() -> Self { + TestSocket { + read_buffer: vec![], + write_buffer: vec![], + cursor: 0, + buf_size: 0, + } + } + + pub fn new_buf(buf_size: usize) -> TestSocket { + TestSocket { + read_buffer: vec![], + write_buffer: vec![], + cursor: 0, + buf_size: buf_size, + } + } + + pub fn new_ready(data: Vec) -> TestSocket { + TestSocket { + read_buffer: data, + write_buffer: vec![], + cursor: 0, + buf_size: 0, + } + } +} + +impl Read for TestSocket { + fn read(&mut self, buf: &mut [u8]) -> Result { + let end_position = cmp::min(self.read_buffer.len(), self.cursor+buf.len()); + let len = cmp::max(end_position - self.cursor, 0); + match len { + 0 => Ok(0), + _ => { + for i in self.cursor..end_position { + buf[i-self.cursor] = self.read_buffer[i]; + } + self.cursor = self.cursor + buf.len(); + Ok(len) + } + } + } +} + +impl Write for TestSocket { + fn write(&mut self, buf: &[u8]) -> Result { + if self.buf_size == 0 || buf.len() < self.buf_size { + self.write_buffer.extend(buf.iter().cloned()); + Ok(buf.len()) + } + else { + self.write_buffer.extend(buf.iter().take(self.buf_size).cloned()); + Ok(self.buf_size) + } + } + + fn flush(&mut self) -> Result<()> { + unimplemented!(); + } +} From 17a9bb81e8b76dd0fca1bb5c50c3dbfb5be6e507 Mon Sep 17 00:00:00 2001 From: NikVolf Date: Fri, 25 Mar 2016 00:39:20 +0300 Subject: [PATCH 10/22] whitespaces --- ipc/codegen/build.rs | 28 ++++++++++++++-------------- ipc/codegen/src/codegen.rs | 26 +++++++++++++------------- ipc/codegen/src/lib.rs | 14 +++++++------- 3 files changed, 34 insertions(+), 34 deletions(-) diff --git a/ipc/codegen/build.rs b/ipc/codegen/build.rs index db9f5ac7e..82f990188 100644 --- a/ipc/codegen/build.rs +++ b/ipc/codegen/build.rs @@ -17,29 +17,29 @@ #[cfg(feature = "with-syntex")] mod inner { - extern crate syntex; - extern crate quasi_codegen; + extern crate syntex; + extern crate quasi_codegen; - use std::env; - use std::path::Path; + use std::env; + use std::path::Path; - pub fn main() { - let out_dir = env::var_os("OUT_DIR").unwrap(); - let mut registry = syntex::Registry::new(); - quasi_codegen::register(&mut registry); + pub fn main() { + let out_dir = env::var_os("OUT_DIR").unwrap(); + let mut registry = syntex::Registry::new(); + quasi_codegen::register(&mut registry); - let src = Path::new("src/lib.rs.in"); - let dst = Path::new(&out_dir).join("lib.rs"); + let src = Path::new("src/lib.rs.in"); + let dst = Path::new(&out_dir).join("lib.rs"); - registry.expand("", &src, &dst).unwrap(); - } + registry.expand("", &src, &dst).unwrap(); + } } #[cfg(not(feature = "with-syntex"))] mod inner { - pub fn main() {} + pub fn main() {} } fn main() { - inner::main(); + inner::main(); } diff --git a/ipc/codegen/src/codegen.rs b/ipc/codegen/src/codegen.rs index 922fefb7b..56e0ae01a 100644 --- a/ipc/codegen/src/codegen.rs +++ b/ipc/codegen/src/codegen.rs @@ -42,22 +42,22 @@ pub fn expand_ipc_implementation( annotatable: &Annotatable, push: &mut FnMut(Annotatable) ) { - let item = match *annotatable { - Annotatable::Item(ref item) => item, - _ => { - cx.span_err(meta_item.span, "`#[derive(Ipc)]` may only be applied to struct implementations"); - return; - } - }; + let item = match *annotatable { + Annotatable::Item(ref item) => item, + _ => { + cx.span_err(meta_item.span, "`#[derive(Ipc)]` may only be applied to struct implementations"); + return; + } + }; - let builder = aster::AstBuilder::new().span(span); + let builder = aster::AstBuilder::new().span(span); - let impl_item = match implement_interface(cx, &builder, &item, push) { - Ok(item) => item, - Err(Error) => { return; } - }; + let impl_item = match implement_interface(cx, &builder, &item, push) { + Ok(item) => item, + Err(Error) => { return; } + }; - push(Annotatable::Item(impl_item)) + push(Annotatable::Item(impl_item)) } fn field_name(builder: &aster::AstBuilder, arg: &Arg) -> ast::Ident { diff --git a/ipc/codegen/src/lib.rs b/ipc/codegen/src/lib.rs index 8129842ba..44ac093d9 100644 --- a/ipc/codegen/src/lib.rs +++ b/ipc/codegen/src/lib.rs @@ -52,16 +52,16 @@ include!("lib.rs.in"); #[cfg(feature = "with-syntex")] pub fn register(reg: &mut syntex::Registry) { - reg.add_attr("feature(custom_derive)"); - reg.add_attr("feature(custom_attribute)"); + reg.add_attr("feature(custom_derive)"); + reg.add_attr("feature(custom_attribute)"); - reg.add_decorator("derive_Ipc", codegen::expand_ipc_implementation); + reg.add_decorator("derive_Ipc", codegen::expand_ipc_implementation); } #[cfg(not(feature = "with-syntex"))] pub fn register(reg: &mut rustc_plugin::Registry) { - reg.register_syntax_extension( - syntax::parse::token::intern("derive_Ipc"), - syntax::ext::base::MultiDecorator( - Box::new(ser::expand_derive_serialize))); + reg.register_syntax_extension( + syntax::parse::token::intern("derive_Ipc"), + syntax::ext::base::MultiDecorator( + Box::new(ser::expand_derive_serialize))); } From 19e05595c8a86357158332571e760c7176d0bf45 Mon Sep 17 00:00:00 2001 From: NikVolf Date: Fri, 25 Mar 2016 00:41:15 +0300 Subject: [PATCH 11/22] whitespace extra --- ipc/codegen/src/codegen.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ipc/codegen/src/codegen.rs b/ipc/codegen/src/codegen.rs index 56e0ae01a..af552b969 100644 --- a/ipc/codegen/src/codegen.rs +++ b/ipc/codegen/src/codegen.rs @@ -62,7 +62,7 @@ pub fn expand_ipc_implementation( fn field_name(builder: &aster::AstBuilder, arg: &Arg) -> ast::Ident { match arg.pat.node { - PatKind::Ident(_, ref ident, _) => builder.id(ident.node), + PatKind::Ident(_, ref ident, _) => builder.id(ident.node), _ => { panic!("unexpected param in interface: {:?}", arg.pat.node) } } } From 1864c243fab1ccecb4331e2fbb2826bfed8d18c7 Mon Sep 17 00:00:00 2001 From: NikVolf Date: Fri, 25 Mar 2016 00:42:09 +0300 Subject: [PATCH 12/22] indents --- ipc/codegen/src/codegen.rs | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/ipc/codegen/src/codegen.rs b/ipc/codegen/src/codegen.rs index af552b969..af0bcee68 100644 --- a/ipc/codegen/src/codegen.rs +++ b/ipc/codegen/src/codegen.rs @@ -36,11 +36,11 @@ use syntax::ptr::P; pub struct Error; pub fn expand_ipc_implementation( - cx: &mut ExtCtxt, - span: Span, - meta_item: &MetaItem, - annotatable: &Annotatable, - push: &mut FnMut(Annotatable) + cx: &mut ExtCtxt, + span: Span, + meta_item: &MetaItem, + annotatable: &Annotatable, + push: &mut FnMut(Annotatable) ) { let item = match *annotatable { Annotatable::Item(ref item) => item, @@ -68,10 +68,10 @@ fn field_name(builder: &aster::AstBuilder, arg: &Arg) -> ast::Ident { } fn push_invoke_signature_aster ( - builder: &aster::AstBuilder, + builder: &aster::AstBuilder, implement: &ImplItem, signature: &MethodSig, - push: &mut FnMut(Annotatable), + push: &mut FnMut(Annotatable), ) -> Dispatch { let inputs = &signature.decl.inputs; @@ -135,7 +135,7 @@ struct Dispatch { fn implement_dispatch_arm_invoke( cx: &ExtCtxt, - builder: &aster::AstBuilder, + builder: &aster::AstBuilder, dispatch: &Dispatch, ) -> P { @@ -221,10 +221,10 @@ fn implement_dispatch_arm(cx: &ExtCtxt, builder: &aster::AstBuilder, index: u32, } fn implement_interface( - cx: &ExtCtxt, - builder: &aster::AstBuilder, - item: &Item, - push: &mut FnMut(Annotatable), + cx: &ExtCtxt, + builder: &aster::AstBuilder, + item: &Item, + push: &mut FnMut(Annotatable), ) -> Result, Error> { let (generics, impl_items) = match item.node { ast::ItemKind::Impl(_, _, ref generics, _, _, ref impl_items) => (generics, impl_items), From cb2e1e1572b02feb874f2266c375ec94cf6c2b85 Mon Sep 17 00:00:00 2001 From: NikVolf Date: Fri, 25 Mar 2016 00:44:02 +0300 Subject: [PATCH 13/22] one more --- ipc/codegen/src/codegen.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ipc/codegen/src/codegen.rs b/ipc/codegen/src/codegen.rs index af0bcee68..69160bed5 100644 --- a/ipc/codegen/src/codegen.rs +++ b/ipc/codegen/src/codegen.rs @@ -67,7 +67,7 @@ fn field_name(builder: &aster::AstBuilder, arg: &Arg) -> ast::Ident { } } -fn push_invoke_signature_aster ( +fn push_invoke_signature_aster( builder: &aster::AstBuilder, implement: &ImplItem, signature: &MethodSig, From c014d5d12e604685786d6ae08b275c6dafd90d37 Mon Sep 17 00:00:00 2001 From: NikVolf Date: Fri, 25 Mar 2016 16:55:48 +0300 Subject: [PATCH 14/22] debug symbols for master/beta --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index f281cb854..859dadea2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -41,5 +41,5 @@ path = "parity/main.rs" name = "parity" [profile.release] -debug = false +debug = true lto = false From 8184e27cb80068961ed93d450e4c27ee1571a475 Mon Sep 17 00:00:00 2001 From: NikVolf Date: Fri, 25 Mar 2016 17:24:04 +0300 Subject: [PATCH 15/22] deleted atavisms --- devtools/README.md | 1 - util/.travis.yml | 33 --- util/LICENSE | 675 --------------------------------------------- util/README.md | 1 - 4 files changed, 710 deletions(-) delete mode 100644 devtools/README.md delete mode 100644 util/.travis.yml delete mode 100644 util/LICENSE delete mode 100644 util/README.md diff --git a/devtools/README.md b/devtools/README.md deleted file mode 100644 index 5d5144689..000000000 --- a/devtools/README.md +++ /dev/null @@ -1 +0,0 @@ -# ethcore dev tools diff --git a/util/.travis.yml b/util/.travis.yml deleted file mode 100644 index eedbcaaad..000000000 --- a/util/.travis.yml +++ /dev/null @@ -1,33 +0,0 @@ -language: rust - -rust: - - beta - -os: - #- linux - - osx - -before_script: - # g++4.8 for C++11 which is required by rocksdb - #- if [ $TRAVIS_OS_NAME == "linux" ]; then - #sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test - #sudo apt-get update -y -qq - #sudo apt-get install -qq --yes --force-yes g++-4.8 - #sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.8 50 - - #wget https://github.com/facebook/rocksdb/archive/rocksdb-3.13.tar.gz - #tar xvf rocksdb-3.13.tar.gz && cd rocksdb-rocksdb-3.13 && make shared_lib - #sudo make install - #cd .. - #else - - brew update - - brew install rocksdb - #fi - -after_success: - #- if [ $TRAVIS_OS_NAME == "linux" ]; then - #sudo apt-get install libcurl4-openssl-dev libelf-dev libdw-dev - #wget https://github.com/SimonKagstrom/kcov/archive/master.tar.gz - #tar xzf master.tar.gz && mkdir kcov-master/build && cd kcov-master/build && cmake .. && make && sudo make install && cd ../.. && - #kcov --coveralls-id=$TRAVIS_JOB_ID --exclude-pattern=/.cargo target/kcov target/debug/ethcore_util-* - #fi diff --git a/util/LICENSE b/util/LICENSE deleted file mode 100644 index 733c07236..000000000 --- a/util/LICENSE +++ /dev/null @@ -1,675 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU General Public License is a free, copyleft license for -software and other kinds of works. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -the GNU General Public License is intended to guarantee your freedom to -share and change all versions of a program--to make sure it remains free -software for all its users. We, the Free Software Foundation, use the -GNU General Public License for most of our software; it applies also to -any other work released this way by its authors. You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -them if you wish), that you receive source code or can get it if you -want it, that you can change the software or use pieces of it in new -free programs, and that you know you can do these things. - - To protect your rights, we need to prevent others from denying you -these rights or asking you to surrender the rights. Therefore, you have -certain responsibilities if you distribute copies of the software, or if -you modify it: responsibilities to respect the freedom of others. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must pass on to the recipients the same -freedoms that you received. You must make sure that they, too, receive -or can get the source code. And you must show them these terms so they -know their rights. - - Developers that use the GNU GPL protect your rights with two steps: -(1) assert copyright on the software, and (2) offer you this License -giving you legal permission to copy, distribute and/or modify it. - - For the developers' and authors' protection, the GPL clearly explains -that there is no warranty for this free software. For both users' and -authors' sake, the GPL requires that modified versions be marked as -changed, so that their problems will not be attributed erroneously to -authors of previous versions. - - Some devices are designed to deny users access to install or run -modified versions of the software inside them, although the manufacturer -can do so. This is fundamentally incompatible with the aim of -protecting users' freedom to change the software. The systematic -pattern of such abuse occurs in the area of products for individuals to -use, which is precisely where it is most unacceptable. Therefore, we -have designed this version of the GPL to prohibit the practice for those -products. If such problems arise substantially in other domains, we -stand ready to extend this provision to those domains in future versions -of the GPL, as needed to protect the freedom of users. - - Finally, every program is threatened constantly by software patents. -States should not allow patents to restrict development and use of -software on general-purpose computers, but in those that do, we wish to -avoid the special danger that patents applied to a free program could -make it effectively proprietary. To prevent this, the GPL assures that -patents cannot be used to render the program non-free. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "The Program" refers to any copyrightable work licensed under this -License. Each licensee is addressed as "you". "Licensees" and -"recipients" may be individuals or organizations. - - To "modify" a work means to copy from or adapt all or part of the work -in a fashion requiring copyright permission, other than the making of an -exact copy. The resulting work is called a "modified version" of the -earlier work or a work "based on" the earlier work. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - To "propagate" a work means to do anything with it that, without -permission, would make you directly or secondarily liable for -infringement under applicable copyright law, except executing it on a -computer or modifying a private copy. Propagation includes copying, -distribution (with or without modification), making available to the -public, and in some countries other activities as well. - - To "convey" a work means any kind of propagation that enables other -parties to make or receive copies. Mere interaction with a user through -a computer network, with no transfer of a copy, is not conveying. - - An interactive user interface displays "Appropriate Legal Notices" -to the extent that it includes a convenient and prominently visible -feature that (1) displays an appropriate copyright notice, and (2) -tells the user that there is no warranty for the work (except to the -extent that warranties are provided), that licensees may convey the -work under this License, and how to view a copy of this License. If -the interface presents a list of user commands or options, such as a -menu, a prominent item in the list meets this criterion. - - 1. Source Code. - - The "source code" for a work means the preferred form of the work -for making modifications to it. "Object code" means any non-source -form of a work. - - A "Standard Interface" means an interface that either is an official -standard defined by a recognized standards body, or, in the case of -interfaces specified for a particular programming language, one that -is widely used among developers working in that language. - - The "System Libraries" of an executable work include anything, other -than the work as a whole, that (a) is included in the normal form of -packaging a Major Component, but which is not part of that Major -Component, and (b) serves only to enable use of the work with that -Major Component, or to implement a Standard Interface for which an -implementation is available to the public in source code form. A -"Major Component", in this context, means a major essential component -(kernel, window system, and so on) of the specific operating system -(if any) on which the executable work runs, or a compiler used to -produce the work, or an object code interpreter used to run it. - - The "Corresponding Source" for a work in object code form means all -the source code needed to generate, install, and (for an executable -work) run the object code and to modify the work, including scripts to -control those activities. However, it does not include the work's -System Libraries, or general-purpose tools or generally available free -programs which are used unmodified in performing those activities but -which are not part of the work. For example, Corresponding Source -includes interface definition files associated with source files for -the work, and the source code for shared libraries and dynamically -linked subprograms that the work is specifically designed to require, -such as by intimate data communication or control flow between those -subprograms and other parts of the work. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - All rights granted under this License are granted for the term of -copyright on the Program, and are irrevocable provided the stated -conditions are met. This License explicitly affirms your unlimited -permission to run the unmodified Program. The output from running a -covered work is covered by this License only if the output, given its -content, constitutes a covered work. This License acknowledges your -rights of fair use or other equivalent, as provided by copyright law. - - You may make, run and propagate covered works that you do not -convey, without conditions so long as your license otherwise remains -in force. You may convey covered works to others for the sole purpose -of having them make modifications exclusively for you, or provide you -with facilities for running those works, provided that you comply with -the terms of this License in conveying all material for which you do -not control copyright. Those thus making or running the covered works -for you must do so exclusively on your behalf, under your direction -and control, on terms that prohibit them from making any copies of -your copyrighted material outside their relationship with you. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - No covered work shall be deemed part of an effective technological -measure under any applicable law fulfilling obligations under article -11 of the WIPO copyright treaty adopted on 20 December 1996, or -similar laws prohibiting or restricting circumvention of such -measures. - - When you convey a covered work, you waive any legal power to forbid -circumvention of technological measures to the extent such circumvention -is effected by exercising rights under this License with respect to -the covered work, and you disclaim any intention to limit operation or -modification of the work as a means of enforcing, against the work's -users, your or third parties' legal rights to forbid circumvention of -technological measures. - - 4. Conveying Verbatim Copies. - - You may convey verbatim copies of the Program's source code as you -receive it, in any medium, provided that you conspicuously and -appropriately publish on each copy an appropriate copyright notice; -keep intact all notices stating that this License and any -non-permissive terms added in accord with section 7 apply to the code; -keep intact all notices of the absence of any warranty; and give all -recipients a copy of this License along with the Program. - - You may charge any price or no price for each copy that you convey, -and you may offer support or warranty protection for a fee. - - 5. Conveying Modified Source Versions. - - You may convey a work based on the Program, or the modifications to -produce it from the Program, in the form of source code under the -terms of section 4, provided that you also meet all of these conditions: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - b) The work must carry prominent notices stating that it is - released under this License and any conditions added under section - 7. This requirement modifies the requirement in section 4 to - "keep intact all notices". - - c) You must license the entire work, as a whole, under this - License to anyone who comes into possession of a copy. This - License will therefore apply, along with any applicable section 7 - additional terms, to the whole of the work, and all its parts, - regardless of how they are packaged. This License gives no - permission to license the work in any other way, but it does not - invalidate such permission if you have separately received it. - - d) If the work has interactive user interfaces, each must display - Appropriate Legal Notices; however, if the Program has interactive - interfaces that do not display Appropriate Legal Notices, your - work need not make them do so. - - A compilation of a covered work with other separate and independent -works, which are not by their nature extensions of the covered work, -and which are not combined with it such as to form a larger program, -in or on a volume of a storage or distribution medium, is called an -"aggregate" if the compilation and its resulting copyright are not -used to limit the access or legal rights of the compilation's users -beyond what the individual works permit. Inclusion of a covered work -in an aggregate does not cause this License to apply to the other -parts of the aggregate. - - 6. Conveying Non-Source Forms. - - You may convey a covered work in object code form under the terms -of sections 4 and 5, provided that you also convey the -machine-readable Corresponding Source under the terms of this License, -in one of these ways: - - a) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by the - Corresponding Source fixed on a durable physical medium - customarily used for software interchange. - - b) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by a - written offer, valid for at least three years and valid for as - long as you offer spare parts or customer support for that product - model, to give anyone who possesses the object code either (1) a - copy of the Corresponding Source for all the software in the - product that is covered by this License, on a durable physical - medium customarily used for software interchange, for a price no - more than your reasonable cost of physically performing this - conveying of source, or (2) access to copy the - Corresponding Source from a network server at no charge. - - c) Convey individual copies of the object code with a copy of the - written offer to provide the Corresponding Source. This - alternative is allowed only occasionally and noncommercially, and - only if you received the object code with such an offer, in accord - with subsection 6b. - - d) Convey the object code by offering access from a designated - place (gratis or for a charge), and offer equivalent access to the - Corresponding Source in the same way through the same place at no - further charge. You need not require recipients to copy the - Corresponding Source along with the object code. If the place to - copy the object code is a network server, the Corresponding Source - may be on a different server (operated by you or a third party) - that supports equivalent copying facilities, provided you maintain - clear directions next to the object code saying where to find the - Corresponding Source. Regardless of what server hosts the - Corresponding Source, you remain obligated to ensure that it is - available for as long as needed to satisfy these requirements. - - e) Convey the object code using peer-to-peer transmission, provided - you inform other peers where the object code and Corresponding - Source of the work are being offered to the general public at no - charge under subsection 6d. - - A separable portion of the object code, whose source code is excluded -from the Corresponding Source as a System Library, need not be -included in conveying the object code work. - - A "User Product" is either (1) a "consumer product", which means any -tangible personal property which is normally used for personal, family, -or household purposes, or (2) anything designed or sold for incorporation -into a dwelling. In determining whether a product is a consumer product, -doubtful cases shall be resolved in favor of coverage. For a particular -product received by a particular user, "normally used" refers to a -typical or common use of that class of product, regardless of the status -of the particular user or of the way in which the particular user -actually uses, or expects or is expected to use, the product. A product -is a consumer product regardless of whether the product has substantial -commercial, industrial or non-consumer uses, unless such uses represent -the only significant mode of use of the product. - - "Installation Information" for a User Product means any methods, -procedures, authorization keys, or other information required to install -and execute modified versions of a covered work in that User Product from -a modified version of its Corresponding Source. The information must -suffice to ensure that the continued functioning of the modified object -code is in no case prevented or interfered with solely because -modification has been made. - - If you convey an object code work under this section in, or with, or -specifically for use in, a User Product, and the conveying occurs as -part of a transaction in which the right of possession and use of the -User Product is transferred to the recipient in perpetuity or for a -fixed term (regardless of how the transaction is characterized), the -Corresponding Source conveyed under this section must be accompanied -by the Installation Information. But this requirement does not apply -if neither you nor any third party retains the ability to install -modified object code on the User Product (for example, the work has -been installed in ROM). - - The requirement to provide Installation Information does not include a -requirement to continue to provide support service, warranty, or updates -for a work that has been modified or installed by the recipient, or for -the User Product in which it has been modified or installed. Access to a -network may be denied when the modification itself materially and -adversely affects the operation of the network or violates the rules and -protocols for communication across the network. - - Corresponding Source conveyed, and Installation Information provided, -in accord with this section must be in a format that is publicly -documented (and with an implementation available to the public in -source code form), and must require no special password or key for -unpacking, reading or copying. - - 7. Additional Terms. - - "Additional permissions" are terms that supplement the terms of this -License by making exceptions from one or more of its conditions. -Additional permissions that are applicable to the entire Program shall -be treated as though they were included in this License, to the extent -that they are valid under applicable law. If additional permissions -apply only to part of the Program, that part may be used separately -under those permissions, but the entire Program remains governed by -this License without regard to the additional permissions. - - When you convey a copy of a covered work, you may at your option -remove any additional permissions from that copy, or from any part of -it. (Additional permissions may be written to require their own -removal in certain cases when you modify the work.) You may place -additional permissions on material, added by you to a covered work, -for which you have or can give appropriate copyright permission. - - Notwithstanding any other provision of this License, for material you -add to a covered work, you may (if authorized by the copyright holders of -that material) supplement the terms of this License with terms: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - b) Requiring preservation of specified reasonable legal notices or - author attributions in that material or in the Appropriate Legal - Notices displayed by works containing it; or - - c) Prohibiting misrepresentation of the origin of that material, or - requiring that modified versions of such material be marked in - reasonable ways as different from the original version; or - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - f) Requiring indemnification of licensors and authors of that - material by anyone who conveys the material (or modified versions of - it) with contractual assumptions of liability to the recipient, for - any liability that these contractual assumptions directly impose on - those licensors and authors. - - All other non-permissive additional terms are considered "further -restrictions" within the meaning of section 10. If the Program as you -received it, or any part of it, contains a notice stating that it is -governed by this License along with a term that is a further -restriction, you may remove that term. If a license document contains -a further restriction but permits relicensing or conveying under this -License, you may add to a covered work material governed by the terms -of that license document, provided that the further restriction does -not survive such relicensing or conveying. - - If you add terms to a covered work in accord with this section, you -must place, in the relevant source files, a statement of the -additional terms that apply to those files, or a notice indicating -where to find the applicable terms. - - Additional terms, permissive or non-permissive, may be stated in the -form of a separately written license, or stated as exceptions; -the above requirements apply either way. - - 8. Termination. - - You may not propagate or modify a covered work except as expressly -provided under this License. Any attempt otherwise to propagate or -modify it is void, and will automatically terminate your rights under -this License (including any patent licenses granted under the third -paragraph of section 11). - - However, if you cease all violation of this License, then your -license from a particular copyright holder is reinstated (a) -provisionally, unless and until the copyright holder explicitly and -finally terminates your license, and (b) permanently, if the copyright -holder fails to notify you of the violation by some reasonable means -prior to 60 days after the cessation. - - Moreover, your license from a particular copyright holder is -reinstated permanently if the copyright holder notifies you of the -violation by some reasonable means, this is the first time you have -received notice of violation of this License (for any work) from that -copyright holder, and you cure the violation prior to 30 days after -your receipt of the notice. - - Termination of your rights under this section does not terminate the -licenses of parties who have received copies or rights from you under -this License. If your rights have been terminated and not permanently -reinstated, you do not qualify to receive new licenses for the same -material under section 10. - - 9. Acceptance Not Required for Having Copies. - - You are not required to accept this License in order to receive or -run a copy of the Program. Ancillary propagation of a covered work -occurring solely as a consequence of using peer-to-peer transmission -to receive a copy likewise does not require acceptance. However, -nothing other than this License grants you permission to propagate or -modify any covered work. These actions infringe copyright if you do -not accept this License. Therefore, by modifying or propagating a -covered work, you indicate your acceptance of this License to do so. - - 10. Automatic Licensing of Downstream Recipients. - - Each time you convey a covered work, the recipient automatically -receives a license from the original licensors, to run, modify and -propagate that work, subject to this License. You are not responsible -for enforcing compliance by third parties with this License. - - An "entity transaction" is a transaction transferring control of an -organization, or substantially all assets of one, or subdividing an -organization, or merging organizations. If propagation of a covered -work results from an entity transaction, each party to that -transaction who receives a copy of the work also receives whatever -licenses to the work the party's predecessor in interest had or could -give under the previous paragraph, plus a right to possession of the -Corresponding Source of the work from the predecessor in interest, if -the predecessor has it or can get it with reasonable efforts. - - You may not impose any further restrictions on the exercise of the -rights granted or affirmed under this License. For example, you may -not impose a license fee, royalty, or other charge for exercise of -rights granted under this License, and you may not initiate litigation -(including a cross-claim or counterclaim in a lawsuit) alleging that -any patent claim is infringed by making, using, selling, offering for -sale, or importing the Program or any portion of it. - - 11. Patents. - - A "contributor" is a copyright holder who authorizes use under this -License of the Program or a work on which the Program is based. The -work thus licensed is called the contributor's "contributor version". - - A contributor's "essential patent claims" are all patent claims -owned or controlled by the contributor, whether already acquired or -hereafter acquired, that would be infringed by some manner, permitted -by this License, of making, using, or selling its contributor version, -but do not include claims that would be infringed only as a -consequence of further modification of the contributor version. For -purposes of this definition, "control" includes the right to grant -patent sublicenses in a manner consistent with the requirements of -this License. - - Each contributor grants you a non-exclusive, worldwide, royalty-free -patent license under the contributor's essential patent claims, to -make, use, sell, offer for sale, import and otherwise run, modify and -propagate the contents of its contributor version. - - In the following three paragraphs, a "patent license" is any express -agreement or commitment, however denominated, not to enforce a patent -(such as an express permission to practice a patent or covenant not to -sue for patent infringement). To "grant" such a patent license to a -party means to make such an agreement or commitment not to enforce a -patent against the party. - - If you convey a covered work, knowingly relying on a patent license, -and the Corresponding Source of the work is not available for anyone -to copy, free of charge and under the terms of this License, through a -publicly available network server or other readily accessible means, -then you must either (1) cause the Corresponding Source to be so -available, or (2) arrange to deprive yourself of the benefit of the -patent license for this particular work, or (3) arrange, in a manner -consistent with the requirements of this License, to extend the patent -license to downstream recipients. "Knowingly relying" means you have -actual knowledge that, but for the patent license, your conveying the -covered work in a country, or your recipient's use of the covered work -in a country, would infringe one or more identifiable patents in that -country that you have reason to believe are valid. - - If, pursuant to or in connection with a single transaction or -arrangement, you convey, or propagate by procuring conveyance of, a -covered work, and grant a patent license to some of the parties -receiving the covered work authorizing them to use, propagate, modify -or convey a specific copy of the covered work, then the patent license -you grant is automatically extended to all recipients of the covered -work and works based on it. - - A patent license is "discriminatory" if it does not include within -the scope of its coverage, prohibits the exercise of, or is -conditioned on the non-exercise of one or more of the rights that are -specifically granted under this License. You may not convey a covered -work if you are a party to an arrangement with a third party that is -in the business of distributing software, under which you make payment -to the third party based on the extent of your activity of conveying -the work, and under which the third party grants, to any of the -parties who would receive the covered work from you, a discriminatory -patent license (a) in connection with copies of the covered work -conveyed by you (or copies made from those copies), or (b) primarily -for and in connection with specific products or compilations that -contain the covered work, unless you entered into that arrangement, -or that patent license was granted, prior to 28 March 2007. - - Nothing in this License shall be construed as excluding or limiting -any implied license or other defenses to infringement that may -otherwise be available to you under applicable patent law. - - 12. No Surrender of Others' Freedom. - - If conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot convey a -covered work so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you may -not convey it at all. For example, if you agree to terms that obligate you -to collect a royalty for further conveying from those to whom you convey -the Program, the only way you could satisfy both those terms and this -License would be to refrain entirely from conveying the Program. - - 13. Use with the GNU Affero General Public License. - - Notwithstanding any other provision of this License, you have -permission to link or combine any covered work with a work licensed -under version 3 of the GNU Affero General Public License into a single -combined work, and to convey the resulting work. The terms of this -License will continue to apply to the part which is the covered work, -but the special requirements of the GNU Affero General Public License, -section 13, concerning interaction through a network will apply to the -combination as such. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU General -Public License "or any later version" applies to it, you have the -option of following the terms and conditions either of that numbered -version or of any later version published by the Free Software -Foundation. If the Program does not specify a version number of the -GNU General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU General Public License can be used, that proxy's -public statement of acceptance of a version permanently authorizes you -to choose that version for the Program. - - Later license versions may give you additional or different -permissions. However, no additional obligations are imposed on any -author or copyright holder as a result of your choosing to follow a -later version. - - 15. Disclaimer of Warranty. - - THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY -APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT -HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY -OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM -IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF -ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. Limitation of Liability. - - IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS -THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY -GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE -USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF -DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD -PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), -EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF -SUCH DAMAGES. - - 17. Interpretation of Sections 15 and 16. - - If the disclaimer of warranty and limitation of liability provided -above cannot be given local legal effect according to their terms, -reviewing courts shall apply local law that most closely approximates -an absolute waiver of all civil liability in connection with the -Program, unless a warranty or assumption of liability accompanies a -copy of the Program in return for a fee. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - {one line to give the program's name and a brief idea of what it does.} - Copyright (C) {year} {name of author} - - This program 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. - - This program 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 this program. If not, see . - -Also add information on how to contact you by electronic and paper mail. - - If the program does terminal interaction, make it output a short -notice like this when it starts in an interactive mode: - - {project} Copyright (C) {year} {fullname} - This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, your program's commands -might be different; for a GUI interface, you would use an "about box". - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU GPL, see -. - - The GNU General Public License does not permit incorporating your program -into proprietary programs. If your program is a subroutine library, you -may consider it more useful to permit linking proprietary applications with -the library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. But first, please read -. - diff --git a/util/README.md b/util/README.md deleted file mode 100644 index 744d98922..000000000 --- a/util/README.md +++ /dev/null @@ -1 +0,0 @@ -# ethcore-util From f231440480a73133d39fa7f7a1e716c41dac6873 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Sat, 26 Mar 2016 00:22:09 +0100 Subject: [PATCH 16/22] Use network id for the web3_net_version return. --- rpc/src/v1/impls/net.rs | 2 +- rpc/src/v1/tests/helpers/sync_provider.rs | 6 ++++-- rpc/src/v1/tests/net.rs | 4 ++-- sync/src/chain.rs | 3 +++ 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/rpc/src/v1/impls/net.rs b/rpc/src/v1/impls/net.rs index e52fc0bd4..fb502e6cf 100644 --- a/rpc/src/v1/impls/net.rs +++ b/rpc/src/v1/impls/net.rs @@ -36,7 +36,7 @@ impl NetClient where S: SyncProvider { impl Net for NetClient where S: SyncProvider + 'static { fn version(&self, _: Params) -> Result { - Ok(Value::String(format!("{}", take_weak!(self.sync).status().protocol_version).to_owned())) + Ok(Value::String(format!("{}", take_weak!(self.sync).status().network_id).to_owned())) } fn peer_count(&self, _params: Params) -> Result { diff --git a/rpc/src/v1/tests/helpers/sync_provider.rs b/rpc/src/v1/tests/helpers/sync_provider.rs index 48b4f55a9..527974140 100644 --- a/rpc/src/v1/tests/helpers/sync_provider.rs +++ b/rpc/src/v1/tests/helpers/sync_provider.rs @@ -16,13 +16,14 @@ //! Test implementation of SyncProvider. +use util::U256; use ethsync::{SyncProvider, SyncStatus, SyncState}; use std::sync::{RwLock}; /// TestSyncProvider config. pub struct Config { /// Protocol version. - pub protocol_version: u8, + pub network_id: U256, /// Number of peers. pub num_peers: usize, } @@ -39,7 +40,8 @@ impl TestSyncProvider { TestSyncProvider { status: RwLock::new(SyncStatus { state: SyncState::NotSynced, - protocol_version: config.protocol_version, + network_id: config.network_id, + protocol_version: 63, start_block_number: 0, last_imported_block_number: None, highest_block_number: None, diff --git a/rpc/src/v1/tests/net.rs b/rpc/src/v1/tests/net.rs index e24045ca6..da42b4241 100644 --- a/rpc/src/v1/tests/net.rs +++ b/rpc/src/v1/tests/net.rs @@ -21,7 +21,7 @@ use v1::tests::helpers::{Config, TestSyncProvider}; fn sync_provider() -> Arc { Arc::new(TestSyncProvider::new(Config { - protocol_version: 65, + network_id: 3, num_peers: 120, })) } @@ -34,7 +34,7 @@ fn rpc_net_version() { io.add_delegate(net); let request = r#"{"jsonrpc": "2.0", "method": "net_version", "params": [], "id": 1}"#; - let response = r#"{"jsonrpc":"2.0","result":"65","id":1}"#; + let response = r#"{"jsonrpc":"2.0","result":"3","id":1}"#; assert_eq!(io.handle_request(request), Some(response.to_owned())); } diff --git a/sync/src/chain.rs b/sync/src/chain.rs index 4fd386333..41afbea1c 100644 --- a/sync/src/chain.rs +++ b/sync/src/chain.rs @@ -125,6 +125,8 @@ pub struct SyncStatus { pub state: SyncState, /// Syncing protocol version. That's the maximum protocol version we connect to. pub protocol_version: u8, + /// The underlying p2p network version. + pub network_id: U256, /// BlockChain height for the moment the sync started. pub start_block_number: BlockNumber, /// Last fully downloaded and imported block number (if any). @@ -249,6 +251,7 @@ impl ChainSync { SyncStatus { state: self.state.clone(), protocol_version: 63, + network_id: self.network_id, start_block_number: self.starting_block, last_imported_block_number: self.last_imported_block, highest_block_number: self.highest_block, From b30fc3a7155ffc20047a62d9171fb47678ec35cc Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Sat, 26 Mar 2016 00:53:35 +0100 Subject: [PATCH 17/22] Fix build. --- rpc/src/v1/tests/eth.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rpc/src/v1/tests/eth.rs b/rpc/src/v1/tests/eth.rs index 209b95ded..815321a73 100644 --- a/rpc/src/v1/tests/eth.rs +++ b/rpc/src/v1/tests/eth.rs @@ -40,7 +40,7 @@ fn accounts_provider() -> Arc { fn sync_provider() -> Arc { Arc::new(TestSyncProvider::new(Config { - protocol_version: 65, + network_version: 65, num_peers: 120, })) } From 3d94670f1f1c69122c16c051bb76fa4ab5e5fa3b Mon Sep 17 00:00:00 2001 From: NikVolf Date: Sat, 26 Mar 2016 03:00:05 +0300 Subject: [PATCH 18/22] web3_sha3 --- rpc/src/v1/impls/web3.rs | 13 +++++++++++++ rpc/src/v1/tests/web3.rs | 14 ++++++++++++++ rpc/src/v1/traits/web3.rs | 4 ++++ 3 files changed, 31 insertions(+) diff --git a/rpc/src/v1/impls/web3.rs b/rpc/src/v1/impls/web3.rs index 64a82adb9..72651dd4e 100644 --- a/rpc/src/v1/impls/web3.rs +++ b/rpc/src/v1/impls/web3.rs @@ -18,6 +18,8 @@ use jsonrpc_core::*; use util::version; use v1::traits::Web3; +use v1::types::Bytes; +use util::sha3::Hashable; /// Web3 rpc implementation. pub struct Web3Client; @@ -34,4 +36,15 @@ impl Web3 for Web3Client { _ => Err(Error::invalid_params()) } } + + fn sha3(&self, params: Params) -> Result { + from_params::<(Bytes,)>(params).and_then( + |(data,)| { + let sha3 = data.to_vec().sha3(); + to_value(&sha3) + } + ) + + } + } diff --git a/rpc/src/v1/tests/web3.rs b/rpc/src/v1/tests/web3.rs index c717d361a..af21a932f 100644 --- a/rpc/src/v1/tests/web3.rs +++ b/rpc/src/v1/tests/web3.rs @@ -31,3 +31,17 @@ fn rpc_web3_version() { assert_eq!(io.handle_request(request), Some(response)); } + +#[test] +fn rpc_web3_sha3() { + let web3 = Web3Client::new().to_delegate(); + let io = IoHandler::new(); + io.add_delegate(web3); + + let v = version().to_owned().replace("Parity/", "Parity//"); + + let request = r#"{"jsonrpc": "2.0", "method": "web3_sha3", "params": ["0x00"], "id": 1}"#; + let response = r#"{"jsonrpc":"2.0","result":"0xbc36789e7a1e281436464229828f817d6612f7b477d66591ff96a9e064bcc98a","id":1}"#; + + assert_eq!(io.handle_request(request), Some(response.to_owned())); +} diff --git a/rpc/src/v1/traits/web3.rs b/rpc/src/v1/traits/web3.rs index bb8653504..c7b21a1a1 100644 --- a/rpc/src/v1/traits/web3.rs +++ b/rpc/src/v1/traits/web3.rs @@ -23,10 +23,14 @@ pub trait Web3: Sized + Send + Sync + 'static { /// Returns current client version. fn client_version(&self, _: Params) -> Result { rpc_unimplemented!() } + /// Returns sha3 of the given data + fn sha3(&self, _: Params) -> Result { rpc_unimplemented!() } + /// Should be used to convert object to io delegate. fn to_delegate(self) -> IoDelegate { let mut delegate = IoDelegate::new(Arc::new(self)); delegate.add_method("web3_clientVersion", Web3::client_version); + delegate.add_method("web3_sha3", Web3::sha3); delegate } } From dc4654fa4cb46dcb95e38b08fa7b40a5b997a102 Mon Sep 17 00:00:00 2001 From: NikVolf Date: Sat, 26 Mar 2016 03:15:27 +0300 Subject: [PATCH 19/22] avoid copy --- rpc/src/v1/impls/web3.rs | 3 ++- rpc/src/v1/types/bytes.rs | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/rpc/src/v1/impls/web3.rs b/rpc/src/v1/impls/web3.rs index 72651dd4e..dcea09ec6 100644 --- a/rpc/src/v1/impls/web3.rs +++ b/rpc/src/v1/impls/web3.rs @@ -40,7 +40,8 @@ impl Web3 for Web3Client { fn sha3(&self, params: Params) -> Result { from_params::<(Bytes,)>(params).and_then( |(data,)| { - let sha3 = data.to_vec().sha3(); + let Bytes(ref v) = data; + let sha3 = v.sha3(); to_value(&sha3) } ) diff --git a/rpc/src/v1/types/bytes.rs b/rpc/src/v1/types/bytes.rs index 8c47806f8..efae15ef6 100644 --- a/rpc/src/v1/types/bytes.rs +++ b/rpc/src/v1/types/bytes.rs @@ -21,7 +21,7 @@ use util::common::FromHex; /// Wrapper structure around vector of bytes. #[derive(Debug, PartialEq, Default)] -pub struct Bytes(Vec); +pub struct Bytes(pub Vec); impl Bytes { /// Simple constructor. From 079a39a5f1b17c656fd9397b636374cc038e5a36 Mon Sep 17 00:00:00 2001 From: NikVolf Date: Sat, 26 Mar 2016 03:19:55 +0300 Subject: [PATCH 20/22] wiki test --- rpc/src/v1/tests/web3.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/rpc/src/v1/tests/web3.rs b/rpc/src/v1/tests/web3.rs index af21a932f..178dddfd7 100644 --- a/rpc/src/v1/tests/web3.rs +++ b/rpc/src/v1/tests/web3.rs @@ -45,3 +45,17 @@ fn rpc_web3_sha3() { assert_eq!(io.handle_request(request), Some(response.to_owned())); } + +#[test] +fn rpc_web3_sha3_wiki() { + let web3 = Web3Client::new().to_delegate(); + let io = IoHandler::new(); + io.add_delegate(web3); + + let v = version().to_owned().replace("Parity/", "Parity//"); + + let request = r#"{"jsonrpc": "2.0", "method": "web3_sha3", "params": ["0x68656c6c6f20776f726c64"], "id": 1}"#; + let response = r#"{"jsonrpc":"2.0","result":"0x47173285a8d7341e5e972fc677286384f802f8ef42a5ec5f03bbfa254cb01fad","id":1}"#; + + assert_eq!(io.handle_request(request), Some(response.to_owned())); +} From 52726088f3cb34381117731696dafde5faa27fb8 Mon Sep 17 00:00:00 2001 From: NikVolf Date: Sat, 26 Mar 2016 04:06:40 +0300 Subject: [PATCH 21/22] actually fix build --- rpc/src/v1/tests/eth.rs | 4 ++-- rpc/src/v1/tests/net.rs | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/rpc/src/v1/tests/eth.rs b/rpc/src/v1/tests/eth.rs index 815321a73..182f6c368 100644 --- a/rpc/src/v1/tests/eth.rs +++ b/rpc/src/v1/tests/eth.rs @@ -40,7 +40,7 @@ fn accounts_provider() -> Arc { fn sync_provider() -> Arc { Arc::new(TestSyncProvider::new(Config { - network_version: 65, + network_id: U256::from(3), num_peers: 120, })) } @@ -83,7 +83,7 @@ impl Default for EthTester { #[test] fn rpc_eth_protocol_version() { let request = r#"{"jsonrpc": "2.0", "method": "eth_protocolVersion", "params": [], "id": 1}"#; - let response = r#"{"jsonrpc":"2.0","result":"65","id":1}"#; + let response = r#"{"jsonrpc":"2.0","result":"63","id":1}"#; assert_eq!(EthTester::default().io.handle_request(request), Some(response.to_owned())); } diff --git a/rpc/src/v1/tests/net.rs b/rpc/src/v1/tests/net.rs index da42b4241..036ced168 100644 --- a/rpc/src/v1/tests/net.rs +++ b/rpc/src/v1/tests/net.rs @@ -18,10 +18,11 @@ use std::sync::Arc; use jsonrpc_core::IoHandler; use v1::{Net, NetClient}; use v1::tests::helpers::{Config, TestSyncProvider}; +use util::numbers::*; fn sync_provider() -> Arc { Arc::new(TestSyncProvider::new(Config { - network_id: 3, + network_id: U256::from(3), num_peers: 120, })) } From 44d9ccf2c56b7fe01ab93880546bb98aba292dfd Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Sat, 26 Mar 2016 11:19:51 +0100 Subject: [PATCH 22/22] Update web3.rs [ci-skip] --- rpc/src/v1/impls/web3.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/rpc/src/v1/impls/web3.rs b/rpc/src/v1/impls/web3.rs index dcea09ec6..87343a18a 100644 --- a/rpc/src/v1/impls/web3.rs +++ b/rpc/src/v1/impls/web3.rs @@ -45,7 +45,5 @@ impl Web3 for Web3Client { to_value(&sha3) } ) - } - }