From c060d9584dae34e0e215f061bd61b2ebd375956b Mon Sep 17 00:00:00 2001 From: Marek Kotewicz Date: Fri, 9 Feb 2018 09:32:06 +0100 Subject: [PATCH] ethabi version 5 (#7723) * Refactor updater to use ethabi-derive * Grumble: do_call type alias * Empty commit to trigger test re-run * migration to ethabi-5.0 * migration to ethabi-5.0 in progress * use ethabi_deriven to generate TransactAcl contract * use ethabi_deriven to generate Registry contract * hash-fetch uses ethabi_derive, removed retain cycle from updater, fixed #7720 * node-filter crate uses ethabi_derive to generate peer_set contract interface * use LruCache in node-filter instead of HashMap * validator_set engine uses ethabi_derive * ethcore does not depend on native_contracts * miner does no depend on native_contracts * secret_store does not use native_contracts (in progress) * removed native-contracts * ethcore and updater does not depend on futures * updated ethereum-types * fixed all warnings caused by using new version of ethereum-types * updated ethabi_derive && ethabi_contract to get rid of warnings * removed another retain cycle in updater, fixed following minor version on update * moved contracts out of native_contracts res * updated ethabi_contract * fixed failing test * fixed failing test * there is no need to create two contracts of the same kind any more * simplify updater::ReleaseTrack conversion into u8 and add several tests for it * applied review suggestions * applied review suggestions --- Cargo.lock | 495 ++++++++-------- Cargo.toml | 2 +- dapps/Cargo.toml | 4 +- dapps/src/apps/fetcher/mod.rs | 16 +- dapps/src/tests/helpers/registrar.rs | 5 +- ethcore/Cargo.toml | 12 +- ethcore/evm/Cargo.toml | 2 +- ethcore/light/Cargo.toml | 4 +- ethcore/light/src/client/header_chain.rs | 19 +- ethcore/light/src/net/request_credits.rs | 4 +- ethcore/migrations/Cargo.toml | 2 +- ethcore/native_contracts/Cargo.toml | 19 - ethcore/native_contracts/build.rs | 64 -- ethcore/native_contracts/generator/Cargo.toml | 9 - ethcore/native_contracts/generator/src/lib.rs | 373 ------------ ethcore/native_contracts/res/tx_acl.json | 1 - ethcore/native_contracts/res/urlhint.json | 6 - .../native_contracts/src/key_server_set.rs | 21 - ethcore/native_contracts/src/lib.rs | 48 -- ethcore/native_contracts/src/peer_set.rs | 21 - ethcore/native_contracts/src/registry.rs | 22 - .../src/secretstore_acl_storage.rs | 22 - .../src/secretstore_service.rs | 21 - .../src/service_transaction.rs | 22 - .../src/test_contracts/mod.rs | 21 - .../src/test_contracts/validator_set.rs | 21 - ethcore/native_contracts/src/tx_acl.rs | 21 - ethcore/native_contracts/src/urlhint.rs | 22 - .../native_contracts/src/validator_report.rs | 22 - ethcore/native_contracts/src/validator_set.rs | 22 - ethcore/node_filter/Cargo.toml | 8 +- .../res/peer_set.json | 0 ethcore/node_filter/src/lib.rs | 85 ++- .../res => res/contracts}/registrar.json | 0 .../contracts}/test_validator_set.json | 0 ethcore/res/contracts/tx_acl.json | 1 + .../contracts}/validator_report.json | 0 .../res => res/contracts}/validator_set.json | 0 ethcore/src/client/client.rs | 52 +- ethcore/src/engines/validator_set/contract.rs | 47 +- .../engines/validator_set/safe_contract.rs | 100 ++-- ethcore/src/ethereum/ethash.rs | 21 +- ethcore/src/lib.rs | 8 +- ethcore/src/machine.rs | 4 +- ethcore/src/miner/miner.rs | 15 +- ethcore/src/miner/stratum.rs | 4 +- ethcore/src/snapshot/io.rs | 11 +- ethcore/src/snapshot/mod.rs | 4 +- .../src/snapshot/tests/proof_of_authority.rs | 49 +- ethcore/src/state/account.rs | 30 +- ethcore/src/state/mod.rs | 6 +- ethcore/src/tx_filter.rs | 34 +- ethcore/transaction/Cargo.toml | 2 +- ethcore/types/Cargo.toml | 2 +- ethcore/vm/Cargo.toml | 2 +- ethcore/wasm/Cargo.toml | 2 +- ethcore/wasm/run/Cargo.toml | 2 +- ethcrypto/Cargo.toml | 2 +- ethkey/Cargo.toml | 4 +- ethstore/Cargo.toml | 4 +- evmbin/Cargo.toml | 2 +- evmbin/src/display/json.rs | 8 +- evmbin/src/display/mod.rs | 11 - evmbin/src/display/std_json.rs | 6 +- hash-fetch/Cargo.toml | 10 +- hash-fetch/src/client.rs | 5 +- hash-fetch/src/lib.rs | 8 +- hash-fetch/src/urlhint.rs | 82 ++- hw/Cargo.toml | 2 +- ipfs/Cargo.toml | 2 +- json/Cargo.toml | 2 +- machine/Cargo.toml | 2 +- miner/Cargo.toml | 6 +- .../res/service_transaction.json | 0 miner/src/lib.rs | 15 +- miner/src/service_transaction_checker.rs | 41 +- miner/src/work_notify.rs | 4 +- parity/blockchain.rs | 8 +- parity/configuration.rs | 8 +- parity/dapps.rs | 24 +- parity/main.rs | 2 +- parity/run.rs | 15 +- rpc/Cargo.toml | 4 +- rpc/src/v1/helpers/light_fetch.rs | 2 +- rpc/src/v1/tests/mocked/eth.rs | 8 +- rpc/src/v1/tests/mocked/parity.rs | 8 +- rpc/src/v1/tests/mocked/parity_accounts.rs | 18 +- rpc/src/v1/tests/mocked/signer.rs | 8 +- rpc/src/v1/tests/mocked/signing.rs | 8 +- rpc/src/v1/types/sync.rs | 4 +- rpc/src/v1/types/uint.rs | 4 +- secret_store/Cargo.toml | 6 +- .../res/acl_storage.json | 0 .../res/key_server_set.json | 0 .../res/service.json | 0 secret_store/src/acl_storage.rs | 38 +- secret_store/src/key_server_set.rs | 162 +++-- secret_store/src/lib.rs | 46 +- secret_store/src/listener/service_contract.rs | 76 ++- .../src/listener/service_contract_listener.rs | 2 +- stratum/Cargo.toml | 2 +- sync/Cargo.toml | 4 +- sync/src/api.rs | 4 +- sync/src/blocks.rs | 2 +- sync/src/snapshot.rs | 4 +- transaction-pool/Cargo.toml | 2 +- transaction-pool/src/tests/tx_builder.rs | 2 +- updater/Cargo.toml | 8 +- updater/res/operations.json | 560 ++++++++++++++++++ updater/src/lib.rs | 24 +- updater/src/operations.rs | 355 ----------- updater/src/types/release_track.rs | 65 +- updater/src/updater.rs | 234 ++++---- util/bloomchain/Cargo.toml | 2 +- util/dir/Cargo.toml | 2 +- util/dir/src/lib.rs | 50 +- util/error/Cargo.toml | 2 +- util/hash/Cargo.toml | 2 +- util/hashdb/Cargo.toml | 2 +- util/journaldb/Cargo.toml | 2 +- util/kvdb-rocksdb/Cargo.toml | 2 +- util/memorydb/Cargo.toml | 2 +- util/network/Cargo.toml | 4 +- util/patricia_trie/Cargo.toml | 4 +- util/plain_hasher/Cargo.toml | 2 +- util/rlp/Cargo.toml | 2 +- util/triehash/Cargo.toml | 2 +- whisper/Cargo.toml | 4 +- whisper/src/rpc/filter.rs | 2 +- 129 files changed, 1678 insertions(+), 2173 deletions(-) delete mode 100644 ethcore/native_contracts/Cargo.toml delete mode 100644 ethcore/native_contracts/build.rs delete mode 100644 ethcore/native_contracts/generator/Cargo.toml delete mode 100644 ethcore/native_contracts/generator/src/lib.rs delete mode 100644 ethcore/native_contracts/res/tx_acl.json delete mode 100644 ethcore/native_contracts/res/urlhint.json delete mode 100644 ethcore/native_contracts/src/key_server_set.rs delete mode 100644 ethcore/native_contracts/src/lib.rs delete mode 100644 ethcore/native_contracts/src/peer_set.rs delete mode 100644 ethcore/native_contracts/src/registry.rs delete mode 100644 ethcore/native_contracts/src/secretstore_acl_storage.rs delete mode 100644 ethcore/native_contracts/src/secretstore_service.rs delete mode 100644 ethcore/native_contracts/src/service_transaction.rs delete mode 100644 ethcore/native_contracts/src/test_contracts/mod.rs delete mode 100644 ethcore/native_contracts/src/test_contracts/validator_set.rs delete mode 100644 ethcore/native_contracts/src/tx_acl.rs delete mode 100644 ethcore/native_contracts/src/urlhint.rs delete mode 100644 ethcore/native_contracts/src/validator_report.rs delete mode 100644 ethcore/native_contracts/src/validator_set.rs rename ethcore/{native_contracts => node_filter}/res/peer_set.json (100%) rename ethcore/{native_contracts/res => res/contracts}/registrar.json (100%) rename ethcore/{native_contracts/res => res/contracts}/test_validator_set.json (100%) create mode 100644 ethcore/res/contracts/tx_acl.json rename ethcore/{native_contracts/res => res/contracts}/validator_report.json (100%) rename ethcore/{native_contracts/res => res/contracts}/validator_set.json (100%) rename {ethcore/native_contracts => miner}/res/service_transaction.json (100%) rename ethcore/native_contracts/res/secretstore_acl_storage.json => secret_store/res/acl_storage.json (100%) rename {ethcore/native_contracts => secret_store}/res/key_server_set.json (100%) rename ethcore/native_contracts/res/secretstore_service.json => secret_store/res/service.json (100%) create mode 100644 updater/res/operations.json delete mode 100644 updater/src/operations.rs diff --git a/Cargo.lock b/Cargo.lock index f7d5e49ba..a1b8955df 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -49,7 +49,7 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -60,9 +60,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "backtrace-sys 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-demangle 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -71,7 +71,7 @@ version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cc 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -89,7 +89,7 @@ name = "base64" version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "byteorder 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "safemem 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -98,7 +98,7 @@ name = "bigint" version = "4.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "byteorder 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "crunchy 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -108,7 +108,7 @@ name = "bincode" version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "byteorder 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -150,7 +150,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" name = "bloomchain" version = "0.2.0" dependencies = [ - "ethbloom 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "ethbloom 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -160,14 +160,14 @@ name = "bn" version = "0.4.4" source = "git+https://github.com/paritytech/bn#c9831a8d10d55045692394cbc10efe0321ddb16f" dependencies = [ - "byteorder 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.3.20 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "byteorder" -version = "1.1.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -175,7 +175,7 @@ name = "bytes" version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "byteorder 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "iovec 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -239,9 +239,9 @@ name = "common-types" version = "0.1.0" dependencies = [ "ethcore-bytes 0.1.0", - "ethereum-types 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "ethereum-types 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "ethjson 0.1.0", - "heapsize 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "keccak-hash 0.1.0", "rlp 0.2.1", "rlp_derive 0.1.0", @@ -271,7 +271,7 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "core-foundation-sys 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -279,7 +279,7 @@ name = "core-foundation-sys" version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -298,7 +298,7 @@ version = "1.1.1" source = "git+https://github.com/paritytech/rust-ctrlc.git#b523017108bb2d571a7a69bd97bc406e63bc7a9d" dependencies = [ "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -312,7 +312,7 @@ name = "daemonize" version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -325,7 +325,7 @@ name = "dir" version = "0.1.0" dependencies = [ "app_dirs 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "ethereum-types 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "ethereum-types 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "journaldb 0.1.0", ] @@ -361,7 +361,7 @@ name = "elastic-array" version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "heapsize 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -384,21 +384,22 @@ dependencies = [ [[package]] name = "eth-secp256k1" version = "0.5.7" -source = "git+https://github.com/paritytech/rust-secp256k1#6370d63adf4e8c91e2eae9225eef4b4e0294c5d0" +source = "git+https://github.com/paritytech/rust-secp256k1#c1fc9daedee67e1b4028ad1b3669275ed49c22cf" dependencies = [ "arrayvec 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "cc 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.3.20 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "ethabi" -version = "4.0.1" +version = "5.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "error-chain 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", + "ethereum-types 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", @@ -406,6 +407,22 @@ dependencies = [ "tiny-keccak 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "ethabi-contract" +version = "5.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "ethabi-derive" +version = "5.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "ethabi 5.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "heck 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "ethash" version = "1.9.0" @@ -421,11 +438,13 @@ dependencies = [ [[package]] name = "ethbloom" -version = "0.3.0" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "crunchy 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "fixed-hash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "ethereum-types-serialize 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "fixed-hash 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", "tiny-keccak 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -436,9 +455,12 @@ dependencies = [ "ansi_term 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", "bloomchain 0.2.0", "bn 0.4.4 (git+https://github.com/paritytech/bn)", - "byteorder 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "common-types 0.1.0", "crossbeam 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "ethabi 5.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "ethabi-contract 5.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "ethabi-derive 5.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "ethash 1.9.0", "ethcore-bloom-journal 0.1.0", "ethcore-bytes 0.1.0", @@ -447,15 +469,14 @@ dependencies = [ "ethcore-miner 1.9.0", "ethcore-stratum 1.9.0", "ethcore-transaction 0.1.0", - "ethereum-types 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "ethereum-types 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "ethjson 0.1.0", "ethkey 0.3.0", "ethstore 0.2.0", "evm 0.1.0", - "futures 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", "hardware-wallet 1.9.0", "hashdb 0.1.1", - "heapsize 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "itertools 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)", "journaldb 0.1.0", "keccak-hash 0.1.0", @@ -469,14 +490,13 @@ dependencies = [ "memory-cache 0.1.0", "memorydb 0.1.1", "migration 0.1.0", - "native-contracts 0.1.0", "num 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-machine 0.1.0", "parking_lot 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", "patricia-trie 0.1.0", "price-info 1.7.0", - "rand 0.3.20 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "rayon 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", "rlp 0.2.1", "rlp_derive 0.1.0", @@ -532,11 +552,11 @@ dependencies = [ "ethcore-io 1.9.0", "ethcore-network 1.9.0", "ethcore-transaction 0.1.0", - "ethereum-types 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "ethereum-types 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "evm 0.1.0", - "futures 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", "hashdb 0.1.1", - "heapsize 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "itertools 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)", "keccak-hash 0.1.0", "kvdb 0.1.0", @@ -548,7 +568,7 @@ dependencies = [ "parking_lot 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", "patricia-trie 0.1.0", "plain_hasher 0.1.0", - "rand 0.3.20 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "rlp 0.2.1", "rlp_derive 0.1.0", "serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", @@ -583,7 +603,7 @@ dependencies = [ "ethcore 1.9.0", "ethcore-bloom-journal 0.1.0", "ethcore-bytes 0.1.0", - "ethereum-types 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "ethereum-types 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "journaldb 0.1.0", "keccak-hash 0.1.0", "kvdb 0.1.0", @@ -600,17 +620,19 @@ name = "ethcore-miner" version = "1.9.0" dependencies = [ "common-types 0.1.0", + "ethabi 5.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "ethabi-contract 5.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "ethabi-derive 5.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "ethash 1.9.0", "ethcore-transaction 0.1.0", - "ethereum-types 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "ethereum-types 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "ethkey 0.3.0", - "futures 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", - "heapsize 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", + "heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "hyper 0.10.0-a.0 (git+https://github.com/paritytech/hyper)", "keccak-hash 0.1.0", "linked-hash-map 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", - "native-contracts 0.1.0", "parking_lot 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "table 0.1.0", @@ -628,17 +650,17 @@ dependencies = [ "ethcore-io 1.9.0", "ethcore-logger 1.9.0", "ethcrypto 0.1.0", - "ethereum-types 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "ethereum-types 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "ethkey 0.3.0", "igd 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "ipnetwork 0.12.7 (registry+https://github.com/rust-lang/crates.io-index)", "keccak-hash 0.1.0", - "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "mio 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", "path 0.1.0", - "rand 0.3.20 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "rlp 0.2.1", "rust-crypto 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -656,23 +678,25 @@ dependencies = [ name = "ethcore-secretstore" version = "1.0.0" dependencies = [ - "byteorder 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "ethabi 5.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "ethabi-contract 5.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "ethabi-derive 5.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "ethcore 1.9.0", "ethcore-bytes 0.1.0", "ethcore-logger 1.9.0", "ethcrypto 0.1.0", - "ethereum-types 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "ethereum-types 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "ethkey 0.3.0", "ethsync 1.9.0", - "futures 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-cpupool 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-cpupool 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "hyper 0.10.13 (registry+https://github.com/rust-lang/crates.io-index)", "keccak-hash 0.1.0", "kvdb 0.1.0", "kvdb-rocksdb 0.1.0", "lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", - "native-contracts 0.1.0", "parking_lot 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", @@ -693,7 +717,7 @@ version = "1.9.0" dependencies = [ "env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "ethcore-logger 1.9.0", - "ethereum-types 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "ethereum-types 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "jsonrpc-core 8.0.1 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.10)", "jsonrpc-macros 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.10)", "jsonrpc-tcp-server 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.10)", @@ -708,11 +732,11 @@ dependencies = [ name = "ethcore-transaction" version = "0.1.0" dependencies = [ - "ethereum-types 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "ethereum-types 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "ethjson 0.1.0", "ethkey 0.3.0", "evm 0.1.0", - "heapsize 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "keccak-hash 0.1.0", "rlp 0.2.1", "rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -724,7 +748,7 @@ name = "ethcrypto" version = "0.1.0" dependencies = [ "eth-secp256k1 0.5.7 (git+https://github.com/paritytech/rust-secp256k1)", - "ethereum-types 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "ethereum-types 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "ethkey 0.3.0", "rust-crypto 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", "subtle 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -733,21 +757,31 @@ dependencies = [ [[package]] name = "ethereum-types" -version = "0.1.4" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "crunchy 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "ethbloom 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "fixed-hash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "ethbloom 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "ethereum-types-serialize 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "fixed-hash 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "uint 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", + "uint 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "ethereum-types-serialize" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "ethjson" version = "0.1.0" dependencies = [ - "ethereum-types 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "ethereum-types 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", @@ -758,14 +792,14 @@ dependencies = [ name = "ethkey" version = "0.3.0" dependencies = [ - "byteorder 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "edit-distance 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "eth-secp256k1 0.5.7 (git+https://github.com/paritytech/rust-secp256k1)", - "ethereum-types 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "ethereum-types 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-wordlist 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.3.20 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "rust-crypto 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "tiny-keccak 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -792,14 +826,14 @@ version = "0.2.0" dependencies = [ "dir 0.1.0", "ethcrypto 0.1.0", - "ethereum-types 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "ethereum-types 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "ethkey 0.3.0", "itertools 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-wordlist 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.3.20 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "rust-crypto 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", @@ -837,9 +871,9 @@ dependencies = [ "ethcore-light 1.9.0", "ethcore-network 1.9.0", "ethcore-transaction 0.1.0", - "ethereum-types 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "ethereum-types 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "ethkey 0.3.0", - "heapsize 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "ipnetwork 0.12.7 (registry+https://github.com/rust-lang/crates.io-index)", "keccak-hash 0.1.0", "kvdb 0.1.0", @@ -848,7 +882,7 @@ dependencies = [ "macros 0.1.0", "parking_lot 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", "plain_hasher 0.1.0", - "rand 0.3.20 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "rlp 0.2.1", "semver 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -861,9 +895,9 @@ name = "evm" version = "0.1.0" dependencies = [ "bit-set 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "ethereum-types 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "ethereum-types 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "evmjit 1.9.0", - "heapsize 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "keccak-hash 0.1.0", "lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -881,7 +915,7 @@ dependencies = [ "ethcore 1.9.0", "ethcore-bytes 0.1.0", "ethcore-transaction 0.1.0", - "ethereum-types 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "ethereum-types 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "ethjson 0.1.0", "evm 0.1.0", "panic_hook 0.1.0", @@ -904,15 +938,15 @@ name = "fdlimit" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "fetch" version = "0.1.0" dependencies = [ - "futures 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-cpupool 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-cpupool 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", "reqwest 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -920,12 +954,12 @@ dependencies = [ [[package]] name = "fixed-hash" -version = "0.1.1" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "heapsize 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.3.20 (registry+https://github.com/rust-lang/crates.io-index)", + "heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -934,7 +968,7 @@ name = "flate2" version = "0.2.20" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", "miniz-sys 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -972,15 +1006,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "futures" -version = "0.1.17" +version = "0.1.18" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "futures-cpupool" -version = "0.1.6" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "futures 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1023,7 +1057,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" name = "hardware-wallet" version = "1.9.0" dependencies = [ - "ethereum-types 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "ethereum-types 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "ethkey 0.3.0", "hidapi 0.3.1 (git+https://github.com/paritytech/hidapi-rs)", "libusb 0.3.0 (git+https://github.com/paritytech/libusb-rs)", @@ -1039,20 +1073,20 @@ name = "hashdb" version = "0.1.1" dependencies = [ "elastic-array 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "ethereum-types 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "ethereum-types 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "heapsize" -version = "0.4.1" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "heck" -version = "0.3.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "unicode-segmentation 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1069,7 +1103,7 @@ version = "0.3.1" source = "git+https://github.com/paritytech/hidapi-rs#e77ea09c98f29ea8855dd9cd9461125a28ca9125" dependencies = [ "cc 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1121,8 +1155,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "base64 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-cpupool 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-cpupool 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "httparse 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "language-tags 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1141,7 +1175,7 @@ name = "hyper-tls" version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "futures 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", "hyper 0.11.2 (registry+https://github.com/rust-lang/crates.io-index)", "native-tls 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-core 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1187,7 +1221,7 @@ name = "iovec" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1202,7 +1236,7 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1225,9 +1259,9 @@ version = "0.1.0" dependencies = [ "ethcore-bytes 0.1.0", "ethcore-logger 1.9.0", - "ethereum-types 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "ethereum-types 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "hashdb 0.1.1", - "heapsize 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "keccak-hash 0.1.0", "kvdb 0.1.0", "kvdb-memorydb 0.1.0", @@ -1244,7 +1278,7 @@ name = "jsonrpc-core" version = "8.0.1" source = "git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.10#786f3e16ba6192a42955eddf57e4baa2a57dde3b" dependencies = [ - "futures 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1340,7 +1374,7 @@ name = "keccak-hash" version = "0.1.0" dependencies = [ "cc 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "ethereum-types 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "ethereum-types 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "tempdir 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", "tiny-keccak 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1377,7 +1411,7 @@ name = "kvdb-rocksdb" version = "0.1.0" dependencies = [ "elastic-array 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "ethereum-types 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "ethereum-types 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "interleaved-ordered 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "kvdb 0.1.0", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1411,7 +1445,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "libc" -version = "0.2.31" +version = "0.2.36" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -1420,7 +1454,7 @@ version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "adler32 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "byteorder 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1429,7 +1463,7 @@ version = "0.3.0" source = "git+https://github.com/paritytech/libusb-rs#442708954a720bc89a9cf41e7be021a778bdbc27" dependencies = [ "bit-set 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", "libusb-sys 0.2.4 (git+https://github.com/paritytech/libusb-sys)", ] @@ -1439,7 +1473,7 @@ version = "0.2.4" source = "git+https://github.com/paritytech/libusb-sys#14bdb698003731b6344a79e1d814704e44363e7c" dependencies = [ "cc 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1506,7 +1540,7 @@ name = "memchr" version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1514,15 +1548,15 @@ name = "memmap" version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "memory-cache" version = "0.1.0" dependencies = [ - "heapsize 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "lru-cache 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1532,9 +1566,9 @@ version = "0.1.1" dependencies = [ "bigint 4.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "elastic-array 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "ethereum-types 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "ethereum-types 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "hashdb 0.1.1", - "heapsize 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "keccak-hash 0.1.0", "plain_hasher 0.1.0", "rlp 0.2.1", @@ -1585,7 +1619,7 @@ version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cc 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1596,7 +1630,7 @@ dependencies = [ "iovec 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "lazycell 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "magenta 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "magenta-sys 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1623,7 +1657,7 @@ name = "mio-uds" version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", "mio 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1665,32 +1699,13 @@ dependencies = [ "tiny-keccak 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "native-contract-generator" -version = "0.1.0" -dependencies = [ - "ethabi 4.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "heck 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "native-contracts" -version = "0.1.0" -dependencies = [ - "byteorder 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "ethabi 4.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "ethereum-types 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", - "native-contract-generator 0.1.0", -] - [[package]] name = "native-tls" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", "openssl 0.9.23 (registry+https://github.com/rust-lang/crates.io-index)", "schannel 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "security-framework 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1705,7 +1720,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", "ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1714,15 +1729,17 @@ dependencies = [ name = "node-filter" version = "1.9.0" dependencies = [ + "ethabi 5.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "ethabi-contract 5.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "ethabi-derive 5.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "ethcore 1.9.0", "ethcore-bytes 0.1.0", "ethcore-io 1.9.0", "ethcore-network 1.9.0", - "ethereum-types 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", + "ethereum-types 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "kvdb-memorydb 0.1.0", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", - "native-contracts 0.1.0", + "lru-cache 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1730,8 +1747,8 @@ dependencies = [ name = "node-health" version = "0.1.0" dependencies = [ - "futures 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-cpupool 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-cpupool 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "ntp 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "parity-reactor 0.1.0", @@ -1751,7 +1768,7 @@ name = "ntp" version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "byteorder 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "conv 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "custom_derive 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "error-chain 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1830,7 +1847,7 @@ name = "num_cpus" version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1858,7 +1875,7 @@ dependencies = [ "bitflags 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "foreign-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", "openssl-sys 0.9.23 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1868,7 +1885,7 @@ version = "0.9.23" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cc 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", "pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", "vcpkg 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1925,12 +1942,12 @@ dependencies = [ "ethcore-secretstore 1.0.0", "ethcore-stratum 1.9.0", "ethcore-transaction 0.1.0", - "ethereum-types 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "ethereum-types 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "ethkey 0.3.0", "ethsync 1.9.0", "fdlimit 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-cpupool 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-cpupool 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "ipnetwork 0.12.7 (registry+https://github.com/rust-lang/crates.io-index)", "isatty 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "journaldb 0.1.0", @@ -1985,10 +2002,10 @@ dependencies = [ "env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "ethcore-bytes 0.1.0", "ethcore-devtools 1.9.0", - "ethereum-types 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "ethereum-types 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "fetch 0.1.0", - "futures 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-cpupool 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-cpupool 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "itertools 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)", "jsonrpc-core 8.0.1 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.10)", "jsonrpc-http-server 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.10)", @@ -2003,7 +2020,7 @@ dependencies = [ "parity-ui 1.9.0", "parity-version 1.10.0", "parking_lot 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.3.20 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2044,19 +2061,20 @@ dependencies = [ name = "parity-hash-fetch" version = "1.9.0" dependencies = [ - "ethabi 4.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "ethabi 5.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "ethabi-contract 5.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "ethabi-derive 5.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "ethcore-bytes 0.1.0", - "ethereum-types 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "ethereum-types 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "fetch 0.1.0", - "futures 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", "keccak-hash 0.1.0", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "mime 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", "mime_guess 2.0.0-alpha.2 (registry+https://github.com/rust-lang/crates.io-index)", - "native-contracts 0.1.0", "parity-reactor 0.1.0", "parking_lot 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.3.20 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2067,7 +2085,7 @@ dependencies = [ "cid 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "ethcore 1.9.0", "ethcore-bytes 0.1.0", - "ethereum-types 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "ethereum-types 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "jsonrpc-core 8.0.1 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.10)", "jsonrpc-http-server 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.10)", "multihash 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2096,14 +2114,14 @@ dependencies = [ name = "parity-machine" version = "0.1.0" dependencies = [ - "ethereum-types 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "ethereum-types 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "parity-reactor" version = "0.1.0" dependencies = [ - "futures 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-core 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2124,14 +2142,14 @@ dependencies = [ "ethcore-network 1.9.0", "ethcore-transaction 0.1.0", "ethcrypto 0.1.0", - "ethereum-types 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "ethereum-types 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "ethjson 0.1.0", "ethkey 0.3.0", "ethstore 0.2.0", "ethsync 1.9.0", "fetch 0.1.0", - "futures 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-cpupool 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-cpupool 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "hardware-wallet 1.9.0", "itertools 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)", "jsonrpc-core 8.0.1 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.10)", @@ -2152,7 +2170,7 @@ dependencies = [ "parity-version 1.10.0", "parking_lot 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", "pretty_assertions 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.3.20 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "rlp 0.2.1", "rust-crypto 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2173,7 +2191,7 @@ dependencies = [ name = "parity-rpc-client" version = "1.4.0" dependencies = [ - "futures 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", "jsonrpc-core 8.0.1 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.10)", "jsonrpc-ws-server 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.10)", "keccak-hash 0.1.0", @@ -2192,7 +2210,7 @@ version = "0.1.5" source = "git+https://github.com/nikvolf/parity-tokio-ipc#d6c5b3cfcc913a1b9cf0f0562a10b083ceb9fb7c" dependencies = [ "bytes 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "mio-named-pipes 0.1.4 (git+https://github.com/alexcrichton/mio-named-pipes)", "miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2250,15 +2268,15 @@ dependencies = [ name = "parity-updater" version = "1.9.0" dependencies = [ - "ethabi 4.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "ethabi 5.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "ethabi-contract 5.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "ethabi-derive 5.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "ethcore 1.9.0", "ethcore-bytes 0.1.0", - "ethereum-types 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "ethereum-types 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "ethsync 1.9.0", - "futures 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-hash-fetch 1.9.0", - "parity-reactor 0.1.0", "parity-version 1.10.0", "parking_lot 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", "path 0.1.0", @@ -2283,7 +2301,7 @@ name = "parity-wasm" version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "byteorder 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2293,10 +2311,10 @@ name = "parity-whisper" version = "0.1.0" dependencies = [ "bitflags 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", - "byteorder 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "ethcore-network 1.9.0", "ethcrypto 0.1.0", - "ethereum-types 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "ethereum-types 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "ethkey 0.3.0", "hex 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "jsonrpc-core 8.0.1 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.10)", @@ -2305,7 +2323,7 @@ dependencies = [ "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "ordered-float 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.3.20 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "ring 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)", "rlp 0.2.1", "serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2342,7 +2360,7 @@ version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.3.20 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2359,12 +2377,12 @@ dependencies = [ "elastic-array 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "ethcore-bytes 0.1.0", "ethcore-logger 1.9.0", - "ethereum-types 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "ethereum-types 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "hashdb 0.1.1", "keccak-hash 0.1.0", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "memorydb 0.1.1", - "rand 0.3.20 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "rlp 0.2.1", "triehash 0.1.0", ] @@ -2419,7 +2437,7 @@ name = "plain_hasher" version = "0.1.0" dependencies = [ "crunchy 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "ethereum-types 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "ethereum-types 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2440,7 +2458,7 @@ name = "price-info" version = "1.7.0" dependencies = [ "fetch 0.1.0", - "futures 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2507,7 +2525,7 @@ version = "0.1.0" dependencies = [ "clap 2.29.1 (registry+https://github.com/rust-lang/crates.io-index)", "ethcore-logger 1.9.0", - "ethereum-types 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "ethereum-types 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "ethjson 0.1.0", "rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2561,7 +2579,7 @@ version = "0.3.20" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2570,7 +2588,7 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2588,7 +2606,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "coco 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.3.20 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2621,7 +2639,7 @@ version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", "hyper 0.11.2 (registry+https://github.com/rust-lang/crates.io-index)", "hyper-tls 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "libflate 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2645,7 +2663,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "gcc 0.3.54 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", "rayon 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", "untrusted 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2654,9 +2672,9 @@ dependencies = [ name = "rlp" version = "0.2.1" dependencies = [ - "byteorder 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "elastic-array 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "ethereum-types 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "ethereum-types 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2675,7 +2693,7 @@ name = "rocksdb" version = "0.4.5" source = "git+https://github.com/paritytech/rust-rocksdb#ecf06adf3148ab10f6f7686b724498382ff4f36e" dependencies = [ - "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", "local-encoding 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "rocksdb-sys 0.3.0 (git+https://github.com/paritytech/rust-rocksdb)", ] @@ -2686,7 +2704,7 @@ version = "0.3.0" source = "git+https://github.com/paritytech/rust-rocksdb#ecf06adf3148ab10f6f7686b724498382ff4f36e" dependencies = [ "cc 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", "local-encoding 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "snappy-sys 0.1.0 (git+https://github.com/paritytech/rust-snappy)", ] @@ -2709,7 +2727,7 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", "rprompt 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2719,7 +2737,7 @@ name = "rpc-cli" version = "1.4.0" dependencies = [ "bigint 4.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", "parity-rpc 1.9.0", "parity-rpc-client 1.4.0", "rpassword 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2736,7 +2754,7 @@ version = "0.2.36" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "gcc 0.3.54 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.3.20 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.38 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2776,7 +2794,7 @@ version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2796,7 +2814,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "core-foundation 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "core-foundation-sys 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", "security-framework-sys 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2806,7 +2824,7 @@ version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "core-foundation-sys 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2929,7 +2947,7 @@ name = "smallvec" version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "heapsize 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2937,7 +2955,7 @@ name = "snappy" version = "0.1.0" source = "git+https://github.com/paritytech/rust-snappy#858eac97192ea25d18d3f3626a8cc13ca0b175bb" dependencies = [ - "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", "snappy-sys 0.1.0 (git+https://github.com/paritytech/rust-snappy)", ] @@ -2947,7 +2965,7 @@ version = "0.1.0" source = "git+https://github.com/paritytech/rust-snappy#858eac97192ea25d18d3f3626a8cc13ca0b175bb" dependencies = [ "gcc 0.3.54 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3016,7 +3034,7 @@ name = "syntex_errors" version = "0.58.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)", "syntex_pos 0.58.1 (registry+https://github.com/rust-lang/crates.io-index)", "term 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3081,7 +3099,7 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -3116,7 +3134,7 @@ version = "0.1.38" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", "redox_syscall 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -3132,7 +3150,7 @@ version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", "iovec 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "mio 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3147,7 +3165,7 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -3157,7 +3175,7 @@ version = "0.1.0" source = "git+https://github.com/nikvolf/tokio-named-pipes#0b9b728eaeb0a6673c287ac7692be398fd651752" dependencies = [ "bytes 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", "mio-named-pipes 0.1.4 (git+https://github.com/alexcrichton/mio-named-pipes)", "tokio-core 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3168,7 +3186,7 @@ name = "tokio-proto" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "futures 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "net2 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.3.20 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3185,7 +3203,7 @@ name = "tokio-service" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "futures 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3193,7 +3211,7 @@ name = "tokio-timer" version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "futures 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", "slab 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -3202,7 +3220,7 @@ name = "tokio-tls" version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "futures 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", "native-tls 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-core 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3214,9 +3232,9 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", "iovec 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "mio 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", "mio-uds 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3242,7 +3260,7 @@ name = "transaction-pool" version = "1.9.0" dependencies = [ "error-chain 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", - "ethereum-types 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "ethereum-types 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -3267,7 +3285,7 @@ dependencies = [ name = "triehash" version = "0.1.0" dependencies = [ - "ethereum-types 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "ethereum-types 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "keccak-hash 0.1.0", "rlp 0.2.1", ] @@ -3279,11 +3297,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "uint" -version = "0.1.0" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "byteorder 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "heapsize 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -3381,7 +3399,7 @@ name = "util-error" version = "0.1.0" dependencies = [ "error-chain 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", - "ethereum-types 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "ethereum-types 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "kvdb 0.1.0", "rlp 0.2.1", "rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3432,10 +3450,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" name = "vm" version = "0.1.0" dependencies = [ - "byteorder 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "common-types 0.1.0", "ethcore-bytes 0.1.0", - "ethereum-types 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "ethereum-types 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "ethjson 0.1.0", "keccak-hash 0.1.0", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3452,10 +3470,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" name = "wasm" version = "0.1.0" dependencies = [ - "byteorder 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "ethcore-logger 1.9.0", - "ethereum-types 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", + "ethereum-types 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-wasm 0.23.0 (registry+https://github.com/rust-lang/crates.io-index)", "vm 0.1.0", @@ -3468,7 +3486,7 @@ name = "wasm-utils" version = "0.1.0" source = "git+https://github.com/paritytech/wasm-utils#6fdc1c4ed47a6acb0a4774da505a416dd637bc6d" dependencies = [ - "byteorder 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "clap 2.29.1 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3482,7 +3500,7 @@ name = "wasmi" version = "0.0.0" source = "git+https://github.com/pepyakin/wasmi#551c99273042deaad869c17798060e2212deacab" dependencies = [ - "byteorder 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "parity-wasm 0.23.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -3493,11 +3511,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "winapi" -version = "0.3.3" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "winapi-i686-pc-windows-gnu 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi-x86_64-pc-windows-gnu 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3507,12 +3525,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "winapi-i686-pc-windows-gnu" -version = "0.3.2" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "winapi-x86_64-pc-windows-gnu" -version = "0.3.2" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -3520,7 +3538,7 @@ name = "ws" version = "0.7.1" source = "git+https://github.com/tomusdrw/ws-rs#f8306a798b7541d64624299a83a2c934f173beed" dependencies = [ - "byteorder 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "httparse 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3594,7 +3612,7 @@ dependencies = [ "checksum bitflags 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4efd02e230a02e18f92fc2735f44597385ed02ad8f831e7c1c1156ee5e1ab3a5" "checksum bitflags 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b3c30d3802dfb7281680d6285f2ccdaa8c2d8fee41f93805dba5c4cf50dc23cf" "checksum bn 0.4.4 (git+https://github.com/paritytech/bn)" = "" -"checksum byteorder 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ff81738b726f5d099632ceaffe7fb65b90212e8dce59d518729e7e8634032d3d" +"checksum byteorder 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "652805b7e73fada9d85e9a6682a4abd490cb52d96aeecc12e33a0de34dfd0d23" "checksum bytes 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "1b7db437d718977f6dc9b2e3fd6fc343c02ac6b899b73fdd2179163447bd9ce9" "checksum cc 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7db2f146208d7e0fbee761b09cd65a7f51ccc38705d4e7262dad4d73b12a76b1" "checksum cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d4c819a1287eb618df47cc647173c5c4c66ba19d888a6e50d605672aed3140de" @@ -3619,26 +3637,29 @@ dependencies = [ "checksum env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3ddf21e73e016298f5cb37d6ef8e8da8e39f91f9ec8b0df44b7deb16a9f8cd5b" "checksum error-chain 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ff511d5dc435d703f4971bc399647c9bc38e20cb41452e3b9feb4765419ed3f3" "checksum eth-secp256k1 0.5.7 (git+https://github.com/paritytech/rust-secp256k1)" = "" -"checksum ethabi 4.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c819a3adef0413a2519cbd9a19a35dd1c20c7a0110705beaba8aa4aa87eda95f" -"checksum ethbloom 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "dd5f7fb5d27fb017f21c15d1e0b953831b58581c9942a5e5614fd2b6603697b7" -"checksum ethereum-types 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "2adaa5b8ceafcce0bc3a68ef116ca5702958cc97d70a6eb008aeddb569b092b3" +"checksum ethabi 5.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7d8385a48c8ed984778dcca27efc0de162a191a14ed733a41a07d9b0cfaa999e" +"checksum ethabi-contract 5.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ca2263c24359e827348ac99aa1f2e28ba5bab0d6c0b83941fa252de8a9e9c073" +"checksum ethabi-derive 5.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "9a357d3f4f249408af8d8b241b53b39a419328606825d3bb3fef841bb9d8ba13" +"checksum ethbloom 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f240172b976e2421fa5485e45cd45287bbdb56d742aa3a1d77005c49071a8518" +"checksum ethereum-types 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "bad6fb0e4ab648f4d8d8314c340c47f9e805b085b78be1b8da4676534cb419df" +"checksum ethereum-types-serialize 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4ac59a21a9ce98e188f3dace9eb67a6c4a3c67ec7fbc7218cb827852679dc002" "checksum fdlimit 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b1ee15a7050e5580b3712877157068ea713b245b080ff302ae2ca973cfcd9baa" -"checksum fixed-hash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "75f91321a3926b773df3c6e7e953e3c756d9c06f0e9f05d34a0e103b03fcc9a1" +"checksum fixed-hash 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "21c520ebc46522d519aec9cba2b7115d49cea707d771b772c46bec61aa0daeb8" "checksum flate2 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)" = "e6234dd4468ae5d1e2dbb06fe2b058696fdc50a339c68a393aefbf00bc81e423" "checksum fnv 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "6cc484842f1e2884faf56f529f960cc12ad8c71ce96cc7abba0a067c98fee344" "checksum foreign-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" "checksum foreign-types-shared 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" "checksum fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" "checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" -"checksum futures 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)" = "118b49cac82e04121117cbd3121ede3147e885627d82c4546b87c702debb90c1" -"checksum futures-cpupool 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "77d49e7de8b91b20d6fda43eea906637eff18b96702eb6b2872df8bfab1ad2b5" +"checksum futures 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)" = "0bab5b5e94f5c31fc764ba5dd9ad16568aae5d4825538c01d6bca680c9bf94a7" +"checksum futures-cpupool 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "ab90cde24b3319636588d0c35fe03b1333857621051837ed769faefb4c2162e4" "checksum gcc 0.3.54 (registry+https://github.com/rust-lang/crates.io-index)" = "5e33ec290da0d127825013597dbdfc28bee4964690c7ce1166cbc2a7bd08b1bb" "checksum getopts 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)" = "65922871abd2f101a2eb0eaebadc66668e54a87ad9c3dd82520b5f86ede5eff9" "checksum glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "8be18de09a56b60ed0edf84bc9df007e30040691af7acd1c41874faac5895bfb" "checksum globset 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "464627f948c3190ae3d04b1bc6d7dca2f785bda0ac01278e6db129ad383dbeb6" "checksum hamming 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "65043da274378d68241eb9a8f8f8aa54e349136f7b8e12f63e3ef44043cc30e1" -"checksum heapsize 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "54fab2624374e5137ae4df13bf32b0b269cb804df42d13a51221bbd431d1a237" -"checksum heck 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ea04fa3ead4e05e51a7c806fc07271fdbde4e246a6c6d1efd52e72230b771b82" +"checksum heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1679e6ea370dee694f91f1dc469bf94cf8f52051d147aec3e1f9497c6fc22461" +"checksum heck 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e0db42a2924a5d7d628685e7a8cf9a2edd628650a9d01efc3dde35d3cdd22451" "checksum hex 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d6a22814455d41612f41161581c2883c0c6a1c41852729b17d5ed88f01e153aa" "checksum hidapi 0.3.1 (git+https://github.com/paritytech/hidapi-rs)" = "" "checksum httparse 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "af2f2dd97457e8fb1ae7c5a420db346af389926e36f43768b96f101546b04a07" @@ -3668,7 +3689,7 @@ dependencies = [ "checksum lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "3b37545ab726dd833ec6420aaba8231c5b320814b9029ad585555d2a03e94fbf" "checksum lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c8f31047daa365f19be14b47c29df4f7c3b581832407daabe6ae77397619237d" "checksum lazycell 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3b585b7a6811fb03aa10e74b278a0f00f8dd9b45dc681f148bb29fa5cb61859b" -"checksum libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)" = "d1419b2939a0bc44b77feb34661583c7546b532b192feab36249ab584b86856c" +"checksum libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)" = "1e5d97d6708edaa407429faa671b942dc0f2727222fb6b6539bf1db936e4b121" "checksum libflate 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)" = "a2aa04ec0100812d31a5366130ff9e793291787bc31da845bede4a00ea329830" "checksum libusb 0.3.0 (git+https://github.com/paritytech/libusb-rs)" = "" "checksum libusb-sys 0.2.4 (git+https://github.com/paritytech/libusb-sys)" = "" @@ -3819,7 +3840,7 @@ dependencies = [ "checksum transient-hashmap 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "715254c8f0811be1a79ad3ea5e6fa3c8eddec2b03d7f5ba78cf093e56d79c24f" "checksum trezor-sys 1.0.0 (git+https://github.com/paritytech/trezor-sys)" = "" "checksum typeable 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1410f6f91f21d1612654e7cc69193b0334f909dcf2c790c4826254fbb86f8887" -"checksum uint 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "91ed1e25ded4e37e0967b1f12d5f910b32f979768d4f48e2f6ca7b6e7130b44e" +"checksum uint 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "53a4340c35703f926ec365c6797bb4a7a10bb6b9affe29ca385c9d804401f5e3" "checksum unicase 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7f4765f83163b74f957c797ad9253caf97f103fb064d3999aea9568d09fc8a33" "checksum unicase 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "284b6d3db520d67fbe88fd778c21510d1b0ba4a551e5d0fbb023d33405f6de8a" "checksum unicode-bidi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "49f2bd0c6468a8230e1db229cff8029217cf623c767ea5d60bfbd42729ea54d5" @@ -3842,10 +3863,10 @@ dependencies = [ "checksum wasm-utils 0.1.0 (git+https://github.com/paritytech/wasm-utils)" = "" "checksum wasmi 0.0.0 (git+https://github.com/pepyakin/wasmi)" = "" "checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" -"checksum winapi 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b09fb3b6f248ea4cd42c9a65113a847d612e17505d6ebd1f7357ad68a8bf8693" +"checksum winapi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "04e3bd221fcbe8a271359c04f21a76db7d0c6028862d1bb5512d85e1e2eb5bb3" "checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" -"checksum winapi-i686-pc-windows-gnu 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "ec6667f60c23eca65c561e63a13d81b44234c2e38a6b6c959025ee907ec614cc" -"checksum winapi-x86_64-pc-windows-gnu 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "98f12c52b2630cd05d2c3ffd8e008f7f48252c042b4871c72aed9dc733b96668" +"checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" +"checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" "checksum ws 0.7.1 (git+https://github.com/tomusdrw/ws-rs)" = "" "checksum ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e" "checksum xdg 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a66b7c2281ebde13cf4391d70d4c7e5946c3c25e72a7b859ca8f677dcd0b0c61" diff --git a/Cargo.toml b/Cargo.toml index c7f7cc4cd..fa3e17811 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -45,7 +45,7 @@ ethcore-miner = { path = "miner" } ethcore-network = { path = "util/network" } ethcore-stratum = { path = "stratum" } ethcore-transaction = { path = "ethcore/transaction" } -ethereum-types = "0.1" +ethereum-types = "0.2" node-filter = { path = "ethcore/node_filter" } ethkey = { path = "ethkey" } node-health = { path = "dapps/node-health" } diff --git a/dapps/Cargo.toml b/dapps/Cargo.toml index f0902a7e3..bbe695427 100644 --- a/dapps/Cargo.toml +++ b/dapps/Cargo.toml @@ -16,7 +16,7 @@ log = "0.3" parity-dapps-glue = "1.9" parking_lot = "0.5" mime_guess = "2.0.0-alpha.2" -rand = "0.3" +rand = "0.4" rustc-hex = "1.0" serde = "1.0" serde_derive = "1.0" @@ -29,7 +29,7 @@ jsonrpc-core = { git = "https://github.com/paritytech/jsonrpc.git", branch = "pa jsonrpc-http-server = { git = "https://github.com/paritytech/jsonrpc.git", branch = "parity-1.10" } ethcore-bytes = { path = "../util/bytes" } -ethereum-types = "0.1" +ethereum-types = "0.2" fetch = { path = "../util/fetch" } node-health = { path = "./node-health" } parity-hash-fetch = { path = "../hash-fetch" } diff --git a/dapps/src/apps/fetcher/mod.rs b/dapps/src/apps/fetcher/mod.rs index 797b69947..2b10351e1 100644 --- a/dapps/src/apps/fetcher/mod.rs +++ b/dapps/src/apps/fetcher/mod.rs @@ -23,7 +23,6 @@ mod installers; use std::{fs, env}; use std::path::PathBuf; use std::sync::Arc; -use rustc_hex::FromHex; use futures::{future, Future}; use futures_cpupool::CpuPool; use fetch::{Client as FetchClient, Fetch}; @@ -31,6 +30,7 @@ use hash_fetch::urlhint::{URLHintContract, URLHint, URLHintResult}; use hyper::StatusCode; +use ethereum_types::H256; use {Embeddable, SyncStatus, random_filename}; use parking_lot::Mutex; use page::local; @@ -132,7 +132,7 @@ impl ContentFetcher { // resolve contract call synchronously. // TODO: port to futures-based hyper and make it all async. - fn resolve(&self, content_id: Vec) -> Option { + fn resolve(&self, content_id: H256) -> Option { self.resolver.resolve(content_id) .wait() .unwrap_or_else(|e| { warn!("Error resolving content-id: {}", e); None }) @@ -149,7 +149,7 @@ impl Fetcher for ContentFetcher { } } // fallback to resolver - if let Ok(content_id) = content_id.from_hex() { + if let Ok(content_id) = content_id.parse() { // if there is content or we are syncing return true self.sync.is_major_importing() || self.resolve(content_id).is_some() } else { @@ -178,7 +178,7 @@ impl Endpoint for ContentFetcher { // We need to start fetching the content _ => { trace!(target: "dapps", "Content unavailable. Fetching... {:?}", content_id); - let content_hex = content_id.from_hex().expect("to_handler is called only when `contains` returns true."); + let content_hex = content_id.parse().expect("to_handler is called only when `contains` returns true."); let content = self.resolve(content_hex); let cache = self.cache.clone(); @@ -280,10 +280,10 @@ impl Endpoint for ContentFetcher { mod tests { use std::env; use std::sync::Arc; - use bytes::Bytes; use fetch::{Fetch, Client}; - use futures::future; - use hash_fetch::urlhint::{URLHint, URLHintResult, BoxFuture}; + use futures::{future, Future}; + use hash_fetch::urlhint::{URLHint, URLHintResult}; + use ethereum_types::H256; use apps::cache::ContentStatus; use endpoint::EndpointInfo; @@ -294,7 +294,7 @@ mod tests { #[derive(Clone)] struct FakeResolver; impl URLHint for FakeResolver { - fn resolve(&self, _id: Bytes) -> BoxFuture, String> { + fn resolve(&self, _id: H256) -> Box, Error = String> + Send> { Box::new(future::ok(None)) } } diff --git a/dapps/src/tests/helpers/registrar.rs b/dapps/src/tests/helpers/registrar.rs index 2f7a33e1b..139128f9a 100644 --- a/dapps/src/tests/helpers/registrar.rs +++ b/dapps/src/tests/helpers/registrar.rs @@ -18,9 +18,10 @@ use std::str; use std::sync::Arc; use std::collections::HashMap; +use futures::Future; use ethereum_types::{H256, Address}; use bytes::{Bytes, ToPretty}; -use hash_fetch::urlhint::{ContractClient, BoxFuture}; +use hash_fetch::urlhint::ContractClient; use parking_lot::Mutex; use rustc_hex::FromHex; @@ -66,7 +67,7 @@ impl ContractClient for FakeRegistrar { Ok(REGISTRAR.parse().unwrap()) } - fn call(&self, address: Address, data: Bytes) -> BoxFuture { + fn call(&self, address: Address, data: Bytes) -> Box + Send> { let call = (address.to_hex(), data.to_hex()); self.calls.lock().push(call.clone()); let res = self.responses.lock().get(&call).cloned().expect(&format!("No response for call: {:?}", call)); diff --git a/ethcore/Cargo.toml b/ethcore/Cargo.toml index f1f519d42..b93eb3bcc 100644 --- a/ethcore/Cargo.toml +++ b/ethcore/Cargo.toml @@ -24,27 +24,28 @@ ethcore-logger = { path = "../logger" } ethcore-miner = { path = "../miner" } ethcore-stratum = { path = "../stratum" } ethcore-transaction = { path = "./transaction" } -ethereum-types = "0.1" +ethereum-types = "0.2" memory-cache = { path = "../util/memory_cache" } +ethabi = "5.1" +ethabi-derive = "5.0" +ethabi-contract = "5.0" ethjson = { path = "../json" } ethkey = { path = "../ethkey" } ethstore = { path = "../ethstore" } evm = { path = "evm" } -futures = "0.1" hardware-wallet = { path = "../hw" } heapsize = "0.4" itertools = "0.5" lazy_static = "1.0" log = "0.3" lru-cache = "0.1" -native-contracts = { path = "native_contracts" } num = "0.1" num_cpus = "1.2" parity-machine = { path = "../machine" } parking_lot = "0.5" price-info = { path = "../price-info" } rayon = "0.8" -rand = "0.3" +rand = "0.4" rlp = { path = "../util/rlp" } rlp_derive = { path = "../util/rlp_derive" } kvdb = { path = "../util/kvdb" } @@ -69,9 +70,6 @@ unexpected = { path = "../util/unexpected" } journaldb = { path = "../util/journaldb" } tempdir = "0.3" -[dev-dependencies] -native-contracts = { path = "native_contracts", features = ["test_contracts"] } - [features] jit = ["evm/jit"] evm-debug = ["slow-blocks"] diff --git a/ethcore/evm/Cargo.toml b/ethcore/evm/Cargo.toml index 6dc771e64..6efc05f4e 100644 --- a/ethcore/evm/Cargo.toml +++ b/ethcore/evm/Cargo.toml @@ -5,7 +5,7 @@ authors = ["Parity Technologies "] [dependencies] bit-set = "0.4" -ethereum-types = "0.1" +ethereum-types = "0.2" evmjit = { path = "../../evmjit", optional = true } heapsize = "0.4" lazy_static = "1.0" diff --git a/ethcore/light/Cargo.toml b/ethcore/light/Cargo.toml index 34cf56c4d..0aea8d3bf 100644 --- a/ethcore/light/Cargo.toml +++ b/ethcore/light/Cargo.toml @@ -11,7 +11,7 @@ log = "0.3" ethcore = { path = ".."} ethcore-bytes = { path = "../../util/bytes" } ethcore-transaction = { path = "../transaction" } -ethereum-types = "0.1" +ethereum-types = "0.2" memorydb = { path = "../../util/memorydb" } patricia-trie = { path = "../../util/patricia_trie" } ethcore-network = { path = "../../util/network" } @@ -26,7 +26,7 @@ rlp_derive = { path = "../../util/rlp_derive" } time = "0.1" smallvec = "0.4" futures = "0.1" -rand = "0.3" +rand = "0.4" itertools = "0.5" bincode = "0.8.0" serde = "1.0" diff --git a/ethcore/light/src/client/header_chain.rs b/ethcore/light/src/client/header_chain.rs index 1a9249218..6de68bbe3 100644 --- a/ethcore/light/src/client/header_chain.rs +++ b/ethcore/light/src/client/header_chain.rs @@ -724,6 +724,7 @@ mod tests { use super::HeaderChain; use std::sync::Arc; + use ethereum_types::U256; use ethcore::ids::BlockId; use ethcore::header::Header; use ethcore::spec::Spec; @@ -755,7 +756,7 @@ mod tests { header.set_parent_hash(parent_hash); header.set_number(i); header.set_timestamp(rolling_timestamp); - header.set_difficulty(*genesis_header.difficulty() * i.into()); + header.set_difficulty(*genesis_header.difficulty() * i as u32); parent_hash = header.hash(); let mut tx = db.transaction(); @@ -788,7 +789,7 @@ mod tests { header.set_parent_hash(parent_hash); header.set_number(i); header.set_timestamp(rolling_timestamp); - header.set_difficulty(*genesis_header.difficulty() * i.into()); + header.set_difficulty(*genesis_header.difficulty() * i as u32); parent_hash = header.hash(); let mut tx = db.transaction(); @@ -807,7 +808,7 @@ mod tests { header.set_parent_hash(parent_hash); header.set_number(i); header.set_timestamp(rolling_timestamp); - header.set_difficulty(*genesis_header.difficulty() * i.into()); + header.set_difficulty(*genesis_header.difficulty() * i as u32); parent_hash = header.hash(); let mut tx = db.transaction(); @@ -831,7 +832,7 @@ mod tests { header.set_parent_hash(parent_hash); header.set_number(i); header.set_timestamp(rolling_timestamp); - header.set_difficulty(*genesis_header.difficulty() * (i * i).into()); + header.set_difficulty(*genesis_header.difficulty() * U256::from(i * i)); parent_hash = header.hash(); let mut tx = db.transaction(); @@ -884,7 +885,7 @@ mod tests { header.set_parent_hash(parent_hash); header.set_number(i); header.set_timestamp(rolling_timestamp); - header.set_difficulty(*genesis_header.difficulty() * i.into()); + header.set_difficulty(*genesis_header.difficulty() * i as u32); parent_hash = header.hash(); let mut tx = db.transaction(); @@ -922,7 +923,7 @@ mod tests { header.set_parent_hash(parent_hash); header.set_number(i); header.set_timestamp(rolling_timestamp); - header.set_difficulty(*genesis_header.difficulty() * i.into()); + header.set_difficulty(*genesis_header.difficulty() * i as u32); parent_hash = header.hash(); let mut tx = db.transaction(); @@ -939,7 +940,7 @@ mod tests { header.set_parent_hash(parent_hash); header.set_number(i); header.set_timestamp(rolling_timestamp); - header.set_difficulty(*genesis_header.difficulty() * i.into() * 1000.into()); + header.set_difficulty(*genesis_header.difficulty() * U256::from(i as u32 * 1000u32)); parent_hash = header.hash(); let mut tx = db.transaction(); @@ -989,7 +990,7 @@ mod tests { header.set_parent_hash(parent_hash); header.set_number(i); header.set_timestamp(rolling_timestamp); - header.set_difficulty(*genesis_header.difficulty() * i.into()); + header.set_difficulty(*genesis_header.difficulty() * i as u32); parent_hash = header.hash(); let mut tx = db.transaction(); @@ -1023,7 +1024,7 @@ mod tests { header.set_parent_hash(parent_hash); header.set_number(i); header.set_timestamp(rolling_timestamp); - header.set_difficulty(*genesis_header.difficulty() * i.into()); + header.set_difficulty(*genesis_header.difficulty() * i as u32); parent_hash = header.hash(); let mut tx = db.transaction(); diff --git a/ethcore/light/src/net/request_credits.rs b/ethcore/light/src/net/request_credits.rs index db98115bc..cf11574e7 100644 --- a/ethcore/light/src/net/request_credits.rs +++ b/ethcore/light/src/net/request_credits.rs @@ -320,7 +320,7 @@ impl FlowParams { /// and number of requests made. pub fn compute_cost(&self, request: &Request) -> Option { match *request { - Request::Headers(ref req) => self.costs.headers.map(|c| c * req.max.into()), + Request::Headers(ref req) => self.costs.headers.map(|c| c * U256::from(req.max)), Request::HeaderProof(_) => self.costs.header_proof, Request::TransactionIndex(_) => self.costs.transaction_index, Request::Body(_) => self.costs.body, @@ -444,6 +444,6 @@ mod tests { ); assert_eq!(flow_params2.costs, flow_params3.costs); - assert_eq!(flow_params.costs.headers.unwrap(), flow_params2.costs.headers.unwrap() * 2.into()); + assert_eq!(flow_params.costs.headers.unwrap(), flow_params2.costs.headers.unwrap() * 2u32); } } diff --git a/ethcore/migrations/Cargo.toml b/ethcore/migrations/Cargo.toml index 8b8c58842..db9c31bc3 100644 --- a/ethcore/migrations/Cargo.toml +++ b/ethcore/migrations/Cargo.toml @@ -5,7 +5,7 @@ authors = ["Parity Technologies "] [dependencies] ethcore-bytes = { path = "../../util/bytes" } -ethereum-types = "0.1.4" +ethereum-types = "0.2" keccak-hash = { path = "../../util/hash" } kvdb = { path = "../../util/kvdb" } kvdb-rocksdb = { path = "../../util/kvdb-rocksdb" } diff --git a/ethcore/native_contracts/Cargo.toml b/ethcore/native_contracts/Cargo.toml deleted file mode 100644 index 34460a5cb..000000000 --- a/ethcore/native_contracts/Cargo.toml +++ /dev/null @@ -1,19 +0,0 @@ -[package] -name = "native-contracts" -description = "Generated Rust code for Ethereum contract ABIs" -version = "0.1.0" -authors = ["Parity Technologies "] -build = "build.rs" - -[dependencies] -ethabi = "4.0" -futures = "0.1" -byteorder = "1.0" -ethereum-types = "0.1" - -[build-dependencies] -native-contract-generator = { path = "generator" } - -[features] -default = [] -test_contracts = [] diff --git a/ethcore/native_contracts/build.rs b/ethcore/native_contracts/build.rs deleted file mode 100644 index 72250dba5..000000000 --- a/ethcore/native_contracts/build.rs +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2015-2017 Parity Technologies (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 native_contract_generator; - -use std::path::Path; -use std::fs::File; -use std::io::Write; - -// TODO: just walk the "res" directory and generate whole crate automatically. -const KEY_SERVER_SET_ABI: &'static str = include_str!("res/key_server_set.json"); -const REGISTRY_ABI: &'static str = include_str!("res/registrar.json"); -const URLHINT_ABI: &'static str = include_str!("res/urlhint.json"); -const SERVICE_TRANSACTION_ABI: &'static str = include_str!("res/service_transaction.json"); -const SECRETSTORE_ACL_STORAGE_ABI: &'static str = include_str!("res/secretstore_acl_storage.json"); -const SECRETSTORE_SERVICE_ABI: &'static str = include_str!("res/secretstore_service.json"); -const VALIDATOR_SET_ABI: &'static str = include_str!("res/validator_set.json"); -const VALIDATOR_REPORT_ABI: &'static str = include_str!("res/validator_report.json"); -const PEER_SET_ABI: &'static str = include_str!("res/peer_set.json"); -const TX_ACL_ABI: &'static str = include_str!("res/tx_acl.json"); - -const TEST_VALIDATOR_SET_ABI: &'static str = include_str!("res/test_validator_set.json"); - -fn build_file(name: &str, abi: &str, filename: &str) { - let code = ::native_contract_generator::generate_module(name, abi).unwrap(); - - let out_dir = ::std::env::var("OUT_DIR").unwrap(); - let dest_path = Path::new(&out_dir).join(filename); - let mut f = File::create(&dest_path).unwrap(); - - f.write_all(code.as_bytes()).unwrap(); -} - -fn build_test_contracts() { - build_file("ValidatorSet", TEST_VALIDATOR_SET_ABI, "test_validator_set.rs"); -} - -fn main() { - build_file("KeyServerSet", KEY_SERVER_SET_ABI, "key_server_set.rs"); - build_file("Registry", REGISTRY_ABI, "registry.rs"); - build_file("Urlhint", URLHINT_ABI, "urlhint.rs"); - build_file("ServiceTransactionChecker", SERVICE_TRANSACTION_ABI, "service_transaction.rs"); - build_file("SecretStoreAclStorage", SECRETSTORE_ACL_STORAGE_ABI, "secretstore_acl_storage.rs"); - build_file("SecretStoreService", SECRETSTORE_SERVICE_ABI, "secretstore_service.rs"); - build_file("ValidatorSet", VALIDATOR_SET_ABI, "validator_set.rs"); - build_file("ValidatorReport", VALIDATOR_REPORT_ABI, "validator_report.rs"); - build_file("PeerSet", PEER_SET_ABI, "peer_set.rs"); - build_file("TransactAcl", TX_ACL_ABI, "tx_acl.rs"); - - build_test_contracts(); -} diff --git a/ethcore/native_contracts/generator/Cargo.toml b/ethcore/native_contracts/generator/Cargo.toml deleted file mode 100644 index 1605bc9e2..000000000 --- a/ethcore/native_contracts/generator/Cargo.toml +++ /dev/null @@ -1,9 +0,0 @@ -[package] -name = "native-contract-generator" -description = "Generates Rust code for ethereum contract ABIs" -version = "0.1.0" -authors = ["Parity Technologies "] - -[dependencies] -ethabi = "4.0" -heck = "0.3" diff --git a/ethcore/native_contracts/generator/src/lib.rs b/ethcore/native_contracts/generator/src/lib.rs deleted file mode 100644 index f8caf0467..000000000 --- a/ethcore/native_contracts/generator/src/lib.rs +++ /dev/null @@ -1,373 +0,0 @@ -// Copyright 2015-2017 Parity Technologies (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 . - -//! Rust code contract generator. -//! The code generated will require a dependence on the `ethcore-ethereum_types`, -//! `ethabi`, `byteorder`, and `futures` crates. -//! This currently isn't hygienic, so compilation of generated code may fail -//! due to missing crates or name collisions. This will change when -//! it can be ported to a procedural macro. - -extern crate ethabi; -extern crate heck; - -use ethabi::{Contract, ParamType}; -use heck::SnakeCase; - -/// Errors in generation. -#[derive(Debug)] -pub enum Error { - /// Bad ABI. - Abi(ethabi::Error), - /// Unsupported parameter type in given function. - UnsupportedType(String, ParamType), -} - -/// Given an ABI string, generate code for a a Rust module containing -/// a struct which can be used to call it. -// TODO: make this a proc macro when that's possible. -pub fn generate_module(struct_name: &str, abi: &str) -> Result { - let contract = Contract::load(abi.as_bytes()).map_err(Error::Abi)?; - let functions = generate_functions(&contract)?; - - Ok(format!(r##" -use byteorder::{{BigEndian, ByteOrder}}; -use futures::{{future, Future, IntoFuture}}; -use ethabi::{{Bytes, Contract, Token, Event}}; -use ethereum_types; - -type BoxFuture = Box + Send>; - -/// Generated Rust bindings to an Ethereum contract. -#[derive(Clone, Debug)] -pub struct {name} {{ - contract: Contract, - /// Address to make calls to. - pub address: ethereum_types::H160, -}} - -const ABI: &'static str = r#"{abi_str}"#; - -impl {name} {{ - /// Create a new instance of `{name}` with an address. - /// Calls can be made, given a callback for dispatching calls asynchronously. - pub fn new(address: ethereum_types::H160) -> Self {{ - let contract = Contract::load(ABI.as_bytes()) - .expect("ABI checked at generation-time; qed"); - {name} {{ - contract: contract, - address: address, - }} - }} - - /// Access the underlying `ethabi` contract. - pub fn contract(this: &Self) -> &Contract {{ - &this.contract - }} - - {functions} -}} -"##, - name = struct_name, - abi_str = abi, - functions = functions, - )) -} - -// generate function bodies from the ABI. -fn generate_functions(contract: &Contract) -> Result { - let mut functions = String::new(); - for function in contract.functions() { - let name = &function.name; - let snake_name = name.to_snake_case(); - let inputs: Vec<_> = function.inputs.iter().map(|i| i.kind.clone()).collect(); - let outputs: Vec<_> = function.outputs.iter().map(|i| i.kind.clone()).collect(); - - let (input_params, input_names, to_tokens) = input_params_codegen(&inputs) - .map_err(|bad_type| Error::UnsupportedType(name.clone(), bad_type))?; - - let (output_type, decode_outputs) = output_params_codegen(&outputs) - .map_err(|bad_type| Error::UnsupportedType(name.clone(), bad_type))?; - - functions.push_str(&format!(r##" -/// Call the function "{abi_name}" on the contract. -/// -/// Inputs: {abi_inputs:?} -/// Outputs: {abi_outputs:?} -pub fn {snake_name}(&self, call: F, {params}) -> BoxFuture<{output_type}, String> - where - F: FnOnce(ethereum_types::H160, Vec) -> U, - U: IntoFuture, Error=String>, - U::Future: Send + 'static -{{ - let call_addr = self.address; - let call_future = match self.encode_{snake_name}_input({params_names}) {{ - Ok(call_data) => (call)(call_addr, call_data), - Err(e) => return Box::new(future::err(e)), - }}; - - let function = self.contract.function(r#"{abi_name}"#) - .expect("function existence checked at compile-time; qed").clone(); - - Box::new(call_future - .into_future() - .and_then(move |out| function.decode_output(&out).map_err(|e| format!("{{:?}}", e))) - .map(Vec::into_iter) - .and_then(|mut outputs| {decode_outputs})) -}} - -/// Encode "{abi_name}" function arguments. -/// Arguments: {abi_inputs:?} -pub fn encode_{snake_name}_input(&self, {params}) -> Result, String> {{ - self.contract.function(r#"{abi_name}"#) - .expect("function existence checked at compile-time; qed") - .encode_input(&{to_tokens}) - .map_err(|e| format!("Error encoding call: {{:?}}", e)) -}} - "##, - abi_name = name, - abi_inputs = inputs, - abi_outputs = outputs, - snake_name = snake_name, - params = input_params, - params_names = input_names, - output_type = output_type, - to_tokens = to_tokens, - decode_outputs = decode_outputs, - )) - } - - Ok(functions) -} - -// generate code for params in function signature and turning them into tokens. -// -// three pieces of code are generated: the first gives input types for the function signature, -// the second one gives input parameter names to pass to another method, -// and the third gives code to tokenize those inputs. -// -// params of form `param_0: type_0, param_1: type_1, ...` -// tokenizing code of form `{let mut tokens = Vec::new(); tokens.push({param_X}); tokens }` -// -// returns any unsupported param type encountered. -fn input_params_codegen(inputs: &[ParamType]) -> Result<(String, String, String), ParamType> { - let mut params = String::new(); - let mut params_names = String::new(); - let mut to_tokens = "{ let mut tokens = Vec::new();".to_string(); - - for (index, param_type) in inputs.iter().enumerate() { - let param_name = format!("param_{}", index); - let rust_type = rust_type(param_type.clone())?; - let (needs_mut, tokenize_code) = tokenize(¶m_name, param_type.clone()); - - params.push_str(&format!("{}{}: {}, ", - if needs_mut { "mut " } else { "" }, param_name, rust_type)); - - params_names.push_str(&format!("{}, ", param_name)); - - to_tokens.push_str(&format!("tokens.push({{ {} }});", tokenize_code)); - } - - to_tokens.push_str(" tokens }"); - Ok((params, params_names, to_tokens)) -} - -// generate code for outputs of the function and detokenizing them. -// -// two pieces of code are generated: the first gives an output type for the function signature -// as a tuple, and the second gives code to get that tuple from a deque of tokens. -// -// produce output type of the form (type_1, type_2, ...) without trailing comma. -// produce code for getting this output type from `outputs: Vec::IntoIter`, where -// an `Err(String)` can be returned. -// -// returns any unsupported param type encountered. -fn output_params_codegen(outputs: &[ParamType]) -> Result<(String, String), ParamType> { - let mut output_type = "(".to_string(); - let mut decode_outputs = "Ok((".to_string(); - - for (index, output) in outputs.iter().cloned().enumerate() { - let rust_type = rust_type(output.clone())?; - - output_type.push_str(&rust_type); - - decode_outputs.push_str(&format!( - r#" - outputs - .next() - .and_then(|output| {{ {} }}) - .ok_or_else(|| "Wrong output type".to_string())? - "#, - detokenize("output", output) - )); - - // don't append trailing commas for the last element - // so we can reuse the same code for single-output contracts, - // since T == (T) != (T,) - if index < outputs.len() - 1 { - output_type.push_str(", "); - decode_outputs.push_str(", "); - } - } - - output_type.push_str(")"); - decode_outputs.push_str("))"); - Ok((output_type, decode_outputs)) -} - -// create code for an argument type from param type. -fn rust_type(input: ParamType) -> Result { - Ok(match input { - ParamType::Address => "ethereum_types::H160".into(), - ParamType::FixedBytes(len) if len <= 32 => format!("ethereum_types::H{}", len * 8), - ParamType::Bytes | ParamType::FixedBytes(_) => "Vec".into(), - ParamType::Int(width) => match width { - 8 | 16 | 32 | 64 => format!("i{}", width), - _ => return Err(ParamType::Int(width)), - }, - ParamType::Uint(width) => match width { - 8 | 16 | 32 | 64 => format!("u{}", width), - 128 | 160 | 256 => format!("ethereum_types::U{}", width), - _ => return Err(ParamType::Uint(width)), - }, - ParamType::Bool => "bool".into(), - ParamType::String => "String".into(), - ParamType::Array(kind) => format!("Vec<{}>", rust_type(*kind)?), - other => return Err(other), - }) -} - -// create code for tokenizing this parameter. -// returns (needs_mut, code), where needs_mut indicates mutability required. -// panics on unsupported types. -fn tokenize(name: &str, input: ParamType) -> (bool, String) { - let mut needs_mut = false; - let code = match input { - ParamType::Address => format!("Token::Address({}.0)", name), - ParamType::Bytes => format!("Token::Bytes({})", name), - ParamType::FixedBytes(len) if len <= 32 => - format!("Token::FixedBytes({}.0.to_vec())", name), - ParamType::FixedBytes(len) => { - needs_mut = true; - format!("{}.resize({}, 0); Token::FixedBytes({})", name, len, name) - } - ParamType::Int(width) => match width { - 8 => format!("let mut r = [0xff; 32]; r[31] = {}; Token::Int(r)", name), - 16 | 32 | 64 => - format!("let mut r = [0xff; 32]; BigEndian::write_i{}(&mut r[{}..], {}); Token::Int(r))", - width, 32 - (width / 8), name), - _ => panic!("Signed int with more than 64 bits not supported."), - }, - ParamType::Uint(width) => format!( - "let mut r = [0; 32]; {}.to_big_endian(&mut r); Token::Uint(r)", - if width <= 64 { format!("ethereum_types::U256::from({} as u64)", name) } - else { format!("ethereum_types::U256::from({})", name) } - ), - ParamType::Bool => format!("Token::Bool({})", name), - ParamType::String => format!("Token::String({})", name), - ParamType::Array(kind) => { - let (needs_mut, code) = tokenize("i", *kind); - format!("Token::Array({}.into_iter().map(|{}i| {{ {} }}).collect())", - name, if needs_mut { "mut " } else { "" }, code) - } - ParamType::FixedArray(_, _) => panic!("Fixed-length arrays not supported."), - }; - - (needs_mut, code) -} - -// create code for detokenizing this parameter. -// takes an output type and the identifier of a token. -// expands to code that evaluates to a Option -// panics on unsupported types. -fn detokenize(name: &str, output_type: ParamType) -> String { - match output_type { - ParamType::Address => format!("{}.to_address().map(ethereum_types::H160)", name), - ParamType::Bytes => format!("{}.to_bytes()", name), - ParamType::FixedBytes(len) if len <= 32 => { - // ensure no panic on slice too small. - let read_hash = format!("b.resize({}, 0); ethereum_types::H{}::from_slice(&b[..{}])", - len, len * 8, len); - - format!("{}.to_fixed_bytes().map(|mut b| {{ {} }})", - name, read_hash) - } - ParamType::FixedBytes(_) => format!("{}.to_fixed_bytes()", name), - ParamType::Int(width) => { - let read_int = match width { - 8 => "i[31] as i8".into(), - 16 | 32 | 64 => format!("BigEndian::read_i{}(&i[{}..])", width, 32 - (width / 8)), - _ => panic!("Signed integers over 64 bytes not allowed."), - }; - format!("{}.to_int().map(|i| {})", name, read_int) - } - ParamType::Uint(width) => { - let read_uint = match width { - 8 => "u[31] as u8".into(), - 16 | 32 | 64 => format!("BigEndian::read_u{}(&u[{}..])", width, 32 - (width / 8)), - _ => format!("ethereum_types::U{}::from(&u[..])", width), - }; - - format!("{}.to_uint().map(|u| {})", name, read_uint) - } - ParamType::Bool => format!("{}.to_bool()", name), - ParamType::String => format!("{}.to_string()", name), - ParamType::Array(kind) => { - let read_array = format!("x.into_iter().map(|a| {{ {} }}).collect::>>()", - detokenize("a", *kind)); - - format!("{}.to_array().and_then(|x| {{ {} }})", - name, read_array) - } - ParamType::FixedArray(_, _) => panic!("Fixed-length arrays not supported.") - } -} - -#[cfg(test)] -mod tests { - use ethabi::ParamType; - - #[test] - fn input_types() { - assert_eq!(::input_params_codegen(&[]).unwrap().0, ""); - assert_eq!(::input_params_codegen(&[ParamType::Address]).unwrap().0, "param_0: ethereum_types::H160, "); - assert_eq!(::input_params_codegen(&[ParamType::Address, ParamType::Bytes]).unwrap().0, - "param_0: ethereum_types::H160, param_1: Vec, "); - } - - #[test] - fn output_types() { - assert_eq!(::output_params_codegen(&[]).unwrap().0, "()"); - assert_eq!(::output_params_codegen(&[ParamType::Address]).unwrap().0, "(ethereum_types::H160)"); - assert_eq!(::output_params_codegen(&[ParamType::Address, ParamType::Array(Box::new(ParamType::Bytes))]).unwrap().0, - "(ethereum_types::H160, Vec>)"); - } - - #[test] - fn rust_type() { - assert_eq!(::rust_type(ParamType::FixedBytes(32)).unwrap(), "ethereum_types::H256"); - assert_eq!(::rust_type(ParamType::Array(Box::new(ParamType::FixedBytes(32)))).unwrap(), - "Vec"); - - assert_eq!(::rust_type(ParamType::Uint(64)).unwrap(), "u64"); - assert!(::rust_type(ParamType::Uint(63)).is_err()); - - assert_eq!(::rust_type(ParamType::Int(32)).unwrap(), "i32"); - assert_eq!(::rust_type(ParamType::Uint(256)).unwrap(), "ethereum_types::U256"); - } - - // codegen tests will need bootstrapping of some kind. -} diff --git a/ethcore/native_contracts/res/tx_acl.json b/ethcore/native_contracts/res/tx_acl.json deleted file mode 100644 index cff9956de..000000000 --- a/ethcore/native_contracts/res/tx_acl.json +++ /dev/null @@ -1 +0,0 @@ -[{"constant":false,"inputs":[{"name":"sender","type":"address"}],"name":"allowedTxTypes","outputs":[{"name":"","type":"uint32"}],"payable":false,"stateMutability":"nonpayable","type":"function"}] diff --git a/ethcore/native_contracts/res/urlhint.json b/ethcore/native_contracts/res/urlhint.json deleted file mode 100644 index 629f166bb..000000000 --- a/ethcore/native_contracts/res/urlhint.json +++ /dev/null @@ -1,6 +0,0 @@ -[ - {"constant":false,"inputs":[{"name":"_content","type":"bytes32"},{"name":"_url","type":"string"}],"name":"hintURL","outputs":[],"type":"function"}, - {"constant":false,"inputs":[{"name":"_content","type":"bytes32"},{"name":"_accountSlashRepo","type":"string"},{"name":"_commit","type":"bytes20"}],"name":"hint","outputs":[],"type":"function"}, - {"constant":true,"inputs":[{"name":"","type":"bytes32"}],"name":"entries","outputs":[{"name":"accountSlashRepo","type":"string"},{"name":"commit","type":"bytes20"},{"name":"owner","type":"address"}],"type":"function"}, - {"constant":false,"inputs":[{"name":"_content","type":"bytes32"}],"name":"unhint","outputs":[],"type":"function"} -] diff --git a/ethcore/native_contracts/src/key_server_set.rs b/ethcore/native_contracts/src/key_server_set.rs deleted file mode 100644 index add34b443..000000000 --- a/ethcore/native_contracts/src/key_server_set.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2015-2017 Parity Technologies (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 . - -#![allow(unused_mut, unused_variables, unused_imports, unused_parens)] - -//! Secret store Key Server set contract. - -include!(concat!(env!("OUT_DIR"), "/key_server_set.rs")); diff --git a/ethcore/native_contracts/src/lib.rs b/ethcore/native_contracts/src/lib.rs deleted file mode 100644 index be8b84085..000000000 --- a/ethcore/native_contracts/src/lib.rs +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright 2015-2017 Parity Technologies (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 . - -//! Native contracts useful for Parity. These are type-safe wrappers -//! autogenerated at compile-time from Ethereum ABIs, and can be instantiated -//! given any closure which can dispatch calls to them asynchronously. - -extern crate futures; -extern crate byteorder; -extern crate ethabi; -extern crate ethereum_types; - -mod key_server_set; -mod registry; -mod urlhint; -mod service_transaction; -mod secretstore_acl_storage; -mod secretstore_service; -mod validator_set; -mod validator_report; -mod peer_set; -mod tx_acl; - -pub mod test_contracts; - -pub use self::key_server_set::KeyServerSet; -pub use self::registry::Registry; -pub use self::urlhint::Urlhint; -pub use self::service_transaction::ServiceTransactionChecker; -pub use self::secretstore_acl_storage::SecretStoreAclStorage; -pub use self::secretstore_service::SecretStoreService; -pub use self::validator_set::ValidatorSet; -pub use self::validator_report::ValidatorReport; -pub use self::peer_set::PeerSet; -pub use self::tx_acl::TransactAcl; diff --git a/ethcore/native_contracts/src/peer_set.rs b/ethcore/native_contracts/src/peer_set.rs deleted file mode 100644 index 1beec5ec4..000000000 --- a/ethcore/native_contracts/src/peer_set.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2015-2017 Parity Technologies (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 . - -#![allow(unused_mut, unused_variables, unused_imports, unused_parens)] - -//! Peer set contract. - -include!(concat!(env!("OUT_DIR"), "/peer_set.rs")); diff --git a/ethcore/native_contracts/src/registry.rs b/ethcore/native_contracts/src/registry.rs deleted file mode 100644 index 5856357d9..000000000 --- a/ethcore/native_contracts/src/registry.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2015-2017 Parity Technologies (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 . - -#![allow(unused_mut, unused_variables, unused_imports, unused_parens)] - -//! Registrar contract: maps names to addresses and data. -// TODO: testing. - -include!(concat!(env!("OUT_DIR"), "/registry.rs")); diff --git a/ethcore/native_contracts/src/secretstore_acl_storage.rs b/ethcore/native_contracts/src/secretstore_acl_storage.rs deleted file mode 100644 index 98200671e..000000000 --- a/ethcore/native_contracts/src/secretstore_acl_storage.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2015-2017 Parity Technologies (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 . - -#![allow(unused_mut, unused_variables, unused_imports, unused_parens)] - -//! Secret store ACL storage contract. -// TODO: testing. - -include!(concat!(env!("OUT_DIR"), "/secretstore_acl_storage.rs")); diff --git a/ethcore/native_contracts/src/secretstore_service.rs b/ethcore/native_contracts/src/secretstore_service.rs deleted file mode 100644 index 1161fc731..000000000 --- a/ethcore/native_contracts/src/secretstore_service.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2015-2017 Parity Technologies (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 . - -#![allow(unused_mut, unused_variables, unused_imports, unused_parens)] - -//! Secret store service contract. - -include!(concat!(env!("OUT_DIR"), "/secretstore_service.rs")); diff --git a/ethcore/native_contracts/src/service_transaction.rs b/ethcore/native_contracts/src/service_transaction.rs deleted file mode 100644 index ccf5c87f5..000000000 --- a/ethcore/native_contracts/src/service_transaction.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2015-2017 Parity Technologies (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 . - -#![allow(unused_mut, unused_variables, unused_imports, unused_parens)] - -//! Service transaction contract. -// TODO: testing. - -include!(concat!(env!("OUT_DIR"), "/service_transaction.rs")); diff --git a/ethcore/native_contracts/src/test_contracts/mod.rs b/ethcore/native_contracts/src/test_contracts/mod.rs deleted file mode 100644 index 44810b3b7..000000000 --- a/ethcore/native_contracts/src/test_contracts/mod.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2015-2017 Parity Technologies (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 . - -//! Contracts used for testing. - -pub mod validator_set; - -pub use self::validator_set::ValidatorSet; diff --git a/ethcore/native_contracts/src/test_contracts/validator_set.rs b/ethcore/native_contracts/src/test_contracts/validator_set.rs deleted file mode 100644 index 5f5379d92..000000000 --- a/ethcore/native_contracts/src/test_contracts/validator_set.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2015-2017 Parity Technologies (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 . - -#![allow(unused_mut, unused_variables, unused_imports, unused_parens)] - -//! Test validator set contract. - -include!(concat!(env!("OUT_DIR"), "/test_validator_set.rs")); diff --git a/ethcore/native_contracts/src/tx_acl.rs b/ethcore/native_contracts/src/tx_acl.rs deleted file mode 100644 index 469fe174a..000000000 --- a/ethcore/native_contracts/src/tx_acl.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2015-2017 Parity Technologies (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 . - -#![allow(unused_mut, unused_variables, unused_imports, unused_parens)] - -//! Transact permissions contract. - -include!(concat!(env!("OUT_DIR"), "/tx_acl.rs")); diff --git a/ethcore/native_contracts/src/urlhint.rs b/ethcore/native_contracts/src/urlhint.rs deleted file mode 100644 index d2085e593..000000000 --- a/ethcore/native_contracts/src/urlhint.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2015-2017 Parity Technologies (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 . - -#![allow(unused_mut, unused_variables, unused_imports)] - -//! Registrar contract: maps names to arbitrary URL. -// TODO: testing. - -include!(concat!(env!("OUT_DIR"), "/urlhint.rs")); diff --git a/ethcore/native_contracts/src/validator_report.rs b/ethcore/native_contracts/src/validator_report.rs deleted file mode 100644 index d77b07c71..000000000 --- a/ethcore/native_contracts/src/validator_report.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2015-2017 Parity Technologies (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 . - -#![allow(unused_mut, unused_variables, unused_imports)] - -//! Validator reporting. -// TODO: testing. - -include!(concat!(env!("OUT_DIR"), "/validator_report.rs")); diff --git a/ethcore/native_contracts/src/validator_set.rs b/ethcore/native_contracts/src/validator_set.rs deleted file mode 100644 index 1597a7bf2..000000000 --- a/ethcore/native_contracts/src/validator_set.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2015-2017 Parity Technologies (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 . - -#![allow(unused_mut, unused_variables, unused_imports, unused_parens)] - -//! Validator set contract. -// TODO: testing. - -include!(concat!(env!("OUT_DIR"), "/validator_set.rs")); diff --git a/ethcore/node_filter/Cargo.toml b/ethcore/node_filter/Cargo.toml index 35cf1eff5..baad75760 100644 --- a/ethcore/node_filter/Cargo.toml +++ b/ethcore/node_filter/Cargo.toml @@ -10,11 +10,13 @@ authors = ["Parity Technologies "] ethcore = { path = ".."} ethcore-bytes = { path = "../../util/bytes" } ethcore-network = { path = "../../util/network" } -ethereum-types = "0.1" -native-contracts = { path = "../native_contracts" } -futures = "0.1" +ethereum-types = "0.2" log = "0.3" parking_lot = "0.5" +ethabi = "5.1" +ethabi-derive = "5.0" +ethabi-contract = "5.0" +lru-cache = "0.1" [dev-dependencies] kvdb-memorydb = { path = "../../util/kvdb-memorydb" } diff --git a/ethcore/native_contracts/res/peer_set.json b/ethcore/node_filter/res/peer_set.json similarity index 100% rename from ethcore/native_contracts/res/peer_set.json rename to ethcore/node_filter/res/peer_set.json diff --git a/ethcore/node_filter/src/lib.rs b/ethcore/node_filter/src/lib.rs index 1cc83c6ca..a145b4e87 100644 --- a/ethcore/node_filter/src/lib.rs +++ b/ethcore/node_filter/src/lib.rs @@ -16,50 +16,55 @@ //! Smart contract based node filter. +extern crate ethabi; extern crate ethcore; extern crate ethcore_bytes as bytes; extern crate ethcore_network as network; extern crate ethereum_types; -extern crate native_contracts; -extern crate futures; +extern crate lru_cache; extern crate parking_lot; #[macro_use] -extern crate log; - -#[cfg(test)] -extern crate kvdb_memorydb; +extern crate ethabi_derive; +#[macro_use] +extern crate ethabi_contract; #[cfg(test)] extern crate ethcore_io as io; +#[cfg(test)] +extern crate kvdb_memorydb; +#[macro_use] +extern crate log; use std::sync::Weak; -use std::collections::HashMap; -use native_contracts::PeerSet as Contract; -use network::{NodeId, ConnectionFilter, ConnectionDirection}; + +use lru_cache::LruCache; +use parking_lot::Mutex; + +use bytes::Bytes; use ethcore::client::{BlockChainClient, BlockId, ChainNotify}; use ethereum_types::{H256, Address}; -use bytes::Bytes; -use parking_lot::Mutex; -use futures::Future; +use network::{NodeId, ConnectionFilter, ConnectionDirection}; + +use_contract!(peer_set, "PeerSet", "res/peer_set.json"); const MAX_CACHE_SIZE: usize = 4096; /// Connection filter that uses a contract to manage permissions. pub struct NodeFilter { - contract: Mutex>, + contract: peer_set::PeerSet, client: Weak, contract_address: Address, - permission_cache: Mutex>, + permission_cache: Mutex>, } impl NodeFilter { /// Create a new instance. Accepts a contract address. pub fn new(client: Weak, contract_address: Address) -> NodeFilter { NodeFilter { - contract: Mutex::new(None), + contract: peer_set::PeerSet::default(), client: client, contract_address: contract_address, - permission_cache: Mutex::new(HashMap::new()), + permission_cache: Mutex::new(LruCache::new(MAX_CACHE_SIZE)), } } @@ -73,40 +78,30 @@ impl ConnectionFilter for NodeFilter { fn connection_allowed(&self, own_id: &NodeId, connecting_id: &NodeId, _direction: ConnectionDirection) -> bool { let mut cache = self.permission_cache.lock(); - if let Some(res) = cache.get(connecting_id) { + if let Some(res) = cache.get_mut(connecting_id) { return *res; } - let mut contract = self.contract.lock(); - if contract.is_none() { - *contract = Some(Contract::new(self.contract_address)); - } - - let allowed = match (self.client.upgrade(), &*contract) { - (Some(ref client), &Some(ref contract)) => { - let own_low = H256::from_slice(&own_id[0..32]); - let own_high = H256::from_slice(&own_id[32..64]); - let id_low = H256::from_slice(&connecting_id[0..32]); - let id_high = H256::from_slice(&connecting_id[32..64]); - let allowed = contract.connection_allowed( - |addr, data| futures::done(client.call_contract(BlockId::Latest, addr, data)), - own_low, - own_high, - id_low, - id_high, - ).wait().unwrap_or_else(|e| { - debug!("Error callling peer set contract: {:?}", e); - false - }); - - allowed - } - _ => false, + let client = match self.client.upgrade() { + Some(client) => client, + None => return false, }; - if cache.len() < MAX_CACHE_SIZE { - cache.insert(*connecting_id, allowed); - } + let address = self.contract_address; + let own_low = H256::from_slice(&own_id[0..32]); + let own_high = H256::from_slice(&own_id[32..64]); + let id_low = H256::from_slice(&connecting_id[0..32]); + let id_high = H256::from_slice(&connecting_id[32..64]); + + let allowed = self.contract.functions() + .connection_allowed() + .call(own_low, own_high, id_low, id_high, &|data| client.call_contract(BlockId::Latest, address, data)) + .unwrap_or_else(|e| { + debug!("Error callling peer set contract: {:?}", e); + false + }); + + cache.insert(*connecting_id, allowed); allowed } } diff --git a/ethcore/native_contracts/res/registrar.json b/ethcore/res/contracts/registrar.json similarity index 100% rename from ethcore/native_contracts/res/registrar.json rename to ethcore/res/contracts/registrar.json diff --git a/ethcore/native_contracts/res/test_validator_set.json b/ethcore/res/contracts/test_validator_set.json similarity index 100% rename from ethcore/native_contracts/res/test_validator_set.json rename to ethcore/res/contracts/test_validator_set.json diff --git a/ethcore/res/contracts/tx_acl.json b/ethcore/res/contracts/tx_acl.json new file mode 100644 index 000000000..cc924cafb --- /dev/null +++ b/ethcore/res/contracts/tx_acl.json @@ -0,0 +1 @@ +[{"constant":true,"inputs":[{"name":"sender","type":"address"}],"name":"allowedTxTypes","outputs":[{"name":"","type":"uint32"}],"payable":false,"stateMutability":"nonpayable","type":"function"}] diff --git a/ethcore/native_contracts/res/validator_report.json b/ethcore/res/contracts/validator_report.json similarity index 100% rename from ethcore/native_contracts/res/validator_report.json rename to ethcore/res/contracts/validator_report.json diff --git a/ethcore/native_contracts/res/validator_set.json b/ethcore/res/contracts/validator_set.json similarity index 100% rename from ethcore/native_contracts/res/validator_set.json rename to ethcore/res/contracts/validator_set.json diff --git a/ethcore/src/client/client.rs b/ethcore/src/client/client.rs index f828b1b84..6e7e800be 100644 --- a/ethcore/src/client/client.rs +++ b/ethcore/src/client/client.rs @@ -50,13 +50,11 @@ use vm::{EnvInfo, LastHashes}; use evm::{Factory as EvmFactory, Schedule}; use executive::{Executive, Executed, TransactOptions, contract_address}; use factory::Factories; -use futures::{future, Future}; use header::{BlockNumber, Header, Seal}; use io::*; use log_entry::LocalizedLogEntry; use miner::{Miner, MinerService}; -use native_contracts::Registry; -use parking_lot::{Mutex, RwLock, MutexGuard}; +use parking_lot::{Mutex, RwLock}; use rand::OsRng; use receipt::{Receipt, LocalizedReceipt}; use rlp::UntrustedRlp; @@ -82,6 +80,8 @@ pub use types::block_status::BlockStatus; pub use blockchain::CacheSize as BlockChainCacheSize; pub use verification::queue::QueueInfo as BlockQueueInfo; +use_contract!(registry, "Registry", "res/contracts/registrar.json"); + const MAX_TX_QUEUE_SIZE: usize = 4096; const MAX_QUEUE_SIZE_TO_SLEEP_ON: usize = 2; const MIN_HISTORY_SIZE: u64 = 8; @@ -165,7 +165,8 @@ pub struct Client { history: u64, ancient_verifier: Mutex>, on_user_defaults_change: Mutex) + 'static + Send>>>, - registrar: Mutex>, + registrar: registry::Registry, + registrar_address: Option
, exit_handler: Mutex) + 'static + Send>>>, } @@ -217,7 +218,7 @@ impl Client { }; if !chain.block_header(&chain.best_block_hash()).map_or(true, |h| state_db.journal_db().contains(h.state_root())) { - warn!("State root not found for block #{} ({})", chain.best_block_number(), chain.best_block_hash().hex()); + warn!("State root not found for block #{} ({:x})", chain.best_block_number(), chain.best_block_hash()); } let engine = spec.engine.clone(); @@ -226,6 +227,11 @@ impl Client { let awake = match config.mode { Mode::Dark(..) | Mode::Off => false, _ => true }; + let registrar_address = engine.additional_params().get("registrar").and_then(|s| Address::from_str(s).ok()); + if let Some(ref addr) = registrar_address { + trace!(target: "client", "Found registrar at {}", addr); + } + let client = Arc::new(Client { enabled: AtomicBool::new(true), sleep_state: Mutex::new(SleepState::new(awake)), @@ -251,7 +257,8 @@ impl Client { history: history, ancient_verifier: Mutex::new(None), on_user_defaults_change: Mutex::new(None), - registrar: Mutex::new(None), + registrar: registry::Registry::default(), + registrar_address, exit_handler: Mutex::new(None), }); @@ -294,12 +301,6 @@ impl Client { } } - if let Some(reg_addr) = client.additional_params().get("registrar").and_then(|s| Address::from_str(s).ok()) { - trace!(target: "client", "Found registrar at {}", reg_addr); - let registrar = Registry::new(reg_addr); - *client.registrar.lock() = Some(registrar); - } - // ensure buffered changes are flushed. client.db.read().flush().map_err(ClientError::Database)?; Ok(client) @@ -340,11 +341,6 @@ impl Client { } } - /// Get the Registry object - useful for looking up names. - pub fn registrar(&self) -> MutexGuard> { - self.registrar.lock() - } - /// Register an action to be done if a mode/spec_name change happens. pub fn on_user_defaults_change(&self, f: F) where F: 'static + FnMut(Option) + Send { *self.on_user_defaults_change.lock() = Some(Box::new(f)); @@ -1828,18 +1824,24 @@ impl BlockChainClient for Client { } fn registrar_address(&self) -> Option
{ - self.registrar.lock().as_ref().map(|r| r.address) + self.registrar_address.clone() } fn registry_address(&self, name: String) -> Option
{ - self.registrar.lock().as_ref() - .and_then(|r| { - let dispatch = move |reg_addr, data| { - future::done(self.call_contract(BlockId::Latest, reg_addr, data)) - }; - r.get_address(dispatch, keccak(name.as_bytes()), "A".to_string()).wait().ok() + let address = match self.registrar_address { + Some(address) => address, + None => return None, + }; + + self.registrar.functions() + .get_address() + .call(keccak(name.as_bytes()), "A", &|data| self.call_contract(BlockId::Latest, address, data)) + .ok() + .and_then(|a| if a.is_zero() { + None + } else { + Some(a) }) - .and_then(|a| if a.is_zero() { None } else { Some(a) }) } fn eip86_transition(&self) -> u64 { diff --git a/ethcore/src/engines/validator_set/contract.rs b/ethcore/src/engines/validator_set/contract.rs index 90cc93436..545b2eaae 100644 --- a/ethcore/src/engines/validator_set/contract.rs +++ b/ethcore/src/engines/validator_set/contract.rs @@ -18,12 +18,10 @@ /// It can also report validators for misbehaviour with two levels: `reportMalicious` and `reportBenign`. use std::sync::Weak; + +use bytes::Bytes; use ethereum_types::{H256, Address}; use parking_lot::RwLock; -use bytes::Bytes; - -use futures::Future; -use native_contracts::ValidatorReport as Provider; use client::EngineClient; use header::{Header, BlockNumber}; @@ -32,40 +30,41 @@ use machine::{AuxiliaryData, Call, EthereumMachine}; use super::{ValidatorSet, SimpleList, SystemCall}; use super::safe_contract::ValidatorSafeContract; +use_contract!(validator_report, "ValidatorReport", "res/contracts/validator_report.json"); + /// A validator contract with reporting. pub struct ValidatorContract { + contract_address: Address, validators: ValidatorSafeContract, - provider: Provider, + provider: validator_report::ValidatorReport, client: RwLock>>, // TODO [keorn]: remove } impl ValidatorContract { pub fn new(contract_address: Address) -> Self { ValidatorContract { + contract_address, validators: ValidatorSafeContract::new(contract_address), - provider: Provider::new(contract_address), + provider: validator_report::ValidatorReport::default(), client: RwLock::new(None), } } } impl ValidatorContract { - // could be `impl Trait`. - // note: dispatches transactions to network as well as execute. - // TODO [keorn]: Make more general. - fn transact(&self) -> Box Result> { - let client = self.client.read().clone(); - Box::new(move |a, d| client.as_ref() + fn transact(&self, data: Bytes) -> Result<(), String> { + let client = self.client.read().as_ref() .and_then(Weak::upgrade) - .ok_or_else(|| "No client!".into()) - .and_then(|c| { - match c.as_full_client() { - Some(c) => c.transact_contract(a, d) - .map_err(|e| format!("Transaction import error: {}", e)), - None => Err("No full client!".into()), - } - }) - .map(|_| Default::default())) + .ok_or_else(|| "No client!")?; + + match client.as_full_client() { + Some(c) => { + c.transact_contract(self.contract_address, data) + .map_err(|e| format!("Transaction import error: {}", e))?; + Ok(()) + }, + None => Err("No full client!".into()), + } } } @@ -112,14 +111,16 @@ impl ValidatorSet for ValidatorContract { } fn report_malicious(&self, address: &Address, _set_block: BlockNumber, block: BlockNumber, proof: Bytes) { - match self.provider.report_malicious(&*self.transact(), *address, block.into(), proof).wait() { + let data = self.provider.functions().report_malicious().input(*address, block, proof); + match self.transact(data) { Ok(_) => warn!(target: "engine", "Reported malicious validator {}", address), Err(s) => warn!(target: "engine", "Validator {} could not be reported {}", address, s), } } fn report_benign(&self, address: &Address, _set_block: BlockNumber, block: BlockNumber) { - match self.provider.report_benign(&*self.transact(), *address, block.into()).wait() { + let data = self.provider.functions().report_benign().input(*address, block); + match self.transact(data) { Ok(_) => warn!(target: "engine", "Reported benign validator misbehaviour {}", address), Err(s) => warn!(target: "engine", "Validator {} could not be reported {}", address, s), } diff --git a/ethcore/src/engines/validator_set/safe_contract.rs b/ethcore/src/engines/validator_set/safe_contract.rs index 93d3de01b..07edf5f88 100644 --- a/ethcore/src/engines/validator_set/safe_contract.rs +++ b/ethcore/src/engines/validator_set/safe_contract.rs @@ -17,11 +17,9 @@ /// Validator set maintained in a contract, updated using `getValidators` method. use std::sync::{Weak, Arc}; -use futures::Future; -use native_contracts::ValidatorSet as Provider; use hash::keccak; -use ethereum_types::{H160, H256, U256, Address, Bloom}; +use ethereum_types::{H256, U256, Address, Bloom}; use parking_lot::{Mutex, RwLock}; use bytes::Bytes; @@ -40,6 +38,8 @@ use receipt::Receipt; use super::{SystemCall, ValidatorSet}; use super::simple_list::SimpleList; +use_contract!(validator_set, "ValidatorSet", "res/contracts/validator_set.json"); + const MEMOIZE_CAPACITY: usize = 500; // TODO: ethabi should be able to generate this. @@ -52,13 +52,14 @@ lazy_static! { // state-dependent proofs for the safe contract: // only "first" proofs are such. struct StateProof { + contract_address: Address, header: Mutex
, - provider: Provider, + provider: validator_set::ValidatorSet, } impl ::engines::StateDependentProof for StateProof { fn generate_proof(&self, caller: &Call) -> Result, String> { - prove_initial(&self.provider, &*self.header.lock(), caller) + prove_initial(&self.provider, self.contract_address, &*self.header.lock(), caller) } fn check_proof(&self, machine: &EthereumMachine, proof: &[u8]) -> Result<(), String> { @@ -68,15 +69,15 @@ impl ::engines::StateDependentProof for StateProof { return Err("wrong header in proof".into()); } - check_first_proof(machine, &self.provider, header, &state_items).map(|_| ()) + check_first_proof(machine, &self.provider, self.contract_address, header, &state_items).map(|_| ()) } } /// The validator contract should have the following interface: pub struct ValidatorSafeContract { - pub address: Address, + contract_address: Address, validators: RwLock>, - provider: Provider, + provider: validator_set::ValidatorSet, client: RwLock>>, // TODO [keorn]: remove } @@ -92,7 +93,7 @@ fn encode_first_proof(header: &Header, state_items: &[Vec]) -> Bytes { } // check a first proof: fetch the validator set at the given block. -fn check_first_proof(machine: &EthereumMachine, provider: &Provider, old_header: Header, state_items: &[DBValue]) +fn check_first_proof(machine: &EthereumMachine, provider: &validator_set::ValidatorSet, contract_address: Address, old_header: Header, state_items: &[DBValue]) -> Result, String> { use transaction::{Action, Transaction}; @@ -117,15 +118,15 @@ fn check_first_proof(machine: &EthereumMachine, provider: &Provider, old_header: // check state proof using given machine. let number = old_header.number(); - provider.get_validators(move |a, d| { + provider.functions().get_validators().call(&|data| { let from = Address::default(); let tx = Transaction { nonce: machine.account_start_nonce(number), - action: Action::Call(a), + action: Action::Call(contract_address), gas: PROVIDED_GAS.into(), gas_price: U256::default(), value: U256::default(), - data: d, + data, }.fake_sign(from); let res = ::state::check_proof( @@ -141,7 +142,7 @@ fn check_first_proof(machine: &EthereumMachine, provider: &Provider, old_header: ::state::ProvedExecution::Failed(e) => Err(format!("Failed call: {}", e)), ::state::ProvedExecution::Complete(e) => Ok(e.output), } - }).wait() + }).map_err(|err| err.to_string()) } fn decode_first_proof(rlp: &UntrustedRlp) -> Result<(Header, Vec), ::error::Error> { @@ -170,18 +171,19 @@ fn decode_proof(rlp: &UntrustedRlp) -> Result<(Header, Vec), ::error::E // given a provider and caller, generate proof. this will just be a state proof // of `getValidators`. -fn prove_initial(provider: &Provider, header: &Header, caller: &Call) -> Result, String> { +fn prove_initial(provider: &validator_set::ValidatorSet, contract_address: Address, header: &Header, caller: &Call) -> Result, String> { use std::cell::RefCell; let epoch_proof = RefCell::new(None); let res = { - let caller = |a, d| { - let (result, proof) = caller(a, d)?; + let caller = |data| { + let (result, proof) = caller(contract_address, data)?; *epoch_proof.borrow_mut() = Some(encode_first_proof(header, &proof)); Ok(result) }; - provider.get_validators(caller).wait() + provider.functions().get_validators().call(&caller) + .map_err(|err| err.to_string()) }; res.map(|validators| { @@ -200,17 +202,18 @@ fn prove_initial(provider: &Provider, header: &Header, caller: &Call) -> Result< impl ValidatorSafeContract { pub fn new(contract_address: Address) -> Self { ValidatorSafeContract { - address: contract_address, + contract_address, validators: RwLock::new(MemoryLruCache::new(MEMOIZE_CAPACITY)), - provider: Provider::new(contract_address), + provider: validator_set::ValidatorSet::default(), client: RwLock::new(None), } } /// Queries the state and gets the set of validators. fn get_list(&self, caller: &Call) -> Option { - let caller = move |a, d| caller(a, d).map(|x| x.0); - match self.provider.get_validators(caller).wait() { + let contract_address = self.contract_address; + let caller = move |data| caller(contract_address, data).map(|x| x.0); + match self.provider.functions().get_validators().call(&caller) { Ok(new) => { debug!(target: "engine", "Set of validators obtained: {:?}", new); Some(SimpleList::new(new)) @@ -244,7 +247,7 @@ impl ValidatorSafeContract { header.hash(), topics); LogEntry { - address: self.address, + address: self.contract_address, topics: topics, data: Vec::new(), // irrelevant for bloom. }.bloom() @@ -254,52 +257,29 @@ impl ValidatorSafeContract { // header the receipts correspond to. fn extract_from_event(&self, bloom: Bloom, header: &Header, receipts: &[Receipt]) -> Option { let check_log = |log: &LogEntry| { - log.address == self.address && + log.address == self.contract_address && log.topics.len() == 2 && log.topics[0] == *EVENT_NAME_HASH && log.topics[1] == *header.parent_hash() }; - let event = Provider::contract(&self.provider) - .event("InitiateChange".into()) - .expect("Contract known ahead of time to have `InitiateChange` event; qed"); - - // iterate in reverse because only the _last_ change in a given - // block actually has any effect. - // the contract should only increment the nonce once. + let event = self.provider.events().initiate_change(); + //// iterate in reverse because only the _last_ change in a given + //// block actually has any effect. + //// the contract should only increment the nonce once. let mut decoded_events = receipts.iter() .rev() - .filter(|r| &bloom & &r.log_bloom == bloom) + .filter(|r| r.log_bloom.contains_bloom(&bloom)) .flat_map(|r| r.logs.iter()) .filter(move |l| check_log(l)) .filter_map(|log| { - let topics = log.topics.iter().map(|x| x.0.clone()).collect(); - event.parse_log((topics, log.data.clone()).into()).ok() + event.parse_log((log.topics.clone(), log.data.clone()).into()).ok() }); + // only last log is taken into account match decoded_events.next() { None => None, - Some(matched_event) => { - - // decode log manually until the native contract generator is - // good enough to do it for us. - let validators_token = &matched_event.params[1].value; - - let validators = validators_token.clone().to_array() - .and_then(|a| a.into_iter() - .map(|x| x.to_address().map(H160)) - .collect::>>() - ) - .map(SimpleList::new); - - if validators.is_none() { - debug!(target: "engine", "Successfully decoded log turned out to be bad."); - } - - trace!(target: "engine", "decoded log. validators: {:?}", validators); - - validators - } + Some(matched_event) => Some(SimpleList::new(matched_event.new_set)) } } } @@ -320,14 +300,15 @@ impl ValidatorSet for ValidatorSafeContract { } fn on_epoch_begin(&self, _first: bool, _header: &Header, caller: &mut SystemCall) -> Result<(), ::error::Error> { - self.provider.finalize_change(caller) - .wait() + let data = self.provider.functions().finalize_change().input(); + caller(self.contract_address, data) + .map(|_| ()) .map_err(::engines::EngineError::FailedSystemCall) .map_err(Into::into) } fn genesis_epoch_data(&self, header: &Header, call: &Call) -> Result, String> { - prove_initial(&self.provider, header, call) + prove_initial(&self.provider, self.contract_address, header, call) } fn is_epoch_end(&self, _first: bool, _chain_head: &Header) -> Option> { @@ -343,8 +324,9 @@ impl ValidatorSet for ValidatorSafeContract { if first { debug!(target: "engine", "signalling transition to fresh contract."); let state_proof = Arc::new(StateProof { + contract_address: self.contract_address, header: Mutex::new(header.clone()), - provider: self.provider.clone(), + provider: validator_set::ValidatorSet::default(), }); return ::engines::EpochChange::Yes(::engines::Proof::WithState(state_proof as Arc<_>)); } @@ -383,7 +365,7 @@ impl ValidatorSet for ValidatorSafeContract { let (old_header, state_items) = decode_first_proof(&rlp)?; let number = old_header.number(); let old_hash = old_header.hash(); - let addresses = check_first_proof(machine, &self.provider, old_header, &state_items) + let addresses = check_first_proof(machine, &self.provider, self.contract_address, old_header, &state_items) .map_err(::engines::EngineError::InsufficientProof)?; trace!(target: "engine", "extracted epoch set at #{}: {} addresses", diff --git a/ethcore/src/ethereum/ethash.rs b/ethcore/src/ethereum/ethash.rs index 824330d2a..4d3bc46f9 100644 --- a/ethcore/src/ethereum/ethash.rs +++ b/ethcore/src/ethereum/ethash.rs @@ -175,8 +175,8 @@ impl Engine for Arc { fn extra_info(&self, header: &Header) -> BTreeMap { if header.seal().len() == self.seal_fields() { map![ - "nonce".to_owned() => format!("0x{}", header.nonce().hex()), - "mixHash".to_owned() => format!("0x{}", header.mix_hash().hex()) + "nonce".to_owned() => format!("0x{:x}", header.nonce()), + "mixHash".to_owned() => format!("0x{:x}", header.mix_hash()) ] } else { BTreeMap::default() @@ -384,9 +384,9 @@ impl Ethash { let diff_inc = (header.timestamp() - parent.timestamp()) / increment_divisor; if diff_inc <= threshold { - *parent.difficulty() + *parent.difficulty() / difficulty_bound_divisor * (threshold - diff_inc).into() + *parent.difficulty() + *parent.difficulty() / difficulty_bound_divisor * U256::from(threshold - diff_inc) } else { - let multiplier = cmp::min(diff_inc - threshold, 99).into(); + let multiplier: U256 = cmp::min(diff_inc - threshold, 99).into(); parent.difficulty().saturating_sub( *parent.difficulty() / difficulty_bound_divisor * multiplier ) @@ -474,6 +474,7 @@ mod tests { use error::{BlockError, Error}; use header::Header; use spec::Spec; + use engines::Engine; use super::super::{new_morden, new_mcip3_test, new_homestead_test_machine}; use super::{Ethash, EthashParams, ecip1017_eras_block_reward}; use rlp; @@ -849,4 +850,16 @@ mod tests { let difficulty = ethash.calculate_difficulty(&header, &parent_header); assert_eq!(U256::from(12543204905719u64), difficulty); } + + #[test] + fn test_extra_info() { + let machine = new_homestead_test_machine(); + let ethparams = get_default_ethash_params(); + let ethash = Ethash::new(&::std::env::temp_dir(), ethparams, machine, None); + let mut header = Header::default(); + header.set_seal(vec![rlp::encode(&H256::from("b251bd2e0283d0658f2cadfdc8ca619b5de94eca5742725e2e757dd13ed7503d")).into_vec(), rlp::encode(&H64::zero()).into_vec()]); + let info = ethash.extra_info(&header); + assert_eq!(info["nonce"], "0x0000000000000000"); + assert_eq!(info["mixHash"], "0xb251bd2e0283d0658f2cadfdc8ca619b5de94eca5742725e2e757dd13ed7503d"); + } } diff --git a/ethcore/src/lib.rs b/ethcore/src/lib.rs index 565477eec..8d020d5df 100644 --- a/ethcore/src/lib.rs +++ b/ethcore/src/lib.rs @@ -71,12 +71,10 @@ extern crate ethcore_transaction as transaction; extern crate ethereum_types; extern crate ethjson; extern crate ethkey; -extern crate futures; extern crate hardware_wallet; extern crate hashdb; extern crate itertools; extern crate lru_cache; -extern crate native_contracts; extern crate num_cpus; extern crate num; extern crate parity_machine; @@ -99,6 +97,12 @@ extern crate util_error; extern crate snappy; extern crate migration; +extern crate ethabi; +#[macro_use] +extern crate ethabi_derive; +#[macro_use] +extern crate ethabi_contract; + #[macro_use] extern crate rlp_derive; extern crate rustc_hex; diff --git a/ethcore/src/machine.rs b/ethcore/src/machine.rs index 8bd8afac5..62b9a13b4 100644 --- a/ethcore/src/machine.rs +++ b/ethcore/src/machine.rs @@ -220,7 +220,7 @@ impl EthereumMachine { let total_lower_limit = cmp::max(lower_limit, gas_floor_target); let total_upper_limit = cmp::min(upper_limit, gas_ceil_target); let gas_limit = cmp::max(gas_floor_target, cmp::min(total_upper_limit, - lower_limit + (header.gas_used().clone() * 6.into() / 5.into()) / bound_divisor)); + lower_limit + (header.gas_used().clone() * 6u32 / 5.into()) / bound_divisor)); round_block_gas_limit(gas_limit, total_lower_limit, total_upper_limit) }; // ensure that we are not violating protocol limits @@ -384,7 +384,7 @@ impl EthereumMachine { /// Additional params. pub fn additional_params(&self) -> HashMap { hash_map![ - "registrar".to_owned() => self.params.registrar.hex() + "registrar".to_owned() => format!("{:x}", self.params.registrar) ] } } diff --git a/ethcore/src/miner/miner.rs b/ethcore/src/miner/miner.rs index 67567cc7d..c799459e7 100644 --- a/ethcore/src/miner/miner.rs +++ b/ethcore/src/miner/miner.rs @@ -647,7 +647,7 @@ impl Miner { queue.set_gas_limit(gas_limit); if let GasLimit::Auto = self.options.tx_queue_gas_limit { // Set total tx queue gas limit to be 20x the block gas limit. - queue.set_total_gas_limit(gas_limit * 20.into()); + queue.set_total_gas_limit(gas_limit * 20u32); } } @@ -720,9 +720,6 @@ impl Miner { } }).unwrap_or(default_origin); - // try to install service transaction checker before appending transactions - self.service_transaction_action.update_from_chain_client(client); - let details_provider = TransactionDetailsProvider::new(client, &self.service_transaction_action); match origin { TransactionOrigin::Local | TransactionOrigin::RetractedBlock => { @@ -838,7 +835,7 @@ impl MinerService for Miner { fn sensible_gas_price(&self) -> U256 { // 10% above our minimum. - *self.transaction_queue.read().minimal_gas_price() * 110.into() / 100.into() + *self.transaction_queue.read().minimal_gas_price() * 110u32 / 100.into() } fn sensible_gas_limit(&self) -> U256 { @@ -1169,7 +1166,7 @@ impl MinerService for Miner { let n = sealed.header().number(); let h = sealed.header().hash(); chain.import_sealed_block(sealed)?; - info!(target: "miner", "Submitted block imported OK. #{}: {}", Colour::White.bold().paint(format!("{}", n)), Colour::White.bold().paint(h.hex())); + info!(target: "miner", "Submitted block imported OK. #{}: {}", Colour::White.bold().paint(format!("{}", n)), Colour::White.bold().paint(format!("{:x}", h))); Ok(()) }) } @@ -1231,12 +1228,6 @@ enum ServiceTransactionAction { } impl ServiceTransactionAction { - pub fn update_from_chain_client(&self, client: &MiningBlockChainClient) { - if let ServiceTransactionAction::Check(ref checker) = *self { - checker.update_from_chain_client(&client); - } - } - pub fn check(&self, client: &MiningBlockChainClient, tx: &SignedTransaction) -> Result { match *self { ServiceTransactionAction::Refuse => Err("configured to refuse service transactions".to_owned()), diff --git a/ethcore/src/miner/stratum.rs b/ethcore/src/miner/stratum.rs index 80ec44ea4..c8c387e51 100644 --- a/ethcore/src/miner/stratum.rs +++ b/ethcore/src/miner/stratum.rs @@ -173,8 +173,8 @@ impl StratumJobDispatcher { let seed_hash = &self.seed_compute.lock().hash_block_number(number); let seed_hash = H256::from_slice(&seed_hash[..]); format!( - r#"["0x", "0x{}","0x{}","0x{}","0x{:x}"]"#, - pow_hash.hex(), seed_hash.hex(), target.hex(), number + r#"["0x", "0x{:x}","0x{:x}","0x{:x}","0x{:x}"]"#, + pow_hash, seed_hash, target, number ) } diff --git a/ethcore/src/snapshot/io.rs b/ethcore/src/snapshot/io.rs index 6243a0025..7e38177ea 100644 --- a/ethcore/src/snapshot/io.rs +++ b/ethcore/src/snapshot/io.rs @@ -156,12 +156,9 @@ impl LooseWriter { // writing logic is the same for both kinds of chunks. fn write_chunk(&mut self, hash: H256, chunk: &[u8]) -> io::Result<()> { - let mut file_path = self.dir.clone(); - file_path.push(hash.hex()); - + let file_path = self.dir.join(format!("{:x}", hash)); let mut file = File::create(file_path)?; file.write_all(chunk)?; - Ok(()) } } @@ -327,14 +324,10 @@ impl SnapshotReader for LooseReader { } fn chunk(&self, hash: H256) -> io::Result { - let mut path = self.dir.clone(); - path.push(hash.hex()); - + let path = self.dir.join(format!("{:x}", hash)); let mut buf = Vec::new(); let mut file = File::open(&path)?; - file.read_to_end(&mut buf)?; - Ok(buf) } } diff --git a/ethcore/src/snapshot/mod.rs b/ethcore/src/snapshot/mod.rs index d3675fe7a..94be8175a 100644 --- a/ethcore/src/snapshot/mod.rs +++ b/ethcore/src/snapshot/mod.rs @@ -181,8 +181,8 @@ pub fn chunk_secondary<'a>(mut chunker: Box, chain: &'a Bloc let size = compressed.len(); writer.lock().write_block_chunk(hash, compressed)?; - trace!(target: "snapshot", "wrote secondary chunk. hash: {}, size: {}, uncompressed size: {}", - hash.hex(), size, raw_data.len()); + trace!(target: "snapshot", "wrote secondary chunk. hash: {:x}, size: {}, uncompressed size: {}", + hash, size, raw_data.len()); progress.size.fetch_add(size, Ordering::SeqCst); chunk_hashes.push(hash); diff --git a/ethcore/src/snapshot/tests/proof_of_authority.rs b/ethcore/src/snapshot/tests/proof_of_authority.rs index 3f350e89e..c237acf78 100644 --- a/ethcore/src/snapshot/tests/proof_of_authority.rs +++ b/ethcore/src/snapshot/tests/proof_of_authority.rs @@ -23,8 +23,6 @@ use std::str::FromStr; use account_provider::AccountProvider; use client::{Client, BlockChainClient}; use ethkey::Secret; -use futures::Future; -use native_contracts::test_contracts::ValidatorSet; use snapshot::tests::helpers as snapshot_helpers; use spec::Spec; use tests::helpers; @@ -33,6 +31,8 @@ use transaction::{Transaction, Action, SignedTransaction}; use ethereum_types::Address; use kvdb_memorydb; +use_contract!(test_validator_set, "ValidatorSet", "res/contracts/test_validator_set.json"); + const PASS: &'static str = ""; const TRANSITION_BLOCK_1: usize = 2; // block at which the contract becomes activated. const TRANSITION_BLOCK_2: usize = 10; // block at which the second contract activates. @@ -56,7 +56,7 @@ lazy_static! { /// Account with secrets keccak("1") is initially the validator. /// Transitions to the contract at block 2, initially same validator set. /// Create a new Spec with AuthorityRound which uses a contract at address 5 to determine the current validators using `getValidators`. -/// `native_contracts::test_contracts::ValidatorSet` provides a native wrapper for the ABi. +/// `test_validator_set::ValidatorSet` provides a native wrapper for the ABi. fn spec_fixed_to_contract() -> Spec { let data = include_bytes!("test_validator_contract.json"); Spec::load(&::std::env::temp_dir(), &data[..]).unwrap() @@ -136,8 +136,7 @@ fn make_chain(accounts: Arc, blocks_beyond: usize, transitions: vec![transaction] }; - let contract_1 = ValidatorSet::new(*CONTRACT_ADDR_1); - let contract_2 = ValidatorSet::new(*CONTRACT_ADDR_2); + let contract = test_validator_set::ValidatorSet::default(); // apply all transitions. for transition in transitions { @@ -160,34 +159,24 @@ fn make_chain(accounts: Arc, blocks_beyond: usize, transitions: let pending = if manual { trace!(target: "snapshot", "applying set transition at block #{}", num); - let contract = match num >= TRANSITION_BLOCK_2 { - true => &contract_2, - false => &contract_1, + let address = match num >= TRANSITION_BLOCK_2 { + true => &CONTRACT_ADDR_2 as &Address, + false => &CONTRACT_ADDR_1 as &Address, }; - let mut pending = Vec::new(); - { - let mut exec = |addr, data| { - let mut nonce = nonce.borrow_mut(); - let transaction = Transaction { - nonce: *nonce, - gas_price: 0.into(), - gas: 1_000_000.into(), - action: Action::Call(addr), - value: 0.into(), - data: data, - }.sign(&*RICH_SECRET, client.signing_chain_id()); + let data = contract.functions().set_validators().input(new_set.clone()); + let mut nonce = nonce.borrow_mut(); + let transaction = Transaction { + nonce: *nonce, + gas_price: 0.into(), + gas: 1_000_000.into(), + action: Action::Call(*address), + value: 0.into(), + data, + }.sign(&*RICH_SECRET, client.signing_chain_id()); - pending.push(transaction); - - *nonce = *nonce + 1.into(); - Ok(Vec::new()) - }; - - contract.set_validators(&mut exec, new_set.clone()).wait().unwrap(); - } - - pending + *nonce = *nonce + 1.into(); + vec![transaction] } else { make_useless_transactions() }; diff --git a/ethcore/src/state/account.rs b/ethcore/src/state/account.rs index 63f14322d..9c5ec03d7 100644 --- a/ethcore/src/state/account.rs +++ b/ethcore/src/state/account.rs @@ -486,7 +486,7 @@ impl fmt::Debug for Account { #[cfg(test)] mod tests { use rlp::{UntrustedRlp, RlpType, Compressible}; - use ethereum_types::{H256, U256, Address}; + use ethereum_types::{H256, Address}; use memorydb::MemoryDB; use bytes::Bytes; use super::*; @@ -508,7 +508,7 @@ mod tests { let mut db = AccountDBMut::new(&mut db, &Address::new()); let rlp = { let mut a = Account::new_contract(69.into(), 0.into()); - a.set_storage(H256::from(&U256::from(0x00u64)), H256::from(&U256::from(0x1234u64))); + a.set_storage(0x00u64.into(), 0x1234u64.into()); a.commit_storage(&Default::default(), &mut db).unwrap(); a.init_code(vec![]); a.commit_code(&mut db); @@ -516,9 +516,9 @@ mod tests { }; let a = Account::from_rlp(&rlp); - assert_eq!(a.storage_root().unwrap().hex(), "c57e1afb758b07f8d2c8f13a3b6e44fa5ff94ab266facc5a4fd3f062426e50b2"); - assert_eq!(a.storage_at(&db.immutable(), &H256::from(&U256::from(0x00u64))).unwrap(), H256::from(&U256::from(0x1234u64))); - assert_eq!(a.storage_at(&db.immutable(), &H256::from(&U256::from(0x01u64))).unwrap(), H256::new()); + assert_eq!(*a.storage_root().unwrap(), "c57e1afb758b07f8d2c8f13a3b6e44fa5ff94ab266facc5a4fd3f062426e50b2".into()); + assert_eq!(a.storage_at(&db.immutable(), &0x00u64.into()).unwrap(), 0x1234u64.into()); + assert_eq!(a.storage_at(&db.immutable(), &0x01u64.into()).unwrap(), H256::default()); } #[test] @@ -548,7 +548,7 @@ mod tests { a.set_storage(0.into(), 0x1234.into()); assert_eq!(a.storage_root(), None); a.commit_storage(&Default::default(), &mut db).unwrap(); - assert_eq!(a.storage_root().unwrap().hex(), "c57e1afb758b07f8d2c8f13a3b6e44fa5ff94ab266facc5a4fd3f062426e50b2"); + assert_eq!(*a.storage_root().unwrap(), "c57e1afb758b07f8d2c8f13a3b6e44fa5ff94ab266facc5a4fd3f062426e50b2".into()); } #[test] @@ -562,7 +562,7 @@ mod tests { a.commit_storage(&Default::default(), &mut db).unwrap(); a.set_storage(1.into(), 0.into()); a.commit_storage(&Default::default(), &mut db).unwrap(); - assert_eq!(a.storage_root().unwrap().hex(), "c57e1afb758b07f8d2c8f13a3b6e44fa5ff94ab266facc5a4fd3f062426e50b2"); + assert_eq!(*a.storage_root().unwrap(), "c57e1afb758b07f8d2c8f13a3b6e44fa5ff94ab266facc5a4fd3f062426e50b2".into()); } #[test] @@ -574,7 +574,7 @@ mod tests { assert_eq!(a.code_filth, Filth::Dirty); assert_eq!(a.code_size(), Some(3)); a.commit_code(&mut db); - assert_eq!(a.code_hash().hex(), "af231e631776a517ca23125370d542873eca1fb4d613ed9b5d5335a46ae5b7eb"); + assert_eq!(a.code_hash(), "af231e631776a517ca23125370d542873eca1fb4d613ed9b5d5335a46ae5b7eb".into()); } #[test] @@ -586,16 +586,16 @@ mod tests { assert_eq!(a.code_filth, Filth::Dirty); a.commit_code(&mut db); assert_eq!(a.code_filth, Filth::Clean); - assert_eq!(a.code_hash().hex(), "af231e631776a517ca23125370d542873eca1fb4d613ed9b5d5335a46ae5b7eb"); + assert_eq!(a.code_hash(), "af231e631776a517ca23125370d542873eca1fb4d613ed9b5d5335a46ae5b7eb".into()); a.reset_code(vec![0x55]); assert_eq!(a.code_filth, Filth::Dirty); a.commit_code(&mut db); - assert_eq!(a.code_hash().hex(), "37bf2238b11b68cdc8382cece82651b59d3c3988873b6e0f33d79694aa45f1be"); + assert_eq!(a.code_hash(), "37bf2238b11b68cdc8382cece82651b59d3c3988873b6e0f33d79694aa45f1be".into()); } #[test] fn rlpio() { - let a = Account::new(U256::from(69u8), U256::from(0u8), HashMap::new(), Bytes::new()); + let a = Account::new(69u8.into(), 0u8.into(), HashMap::new(), Bytes::new()); let b = Account::from_rlp(&a.rlp()); assert_eq!(a.balance(), b.balance()); assert_eq!(a.nonce(), b.nonce()); @@ -605,17 +605,17 @@ mod tests { #[test] fn new_account() { - let a = Account::new(U256::from(69u8), U256::from(0u8), HashMap::new(), Bytes::new()); + let a = Account::new(69u8.into(), 0u8.into(), HashMap::new(), Bytes::new()); assert_eq!(a.rlp().to_hex(), "f8448045a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a0c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470"); - assert_eq!(a.balance(), &U256::from(69u8)); - assert_eq!(a.nonce(), &U256::from(0u8)); + assert_eq!(*a.balance(), 69u8.into()); + assert_eq!(*a.nonce(), 0u8.into()); assert_eq!(a.code_hash(), KECCAK_EMPTY); assert_eq!(a.storage_root().unwrap(), &KECCAK_NULL_RLP); } #[test] fn create_account() { - let a = Account::new(U256::from(69u8), U256::from(0u8), HashMap::new(), Bytes::new()); + let a = Account::new(69u8.into(), 0u8.into(), HashMap::new(), Bytes::new()); assert_eq!(a.rlp().to_hex(), "f8448045a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a0c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470"); } diff --git a/ethcore/src/state/mod.rs b/ethcore/src/state/mod.rs index a8d298440..a6de903dd 100644 --- a/ethcore/src/state/mod.rs +++ b/ethcore/src/state/mod.rs @@ -644,7 +644,7 @@ impl State { /// Mutate storage of account `a` so that it is `value` for `key`. pub fn set_storage(&mut self, a: &Address, key: H256, value: H256) -> trie::Result<()> { - trace!(target: "state", "set_storage({}:{} to {})", a, key.hex(), value.hex()); + trace!(target: "state", "set_storage({}:{:x} to {:x})", a, key, value); if self.storage_at(a, &key)? != value { self.require(a, false)?.set_storage(key, value) } @@ -2085,7 +2085,7 @@ mod tests { let a = Address::zero(); state.require(&a, false).unwrap(); state.commit().unwrap(); - assert_eq!(state.root().hex(), "0ce23f3c809de377b008a4a3ee94a0834aac8bec1f86e28ffe4fdb5a15b0c785"); + assert_eq!(*state.root(), "0ce23f3c809de377b008a4a3ee94a0834aac8bec1f86e28ffe4fdb5a15b0c785".into()); } #[test] @@ -2122,7 +2122,7 @@ mod tests { fn create_empty() { let mut state = get_temp_state(); state.commit().unwrap(); - assert_eq!(state.root().hex(), "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421"); + assert_eq!(*state.root(), "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421".into()); } #[test] diff --git a/ethcore/src/tx_filter.rs b/ethcore/src/tx_filter.rs index a23139898..75bd16842 100644 --- a/ethcore/src/tx_filter.rs +++ b/ethcore/src/tx_filter.rs @@ -19,15 +19,15 @@ use std::collections::HashMap; use std::collections::hash_map::Entry; use ethereum_types::{H256, Address}; -use native_contracts::TransactAcl as Contract; use client::{BlockChainClient, BlockId, ChainNotify}; use bytes::Bytes; use parking_lot::Mutex; -use futures::{self, Future}; use spec::CommonParams; use transaction::{Action, SignedTransaction}; use hash::KECCAK_EMPTY; +use_contract!(transact_acl, "TransactAcl", "res/contracts/tx_acl.json"); + const MAX_CACHE_SIZE: usize = 4096; mod tx_permissions { @@ -41,7 +41,7 @@ mod tx_permissions { /// Connection filter that uses a contract to manage permissions. pub struct TransactionFilter { - contract: Mutex>, + contract: transact_acl::TransactAcl, contract_address: Address, permission_cache: Mutex>, } @@ -51,7 +51,7 @@ impl TransactionFilter { pub fn from_params(params: &CommonParams) -> Option { params.transaction_permission_contract.map(|address| TransactionFilter { - contract: Mutex::new(None), + contract: transact_acl::TransactAcl::default(), contract_address: address, permission_cache: Mutex::new(HashMap::new()), } @@ -79,23 +79,15 @@ impl TransactionFilter { match cache.entry((*parent_hash, sender)) { Entry::Occupied(entry) => *entry.get() & tx_type != 0, Entry::Vacant(entry) => { - let mut contract = self.contract.lock(); - if contract.is_none() { - *contract = Some(Contract::new(self.contract_address)); - } - - let permissions = match &*contract { - &Some(ref contract) => { - contract.allowed_tx_types( - |addr, data| futures::done(client.call_contract(BlockId::Hash(*parent_hash), addr, data)), - sender, - ).wait().unwrap_or_else(|e| { - debug!("Error callling tx permissions contract: {:?}", e); - tx_permissions::NONE - }) - } - _ => tx_permissions::NONE, - }; + let contract_address = self.contract_address; + let permissions = self.contract.functions() + .allowed_tx_types() + .call(sender, &|data| client.call_contract(BlockId::Hash(*parent_hash), contract_address, data)) + .map(|p| p.low_u32()) + .unwrap_or_else(|e| { + debug!("Error callling tx permissions contract: {:?}", e); + tx_permissions::NONE + }); if len < MAX_CACHE_SIZE { entry.insert(permissions); diff --git a/ethcore/transaction/Cargo.toml b/ethcore/transaction/Cargo.toml index 7cf5cc416..7b45cae47 100644 --- a/ethcore/transaction/Cargo.toml +++ b/ethcore/transaction/Cargo.toml @@ -12,7 +12,7 @@ heapsize = "0.4" keccak-hash = { path = "../../util/hash" } rlp = { path = "../../util/rlp" } unexpected = { path = "../../util/unexpected" } -ethereum-types = "0.1" +ethereum-types = "0.2" [dev-dependencies] rustc-hex= "1.0" diff --git a/ethcore/types/Cargo.toml b/ethcore/types/Cargo.toml index fd315c9f4..a14929f47 100644 --- a/ethcore/types/Cargo.toml +++ b/ethcore/types/Cargo.toml @@ -8,7 +8,7 @@ authors = ["Parity Technologies "] rlp = { path = "../../util/rlp" } rlp_derive = { path = "../../util/rlp_derive" } ethcore-bytes = { path = "../../util/bytes" } -ethereum-types = "0.1" +ethereum-types = "0.2" ethjson = { path = "../../json" } keccak-hash = { path = "../../util/hash" } heapsize = "0.4" diff --git a/ethcore/vm/Cargo.toml b/ethcore/vm/Cargo.toml index 7ab98afc7..41ff98d0a 100644 --- a/ethcore/vm/Cargo.toml +++ b/ethcore/vm/Cargo.toml @@ -6,7 +6,7 @@ authors = ["Parity Technologies "] [dependencies] byteorder = "1.0" ethcore-bytes = { path = "../../util/bytes" } -ethereum-types = "0.1" +ethereum-types = "0.2" patricia-trie = { path = "../../util/patricia_trie" } log = "0.3" common-types = { path = "../types" } diff --git a/ethcore/wasm/Cargo.toml b/ethcore/wasm/Cargo.toml index 3c2d89e42..d3f2852c6 100644 --- a/ethcore/wasm/Cargo.toml +++ b/ethcore/wasm/Cargo.toml @@ -5,7 +5,7 @@ authors = ["Parity Technologies "] [dependencies] byteorder = "1.0" -ethereum-types = "0.1" +ethereum-types = "0.2" log = "0.3" parity-wasm = "0.23" libc = "0.2" diff --git a/ethcore/wasm/run/Cargo.toml b/ethcore/wasm/run/Cargo.toml index a56025f62..91cbfb996 100644 --- a/ethcore/wasm/run/Cargo.toml +++ b/ethcore/wasm/run/Cargo.toml @@ -7,7 +7,7 @@ authors = ["Parity Technologies "] serde = "1" serde_json = "1" serde_derive = "1" -ethereum-types = "0.1" +ethereum-types = "0.2" ethjson = { path = "../../../json" } vm = { path = "../../vm" } wasm = { path = "../" } diff --git a/ethcrypto/Cargo.toml b/ethcrypto/Cargo.toml index ee6566785..2344f59d0 100644 --- a/ethcrypto/Cargo.toml +++ b/ethcrypto/Cargo.toml @@ -8,5 +8,5 @@ rust-crypto = "0.2.36" tiny-keccak = "1.3" eth-secp256k1 = { git = "https://github.com/paritytech/rust-secp256k1" } ethkey = { path = "../ethkey" } -ethereum-types = "0.1" +ethereum-types = "0.2" subtle = "0.1" diff --git a/ethkey/Cargo.toml b/ethkey/Cargo.toml index 9fe8dbf07..a3e903271 100644 --- a/ethkey/Cargo.toml +++ b/ethkey/Cargo.toml @@ -7,11 +7,11 @@ authors = ["Parity Technologies "] byteorder = "1.0" edit-distance = "2.0" eth-secp256k1 = { git = "https://github.com/paritytech/rust-secp256k1" } -ethereum-types = "0.1" +ethereum-types = "0.2" lazy_static = "1.0" log = "0.3" parity-wordlist = "1.2" -rand = "0.3.14" +rand = "0.4" rust-crypto = "0.2" rustc-hex = "1.0" tiny-keccak = "1.3" diff --git a/ethstore/Cargo.toml b/ethstore/Cargo.toml index 0706fb1b7..1f821cb1f 100755 --- a/ethstore/Cargo.toml +++ b/ethstore/Cargo.toml @@ -6,7 +6,7 @@ authors = ["Parity Technologies "] [dependencies] log = "0.3" libc = "0.2" -rand = "0.3" +rand = "0.4" ethkey = { path = "../ethkey" } serde = "1.0" serde_json = "1.0" @@ -18,7 +18,7 @@ time = "0.1.34" itertools = "0.5" parking_lot = "0.5" ethcrypto = { path = "../ethcrypto" } -ethereum-types = "0.1" +ethereum-types = "0.2" dir = { path = "../util/dir" } smallvec = "0.4" parity-wordlist = "1.0" diff --git a/evmbin/Cargo.toml b/evmbin/Cargo.toml index 9f2c9fa7d..8a83f9a35 100644 --- a/evmbin/Cargo.toml +++ b/evmbin/Cargo.toml @@ -14,7 +14,7 @@ ethcore = { path = "../ethcore" } ethjson = { path = "../json" } ethcore-bytes = { path = "../util/bytes" } ethcore-transaction = { path = "../ethcore/transaction" } -ethereum-types = "0.1" +ethereum-types = "0.2" evm = { path = "../ethcore/evm" } panic_hook = { path = "../util/panic_hook" } rustc-hex = "1.0" diff --git a/evmbin/src/display/json.rs b/evmbin/src/display/json.rs index fbfb46952..00ca91b94 100644 --- a/evmbin/src/display/json.rs +++ b/evmbin/src/display/json.rs @@ -49,7 +49,7 @@ impl Informant { } fn stack(&self) -> String { - let items = self.stack.iter().map(display::u256_as_str).collect::>(); + let items = self.stack.iter().map(|i| format!("\"0x{:x}\"", i)).collect::>(); format!("[{}]", items.join(",")) } @@ -124,12 +124,12 @@ impl trace::VMTracer for Informant { let info = ::evm::INSTRUCTIONS[self.instruction as usize]; let trace = format!( - "{{\"pc\":{pc},\"op\":{op},\"opName\":\"{name}\",\"gas\":{gas},\"gasCost\":{gas_cost},\"memory\":{memory},\"stack\":{stack},\"storage\":{storage},\"depth\":{depth}}}", + "{{\"pc\":{pc},\"op\":{op},\"opName\":\"{name}\",\"gas\":\"0x{gas:x}\",\"gasCost\":\"0x{gas_cost:x}\",\"memory\":{memory},\"stack\":{stack},\"storage\":{storage},\"depth\":{depth}}}", pc = self.pc, op = self.instruction, name = info.name, - gas = display::u256_as_str(&(gas_used.saturating_add(self.gas_cost))), - gas_cost = display::u256_as_str(&self.gas_cost), + gas = gas_used.saturating_add(self.gas_cost), + gas_cost = self.gas_cost, memory = self.memory(), stack = self.stack(), storage = self.storage(), diff --git a/evmbin/src/display/mod.rs b/evmbin/src/display/mod.rs index f5a18aa94..b9390058b 100644 --- a/evmbin/src/display/mod.rs +++ b/evmbin/src/display/mod.rs @@ -17,7 +17,6 @@ //! VM Output display utils. use std::time::Duration; -use ethereum_types::U256; pub mod json; pub mod std_json; @@ -32,13 +31,3 @@ pub fn format_time(time: &Duration) -> String { pub fn as_micros(time: &Duration) -> u64 { time.as_secs() * 1_000_000 + time.subsec_nanos() as u64 / 1_000 } - -/// Converts U256 into string. -/// TODO Overcomes: https://github.com/paritytech/bigint/issues/13 -pub fn u256_as_str(v: &U256) -> String { - if v.is_zero() { - "\"0x0\"".into() - } else { - format!("\"{:x}\"", v) - } -} diff --git a/evmbin/src/display/std_json.rs b/evmbin/src/display/std_json.rs index fe34c29a4..3d8f52dbd 100644 --- a/evmbin/src/display/std_json.rs +++ b/evmbin/src/display/std_json.rs @@ -67,7 +67,7 @@ impl Informant { impl Informant { fn stack(&self) -> String { - let items = self.stack.iter().map(display::u256_as_str).collect::>(); + let items = self.stack.iter().map(|i| format!("\"0x{:x}\"", i)).collect::>(); format!("[{}]", items.join(",")) } @@ -125,11 +125,11 @@ impl trace::VMTracer for Informant { writeln!( &mut self.sink, - "{{\"pc\":{pc},\"op\":{op},\"opName\":\"{name}\",\"gas\":{gas},\"stack\":{stack},\"storage\":{storage},\"depth\":{depth}}}", + "{{\"pc\":{pc},\"op\":{op},\"opName\":\"{name}\",\"gas\":\"0x{gas:x}\",\"stack\":{stack},\"storage\":{storage},\"depth\":{depth}}}", pc = pc, op = instruction, name = info.name, - gas = display::u256_as_str(¤t_gas), + gas = current_gas, stack = stack, storage = storage, depth = self.depth, diff --git a/hash-fetch/Cargo.toml b/hash-fetch/Cargo.toml index b6c940bf2..f20f76fcc 100644 --- a/hash-fetch/Cargo.toml +++ b/hash-fetch/Cargo.toml @@ -11,15 +11,17 @@ futures = "0.1" log = "0.3" mime = "0.3" mime_guess = "2.0.0-alpha.2" -rand = "0.3" +rand = "0.4" rustc-hex = "1.0" fetch = { path = "../util/fetch" } ethcore-bytes = { path = "../util/bytes" } -ethereum-types = "0.1" +ethereum-types = "0.2" parity-reactor = { path = "../util/reactor" } -native-contracts = { path = "../ethcore/native_contracts" } keccak-hash = { path = "../util/hash" } +ethabi = "5.1" +ethabi-derive = "5.0" +ethabi-contract = "5.0" + [dev-dependencies] -ethabi = "4.0" parking_lot = "0.5" diff --git a/hash-fetch/src/client.rs b/hash-fetch/src/client.rs index d4a5c3208..9d2a5c838 100644 --- a/hash-fetch/src/client.rs +++ b/hash-fetch/src/client.rs @@ -23,7 +23,7 @@ use std::path::PathBuf; use hash::keccak_buffer; use fetch::{Fetch, Response, Error as FetchError, Client as FetchClient}; -use futures::Future; +use futures::{Future, IntoFuture}; use parity_reactor::Remote; use urlhint::{ContractClient, URLHintContract, URLHint, URLHintResult}; use ethereum_types::H256; @@ -143,7 +143,7 @@ impl HashFetch for Client { let random_path = self.random_path.clone(); let remote_fetch = self.fetch.clone(); - let future = self.contract.resolve(hash.to_vec()) + let future = self.contract.resolve(hash) .map_err(|e| { warn!("Error resolving URL: {}", e); Error::NoResolution }) .and_then(|maybe_url| maybe_url.ok_or(Error::NoResolution)) .map(|content| match content { @@ -157,6 +157,7 @@ impl HashFetch for Client { content.url }, }) + .into_future() .and_then(move |url| { debug!(target: "fetch", "Resolved {:?} to {:?}. Fetching...", hash, url); let future = remote_fetch.fetch(&url).then(move |result| { diff --git a/hash-fetch/src/lib.rs b/hash-fetch/src/lib.rs index 2165b5a39..15c6031ce 100644 --- a/hash-fetch/src/lib.rs +++ b/hash-fetch/src/lib.rs @@ -21,23 +21,25 @@ #[macro_use] extern crate log; +extern crate ethabi; extern crate ethcore_bytes as bytes; extern crate ethereum_types; extern crate futures; extern crate keccak_hash as hash; extern crate mime; extern crate mime_guess; -extern crate native_contracts; extern crate parity_reactor; extern crate rand; extern crate rustc_hex; pub extern crate fetch; +#[macro_use] +extern crate ethabi_derive; +#[macro_use] +extern crate ethabi_contract; #[cfg(test)] extern crate parking_lot; -#[cfg(test)] -extern crate ethabi; mod client; diff --git a/hash-fetch/src/urlhint.rs b/hash-fetch/src/urlhint.rs index 3f958d1db..39c12347a 100644 --- a/hash-fetch/src/urlhint.rs +++ b/hash-fetch/src/urlhint.rs @@ -23,13 +23,12 @@ use mime_guess; use hash::keccak; use futures::{future, Future}; -use native_contracts::{Registry, Urlhint}; -use ethereum_types::{H160, H256, Address}; +use futures::future::Either; +use ethereum_types::{H256, Address}; use bytes::Bytes; -/// Boxed future that can be shared between threads. -/// TODO [ToDr] Use concrete types! -pub type BoxFuture = Box + Send>; +use_contract!(registry, "Registry", "res/registrar.json"); +use_contract!(urlhint, "Urlhint", "res/urlhint.json"); const COMMIT_LEN: usize = 20; /// GithubHint entries with commit set as `0x0..01` should be treated @@ -43,7 +42,7 @@ pub trait ContractClient: Send + Sync { /// Get registrar address fn registrar(&self) -> Result; /// Call Contract - fn call(&self, address: Address, data: Bytes) -> BoxFuture; + fn call(&self, address: Address, data: Bytes) -> Box + Send>; } /// Github-hosted dapp. @@ -106,14 +105,13 @@ pub enum URLHintResult { /// URLHint Contract interface pub trait URLHint: Send + Sync { /// Resolves given id to registrar entry. - fn resolve(&self, id: Bytes) -> BoxFuture, String>; + fn resolve(&self, id: H256) -> Box, Error = String> + Send>; } /// `URLHintContract` API -#[derive(Clone)] pub struct URLHintContract { - urlhint: Arc, - registrar: Registry, + urlhint: urlhint::Urlhint, + registrar: registry::Registry, client: Arc, } @@ -121,9 +119,9 @@ impl URLHintContract { /// Creates new `URLHintContract` pub fn new(client: Arc) -> Self { URLHintContract { - urlhint: Arc::new(Urlhint::new(Default::default())), - registrar: Registry::new(Default::default()), - client: client, + urlhint: urlhint::Urlhint::default(), + registrar: registry::Registry::default(), + client, } } } @@ -137,7 +135,7 @@ fn get_urlhint_content(account_slash_repo: String, owner: Address) -> Content { } } -fn decode_urlhint_output(output: (String, H160, Address)) -> Option { +fn decode_urlhint_output(output: (String, [u8; 20], Address)) -> Option { let (account_slash_repo, commit, owner) = output; if owner == Address::default() { @@ -173,36 +171,30 @@ fn decode_urlhint_output(output: (String, H160, Address)) -> Option BoxFuture, String> { - use futures::future::Either; - - let do_call = |_, data| { - let addr = match self.client.registrar() { - Ok(addr) => addr, - Err(e) => return Box::new(future::err(e)) - as BoxFuture, _>, - }; - - self.client.call(addr, data) + fn resolve(&self, id: H256) -> Box, Error = String> + Send> { + let address = match self.client.registrar() { + Ok(a) => a, + Err(e) => return Box::new(future::err(e)), }; - let urlhint = self.urlhint.clone(); let client = self.client.clone(); - Box::new(self.registrar.get_address(do_call, keccak("githubhint"), "A".into()) - .map(|addr| if addr == Address::default() { None } else { Some(addr) }) - .and_then(move |address| { - let mut fixed_id = [0; 32]; - let len = ::std::cmp::min(32, id.len()); - fixed_id[..len].copy_from_slice(&id[..len]); + let get_address = self.registrar.functions().get_address(); + let entries = self.urlhint.functions().entries(); + let data = get_address.input(keccak("githubhint"), "A"); - match address { - None => Either::A(future::ok(None)), - Some(address) => { - let do_call = move |_, data| client.call(address, data); - Either::B(urlhint.entries(do_call, H256(fixed_id)).map(decode_urlhint_output)) - } - } - })) + let future = client.call(address, data) + .and_then(move |output| get_address.output(&output).map_err(|e| e.to_string())) + .and_then(move |addr| if !addr.is_zero() { + let data = entries.input(id); + let result = client.call(addr, data) + .and_then(move |output| entries.output(&output).map_err(|e| e.to_string())) + .map(decode_urlhint_output); + Either::B(result) + } else { + Either::A(future::ok(None)) + }); + + Box::new(future) } } @@ -270,7 +262,7 @@ pub mod tests { Ok(REGISTRAR.parse().unwrap()) } - fn call(&self, address: Address, data: Bytes) -> BoxFuture { + fn call(&self, address: Address, data: Bytes) -> Box + Send> { self.calls.lock().push((address.to_hex(), data.to_hex())); let res = self.responses.lock().remove(0); Box::new(res.into_future()) @@ -283,7 +275,7 @@ pub mod tests { let registrar = FakeRegistrar::new(); let resolve_result = { use ethabi::{encode, Token}; - encode(&[Token::String(String::new()), Token::FixedBytes(vec![0; 20]), Token::Address([0; 20])]) + encode(&[Token::String(String::new()), Token::FixedBytes(vec![0; 20]), Token::Address([0; 20].into())]) }; registrar.responses.lock()[1] = Ok(resolve_result); @@ -293,7 +285,7 @@ pub mod tests { // when - let res = urlhint.resolve("test".bytes().collect()).wait().unwrap(); + let res = urlhint.resolve("test".as_bytes().into()).wait().unwrap(); let calls = calls.lock(); let call0 = calls.get(0).expect("Registrar resolve called"); let call1 = calls.get(1).expect("URLHint Resolve called"); @@ -321,7 +313,7 @@ pub mod tests { let urlhint = URLHintContract::new(Arc::new(registrar)); // when - let res = urlhint.resolve("test".bytes().collect()).wait().unwrap(); + let res = urlhint.resolve("test".as_bytes().into()).wait().unwrap(); // then assert_eq!(res, Some(URLHintResult::Dapp(GithubApp { @@ -343,7 +335,7 @@ pub mod tests { let urlhint = URLHintContract::new(Arc::new(registrar)); // when - let res = urlhint.resolve("test".bytes().collect()).wait().unwrap(); + let res = urlhint.resolve("test".as_bytes().into()).wait().unwrap(); // then assert_eq!(res, Some(URLHintResult::Content(Content { diff --git a/hw/Cargo.toml b/hw/Cargo.toml index 2c2440ffc..9e248e7ae 100644 --- a/hw/Cargo.toml +++ b/hw/Cargo.toml @@ -14,7 +14,7 @@ hidapi = { git = "https://github.com/paritytech/hidapi-rs" } libusb = { git = "https://github.com/paritytech/libusb-rs" } trezor-sys = { git = "https://github.com/paritytech/trezor-sys" } ethkey = { path = "../ethkey" } -ethereum-types = "0.1" +ethereum-types = "0.2" [dev-dependencies] rustc-hex = "1.0" diff --git a/ipfs/Cargo.toml b/ipfs/Cargo.toml index 437c4d638..353b47df1 100644 --- a/ipfs/Cargo.toml +++ b/ipfs/Cargo.toml @@ -8,7 +8,7 @@ authors = ["Parity Technologies "] [dependencies] ethcore = { path = "../ethcore" } ethcore-bytes = { path = "../util/bytes" } -ethereum-types = "0.1" +ethereum-types = "0.2" jsonrpc-core = { git = "https://github.com/paritytech/jsonrpc.git", branch = "parity-1.10" } jsonrpc-http-server = { git = "https://github.com/paritytech/jsonrpc.git", branch = "parity-1.10" } rlp = { path = "../util/rlp" } diff --git a/json/Cargo.toml b/json/Cargo.toml index 49371a6d9..6e84e6da3 100644 --- a/json/Cargo.toml +++ b/json/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" authors = ["Parity Technologies "] [dependencies] -ethereum-types = "0.1" +ethereum-types = "0.2" rustc-hex = "1.0" serde = "1.0" serde_json = "1.0" diff --git a/machine/Cargo.toml b/machine/Cargo.toml index 7e3b23e67..037bc55bf 100644 --- a/machine/Cargo.toml +++ b/machine/Cargo.toml @@ -5,4 +5,4 @@ description = "Generalization of a state machine for consensus engines" authors = ["Parity Technologies "] [dependencies] -ethereum-types = "0.1" +ethereum-types = "0.2" diff --git a/miner/Cargo.toml b/miner/Cargo.toml index d255e54a1..0fc9052ea 100644 --- a/miner/Cargo.toml +++ b/miner/Cargo.toml @@ -11,16 +11,18 @@ authors = ["Parity Technologies "] hyper = { git = "https://github.com/paritytech/hyper", default-features = false } common-types = { path = "../ethcore/types" } +ethabi = "5.1" +ethabi-contract = "5.0" +ethabi-derive = "5.0" ethash = { path = "../ethash" } ethcore-transaction = { path = "../ethcore/transaction" } -ethereum-types = "0.1" +ethereum-types = "0.2" ethkey = { path = "../ethkey" } futures = "0.1" heapsize = "0.4" keccak-hash = { path = "../util/hash" } linked-hash-map = "0.5" log = "0.3" -native-contracts = { path = "../ethcore/native_contracts" } parking_lot = "0.5" rustc-hex = "1.0" table = { path = "../util/table" } diff --git a/ethcore/native_contracts/res/service_transaction.json b/miner/res/service_transaction.json similarity index 100% rename from ethcore/native_contracts/res/service_transaction.json rename to miner/res/service_transaction.json diff --git a/miner/src/lib.rs b/miner/src/lib.rs index fe6e5fe21..9a2ebae13 100644 --- a/miner/src/lib.rs +++ b/miner/src/lib.rs @@ -20,24 +20,27 @@ //! Keeps track of transactions and mined block. extern crate common_types as types; -extern crate ethereum_types; +extern crate ethabi; extern crate ethcore_transaction as transaction; +extern crate ethereum_types; extern crate futures; extern crate heapsize; extern crate keccak_hash as hash; extern crate linked_hash_map; -extern crate native_contracts; extern crate parking_lot; extern crate table; extern crate transient_hashmap; #[macro_use] -extern crate log; - -#[cfg(test)] -extern crate rustc_hex; +extern crate ethabi_derive; +#[macro_use] +extern crate ethabi_contract; #[cfg(test)] extern crate ethkey; +#[macro_use] +extern crate log; +#[cfg(test)] +extern crate rustc_hex; pub mod banning_queue; pub mod external; diff --git a/miner/src/service_transaction_checker.rs b/miner/src/service_transaction_checker.rs index 338768d55..806acf29b 100644 --- a/miner/src/service_transaction_checker.rs +++ b/miner/src/service_transaction_checker.rs @@ -16,13 +16,12 @@ //! A service transactions contract checker. -use futures::{future, Future}; -use native_contracts::ServiceTransactionChecker as Contract; -use ethereum_types::{U256, Address}; -use parking_lot::Mutex; +use ethereum_types::Address; use transaction::SignedTransaction; use types::ids::BlockId; +use_contract!(service_transaction, "ServiceTransaction", "res/service_transaction.json"); + const SERVICE_TRANSACTION_CONTRACT_REGISTRY_NAME: &'static str = "service_transaction_checker"; /// A contract calling interface. @@ -37,34 +36,22 @@ pub trait ContractCaller { /// Service transactions checker. #[derive(Default)] pub struct ServiceTransactionChecker { - contract: Mutex>, + contract: service_transaction::ServiceTransaction, } impl ServiceTransactionChecker { - /// Try to create instance, reading contract address from given chain client. - pub fn update_from_chain_client(&self, client: &ContractCaller) { - let mut contract = self.contract.lock(); - if contract.is_none() { - *contract = client.registry_address(SERVICE_TRANSACTION_CONTRACT_REGISTRY_NAME) - .and_then(|contract_addr| { - trace!(target: "txqueue", "Configuring for service transaction checker contract from {}", contract_addr); - - Some(Contract::new(contract_addr)) - }) - } - } - /// Checks if service transaction can be appended to the transaction queue. pub fn check(&self, client: &ContractCaller, tx: &SignedTransaction) -> Result { - debug_assert_eq!(tx.gas_price, U256::zero()); + assert!(tx.gas_price.is_zero()); - if let Some(ref contract) = *self.contract.lock() { - contract.certified( - |addr, data| future::done(client.call_contract(BlockId::Latest, addr, data)), - tx.sender() - ).wait() - } else { - Err("contract is not configured".to_owned()) - } + let address = client.registry_address(SERVICE_TRANSACTION_CONTRACT_REGISTRY_NAME) + .ok_or_else(|| "contract is not configured")?; + + trace!(target: "txqueue", "Checking service transaction checker contract from {}", address); + + self.contract.functions() + .certified() + .call(tx.sender(), &|data| client.call_contract(BlockId::Latest, address, data)) + .map_err(|e| e.to_string()) } } diff --git a/miner/src/work_notify.rs b/miner/src/work_notify.rs index f02393c89..8ab65ed83 100644 --- a/miner/src/work_notify.rs +++ b/miner/src/work_notify.rs @@ -88,8 +88,8 @@ impl NotifyWork for WorkPoster { let seed_hash = &self.seed_compute.lock().hash_block_number(number); let seed_hash = H256::from_slice(&seed_hash[..]); let body = format!( - r#"{{ "result": ["0x{}","0x{}","0x{}","0x{:x}"] }}"#, - pow_hash.hex(), seed_hash.hex(), target.hex(), number + r#"{{ "result": ["0x{:x}","0x{:x}","0x{:x}","0x{:x}"] }}"#, + pow_hash, seed_hash, target, number ); let mut client = self.client.lock(); for u in &self.urls { diff --git a/parity/blockchain.rs b/parity/blockchain.rs index 3baf97f61..6f6507b01 100644 --- a/parity/blockchain.rs +++ b/parity/blockchain.rs @@ -645,17 +645,17 @@ fn execute_export_state(cmd: ExportState) -> Result<(), String> { if i != 0 { out.write(b",").expect("Write error"); } - out.write_fmt(format_args!("\n\"0x{}\": {{\"balance\": \"{:x}\", \"nonce\": \"{:x}\"", account.hex(), balance, client.nonce(&account, at).unwrap_or_else(U256::zero))).expect("Write error"); + out.write_fmt(format_args!("\n\"0x{:x}\": {{\"balance\": \"{:x}\", \"nonce\": \"{:x}\"", account, balance, client.nonce(&account, at).unwrap_or_else(U256::zero))).expect("Write error"); let code = client.code(&account, at).unwrap_or(None).unwrap_or_else(Vec::new); if !code.is_empty() { - out.write_fmt(format_args!(", \"code_hash\": \"0x{}\"", keccak(&code).hex())).expect("Write error"); + out.write_fmt(format_args!(", \"code_hash\": \"0x{:x}\"", keccak(&code))).expect("Write error"); if cmd.code { out.write_fmt(format_args!(", \"code\": \"{}\"", code.to_hex())).expect("Write error"); } } let storage_root = client.storage_root(&account, at).unwrap_or(KECCAK_NULL_RLP); if storage_root != KECCAK_NULL_RLP { - out.write_fmt(format_args!(", \"storage_root\": \"0x{}\"", storage_root.hex())).expect("Write error"); + out.write_fmt(format_args!(", \"storage_root\": \"0x{:x}\"", storage_root)).expect("Write error"); if cmd.storage { out.write_fmt(format_args!(", \"storage\": {{")).expect("Write error"); let mut last_storage: Option = None; @@ -669,7 +669,7 @@ fn execute_export_state(cmd: ExportState) -> Result<(), String> { if last_storage.is_some() { out.write(b",").expect("Write error"); } - out.write_fmt(format_args!("\n\t\"0x{}\": \"0x{}\"", key.hex(), client.storage_at(&account, &key, at).unwrap_or_else(Default::default).hex())).expect("Write error"); + out.write_fmt(format_args!("\n\t\"0x{:x}\": \"0x{:x}\"", key, client.storage_at(&account, &key, at).unwrap_or_else(Default::default))).expect("Write error"); last_storage = Some(key); } } diff --git a/parity/configuration.rs b/parity/configuration.rs index 6b19c1702..480fefe7d 100644 --- a/parity/configuration.rs +++ b/parity/configuration.rs @@ -1384,7 +1384,13 @@ mod tests { acc_conf: Default::default(), gas_pricer_conf: Default::default(), miner_extras: Default::default(), - update_policy: UpdatePolicy { enable_downloading: true, require_consensus: true, filter: UpdateFilter::Critical, track: ReleaseTrack::Unknown, path: default_hypervisor_path() }, + update_policy: UpdatePolicy { + enable_downloading: true, + require_consensus: true, + filter: UpdateFilter::Critical, + track: ReleaseTrack::Unknown, + path: default_hypervisor_path() + }, mode: Default::default(), tracing: Default::default(), compaction: Default::default(), diff --git a/parity/dapps.rs b/parity/dapps.rs index 8d200aa09..0d66bdc85 100644 --- a/parity/dapps.rs +++ b/parity/dapps.rs @@ -22,7 +22,7 @@ use dir::default_data_path; use dir::helpers::replace_home; use ethcore::client::{Client, BlockChainClient, BlockId}; use ethsync::LightSync; -use futures::{future, IntoFuture, Future}; +use futures::{Future, future, IntoFuture}; use hash_fetch::fetch::Client as FetchClient; use hash_fetch::urlhint::ContractClient; use light::client::LightChainClient; @@ -70,18 +70,22 @@ pub struct FullRegistrar { pub client: Arc, } +impl FullRegistrar { + pub fn new(client: Arc) -> Self { + FullRegistrar { + client, + } + } +} + impl ContractClient for FullRegistrar { fn registrar(&self) -> Result { - self.client.additional_params().get("registrar") + self.client.registrar_address() .ok_or_else(|| "Registrar not defined.".into()) - .and_then(|registrar| { - registrar.parse().map_err(|e| format!("Invalid registrar address: {:?}", e)) - }) } - fn call(&self, address: Address, data: Bytes) -> Box + Send> { - Box::new(self.client.call_contract(BlockId::Latest, address, data) - .into_future()) + fn call(&self, address: Address, data: Bytes) -> Box + Send> { + Box::new(self.client.call_contract(BlockId::Latest, address, data).into_future()) } } @@ -104,13 +108,13 @@ impl ContractClient for LightRegistrar { }) } - fn call(&self, address: Address, data: Bytes) -> Box + Send> { + fn call(&self, address: Address, data: Bytes) -> Box + Send> { let header = self.client.best_block_header(); let env_info = self.client.env_info(BlockId::Hash(header.hash())) .ok_or_else(|| format!("Cannot fetch env info for header {}", header.hash())); let env_info = match env_info { - Ok(x) => x, + Ok(e) => e, Err(e) => return Box::new(future::err(e)), }; diff --git a/parity/main.rs b/parity/main.rs index 89f649146..1a1eccf12 100644 --- a/parity/main.rs +++ b/parity/main.rs @@ -144,7 +144,7 @@ fn print_hash_of(maybe_file: Option) -> Result { if let Some(file) = maybe_file { let mut f = BufReader::new(File::open(&file).map_err(|_| "Unable to open file".to_owned())?); let hash = keccak_buffer(&mut f).map_err(|_| "Unable to read from file".to_owned())?; - Ok(hash.hex()) + Ok(format!("{:x}", hash)) } else { Err("Streaming from standard input not yet supported. Specify a file.".to_owned()) } diff --git a/parity/run.rs b/parity/run.rs index 3ee4b9db6..585b72443 100644 --- a/parity/run.rs +++ b/parity/run.rs @@ -35,6 +35,7 @@ use ethcore_logger::{Config as LogConfig, RotatingLogger}; use ethsync::{self, SyncConfig}; use fdlimit::raise_fd_limit; use hash_fetch::fetch::{Fetch, Client as FetchClient}; +use hash_fetch; use informant::{Informant, LightNodeInformantData, FullNodeInformantData}; use journaldb::Algorithm; use light::Cache as LightDataCache; @@ -304,11 +305,11 @@ fn execute_light_impl(cmd: RunCmd, can_restart: bool, logger: Arc); impl fmt::Debug for LightSyncStatus { @@ -334,7 +335,7 @@ fn execute_light_impl(cmd: RunCmd, can_restart: bool, logger: Arc) // spin up event loop let event_loop = EventLoop::spawn(); + let contract_client = Arc::new(::dapps::FullRegistrar::new(client.clone())); + // the updater service let updater = Updater::new( Arc::downgrade(&(service.client() as Arc)), Arc::downgrade(&sync_provider), update_policy, - fetch.clone(), - event_loop.remote(), + hash_fetch::Client::with_fetch(contract_client.clone(), fetch.clone(), event_loop.remote()) ); service.add_notify(updater.clone()); @@ -698,7 +700,6 @@ pub fn execute_impl(cmd: RunCmd, can_restart: bool, logger: Arc) // the dapps server let (node_health, dapps_deps) = { let (sync, client) = (sync_provider.clone(), client.clone()); - let contract_client = Arc::new(::dapps::FullRegistrar { client: client.clone() }); struct SyncStatus(Arc, Arc, ethsync::NetworkConfiguration); impl fmt::Debug for SyncStatus { @@ -725,7 +726,7 @@ pub fn execute_impl(cmd: RunCmd, can_restart: bool, logger: Arc) (node_health.clone(), dapps::Dependencies { sync_status, node_health, - contract_client: contract_client, + contract_client, fetch: fetch.clone(), signer: signer_service.clone(), ui_address: cmd.ui_conf.redirection_address(), diff --git a/rpc/Cargo.toml b/rpc/Cargo.toml index bfb26e2d2..96a8e836f 100644 --- a/rpc/Cargo.toml +++ b/rpc/Cargo.toml @@ -16,7 +16,7 @@ log = "0.3" multihash ="0.7" order-stat = "0.1" parking_lot = "0.5" -rand = "0.3" +rand = "0.4" rust-crypto = "0.2" rustc-hex = "1.0" semver = "0.6" @@ -46,7 +46,7 @@ ethcore-light = { path = "../ethcore/light" } ethcore-logger = { path = "../logger" } ethcore-miner = { path = "../miner" } ethcore-transaction = { path = "../ethcore/transaction" } -ethereum-types = "0.1" +ethereum-types = "0.2" ethcrypto = { path = "../ethcrypto" } ethjson = { path = "../json" } diff --git a/rpc/src/v1/helpers/light_fetch.rs b/rpc/src/v1/helpers/light_fetch.rs index 7746aaef8..eccf521d9 100644 --- a/rpc/src/v1/helpers/light_fetch.rs +++ b/rpc/src/v1/helpers/light_fetch.rs @@ -455,7 +455,7 @@ fn execute_tx(gas_known: bool, params: ExecuteParams) -> BoxFuture params.hdr.gas_limit() { params.tx.gas = old_gas; } else { diff --git a/rpc/src/v1/tests/mocked/eth.rs b/rpc/src/v1/tests/mocked/eth.rs index 9abb94aa7..c66da9b1c 100644 --- a/rpc/src/v1/tests/mocked/eth.rs +++ b/rpc/src/v1/tests/mocked/eth.rs @@ -874,12 +874,12 @@ fn rpc_eth_sign_transaction() { r#""input":"0x","# + r#""nonce":"0x1","# + &format!("\"publicKey\":\"0x{:?}\",", t.recover_public().unwrap()) + - &format!("\"r\":\"0x{}\",", U256::from(signature.r()).to_hex()) + + &format!("\"r\":\"0x{:x}\",", U256::from(signature.r())) + &format!("\"raw\":\"0x{}\",", rlp.to_hex()) + - &format!("\"s\":\"0x{}\",", U256::from(signature.s()).to_hex()) + - &format!("\"standardV\":\"0x{}\",", U256::from(t.standard_v()).to_hex()) + + &format!("\"s\":\"0x{:x}\",", U256::from(signature.s())) + + &format!("\"standardV\":\"0x{:x}\",", U256::from(t.standard_v())) + r#""to":"0xd46e8dd67c5d32be8058bb8eb970870f07244567","transactionIndex":null,"# + - &format!("\"v\":\"0x{}\",", U256::from(t.original_v()).to_hex()) + + &format!("\"v\":\"0x{:x}\",", U256::from(t.original_v())) + r#""value":"0x9184e72a""# + r#"}},"id":1}"#; diff --git a/rpc/src/v1/tests/mocked/parity.rs b/rpc/src/v1/tests/mocked/parity.rs index 34d712b8c..4b75e07fe 100644 --- a/rpc/src/v1/tests/mocked/parity.rs +++ b/rpc/src/v1/tests/mocked/parity.rs @@ -134,14 +134,14 @@ fn rpc_parity_accounts_info() { deps.accounts.set_account_meta(address.clone(), "{foo: 69}".into()).unwrap(); let request = r#"{"jsonrpc": "2.0", "method": "parity_accountsInfo", "params": [], "id": 1}"#; - let response = format!("{{\"jsonrpc\":\"2.0\",\"result\":{{\"0x{}\":{{\"name\":\"Test\"}}}},\"id\":1}}", address.hex()); + let response = format!("{{\"jsonrpc\":\"2.0\",\"result\":{{\"0x{:x}\":{{\"name\":\"Test\"}}}},\"id\":1}}", address); assert_eq!(io.handle_request_sync(request), Some(response)); // Change the whitelist let address = Address::from(1); deps.accounts.set_new_dapps_addresses(Some(vec![address.clone()])).unwrap(); let request = r#"{"jsonrpc": "2.0", "method": "parity_accountsInfo", "params": [], "id": 1}"#; - let response = format!("{{\"jsonrpc\":\"2.0\",\"result\":{{\"0x{}\":{{\"name\":\"XX\"}}}},\"id\":1}}", address.hex()); + let response = format!("{{\"jsonrpc\":\"2.0\",\"result\":{{\"0x{:x}\":{{\"name\":\"XX\"}}}},\"id\":1}}", address); assert_eq!(io.handle_request_sync(request), Some(response)); } @@ -154,7 +154,7 @@ fn rpc_parity_default_account() { // Check empty let address = Address::default(); let request = r#"{"jsonrpc": "2.0", "method": "parity_defaultAccount", "params": [], "id": 1}"#; - let response = format!("{{\"jsonrpc\":\"2.0\",\"result\":\"0x{}\",\"id\":1}}", address.hex()); + let response = format!("{{\"jsonrpc\":\"2.0\",\"result\":\"0x{:x}\",\"id\":1}}", address); assert_eq!(io.handle_request_sync(request), Some(response)); // With account @@ -164,7 +164,7 @@ fn rpc_parity_default_account() { let address = accounts[0]; let request = r#"{"jsonrpc": "2.0", "method": "parity_defaultAccount", "params": [], "id": 1}"#; - let response = format!("{{\"jsonrpc\":\"2.0\",\"result\":\"0x{}\",\"id\":1}}", address.hex()); + let response = format!("{{\"jsonrpc\":\"2.0\",\"result\":\"0x{:x}\",\"id\":1}}", address); assert_eq!(io.handle_request_sync(request), Some(response)); } diff --git a/rpc/src/v1/tests/mocked/parity_accounts.rs b/rpc/src/v1/tests/mocked/parity_accounts.rs index 4aba68f1e..540bea903 100644 --- a/rpc/src/v1/tests/mocked/parity_accounts.rs +++ b/rpc/src/v1/tests/mocked/parity_accounts.rs @@ -75,7 +75,7 @@ fn should_be_able_to_get_account_info() { let request = r#"{"jsonrpc": "2.0", "method": "parity_allAccountsInfo", "params": [], "id": 1}"#; let res = tester.io.handle_request_sync(request); - let response = format!("{{\"jsonrpc\":\"2.0\",\"result\":{{\"0x{}\":{{\"meta\":\"{{foo: 69}}\",\"name\":\"Test\",\"uuid\":\"{}\"}}}},\"id\":1}}", address.hex(), uuid); + let response = format!("{{\"jsonrpc\":\"2.0\",\"result\":{{\"0x{:x}\":{{\"meta\":\"{{foo: 69}}\",\"name\":\"Test\",\"uuid\":\"{}\"}}}},\"id\":1}}", address, uuid); assert_eq!(res, Some(response)); } @@ -87,7 +87,7 @@ fn should_be_able_to_set_name() { assert_eq!(accounts.len(), 1); let address = accounts[0]; - let request = format!(r#"{{"jsonrpc": "2.0", "method": "parity_setAccountName", "params": ["0x{}", "Test"], "id": 1}}"#, address.hex()); + let request = format!(r#"{{"jsonrpc": "2.0", "method": "parity_setAccountName", "params": ["0x{:x}", "Test"], "id": 1}}"#, address); let response = r#"{"jsonrpc":"2.0","result":true,"id":1}"#; let res = tester.io.handle_request_sync(&request); assert_eq!(res, Some(response.into())); @@ -96,7 +96,7 @@ fn should_be_able_to_set_name() { let request = r#"{"jsonrpc": "2.0", "method": "parity_allAccountsInfo", "params": [], "id": 1}"#; let res = tester.io.handle_request_sync(request); - let response = format!("{{\"jsonrpc\":\"2.0\",\"result\":{{\"0x{}\":{{\"meta\":\"{{}}\",\"name\":\"Test\",\"uuid\":\"{}\"}}}},\"id\":1}}", address.hex(), uuid); + let response = format!("{{\"jsonrpc\":\"2.0\",\"result\":{{\"0x{:x}\":{{\"meta\":\"{{}}\",\"name\":\"Test\",\"uuid\":\"{}\"}}}},\"id\":1}}", address, uuid); assert_eq!(res, Some(response)); } @@ -108,7 +108,7 @@ fn should_be_able_to_set_meta() { assert_eq!(accounts.len(), 1); let address = accounts[0]; - let request = format!(r#"{{"jsonrpc": "2.0", "method": "parity_setAccountMeta", "params": ["0x{}", "{{foo: 69}}"], "id": 1}}"#, address.hex()); + let request = format!(r#"{{"jsonrpc": "2.0", "method": "parity_setAccountMeta", "params": ["0x{:x}", "{{foo: 69}}"], "id": 1}}"#, address); let response = r#"{"jsonrpc":"2.0","result":true,"id":1}"#; let res = tester.io.handle_request_sync(&request); assert_eq!(res, Some(response.into())); @@ -117,7 +117,7 @@ fn should_be_able_to_set_meta() { let request = r#"{"jsonrpc": "2.0", "method": "parity_allAccountsInfo", "params": [], "id": 1}"#; let res = tester.io.handle_request_sync(request); - let response = format!("{{\"jsonrpc\":\"2.0\",\"result\":{{\"0x{}\":{{\"meta\":\"{{foo: 69}}\",\"name\":\"\",\"uuid\":\"{}\"}}}},\"id\":1}}", address.hex(), uuid); + let response = format!("{{\"jsonrpc\":\"2.0\",\"result\":{{\"0x{:x}\":{{\"meta\":\"{{foo: 69}}\",\"name\":\"\",\"uuid\":\"{}\"}}}},\"id\":1}}", address, uuid); assert_eq!(res, Some(response)); } @@ -235,7 +235,7 @@ fn should_be_able_to_kill_account() { let res = tester.io.handle_request_sync(&request); assert_eq!(res, Some(response.into())); - let request = format!(r#"{{"jsonrpc": "2.0", "method": "parity_killAccount", "params": ["0x{}", "password"], "id": 1}}"#, address.hex()); + let request = format!(r#"{{"jsonrpc": "2.0", "method": "parity_killAccount", "params": ["0x{:x}", "password"], "id": 1}}"#, address); let response = r#"{"jsonrpc":"2.0","result":true,"id":1}"#; let res = tester.io.handle_request_sync(&request); assert_eq!(res, Some(response.into())); @@ -334,7 +334,7 @@ fn rpc_parity_change_vault() { let (address, _) = tester.accounts.new_account_and_public("root_password").unwrap(); assert!(tester.accounts.create_vault("vault1", "password1").is_ok()); - let request = format!(r#"{{"jsonrpc": "2.0", "method": "parity_changeVault", "params":["0x{}", "vault1"], "id": 1}}"#, address.hex()); + let request = format!(r#"{{"jsonrpc": "2.0", "method": "parity_changeVault", "params":["0x{:x}", "vault1"], "id": 1}}"#, address); let response = r#"{"jsonrpc":"2.0","result":true,"id":1}"#; assert_eq!(tester.io.handle_request_sync(&request), Some(response.to_owned())); @@ -351,7 +351,7 @@ fn rpc_parity_vault_adds_vault_field_to_acount_meta() { assert!(tester.accounts.change_vault(address1, "vault1").is_ok()); let request = r#"{"jsonrpc": "2.0", "method": "parity_allAccountsInfo", "params":[], "id": 1}"#; - let response = format!(r#"{{"jsonrpc":"2.0","result":{{"0x{}":{{"meta":"{{\"vault\":\"vault1\"}}","name":"","uuid":"{}"}}}},"id":1}}"#, address1.hex(), uuid1); + let response = format!(r#"{{"jsonrpc":"2.0","result":{{"0x{:x}":{{"meta":"{{\"vault\":\"vault1\"}}","name":"","uuid":"{}"}}}},"id":1}}"#, address1, uuid1); assert_eq!(tester.io.handle_request_sync(request), Some(response.to_owned())); @@ -359,7 +359,7 @@ fn rpc_parity_vault_adds_vault_field_to_acount_meta() { assert!(tester.accounts.change_vault(address1, "").is_ok()); let request = r#"{"jsonrpc": "2.0", "method": "parity_allAccountsInfo", "params":[], "id": 1}"#; - let response = format!(r#"{{"jsonrpc":"2.0","result":{{"0x{}":{{"meta":"{{}}","name":"","uuid":"{}"}}}},"id":1}}"#, address1.hex(), uuid1); + let response = format!(r#"{{"jsonrpc":"2.0","result":{{"0x{:x}":{{"meta":"{{}}","name":"","uuid":"{}"}}}},"id":1}}"#, address1, uuid1); assert_eq!(tester.io.handle_request_sync(request), Some(response.to_owned())); } diff --git a/rpc/src/v1/tests/mocked/signer.rs b/rpc/src/v1/tests/mocked/signer.rs index e7aa49d5a..da531a00f 100644 --- a/rpc/src/v1/tests/mocked/signer.rs +++ b/rpc/src/v1/tests/mocked/signer.rs @@ -466,12 +466,12 @@ fn should_confirm_sign_transaction_with_rlp() { r#""input":"0x","# + r#""nonce":"0x0","# + &format!("\"publicKey\":\"0x{:?}\",", t.public_key().unwrap()) + - &format!("\"r\":\"0x{}\",", U256::from(signature.r()).to_hex()) + + &format!("\"r\":\"0x{:x}\",", U256::from(signature.r())) + &format!("\"raw\":\"0x{}\",", rlp.to_hex()) + - &format!("\"s\":\"0x{}\",", U256::from(signature.s()).to_hex()) + - &format!("\"standardV\":\"0x{}\",", U256::from(t.standard_v()).to_hex()) + + &format!("\"s\":\"0x{:x}\",", U256::from(signature.s())) + + &format!("\"standardV\":\"0x{:x}\",", U256::from(t.standard_v())) + r#""to":"0xd46e8dd67c5d32be8058bb8eb970870f07244567","transactionIndex":null,"# + - &format!("\"v\":\"0x{}\",", U256::from(t.original_v()).to_hex()) + + &format!("\"v\":\"0x{:x}\",", U256::from(t.original_v())) + r#""value":"0x1""# + r#"}},"id":1}"#; diff --git a/rpc/src/v1/tests/mocked/signing.rs b/rpc/src/v1/tests/mocked/signing.rs index 10c2dd116..5bf5119ec 100644 --- a/rpc/src/v1/tests/mocked/signing.rs +++ b/rpc/src/v1/tests/mocked/signing.rs @@ -317,12 +317,12 @@ fn should_add_sign_transaction_to_the_queue() { r#""input":"0x","# + r#""nonce":"0x1","# + &format!("\"publicKey\":\"0x{:?}\",", t.public_key().unwrap()) + - &format!("\"r\":\"0x{}\",", U256::from(signature.r()).to_hex()) + + &format!("\"r\":\"0x{:x}\",", U256::from(signature.r())) + &format!("\"raw\":\"0x{}\",", rlp.to_hex()) + - &format!("\"s\":\"0x{}\",", U256::from(signature.s()).to_hex()) + - &format!("\"standardV\":\"0x{}\",", U256::from(t.standard_v()).to_hex()) + + &format!("\"s\":\"0x{:x}\",", U256::from(signature.s())) + + &format!("\"standardV\":\"0x{:x}\",", U256::from(t.standard_v())) + r#""to":"0xd46e8dd67c5d32be8058bb8eb970870f07244567","transactionIndex":null,"# + - &format!("\"v\":\"0x{}\",", U256::from(t.original_v()).to_hex()) + + &format!("\"v\":\"0x{:x}\",", U256::from(t.original_v())) + r#""value":"0x9184e72a""# + r#"}},"id":1}"#; diff --git a/rpc/src/v1/types/sync.rs b/rpc/src/v1/types/sync.rs index 813fe8cb3..ae421ed40 100644 --- a/rpc/src/v1/types/sync.rs +++ b/rpc/src/v1/types/sync.rs @@ -103,7 +103,7 @@ impl From for EthProtocolInfo { EthProtocolInfo { version: info.version, difficulty: info.difficulty.map(Into::into), - head: info.head.hex(), + head: format!("{:x}", info.head), } } } @@ -124,7 +124,7 @@ impl From for PipProtocolInfo { PipProtocolInfo { version: info.version, difficulty: info.difficulty.into(), - head: info.head.hex(), + head: format!("{:x}", info.head), } } } diff --git a/rpc/src/v1/types/uint.rs b/rpc/src/v1/types/uint.rs index 1333d22fd..e887322db 100644 --- a/rpc/src/v1/types/uint.rs +++ b/rpc/src/v1/types/uint.rs @@ -102,13 +102,13 @@ impl_uint!(U64, u64, 1); impl serde::Serialize for U128 { fn serialize(&self, serializer: S) -> Result where S: serde::Serializer { - serializer.serialize_str(&format!("0x{}", self.0.to_hex())) + serializer.serialize_str(&format!("0x{:x}", self.0)) } } impl serde::Serialize for U256 { fn serialize(&self, serializer: S) -> Result where S: serde::Serializer { - serializer.serialize_str(&format!("0x{}", self.0.to_hex())) + serializer.serialize_str(&format!("0x{:x}", self.0)) } } diff --git a/secret_store/Cargo.toml b/secret_store/Cargo.toml index 5e9a51db2..10b690b6d 100644 --- a/secret_store/Cargo.toml +++ b/secret_store/Cargo.toml @@ -24,7 +24,7 @@ tokio-proto = "0.1" url = "1.0" ethcore = { path = "../ethcore" } ethcore-bytes = { path = "../util/bytes" } -ethereum-types = "0.1" +ethereum-types = "0.2" ethsync = { path = "../sync" } kvdb = { path = "../util/kvdb" } kvdb-rocksdb = { path = "../util/kvdb-rocksdb" } @@ -32,8 +32,10 @@ keccak-hash = { path = "../util/hash" } ethcore-logger = { path = "../logger" } ethcrypto = { path = "../ethcrypto" } ethkey = { path = "../ethkey" } -native-contracts = { path = "../ethcore/native_contracts" } lazy_static = "1.0" +ethabi = "5.1" +ethabi-derive = "5.0" +ethabi-contract = "5.0" [dev-dependencies] tempdir = "0.3" diff --git a/ethcore/native_contracts/res/secretstore_acl_storage.json b/secret_store/res/acl_storage.json similarity index 100% rename from ethcore/native_contracts/res/secretstore_acl_storage.json rename to secret_store/res/acl_storage.json diff --git a/ethcore/native_contracts/res/key_server_set.json b/secret_store/res/key_server_set.json similarity index 100% rename from ethcore/native_contracts/res/key_server_set.json rename to secret_store/res/key_server_set.json diff --git a/ethcore/native_contracts/res/secretstore_service.json b/secret_store/res/service.json similarity index 100% rename from ethcore/native_contracts/res/secretstore_service.json rename to secret_store/res/service.json diff --git a/secret_store/src/acl_storage.rs b/secret_store/src/acl_storage.rs index 5f8a0d268..1d96148eb 100644 --- a/secret_store/src/acl_storage.rs +++ b/secret_store/src/acl_storage.rs @@ -16,16 +16,16 @@ use std::sync::Arc; use std::collections::{HashMap, HashSet}; -use futures::{future, Future}; use parking_lot::{Mutex, RwLock}; use ethkey::public_to_address; use ethcore::client::{BlockChainClient, BlockId, ChainNotify}; -use native_contracts::SecretStoreAclStorage; use ethereum_types::{H256, Address}; use bytes::Bytes; use trusted_client::TrustedClient; use types::all::{Error, ServerKeyId, Public}; +use_contract!(acl_storage, "AclStorage", "res/acl_storage.json"); + const ACL_CHECKER_CONTRACT_REGISTRY_NAME: &'static str = "secretstore_acl_checker"; /// ACL storage of Secret Store @@ -47,7 +47,7 @@ struct CachedContract { /// Contract address. contract_addr: Option
, /// Contract at given address. - contract: Option, + contract: acl_storage::AclStorage, } /// Dummy ACL storage implementation (check always passed). @@ -86,23 +86,20 @@ impl ChainNotify for OnChainAclStorage { impl CachedContract { pub fn new(client: TrustedClient) -> Self { CachedContract { - client: client, + client, contract_addr: None, - contract: None, + contract: acl_storage::AclStorage::default(), } } pub fn update(&mut self) { if let Some(client) = self.client.get() { - let new_contract_addr = client.registry_address(ACL_CHECKER_CONTRACT_REGISTRY_NAME.to_owned()); - if self.contract_addr.as_ref() != new_contract_addr.as_ref() { - self.contract = new_contract_addr.map(|contract_addr| { - trace!(target: "secretstore", "Configuring for ACL checker contract from {}", contract_addr); - - SecretStoreAclStorage::new(contract_addr) - }); - - self.contract_addr = new_contract_addr; + match client.registry_address(ACL_CHECKER_CONTRACT_REGISTRY_NAME.to_owned()) { + Some(new_contract_addr) if Some(new_contract_addr).as_ref() != self.contract_addr.as_ref() => { + trace!(target: "secretstore", "Configuring for ACL checker contract from {}", new_contract_addr); + self.contract_addr = Some(new_contract_addr); + }, + Some(_) | None => () } } } @@ -110,13 +107,14 @@ impl CachedContract { pub fn check(&mut self, public: &Public, document: &ServerKeyId) -> Result { if let Some(client) = self.client.get() { // call contract to check accesss - match self.contract.as_ref() { - Some(contract) => { + match self.contract_addr { + Some(contract_address) => { let address = public_to_address(&public); - let do_call = |a, d| future::done(client.call_contract(BlockId::Latest, a, d)); - contract.check_permissions(do_call, address, document.clone()) - .map_err(|err| Error::Internal(err)) - .wait() + let do_call = |data| client.call_contract(BlockId::Latest, contract_address, data); + self.contract.functions() + .check_permissions() + .call(address, document.clone(), &do_call) + .map_err(|e| Error::Internal(e.to_string())) }, None => Err(Error::Internal("ACL checker contract is not configured".to_owned())), } diff --git a/secret_store/src/key_server_set.rs b/secret_store/src/key_server_set.rs index 7b48909b1..62df81ce4 100644 --- a/secret_store/src/key_server_set.rs +++ b/secret_store/src/key_server_set.rs @@ -17,12 +17,10 @@ use std::sync::Arc; use std::net::SocketAddr; use std::collections::{BTreeMap, HashSet}; -use futures::{future, Future, IntoFuture}; use parking_lot::Mutex; use ethcore::filter::Filter; use ethcore::client::{Client, BlockChainClient, BlockId, ChainNotify}; use ethkey::public_to_address; -use native_contracts::KeyServerSet as KeyServerSetContract; use hash::keccak; use ethereum_types::{H256, Address}; use bytes::Bytes; @@ -30,7 +28,7 @@ use types::all::{Error, Public, NodeAddress, NodeId}; use trusted_client::TrustedClient; use {NodeKeyPair}; -type BoxFuture = Box + Send>; +use_contract!(key_server, "KeyServerSet", "res/key_server_set.json"); /// Name of KeyServerSet contract in registry. const KEY_SERVER_SET_CONTRACT_REGISTRY_NAME: &'static str = "secretstore_server_set"; @@ -118,7 +116,9 @@ struct CachedContract { /// Blockchain client. client: TrustedClient, /// Contract address. - contract: Option, + contract_address: Option
, + /// Contract interface. + contract: key_server::KeyServerSet, /// Is auto-migrate enabled? auto_migrate_enabled: bool, /// Current contract state. @@ -168,6 +168,77 @@ impl ChainNotify for OnChainKeyServerSet { } } +trait KeyServerSubset) -> Result, String>> { + fn read_list(&self, f: &F) -> Result, String>; + + fn read_public(&self, address: Address, f: &F) -> Result; + + fn read_address(&self, address: Address, f: &F) -> Result; +} + +#[derive(Default)] +struct CurrentKeyServerSubset { + read_list: key_server::functions::GetCurrentKeyServers, + read_public: key_server::functions::GetCurrentKeyServerPublic, + read_address: key_server::functions::GetCurrentKeyServerAddress, +} + +impl ) -> Result, String>> KeyServerSubset for CurrentKeyServerSubset { + fn read_list(&self, f: &F) -> Result, String> { + self.read_list.call(f).map_err(|e| e.to_string()) + } + + fn read_public(&self, address: Address, f: &F) -> Result { + self.read_public.call(address, f).map_err(|e| e.to_string()) + } + + fn read_address(&self, address: Address, f: &F) -> Result { + self.read_address.call(address, f).map_err(|e| e.to_string()) + } +} + +#[derive(Default)] +struct MigrationKeyServerSubset { + read_list: key_server::functions::GetMigrationKeyServers, + read_public: key_server::functions::GetMigrationKeyServerPublic, + read_address: key_server::functions::GetMigrationKeyServerAddress, +} + +impl ) -> Result, String>> KeyServerSubset for MigrationKeyServerSubset { + fn read_list(&self, f: &F) -> Result, String> { + self.read_list.call(f).map_err(|e| e.to_string()) + } + + fn read_public(&self, address: Address, f: &F) -> Result { + self.read_public.call(address, f).map_err(|e| e.to_string()) + } + + fn read_address(&self, address: Address, f: &F) -> Result { + self.read_address.call(address, f).map_err(|e| e.to_string()) + } +} + +#[derive(Default)] +struct NewKeyServerSubset { + read_list: key_server::functions::GetNewKeyServers, + read_public: key_server::functions::GetNewKeyServerPublic, + read_address: key_server::functions::GetNewKeyServerAddress, +} + +impl ) -> Result, String>> KeyServerSubset for NewKeyServerSubset { + fn read_list(&self, f: &F) -> Result, String> { + self.read_list.call(f).map_err(|e| e.to_string()) + } + + fn read_public(&self, address: Address, f: &F) -> Result { + self.read_public.call(address, f).map_err(|e| e.to_string()) + } + + fn read_address(&self, address: Address, f: &F) -> Result { + self.read_address.call(address, f).map_err(|e| e.to_string()) + } +} + impl CachedContract { pub fn new(client: TrustedClient, self_key_pair: Arc, auto_migrate_enabled: bool, key_servers: BTreeMap) -> Result { let server_set = key_servers.into_iter() @@ -179,7 +250,8 @@ impl CachedContract { .collect::, Error>>()?; Ok(CachedContract { client: client, - contract: None, + contract_address: None, + contract: key_server::KeyServerSet::default(), auto_migrate_enabled: auto_migrate_enabled, future_new_set: None, confirm_migration_tx: None, @@ -208,54 +280,40 @@ impl CachedContract { } fn start_migration(&mut self, migration_id: H256) { - // trust is not needed here, because it is the reaction to the read of the trusted client - if let (Some(client), Some(contract)) = (self.client.get_untrusted(), self.contract.as_ref()) { + // trust is not needed here, because it is the reaction to the read of the trusted client + if let (Some(client), Some(contract_address)) = (self.client.get_untrusted(), self.contract_address) { // check if we need to send start migration transaction if !update_last_transaction_block(&*client, &migration_id, &mut self.start_migration_tx) { return; } // prepare transaction data - let transaction_data = match contract.encode_start_migration_input(migration_id) { - Ok(transaction_data) => transaction_data, - Err(error) => { - warn!(target: "secretstore_net", "{}: failed to prepare auto-migration start transaction: {}", - self.self_key_pair.public(), error); - return; - }, - }; + let transaction_data = self.contract.functions().start_migration().input(migration_id); // send transaction - if let Err(error) = client.transact_contract(contract.address.clone(), transaction_data) { + if let Err(error) = client.transact_contract(contract_address, transaction_data) { warn!(target: "secretstore_net", "{}: failed to submit auto-migration start transaction: {}", self.self_key_pair.public(), error); } else { trace!(target: "secretstore_net", "{}: sent auto-migration start transaction", - self.self_key_pair.public(), ); + self.self_key_pair.public()); } } } fn confirm_migration(&mut self, migration_id: H256) { // trust is not needed here, because we have already completed the action - if let (Some(client), Some(contract)) = (self.client.get(), self.contract.as_ref()) { + if let (Some(client), Some(contract_address)) = (self.client.get(), self.contract_address) { // check if we need to send start migration transaction if !update_last_transaction_block(&*client, &migration_id, &mut self.confirm_migration_tx) { return; } // prepare transaction data - let transaction_data = match contract.encode_confirm_migration_input(migration_id) { - Ok(transaction_data) => transaction_data, - Err(error) => { - warn!(target: "secretstore_net", "{}: failed to prepare auto-migration confirmation transaction: {}", - self.self_key_pair.public(), error); - return; - }, - }; + let transaction_data = self.contract.functions().confirm_migration().input(migration_id); // send transaction - if let Err(error) = client.transact_contract(contract.address.clone(), transaction_data) { + if let Err(error) = client.transact_contract(contract_address, transaction_data) { warn!(target: "secretstore_net", "{}: failed to submit auto-migration confirmation transaction: {}", self.self_key_pair.public(), error); } else { @@ -270,18 +328,18 @@ impl CachedContract { let new_contract_addr = client.registry_address(KEY_SERVER_SET_CONTRACT_REGISTRY_NAME.to_owned()); // new contract installed => read nodes set from the contract - if self.contract.as_ref().map(|c| &c.address) != new_contract_addr.as_ref() { + if self.contract_address.as_ref() != new_contract_addr.as_ref() { self.read_from_registry(&*client, new_contract_addr); return; } // check for contract events - let is_set_changed = self.contract.is_some() && enacted.iter() + let is_set_changed = self.contract_address.is_some() && enacted.iter() .chain(retracted.iter()) .any(|block_hash| !client.logs(Filter { from_block: BlockId::Hash(block_hash.clone()), to_block: BlockId::Hash(block_hash.clone()), - address: self.contract.as_ref().map(|c| vec![c.address.clone()]), + address: self.contract_address.map(|address| vec![address]), topics: vec![ Some(vec![*ADDED_EVENT_NAME_HASH, *REMOVED_EVENT_NAME_HASH, *MIGRATION_STARTED_EVENT_NAME_HASH, *MIGRATION_COMPLETED_EVENT_NAME_HASH]), @@ -299,14 +357,13 @@ impl CachedContract { } fn read_from_registry(&mut self, client: &Client, new_contract_address: Option
) { - self.contract = new_contract_address.map(|contract_addr| { + if let Some(ref contract_addr) = new_contract_address { trace!(target: "secretstore", "Configuring for key server set contract from {}", contract_addr); + } + self.contract_address = new_contract_address; - KeyServerSetContract::new(contract_addr) - }); - - let contract = match self.contract.as_ref() { - Some(contract) => contract, + let contract_address = match self.contract_address { + Some(contract_address) => contract_address, None => { // no contract installed => empty snapshot // WARNING: after restart current_set will be reset to the set from configuration file @@ -318,28 +375,25 @@ impl CachedContract { }, }; - let do_call = |a, d| future::done(client.call_contract(BlockId::Latest, a, d)); + let do_call = |data| client.call_contract(BlockId::Latest, contract_address, data); - let current_set = Self::read_key_server_set(&contract, &do_call, &KeyServerSetContract::get_current_key_servers, - &KeyServerSetContract::get_current_key_server_public, &KeyServerSetContract::get_current_key_server_address); + let current_set = Self::read_key_server_set(CurrentKeyServerSubset::default(), &do_call); // read migration-related data if auto migration is enabled let (new_set, migration) = match self.auto_migrate_enabled { true => { - let new_set = Self::read_key_server_set(&contract, &do_call, &KeyServerSetContract::get_new_key_servers, - &KeyServerSetContract::get_new_key_server_public, &KeyServerSetContract::get_new_key_server_address); - let migration_set = Self::read_key_server_set(&contract, &do_call, &KeyServerSetContract::get_migration_key_servers, - &KeyServerSetContract::get_migration_key_server_public, &KeyServerSetContract::get_migration_key_server_address); + let new_set = Self::read_key_server_set(NewKeyServerSubset::default(), &do_call); + let migration_set = Self::read_key_server_set(MigrationKeyServerSubset::default(), &do_call); let migration_id = match migration_set.is_empty() { - false => contract.get_migration_id(&do_call).wait() + false => self.contract.functions().get_migration_id().call(&do_call) .map_err(|err| { trace!(target: "secretstore", "Error {} reading migration id from contract", err); err }) .ok(), true => None, }; let migration_master = match migration_set.is_empty() { - false => contract.get_migration_master(&do_call).wait() + false => self.contract.functions().get_migration_master().call(&do_call) .map_err(|err| { trace!(target: "secretstore", "Error {} reading migration master from contract", err); err }) .ok() .and_then(|address| current_set.keys().chain(migration_set.keys()) @@ -350,7 +404,7 @@ impl CachedContract { let is_migration_confirmed = match migration_set.is_empty() { false if current_set.contains_key(self.self_key_pair.public()) || migration_set.contains_key(self.self_key_pair.public()) => - contract.is_migration_confirmed(&do_call, self.self_key_pair.address()).wait() + self.contract.functions().is_migration_confirmed().call(self.self_key_pair.address(), &do_call) .map_err(|err| { trace!(target: "secretstore", "Error {} reading migration confirmation from contract", err); err }) .ok(), _ => None, @@ -387,23 +441,19 @@ impl CachedContract { self.snapshot = new_snapshot; } - fn read_key_server_set(contract: &KeyServerSetContract, do_call: F, read_list: FL, read_public: FP, read_address: FA) -> BTreeMap + fn read_key_server_set(subset: T, do_call: F) -> BTreeMap where - F: FnOnce(Address, Vec) -> U + Copy, - U: IntoFuture, Error=String>, - U::Future: Send + 'static, - FL: Fn(&KeyServerSetContract, F) -> BoxFuture, String>, - FP: Fn(&KeyServerSetContract, F, Address) -> BoxFuture, String>, - FA: Fn(&KeyServerSetContract, F, Address) -> BoxFuture { + T: KeyServerSubset, + F: Fn(Vec) -> Result, String> { let mut key_servers = BTreeMap::new(); let mut key_servers_addresses = HashSet::new(); - let key_servers_list = read_list(contract, do_call).wait() + let key_servers_list = subset.read_list(&do_call) .map_err(|err| { warn!(target: "secretstore_net", "error {} reading list of key servers from contract", err); err }) .unwrap_or_default(); for key_server in key_servers_list { - let key_server_public = read_public(contract, do_call, key_server).wait() + let key_server_public = subset.read_public(key_server, &do_call) .and_then(|p| if p.len() == 64 { Ok(Public::from_slice(&p)) } else { Err(format!("Invalid public length {}", p.len())) }); - let key_server_address: Result = read_address(contract, do_call, key_server).wait() + let key_server_address: Result = subset.read_address(key_server, &do_call) .and_then(|a| a.parse().map_err(|e| format!("Invalid ip address: {}", e))); // only add successfully parsed nodes diff --git a/secret_store/src/lib.rs b/secret_store/src/lib.rs index 4e253f812..9d89ba0c6 100644 --- a/secret_store/src/lib.rs +++ b/secret_store/src/lib.rs @@ -15,38 +15,42 @@ // along with Parity. If not, see . extern crate byteorder; -#[macro_use] -extern crate log; -#[macro_use] -extern crate futures; +extern crate ethabi; +extern crate ethcore; +extern crate ethcore_bytes as bytes; +extern crate ethcore_logger as logger; +extern crate ethcrypto; +extern crate ethereum_types; +extern crate ethkey; +extern crate ethsync; extern crate futures_cpupool; extern crate hyper; -#[macro_use] -extern crate lazy_static; +extern crate keccak_hash as hash; +extern crate kvdb; +extern crate kvdb_rocksdb; extern crate parking_lot; extern crate rustc_hex; extern crate serde; extern crate serde_json; -#[macro_use] -extern crate serde_derive; extern crate tiny_keccak; -extern crate tokio_io; extern crate tokio_core; -extern crate tokio_service; +extern crate tokio_io; extern crate tokio_proto; +extern crate tokio_service; extern crate url; -extern crate ethcore; -extern crate ethcore_bytes as bytes; -extern crate ethcore_logger as logger; -extern crate ethereum_types; -extern crate ethcrypto; -extern crate ethkey; -extern crate ethsync; -extern crate native_contracts; -extern crate keccak_hash as hash; -extern crate kvdb; -extern crate kvdb_rocksdb; +#[macro_use] +extern crate ethabi_derive; +#[macro_use] +extern crate ethabi_contract; +#[macro_use] +extern crate futures; +#[macro_use] +extern crate serde_derive; +#[macro_use] +extern crate lazy_static; +#[macro_use] +extern crate log; mod key_server_cluster; mod types; diff --git a/secret_store/src/listener/service_contract.rs b/secret_store/src/listener/service_contract.rs index f68dbe1ad..59746c700 100644 --- a/secret_store/src/listener/service_contract.rs +++ b/secret_store/src/listener/service_contract.rs @@ -15,18 +15,18 @@ // along with Parity. If not, see . use std::sync::Arc; -use futures::{future, Future}; use parking_lot::RwLock; use ethcore::filter::Filter; use ethcore::client::{Client, BlockChainClient, BlockId}; use ethkey::{Public, Signature, public_to_address}; -use native_contracts::SecretStoreService; use hash::keccak; -use ethereum_types::{H256, U256}; +use ethereum_types::{H256, U256, Address}; use listener::service_contract_listener::ServiceTask; use trusted_client::TrustedClient; use {ServerKeyId, NodeKeyPair, ContractAddress}; +use_contract!(service, "Service", "res/service.json"); + /// Name of the SecretStore contract in the registry. const SERVICE_CONTRACT_REGISTRY_NAME: &'static str = "secretstore_service"; @@ -61,13 +61,15 @@ pub struct OnChainServiceContract { /// Contract addresss. address: ContractAddress, /// Contract. - data: RwLock, + data: RwLock, } /// On-chain service contract data. -struct SecretStoreServiceData { +struct ServiceData { /// Contract. - pub contract: Arc, + pub contract: service::Service, + /// Contract address. + pub contract_address: Address, /// Last block we have read logs from. pub last_log_block: Option, } @@ -77,7 +79,9 @@ struct PendingRequestsIterator { /// Blockchain client. client: Arc, /// Contract. - contract: Arc, + contract: service::Service, + /// Contract address. + contract_address: Address, /// This node key pair. self_key_pair: Arc, /// Block, this iterator is created for. @@ -110,8 +114,9 @@ impl OnChainServiceContract { client: client, self_key_pair: self_key_pair, address: address, - data: RwLock::new(SecretStoreServiceData { - contract: Arc::new(SecretStoreService::new(contract_addr)), + data: RwLock::new(ServiceData { + contract: service::Service::default(), + contract_address: contract_addr, last_log_block: None, }), } @@ -126,15 +131,15 @@ impl ServiceContract for OnChainServiceContract { if let Some(client) = self.client.get() { // update contract address from registry let service_contract_addr = client.registry_address(SERVICE_CONTRACT_REGISTRY_NAME.to_owned()).unwrap_or_default(); - if self.data.read().contract.address != service_contract_addr { + if self.data.read().contract_address != service_contract_addr { trace!(target: "secretstore", "{}: installing service contract from address {}", self.self_key_pair.public(), service_contract_addr); - self.data.write().contract = Arc::new(SecretStoreService::new(service_contract_addr)); + self.data.write().contract_address = service_contract_addr; } } } - self.data.read().contract.address != Default::default() + self.data.read().contract_address != Default::default() && self.client.get().is_some() } @@ -151,7 +156,7 @@ impl ServiceContract for OnChainServiceContract { // prepare range of blocks to read logs from let (address, first_block, last_block) = { let mut data = self.data.write(); - let address = data.contract.address.clone(); + let address = data.contract_address; let confirmed_block = match get_confirmed_block_hash(&*client, REQUEST_CONFIRMATIONS_REQUIRED) { Some(confirmed_block) => confirmed_block, None => return Box::new(::std::iter::empty()), // no block with enough confirmations @@ -197,12 +202,13 @@ impl ServiceContract for OnChainServiceContract { // we only need requests that are here for more than REQUEST_CONFIRMATIONS_REQUIRED blocks // => we're reading from Latest - (REQUEST_CONFIRMATIONS_REQUIRED + 1) block let data = self.data.read(); - match data.contract.address == Default::default() { + match data.contract_address == Default::default() { true => Box::new(::std::iter::empty()), false => get_confirmed_block_hash(&*client, REQUEST_CONFIRMATIONS_REQUIRED + 1) .and_then(|b| { - let do_call = |a, d| future::done(client.call_contract(BlockId::Hash(b.clone()), a, d)); - data.contract.server_key_generation_requests_count(&do_call).wait() + let contract_address = data.contract_address; + let do_call = |data| client.call_contract(BlockId::Hash(b), contract_address, data); + data.contract.functions().server_key_generation_requests_count().call(&do_call) .map_err(|error| { warn!(target: "secretstore", "{}: call to server_key_generation_requests_count failed: {}", self.self_key_pair.public(), error); @@ -213,7 +219,8 @@ impl ServiceContract for OnChainServiceContract { }) .map(|(b, l)| Box::new(PendingRequestsIterator { client: client, - contract: data.contract.clone(), + contract: service::Service::default(), + contract_address: data.contract_address, self_key_pair: self.self_key_pair.clone(), block: b, index: 0.into(), @@ -226,7 +233,7 @@ impl ServiceContract for OnChainServiceContract { fn publish_server_key(&self, server_key_id: &ServerKeyId, server_key: &Public) -> Result<(), String> { // only publish if contract address is set && client is online let data = self.data.read(); - if data.contract.address == Default::default() { + if data.contract_address == Default::default() { // it is not an error, because key could be generated even without contract return Ok(()); } @@ -239,9 +246,13 @@ impl ServiceContract for OnChainServiceContract { // only publish key if contract waits for publication // failing is ok here - it could be that enough confirmations have been recevied // or key has been requested using HTTP API - let do_call = |a, d| future::done(client.call_contract(BlockId::Latest, a, d)); + let contract_address = data.contract_address; + let do_call = |data| client.call_contract(BlockId::Latest, contract_address, data); let self_address = public_to_address(self.self_key_pair.public()); - if data.contract.get_server_key_confirmation_status(&do_call, server_key_id.clone(), self_address).wait().unwrap_or(false) { + if data.contract.functions() + .get_server_key_confirmation_status() + .call(*server_key_id, self_address, &do_call) + .unwrap_or(false) { return Ok(()); } @@ -249,16 +260,18 @@ impl ServiceContract for OnChainServiceContract { let server_key_hash = keccak(server_key); let signed_server_key = self.self_key_pair.sign(&server_key_hash).map_err(|e| format!("{}", e))?; let signed_server_key: Signature = signed_server_key.into_electrum().into(); - let transaction_data = data.contract.encode_server_key_generated_input(server_key_id.clone(), - server_key.to_vec(), - signed_server_key.v(), - signed_server_key.r().into(), - signed_server_key.s().into() - )?; + let transaction_data = data.contract.functions() + .server_key_generated() + .input(*server_key_id, + server_key.to_vec(), + signed_server_key.v(), + signed_server_key.r(), + signed_server_key.s(), + ); // send transaction client.transact_contract( - data.contract.address.clone(), + data.contract_address, transaction_data ).map_err(|e| format!("{}", e))?; @@ -278,13 +291,14 @@ impl Iterator for PendingRequestsIterator { self.index = self.index + 1.into(); let self_address = public_to_address(self.self_key_pair.public()); - let do_call = |a, d| future::done(self.client.call_contract(BlockId::Hash(self.block.clone()), a, d)); - self.contract.get_server_key_id(&do_call, index).wait() + let contract_address = self.contract_address; + let do_call = |data| self.client.call_contract(BlockId::Hash(self.block.clone()), contract_address, data); + self.contract.functions().get_server_key_id().call(index, &do_call) .and_then(|server_key_id| - self.contract.get_server_key_threshold(&do_call, server_key_id.clone()).wait() + self.contract.functions().get_server_key_threshold().call(server_key_id, &do_call) .map(|threshold| (server_key_id, threshold))) .and_then(|(server_key_id, threshold)| - self.contract.get_server_key_confirmation_status(&do_call, server_key_id.clone(), self_address).wait() + self.contract.functions().get_server_key_confirmation_status().call(server_key_id, self_address, &do_call) .map(|is_confirmed| (server_key_id, threshold, is_confirmed))) .map(|(server_key_id, threshold, is_confirmed)| Some((is_confirmed, ServiceTask::GenerateServerKey(server_key_id, threshold.into())))) diff --git a/secret_store/src/listener/service_contract_listener.rs b/secret_store/src/listener/service_contract_listener.rs index ab9b0b4d3..5686c677c 100644 --- a/secret_store/src/listener/service_contract_listener.rs +++ b/secret_store/src/listener/service_contract_listener.rs @@ -376,7 +376,7 @@ fn is_processed_by_this_key_server(key_server_set: &KeyServerSet, self_key_pair: let server_key_id_value: U256 = server_key_id.into(); let range_interval = U256::max_value() / total_servers_count.into(); - let range_begin = (range_interval + 1.into()) * this_server_index.into(); + let range_begin = (range_interval + 1.into()) * this_server_index as u32; let range_end = range_begin.saturating_add(range_interval); server_key_id_value >= range_begin && server_key_id_value <= range_end diff --git a/stratum/Cargo.toml b/stratum/Cargo.toml index 6b10088af..8f2b05dc2 100644 --- a/stratum/Cargo.toml +++ b/stratum/Cargo.toml @@ -7,7 +7,7 @@ authors = ["Parity Technologies "] [dependencies] ethcore-logger = { path = "../logger" } -ethereum-types = "0.1" +ethereum-types = "0.2" keccak-hash = { path = "../util/hash" } jsonrpc-core = { git = "https://github.com/paritytech/jsonrpc.git", branch = "parity-1.10" } jsonrpc-macros = { git = "https://github.com/paritytech/jsonrpc.git", branch = "parity-1.10" } diff --git a/sync/Cargo.toml b/sync/Cargo.toml index 3f7185b43..4b8701c90 100644 --- a/sync/Cargo.toml +++ b/sync/Cargo.toml @@ -14,7 +14,7 @@ ethcore-io = { path = "../util/io" } ethcore-light = { path = "../ethcore/light" } ethcore-transaction = { path = "../ethcore/transaction" } ethcore = { path = "../ethcore" } -ethereum-types = "0.1" +ethereum-types = "0.2" plain_hasher = { path = "../util/plain_hasher" } rlp = { path = "../util/rlp" } keccak-hash = { path = "../util/hash" } @@ -24,7 +24,7 @@ macros = { path = "../util/macros" } log = "0.3" env_logger = "0.4" time = "0.1.34" -rand = "0.3.13" +rand = "0.4" heapsize = "0.4" semver = "0.6" smallvec = { version = "0.4", features = ["heapsizeof"] } diff --git a/sync/src/api.rs b/sync/src/api.rs index 56a65c755..d0f55d53c 100644 --- a/sync/src/api.rs +++ b/sync/src/api.rs @@ -293,7 +293,7 @@ impl SyncProvider for EthSync { }; Some(PeerInfo { - id: session_info.id.map(|id| id.hex()), + id: session_info.id.map(|id| format!("{:x}", id)), client_version: session_info.client_version, capabilities: session_info.peer_capabilities.into_iter().map(|c| c.to_string()).collect(), remote_address: session_info.remote_address, @@ -821,7 +821,7 @@ impl LightSyncProvider for LightSync { }; Some(PeerInfo { - id: session_info.id.map(|id| id.hex()), + id: session_info.id.map(|id| format!("{:x}", id)), client_version: session_info.client_version, capabilities: session_info.peer_capabilities.into_iter().map(|c| c.to_string()).collect(), remote_address: session_info.remote_address, diff --git a/sync/src/blocks.rs b/sync/src/blocks.rs index b9addf698..7ce426f59 100644 --- a/sync/src/blocks.rs +++ b/sync/src/blocks.rs @@ -453,7 +453,7 @@ impl BlockCollection { self.parents.insert(info.parent_hash().clone(), hash.clone()); self.blocks.insert(hash.clone(), block); - trace!(target: "sync", "New header: {}", hash.hex()); + trace!(target: "sync", "New header: {:x}", hash); Ok(hash) } diff --git a/sync/src/snapshot.rs b/sync/src/snapshot.rs index d54b6bd3e..917e84c88 100644 --- a/sync/src/snapshot.rs +++ b/sync/src/snapshot.rs @@ -73,7 +73,7 @@ impl Snapshot { pub fn validate_chunk(&mut self, chunk: &[u8]) -> Result { let hash = keccak(chunk); if self.completed_chunks.contains(&hash) { - trace!(target: "sync", "Ignored proccessed chunk: {}", hash.hex()); + trace!(target: "sync", "Ignored proccessed chunk: {:x}", hash); return Err(()); } self.downloading_chunks.remove(&hash); @@ -85,7 +85,7 @@ impl Snapshot { self.completed_chunks.insert(hash.clone()); return Ok(ChunkType::State(hash)); } - trace!(target: "sync", "Ignored unknown chunk: {}", hash.hex()); + trace!(target: "sync", "Ignored unknown chunk: {:x}", hash); Err(()) } diff --git a/transaction-pool/Cargo.toml b/transaction-pool/Cargo.toml index 70aba5d04..6652001f5 100644 --- a/transaction-pool/Cargo.toml +++ b/transaction-pool/Cargo.toml @@ -9,4 +9,4 @@ authors = ["Parity Technologies "] error-chain = "0.11" log = "0.3" smallvec = "0.4" -ethereum-types = { version = "0.1", features = ["heapsizeof"] } +ethereum-types = "0.2" diff --git a/transaction-pool/src/tests/tx_builder.rs b/transaction-pool/src/tests/tx_builder.rs index cd50a4fd0..e9c1c1d5f 100644 --- a/transaction-pool/src/tests/tx_builder.rs +++ b/transaction-pool/src/tests/tx_builder.rs @@ -60,7 +60,7 @@ impl TransactionBuilder { self.insertion_id.set(id); id }; - let hash = self.nonce ^ (U256::from(100) * self.gas_price) ^ (U256::from(100_000) * self.sender.low_u64().into()); + let hash = self.nonce ^ (U256::from(100) * self.gas_price) ^ (U256::from(100_000) * U256::from(self.sender.low_u64())); Transaction { hash: hash.into(), nonce: self.nonce, diff --git a/updater/Cargo.toml b/updater/Cargo.toml index 740a0d8b2..a821ef672 100644 --- a/updater/Cargo.toml +++ b/updater/Cargo.toml @@ -7,16 +7,16 @@ authors = ["Parity Technologies "] [dependencies] log = "0.3" -ethabi = "4.0" +ethabi = "5.1" +ethabi-derive = "5.0" +ethabi-contract = "5.0" target_info = "0.1" semver = "0.6" ethcore = { path = "../ethcore" } ethsync = { path = "../sync" } ethcore-bytes = { path = "../util/bytes" } -ethereum-types = "0.1" -futures = "0.1" +ethereum-types = "0.2" parking_lot = "0.5" parity-hash-fetch = { path = "../hash-fetch" } -parity-reactor = { path = "../util/reactor" } parity-version = { path = "../util/version" } path = { path = "../util/path" } diff --git a/updater/res/operations.json b/updater/res/operations.json new file mode 100644 index 000000000..2a14e0f0a --- /dev/null +++ b/updater/res/operations.json @@ -0,0 +1,560 @@ +[ + { + "constant": false, + "inputs": [ + { + "name": "_client", + "type": "bytes32" + }, + { + "name": "_newOwner", + "type": "address" + } + ], + "name": "resetClientOwner", + "outputs": [], + "payable": false, + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "name": "_client", + "type": "bytes32" + }, + { + "name": "_release", + "type": "bytes32" + } + ], + "name": "isLatest", + "outputs": [ + { + "name": "", + "type": "bool" + } + ], + "payable": false, + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "_txid", + "type": "bytes32" + } + ], + "name": "rejectTransaction", + "outputs": [], + "payable": false, + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "_newOwner", + "type": "address" + } + ], + "name": "setOwner", + "outputs": [], + "payable": false, + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "_number", + "type": "uint32" + }, + { + "name": "_name", + "type": "bytes32" + }, + { + "name": "_hard", + "type": "bool" + }, + { + "name": "_spec", + "type": "bytes32" + } + ], + "name": "proposeFork", + "outputs": [], + "payable": false, + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "_client", + "type": "bytes32" + } + ], + "name": "removeClient", + "outputs": [], + "payable": false, + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "name": "_client", + "type": "bytes32" + }, + { + "name": "_release", + "type": "bytes32" + } + ], + "name": "release", + "outputs": [ + { + "name": "o_forkBlock", + "type": "uint32" + }, + { + "name": "o_track", + "type": "uint8" + }, + { + "name": "o_semver", + "type": "uint24" + }, + { + "name": "o_critical", + "type": "bool" + } + ], + "payable": false, + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "name": "_client", + "type": "bytes32" + }, + { + "name": "_checksum", + "type": "bytes32" + } + ], + "name": "build", + "outputs": [ + { + "name": "o_release", + "type": "bytes32" + }, + { + "name": "o_platform", + "type": "bytes32" + } + ], + "payable": false, + "type": "function" + }, + { + "constant": false, + "inputs": [], + "name": "rejectFork", + "outputs": [], + "payable": false, + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "name": "", + "type": "bytes32" + } + ], + "name": "client", + "outputs": [ + { + "name": "owner", + "type": "address" + }, + { + "name": "required", + "type": "bool" + } + ], + "payable": false, + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "_newOwner", + "type": "address" + } + ], + "name": "setClientOwner", + "outputs": [], + "payable": false, + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "name": "", + "type": "uint32" + } + ], + "name": "fork", + "outputs": [ + { + "name": "name", + "type": "bytes32" + }, + { + "name": "spec", + "type": "bytes32" + }, + { + "name": "hard", + "type": "bool" + }, + { + "name": "ratified", + "type": "bool" + }, + { + "name": "requiredCount", + "type": "uint256" + } + ], + "payable": false, + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "_release", + "type": "bytes32" + }, + { + "name": "_platform", + "type": "bytes32" + }, + { + "name": "_checksum", + "type": "bytes32" + } + ], + "name": "addChecksum", + "outputs": [], + "payable": false, + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "_txid", + "type": "bytes32" + } + ], + "name": "confirmTransaction", + "outputs": [ + { + "name": "txSuccess", + "type": "uint256" + } + ], + "payable": false, + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "name": "", + "type": "bytes32" + } + ], + "name": "proxy", + "outputs": [ + { + "name": "requiredCount", + "type": "uint256" + }, + { + "name": "to", + "type": "address" + }, + { + "name": "data", + "type": "bytes" + }, + { + "name": "value", + "type": "uint256" + }, + { + "name": "gas", + "type": "uint256" + } + ], + "payable": false, + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "_client", + "type": "bytes32" + }, + { + "name": "_owner", + "type": "address" + } + ], + "name": "addClient", + "outputs": [], + "payable": false, + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "name": "", + "type": "address" + } + ], + "name": "clientOwner", + "outputs": [ + { + "name": "", + "type": "bytes32" + } + ], + "payable": false, + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "_txid", + "type": "bytes32" + }, + { + "name": "_to", + "type": "address" + }, + { + "name": "_data", + "type": "bytes" + }, + { + "name": "_value", + "type": "uint256" + }, + { + "name": "_gas", + "type": "uint256" + } + ], + "name": "proposeTransaction", + "outputs": [ + { + "name": "txSuccess", + "type": "uint256" + } + ], + "payable": false, + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "grandOwner", + "outputs": [ + { + "name": "", + "type": "address" + } + ], + "payable": false, + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "_release", + "type": "bytes32" + }, + { + "name": "_forkBlock", + "type": "uint32" + }, + { + "name": "_track", + "type": "uint8" + }, + { + "name": "_semver", + "type": "uint24" + }, + { + "name": "_critical", + "type": "bool" + } + ], + "name": "addRelease", + "outputs": [], + "payable": false, + "type": "function" + }, + { + "constant": false, + "inputs": [], + "name": "acceptFork", + "outputs": [], + "payable": false, + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "clientsRequired", + "outputs": [ + { + "name": "", + "type": "uint32" + } + ], + "payable": false, + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "name": "_client", + "type": "bytes32" + }, + { + "name": "_release", + "type": "bytes32" + } + ], + "name": "track", + "outputs": [ + { + "name": "", + "type": "uint8" + } + ], + "payable": false, + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "_client", + "type": "bytes32" + }, + { + "name": "_r", + "type": "bool" + } + ], + "name": "setClientRequired", + "outputs": [], + "payable": false, + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "latestFork", + "outputs": [ + { + "name": "", + "type": "uint32" + } + ], + "payable": false, + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "name": "_client", + "type": "bytes32" + }, + { + "name": "_track", + "type": "uint8" + } + ], + "name": "latestInTrack", + "outputs": [ + { + "name": "", + "type": "bytes32" + } + ], + "payable": false, + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "name": "_client", + "type": "bytes32" + }, + { + "name": "_release", + "type": "bytes32" + }, + { + "name": "_platform", + "type": "bytes32" + } + ], + "name": "checksum", + "outputs": [ + { + "name": "", + "type": "bytes32" + } + ], + "payable": false, + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "proposedFork", + "outputs": [ + { + "name": "", + "type": "uint32" + } + ], + "payable": false, + "type": "function" + } +] diff --git a/updater/src/lib.rs b/updater/src/lib.rs index 84dfc49f0..c1e19cf1d 100644 --- a/updater/src/lib.rs +++ b/updater/src/lib.rs @@ -16,27 +16,29 @@ //! Updater for Parity executables -#[macro_use] extern crate log; +extern crate ethabi; +extern crate ethcore; extern crate ethcore_bytes as bytes; extern crate ethereum_types; -extern crate parking_lot; -extern crate parity_hash_fetch as hash_fetch; -extern crate ethcore; -extern crate ethabi; extern crate ethsync; -extern crate futures; -extern crate target_info; -extern crate parity_reactor; +extern crate parity_hash_fetch as hash_fetch; extern crate parity_version as version; +extern crate parking_lot; extern crate path; extern crate semver; +extern crate target_info; + +#[macro_use] +extern crate ethabi_contract; +#[macro_use] +extern crate ethabi_derive; +#[macro_use] +extern crate log; mod updater; -mod operations; mod types; - mod service; -pub use service::{Service}; +pub use service::Service; pub use types::{ReleaseInfo, OperationsInfo, CapState, VersionInfo, ReleaseTrack}; pub use updater::{Updater, UpdateFilter, UpdatePolicy}; diff --git a/updater/src/operations.rs b/updater/src/operations.rs deleted file mode 100644 index fcea1e102..000000000 --- a/updater/src/operations.rs +++ /dev/null @@ -1,355 +0,0 @@ -// Autogenerated from JSON contract definition using Rust contract convertor. - -use std::string::String; -use std::result::Result; -use std::fmt; -use ethabi; -use ethereum_types; - -pub struct Operations { - contract: ethabi::Contract, - address: ethereum_types::Address, - do_call: Box) -> Result, String> + Send + Sync + 'static>, -} -impl Operations { - pub fn new(address: ethereum_types::Address, do_call: F) -> Self where F: Fn(ethereum_types::Address, Vec) -> Result, String> + Send + Sync + 'static { - Operations { - contract: ethabi::Contract::load(b"[{\"constant\":false,\"inputs\":[{\"name\":\"_client\",\"type\":\"bytes32\"},{\"name\":\"_newOwner\",\"type\":\"address\"}],\"name\":\"resetClientOwner\",\"outputs\":[],\"payable\":false,\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_client\",\"type\":\"bytes32\"},{\"name\":\"_release\",\"type\":\"bytes32\"}],\"name\":\"isLatest\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_txid\",\"type\":\"bytes32\"}],\"name\":\"rejectTransaction\",\"outputs\":[],\"payable\":false,\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_newOwner\",\"type\":\"address\"}],\"name\":\"setOwner\",\"outputs\":[],\"payable\":false,\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_number\",\"type\":\"uint32\"},{\"name\":\"_name\",\"type\":\"bytes32\"},{\"name\":\"_hard\",\"type\":\"bool\"},{\"name\":\"_spec\",\"type\":\"bytes32\"}],\"name\":\"proposeFork\",\"outputs\":[],\"payable\":false,\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_client\",\"type\":\"bytes32\"}],\"name\":\"removeClient\",\"outputs\":[],\"payable\":false,\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_client\",\"type\":\"bytes32\"},{\"name\":\"_release\",\"type\":\"bytes32\"}],\"name\":\"release\",\"outputs\":[{\"name\":\"o_forkBlock\",\"type\":\"uint32\"},{\"name\":\"o_track\",\"type\":\"uint8\"},{\"name\":\"o_semver\",\"type\":\"uint24\"},{\"name\":\"o_critical\",\"type\":\"bool\"}],\"payable\":false,\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_client\",\"type\":\"bytes32\"},{\"name\":\"_checksum\",\"type\":\"bytes32\"}],\"name\":\"build\",\"outputs\":[{\"name\":\"o_release\",\"type\":\"bytes32\"},{\"name\":\"o_platform\",\"type\":\"bytes32\"}],\"payable\":false,\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"rejectFork\",\"outputs\":[],\"payable\":false,\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"bytes32\"}],\"name\":\"client\",\"outputs\":[{\"name\":\"owner\",\"type\":\"address\"},{\"name\":\"required\",\"type\":\"bool\"}],\"payable\":false,\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_newOwner\",\"type\":\"address\"}],\"name\":\"setClientOwner\",\"outputs\":[],\"payable\":false,\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"uint32\"}],\"name\":\"fork\",\"outputs\":[{\"name\":\"name\",\"type\":\"bytes32\"},{\"name\":\"spec\",\"type\":\"bytes32\"},{\"name\":\"hard\",\"type\":\"bool\"},{\"name\":\"ratified\",\"type\":\"bool\"},{\"name\":\"requiredCount\",\"type\":\"uint256\"}],\"payable\":false,\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_release\",\"type\":\"bytes32\"},{\"name\":\"_platform\",\"type\":\"bytes32\"},{\"name\":\"_checksum\",\"type\":\"bytes32\"}],\"name\":\"addChecksum\",\"outputs\":[],\"payable\":false,\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_txid\",\"type\":\"bytes32\"}],\"name\":\"confirmTransaction\",\"outputs\":[{\"name\":\"txSuccess\",\"type\":\"uint256\"}],\"payable\":false,\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"bytes32\"}],\"name\":\"proxy\",\"outputs\":[{\"name\":\"requiredCount\",\"type\":\"uint256\"},{\"name\":\"to\",\"type\":\"address\"},{\"name\":\"data\",\"type\":\"bytes\"},{\"name\":\"value\",\"type\":\"uint256\"},{\"name\":\"gas\",\"type\":\"uint256\"}],\"payable\":false,\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_client\",\"type\":\"bytes32\"},{\"name\":\"_owner\",\"type\":\"address\"}],\"name\":\"addClient\",\"outputs\":[],\"payable\":false,\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"address\"}],\"name\":\"clientOwner\",\"outputs\":[{\"name\":\"\",\"type\":\"bytes32\"}],\"payable\":false,\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_txid\",\"type\":\"bytes32\"},{\"name\":\"_to\",\"type\":\"address\"},{\"name\":\"_data\",\"type\":\"bytes\"},{\"name\":\"_value\",\"type\":\"uint256\"},{\"name\":\"_gas\",\"type\":\"uint256\"}],\"name\":\"proposeTransaction\",\"outputs\":[{\"name\":\"txSuccess\",\"type\":\"uint256\"}],\"payable\":false,\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"grandOwner\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_release\",\"type\":\"bytes32\"},{\"name\":\"_forkBlock\",\"type\":\"uint32\"},{\"name\":\"_track\",\"type\":\"uint8\"},{\"name\":\"_semver\",\"type\":\"uint24\"},{\"name\":\"_critical\",\"type\":\"bool\"}],\"name\":\"addRelease\",\"outputs\":[],\"payable\":false,\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"acceptFork\",\"outputs\":[],\"payable\":false,\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"clientsRequired\",\"outputs\":[{\"name\":\"\",\"type\":\"uint32\"}],\"payable\":false,\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_client\",\"type\":\"bytes32\"},{\"name\":\"_release\",\"type\":\"bytes32\"}],\"name\":\"track\",\"outputs\":[{\"name\":\"\",\"type\":\"uint8\"}],\"payable\":false,\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_client\",\"type\":\"bytes32\"},{\"name\":\"_r\",\"type\":\"bool\"}],\"name\":\"setClientRequired\",\"outputs\":[],\"payable\":false,\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"latestFork\",\"outputs\":[{\"name\":\"\",\"type\":\"uint32\"}],\"payable\":false,\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_client\",\"type\":\"bytes32\"},{\"name\":\"_track\",\"type\":\"uint8\"}],\"name\":\"latestInTrack\",\"outputs\":[{\"name\":\"\",\"type\":\"bytes32\"}],\"payable\":false,\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_client\",\"type\":\"bytes32\"},{\"name\":\"_release\",\"type\":\"bytes32\"},{\"name\":\"_platform\",\"type\":\"bytes32\"}],\"name\":\"checksum\",\"outputs\":[{\"name\":\"\",\"type\":\"bytes32\"}],\"payable\":false,\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"proposedFork\",\"outputs\":[{\"name\":\"\",\"type\":\"uint32\"}],\"payable\":false,\"type\":\"function\"}]" as &[u8]).expect("JSON is autogenerated; qed"), - address: address, - do_call: Box::new(do_call), - } - } - fn as_string(e: T) -> String { format!("{:?}", e) } - - /// Auto-generated from: `{"constant":false,"inputs":[{"name":"_client","type":"bytes32"},{"name":"_newOwner","type":"address"}],"name":"resetClientOwner","outputs":[],"payable":false,"type":"function"}` - #[allow(dead_code)] - pub fn reset_client_owner(&self, _client: &str, _new_owner: ðereum_types::Address) -> Result<(), String> { - let call = self.contract.function("resetClientOwner".into()).map_err(Self::as_string)?; - let data = call.encode_input(& - vec![ethabi::Token::FixedBytes(_client.as_bytes().to_owned()), ethabi::Token::Address(_new_owner.clone().0)] - ).map_err(Self::as_string)?; - call.decode_output(&(self.do_call)(self.address.clone(), data)?).map_err(Self::as_string)?; - - Ok(()) - } - - /// Auto-generated from: `{"constant":true,"inputs":[{"name":"_client","type":"bytes32"},{"name":"_release","type":"bytes32"}],"name":"isLatest","outputs":[{"name":"","type":"bool"}],"payable":false,"type":"function"}` - #[allow(dead_code)] - pub fn is_latest(&self, _client: &str, _release: ðereum_types::H256) -> Result { - let call = self.contract.function("isLatest".into()).map_err(Self::as_string)?; - let data = call.encode_input(& - vec![ethabi::Token::FixedBytes(_client.as_bytes().to_owned()), ethabi::Token::FixedBytes(_release.as_ref().to_owned())] - ).map_err(Self::as_string)?; - let output = call.decode_output(&(self.do_call)(self.address.clone(), data)?).map_err(Self::as_string)?; - let mut result = output.into_iter().rev().collect::>(); - Ok({ let r = result.pop().ok_or("Invalid return arity")?; let r = r.to_bool().ok_or("Invalid type returned")?; r }) - } - - /// Auto-generated from: `{"constant":false,"inputs":[{"name":"_txid","type":"bytes32"}],"name":"rejectTransaction","outputs":[],"payable":false,"type":"function"}` - #[allow(dead_code)] - pub fn reject_transaction(&self, _txid: ðereum_types::H256) -> Result<(), String> { - let call = self.contract.function("rejectTransaction".into()).map_err(Self::as_string)?; - let data = call.encode_input(& - vec![ethabi::Token::FixedBytes(_txid.as_ref().to_owned())] - ).map_err(Self::as_string)?; - call.decode_output(&(self.do_call)(self.address.clone(), data)?).map_err(Self::as_string)?; - - Ok(()) - } - - /// Auto-generated from: `{"constant":false,"inputs":[{"name":"_newOwner","type":"address"}],"name":"setOwner","outputs":[],"payable":false,"type":"function"}` - #[allow(dead_code)] - pub fn set_owner(&self, _new_owner: ðereum_types::Address) -> Result<(), String> { - let call = self.contract.function("setOwner".into()).map_err(Self::as_string)?; - let data = call.encode_input(& - vec![ethabi::Token::Address(_new_owner.clone().0)] - ).map_err(Self::as_string)?; - call.decode_output(&(self.do_call)(self.address.clone(), data)?).map_err(Self::as_string)?; - - Ok(()) - } - - /// Auto-generated from: `{"constant":false,"inputs":[{"name":"_number","type":"uint32"},{"name":"_name","type":"bytes32"},{"name":"_hard","type":"bool"},{"name":"_spec","type":"bytes32"}],"name":"proposeFork","outputs":[],"payable":false,"type":"function"}` - #[allow(dead_code)] - pub fn propose_fork(&self, _number: u32, _name: ðereum_types::H256, _hard: bool, _spec: ðereum_types::H256) -> Result<(), String> { - let call = self.contract.function("proposeFork".into()).map_err(Self::as_string)?; - let data = call.encode_input(& - vec![ethabi::Token::Uint({ let mut r = [0u8; 32]; ethereum_types::U256::from(_number as u64).to_big_endian(&mut r); r }), ethabi::Token::FixedBytes(_name.as_ref().to_owned()), ethabi::Token::Bool(_hard), ethabi::Token::FixedBytes(_spec.as_ref().to_owned())] - ).map_err(Self::as_string)?; - call.decode_output(&(self.do_call)(self.address.clone(), data)?).map_err(Self::as_string)?; - - Ok(()) - } - - /// Auto-generated from: `{"constant":false,"inputs":[{"name":"_client","type":"bytes32"}],"name":"removeClient","outputs":[],"payable":false,"type":"function"}` - #[allow(dead_code)] - pub fn remove_client(&self, _client: &str) -> Result<(), String> { - let call = self.contract.function("removeClient".into()).map_err(Self::as_string)?; - let data = call.encode_input(& - vec![ethabi::Token::FixedBytes(_client.as_bytes().to_owned())] - ).map_err(Self::as_string)?; - call.decode_output(&(self.do_call)(self.address.clone(), data)?).map_err(Self::as_string)?; - - Ok(()) - } - - /// Auto-generated from: `{"constant":true,"inputs":[{"name":"_client","type":"bytes32"},{"name":"_release","type":"bytes32"}],"name":"release","outputs":[{"name":"o_forkBlock","type":"uint32"},{"name":"o_track","type":"uint8"},{"name":"o_semver","type":"uint24"},{"name":"o_critical","type":"bool"}],"payable":false,"type":"function"}` - #[allow(dead_code)] - pub fn release(&self, _client: &str, _release: ðereum_types::H256) -> Result<(u32, u8, u32, bool), String> { - let call = self.contract.function("release".into()).map_err(Self::as_string)?; - let data = call.encode_input(& - vec![ethabi::Token::FixedBytes(_client.as_bytes().to_owned()), ethabi::Token::FixedBytes(_release.as_ref().to_owned())] - ).map_err(Self::as_string)?; - let output = call.decode_output(&(self.do_call)(self.address.clone(), data)?).map_err(Self::as_string)?; - let mut result = output.into_iter().rev().collect::>(); - Ok(({ let r = result.pop().ok_or("Invalid return arity")?; let r = r.to_uint().ok_or("Invalid type returned")?; ethereum_types::U256::from(r.as_ref()).as_u64() as u32 }, { let r = result.pop().ok_or("Invalid return arity")?; let r = r.to_uint().ok_or("Invalid type returned")?; ethereum_types::U256::from(r.as_ref()).as_u64() as u8 }, { let r = result.pop().ok_or("Invalid return arity")?; let r = r.to_uint().ok_or("Invalid type returned")?; ethereum_types::U256::from(r.as_ref()).as_u64() as u32 }, { let r = result.pop().ok_or("Invalid return arity")?; let r = r.to_bool().ok_or("Invalid type returned")?; r })) - } - - /// Auto-generated from: `{"constant":true,"inputs":[{"name":"_client","type":"bytes32"},{"name":"_checksum","type":"bytes32"}],"name":"build","outputs":[{"name":"o_release","type":"bytes32"},{"name":"o_platform","type":"bytes32"}],"payable":false,"type":"function"}` - #[allow(dead_code)] - pub fn build(&self, _client: &str, _checksum: ðereum_types::H256) -> Result<(ethereum_types::H256, ethereum_types::H256), String> { - let call = self.contract.function("build".into()).map_err(Self::as_string)?; - let data = call.encode_input(& - vec![ethabi::Token::FixedBytes(_client.as_bytes().to_owned()), ethabi::Token::FixedBytes(_checksum.as_ref().to_owned())] - ).map_err(Self::as_string)?; - let output = call.decode_output(&(self.do_call)(self.address.clone(), data)?).map_err(Self::as_string)?; - let mut result = output.into_iter().rev().collect::>(); - Ok(({ let r = result.pop().ok_or("Invalid return arity")?; let r = r.to_fixed_bytes().ok_or("Invalid type returned")?; ethereum_types::H256::from_slice(r.as_ref()) }, { let r = result.pop().ok_or("Invalid return arity")?; let r = r.to_fixed_bytes().ok_or("Invalid type returned")?; ethereum_types::H256::from_slice(r.as_ref()) })) - } - - /// Auto-generated from: `{"constant":false,"inputs":[],"name":"rejectFork","outputs":[],"payable":false,"type":"function"}` - #[allow(dead_code)] - pub fn reject_fork(&self) -> Result<(), String> { - let call = self.contract.function("rejectFork".into()).map_err(Self::as_string)?; - let data = call.encode_input(& - vec![] - ).map_err(Self::as_string)?; - call.decode_output(&(self.do_call)(self.address.clone(), data)?).map_err(Self::as_string)?; - - Ok(()) - } - - /// Auto-generated from: `{"constant":true,"inputs":[{"name":"","type":"bytes32"}],"name":"client","outputs":[{"name":"owner","type":"address"},{"name":"required","type":"bool"}],"payable":false,"type":"function"}` - #[allow(dead_code)] - pub fn client(&self, _1: ðereum_types::H256) -> Result<(ethereum_types::Address, bool), String> { - let call = self.contract.function("client".into()).map_err(Self::as_string)?; - let data = call.encode_input(& - vec![ethabi::Token::FixedBytes(_1.as_ref().to_owned())] - ).map_err(Self::as_string)?; - let output = call.decode_output(&(self.do_call)(self.address.clone(), data)?).map_err(Self::as_string)?; - let mut result = output.into_iter().rev().collect::>(); - Ok(({ let r = result.pop().ok_or("Invalid return arity")?; let r = r.to_address().ok_or("Invalid type returned")?; ethereum_types::Address::from(r) }, { let r = result.pop().ok_or("Invalid return arity")?; let r = r.to_bool().ok_or("Invalid type returned")?; r })) - } - - /// Auto-generated from: `{"constant":false,"inputs":[{"name":"_newOwner","type":"address"}],"name":"setClientOwner","outputs":[],"payable":false,"type":"function"}` - #[allow(dead_code)] - pub fn set_client_owner(&self, _new_owner: ðereum_types::Address) -> Result<(), String> { - let call = self.contract.function("setClientOwner".into()).map_err(Self::as_string)?; - let data = call.encode_input(& - vec![ethabi::Token::Address(_new_owner.clone().0)] - ).map_err(Self::as_string)?; - call.decode_output(&(self.do_call)(self.address.clone(), data)?).map_err(Self::as_string)?; - - Ok(()) - } - - /// Auto-generated from: `{"constant":true,"inputs":[{"name":"","type":"uint32"}],"name":"fork","outputs":[{"name":"name","type":"bytes32"},{"name":"spec","type":"bytes32"},{"name":"hard","type":"bool"},{"name":"ratified","type":"bool"},{"name":"requiredCount","type":"uint256"}],"payable":false,"type":"function"}` - #[allow(dead_code)] - pub fn fork(&self, _1: u32) -> Result<(ethereum_types::H256, ethereum_types::H256, bool, bool, ethereum_types::U256), String> { - let call = self.contract.function("fork".into()).map_err(Self::as_string)?; - let data = call.encode_input(& - vec![ethabi::Token::Uint({ let mut r = [0u8; 32]; ethereum_types::U256::from(_1 as u64).to_big_endian(&mut r); r })] - ).map_err(Self::as_string)?; - let output = call.decode_output(&(self.do_call)(self.address.clone(), data)?).map_err(Self::as_string)?; - let mut result = output.into_iter().rev().collect::>(); - Ok(({ let r = result.pop().ok_or("Invalid return arity")?; let r = r.to_fixed_bytes().ok_or("Invalid type returned")?; ethereum_types::H256::from_slice(r.as_ref()) }, { let r = result.pop().ok_or("Invalid return arity")?; let r = r.to_fixed_bytes().ok_or("Invalid type returned")?; ethereum_types::H256::from_slice(r.as_ref()) }, { let r = result.pop().ok_or("Invalid return arity")?; let r = r.to_bool().ok_or("Invalid type returned")?; r }, { let r = result.pop().ok_or("Invalid return arity")?; let r = r.to_bool().ok_or("Invalid type returned")?; r }, { let r = result.pop().ok_or("Invalid return arity")?; let r = r.to_uint().ok_or("Invalid type returned")?; ethereum_types::U256::from(r.as_ref()) })) - } - - /// Auto-generated from: `{"constant":false,"inputs":[{"name":"_release","type":"bytes32"},{"name":"_platform","type":"bytes32"},{"name":"_checksum","type":"bytes32"}],"name":"addChecksum","outputs":[],"payable":false,"type":"function"}` - #[allow(dead_code)] - pub fn add_checksum(&self, _release: ðereum_types::H256, _platform: &str, _checksum: ðereum_types::H256) -> Result<(), String> { - let call = self.contract.function("addChecksum".into()).map_err(Self::as_string)?; - let data = call.encode_input(& - vec![ethabi::Token::FixedBytes(_release.as_ref().to_owned()), ethabi::Token::FixedBytes(_platform.as_bytes().to_owned()), ethabi::Token::FixedBytes(_checksum.as_ref().to_owned())] - ).map_err(Self::as_string)?; - call.decode_output(&(self.do_call)(self.address.clone(), data)?).map_err(Self::as_string)?; - - Ok(()) - } - - /// Auto-generated from: `{"constant":false,"inputs":[{"name":"_txid","type":"bytes32"}],"name":"confirmTransaction","outputs":[{"name":"txSuccess","type":"uint256"}],"payable":false,"type":"function"}` - #[allow(dead_code)] - pub fn confirm_transaction(&self, _txid: ðereum_types::H256) -> Result { - let call = self.contract.function("confirmTransaction".into()).map_err(Self::as_string)?; - let data = call.encode_input(& - vec![ethabi::Token::FixedBytes(_txid.as_ref().to_owned())] - ).map_err(Self::as_string)?; - let output = call.decode_output(&(self.do_call)(self.address.clone(), data)?).map_err(Self::as_string)?; - let mut result = output.into_iter().rev().collect::>(); - Ok({ let r = result.pop().ok_or("Invalid return arity")?; let r = r.to_uint().ok_or("Invalid type returned")?; ethereum_types::U256::from(r.as_ref()) }) - } - - /// Auto-generated from: `{"constant":true,"inputs":[{"name":"","type":"bytes32"}],"name":"proxy","outputs":[{"name":"requiredCount","type":"uint256"},{"name":"to","type":"address"},{"name":"data","type":"bytes"},{"name":"value","type":"uint256"},{"name":"gas","type":"uint256"}],"payable":false,"type":"function"}` - #[allow(dead_code)] - pub fn proxy(&self, _1: ðereum_types::H256) -> Result<(ethereum_types::U256, ethereum_types::Address, Vec, ethereum_types::U256, ethereum_types::U256), String> { - let call = self.contract.function("proxy".into()).map_err(Self::as_string)?; - let data = call.encode_input(& - vec![ethabi::Token::FixedBytes(_1.as_ref().to_owned())] - ).map_err(Self::as_string)?; - let output = call.decode_output(&(self.do_call)(self.address.clone(), data)?).map_err(Self::as_string)?; - let mut result = output.into_iter().rev().collect::>(); - Ok(({ let r = result.pop().ok_or("Invalid return arity")?; let r = r.to_uint().ok_or("Invalid type returned")?; ethereum_types::U256::from(r.as_ref()) }, { let r = result.pop().ok_or("Invalid return arity")?; let r = r.to_address().ok_or("Invalid type returned")?; ethereum_types::Address::from(r) }, { let r = result.pop().ok_or("Invalid return arity")?; let r = r.to_bytes().ok_or("Invalid type returned")?; r }, { let r = result.pop().ok_or("Invalid return arity")?; let r = r.to_uint().ok_or("Invalid type returned")?; ethereum_types::U256::from(r.as_ref()) }, { let r = result.pop().ok_or("Invalid return arity")?; let r = r.to_uint().ok_or("Invalid type returned")?; ethereum_types::U256::from(r.as_ref()) })) - } - - /// Auto-generated from: `{"constant":false,"inputs":[{"name":"_client","type":"bytes32"},{"name":"_owner","type":"address"}],"name":"addClient","outputs":[],"payable":false,"type":"function"}` - #[allow(dead_code)] - pub fn add_client(&self, _client: &str, _owner: ðereum_types::Address) -> Result<(), String> { - let call = self.contract.function("addClient".into()).map_err(Self::as_string)?; - let data = call.encode_input(& - vec![ethabi::Token::FixedBytes(_client.as_bytes().to_owned()), ethabi::Token::Address(_owner.clone().0)] - ).map_err(Self::as_string)?; - call.decode_output(&(self.do_call)(self.address.clone(), data)?).map_err(Self::as_string)?; - - Ok(()) - } - - /// Auto-generated from: `{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"clientOwner","outputs":[{"name":"","type":"bytes32"}],"payable":false,"type":"function"}` - #[allow(dead_code)] - pub fn client_owner(&self, _1: ðereum_types::Address) -> Result { - let call = self.contract.function("clientOwner".into()).map_err(Self::as_string)?; - let data = call.encode_input(& - vec![ethabi::Token::Address(_1.clone().0)] - ).map_err(Self::as_string)?; - let output = call.decode_output(&(self.do_call)(self.address.clone(), data)?).map_err(Self::as_string)?; - let mut result = output.into_iter().rev().collect::>(); - Ok({ let r = result.pop().ok_or("Invalid return arity")?; let r = r.to_fixed_bytes().ok_or("Invalid type returned")?; ethereum_types::H256::from_slice(r.as_ref()) }) - } - - /// Auto-generated from: `{"constant":false,"inputs":[{"name":"_txid","type":"bytes32"},{"name":"_to","type":"address"},{"name":"_data","type":"bytes"},{"name":"_value","type":"uint256"},{"name":"_gas","type":"uint256"}],"name":"proposeTransaction","outputs":[{"name":"txSuccess","type":"uint256"}],"payable":false,"type":"function"}` - #[allow(dead_code)] - pub fn propose_transaction(&self, _txid: ðereum_types::H256, _to: ðereum_types::Address, _data: &[u8], _value: ethereum_types::U256, _gas: ethereum_types::U256) -> Result { - let call = self.contract.function("proposeTransaction".into()).map_err(Self::as_string)?; - let data = call.encode_input(& - vec![ethabi::Token::FixedBytes(_txid.as_ref().to_owned()), ethabi::Token::Address(_to.clone().0), ethabi::Token::Bytes(_data.to_owned()), ethabi::Token::Uint({ let mut r = [0u8; 32]; _value.to_big_endian(&mut r); r }), ethabi::Token::Uint({ let mut r = [0u8; 32]; _gas.to_big_endian(&mut r); r })] - ).map_err(Self::as_string)?; - let output = call.decode_output(&(self.do_call)(self.address.clone(), data)?).map_err(Self::as_string)?; - let mut result = output.into_iter().rev().collect::>(); - Ok({ let r = result.pop().ok_or("Invalid return arity")?; let r = r.to_uint().ok_or("Invalid type returned")?; ethereum_types::U256::from(r.as_ref()) }) - } - - /// Auto-generated from: `{"constant":true,"inputs":[],"name":"grandOwner","outputs":[{"name":"","type":"address"}],"payable":false,"type":"function"}` - #[allow(dead_code)] - pub fn grand_owner(&self) -> Result { - let call = self.contract.function("grandOwner".into()).map_err(Self::as_string)?; - let data = call.encode_input(& - vec![] - ).map_err(Self::as_string)?; - let output = call.decode_output(&&(self.do_call)(self.address.clone(), data)?).map_err(Self::as_string)?; - let mut result = output.into_iter().rev().collect::>(); - Ok({ let r = result.pop().ok_or("Invalid return arity")?; let r = r.to_address().ok_or("Invalid type returned")?; ethereum_types::Address::from(r) }) - } - - /// Auto-generated from: `{"constant":false,"inputs":[{"name":"_release","type":"bytes32"},{"name":"_forkBlock","type":"uint32"},{"name":"_track","type":"uint8"},{"name":"_semver","type":"uint24"},{"name":"_critical","type":"bool"}],"name":"addRelease","outputs":[],"payable":false,"type":"function"}` - #[allow(dead_code)] - pub fn add_release(&self, _release: ðereum_types::H256, _fork_block: u32, _track: u8, _semver: u32, _critical: bool) -> Result<(), String> { - let call = self.contract.function("addRelease".into()).map_err(Self::as_string)?; - let data = call.encode_input(& - vec![ethabi::Token::FixedBytes(_release.as_ref().to_owned()), ethabi::Token::Uint({ let mut r = [0u8; 32]; ethereum_types::U256::from(_fork_block as u64).to_big_endian(&mut r); r }), ethabi::Token::Uint({ let mut r = [0u8; 32]; ethereum_types::U256::from(_track as u64).to_big_endian(&mut r); r }), ethabi::Token::Uint({ let mut r = [0u8; 32]; ethereum_types::U256::from(_semver as u64).to_big_endian(&mut r); r }), ethabi::Token::Bool(_critical)] - ).map_err(Self::as_string)?; - call.decode_output(&(self.do_call)(self.address.clone(), data)?).map_err(Self::as_string)?; - - Ok(()) - } - - /// Auto-generated from: `{"constant":false,"inputs":[],"name":"acceptFork","outputs":[],"payable":false,"type":"function"}` - #[allow(dead_code)] - pub fn accept_fork(&self) -> Result<(), String> { - let call = self.contract.function("acceptFork".into()).map_err(Self::as_string)?; - let data = call.encode_input(& - vec![] - ).map_err(Self::as_string)?; - call.decode_output(&(self.do_call)(self.address.clone(), data)?).map_err(Self::as_string)?; - - Ok(()) - } - - /// Auto-generated from: `{"constant":true,"inputs":[],"name":"clientsRequired","outputs":[{"name":"","type":"uint32"}],"payable":false,"type":"function"}` - #[allow(dead_code)] - pub fn clients_required(&self) -> Result { - let call = self.contract.function("clientsRequired".into()).map_err(Self::as_string)?; - let data = call.encode_input(& - vec![] - ).map_err(Self::as_string)?; - let output = call.decode_output(&(self.do_call)(self.address.clone(), data)?).map_err(Self::as_string)?; - let mut result = output.into_iter().rev().collect::>(); - Ok({ let r = result.pop().ok_or("Invalid return arity")?; let r = r.to_uint().ok_or("Invalid type returned")?; ethereum_types::U256::from(r.as_ref()).as_u64() as u32 }) - } - - /// Auto-generated from: `{"constant":true,"inputs":[{"name":"_client","type":"bytes32"},{"name":"_release","type":"bytes32"}],"name":"track","outputs":[{"name":"","type":"uint8"}],"payable":false,"type":"function"}` - #[allow(dead_code)] - pub fn track(&self, _client: &str, _release: ðereum_types::H256) -> Result { - let call = self.contract.function("track".into()).map_err(Self::as_string)?; - let data = call.encode_input(& - vec![ethabi::Token::FixedBytes(_client.as_bytes().to_owned()), ethabi::Token::FixedBytes(_release.as_ref().to_owned())] - ).map_err(Self::as_string)?; - let output = call.decode_output(&(self.do_call)(self.address.clone(), data)?).map_err(Self::as_string)?; - let mut result = output.into_iter().rev().collect::>(); - Ok({ let r = result.pop().ok_or("Invalid return arity")?; let r = r.to_uint().ok_or("Invalid type returned")?; ethereum_types::U256::from(r.as_ref()).as_u64() as u8 }) - } - - /// Auto-generated from: `{"constant":false,"inputs":[{"name":"_client","type":"bytes32"},{"name":"_r","type":"bool"}],"name":"setClientRequired","outputs":[],"payable":false,"type":"function"}` - #[allow(dead_code)] - pub fn set_client_required(&self, _client: &str, _r: bool) -> Result<(), String> { - let call = self.contract.function("setClientRequired".into()).map_err(Self::as_string)?; - let data = call.encode_input(& - vec![ethabi::Token::FixedBytes(_client.as_bytes().to_owned()), ethabi::Token::Bool(_r)] - ).map_err(Self::as_string)?; - call.decode_output(&(self.do_call)(self.address.clone(), data)?).map_err(Self::as_string)?; - - Ok(()) - } - - /// Auto-generated from: `{"constant":true,"inputs":[],"name":"latestFork","outputs":[{"name":"","type":"uint32"}],"payable":false,"type":"function"}` - #[allow(dead_code)] - pub fn latest_fork(&self) -> Result { - let call = self.contract.function("latestFork".into()).map_err(Self::as_string)?; - let data = call.encode_input(&[]).map_err(Self::as_string)?; - let output = call.decode_output(&(self.do_call)(self.address.clone(), data)?).map_err(Self::as_string)?; - let mut result = output.into_iter().rev().collect::>(); - Ok({ let r = result.pop().ok_or("Invalid return arity")?; let r = r.to_uint().ok_or("Invalid type returned")?; ethereum_types::U256::from(r.as_ref()).as_u64() as u32 }) - } - - /// Auto-generated from: `{"constant":true,"inputs":[{"name":"_client","type":"bytes32"},{"name":"_track","type":"uint8"}],"name":"latestInTrack","outputs":[{"name":"","type":"bytes32"}],"payable":false,"type":"function"}` - #[allow(dead_code)] - pub fn latest_in_track(&self, _client: &str, _track: u8) -> Result { - let call = self.contract.function("latestInTrack".into()).map_err(Self::as_string)?; - let data = call.encode_input(& - &vec![ethabi::Token::FixedBytes(_client.as_bytes().to_owned()), ethabi::Token::Uint({ let mut r = [0u8; 32]; ethereum_types::U256::from(_track as u64).to_big_endian(&mut r); r })] - ).map_err(Self::as_string)?; - let output = call.decode_output(&(self.do_call)(self.address.clone(), data)?).map_err(Self::as_string)?; - let mut result = output.into_iter().rev().collect::>(); - Ok({ let r = result.pop().ok_or("Invalid return arity")?; let r = r.to_fixed_bytes().ok_or("Invalid type returned")?; ethereum_types::H256::from_slice(r.as_ref()) }) - } - - /// Auto-generated from: `{"constant":true,"inputs":[{"name":"_client","type":"bytes32"},{"name":"_release","type":"bytes32"},{"name":"_platform","type":"bytes32"}],"name":"checksum","outputs":[{"name":"","type":"bytes32"}],"payable":false,"type":"function"}` - #[allow(dead_code)] - pub fn checksum(&self, _client: &str, _release: ðereum_types::H256, _platform: &str) -> Result { - let call = self.contract.function("checksum".into()).map_err(Self::as_string)?; - let data = call.encode_input(& - vec![ethabi::Token::FixedBytes(_client.as_bytes().to_owned()), ethabi::Token::FixedBytes(_release.as_ref().to_owned()), ethabi::Token::FixedBytes(_platform.as_bytes().to_owned())] - ).map_err(Self::as_string)?; - let output = call.decode_output(&(self.do_call)(self.address.clone(), data)?).map_err(Self::as_string)?; - let mut result = output.into_iter().rev().collect::>(); - Ok({ let r = result.pop().ok_or("Invalid return arity")?; let r = r.to_fixed_bytes().ok_or("Invalid type returned")?; ethereum_types::H256::from_slice(r.as_ref()) }) - } - - /// Auto-generated from: `{"constant":true,"inputs":[],"name":"proposedFork","outputs":[{"name":"","type":"uint32"}],"payable":false,"type":"function"}` - #[allow(dead_code)] - pub fn proposed_fork(&self) -> Result { - let call = self.contract.function("proposedFork".into()).map_err(Self::as_string)?; - let data = call.encode_input(&[]).map_err(Self::as_string)?; - let output = call.decode_output(&(self.do_call)(self.address.clone(), data)?).map_err(Self::as_string)?; - let mut result = output.into_iter().rev().collect::>(); - Ok({ let r = result.pop().ok_or("Invalid return arity")?; let r = r.to_uint().ok_or("Invalid type returned")?; ethereum_types::U256::from(r.as_ref()).as_u64() as u32 }) - } -} diff --git a/updater/src/types/release_track.rs b/updater/src/types/release_track.rs index 0eaf85d14..a1f646805 100644 --- a/updater/src/types/release_track.rs +++ b/updater/src/types/release_track.rs @@ -19,18 +19,19 @@ use std::fmt; /// A release's track. +#[repr(u8)] #[derive(PartialEq, Eq, Clone, Copy, Debug)] pub enum ReleaseTrack { /// Stable track. - Stable, + Stable = 1, /// Beta track. - Beta, + Beta = 2, /// Nightly track. - Nightly, + Nightly = 3, /// Testing track. - Testing, + Testing = 4, /// No known track, also "current executable's track" when it's not yet known. - Unknown, + Unknown = 0, } impl fmt::Display for ReleaseTrack { @@ -69,14 +70,50 @@ impl From for ReleaseTrack { } } -impl Into for ReleaseTrack { - fn into(self) -> u8 { - match self { - ReleaseTrack::Stable => 1, - ReleaseTrack::Beta => 2, - ReleaseTrack::Nightly => 3, - ReleaseTrack::Testing => 4, - ReleaseTrack::Unknown => 0, - } + +impl From for u8 { + fn from(rt: ReleaseTrack) -> Self { + rt as u8 + } +} + +#[cfg(test)] +mod tests { + use super::ReleaseTrack; + + #[test] + fn test_release_track_from() { + assert_eq!(ReleaseTrack::Stable, 1u8.into()); + assert_eq!(ReleaseTrack::Beta, 2u8.into()); + assert_eq!(ReleaseTrack::Nightly, 3u8.into()); + assert_eq!(ReleaseTrack::Testing, 4u8.into()); + assert_eq!(ReleaseTrack::Unknown, 0u8.into()); + } + + #[test] + fn test_release_track_into() { + assert_eq!(1u8, u8::from(ReleaseTrack::Stable)); + assert_eq!(2u8, u8::from(ReleaseTrack::Beta)); + assert_eq!(3u8, u8::from(ReleaseTrack::Nightly)); + assert_eq!(4u8, u8::from(ReleaseTrack::Testing)); + assert_eq!(0u8, u8::from(ReleaseTrack::Unknown)); + } + + #[test] + fn test_release_track_from_str() { + assert_eq!(ReleaseTrack::Stable, "stable".into()); + assert_eq!(ReleaseTrack::Beta, "beta".into()); + assert_eq!(ReleaseTrack::Nightly, "nightly".into()); + assert_eq!(ReleaseTrack::Testing, "testing".into()); + assert_eq!(ReleaseTrack::Unknown, "unknown".into()); + } + + #[test] + fn test_release_track_into_str() { + assert_eq!("stable", ReleaseTrack::Stable.to_string()); + assert_eq!("beta", ReleaseTrack::Beta.to_string()); + assert_eq!("nightly", ReleaseTrack::Nightly.to_string()); + assert_eq!("testing", ReleaseTrack::Testing.to_string()); + assert_eq!("unknown", ReleaseTrack::Unknown.to_string()); } } diff --git a/updater/src/updater.rs b/updater/src/updater.rs index 347d2ccf9..80f622d6e 100644 --- a/updater/src/updater.rs +++ b/updater/src/updater.rs @@ -21,20 +21,18 @@ use std::sync::{Arc, Weak}; use ethcore::client::{BlockId, BlockChainClient, ChainNotify}; use ethsync::{SyncProvider}; -use futures::future; use hash_fetch::{self as fetch, HashFetch}; -use hash_fetch::fetch::Client as FetchService; -use operations::Operations; -use parity_reactor::Remote; use path::restrict_permissions_owner; use service::{Service}; use target_info::Target; use types::{ReleaseInfo, OperationsInfo, CapState, VersionInfo, ReleaseTrack}; -use ethereum_types::{H160, H256, Address}; +use ethereum_types::H256; use bytes::Bytes; use parking_lot::Mutex; use version; +use_contract!(operations_contract, "Operations", "res/operations.json"); + /// Filter for releases. #[derive(Debug, Eq, PartialEq, Clone)] pub enum UpdateFilter { @@ -93,8 +91,8 @@ pub struct Updater { weak_self: Mutex>, client: Weak, sync: Weak, - fetcher: Mutex>, - operations: Mutex>, + fetcher: fetch::Client, + operations_contract: operations_contract::Operations, exit_handler: Mutex>>, // Our version info (static) @@ -106,6 +104,10 @@ pub struct Updater { const CLIENT_ID: &'static str = "parity"; +fn client_id_hash() -> H256 { + CLIENT_ID.as_bytes().into() +} + fn platform() -> String { if cfg!(target_os = "macos") { "x86_64-apple-darwin".into() @@ -118,20 +120,23 @@ fn platform() -> String { } } +fn platform_id_hash() -> H256 { + platform().as_bytes().into() +} + impl Updater { - pub fn new(client: Weak, sync: Weak, update_policy: UpdatePolicy, fetch: FetchService, remote: Remote) -> Arc { + pub fn new(client: Weak, sync: Weak, update_policy: UpdatePolicy, fetcher: fetch::Client) -> Arc { let r = Arc::new(Updater { update_policy: update_policy, weak_self: Mutex::new(Default::default()), client: client.clone(), sync: sync.clone(), - fetcher: Mutex::new(None), - operations: Mutex::new(None), + fetcher, + operations_contract: operations_contract::Operations::default(), exit_handler: Mutex::new(None), this: VersionInfo::this(), state: Mutex::new(Default::default()), }); - *r.fetcher.lock() = Some(fetch::Client::with_fetch(r.clone(), fetch, remote)); *r.weak_self.lock() = Arc::downgrade(&r); r.poll(); r @@ -142,17 +147,30 @@ impl Updater { *self.exit_handler.lock() = Some(Box::new(f)); } - fn collect_release_info(operations: &Operations, release_id: &H256) -> Result { - let (fork, track, semver, is_critical) = operations.release(CLIENT_ID, release_id)?; - let latest_binary = operations.checksum(CLIENT_ID, release_id, &platform())?; + fn collect_release_info) -> Result, String>>(&self, release_id: H256, do_call: &T) -> Result { + let (fork, track, semver, is_critical) = self.operations_contract.functions() + .release() + .call(client_id_hash(), release_id, &do_call) + .map_err(|e| format!("{:?}", e))?; + + let (fork, track, semver) = (fork.low_u64(), track.low_u32(), semver.low_u32()); + + let latest_binary = self.operations_contract.functions() + .checksum() + .call(client_id_hash(), release_id, platform_id_hash(), &do_call) + .map_err(|e| format!("{:?}", e))?; + Ok(ReleaseInfo { - version: VersionInfo::from_raw(semver, track, release_id.clone().into()), - is_critical: is_critical, - fork: fork as u64, + version: VersionInfo::from_raw(semver, track as u8, release_id.into()), + is_critical, + fork, binary: if latest_binary.is_zero() { None } else { Some(latest_binary) }, }) } + /// Returns release track of the parity node. + /// `update_policy.track` is the track specified from the command line, whereas `this.track` + /// is the track of the software which is currently run fn track(&self) -> ReleaseTrack { match self.update_policy.track { ReleaseTrack::Unknown => self.this.track, @@ -160,42 +178,68 @@ impl Updater { } } + fn latest_in_track) -> Result, String>>(&self, track: ReleaseTrack, do_call: &T) -> Result { + self.operations_contract.functions() + .latest_in_track() + .call(client_id_hash(), u8::from(track), do_call) + .map_err(|e| format!("{:?}", e)) + } + fn collect_latest(&self) -> Result { - if let Some(ref operations) = *self.operations.lock() { - let hh: H256 = self.this.hash.into(); - trace!(target: "updater", "Looking up this_fork for our release: {}/{:?}", CLIENT_ID, hh); - let this_fork = operations.release(CLIENT_ID, &self.this.hash.into()).ok() - .and_then(|(fork, track, _, _)| { - trace!(target: "updater", "Operations returned fork={}, track={}", fork as u64, track); - if track > 0 {Some(fork as u64)} else {None} - }); - - if self.track() == ReleaseTrack::Unknown { - return Err(format!("Current executable ({}) is unreleased.", H160::from(self.this.hash))); - } - - let latest_in_track = operations.latest_in_track(CLIENT_ID, self.track().into())?; - let in_track = Self::collect_release_info(operations, &latest_in_track)?; - let mut in_minor = Some(in_track.clone()); - const PROOF: &'static str = "in_minor initialised and assigned with Some; loop breaks if None assigned; qed"; - while in_minor.as_ref().expect(PROOF).version.track != self.track() { - let track = match in_minor.as_ref().expect(PROOF).version.track { - ReleaseTrack::Beta => ReleaseTrack::Stable, - ReleaseTrack::Nightly => ReleaseTrack::Beta, - _ => { in_minor = None; break; } - }; - in_minor = Some(Self::collect_release_info(operations, &operations.latest_in_track(CLIENT_ID, track.into())?)?); - } - - Ok(OperationsInfo { - fork: operations.latest_fork()? as u64, - this_fork: this_fork, - track: in_track, - minor: in_minor, - }) - } else { - Err("Operations not available".into()) + if self.track() == ReleaseTrack::Unknown { + return Err(format!("Current executable ({}) is unreleased.", self.this.hash)); } + + let client = self.client.upgrade().ok_or_else(|| "Cannot obtain client")?; + let address = client.registry_address("operations".into()).ok_or_else(|| "Cannot get operations contract address")?; + let do_call = |data| client.call_contract(BlockId::Latest, address, data).map_err(|e| format!("{:?}", e)); + + trace!(target: "updater", "Looking up this_fork for our release: {}/{:?}", CLIENT_ID, self.this.hash); + + // get the fork number of this release + let this_fork = self.operations_contract.functions() + .release() + .call(client_id_hash(), self.this.hash, &do_call) + .ok() + .and_then(|(fork, track, _, _)| { + let this_track: ReleaseTrack = (track.low_u64() as u8).into(); + match this_track { + ReleaseTrack::Unknown => None, + _ => Some(fork.low_u64()), + } + }); + + // get the hash of the latest release in our track + let latest_in_track = self.latest_in_track(self.track(), &do_call)?; + + // get the release info for the latest version in track + let in_track = self.collect_release_info(latest_in_track, &do_call)?; + let mut in_minor = Some(in_track.clone()); + const PROOF: &'static str = "in_minor initialised and assigned with Some; loop breaks if None assigned; qed"; + + // if the minor version has changed, let's check the minor version on a different track + while in_minor.as_ref().expect(PROOF).version.version.minor != self.this.version.minor { + let track = match in_minor.as_ref().expect(PROOF).version.track { + ReleaseTrack::Beta => ReleaseTrack::Stable, + ReleaseTrack::Nightly => ReleaseTrack::Beta, + _ => { in_minor = None; break; } + }; + + let latest_in_track = self.latest_in_track(track, &do_call)?; + in_minor = Some(self.collect_release_info(latest_in_track, &do_call)?); + } + + let fork = self.operations_contract.functions() + .latest_fork() + .call(&do_call) + .map_err(|e| format!("{:?}", e))?.low_u64(); + + Ok(OperationsInfo { + fork, + this_fork, + track: in_track, + minor: in_minor, + }) } fn update_file_name(v: &VersionInfo) -> String { @@ -209,6 +253,7 @@ impl Updater { } fn fetch_done(&self, result: Result) { + // old below (|| -> Result<(), (String, bool)> { let auto = { let mut s = self.state.lock(); @@ -246,17 +291,6 @@ impl Updater { return; } - if self.operations.lock().is_none() { - if let Some(ops_addr) = self.client.upgrade().and_then(|c| c.registry_address("operations".into())) { - trace!(target: "updater", "Found operations at {}", ops_addr); - let client = self.client.clone(); - *self.operations.lock() = Some(Operations::new(ops_addr, move |a, d| client.upgrade().ok_or("No client!".into()).and_then(|c| c.call_contract(BlockId::Latest, a, d)))); - } else { - // No Operations contract - bail. - return; - } - } - let current_number = self.client.upgrade().map_or(0, |c| c.block_number(BlockId::Latest).unwrap_or(0)); let mut capability = CapState::Unknown; @@ -291,7 +325,7 @@ impl Updater { drop(s); let weak_self = self.weak_self.lock().clone(); let f = move |r: Result| if let Some(this) = weak_self.upgrade() { this.fetch_done(r) }; - self.fetcher.lock().as_ref().expect("Created on `new`; qed").fetch(b, Box::new(f)); + self.fetcher.fetch(b, Box::new(f)); } } } @@ -334,22 +368,6 @@ impl ChainNotify for Updater { } } -impl fetch::urlhint::ContractClient for Updater { - fn registrar(&self) -> Result { - self.client.upgrade().ok_or_else(|| "Client not available".to_owned())? - .registrar_address() - .ok_or_else(|| "Registrar not available".into()) - } - - fn call(&self, address: Address, data: Bytes) -> fetch::urlhint::BoxFuture { - Box::new(future::done( - self.client.upgrade() - .ok_or_else(|| "Client not available".into()) - .and_then(move |c| c.call_contract(BlockId::Latest, address, data)) - )) - } -} - impl Service for Updater { fn capability(&self) -> CapState { self.state.lock().capability @@ -360,36 +378,40 @@ impl Service for Updater { } fn execute_upgrade(&self) -> bool { - (|| -> Result { - let mut s = self.state.lock(); - if let Some(r) = s.ready.take() { - let p = Self::update_file_name(&r.version); - let n = self.updates_path("latest"); - // TODO: creating then writing is a bit fragile. would be nice to make it atomic. - match fs::File::create(&n).and_then(|mut f| f.write_all(p.as_bytes())) { - Ok(_) => { - info!(target: "updater", "Completed upgrade to {}", &r.version); - s.installed = Some(r); - if let Some(ref h) = *self.exit_handler.lock() { - (*h)(); - } else { - info!("Update installed; ready for restart."); - } - Ok(true) - } - Err(e) => { - s.ready = Some(r); - Err(format!("Unable to create soft-link for update {:?}", e)) - } - } - } else { + let mut s = self.state.lock(); + let ready = match s.ready.take() { + Some(ready) => ready, + None => { warn!(target: "updater", "Execute upgrade called when no upgrade ready."); - Ok(false) + return false; } - })().unwrap_or_else(|e| { warn!("{}", e); false }) + }; + + let p = Self::update_file_name(&ready.version); + let n = self.updates_path("latest"); + + // TODO: creating then writing is a bit fragile. would be nice to make it atomic. + if let Err(e) = fs::File::create(&n).and_then(|mut f| f.write_all(p.as_bytes())) { + s.ready = Some(ready); + warn!(target: "updater", "Unable to create soft-link for update {:?}", e); + return false; + } + + info!(target: "updater", "Completed upgrade to {}", &ready.version); + s.installed = Some(ready); + match *self.exit_handler.lock() { + Some(ref h) => (*h)(), + None => info!(target: "updater", "Update installed; ready for restart."), + } + + true } - fn version_info(&self) -> VersionInfo { self.this.clone() } + fn version_info(&self) -> VersionInfo { + self.this.clone() + } - fn info(&self) -> Option { self.state.lock().latest.clone() } + fn info(&self) -> Option { + self.state.lock().latest.clone() + } } diff --git a/util/bloomchain/Cargo.toml b/util/bloomchain/Cargo.toml index ea3022cea..a9bd8432c 100644 --- a/util/bloomchain/Cargo.toml +++ b/util/bloomchain/Cargo.toml @@ -8,7 +8,7 @@ license = "MIT" keywords = ["ethereum", "ethcore", "bloom", "chain", "filter"] [dependencies] -ethbloom = "0.3" +ethbloom = "0.4" [dev-dependencies] rustc-hex = "1.0" diff --git a/util/dir/Cargo.toml b/util/dir/Cargo.toml index fab41c630..c94086386 100644 --- a/util/dir/Cargo.toml +++ b/util/dir/Cargo.toml @@ -4,6 +4,6 @@ version = "0.1.0" authors = ["Parity Technologies "] [dependencies] -ethereum-types = "0.1" +ethereum-types = "0.2" journaldb = { path = "../journaldb" } app_dirs = "1.1.1" diff --git a/util/dir/src/lib.rs b/util/dir/src/lib.rs index 303919e42..39175d000 100644 --- a/util/dir/src/lib.rs +++ b/util/dir/src/lib.rs @@ -156,92 +156,66 @@ impl DatabaseDirectories { /// Base DB directory for the given fork. // TODO: remove in 1.7 pub fn legacy_fork_path(&self) -> PathBuf { - let mut dir = Path::new(&self.legacy_path).to_path_buf(); - dir.push(format!("{:?}{}", H64::from(self.genesis_hash), self.fork_name.as_ref().map(|f| format!("-{}", f)).unwrap_or_default())); - dir + Path::new(&self.legacy_path).join(format!("{:?}{}", H64::from(self.genesis_hash), self.fork_name.as_ref().map(|f| format!("-{}", f)).unwrap_or_default())) } /// Spec root directory for the given fork. pub fn spec_root_path(&self) -> PathBuf { - let mut dir = Path::new(&self.path).to_path_buf(); - dir.push(&self.spec_name); - dir + Path::new(&self.path).join(&self.spec_name) } /// Generic client path pub fn client_path(&self, pruning: Algorithm) -> PathBuf { - let mut dir = self.db_root_path(); - dir.push(pruning.as_internal_name_str()); - dir.push("db"); - dir + self.db_root_path().join(pruning.as_internal_name_str()).join("db") } /// DB root path, named after genesis hash pub fn db_root_path(&self) -> PathBuf { - let mut dir = self.spec_root_path(); - dir.push("db"); - dir.push(H64::from(self.genesis_hash).hex()); - dir + self.spec_root_path().join("db").join(format!("{:x}", H64::from(self.genesis_hash))) } /// DB path pub fn db_path(&self, pruning: Algorithm) -> PathBuf { - let mut dir = self.db_root_path(); - dir.push(pruning.as_internal_name_str()); - dir + self.db_root_path().join(pruning.as_internal_name_str()) } /// Get the root path for database // TODO: remove in 1.7 pub fn legacy_version_path(&self, pruning: Algorithm) -> PathBuf { - let mut dir = self.legacy_fork_path(); - dir.push(format!("v{}-sec-{}", LEGACY_CLIENT_DB_VER_STR, pruning.as_internal_name_str())); - dir + self.legacy_fork_path().join(format!("v{}-sec-{}", LEGACY_CLIENT_DB_VER_STR, pruning.as_internal_name_str())) } /// Get user defaults path, legacy way // TODO: remove in 1.7 pub fn legacy_user_defaults_path(&self) -> PathBuf { - let mut dir = self.legacy_fork_path(); - dir.push("user_defaults"); - dir + self.legacy_fork_path().join("user_defaults") } /// Get snapshot path, legacy way // TODO: remove in 1.7 pub fn legacy_snapshot_path(&self) -> PathBuf { - let mut dir = self.legacy_fork_path(); - dir.push("snapshot"); - dir + self.legacy_fork_path().join("snapshot") } /// Get user defaults path, legacy way // TODO: remove in 1.7 pub fn legacy_network_path(&self) -> PathBuf { - let mut dir = self.legacy_fork_path(); - dir.push("network"); - dir + self.legacy_fork_path().join("network") } /// Get user defauls path pub fn user_defaults_path(&self) -> PathBuf { - let mut dir = self.spec_root_path(); - dir.push("user_defaults"); - dir + self.spec_root_path().join("user_defaults") } /// Get the path for the snapshot directory given the genesis hash and fork name. pub fn snapshot_path(&self) -> PathBuf { - let mut dir = self.db_root_path(); - dir.push("snapshot"); - dir + self.db_root_path().join("snapshot") } /// Get the path for the network directory. pub fn network_path(&self) -> PathBuf { - let mut dir = self.spec_root_path(); - dir.push("network"); - dir + self.spec_root_path().join("network") } } diff --git a/util/error/Cargo.toml b/util/error/Cargo.toml index 4bd28e478..ffbd8e4a7 100644 --- a/util/error/Cargo.toml +++ b/util/error/Cargo.toml @@ -6,6 +6,6 @@ authors = ["Parity Technologies "] [dependencies] rlp = { path = "../rlp" } kvdb = { path = "../kvdb" } -ethereum-types = "0.1" +ethereum-types = "0.2" error-chain = { version = "0.11", default-features = false } rustc-hex = "1.0" diff --git a/util/hash/Cargo.toml b/util/hash/Cargo.toml index 7e97b09f5..c7fee36e0 100644 --- a/util/hash/Cargo.toml +++ b/util/hash/Cargo.toml @@ -8,7 +8,7 @@ authors = ["Parity Technologies "] build = "build.rs" [dependencies] -ethereum-types = "0.1" +ethereum-types = "0.2" tiny-keccak = "1.3" [build-dependencies] diff --git a/util/hashdb/Cargo.toml b/util/hashdb/Cargo.toml index 61b1f2ce2..de538f56c 100644 --- a/util/hashdb/Cargo.toml +++ b/util/hashdb/Cargo.toml @@ -7,4 +7,4 @@ license = "GPL-3.0" [dependencies] elastic-array = "0.9" -ethereum-types = "0.1" +ethereum-types = "0.2" diff --git a/util/journaldb/Cargo.toml b/util/journaldb/Cargo.toml index c3066da24..d3d4708f0 100644 --- a/util/journaldb/Cargo.toml +++ b/util/journaldb/Cargo.toml @@ -7,7 +7,7 @@ license = "GPL3" [dependencies] ethcore-bytes = { path = "../bytes" } -ethereum-types = "0.1" +ethereum-types = "0.2" hashdb = { path = "../hashdb" } heapsize = "0.4" kvdb = { path = "../kvdb" } diff --git a/util/kvdb-rocksdb/Cargo.toml b/util/kvdb-rocksdb/Cargo.toml index 59b836d29..a669e3d16 100644 --- a/util/kvdb-rocksdb/Cargo.toml +++ b/util/kvdb-rocksdb/Cargo.toml @@ -5,7 +5,7 @@ authors = ["Parity Technologies "] [dependencies] elastic-array = "0.9" -ethereum-types = "0.1" +ethereum-types = "0.2" kvdb = { path = "../kvdb" } log = "0.3" num_cpus = "1.0" diff --git a/util/memorydb/Cargo.toml b/util/memorydb/Cargo.toml index 9d1785e96..2853761d3 100644 --- a/util/memorydb/Cargo.toml +++ b/util/memorydb/Cargo.toml @@ -9,7 +9,7 @@ license = "GPL-3.0" bigint = "4.0" elastic-array = "0.9" heapsize = "0.4" -ethereum-types = { version = "0.1", features = ["heapsizeof"] } +ethereum-types = "0.2" keccak-hash = { version = "0.1.0", path = "../hash" } hashdb = { version = "0.1.1", path = "../hashdb" } plain_hasher = { path = "../plain_hasher" } diff --git a/util/network/Cargo.toml b/util/network/Cargo.toml index 255159797..4271b5914 100644 --- a/util/network/Cargo.toml +++ b/util/network/Cargo.toml @@ -10,7 +10,7 @@ authors = ["Parity Technologies "] log = "0.3" mio = "0.6.8" bytes = "0.4" -rand = "0.3.12" +rand = "0.4" time = "0.1.34" tiny-keccak = "1.3" rust-crypto = "0.2.34" @@ -22,7 +22,7 @@ ansi_term = "0.10" rustc-hex = "1.0" ethcore-io = { path = "../io" } ethcore-bytes = { path = "../bytes" } -ethereum-types = "0.1" +ethereum-types = "0.2" ethkey = { path = "../../ethkey" } ethcrypto = { path = "../../ethcrypto" } rlp = { path = "../rlp" } diff --git a/util/patricia_trie/Cargo.toml b/util/patricia_trie/Cargo.toml index cf8d7899e..be95643a1 100644 --- a/util/patricia_trie/Cargo.toml +++ b/util/patricia_trie/Cargo.toml @@ -8,9 +8,9 @@ license = "GPL-3.0" [dependencies] elastic-array = "0.9" log = "0.3" -rand = "0.3" +rand = "0.4" ethcore-bytes = { version = "0.1.0", path = "../bytes" } -ethereum-types = "0.1" +ethereum-types = "0.2" keccak-hash = { version = "0.1.0", path = "../hash" } hashdb = { version = "0.1.1", path = "../hashdb" } rlp = { version = "0.2.1", path = "../rlp" } diff --git a/util/plain_hasher/Cargo.toml b/util/plain_hasher/Cargo.toml index f14f2f48f..d79ea4c5e 100644 --- a/util/plain_hasher/Cargo.toml +++ b/util/plain_hasher/Cargo.toml @@ -9,4 +9,4 @@ homepage = "https://github.com/paritytech/plain_hasher" [dependencies] crunchy = "0.1.6" -ethereum-types = "0.1" +ethereum-types = "0.2" diff --git a/util/rlp/Cargo.toml b/util/rlp/Cargo.toml index 7e68e5f4f..7d6611742 100644 --- a/util/rlp/Cargo.toml +++ b/util/rlp/Cargo.toml @@ -8,7 +8,7 @@ authors = ["Parity Technologies "] [dependencies] elastic-array = "0.9" -ethereum-types = "0.1" +ethereum-types = "0.2" lazy_static = "1.0" rustc-hex = "1.0" byteorder = "1.0" diff --git a/util/triehash/Cargo.toml b/util/triehash/Cargo.toml index a19a4da0d..16678275a 100644 --- a/util/triehash/Cargo.toml +++ b/util/triehash/Cargo.toml @@ -7,5 +7,5 @@ license = "GPL-3.0" [dependencies] rlp = { version = "0.2.1", path = "../rlp" } -ethereum-types = "0.1" +ethereum-types = "0.2" keccak-hash = { version = "0.1", path = "../hash" } diff --git a/whisper/Cargo.toml b/whisper/Cargo.toml index 443620970..26ec0ee2d 100644 --- a/whisper/Cargo.toml +++ b/whisper/Cargo.toml @@ -7,7 +7,7 @@ description = "Whisper Protocol implementation for Parity" [dependencies] bitflags = "0.9" byteorder = "1.0.0" -ethereum-types = "0.1" +ethereum-types = "0.2" ethcore-network = { path = "../util/network" } ethcrypto = { path = "../ethcrypto" } ethkey = { path = "../ethkey" } @@ -15,7 +15,7 @@ hex = "0.2" log = "0.3" ordered-float = "0.5" parking_lot = "0.5" -rand = "0.3" +rand = "0.4" ring = "0.12" rlp = { path = "../util/rlp" } serde = "1.0" diff --git a/whisper/src/rpc/filter.rs b/whisper/src/rpc/filter.rs index 435fb950b..663c6a6bf 100644 --- a/whisper/src/rpc/filter.rs +++ b/whisper/src/rpc/filter.rs @@ -111,7 +111,7 @@ impl Manager { .map_err(|_| "unable to acquire secure randomness")? .gen(); - sub.assign_id(::jsonrpc_pubsub::SubscriptionId::String(id.hex())) + sub.assign_id(::jsonrpc_pubsub::SubscriptionId::String(format!("{:x}", id))) .map(move |sink| { let entry = FilterEntry::Subscription(Arc::new(filter), sink); self.filters.write().insert(id, entry);