Compare commits
30 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
71a928110c | ||
|
|
ea4da34dac | ||
|
|
7a15ea448d | ||
|
|
13300b066e | ||
|
|
5a40dba9ab | ||
|
|
a80e19e51e | ||
|
|
53bbe0d959 | ||
|
|
094fad1155 | ||
|
|
2255b389cc | ||
|
|
e0a86a9a06 | ||
|
|
fb443dbe16 | ||
|
|
603c52f82d | ||
|
|
98598d312d | ||
|
|
c2b7d58aaf | ||
|
|
3bcf8a84ce | ||
|
|
e018395c05 | ||
|
|
69d32b884f | ||
|
|
f3693a0a43 | ||
|
|
f91c3d9d62 | ||
|
|
b007c7225f | ||
|
|
0b2eb3a4c3 | ||
|
|
780cf0ce1a | ||
|
|
f264d10cc5 | ||
|
|
f52aee83bc | ||
|
|
afa21ce001 | ||
|
|
5ef8c75808 | ||
|
|
aedd7477ab | ||
|
|
979e519c79 | ||
|
|
2799a26d66 | ||
|
|
95d57c839d |
@@ -321,7 +321,7 @@ windows:
|
||||
- set INCLUDE=C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Include;C:\vs2015\VC\include;C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt
|
||||
- set LIB=C:\vs2015\VC\lib;C:\Program Files (x86)\Windows Kits\10\Lib\10.0.10240.0\ucrt\x64
|
||||
- set RUST_BACKTRACE=1
|
||||
- set RUSTFLAGS=%RUSTFLAGS% -Zorbit=off
|
||||
- set RUSTFLAGS=%RUSTFLAGS%
|
||||
- rustup default stable-x86_64-pc-windows-msvc
|
||||
- cargo build --release %CARGOFLAGS%
|
||||
- curl -sL --url "https://github.com/ethcore/win-build/raw/master/SimpleFC.dll" -o nsis\SimpleFC.dll
|
||||
|
||||
40
Cargo.lock
generated
40
Cargo.lock
generated
@@ -1,6 +1,6 @@
|
||||
[root]
|
||||
name = "parity"
|
||||
version = "1.4.2"
|
||||
version = "1.4.3"
|
||||
dependencies = [
|
||||
"ansi_term 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"clippy 0.0.96 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@@ -21,7 +21,7 @@ dependencies = [
|
||||
"ethcore-rpc 1.4.0",
|
||||
"ethcore-signer 1.4.0",
|
||||
"ethcore-stratum 1.4.0",
|
||||
"ethcore-util 1.4.2",
|
||||
"ethcore-util 1.4.3",
|
||||
"ethsync 1.4.0",
|
||||
"fdlimit 0.1.0",
|
||||
"hyper 0.9.10 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@@ -289,7 +289,7 @@ dependencies = [
|
||||
"ethcore-ipc 1.4.0",
|
||||
"ethcore-ipc-codegen 1.4.0",
|
||||
"ethcore-ipc-nano 1.4.0",
|
||||
"ethcore-util 1.4.2",
|
||||
"ethcore-util 1.4.3",
|
||||
"ethjson 0.1.0",
|
||||
"ethkey 0.2.0",
|
||||
"ethstore 0.1.0",
|
||||
@@ -312,7 +312,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ethcore-bigint"
|
||||
version = "0.1.1"
|
||||
version = "0.1.2"
|
||||
dependencies = [
|
||||
"heapsize 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@@ -336,7 +336,7 @@ dependencies = [
|
||||
"ethabi 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"ethcore-devtools 1.4.0",
|
||||
"ethcore-rpc 1.4.0",
|
||||
"ethcore-util 1.4.2",
|
||||
"ethcore-util 1.4.3",
|
||||
"fetch 0.1.0",
|
||||
"hyper 0.9.4 (git+https://github.com/ethcore/hyper)",
|
||||
"jsonrpc-core 3.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@@ -381,7 +381,7 @@ name = "ethcore-ipc"
|
||||
version = "1.4.0"
|
||||
dependencies = [
|
||||
"ethcore-devtools 1.4.0",
|
||||
"ethcore-util 1.4.2",
|
||||
"ethcore-util 1.4.3",
|
||||
"nanomsg 0.5.1 (git+https://github.com/ethcore/nanomsg.rs.git)",
|
||||
"semver 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
@@ -428,7 +428,7 @@ dependencies = [
|
||||
"ethcore-ipc 1.4.0",
|
||||
"ethcore-ipc-codegen 1.4.0",
|
||||
"ethcore-ipc-nano 1.4.0",
|
||||
"ethcore-util 1.4.2",
|
||||
"ethcore-util 1.4.3",
|
||||
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"nanomsg 0.5.1 (git+https://github.com/ethcore/nanomsg.rs.git)",
|
||||
"semver 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@@ -439,7 +439,7 @@ name = "ethcore-logger"
|
||||
version = "1.4.0"
|
||||
dependencies = [
|
||||
"env_logger 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"ethcore-util 1.4.2",
|
||||
"ethcore-util 1.4.3",
|
||||
"isatty 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"lazy_static 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@@ -455,7 +455,7 @@ dependencies = [
|
||||
"bytes 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"ethcore-devtools 1.4.0",
|
||||
"ethcore-io 1.4.0",
|
||||
"ethcore-util 1.4.2",
|
||||
"ethcore-util 1.4.3",
|
||||
"ethcrypto 0.1.0",
|
||||
"ethkey 0.2.0",
|
||||
"igd 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@@ -482,7 +482,7 @@ dependencies = [
|
||||
"ethcore-devtools 1.4.0",
|
||||
"ethcore-io 1.4.0",
|
||||
"ethcore-ipc 1.4.0",
|
||||
"ethcore-util 1.4.2",
|
||||
"ethcore-util 1.4.3",
|
||||
"ethcrypto 0.1.0",
|
||||
"ethjson 0.1.0",
|
||||
"ethkey 0.2.0",
|
||||
@@ -511,7 +511,7 @@ dependencies = [
|
||||
"ethcore-devtools 1.4.0",
|
||||
"ethcore-io 1.4.0",
|
||||
"ethcore-rpc 1.4.0",
|
||||
"ethcore-util 1.4.2",
|
||||
"ethcore-util 1.4.3",
|
||||
"jsonrpc-core 3.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-dapps-glue 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@@ -530,7 +530,7 @@ dependencies = [
|
||||
"ethcore-ipc 1.4.0",
|
||||
"ethcore-ipc-codegen 1.4.0",
|
||||
"ethcore-ipc-nano 1.4.0",
|
||||
"ethcore-util 1.4.2",
|
||||
"ethcore-util 1.4.3",
|
||||
"json-tcp-server 0.1.0 (git+https://github.com/ethcore/json-tcp-server)",
|
||||
"jsonrpc-core 3.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"lazy_static 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@@ -541,7 +541,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ethcore-util"
|
||||
version = "1.4.2"
|
||||
version = "1.4.3"
|
||||
dependencies = [
|
||||
"ansi_term 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"arrayvec 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@@ -549,7 +549,7 @@ dependencies = [
|
||||
"elastic-array 0.6.0 (git+https://github.com/ethcore/elastic-array)",
|
||||
"env_logger 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"eth-secp256k1 0.5.4 (git+https://github.com/ethcore/rust-secp256k1)",
|
||||
"ethcore-bigint 0.1.1",
|
||||
"ethcore-bigint 0.1.2",
|
||||
"ethcore-bloom-journal 0.1.0",
|
||||
"ethcore-devtools 1.4.0",
|
||||
"heapsize 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@@ -580,7 +580,7 @@ name = "ethcrypto"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"eth-secp256k1 0.5.4 (git+https://github.com/ethcore/rust-secp256k1)",
|
||||
"ethcore-bigint 0.1.1",
|
||||
"ethcore-bigint 0.1.2",
|
||||
"ethkey 0.2.0",
|
||||
"rust-crypto 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"tiny-keccak 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@@ -590,7 +590,7 @@ dependencies = [
|
||||
name = "ethjson"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"ethcore-util 1.4.2",
|
||||
"ethcore-util 1.4.3",
|
||||
"rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 0.8.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_codegen 0.8.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@@ -603,7 +603,7 @@ version = "0.2.0"
|
||||
dependencies = [
|
||||
"docopt 0.6.80 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"eth-secp256k1 0.5.4 (git+https://github.com/ethcore/rust-secp256k1)",
|
||||
"ethcore-bigint 0.1.1",
|
||||
"ethcore-bigint 0.1.2",
|
||||
"lazy_static 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@@ -643,7 +643,7 @@ dependencies = [
|
||||
"ethcore-ipc-codegen 1.4.0",
|
||||
"ethcore-ipc-nano 1.4.0",
|
||||
"ethcore-network 1.4.0",
|
||||
"ethcore-util 1.4.2",
|
||||
"ethcore-util 1.4.3",
|
||||
"heapsize 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parking_lot 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@@ -1249,7 +1249,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "parity-ui-precompiled"
|
||||
version = "1.4.0"
|
||||
source = "git+https://github.com/ethcore/js-precompiled.git?branch=beta#8a2b297e342e4a5c441dc15bed54c6b53d0b5657"
|
||||
source = "git+https://github.com/ethcore/js-precompiled.git?branch=beta#b0eae71ecc5655021b1ea2a06760b20dee286569"
|
||||
dependencies = [
|
||||
"parity-dapps-glue 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
@@ -1463,7 +1463,7 @@ name = "rlp"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"elastic-array 0.6.0 (git+https://github.com/ethcore/elastic-array)",
|
||||
"ethcore-bigint 0.1.1",
|
||||
"ethcore-bigint 0.1.2",
|
||||
"lazy_static 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
[package]
|
||||
description = "Ethcore client."
|
||||
name = "parity"
|
||||
version = "1.4.2"
|
||||
version = "1.4.3"
|
||||
license = "GPL-3.0"
|
||||
authors = ["Ethcore <admin@ethcore.io>"]
|
||||
build = "build.rs"
|
||||
|
||||
@@ -131,7 +131,7 @@ impl<A: Authorization + 'static> server::Handler<HttpStream> for Router<A> {
|
||||
StatusCode::NotFound,
|
||||
"404 Not Found",
|
||||
"Your homepage is not available when Trusted Signer is disabled.",
|
||||
Some("You can still access dapps by writing a correct address, though. Re-enabled Signer to get your homepage back."),
|
||||
Some("You can still access dapps by writing a correct address, though. Re-enable Signer to get your homepage back."),
|
||||
self.signer_address.clone(),
|
||||
))
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use std::thread;
|
||||
use std::time::Duration;
|
||||
use std::io::{Read, Write};
|
||||
use std::str::{self, Lines};
|
||||
@@ -42,8 +43,28 @@ pub fn read_block(lines: &mut Lines, all: bool) -> String {
|
||||
block
|
||||
}
|
||||
|
||||
fn connect(address: &SocketAddr) -> TcpStream {
|
||||
let mut retries = 0;
|
||||
let mut last_error = None;
|
||||
while retries < 10 {
|
||||
retries += 1;
|
||||
|
||||
let res = TcpStream::connect(address);
|
||||
match res {
|
||||
Ok(stream) => {
|
||||
return stream;
|
||||
},
|
||||
Err(e) => {
|
||||
last_error = Some(e);
|
||||
thread::sleep(Duration::from_millis(retries * 10));
|
||||
}
|
||||
}
|
||||
}
|
||||
panic!("Unable to connect to the server. Last error: {:?}", last_error);
|
||||
}
|
||||
|
||||
pub fn request(address: &SocketAddr, request: &str) -> Response {
|
||||
let mut req = TcpStream::connect(address).unwrap();
|
||||
let mut req = connect(address);
|
||||
req.set_read_timeout(Some(Duration::from_secs(1))).unwrap();
|
||||
req.write_all(request.as_bytes()).unwrap();
|
||||
|
||||
|
||||
@@ -131,10 +131,11 @@
|
||||
"0x807640a13483f8ac783c557fcdf27be11ea4ac7a"
|
||||
],
|
||||
"eip150Transition": "0x259518",
|
||||
"eip155Transition": "0x7fffffffffffffff",
|
||||
"eip160Transition": "0x7fffffffffffffff",
|
||||
"eip161abcTransition": "0x7fffffffffffffff",
|
||||
"eip161dTransition": "0x7fffffffffffffff"
|
||||
"eip155Transition": 2675000,
|
||||
"eip160Transition": 2675000,
|
||||
"eip161abcTransition": 2675000,
|
||||
"eip161dTransition": 2675000,
|
||||
"maxCodeSize": 24576
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -11,10 +11,10 @@
|
||||
"registrar": "0x52dff57a8a1532e6afb3dc07e2af58bb9eb05b3d",
|
||||
"homesteadTransition": "0x789b0",
|
||||
"eip150Transition": "0x1b34d8",
|
||||
"eip155Transition": "0x7fffffffffffffff",
|
||||
"eip160Transition": "0x7fffffffffffffff",
|
||||
"eip161abcTransition": "0x7fffffffffffffff",
|
||||
"eip161dTransition": "0x7fffffffffffffff"
|
||||
"eip155Transition": 1885000,
|
||||
"eip160Transition": 1885000,
|
||||
"eip161abcTransition": 1885000,
|
||||
"eip161dTransition": 1885000
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -1050,7 +1050,9 @@ impl BlockChainClient for Client {
|
||||
transaction_hash: transaction_hash.clone(),
|
||||
transaction_index: transaction_index,
|
||||
log_index: i
|
||||
}).collect()
|
||||
}).collect(),
|
||||
log_bloom: receipt.log_bloom,
|
||||
state_root: receipt.state_root,
|
||||
})
|
||||
},
|
||||
_ => None
|
||||
|
||||
@@ -315,7 +315,7 @@ pub fn get_temp_state_db() -> GuardedTempResult<StateDB> {
|
||||
|
||||
impl MiningBlockChainClient for TestBlockChainClient {
|
||||
fn latest_schedule(&self) -> Schedule {
|
||||
Schedule::new_post_eip150(true, true, true)
|
||||
Schedule::new_post_eip150(24576, true, true, true)
|
||||
}
|
||||
|
||||
fn prepare_open_block(&self, author: Address, gas_range_target: (U256, U256), extra_data: Bytes) -> OpenBlock {
|
||||
|
||||
@@ -55,7 +55,7 @@ impl Engine for InstantSeal {
|
||||
}
|
||||
|
||||
fn schedule(&self, _env_info: &EnvInfo) -> Schedule {
|
||||
Schedule::new_homestead()
|
||||
Schedule::new_post_eip150(usize::max_value(), false, false, false)
|
||||
}
|
||||
|
||||
fn is_sealer(&self, _author: &Address) -> Option<bool> { Some(true) }
|
||||
|
||||
@@ -70,6 +70,8 @@ pub struct EthashParams {
|
||||
pub eip161abc_transition: u64,
|
||||
/// Number of first block where EIP-161.d begins.
|
||||
pub eip161d_transition: u64,
|
||||
/// Maximum amount of code that can be deploying into a contract.
|
||||
pub max_code_size: u64,
|
||||
}
|
||||
|
||||
impl From<ethjson::spec::EthashParams> for EthashParams {
|
||||
@@ -83,17 +85,18 @@ impl From<ethjson::spec::EthashParams> for EthashParams {
|
||||
block_reward: p.block_reward.into(),
|
||||
registrar: p.registrar.map_or_else(Address::new, Into::into),
|
||||
homestead_transition: p.homestead_transition.map_or(0, Into::into),
|
||||
dao_hardfork_transition: p.dao_hardfork_transition.map_or(0x7fffffffffffffff, Into::into),
|
||||
dao_hardfork_transition: p.dao_hardfork_transition.map_or(u64::max_value(), Into::into),
|
||||
dao_hardfork_beneficiary: p.dao_hardfork_beneficiary.map_or_else(Address::new, Into::into),
|
||||
dao_hardfork_accounts: p.dao_hardfork_accounts.unwrap_or_else(Vec::new).into_iter().map(Into::into).collect(),
|
||||
difficulty_hardfork_transition: p.difficulty_hardfork_transition.map_or(0x7fffffffffffffff, Into::into),
|
||||
difficulty_hardfork_transition: p.difficulty_hardfork_transition.map_or(u64::max_value(), Into::into),
|
||||
difficulty_hardfork_bound_divisor: p.difficulty_hardfork_bound_divisor.map_or(p.difficulty_bound_divisor.into(), Into::into),
|
||||
bomb_defuse_transition: p.bomb_defuse_transition.map_or(0x7fffffffffffffff, Into::into),
|
||||
bomb_defuse_transition: p.bomb_defuse_transition.map_or(u64::max_value(), Into::into),
|
||||
eip150_transition: p.eip150_transition.map_or(0, Into::into),
|
||||
eip155_transition: p.eip155_transition.map_or(0, Into::into),
|
||||
eip160_transition: p.eip160_transition.map_or(0, Into::into),
|
||||
eip161abc_transition: p.eip161abc_transition.map_or(0, Into::into),
|
||||
eip161d_transition: p.eip161d_transition.map_or(0x7fffffffffffffff, Into::into),
|
||||
eip161d_transition: p.eip161d_transition.map_or(u64::max_value(), Into::into),
|
||||
max_code_size: p.max_code_size.map_or(u64::max_value(), Into::into),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -146,6 +149,7 @@ impl Engine for Ethash {
|
||||
Schedule::new_homestead()
|
||||
} else {
|
||||
Schedule::new_post_eip150(
|
||||
self.ethash_params.max_code_size as usize,
|
||||
env_info.number >= self.ethash_params.eip160_transition,
|
||||
env_info.number >= self.ethash_params.eip161abc_transition,
|
||||
env_info.number >= self.ethash_params.eip161d_transition
|
||||
|
||||
@@ -70,6 +70,8 @@ pub struct Schedule {
|
||||
pub quad_coeff_div: usize,
|
||||
/// Cost for contract length when executing `CREATE`
|
||||
pub create_data_gas: usize,
|
||||
/// Maximum code size when creating a contract.
|
||||
pub create_data_limit: usize,
|
||||
/// Transaction cost
|
||||
pub tx_gas: usize,
|
||||
/// `CREATE` transaction cost
|
||||
@@ -111,7 +113,7 @@ impl Schedule {
|
||||
}
|
||||
|
||||
/// Schedule for the post-EIP-150-era of the Ethereum main net.
|
||||
pub fn new_post_eip150(fix_exp: bool, no_empty: bool, kill_empty: bool) -> Schedule {
|
||||
pub fn new_post_eip150(max_code_size: usize, fix_exp: bool, no_empty: bool, kill_empty: bool) -> Schedule {
|
||||
Schedule {
|
||||
exceptional_failed_code_deposit: true,
|
||||
have_delegate_call: true,
|
||||
@@ -139,6 +141,7 @@ impl Schedule {
|
||||
memory_gas: 3,
|
||||
quad_coeff_div: 512,
|
||||
create_data_gas: 200,
|
||||
create_data_limit: max_code_size,
|
||||
tx_gas: 21000,
|
||||
tx_create_gas: 53000,
|
||||
tx_data_zero_gas: 4,
|
||||
@@ -183,6 +186,7 @@ impl Schedule {
|
||||
memory_gas: 3,
|
||||
quad_coeff_div: 512,
|
||||
create_data_gas: 200,
|
||||
create_data_limit: usize::max_value(),
|
||||
tx_gas: 21000,
|
||||
tx_create_gas: tcg,
|
||||
tx_data_zero_gas: 4,
|
||||
|
||||
@@ -242,7 +242,7 @@ impl<'a, T, V> Ext for Externalities<'a, T, V> where T: 'a + Tracer, V: 'a + VMT
|
||||
},
|
||||
OutputPolicy::InitContract(ref mut copy) => {
|
||||
let return_cost = U256::from(data.len()) * U256::from(self.schedule.create_data_gas);
|
||||
if return_cost > *gas {
|
||||
if return_cost > *gas || data.len() > self.schedule.create_data_limit {
|
||||
return match self.schedule.exceptional_failed_code_deposit {
|
||||
true => Err(evm::Error::OutOfGas),
|
||||
false => Ok(*gas)
|
||||
|
||||
@@ -935,6 +935,8 @@ impl MinerService for Miner {
|
||||
}
|
||||
},
|
||||
logs: receipt.logs.clone(),
|
||||
log_bloom: receipt.log_bloom,
|
||||
state_root: receipt.state_root,
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -19,11 +19,11 @@
|
||||
use account_db::{AccountDB, AccountDBMut};
|
||||
use snapshot::Error;
|
||||
|
||||
use util::{U256, FixedHash, H256, Bytes, HashDB, DBValue, SHA3_EMPTY, SHA3_NULL_RLP};
|
||||
use util::{U256, FixedHash, H256, Bytes, HashDB, SHA3_EMPTY, SHA3_NULL_RLP};
|
||||
use util::trie::{TrieDB, Trie};
|
||||
use rlp::{Rlp, RlpStream, Stream, UntrustedRlp, View};
|
||||
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use std::collections::HashSet;
|
||||
|
||||
// An empty account -- these are replaced with RLP null data for a space optimization.
|
||||
const ACC_EMPTY: Account = Account {
|
||||
@@ -150,7 +150,6 @@ impl Account {
|
||||
pub fn from_fat_rlp(
|
||||
acct_db: &mut AccountDBMut,
|
||||
rlp: UntrustedRlp,
|
||||
code_map: &HashMap<H256, Bytes>,
|
||||
) -> Result<(Self, Option<Bytes>), Error> {
|
||||
use util::{TrieDBMut, TrieMut};
|
||||
|
||||
@@ -177,9 +176,6 @@ impl Account {
|
||||
}
|
||||
CodeState::Hash => {
|
||||
let code_hash = try!(rlp.val_at(3));
|
||||
if let Some(code) = code_map.get(&code_hash) {
|
||||
acct_db.emplace(code_hash.clone(), DBValue::from_slice(code));
|
||||
}
|
||||
|
||||
(code_hash, None)
|
||||
}
|
||||
@@ -229,7 +225,7 @@ mod tests {
|
||||
use util::{Address, FixedHash, H256, HashDB, DBValue};
|
||||
use rlp::{UntrustedRlp, View};
|
||||
|
||||
use std::collections::{HashSet, HashMap};
|
||||
use std::collections::HashSet;
|
||||
|
||||
use super::{ACC_EMPTY, Account};
|
||||
|
||||
@@ -250,7 +246,7 @@ mod tests {
|
||||
|
||||
let fat_rlp = account.to_fat_rlp(&AccountDB::new(db.as_hashdb(), &addr), &mut Default::default()).unwrap();
|
||||
let fat_rlp = UntrustedRlp::new(&fat_rlp);
|
||||
assert_eq!(Account::from_fat_rlp(&mut AccountDBMut::new(db.as_hashdb_mut(), &addr), fat_rlp, &Default::default()).unwrap().0, account);
|
||||
assert_eq!(Account::from_fat_rlp(&mut AccountDBMut::new(db.as_hashdb_mut(), &addr), fat_rlp).unwrap().0, account);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -275,7 +271,7 @@ mod tests {
|
||||
|
||||
let fat_rlp = account.to_fat_rlp(&AccountDB::new(db.as_hashdb(), &addr), &mut Default::default()).unwrap();
|
||||
let fat_rlp = UntrustedRlp::new(&fat_rlp);
|
||||
assert_eq!(Account::from_fat_rlp(&mut AccountDBMut::new(db.as_hashdb_mut(), &addr), fat_rlp, &Default::default()).unwrap().0, account);
|
||||
assert_eq!(Account::from_fat_rlp(&mut AccountDBMut::new(db.as_hashdb_mut(), &addr), fat_rlp).unwrap().0, account);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -318,12 +314,11 @@ mod tests {
|
||||
let fat_rlp1 = UntrustedRlp::new(&fat_rlp1);
|
||||
let fat_rlp2 = UntrustedRlp::new(&fat_rlp2);
|
||||
|
||||
let code_map = HashMap::new();
|
||||
let (acc, maybe_code) = Account::from_fat_rlp(&mut AccountDBMut::new(db.as_hashdb_mut(), &addr2), fat_rlp2, &code_map).unwrap();
|
||||
let (acc, maybe_code) = Account::from_fat_rlp(&mut AccountDBMut::new(db.as_hashdb_mut(), &addr2), fat_rlp2).unwrap();
|
||||
assert!(maybe_code.is_none());
|
||||
assert_eq!(acc, account2);
|
||||
|
||||
let (acc, maybe_code) = Account::from_fat_rlp(&mut AccountDBMut::new(db.as_hashdb_mut(), &addr1), fat_rlp1, &code_map).unwrap();
|
||||
let (acc, maybe_code) = Account::from_fat_rlp(&mut AccountDBMut::new(db.as_hashdb_mut(), &addr1), fat_rlp1).unwrap();
|
||||
assert_eq!(maybe_code, Some(b"this is definitely code".to_vec()));
|
||||
assert_eq!(acc, account1);
|
||||
}
|
||||
@@ -332,9 +327,8 @@ mod tests {
|
||||
fn encoding_empty_acc() {
|
||||
let mut db = get_temp_state_db();
|
||||
let mut used_code = HashSet::new();
|
||||
let code_map = HashMap::new();
|
||||
|
||||
assert_eq!(ACC_EMPTY.to_fat_rlp(&AccountDB::new(db.as_hashdb(), &Address::default()), &mut used_code).unwrap(), ::rlp::NULL_RLP.to_vec());
|
||||
assert_eq!(Account::from_fat_rlp(&mut AccountDBMut::new(db.as_hashdb_mut(), &Address::default()), UntrustedRlp::new(&::rlp::NULL_RLP), &code_map).unwrap(), (ACC_EMPTY, None));
|
||||
assert_eq!(Account::from_fat_rlp(&mut AccountDBMut::new(db.as_hashdb_mut(), &Address::default()), UntrustedRlp::new(&::rlp::NULL_RLP)).unwrap(), (ACC_EMPTY, None));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -389,7 +389,7 @@ pub fn chunk_state<'a>(db: &HashDB, root: &H256, writer: &Mutex<SnapshotWriter +
|
||||
pub struct StateRebuilder {
|
||||
db: Box<JournalDB>,
|
||||
state_root: H256,
|
||||
code_map: HashMap<H256, Bytes>, // maps code hashes to code itself.
|
||||
known_code: HashMap<H256, H256>, // code hashes mapped to first account with this code.
|
||||
missing_code: HashMap<H256, Vec<H256>>, // maps code hashes to lists of accounts missing that code.
|
||||
bloom: Bloom,
|
||||
}
|
||||
@@ -400,7 +400,7 @@ impl StateRebuilder {
|
||||
StateRebuilder {
|
||||
db: journaldb::new(db.clone(), pruning, ::db::COL_STATE),
|
||||
state_root: SHA3_NULL_RLP,
|
||||
code_map: HashMap::new(),
|
||||
known_code: HashMap::new(),
|
||||
missing_code: HashMap::new(),
|
||||
bloom: StateDB::load_bloom(&*db),
|
||||
}
|
||||
@@ -419,24 +419,26 @@ impl StateRebuilder {
|
||||
let chunk_size = account_fat_rlps.len() / ::num_cpus::get() + 1;
|
||||
|
||||
// new code contained within this chunk.
|
||||
let mut chunk_code = HashMap::new();
|
||||
let mut chunk_code = Vec::new();
|
||||
|
||||
for (account_chunk, out_pairs_chunk) in account_fat_rlps.chunks(chunk_size).zip(pairs.chunks_mut(chunk_size)) {
|
||||
let code_map = &self.code_map;
|
||||
let status = try!(rebuild_accounts(self.db.as_hashdb_mut(), account_chunk, out_pairs_chunk, code_map));
|
||||
let status = try!(rebuild_accounts(self.db.as_hashdb_mut(), account_chunk, out_pairs_chunk, &self.known_code));
|
||||
chunk_code.extend(status.new_code);
|
||||
|
||||
// update missing code.
|
||||
for (addr_hash, code_hash) in status.missing_code {
|
||||
self.missing_code.entry(code_hash).or_insert_with(Vec::new).push(addr_hash);
|
||||
}
|
||||
}
|
||||
|
||||
// patch up all missing code. must be done after collecting all new missing code entries.
|
||||
for (code_hash, code) in chunk_code {
|
||||
for (code_hash, code, first_with) in chunk_code {
|
||||
for addr_hash in self.missing_code.remove(&code_hash).unwrap_or_else(Vec::new) {
|
||||
let mut db = AccountDBMut::from_hash(self.db.as_hashdb_mut(), addr_hash);
|
||||
db.emplace(code_hash, DBValue::from_slice(&code));
|
||||
}
|
||||
|
||||
self.code_map.insert(code_hash, code);
|
||||
self.known_code.insert(code_hash, first_with);
|
||||
}
|
||||
|
||||
let backing = self.db.backing().clone();
|
||||
@@ -482,7 +484,8 @@ impl StateRebuilder {
|
||||
|
||||
#[derive(Default)]
|
||||
struct RebuiltStatus {
|
||||
new_code: Vec<(H256, Bytes)>, // new code that's become available.
|
||||
// new code that's become available. (code_hash, code, addr_hash)
|
||||
new_code: Vec<(H256, Bytes, H256)>,
|
||||
missing_code: Vec<(H256, H256)>, // accounts that are missing code.
|
||||
}
|
||||
|
||||
@@ -492,9 +495,8 @@ fn rebuild_accounts(
|
||||
db: &mut HashDB,
|
||||
account_chunk: &[&[u8]],
|
||||
out_chunk: &mut [(H256, Bytes)],
|
||||
code_map: &HashMap<H256, Bytes>
|
||||
) -> Result<RebuiltStatus, ::error::Error>
|
||||
{
|
||||
known_code: &HashMap<H256, H256>,
|
||||
) -> Result<RebuiltStatus, ::error::Error> {
|
||||
let mut status = RebuiltStatus::default();
|
||||
for (account_pair, out) in account_chunk.into_iter().zip(out_chunk) {
|
||||
let account_rlp = UntrustedRlp::new(account_pair);
|
||||
@@ -503,17 +505,33 @@ fn rebuild_accounts(
|
||||
let fat_rlp = try!(account_rlp.at(1));
|
||||
|
||||
let thin_rlp = {
|
||||
let mut acct_db = AccountDBMut::from_hash(db, hash);
|
||||
|
||||
// fill out the storage trie and code while decoding.
|
||||
let (acc, maybe_code) = try!(Account::from_fat_rlp(&mut acct_db, fat_rlp, code_map));
|
||||
let (acc, maybe_code) = {
|
||||
let mut acct_db = AccountDBMut::from_hash(db, hash);
|
||||
try!(Account::from_fat_rlp(&mut acct_db, fat_rlp))
|
||||
};
|
||||
|
||||
let code_hash = acc.code_hash().clone();
|
||||
match maybe_code {
|
||||
Some(code) => status.new_code.push((code_hash, code)),
|
||||
// new inline code
|
||||
Some(code) => status.new_code.push((code_hash, code, hash)),
|
||||
None => {
|
||||
if code_hash != ::util::SHA3_EMPTY && !code_map.contains_key(&code_hash) {
|
||||
status.missing_code.push((hash, code_hash));
|
||||
if code_hash != ::util::SHA3_EMPTY {
|
||||
// see if this code has already been included inline
|
||||
match known_code.get(&code_hash) {
|
||||
Some(&first_with) => {
|
||||
// if so, load it from the database.
|
||||
let code = try!(AccountDB::from_hash(db, first_with)
|
||||
.get(&code_hash)
|
||||
.ok_or_else(|| Error::MissingCode(vec![first_with])));
|
||||
|
||||
// and write it again under a different mangled key
|
||||
AccountDBMut::from_hash(db, hash).emplace(code_hash, code);
|
||||
}
|
||||
// if not, queue it up to be filled later
|
||||
None => status.missing_code.push((hash, code_hash)),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
//! State snapshotting tests.
|
||||
|
||||
use snapshot::{chunk_state, Progress, StateRebuilder};
|
||||
use snapshot::account::Account;
|
||||
use snapshot::io::{PackedReader, PackedWriter, SnapshotReader, SnapshotWriter};
|
||||
use super::helpers::{compare_dbs, StateProducer};
|
||||
|
||||
@@ -28,6 +29,8 @@ use util::memorydb::MemoryDB;
|
||||
use util::Mutex;
|
||||
use devtools::RandomTempPath;
|
||||
|
||||
use util::sha3::SHA3_NULL_RLP;
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
#[test]
|
||||
@@ -82,3 +85,54 @@ fn snap_and_restore() {
|
||||
|
||||
compare_dbs(&old_db, new_db.as_hashdb());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn get_code_from_prev_chunk() {
|
||||
use std::collections::HashSet;
|
||||
use rlp::{RlpStream, Stream};
|
||||
use util::{HashDB, H256, FixedHash, U256, Hashable};
|
||||
|
||||
use account_db::{AccountDBMut, AccountDB};
|
||||
|
||||
let code = b"this is definitely code";
|
||||
let mut used_code = HashSet::new();
|
||||
let mut acc_stream = RlpStream::new_list(4);
|
||||
acc_stream.append(&U256::default())
|
||||
.append(&U256::default())
|
||||
.append(&SHA3_NULL_RLP)
|
||||
.append(&code.sha3());
|
||||
|
||||
let (h1, h2) = (H256::random(), H256::random());
|
||||
|
||||
// two accounts with the same code, one per chunk.
|
||||
// first one will have code inlined,
|
||||
// second will just have its hash.
|
||||
let thin_rlp = acc_stream.out();
|
||||
let acc1 = Account::from_thin_rlp(&thin_rlp);
|
||||
let acc2 = Account::from_thin_rlp(&thin_rlp);
|
||||
|
||||
let mut make_chunk = |acc: Account, hash| {
|
||||
let mut db = MemoryDB::new();
|
||||
AccountDBMut::from_hash(&mut db, hash).insert(&code[..]);
|
||||
|
||||
let fat_rlp = acc.to_fat_rlp(&AccountDB::from_hash(&db, hash), &mut used_code).unwrap();
|
||||
|
||||
let mut stream = RlpStream::new_list(1);
|
||||
stream.begin_list(2).append(&hash).append_raw(&fat_rlp, 1);
|
||||
stream.out()
|
||||
};
|
||||
|
||||
let chunk1 = make_chunk(acc1, h1);
|
||||
let chunk2 = make_chunk(acc2, h2);
|
||||
|
||||
let db_path = RandomTempPath::create_dir();
|
||||
let db_cfg = DatabaseConfig::with_columns(::db::NUM_COLUMNS);
|
||||
let new_db = Arc::new(Database::open(&db_cfg, &db_path.to_string_lossy()).unwrap());
|
||||
|
||||
let mut rebuilder = StateRebuilder::new(new_db, Algorithm::Archive);
|
||||
|
||||
rebuilder.feed(&chunk1).unwrap();
|
||||
rebuilder.feed(&chunk2).unwrap();
|
||||
|
||||
rebuilder.check_missing().unwrap();
|
||||
}
|
||||
@@ -93,6 +93,10 @@ pub struct RichReceipt {
|
||||
pub contract_address: Option<Address>,
|
||||
/// Logs
|
||||
pub logs: Vec<LogEntry>,
|
||||
/// Logs bloom
|
||||
pub log_bloom: LogBloom,
|
||||
/// State root
|
||||
pub state_root: H256,
|
||||
}
|
||||
|
||||
/// Receipt with additional info.
|
||||
@@ -114,6 +118,10 @@ pub struct LocalizedReceipt {
|
||||
pub contract_address: Option<Address>,
|
||||
/// Logs
|
||||
pub logs: Vec<LocalizedLogEntry>,
|
||||
/// Logs bloom
|
||||
pub log_bloom: LogBloom,
|
||||
/// State root
|
||||
pub state_root: H256,
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -70,7 +70,8 @@ export default class AccountSelector extends Component {
|
||||
static propTypes = {
|
||||
list: PropTypes.array.isRequired,
|
||||
selected: PropTypes.object.isRequired,
|
||||
handleSetSelected: PropTypes.func.isRequired
|
||||
handleSetSelected: PropTypes.func.isRequired,
|
||||
onAccountChange: PropTypes.func
|
||||
};
|
||||
|
||||
state = {
|
||||
@@ -85,7 +86,8 @@ export default class AccountSelector extends Component {
|
||||
nestedItems={ nestedAccounts }
|
||||
open={ this.state.open }
|
||||
onSelectAccount={ this.onToggleOpen }
|
||||
autoGenerateNestedIndicator={ false } />
|
||||
autoGenerateNestedIndicator={ false }
|
||||
nestedListStyle={ { maxHeight: '14em', overflow: 'auto' } } />
|
||||
);
|
||||
|
||||
return (
|
||||
@@ -110,6 +112,10 @@ export default class AccountSelector extends Component {
|
||||
|
||||
onToggleOpen = () => {
|
||||
this.setState({ open: !this.state.open });
|
||||
|
||||
if (typeof this.props.onAccountChange === 'function') {
|
||||
this.props.onAccountChange();
|
||||
}
|
||||
}
|
||||
|
||||
onSelectAccount = (address) => {
|
||||
|
||||
@@ -21,7 +21,7 @@ import { Dialog, FlatButton } from 'material-ui';
|
||||
import AccountSelector from '../../Accounts/AccountSelector';
|
||||
import InputText from '../../Inputs/Text';
|
||||
|
||||
import { TOKEN_ADDRESS_TYPE, TLA_TYPE, UINT_TYPE, STRING_TYPE } from '../../Inputs/validation';
|
||||
import { TOKEN_ADDRESS_TYPE, TLA_TYPE, DECIMAL_TYPE, STRING_TYPE } from '../../Inputs/validation';
|
||||
|
||||
import styles from '../actions.css';
|
||||
|
||||
@@ -41,11 +41,11 @@ const initState = {
|
||||
floatingLabelText: 'Token TLA',
|
||||
hintText: 'The token short name (3 characters)'
|
||||
},
|
||||
base: {
|
||||
decimals: {
|
||||
...defaultField,
|
||||
type: UINT_TYPE,
|
||||
floatingLabelText: 'Token Base',
|
||||
hintText: 'The token precision'
|
||||
type: DECIMAL_TYPE,
|
||||
floatingLabelText: 'Token Decimals',
|
||||
hintText: 'The number of decimals (0-18)'
|
||||
},
|
||||
name: {
|
||||
...defaultField,
|
||||
@@ -81,6 +81,7 @@ export default class RegisterAction extends Component {
|
||||
className={ styles.dialog }
|
||||
onRequestClose={ this.onClose }
|
||||
actions={ this.renderActions() }
|
||||
ref='dialog'
|
||||
autoScrollBodyContent
|
||||
>
|
||||
{ this.renderContent() }
|
||||
@@ -149,7 +150,9 @@ export default class RegisterAction extends Component {
|
||||
renderForm () {
|
||||
return (
|
||||
<div>
|
||||
<AccountSelector />
|
||||
<AccountSelector
|
||||
onAccountChange={ this.onAccountChange }
|
||||
/>
|
||||
{ this.renderInputs() }
|
||||
</div>
|
||||
);
|
||||
@@ -175,6 +178,11 @@ export default class RegisterAction extends Component {
|
||||
});
|
||||
}
|
||||
|
||||
onAccountChange = () => {
|
||||
const { dialog } = this.refs;
|
||||
dialog.forceUpdate();
|
||||
}
|
||||
|
||||
onChange (fieldKey, valid, value) {
|
||||
const { fields } = this.state;
|
||||
const field = fields[fieldKey];
|
||||
|
||||
@@ -47,7 +47,8 @@ export const registerToken = (tokenData) => (dispatch, getState) => {
|
||||
const contractInstance = state.status.contract.instance;
|
||||
const fee = state.status.contract.fee;
|
||||
|
||||
const { address, base, name, tla } = tokenData;
|
||||
const { address, decimals, name, tla } = tokenData;
|
||||
const base = Math.pow(10, decimals);
|
||||
|
||||
dispatch(setRegisterSending(true));
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@ export const SIMPLE_TOKEN_ADDRESS_TYPE = 'SIMPLE_TOKEN_ADDRESS_TYPE';
|
||||
export const TLA_TYPE = 'TLA_TYPE';
|
||||
export const SIMPLE_TLA_TYPE = 'SIMPLE_TLA_TYPE';
|
||||
export const UINT_TYPE = 'UINT_TYPE';
|
||||
export const DECIMAL_TYPE = 'DECIMAL_TYPE';
|
||||
export const STRING_TYPE = 'STRING_TYPE';
|
||||
export const HEX_TYPE = 'HEX_TYPE';
|
||||
export const URL_TYPE = 'URL_TYPE';
|
||||
@@ -39,6 +40,7 @@ export const URL_TYPE = 'URL_TYPE';
|
||||
export const ERRORS = {
|
||||
invalidTLA: 'The TLA should be 3 characters long',
|
||||
invalidUint: 'Please enter a non-negative integer',
|
||||
invalidDecimal: 'Please enter a value between 0 and 18',
|
||||
invalidString: 'Please enter at least a character',
|
||||
invalidAccount: 'Please select an account to transact with',
|
||||
invalidRecipient: 'Please select an account to send to',
|
||||
@@ -75,7 +77,7 @@ const validateTokenAddress = (address, contract, simple) => {
|
||||
|
||||
return getTokenTotalSupply(address)
|
||||
.then(balance => {
|
||||
if (balance === null) {
|
||||
if (balance === null || balance.equals(0)) {
|
||||
return {
|
||||
error: ERRORS.invalidTokenAddress,
|
||||
valid: false
|
||||
@@ -152,6 +154,21 @@ const validateUint = (uint) => {
|
||||
};
|
||||
};
|
||||
|
||||
const validateDecimal = (decimal) => {
|
||||
if (!/^\d+$/.test(decimal) || parseInt(decimal) < 0 || parseInt(decimal) > 18) {
|
||||
return {
|
||||
error: ERRORS.invalidDecimal,
|
||||
valid: false
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
value: parseInt(decimal),
|
||||
error: null,
|
||||
valid: true
|
||||
};
|
||||
};
|
||||
|
||||
const validateString = (string) => {
|
||||
if (string.toString().length === 0) {
|
||||
return {
|
||||
@@ -204,6 +221,7 @@ export const validate = (value, type, contract) => {
|
||||
if (type === TLA_TYPE) return validateTLA(value, contract);
|
||||
if (type === SIMPLE_TLA_TYPE) return validateTLA(value, contract, true);
|
||||
if (type === UINT_TYPE) return validateUint(value);
|
||||
if (type === DECIMAL_TYPE) return validateDecimal(value);
|
||||
if (type === STRING_TYPE) return validateString(value);
|
||||
if (type === HEX_TYPE) return validateHex(value);
|
||||
if (type === URL_TYPE) return validateURL(value);
|
||||
|
||||
@@ -57,6 +57,7 @@ export default class Token extends Component {
|
||||
isLoading: PropTypes.bool,
|
||||
isPending: PropTypes.bool,
|
||||
isTokenOwner: PropTypes.bool.isRequired,
|
||||
isContractOwner: PropTypes.bool.isRequired,
|
||||
|
||||
fullWidth: PropTypes.bool
|
||||
};
|
||||
@@ -151,8 +152,8 @@ export default class Token extends Component {
|
||||
if (!base || base < 0) return null;
|
||||
return (
|
||||
<Chip
|
||||
value={ base.toString() }
|
||||
label='Base' />
|
||||
value={ Math.log10(base).toString() }
|
||||
label='Decimals' />
|
||||
);
|
||||
}
|
||||
|
||||
@@ -220,7 +221,7 @@ export default class Token extends Component {
|
||||
}
|
||||
|
||||
renderUnregister () {
|
||||
if (!this.props.isTokenOwner) {
|
||||
if (!this.props.isContractOwner) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ export default class Tokens extends Component {
|
||||
}
|
||||
|
||||
renderTokens (tokens) {
|
||||
const { accounts } = this.props;
|
||||
const { accounts, isOwner } = this.props;
|
||||
|
||||
return tokens.map((token, index) => {
|
||||
if (!token || !token.tla) {
|
||||
@@ -61,7 +61,8 @@ export default class Tokens extends Component {
|
||||
handleMetaLookup={ this.props.handleMetaLookup }
|
||||
handleAddMeta={ this.props.handleAddMeta }
|
||||
key={ index }
|
||||
isTokenOwner={ isTokenOwner } />
|
||||
isTokenOwner={ isTokenOwner }
|
||||
isContractOwner={ isOwner } />
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -314,7 +314,7 @@ export default class Transfer extends Component {
|
||||
}
|
||||
|
||||
const token = balance.tokens.find((balance) => balance.token.tag === tag).token;
|
||||
const s = new BigNumber(num).mul(token.format || 1).toString();
|
||||
const s = new BigNumber(num).mul(token.format || 1).toFixed();
|
||||
|
||||
if (s.indexOf('.') !== -1) {
|
||||
return ERRORS.invalidDecimals;
|
||||
@@ -516,6 +516,13 @@ export default class Transfer extends Component {
|
||||
}
|
||||
|
||||
recalculateGas = () => {
|
||||
if (!this.isValid()) {
|
||||
this.setState({
|
||||
gas: '0'
|
||||
}, this.recalculate);
|
||||
return;
|
||||
}
|
||||
|
||||
(this.state.isEth
|
||||
? this._estimateGasEth()
|
||||
: this._estimateGasToken()
|
||||
|
||||
43
js/src/views/Dapps/builtin.json
Normal file
43
js/src/views/Dapps/builtin.json
Normal file
@@ -0,0 +1,43 @@
|
||||
[
|
||||
{
|
||||
"id": "0xf9f2d620c2e08f83e45555247146c62185e4ab7cf82a4b9002a265a0d020348f",
|
||||
"url": "basiccoin",
|
||||
"name": "Token Deployment",
|
||||
"description": "Deploy new basic tokens that you are able to send around",
|
||||
"author": "Parity Team <admin@ethcore.io>",
|
||||
"version": "1.0.0"
|
||||
},
|
||||
{
|
||||
"id": "0xd1adaede68d344519025e2ff574650cd99d3830fe6d274c7a7843cdc00e17938",
|
||||
"url": "registry",
|
||||
"name": "Registry",
|
||||
"description": "A global registry of addresses on the network",
|
||||
"author": "Parity Team <admin@ethcore.io>",
|
||||
"version": "1.0.0"
|
||||
},
|
||||
{
|
||||
"id": "0x0a8048117e51e964628d0f2d26342b3cd915248b59bcce2721e1d05f5cfa2208",
|
||||
"url": "tokenreg",
|
||||
"name": "Token Registry",
|
||||
"description": "A registry of transactable tokens on the network",
|
||||
"author": "Parity Team <admin@ethcore.io>",
|
||||
"version": "1.0.0"
|
||||
},
|
||||
{
|
||||
"id": "0xf49089046f53f5d2e5f3513c1c32f5ff57d986e46309a42d2b249070e4e72c46",
|
||||
"url": "signaturereg",
|
||||
"name": "Method Registry",
|
||||
"description": "A registry of method signatures for lookups on transactions",
|
||||
"author": "Parity Team <admin@ethcore.io>",
|
||||
"version": "1.0.0"
|
||||
},
|
||||
{
|
||||
"id": "0x058740ee9a5a3fb9f1cfa10752baec87e09cc45cd7027fd54708271aca300c75",
|
||||
"url": "githubhint",
|
||||
"name": "GitHub Hint",
|
||||
"description": "A mapping of GitHub URLs to hashes for use in contracts as references",
|
||||
"author": "Parity Team <admin@ethcore.io>",
|
||||
"version": "1.0.0",
|
||||
"secure": true
|
||||
}
|
||||
]
|
||||
@@ -14,69 +14,39 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import { action, computed, observable } from 'mobx';
|
||||
import { action, computed, observable, transaction } from 'mobx';
|
||||
|
||||
import Contracts from '../../contracts';
|
||||
import { hashToImageUrl } from '../../redux/util';
|
||||
|
||||
const builtinApps = [
|
||||
{
|
||||
id: '0xf9f2d620c2e08f83e45555247146c62185e4ab7cf82a4b9002a265a0d020348f',
|
||||
url: 'basiccoin',
|
||||
name: 'Token Deployment',
|
||||
description: 'Deploy new basic tokens that you are able to send around',
|
||||
author: 'Parity Team <admin@ethcore.io>',
|
||||
version: '1.0.0'
|
||||
},
|
||||
{
|
||||
id: '0xd1adaede68d344519025e2ff574650cd99d3830fe6d274c7a7843cdc00e17938',
|
||||
url: 'registry',
|
||||
name: 'Registry',
|
||||
description: 'A global registry of addresses on the network',
|
||||
author: 'Parity Team <admin@ethcore.io>',
|
||||
version: '1.0.0'
|
||||
},
|
||||
{
|
||||
id: '0x0a8048117e51e964628d0f2d26342b3cd915248b59bcce2721e1d05f5cfa2208',
|
||||
url: 'tokenreg',
|
||||
name: 'Token Registry',
|
||||
description: 'A registry of transactable tokens on the network',
|
||||
author: 'Parity Team <admin@ethcore.io>',
|
||||
version: '1.0.0'
|
||||
},
|
||||
{
|
||||
id: '0xf49089046f53f5d2e5f3513c1c32f5ff57d986e46309a42d2b249070e4e72c46',
|
||||
url: 'signaturereg',
|
||||
name: 'Method Registry',
|
||||
description: 'A registry of method signatures for lookups on transactions',
|
||||
author: 'Parity Team <admin@ethcore.io>',
|
||||
version: '1.0.0'
|
||||
},
|
||||
{
|
||||
id: '0x058740ee9a5a3fb9f1cfa10752baec87e09cc45cd7027fd54708271aca300c75',
|
||||
url: 'githubhint',
|
||||
name: 'GitHub Hint',
|
||||
description: 'A mapping of GitHub URLs to hashes for use in contracts as references',
|
||||
author: 'Parity Team <admin@ethcore.io>',
|
||||
version: '1.0.0',
|
||||
secure: true
|
||||
}
|
||||
];
|
||||
import builtinApps from './builtin.json';
|
||||
|
||||
const LS_KEY_HIDDEN = 'hiddenApps';
|
||||
const LS_KEY_EXTERNAL = 'externalApps';
|
||||
|
||||
export default class DappsStore {
|
||||
@observable apps = [];
|
||||
@observable hidden = [];
|
||||
@observable externalApps = [];
|
||||
@observable hiddenApps = [];
|
||||
@observable modalOpen = false;
|
||||
|
||||
constructor (api) {
|
||||
this._api = api;
|
||||
|
||||
this._readHiddenApps();
|
||||
this._fetch();
|
||||
this._readExternalApps();
|
||||
|
||||
this._fetchBuiltinApps();
|
||||
this._fetchLocalApps();
|
||||
this._fetchRegistryApps();
|
||||
}
|
||||
|
||||
@computed get visible () {
|
||||
return this.apps.filter((app) => !this.hidden.includes(app.id));
|
||||
return this.apps
|
||||
.filter((app) => {
|
||||
return this.externalApps.includes(app.id) || !this.hiddenApps.includes(app.id);
|
||||
})
|
||||
.sort((a, b) => a.name.localeCompare(b.name));
|
||||
}
|
||||
|
||||
@action openModal = () => {
|
||||
@@ -88,12 +58,12 @@ export default class DappsStore {
|
||||
}
|
||||
|
||||
@action hideApp = (id) => {
|
||||
this.hidden = this.hidden.concat(id);
|
||||
this.hiddenApps = this.hiddenApps.concat(id);
|
||||
this._writeHiddenApps();
|
||||
}
|
||||
|
||||
@action showApp = (id) => {
|
||||
this.hidden = this.hidden.filter((_id) => _id !== id);
|
||||
this.hiddenApps = this.hiddenApps.filter((_id) => _id !== id);
|
||||
this._writeHiddenApps();
|
||||
}
|
||||
|
||||
@@ -103,25 +73,48 @@ export default class DappsStore {
|
||||
: '';
|
||||
}
|
||||
|
||||
_fetch () {
|
||||
Promise
|
||||
.all([
|
||||
this._fetchLocal(),
|
||||
this._fetchRegistry()
|
||||
])
|
||||
.then(([localApps, registryApps]) => {
|
||||
this.apps = []
|
||||
.concat(localApps)
|
||||
.concat(registryApps)
|
||||
.filter((app) => app.id)
|
||||
.sort((a, b) => (a.name || '').localeCompare(b.name || ''));
|
||||
})
|
||||
.catch((error) => {
|
||||
console.warn('DappStore:fetch', error);
|
||||
_fetchBuiltinApps () {
|
||||
const { dappReg } = Contracts.get();
|
||||
|
||||
return Promise
|
||||
.all(builtinApps.map((app) => dappReg.getImage(app.id)))
|
||||
.then((imageIds) => {
|
||||
transaction(() => {
|
||||
builtinApps.forEach((app, index) => {
|
||||
app.type = 'builtin';
|
||||
app.image = hashToImageUrl(imageIds[index]);
|
||||
this.apps.push(app);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
_fetchRegistry () {
|
||||
_fetchLocalApps () {
|
||||
return fetch(`${this._getHost()}/api/apps`)
|
||||
.then((response) => {
|
||||
return response.ok
|
||||
? response.json()
|
||||
: [];
|
||||
})
|
||||
.then((apps) => {
|
||||
return apps
|
||||
.map((app) => {
|
||||
app.type = 'local';
|
||||
return app;
|
||||
})
|
||||
.filter((app) => app.id && !['ui'].includes(app.id));
|
||||
})
|
||||
.then((apps) => {
|
||||
transaction(() => {
|
||||
(apps || []).forEach((app) => this.apps.push(app));
|
||||
});
|
||||
})
|
||||
.catch((error) => {
|
||||
console.warn('DappsStore:fetchLocal', error);
|
||||
});
|
||||
}
|
||||
|
||||
_fetchRegistryApps () {
|
||||
const { dappReg } = Contracts.get();
|
||||
|
||||
return dappReg
|
||||
@@ -137,9 +130,9 @@ export default class DappsStore {
|
||||
return Promise.all(promises);
|
||||
})
|
||||
.then((appsInfo) => {
|
||||
const appIds = appsInfo.map(([appId, owner]) => {
|
||||
return this._api.util.bytesToHex(appId);
|
||||
});
|
||||
const appIds = appsInfo
|
||||
.map(([appId, owner]) => this._api.util.bytesToHex(appId))
|
||||
.filter((appId) => !builtinApps.find((app) => app.id === appId));
|
||||
|
||||
return Promise
|
||||
.all([
|
||||
@@ -149,27 +142,21 @@ export default class DappsStore {
|
||||
])
|
||||
.then(([imageIds, contentIds, manifestIds]) => {
|
||||
return appIds.map((appId, index) => {
|
||||
const app = builtinApps.find((ba) => ba.id === appId) || {
|
||||
const app = {
|
||||
id: appId,
|
||||
image: hashToImageUrl(imageIds[index]),
|
||||
contentHash: this._api.util.bytesToHex(contentIds[index]).substr(2),
|
||||
manifestHash: this._api.util.bytesToHex(manifestIds[index]).substr(2),
|
||||
type: 'network'
|
||||
};
|
||||
|
||||
app.image = hashToImageUrl(imageIds[index]);
|
||||
app.type = app.type || 'builtin';
|
||||
|
||||
return app;
|
||||
});
|
||||
});
|
||||
})
|
||||
.then((apps) => {
|
||||
return Promise
|
||||
.all(apps.map((app) => {
|
||||
return app.manifestHash
|
||||
? this._fetchManifest(app.manifestHash)
|
||||
: null;
|
||||
}))
|
||||
.all(apps.map((app) => this._fetchManifest(app.manifestHash)))
|
||||
.then((manifests) => {
|
||||
return apps.map((app, index) => {
|
||||
const manifest = manifests[index];
|
||||
@@ -177,7 +164,7 @@ export default class DappsStore {
|
||||
if (manifest) {
|
||||
app.manifestHash = null;
|
||||
Object.keys(manifest)
|
||||
.filter((key) => key !== 'id')
|
||||
.filter((key) => ['author', 'description', 'name', 'version'].includes(key))
|
||||
.forEach((key) => {
|
||||
app[key] = manifest[key];
|
||||
});
|
||||
@@ -192,6 +179,11 @@ export default class DappsStore {
|
||||
});
|
||||
});
|
||||
})
|
||||
.then((apps) => {
|
||||
transaction(() => {
|
||||
(apps || []).forEach((app) => this.apps.push(app));
|
||||
});
|
||||
})
|
||||
.catch((error) => {
|
||||
console.warn('DappsStore:fetchRegistry', error);
|
||||
});
|
||||
@@ -210,39 +202,43 @@ export default class DappsStore {
|
||||
});
|
||||
}
|
||||
|
||||
_fetchLocal () {
|
||||
return fetch(`${this._getHost()}/api/apps`)
|
||||
.then((response) => {
|
||||
return response.ok
|
||||
? response.json()
|
||||
: [];
|
||||
})
|
||||
.then((localApps) => {
|
||||
return localApps
|
||||
.filter((app) => app && app.id && !['ui'].includes(app.id))
|
||||
.map((app) => {
|
||||
app.type = 'local';
|
||||
return app;
|
||||
});
|
||||
})
|
||||
.catch((error) => {
|
||||
console.warn('DappsStore:fetchLocal', error);
|
||||
});
|
||||
}
|
||||
|
||||
_readHiddenApps () {
|
||||
const stored = localStorage.getItem('hiddenApps');
|
||||
const stored = localStorage.getItem(LS_KEY_HIDDEN);
|
||||
|
||||
if (stored) {
|
||||
try {
|
||||
this.hidden = JSON.parse(stored);
|
||||
this.hiddenApps = JSON.parse(stored);
|
||||
} catch (error) {
|
||||
console.warn('DappsStore:readHiddenApps', error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_readExternalApps () {
|
||||
const stored = localStorage.getItem(LS_KEY_EXTERNAL);
|
||||
|
||||
if (stored) {
|
||||
try {
|
||||
this.externalApps = JSON.parse(stored);
|
||||
} catch (error) {
|
||||
console.warn('DappsStore:readExternalApps', error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_writeExternalApps () {
|
||||
try {
|
||||
localStorage.setItem(LS_KEY_EXTERNAL, JSON.stringify(this.externalApps));
|
||||
} catch (error) {
|
||||
console.error('DappsStore:writeExternalApps', error);
|
||||
}
|
||||
}
|
||||
|
||||
_writeHiddenApps () {
|
||||
localStorage.setItem('hiddenApps', JSON.stringify(this.hidden));
|
||||
try {
|
||||
localStorage.setItem(LS_KEY_HIDDEN, JSON.stringify(this.hiddenApps));
|
||||
} catch (error) {
|
||||
console.error('DappsStore:writeHiddenApps', error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,6 +85,10 @@ pub struct EthashParams {
|
||||
/// See main EthashParams docs.
|
||||
#[serde(rename="eip161dTransition")]
|
||||
pub eip161d_transition: Option<Uint>,
|
||||
|
||||
/// See main EthashParams docs.
|
||||
#[serde(rename="maxCodeSize")]
|
||||
pub max_code_size: Option<Uint>,
|
||||
}
|
||||
|
||||
/// Ethash engine deserialization.
|
||||
|
||||
@@ -578,7 +578,7 @@
|
||||
<key>OVERWRITE_PERMISSIONS</key>
|
||||
<false/>
|
||||
<key>VERSION</key>
|
||||
<string>1.4.2</string>
|
||||
<string>1.4.3</string>
|
||||
</dict>
|
||||
<key>UUID</key>
|
||||
<string>2DCD5B81-7BAF-4DA1-9251-6274B089FD36</string>
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
!define DESCRIPTION "Fast, light, robust Ethereum implementation"
|
||||
!define VERSIONMAJOR 1
|
||||
!define VERSIONMINOR 4
|
||||
!define VERSIONBUILD 2
|
||||
!define VERSIONBUILD 3
|
||||
!define ARGS "--warp"
|
||||
!define FIRST_START_ARGS "ui --warp --mode=passive"
|
||||
|
||||
|
||||
@@ -15,9 +15,8 @@
|
||||
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use std::{io, env};
|
||||
use std::io::{Write, Read, BufReader, BufRead};
|
||||
use std::io::{Write, BufReader, BufRead};
|
||||
use std::time::Duration;
|
||||
use std::path::Path;
|
||||
use std::fs::File;
|
||||
use util::{clean_0x, U256, Uint, Address, path, CompactionProfile};
|
||||
use util::journaldb::Algorithm;
|
||||
@@ -299,13 +298,11 @@ pub fn password_prompt() -> Result<String, String> {
|
||||
}
|
||||
|
||||
/// Read a password from password file.
|
||||
pub fn password_from_file<P>(path: P) -> Result<String, String> where P: AsRef<Path> {
|
||||
let mut file = try!(File::open(path).map_err(|_| "Unable to open password file."));
|
||||
let mut file_content = String::new();
|
||||
match file.read_to_string(&mut file_content) {
|
||||
Ok(_) => Ok(file_content.trim().into()),
|
||||
Err(_) => Err("Unable to read password file.".into()),
|
||||
}
|
||||
pub fn password_from_file(path: String) -> Result<String, String> {
|
||||
let passwords = try!(passwords_from_files(vec![path]));
|
||||
// use only first password from the file
|
||||
passwords.get(0).map(String::to_owned)
|
||||
.ok_or_else(|| "Password file seems to be empty.".to_owned())
|
||||
}
|
||||
|
||||
/// Reads passwords from files. Treats each line as a separate password.
|
||||
@@ -314,10 +311,11 @@ pub fn passwords_from_files(files: Vec<String>) -> Result<Vec<String>, String> {
|
||||
let file = try!(File::open(filename).map_err(|_| format!("{} Unable to read password file. Ensure it exists and permissions are correct.", filename)));
|
||||
let reader = BufReader::new(&file);
|
||||
let lines = reader.lines()
|
||||
.map(|l| l.unwrap())
|
||||
.filter_map(|l| l.ok())
|
||||
.map(|pwd| pwd.trim().to_owned())
|
||||
.collect::<Vec<String>>();
|
||||
Ok(lines)
|
||||
}).collect::<Result<Vec<Vec<String>>, String>>();
|
||||
}).collect::<Result<Vec<Vec<String>>, String>>();
|
||||
Ok(try!(passwords).into_iter().flat_map(|x| x).collect())
|
||||
}
|
||||
|
||||
@@ -418,7 +416,20 @@ mod tests {
|
||||
let path = RandomTempPath::new();
|
||||
let mut file = File::create(path.as_path()).unwrap();
|
||||
file.write_all(b"a bc ").unwrap();
|
||||
assert_eq!(password_from_file(path).unwrap().as_bytes(), b"a bc");
|
||||
assert_eq!(password_from_file(path.as_str().into()).unwrap().as_bytes(), b"a bc");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_password_multiline() {
|
||||
let path = RandomTempPath::new();
|
||||
let mut file = File::create(path.as_path()).unwrap();
|
||||
file.write_all(br#" password with trailing whitespace
|
||||
those passwords should be
|
||||
ignored
|
||||
but the first password is trimmed
|
||||
|
||||
"#).unwrap();
|
||||
assert_eq!(&password_from_file(path.as_str().into()).unwrap(), "password with trailing whitespace");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -209,6 +209,8 @@ impl MinerService for TestMinerService {
|
||||
gas_used: r.gas_used.clone(),
|
||||
contract_address: None,
|
||||
logs: r.logs.clone(),
|
||||
log_bloom: r.log_bloom,
|
||||
state_root: r.state_root,
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
@@ -485,7 +485,7 @@ fn rpc_eth_pending_transaction_by_hash() {
|
||||
tester.miner.pending_transactions.lock().insert(H256::zero(), tx);
|
||||
}
|
||||
|
||||
let response = r#"{"jsonrpc":"2.0","result":{"blockHash":null,"blockNumber":null,"creates":null,"from":"0x0f65fe9276bc9a24ae7083ae28e2660ef72df99e","gas":"0x5208","gasPrice":"0x1","hash":"0x41df922fd0d4766fcc02e161f8295ec28522f329ae487f14d811e4b64c8d6e31","input":"0x","nonce":"0x0","publicKey":"0x7ae46da747962c2ee46825839c1ef9298e3bd2e70ca2938495c3693a485ec3eaa8f196327881090ff64cf4fbb0a48485d4f83098e189ed3b7a87d5941b59f789","raw":"0xf85f800182520894095e7baea6a6c7c4c2dfeb977efac326af552d870a801ba048b55bfa915ac795c431978d8a6a992b628d557da5ff759b307d495a36649353a0efffd310ac743f371de3b9f7f9cb56c0b28ad43601b4ab949f53faa07bd2c804","to":"0x095e7baea6a6c7c4c2dfeb977efac326af552d87","transactionIndex":null,"value":"0xa"},"id":1}"#;
|
||||
let response = r#"{"jsonrpc":"2.0","result":{"blockHash":null,"blockNumber":null,"creates":null,"from":"0x0f65fe9276bc9a24ae7083ae28e2660ef72df99e","gas":"0x5208","gasPrice":"0x1","hash":"0x41df922fd0d4766fcc02e161f8295ec28522f329ae487f14d811e4b64c8d6e31","input":"0x","nonce":"0x0","publicKey":"0x7ae46da747962c2ee46825839c1ef9298e3bd2e70ca2938495c3693a485ec3eaa8f196327881090ff64cf4fbb0a48485d4f83098e189ed3b7a87d5941b59f789","r":"0x48b55bfa915ac795c431978d8a6a992b628d557da5ff759b307d495a36649353","raw":"0xf85f800182520894095e7baea6a6c7c4c2dfeb977efac326af552d870a801ba048b55bfa915ac795c431978d8a6a992b628d557da5ff759b307d495a36649353a0efffd310ac743f371de3b9f7f9cb56c0b28ad43601b4ab949f53faa07bd2c804","s":"0xefffd310ac743f371de3b9f7f9cb56c0b28ad43601b4ab949f53faa07bd2c804","to":"0x095e7baea6a6c7c4c2dfeb977efac326af552d87","transactionIndex":null,"v":0,"value":"0xa"},"id":1}"#;
|
||||
let request = r#"{
|
||||
"jsonrpc": "2.0",
|
||||
"method": "eth_getTransactionByHash",
|
||||
@@ -879,7 +879,9 @@ fn rpc_eth_transaction_receipt() {
|
||||
transaction_hash: H256::new(),
|
||||
transaction_index: 0,
|
||||
log_index: 1,
|
||||
}]
|
||||
}],
|
||||
log_bloom: 0.into(),
|
||||
state_root: 0.into(),
|
||||
};
|
||||
|
||||
let hash = H256::from_str("b903239f8543d04b5dc1ba6579132b143087c68db1b2168786408fcbce568238").unwrap();
|
||||
@@ -892,7 +894,7 @@ fn rpc_eth_transaction_receipt() {
|
||||
"params": ["0xb903239f8543d04b5dc1ba6579132b143087c68db1b2168786408fcbce568238"],
|
||||
"id": 1
|
||||
}"#;
|
||||
let response = r#"{"jsonrpc":"2.0","result":{"blockHash":"0xed76641c68a1c641aee09a94b3b471f4dc0316efe5ac19cf488e2674cf8d05b5","blockNumber":"0x4510c","contractAddress":null,"cumulativeGasUsed":"0x20","gasUsed":"0x10","logs":[{"address":"0x33990122638b9132ca29c723bdf037f1a891a70c","blockHash":"0xed76641c68a1c641aee09a94b3b471f4dc0316efe5ac19cf488e2674cf8d05b5","blockNumber":"0x4510c","data":"0x","logIndex":"0x1","topics":["0xa6697e974e6a320f454390be03f74955e8978f1a6971ea6730542e37b66179bc","0x4861736852656700000000000000000000000000000000000000000000000000"],"transactionHash":"0x0000000000000000000000000000000000000000000000000000000000000000","transactionIndex":"0x0","type":"mined"}],"transactionHash":"0x0000000000000000000000000000000000000000000000000000000000000000","transactionIndex":"0x0"},"id":1}"#;
|
||||
let response = r#"{"jsonrpc":"2.0","result":{"blockHash":"0xed76641c68a1c641aee09a94b3b471f4dc0316efe5ac19cf488e2674cf8d05b5","blockNumber":"0x4510c","contractAddress":null,"cumulativeGasUsed":"0x20","gasUsed":"0x10","logs":[{"address":"0x33990122638b9132ca29c723bdf037f1a891a70c","blockHash":"0xed76641c68a1c641aee09a94b3b471f4dc0316efe5ac19cf488e2674cf8d05b5","blockNumber":"0x4510c","data":"0x","logIndex":"0x1","topics":["0xa6697e974e6a320f454390be03f74955e8978f1a6971ea6730542e37b66179bc","0x4861736852656700000000000000000000000000000000000000000000000000"],"transactionHash":"0x0000000000000000000000000000000000000000000000000000000000000000","transactionIndex":"0x0","type":"mined"}],"logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","root":"0x0000000000000000000000000000000000000000000000000000000000000000","transactionHash":"0x0000000000000000000000000000000000000000000000000000000000000000","transactionIndex":"0x0"},"id":1}"#;
|
||||
|
||||
assert_eq!(tester.io.handle_request_sync(request), Some(response.to_owned()));
|
||||
}
|
||||
|
||||
@@ -139,7 +139,7 @@ mod tests {
|
||||
fn test_serialize_block_transactions() {
|
||||
let t = BlockTransactions::Full(vec![Transaction::default()]);
|
||||
let serialized = serde_json::to_string(&t).unwrap();
|
||||
assert_eq!(serialized, r#"[{"hash":"0x0000000000000000000000000000000000000000000000000000000000000000","nonce":"0x0","blockHash":null,"blockNumber":null,"transactionIndex":null,"from":"0x0000000000000000000000000000000000000000","to":null,"value":"0x0","gasPrice":"0x0","gas":"0x0","input":"0x","creates":null,"raw":"0x","publicKey":null}]"#);
|
||||
assert_eq!(serialized, r#"[{"hash":"0x0000000000000000000000000000000000000000000000000000000000000000","nonce":"0x0","blockHash":null,"blockNumber":null,"transactionIndex":null,"from":"0x0000000000000000000000000000000000000000","to":null,"value":"0x0","gasPrice":"0x0","gas":"0x0","input":"0x","creates":null,"raw":"0x","publicKey":null,"v":0,"r":"0x0000000000000000000000000000000000000000000000000000000000000000","s":"0x0000000000000000000000000000000000000000000000000000000000000000"}]"#);
|
||||
|
||||
let t = BlockTransactions::Hashes(vec![H256::default().into()]);
|
||||
let serialized = serde_json::to_string(&t).unwrap();
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use v1::types::{Log, H160, H256, U256};
|
||||
use v1::types::{Log, H160, H256, H2048, U256};
|
||||
use ethcore::receipt::{Receipt as EthReceipt, RichReceipt, LocalizedReceipt};
|
||||
|
||||
/// Receipt
|
||||
@@ -43,6 +43,12 @@ pub struct Receipt {
|
||||
pub contract_address: Option<H160>,
|
||||
/// Logs
|
||||
pub logs: Vec<Log>,
|
||||
/// State Root
|
||||
#[serde(rename="root")]
|
||||
pub state_root: H256,
|
||||
/// Logs bloom
|
||||
#[serde(rename="logsBloom")]
|
||||
pub logs_bloom: H2048,
|
||||
}
|
||||
|
||||
impl From<LocalizedReceipt> for Receipt {
|
||||
@@ -56,6 +62,8 @@ impl From<LocalizedReceipt> for Receipt {
|
||||
gas_used: Some(r.gas_used.into()),
|
||||
contract_address: r.contract_address.map(Into::into),
|
||||
logs: r.logs.into_iter().map(Into::into).collect(),
|
||||
state_root: r.state_root.into(),
|
||||
logs_bloom: r.log_bloom.into(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -71,6 +79,8 @@ impl From<RichReceipt> for Receipt {
|
||||
gas_used: Some(r.gas_used.into()),
|
||||
contract_address: r.contract_address.map(Into::into),
|
||||
logs: r.logs.into_iter().map(Into::into).collect(),
|
||||
state_root: r.state_root.into(),
|
||||
logs_bloom: r.log_bloom.into(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -86,6 +96,8 @@ impl From<EthReceipt> for Receipt {
|
||||
gas_used: None,
|
||||
contract_address: None,
|
||||
logs: r.logs.into_iter().map(Into::into).collect(),
|
||||
state_root: r.state_root.into(),
|
||||
logs_bloom: r.log_bloom.into(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -93,35 +105,36 @@ impl From<EthReceipt> for Receipt {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use serde_json;
|
||||
use std::str::FromStr;
|
||||
use v1::types::{Log, Receipt, U256, H256, H160};
|
||||
use v1::types::{Log, Receipt};
|
||||
|
||||
#[test]
|
||||
fn receipt_serialization() {
|
||||
let s = r#"{"transactionHash":"0x0000000000000000000000000000000000000000000000000000000000000000","transactionIndex":"0x0","blockHash":"0xed76641c68a1c641aee09a94b3b471f4dc0316efe5ac19cf488e2674cf8d05b5","blockNumber":"0x4510c","cumulativeGasUsed":"0x20","gasUsed":"0x10","contractAddress":null,"logs":[{"address":"0x33990122638b9132ca29c723bdf037f1a891a70c","topics":["0xa6697e974e6a320f454390be03f74955e8978f1a6971ea6730542e37b66179bc","0x4861736852656700000000000000000000000000000000000000000000000000"],"data":"0x","blockHash":"0xed76641c68a1c641aee09a94b3b471f4dc0316efe5ac19cf488e2674cf8d05b5","blockNumber":"0x4510c","transactionHash":"0x0000000000000000000000000000000000000000000000000000000000000000","transactionIndex":"0x0","logIndex":"0x1","type":"mined"}]}"#;
|
||||
let s = r#"{"transactionHash":"0x0000000000000000000000000000000000000000000000000000000000000000","transactionIndex":"0x0","blockHash":"0xed76641c68a1c641aee09a94b3b471f4dc0316efe5ac19cf488e2674cf8d05b5","blockNumber":"0x4510c","cumulativeGasUsed":"0x20","gasUsed":"0x10","contractAddress":null,"logs":[{"address":"0x33990122638b9132ca29c723bdf037f1a891a70c","topics":["0xa6697e974e6a320f454390be03f74955e8978f1a6971ea6730542e37b66179bc","0x4861736852656700000000000000000000000000000000000000000000000000"],"data":"0x","blockHash":"0xed76641c68a1c641aee09a94b3b471f4dc0316efe5ac19cf488e2674cf8d05b5","blockNumber":"0x4510c","transactionHash":"0x0000000000000000000000000000000000000000000000000000000000000000","transactionIndex":"0x0","logIndex":"0x1","type":"mined"}],"root":"0x000000000000000000000000000000000000000000000000000000000000000a","logsBloom":"0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000f"}"#;
|
||||
|
||||
let receipt = Receipt {
|
||||
transaction_hash: Some(H256::from(0)),
|
||||
transaction_index: Some(U256::from(0)),
|
||||
block_hash: Some(H256::from_str("ed76641c68a1c641aee09a94b3b471f4dc0316efe5ac19cf488e2674cf8d05b5").unwrap()),
|
||||
block_number: Some(U256::from(0x4510c)),
|
||||
cumulative_gas_used: U256::from(0x20),
|
||||
gas_used: Some(U256::from(0x10)),
|
||||
transaction_hash: Some(0.into()),
|
||||
transaction_index: Some(0.into()),
|
||||
block_hash: Some("ed76641c68a1c641aee09a94b3b471f4dc0316efe5ac19cf488e2674cf8d05b5".parse().unwrap()),
|
||||
block_number: Some(0x4510c.into()),
|
||||
cumulative_gas_used: 0x20.into(),
|
||||
gas_used: Some(0x10.into()),
|
||||
contract_address: None,
|
||||
logs: vec![Log {
|
||||
address: H160::from_str("33990122638b9132ca29c723bdf037f1a891a70c").unwrap(),
|
||||
address: "33990122638b9132ca29c723bdf037f1a891a70c".parse().unwrap(),
|
||||
topics: vec![
|
||||
H256::from_str("a6697e974e6a320f454390be03f74955e8978f1a6971ea6730542e37b66179bc").unwrap(),
|
||||
H256::from_str("4861736852656700000000000000000000000000000000000000000000000000").unwrap(),
|
||||
"a6697e974e6a320f454390be03f74955e8978f1a6971ea6730542e37b66179bc".parse().unwrap(),
|
||||
"4861736852656700000000000000000000000000000000000000000000000000".parse().unwrap(),
|
||||
],
|
||||
data: vec![].into(),
|
||||
block_hash: Some(H256::from_str("ed76641c68a1c641aee09a94b3b471f4dc0316efe5ac19cf488e2674cf8d05b5").unwrap()),
|
||||
block_number: Some(U256::from(0x4510c)),
|
||||
transaction_hash: Some(H256::default()),
|
||||
transaction_index: Some(U256::default()),
|
||||
log_index: Some(U256::from(1)),
|
||||
log_type: "mined".to_owned(),
|
||||
}]
|
||||
block_hash: Some("ed76641c68a1c641aee09a94b3b471f4dc0316efe5ac19cf488e2674cf8d05b5".parse().unwrap()),
|
||||
block_number: Some(0x4510c.into()),
|
||||
transaction_hash: Some(0.into()),
|
||||
transaction_index: Some(0.into()),
|
||||
log_index: Some(1.into()),
|
||||
log_type: "mined".into(),
|
||||
}],
|
||||
logs_bloom: 15.into(),
|
||||
state_root: 10.into(),
|
||||
};
|
||||
|
||||
let serialized = serde_json::to_string(&receipt).unwrap();
|
||||
|
||||
@@ -54,10 +54,17 @@ pub struct Transaction {
|
||||
/// Public key of the signer.
|
||||
#[serde(rename="publicKey")]
|
||||
pub public_key: Option<H512>,
|
||||
/// The V field of the signature.
|
||||
pub v: u8,
|
||||
/// The R field of the signature.
|
||||
pub r: H256,
|
||||
/// The S field of the signature.
|
||||
pub s: H256,
|
||||
}
|
||||
|
||||
impl From<LocalizedTransaction> for Transaction {
|
||||
fn from(t: LocalizedTransaction) -> Transaction {
|
||||
let signature = t.signature();
|
||||
Transaction {
|
||||
hash: t.hash().into(),
|
||||
nonce: t.nonce.into(),
|
||||
@@ -79,12 +86,16 @@ impl From<LocalizedTransaction> for Transaction {
|
||||
},
|
||||
raw: ::rlp::encode(&t.signed).to_vec().into(),
|
||||
public_key: t.public_key().ok().map(Into::into),
|
||||
v: signature.v(),
|
||||
r: signature.r().into(),
|
||||
s: signature.s().into(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<SignedTransaction> for Transaction {
|
||||
fn from(t: SignedTransaction) -> Transaction {
|
||||
let signature = t.signature();
|
||||
Transaction {
|
||||
hash: t.hash().into(),
|
||||
nonce: t.nonce.into(),
|
||||
@@ -106,6 +117,9 @@ impl From<SignedTransaction> for Transaction {
|
||||
},
|
||||
raw: ::rlp::encode(&t).to_vec().into(),
|
||||
public_key: t.public_key().ok().map(Into::into),
|
||||
v: signature.v(),
|
||||
r: signature.r().into(),
|
||||
s: signature.s().into(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -119,7 +133,7 @@ mod tests {
|
||||
fn test_transaction_serialize() {
|
||||
let t = Transaction::default();
|
||||
let serialized = serde_json::to_string(&t).unwrap();
|
||||
assert_eq!(serialized, r#"{"hash":"0x0000000000000000000000000000000000000000000000000000000000000000","nonce":"0x0","blockHash":null,"blockNumber":null,"transactionIndex":null,"from":"0x0000000000000000000000000000000000000000","to":null,"value":"0x0","gasPrice":"0x0","gas":"0x0","input":"0x","creates":null,"raw":"0x","publicKey":null}"#);
|
||||
assert_eq!(serialized, r#"{"hash":"0x0000000000000000000000000000000000000000000000000000000000000000","nonce":"0x0","blockHash":null,"blockNumber":null,"transactionIndex":null,"from":"0x0000000000000000000000000000000000000000","to":null,"value":"0x0","gasPrice":"0x0","gas":"0x0","input":"0x","creates":null,"raw":"0x","publicKey":null,"v":0,"r":"0x0000000000000000000000000000000000000000000000000000000000000000","s":"0x0000000000000000000000000000000000000000000000000000000000000000"}"#);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
use std::ops::{Deref, DerefMut};
|
||||
use std::thread;
|
||||
use std::time::{self, Duration};
|
||||
use std::time;
|
||||
use std::sync::Arc;
|
||||
use devtools::{http_client, RandomTempPath};
|
||||
use rpc::ConfirmationsQueue;
|
||||
@@ -50,7 +50,6 @@ pub fn serve() -> (Server, usize, GuardedAuthCodes) {
|
||||
let builder = ServerBuilder::new(queue, path.to_path_buf());
|
||||
let port = 35000 + rand::random::<usize>() % 10000;
|
||||
let res = builder.start(format!("127.0.0.1:{}", port).parse().unwrap()).unwrap();
|
||||
thread::sleep(Duration::from_millis(25));
|
||||
|
||||
(res, port, GuardedAuthCodes {
|
||||
authcodes: AuthCodes::from_file(&path).unwrap(),
|
||||
|
||||
@@ -3,7 +3,7 @@ description = "Ethcore utility library"
|
||||
homepage = "http://ethcore.io"
|
||||
license = "GPL-3.0"
|
||||
name = "ethcore-util"
|
||||
version = "1.4.2"
|
||||
version = "1.4.3"
|
||||
authors = ["Ethcore <admin@ethcore.io>"]
|
||||
build = "build.rs"
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ homepage = "http://ethcore.io"
|
||||
repository = "https://github.com/ethcore/parity"
|
||||
license = "GPL-3.0"
|
||||
name = "ethcore-bigint"
|
||||
version = "0.1.1"
|
||||
version = "0.1.2"
|
||||
authors = ["Ethcore <admin@ethcore.io>"]
|
||||
build = "build.rs"
|
||||
|
||||
|
||||
@@ -386,6 +386,12 @@ macro_rules! impl_hash {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> From<&'a [u8]> for $from {
|
||||
fn from(s: &'a [u8]) -> $from {
|
||||
$from::from_slice(s)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,10 +17,10 @@
|
||||
//! Database of byte-slices keyed to their Keccak hash.
|
||||
use hash::*;
|
||||
use std::collections::HashMap;
|
||||
use elastic_array::ElasticArray256;
|
||||
use elastic_array::ElasticArray128;
|
||||
|
||||
/// `HashDB` value type.
|
||||
pub type DBValue = ElasticArray256<u8>;
|
||||
pub type DBValue = ElasticArray128<u8>;
|
||||
|
||||
/// Trait modelling datastore keyed by a 32-byte Keccak hash.
|
||||
pub trait HashDB: AsHashDB + Send + Sync {
|
||||
|
||||
@@ -464,6 +464,7 @@ impl Database {
|
||||
try!(db.write_opt(batch, &self.write_opts));
|
||||
for column in self.flushing.write().iter_mut() {
|
||||
column.clear();
|
||||
column.shrink_to_fit();
|
||||
}
|
||||
Ok(())
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user