From 20bd1fa789b29824b617e74867b5f4182cc011ae Mon Sep 17 00:00:00 2001 From: Andreas Fackler Date: Tue, 22 Oct 2019 15:59:58 +0200 Subject: [PATCH 01/21] Remove unused macro_use. (#11191) --- secret-store/src/lib.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/secret-store/src/lib.rs b/secret-store/src/lib.rs index 23a3e7e3dd4..bdf3f638d28 100644 --- a/secret-store/src/lib.rs +++ b/secret-store/src/lib.rs @@ -42,7 +42,6 @@ extern crate tokio_service; extern crate url; extern crate jsonrpc_server_utils; -#[macro_use] extern crate ethabi_derive; #[macro_use] extern crate ethabi_contract; From 81ca599f2adf7737c4c57f49fce94a304c6fc242 Mon Sep 17 00:00:00 2001 From: Tino Breddin Date: Tue, 22 Oct 2019 22:03:52 +0200 Subject: [PATCH 02/21] Made ecrecover implementation trait public (#11188) * Made ecrecover Implementation trait public * Make all builtin contract types public This ensure the API is consistent in terms of visibility. --- ethcore/builtin/src/lib.rs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/ethcore/builtin/src/lib.rs b/ethcore/builtin/src/lib.rs index 78633a12ef7..3ecc1499fab 100644 --- a/ethcore/builtin/src/lib.rs +++ b/ethcore/builtin/src/lib.rs @@ -37,7 +37,7 @@ use parity_crypto::digest; use eip_152::compress; /// Native implementation of a built-in contract. -trait Implementation: Send + Sync { +pub trait Implementation: Send + Sync { /// execute this built-in on the given input, writing to the given output. fn execute(&self, input: &[u8], output: &mut BytesRef) -> Result<(), &'static str>; } @@ -305,31 +305,31 @@ fn ethereum_builtin(name: &str) -> Result, EthcoreError> // - blake2_f (The Blake2 compression function F, EIP-152) #[derive(Debug)] -struct Identity; +pub struct Identity; #[derive(Debug)] -struct EcRecover; +pub struct EcRecover; #[derive(Debug)] -struct Sha256; +pub struct Sha256; #[derive(Debug)] -struct Ripemd160; +pub struct Ripemd160; #[derive(Debug)] -struct Modexp; +pub struct Modexp; #[derive(Debug)] -struct Bn128Add; +pub struct Bn128Add; #[derive(Debug)] -struct Bn128Mul; +pub struct Bn128Mul; #[derive(Debug)] -struct Bn128Pairing; +pub struct Bn128Pairing; #[derive(Debug)] -struct Blake2F; +pub struct Blake2F; impl Implementation for Identity { fn execute(&self, input: &[u8], output: &mut BytesRef) -> Result<(), &'static str> { From 834585d61b79fad42c2eab8c0023b7ee60a531fd Mon Sep 17 00:00:00 2001 From: Anton Gavrilov Date: Wed, 23 Oct 2019 13:03:46 +0200 Subject: [PATCH 03/21] Crypto primitives removed from ethkey (#11174) * Crypto utils removed from ethkey * Fix ethkey lib * Switch ethsore to new crypto * Accounts crate fixed * Secret store crate switched to new crypto * Ethcore builtin fixed * Accounts crate fixed * Ethcore crate fixed * Util network fixed * Util network-devp2p fixed * Private tx fixed * Ethcore sync fixed * Secret store fixed * Rpc fixed * Parity fixed * Ethkey cli fixed * Local store fixed * Ethcore blockchain fixed * Cargo.lock pushed; doc comment added for reversed nonce * Ethstore tests fixed * Ethstore cli fixed * Miner fixed * Snapshot tests are fixed * Single brackets removed * Machine fixed * Verification fixed * Executive state fixed * More single brackets removed * Update version of parity-crypto * Use published version 0.4.2 of parity-crypto * New test in tx_filter fixed --- Cargo.lock | 174 +++--- Cargo.toml | 1 + accounts/Cargo.toml | 1 + accounts/ethkey/Cargo.toml | 14 +- accounts/ethkey/cli/Cargo.toml | 1 + accounts/ethkey/cli/src/main.rs | 10 +- accounts/ethkey/src/brain.rs | 12 +- accounts/ethkey/src/brain_prefix.rs | 6 +- accounts/ethkey/src/brain_recover.rs | 3 +- accounts/ethkey/src/crypto.rs | 189 ------- accounts/ethkey/src/error.rs | 81 --- accounts/ethkey/src/extended.rs | 517 ------------------ accounts/ethkey/src/keccak.rs | 31 -- accounts/ethkey/src/keypair.rs | 114 ---- accounts/ethkey/src/lib.rs | 49 +- accounts/ethkey/src/math.rs | 129 ----- accounts/ethkey/src/prefix.rs | 5 +- accounts/ethkey/src/random.rs | 42 -- accounts/ethkey/src/secret.rs | 304 ---------- accounts/ethkey/src/signature.rs | 314 ----------- accounts/ethstore/Cargo.toml | 2 +- accounts/ethstore/cli/Cargo.toml | 2 + accounts/ethstore/cli/src/crack.rs | 3 +- accounts/ethstore/cli/src/main.rs | 5 +- accounts/ethstore/src/account/crypto.rs | 7 +- accounts/ethstore/src/account/safe_account.rs | 9 +- accounts/ethstore/src/accounts_dir/disk.rs | 2 +- accounts/ethstore/src/accounts_dir/memory.rs | 2 +- accounts/ethstore/src/error.rs | 24 +- accounts/ethstore/src/ethkey.rs | 41 -- accounts/ethstore/src/ethstore.rs | 17 +- accounts/ethstore/src/import.rs | 2 +- accounts/ethstore/src/lib.rs | 31 +- accounts/ethstore/src/presale.rs | 5 +- accounts/ethstore/src/secret_store.rs | 5 +- accounts/ethstore/tests/api.rs | 3 +- accounts/src/account_data.rs | 3 +- accounts/src/lib.rs | 6 +- accounts/src/stores.rs | 2 +- ethcore/Cargo.toml | 6 +- ethcore/blockchain/Cargo.toml | 2 +- ethcore/blockchain/src/blockchain.rs | 2 +- ethcore/builtin/Cargo.toml | 3 +- ethcore/builtin/src/lib.rs | 2 +- ethcore/engine/Cargo.toml | 6 +- ethcore/engine/src/engine.rs | 2 +- ethcore/engine/src/signer.rs | 12 +- ethcore/engine/src/test_helpers.rs | 15 +- ethcore/engines/authority-round/Cargo.toml | 2 +- ethcore/engines/authority-round/src/lib.rs | 16 +- ethcore/engines/basic-authority/Cargo.toml | 2 +- ethcore/engines/basic-authority/src/lib.rs | 6 +- ethcore/engines/clique/Cargo.toml | 2 +- ethcore/engines/clique/src/lib.rs | 2 +- ethcore/engines/clique/src/tests.rs | 4 +- ethcore/engines/clique/src/util.rs | 2 +- ethcore/engines/validator-set/Cargo.toml | 2 +- ethcore/engines/validator-set/src/multi.rs | 2 +- .../validator-set/src/safe_contract.rs | 2 +- ethcore/executive-state/Cargo.toml | 2 +- ethcore/executive-state/src/lib.rs | 2 +- ethcore/machine/Cargo.toml | 2 +- ethcore/machine/src/executive.rs | 2 +- ethcore/machine/src/machine.rs | 2 +- ethcore/machine/src/tx_filter.rs | 26 +- ethcore/private-tx/Cargo.toml | 3 +- ethcore/private-tx/src/encryptor.rs | 2 +- ethcore/private-tx/src/error.rs | 13 +- ethcore/private-tx/src/key_server_keys.rs | 5 +- ethcore/private-tx/src/lib.rs | 19 +- ethcore/private-tx/src/messages.rs | 2 +- .../private-tx/src/private_transactions.rs | 2 +- ethcore/private-tx/tests/private_contract.rs | 27 +- ethcore/snapshot/snapshot-tests/Cargo.toml | 2 +- .../snapshot-tests/src/proof_of_authority.rs | 2 +- ethcore/src/client/client.rs | 2 +- ethcore/src/lib.rs | 2 +- ethcore/src/miner/miner.rs | 2 +- ethcore/src/test_helpers/mod.rs | 2 +- ethcore/src/test_helpers/test_client.rs | 2 +- ethcore/src/tests/client.rs | 2 +- ethcore/src/tests/trace.rs | 2 +- ethcore/sync/Cargo.toml | 2 +- ethcore/sync/src/api.rs | 2 +- ethcore/sync/src/block_sync.rs | 2 +- ethcore/sync/src/chain/mod.rs | 2 +- ethcore/sync/src/tests/consensus.rs | 2 +- ethcore/sync/src/tests/private.rs | 2 +- ethcore/types/Cargo.toml | 2 +- ethcore/types/src/errors/ethcore_error.rs | 4 +- ethcore/types/src/lib.rs | 2 +- ethcore/types/src/transaction/error.rs | 6 +- ethcore/types/src/transaction/transaction.rs | 26 +- ethcore/verification/Cargo.toml | 2 +- ethcore/verification/src/verification.rs | 4 +- miner/Cargo.toml | 2 +- miner/local-store/Cargo.toml | 1 + miner/local-store/src/lib.rs | 3 +- miner/src/lib.rs | 2 +- miner/src/pool/local_transactions.rs | 2 +- miner/src/pool/replace.rs | 2 +- miner/src/pool/tests/tx.rs | 2 +- parity/account_utils.rs | 6 +- parity/configuration.rs | 4 +- parity/lib.rs | 1 + parity/presale.rs | 4 +- parity/secretstore.rs | 5 +- rpc/Cargo.toml | 2 +- rpc/src/v1/helpers/dispatch/mod.rs | 3 +- rpc/src/v1/helpers/dispatch/signing.rs | 2 +- rpc/src/v1/helpers/engine_signer.rs | 7 +- rpc/src/v1/helpers/secretstore.rs | 16 +- rpc/src/v1/helpers/signature.rs | 8 +- rpc/src/v1/impls/light/parity.rs | 3 +- rpc/src/v1/impls/parity.rs | 3 +- rpc/src/v1/impls/parity_accounts.rs | 6 +- rpc/src/v1/impls/parity_set.rs | 4 +- rpc/src/v1/impls/personal.rs | 2 +- rpc/src/v1/impls/secretstore.rs | 4 +- rpc/src/v1/impls/signer.rs | 9 +- rpc/src/v1/tests/mocked/parity.rs | 2 +- rpc/src/v1/tests/mocked/personal.rs | 2 +- rpc/src/v1/tests/mocked/secretstore.rs | 2 +- rpc/src/v1/tests/mocked/signing.rs | 3 +- secret-store/Cargo.toml | 4 +- secret-store/src/key_server.rs | 54 +- .../key_version_negotiation_session.rs | 4 +- .../servers_set_change_session.rs | 4 +- .../admin_sessions/share_add_session.rs | 4 +- .../admin_sessions/share_change_session.rs | 2 +- .../client_sessions/decryption_session.rs | 26 +- .../client_sessions/encryption_session.rs | 2 +- .../client_sessions/generation_session.rs | 4 +- .../client_sessions/signing_session_ecdsa.rs | 6 +- .../signing_session_schnorr.rs | 8 +- .../src/key_server_cluster/cluster.rs | 4 +- .../cluster_connections_net.rs | 2 +- .../key_server_cluster/cluster_sessions.rs | 4 +- .../cluster_sessions_creator.rs | 2 +- .../key_server_cluster/connection_trigger.rs | 4 +- .../connection_trigger_with_migration.rs | 2 +- .../src/key_server_cluster/io/handshake.rs | 6 +- .../src/key_server_cluster/io/message.rs | 12 +- .../src/key_server_cluster/io/read_message.rs | 2 +- .../src/key_server_cluster/io/read_payload.rs | 2 +- .../key_server_cluster/io/write_message.rs | 2 +- .../jobs/consensus_session.rs | 2 +- .../key_server_cluster/jobs/decryption_job.rs | 4 +- .../key_server_cluster/jobs/job_session.rs | 2 +- .../jobs/servers_set_change_access_job.rs | 2 +- .../jobs/signing_job_ecdsa.rs | 6 +- .../jobs/signing_job_schnorr.rs | 2 +- secret-store/src/key_server_cluster/math.rs | 79 ++- .../src/key_server_cluster/message.rs | 6 +- .../src/key_server_cluster/net/connection.rs | 2 +- secret-store/src/key_server_set.rs | 4 +- secret-store/src/key_storage.rs | 4 +- secret-store/src/lib.rs | 3 +- secret-store/src/listener/http_listener.rs | 2 +- secret-store/src/listener/service_contract.rs | 4 +- .../listener/service_contract_aggregate.rs | 2 +- .../src/listener/service_contract_listener.rs | 4 +- secret-store/src/node_key_pair.rs | 4 +- secret-store/src/serialization.rs | 18 +- secret-store/src/traits.rs | 2 +- secret-store/src/types/all.rs | 30 +- secret-store/src/types/error.rs | 12 +- util/network-devp2p/Cargo.toml | 3 +- util/network-devp2p/src/connection.rs | 8 +- util/network-devp2p/src/discovery.rs | 4 +- util/network-devp2p/src/handshake.rs | 5 +- util/network-devp2p/src/host.rs | 2 +- util/network-devp2p/tests/tests.rs | 2 +- util/network/Cargo.toml | 3 +- util/network/src/error.rs | 14 +- util/network/src/lib.rs | 3 +- 176 files changed, 579 insertions(+), 2376 deletions(-) delete mode 100644 accounts/ethkey/src/crypto.rs delete mode 100644 accounts/ethkey/src/error.rs delete mode 100644 accounts/ethkey/src/extended.rs delete mode 100644 accounts/ethkey/src/keccak.rs delete mode 100644 accounts/ethkey/src/keypair.rs delete mode 100644 accounts/ethkey/src/math.rs delete mode 100644 accounts/ethkey/src/random.rs delete mode 100644 accounts/ethkey/src/secret.rs delete mode 100644 accounts/ethkey/src/signature.rs delete mode 100644 accounts/ethstore/src/ethkey.rs diff --git a/Cargo.lock b/Cargo.lock index b00c3553702..291ba89d3ed 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -130,6 +130,11 @@ dependencies = [ "nodrop 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "arrayvec" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "ascii" version = "0.7.1" @@ -174,7 +179,6 @@ dependencies = [ "ethcore-io 1.12.0", "ethereum-types 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "ethjson 0.1.0", - "ethkey 0.3.0", "itertools 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)", "keccak-hash 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -182,6 +186,7 @@ dependencies = [ "lru-cache 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "machine 0.1.0", "macros 0.1.0", + "parity-crypto 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "rlp 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", @@ -203,7 +208,7 @@ version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "backtrace-sys 0.1.24 (registry+https://github.com/rust-lang/crates.io-index)", - "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-demangle 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -214,7 +219,7 @@ name = "backtrace-sys" version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.46 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -251,10 +256,10 @@ dependencies = [ "ethcore-accounts 0.1.0", "ethereum-types 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "ethjson 0.1.0", - "ethkey 0.3.0", "keccak-hash 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "machine 0.1.0", + "parity-crypto 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "rlp 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "spec 0.1.0", @@ -440,7 +445,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "cc" -version = "1.0.28" +version = "1.0.46" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -450,7 +455,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "cfg-if" -version = "0.1.9" +version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -535,13 +540,13 @@ dependencies = [ "ethcore 1.12.0", "ethereum-types 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "ethjson 0.1.0", - "ethkey 0.3.0", "keccak-hash 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "lru-cache 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "machine 0.1.0", "macros 0.1.0", + "parity-crypto 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", "rlp 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -564,7 +569,7 @@ name = "cmake" version = "0.1.35" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.46 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -588,9 +593,9 @@ dependencies = [ "ethcore-io 1.12.0", "ethereum-types 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "ethjson 0.1.0", - "ethkey 0.3.0", "keccak-hash 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-bytes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-crypto 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "parity-snappy 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-util-mem 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "patricia-trie-ethereum 0.1.0", @@ -658,7 +663,7 @@ version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "arrayvec 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", - "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "memoffset 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -683,7 +688,7 @@ name = "crossbeam-utils" version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -878,10 +883,11 @@ dependencies = [ "ethcore-blockchain 0.1.0", "ethcore-builtin 0.1.0", "ethereum-types 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "ethkey 0.3.0", + "ethkey 0.4.0", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "machine 0.1.0", "parity-bytes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-crypto 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "vm 0.1.0", ] @@ -925,17 +931,6 @@ dependencies = [ "backtrace 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "eth-secp256k1" -version = "0.5.7" -source = "git+https://github.com/paritytech/rust-secp256k1#246aefeef6337d208d820936e8e868f11d80e98c" -dependencies = [ - "arrayvec 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", - "cc 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)", - "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "ethabi" version = "9.0.1" @@ -1044,7 +1039,6 @@ dependencies = [ "ethcore-stratum 1.12.0", "ethereum-types 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "ethjson 0.1.0", - "ethkey 0.3.0", "evm 0.1.0", "executive-state 0.1.0", "fetch 0.1.0", @@ -1062,6 +1056,7 @@ dependencies = [ "macros 0.1.0", "memory-cache 0.1.0", "parity-bytes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-crypto 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "parity-runtime 0.1.0", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "patricia-trie-ethereum 0.1.0", @@ -1097,9 +1092,10 @@ name = "ethcore-accounts" version = "0.1.0" dependencies = [ "ethereum-types 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "ethkey 0.3.0", + "ethkey 0.4.0", "ethstore 0.2.1", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-crypto 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.99 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1117,13 +1113,13 @@ dependencies = [ "env_logger 0.5.13 (registry+https://github.com/rust-lang/crates.io-index)", "ethcore-db 0.1.0", "ethereum-types 0.8.0 (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)", "keccak-hash 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "kvdb 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "kvdb-memorydb 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-bytes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-crypto 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "parity-util-mem 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1153,13 +1149,12 @@ dependencies = [ "eip-152 0.1.0", "ethereum-types 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "ethjson 0.1.0", - "ethkey 0.3.0", "hex-literal 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "keccak-hash 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "num 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", "parity-bytes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-crypto 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-crypto 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1278,13 +1273,13 @@ dependencies = [ "ethash 1.12.0", "ethcore-call-contract 0.1.0", "ethereum-types 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "ethkey 0.3.0", "fetch 0.1.0", "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", "hyper 0.12.19 (registry+https://github.com/rust-lang/crates.io-index)", "keccak-hash 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "linked-hash-map 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-crypto 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "parity-runtime 0.1.0", "parity-util-mem 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1308,11 +1303,10 @@ dependencies = [ "derive_more 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", "ethcore-io 1.12.0", "ethereum-types 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "ethkey 0.3.0", "ipnetwork 0.12.8 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-crypto 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-crypto 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "parity-snappy 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "rlp 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1331,7 +1325,6 @@ dependencies = [ "ethcore-io 1.12.0", "ethcore-network 1.12.0", "ethereum-types 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "ethkey 0.3.0", "igd 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "ipnetwork 0.12.8 (registry+https://github.com/rust-lang/crates.io-index)", "keccak-hash 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1340,7 +1333,7 @@ dependencies = [ "lru-cache 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", "parity-bytes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-crypto 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-crypto 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "parity-path 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "parity-snappy 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1373,7 +1366,6 @@ dependencies = [ "ethcore-miner 1.12.0", "ethereum-types 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "ethjson 0.1.0", - "ethkey 0.3.0", "fetch 0.1.0", "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", "hash-db 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1384,7 +1376,7 @@ dependencies = [ "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "machine 0.1.0", "parity-bytes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-crypto 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-crypto 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "parity-util-mem 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "patricia-trie-ethereum 0.1.0", @@ -1422,7 +1414,7 @@ dependencies = [ "ethcore-call-contract 0.1.0", "ethcore-sync 1.12.0", "ethereum-types 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "ethkey 0.3.0", + "ethkey 0.4.0", "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", "hyper 0.12.19 (registry+https://github.com/rust-lang/crates.io-index)", "jsonrpc-server-utils 14.0.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1432,7 +1424,7 @@ dependencies = [ "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-bytes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-crypto 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-crypto 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "parity-runtime 0.1.0", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "percent-encoding 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1503,7 +1495,6 @@ dependencies = [ "ethcore-network-devp2p 1.12.0", "ethcore-private-tx 1.0.0", "ethereum-types 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "ethkey 0.3.0", "fastmap 0.1.0", "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", "keccak-hash 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1512,6 +1503,7 @@ dependencies = [ "machine 0.1.0", "macros 0.1.0", "parity-bytes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-crypto 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "parity-runtime 0.1.0", "parity-util-mem 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1551,22 +1543,14 @@ dependencies = [ [[package]] name = "ethkey" -version = "0.3.0" +version = "0.4.0" dependencies = [ "edit-distance 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "eth-secp256k1 0.5.7 (git+https://github.com/paritytech/rust-secp256k1)", - "ethereum-types 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-crypto 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-crypto 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "parity-wordlist 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.7.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.99 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", - "tiny-keccak 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "zeroize 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1575,8 +1559,9 @@ version = "0.1.0" dependencies = [ "docopt 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.5.13 (registry+https://github.com/rust-lang/crates.io-index)", - "ethkey 0.3.0", + "ethkey 0.4.0", "panic_hook 0.1.0", + "parity-crypto 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "parity-wordlist 1.3.0 (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.99 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1590,12 +1575,12 @@ version = "0.2.1" dependencies = [ "dir 0.1.2", "ethereum-types 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "ethkey 0.3.0", + "ethkey 0.4.0", "itertools 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-crypto 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-crypto 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "parity-wordlist 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1616,9 +1601,11 @@ dependencies = [ "dir 0.1.2", "docopt 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.5.13 (registry+https://github.com/rust-lang/crates.io-index)", + "ethkey 0.4.0", "ethstore 0.2.1", "num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)", "panic_hook 0.1.0", + "parity-crypto 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (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.99 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1680,7 +1667,6 @@ dependencies = [ "env_logger 0.5.13 (registry+https://github.com/rust-lang/crates.io-index)", "ethcore 1.12.0", "ethereum-types 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "ethkey 0.3.0", "evm 0.1.0", "hash-db 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", "keccak-hash 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1689,6 +1675,7 @@ dependencies = [ "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "machine 0.1.0", "parity-bytes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-crypto 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "patricia-trie-ethereum 0.1.0", "pod 0.1.0", "rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1881,7 +1868,7 @@ name = "getrandom" version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", "wasi 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2198,7 +2185,7 @@ name = "jemalloc-sys" version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.46 (registry+https://github.com/rust-lang/crates.io-index)", "fs_extra 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2450,7 +2437,7 @@ name = "libloading" version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.46 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2491,7 +2478,7 @@ name = "log" version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2548,13 +2535,13 @@ dependencies = [ "ethcore-io 1.12.0", "ethereum-types 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "ethjson 0.1.0", - "ethkey 0.3.0", "evm 0.1.0", "keccak-hash 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "lru-cache 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "macros 0.1.0", "parity-bytes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-crypto 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "rlp 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2633,11 +2620,6 @@ name = "memory_units" version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "memzero" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "migration-rocksdb" version = "0.1.0" @@ -2765,7 +2747,7 @@ name = "net2" version = "0.2.33" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2935,21 +2917,26 @@ dependencies = [ [[package]] name = "parity-crypto" -version = "0.4.0" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "aes 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "aes-ctr 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "block-modes 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "digest 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "ethereum-types 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "hmac 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "memzero 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-secp256k1 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "pbkdf2 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", "ripemd160 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "scrypt 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "subtle 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "tiny-keccak 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "zeroize 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2993,7 +2980,7 @@ dependencies = [ "ethcore-service 0.1.0", "ethcore-sync 1.12.0", "ethereum-types 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "ethkey 0.3.0", + "ethkey 0.4.0", "ethstore 0.2.1", "fake-fetch 0.0.1", "fdlimit 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3011,6 +2998,7 @@ dependencies = [ "number_prefix 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", "panic_hook 0.1.0", "parity-bytes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-crypto 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "parity-daemonize 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-hash-fetch 1.12.0", "parity-ipfs-api 1.12.0", @@ -3091,10 +3079,11 @@ version = "0.1.0" dependencies = [ "common-types 0.1.0", "ethcore-io 1.12.0", - "ethkey 0.3.0", + "ethkey 0.4.0", "kvdb 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "kvdb-memorydb 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-crypto 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "rlp 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.99 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3150,7 +3139,7 @@ dependencies = [ "ethcore-sync 1.12.0", "ethereum-types 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "ethjson 0.1.0", - "ethkey 0.3.0", + "ethkey 0.4.0", "ethstore 0.2.1", "fake-fetch 0.0.1", "fastmap 0.1.0", @@ -3170,7 +3159,7 @@ dependencies = [ "multihash 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "order-stat 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "parity-bytes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-crypto 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-crypto 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "parity-runtime 0.1.0", "parity-updater 1.12.0", "parity-version 2.7.0", @@ -3234,6 +3223,17 @@ dependencies = [ "serde 1.0.99 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "parity-secp256k1" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "arrayvec 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.46 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "parity-snappy" version = "0.1.0" @@ -3301,7 +3301,7 @@ name = "parity-util-mem" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "elastic-array 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", "ethereum-types 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "jemallocator 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3376,7 +3376,7 @@ version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "backtrace 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", - "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", "petgraph 0.4.13 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3929,7 +3929,7 @@ name = "ring" version = "0.14.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.46 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", "spin 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4229,7 +4229,7 @@ dependencies = [ "ethcore-db 0.1.0", "ethcore-io 1.12.0", "ethereum-types 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "ethkey 0.3.0", + "ethkey 0.4.0", "hash-db 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", "itertools 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)", "journaldb 0.2.0", @@ -4276,7 +4276,6 @@ dependencies = [ "ethcore-db 0.1.0", "ethcore-io 1.12.0", "ethereum-types 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "ethkey 0.3.0", "hash-db 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", "journaldb 0.2.0", "keccak-hash 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4286,6 +4285,7 @@ dependencies = [ "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-bytes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-crypto 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "parity-snappy 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "patricia-trie-ethereum 0.1.0", @@ -4305,7 +4305,7 @@ name = "socket2" version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", "redox_syscall 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5057,7 +5057,6 @@ dependencies = [ "ethcore-call-contract 0.1.0", "ethereum-types 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "ethjson 0.1.0", - "ethkey 0.3.0", "executive-state 0.1.0", "keccak-hash 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "kvdb 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5066,6 +5065,7 @@ dependencies = [ "machine 0.1.0", "memory-cache 0.1.0", "parity-bytes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-crypto 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "parity-util-mem 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "rlp 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5118,7 +5118,6 @@ dependencies = [ "ethcore-call-contract 0.1.0", "ethcore-io 1.12.0", "ethereum-types 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "ethkey 0.3.0", "keccak-hash 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "len-caching-lock 0.1.1", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5126,6 +5125,7 @@ dependencies = [ "null-engine 0.1.0", "num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)", "parity-bytes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-crypto 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "parity-util-mem 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "rlp 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5322,15 +5322,15 @@ dependencies = [ [[package]] name = "zeroize" -version = "0.9.1" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "zeroize_derive 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "zeroize_derive 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "zeroize_derive" -version = "0.9.0" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5350,6 +5350,7 @@ dependencies = [ "checksum app_dirs 1.2.1 (git+https://github.com/paritytech/app-dirs-rs)" = "" "checksum arrayref 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "0d382e583f07208808f6b1249e60848879ba3543f57c32277bf52d69c2f0f0ee" "checksum arrayvec 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)" = "b8d73f9beda665eaa98ab9e4f7442bd4e7de6652587de55b2525e52e29c1b0ba" +"checksum arrayvec 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cff77d8686867eceff3105329d4698d96c2391c176d5d03adc90c7389162b5b8" "checksum ascii 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3ae7d751998c189c1d4468cf0a39bb2eae052a9c58d50ebb3b9591ee3813ad50" "checksum assert_matches 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7deb0a829ca7bcfaf5da70b073a8d128619259a7be8216a355e23f00763059e5" "checksum attohttpc 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "eaf0ec4b0e00f61ee75556ca027485b7b354f4a714d88cc03f4468abd9378c86" @@ -5380,9 +5381,9 @@ dependencies = [ "checksum bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)" = "206fdffcfa2df7cbe15601ef46c813fce0965eb3286db6b56c583b814b51c81c" "checksum c2-chacha 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7d64d04786e0f528460fc884753cf8dddcc466be308f6026f8e355c41a0e4101" "checksum cast 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "926013f2860c46252efceabb19f4a6b308197505082c609025aa6706c011d427" -"checksum cc 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4a8b715cb4597106ea87c7c84b2f1d452c7492033765df7f32651e66fcf749" +"checksum cc 1.0.46 (registry+https://github.com/rust-lang/crates.io-index)" = "0213d356d3c4ea2c18c40b037c3be23cd639825c18f25ee670ac7813beeef99c" "checksum cesu8 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6d43a04d8753f35258c91f8ec639f792891f748a1edbd759cf1dcea3382ad83c" -"checksum cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "b486ce3ccf7ffd79fdeb678eac06a9e6c09fc88d33836340becb8fffe87c5e33" +"checksum cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" "checksum chrono 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "45912881121cb26fad7c38c17ba7daa18764771836b34fab7d3fbd93ed633878" "checksum cid 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c0e37fba0087d9f3f4e269827a55dc511abf3e440cc097a0c154ff4e6584f988" "checksum clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5067f5bb2d80ef5d68b4c87db81601f0b75bca627bc2ef76b141d7b846a3c6d9" @@ -5418,7 +5419,6 @@ dependencies = [ "checksum env_logger 0.5.13 (registry+https://github.com/rust-lang/crates.io-index)" = "15b0a4d2e39f8420210be8b27eeda28029729e2fd4291019455016c348240c38" "checksum env_logger 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "aafcde04e90a5226a6443b7aabdb016ba2f8307c847d524724bd9b346dd1a2d3" "checksum error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "07e791d3be96241c77c43846b665ef1384606da2cd2a48730abe606a12906e02" -"checksum eth-secp256k1 0.5.7 (git+https://github.com/paritytech/rust-secp256k1)" = "" "checksum ethabi 9.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "965126c64662832991f5a748893577630b558e47fa94e7f35aefcd20d737cef7" "checksum ethabi-contract 9.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "cf407dce0290374bfbb1528493bc14320e663f75856b73a5b76262d8e2cec3c9" "checksum ethabi-derive 9.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "bd0753d4f9e1dba99450da5f2400b20527702ae8ce0309a5f7c239d305539884" @@ -5515,7 +5515,6 @@ dependencies = [ "checksum memoffset 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ce6075db033bbbb7ee5a0bbd3a3186bbae616f57fb001c485c7ff77955f8177f" "checksum memory-db 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a688133a81c915553c1dd9c3e859949f43a854cb8f8773e690e849b53b1f89f0" "checksum memory_units 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "71d96e3f3c0b6325d8ccd83c33b28acb183edcb6c67938ba104ec546854b0882" -"checksum memzero 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "93c0d11ac30a033511ae414355d80f70d9f29a44a49140face477117a1ee90db" "checksum mime 0.3.12 (registry+https://github.com/rust-lang/crates.io-index)" = "0a907b83e7b9e987032439a387e187119cddafc92d5c2aaeb1d92580a793f630" "checksum mime_guess 2.0.0-alpha.6 (registry+https://github.com/rust-lang/crates.io-index)" = "30de2e4613efcba1ec63d8133f344076952090c122992a903359be5a4f99c3ed" "checksum mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)" = "83f51996a3ed004ef184e16818edc51fadffe8e7ca68be67f9dee67d84d0ff23" @@ -5543,12 +5542,13 @@ dependencies = [ "checksum ordermap 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "a86ed3f5f244b372d6b1a00b72ef7f8876d0bc6a78a4c9985c53614041512063" "checksum owning_ref 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "cdf84f41639e037b484f93433aa3897863b561ed65c6e59c7073d7c561710f37" "checksum parity-bytes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fa5168b4cf41f3835e4bc6ffb32f51bc9365dc50cb351904595b3931d917fd0c" -"checksum parity-crypto 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ded773d0b20caeb099708dcfddf85d75d34ecdba80fcdb573a69af334535d51d" +"checksum parity-crypto 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "27a9c2b525c93d717a234eb220c26474f8d97b08ac50d79faeac4cb6c74bf0b9" "checksum parity-daemonize 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "69b1910b2793ff52713fca0a4ee92544ebec59ccd218ea74560be6f947b4ca77" "checksum parity-path 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "5962540f99d3895d9addf535f37ab1397886bc2c68e59efd040ef458e5f8c3f7" "checksum parity-rocksdb 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d17caf6640e24b70242f3f48615e3f0764f98871e8c7aea25584e29833eb5a8" "checksum parity-rocksdb-sys 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)" = "9581e6b8c63f3808500638372ee56faaaffb57c4d349974bff591606b94d5f57" "checksum parity-scale-codec 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "65582b5c02128a4b0fa60fb3e070216e9c84be3e4a8f1b74bc37e15a25e58daf" +"checksum parity-secp256k1 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4fca4f82fccae37e8bbdaeb949a4a218a1bbc485d11598f193d2a908042e5fc1" "checksum parity-snappy 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2c5f9d149b13134b8b354d93a92830efcbee6fe5b73a2e6e540fe70d4dd8a63" "checksum parity-snappy-sys 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1a413d51e5e1927320c9de992998e4a279dffb8c8a7363570198bd8383e66f1b" "checksum parity-tokio-ipc 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8281bf4f1d6429573f89589bf68d89451c46750977a8264f8ea3edbabeba7947" @@ -5741,5 +5741,5 @@ dependencies = [ "checksum xdg 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a66b7c2281ebde13cf4391d70d4c7e5946c3c25e72a7b859ca8f677dcd0b0c61" "checksum xml-rs 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3c1cb601d29fe2c2ac60a2b2e5e293994d87a1f6fa9687a31a15270f909be9c2" "checksum xmltree 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ff8eaee9d17062850f1e6163b509947969242990ee59a35801af437abe041e70" -"checksum zeroize 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "5e2ea4afc22e9497e26b42bf047083c30f7e3ca566f3bcd7187f83d18b327043" -"checksum zeroize_derive 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "afd1469e4bbca3b96606d26ba6e9bd6d3aed3b1299c82b92ec94377d22d78dbc" +"checksum zeroize 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)" = "45af6a010d13e4cf5b54c94ba5a2b2eba5596b9e46bf5875612d332a1f2b3f86" +"checksum zeroize_derive 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)" = "080616bd0e31f36095288bb0acdf1f78ef02c2fa15527d7e993f2a6c7591643e" diff --git a/Cargo.toml b/Cargo.toml index 407f0aa4a69..7783237f054 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -48,6 +48,7 @@ num_cpus = "1.2" number_prefix = "0.2" panic_hook = { path = "util/panic-hook" } parity-bytes = "0.1" +parity-crypto = { version = "0.4.2", features = ["publickey"] } parity-daemonize = "0.3" parity-hash-fetch = { path = "updater/hash-fetch" } parity-ipfs-api = { path = "ipfs" } diff --git a/accounts/Cargo.toml b/accounts/Cargo.toml index a15c5124b04..7e63f9f584c 100644 --- a/accounts/Cargo.toml +++ b/accounts/Cargo.toml @@ -11,6 +11,7 @@ edition = "2018" ethkey = { path = "ethkey" } ethstore = { path = "ethstore" } log = "0.4" +parity-crypto = { version = "0.4.2", features = ["publickey"] } parking_lot = "0.9" serde = "1.0" serde_derive = "1.0" diff --git a/accounts/ethkey/Cargo.toml b/accounts/ethkey/Cargo.toml index fb3716ad08a..8118ad16372 100644 --- a/accounts/ethkey/Cargo.toml +++ b/accounts/ethkey/Cargo.toml @@ -1,21 +1,13 @@ [package] description = "Parity Ethereum Keys Generator" name = "ethkey" -version = "0.3.0" +version = "0.4.0" authors = ["Parity Technologies "] [dependencies] edit-distance = "2.0" -parity-crypto = "0.4.0" -eth-secp256k1 = { git = "https://github.com/paritytech/rust-secp256k1" } -ethereum-types = "0.8.0" -lazy_static = "1.0" log = "0.4" -parity-wordlist = "1.3" -quick-error = "1.2.2" -rand = "0.7" -rustc-hex = "1.0" serde = "1.0" serde_derive = "1.0" -tiny-keccak = "1.4" -zeroize = "0.9.1" +parity-crypto = { version = "0.4.2", features = ["publickey"] } +parity-wordlist = "1.3" diff --git a/accounts/ethkey/cli/Cargo.toml b/accounts/ethkey/cli/Cargo.toml index cb57f05053f..f9e616ce9a5 100644 --- a/accounts/ethkey/cli/Cargo.toml +++ b/accounts/ethkey/cli/Cargo.toml @@ -9,6 +9,7 @@ docopt = "1.0" env_logger = "0.5" ethkey = { path = "../" } panic_hook = { path = "../../../util/panic-hook" } +parity-crypto = { version = "0.4.2", features = ["publickey"] } parity-wordlist="1.2" rustc-hex = "1.0" serde = "1.0" diff --git a/accounts/ethkey/cli/src/main.rs b/accounts/ethkey/cli/src/main.rs index 759f5f484c1..fb87a3dc5fa 100644 --- a/accounts/ethkey/cli/src/main.rs +++ b/accounts/ethkey/cli/src/main.rs @@ -19,6 +19,7 @@ extern crate env_logger; extern crate ethkey; extern crate panic_hook; extern crate parity_wordlist; +extern crate parity_crypto; extern crate rustc_hex; extern crate serde; extern crate threadpool; @@ -30,7 +31,8 @@ use std::num::ParseIntError; use std::{env, fmt, process, io, sync}; use docopt::Docopt; -use ethkey::{KeyPair, Random, Brain, BrainPrefix, Prefix, Error as EthkeyError, Generator, sign, verify_public, verify_address, brain_recover}; +use ethkey::{Brain, BrainPrefix, Prefix, brain_recover}; +use parity_crypto::publickey::{KeyPair, Random, Error as EthkeyError, Generator, sign, verify_public, verify_address}; use rustc_hex::{FromHex, FromHexError}; const USAGE: &'static str = r#" @@ -200,7 +202,7 @@ fn execute(command: I) -> Result where I: IntoIterator(command: I) -> Result where I: IntoIterator(command: I) -> Result where I: IntoIterator. -use keccak::Keccak256; -use super::{KeyPair, Generator, Secret}; +use std::convert::Infallible; +use parity_crypto::publickey::{KeyPair, Generator, Secret}; +use parity_crypto::Keccak256; use parity_wordlist; /// Simple brainwallet. @@ -32,7 +33,7 @@ impl Brain { } impl Generator for Brain { - type Error = ::Void; + type Error = Infallible; fn generate(&mut self) -> Result { let seed = self.0.clone(); @@ -45,7 +46,7 @@ impl Generator for Brain { match i > 16384 { false => i += 1, true => { - if let Ok(pair) = Secret::from_unsafe_slice(&secret) + if let Ok(pair) = Secret::import_key(&secret) .and_then(KeyPair::from_secret) { if pair.address()[0] == 0 { @@ -61,7 +62,8 @@ impl Generator for Brain { #[cfg(test)] mod tests { - use {Brain, Generator}; + use Brain; + use parity_crypto::publickey::Generator; #[test] fn test_brain() { diff --git a/accounts/ethkey/src/brain_prefix.rs b/accounts/ethkey/src/brain_prefix.rs index 436a6594f62..3974d399612 100644 --- a/accounts/ethkey/src/brain_prefix.rs +++ b/accounts/ethkey/src/brain_prefix.rs @@ -14,7 +14,8 @@ // You should have received a copy of the GNU General Public License // along with Parity Ethereum. If not, see . -use super::{Generator, KeyPair, Error, Brain}; +use super::Brain; +use parity_crypto::publickey::{Generator, KeyPair, Error}; use parity_wordlist as wordlist; /// Tries to find brain-seed keypair with address starting with given prefix. @@ -59,7 +60,8 @@ impl Generator for BrainPrefix { #[cfg(test)] mod tests { - use {Generator, BrainPrefix}; + use BrainPrefix; + use parity_crypto::publickey::Generator; #[test] fn prefix_generator() { diff --git a/accounts/ethkey/src/brain_recover.rs b/accounts/ethkey/src/brain_recover.rs index f9922fae97f..e5745d8a4ea 100644 --- a/accounts/ethkey/src/brain_recover.rs +++ b/accounts/ethkey/src/brain_recover.rs @@ -19,7 +19,8 @@ use std::collections::HashSet; use edit_distance::edit_distance; use parity_wordlist; -use super::{Address, Brain, Generator}; +use super::Brain; +use parity_crypto::publickey::{Address, Generator}; /// Tries to find a phrase for address, given the number /// of expected words and a partial phrase. diff --git a/accounts/ethkey/src/crypto.rs b/accounts/ethkey/src/crypto.rs deleted file mode 100644 index c2da84ecb87..00000000000 --- a/accounts/ethkey/src/crypto.rs +++ /dev/null @@ -1,189 +0,0 @@ -// Copyright 2015-2019 Parity Technologies (UK) Ltd. -// This file is part of Parity Ethereum. - -// Parity Ethereum is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Parity Ethereum is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Parity Ethereum. If not, see . - -use secp256k1; -use std::io; -use parity_crypto::error::SymmError; - -quick_error! { - #[derive(Debug)] - pub enum Error { - Secp(e: secp256k1::Error) { - display("secp256k1 error: {}", e) - cause(e) - from() - } - Io(e: io::Error) { - display("i/o error: {}", e) - cause(e) - from() - } - InvalidMessage { - display("invalid message") - } - Symm(e: SymmError) { - cause(e) - from() - } - } -} - -/// ECDH functions -pub mod ecdh { - use secp256k1::{self, ecdh, key}; - use super::Error; - use {Secret, Public, SECP256K1}; - - /// Agree on a shared secret - pub fn agree(secret: &Secret, public: &Public) -> Result { - let context = &SECP256K1; - let pdata = { - let mut temp = [4u8; 65]; - (&mut temp[1..65]).copy_from_slice(&public[0..64]); - temp - }; - - let publ = key::PublicKey::from_slice(context, &pdata)?; - let sec = key::SecretKey::from_slice(context, secret.as_bytes())?; - let shared = ecdh::SharedSecret::new_raw(context, &publ, &sec); - - Secret::from_unsafe_slice(&shared[0..32]) - .map_err(|_| Error::Secp(secp256k1::Error::InvalidSecretKey)) - } -} - -/// ECIES function -pub mod ecies { - use parity_crypto::{aes, digest, hmac, is_equal}; - use ethereum_types::H128; - use super::{ecdh, Error}; - use {Random, Generator, Public, Secret}; - - /// Encrypt a message with a public key, writing an HMAC covering both - /// the plaintext and authenticated data. - /// - /// Authenticated data may be empty. - pub fn encrypt(public: &Public, auth_data: &[u8], plain: &[u8]) -> Result, Error> { - let r = Random.generate()?; - let z = ecdh::agree(r.secret(), public)?; - let mut key = [0u8; 32]; - kdf(&z, &[0u8; 0], &mut key); - - let ekey = &key[0..16]; - let mkey = hmac::SigKey::sha256(&digest::sha256(&key[16..32])); - - let mut msg = vec![0u8; 1 + 64 + 16 + plain.len() + 32]; - msg[0] = 0x04u8; - { - let msgd = &mut msg[1..]; - msgd[0..64].copy_from_slice(r.public().as_bytes()); - let iv = H128::random(); - msgd[64..80].copy_from_slice(iv.as_bytes()); - { - let cipher = &mut msgd[(64 + 16)..(64 + 16 + plain.len())]; - aes::encrypt_128_ctr(ekey, iv.as_bytes(), plain, cipher)?; - } - let mut hmac = hmac::Signer::with(&mkey); - { - let cipher_iv = &msgd[64..(64 + 16 + plain.len())]; - hmac.update(cipher_iv); - } - hmac.update(auth_data); - let sig = hmac.sign(); - msgd[(64 + 16 + plain.len())..].copy_from_slice(&sig); - } - Ok(msg) - } - - /// Decrypt a message with a secret key, checking HMAC for ciphertext - /// and authenticated data validity. - pub fn decrypt(secret: &Secret, auth_data: &[u8], encrypted: &[u8]) -> Result, Error> { - let meta_len = 1 + 64 + 16 + 32; - if encrypted.len() < meta_len || encrypted[0] < 2 || encrypted[0] > 4 { - return Err(Error::InvalidMessage); //invalid message: publickey - } - - let e = &encrypted[1..]; - let p = Public::from_slice(&e[0..64]); - let z = ecdh::agree(secret, &p)?; - let mut key = [0u8; 32]; - kdf(&z, &[0u8; 0], &mut key); - - let ekey = &key[0..16]; - let mkey = hmac::SigKey::sha256(&digest::sha256(&key[16..32])); - - let clen = encrypted.len() - meta_len; - let cipher_with_iv = &e[64..(64+16+clen)]; - let cipher_iv = &cipher_with_iv[0..16]; - let cipher_no_iv = &cipher_with_iv[16..]; - let msg_mac = &e[(64+16+clen)..]; - - // Verify tag - let mut hmac = hmac::Signer::with(&mkey); - hmac.update(cipher_with_iv); - hmac.update(auth_data); - let mac = hmac.sign(); - - if !is_equal(&mac.as_ref()[..], msg_mac) { - return Err(Error::InvalidMessage); - } - - let mut msg = vec![0u8; clen]; - aes::decrypt_128_ctr(ekey, cipher_iv, cipher_no_iv, &mut msg[..])?; - Ok(msg) - } - - fn kdf(secret: &Secret, s1: &[u8], dest: &mut [u8]) { - // SEC/ISO/Shoup specify counter size SHOULD be equivalent - // to size of hash output, however, it also notes that - // the 4 bytes is okay. NIST specifies 4 bytes. - let mut ctr = 1u32; - let mut written = 0usize; - while written < dest.len() { - let mut hasher = digest::Hasher::sha256(); - let ctrs = [(ctr >> 24) as u8, (ctr >> 16) as u8, (ctr >> 8) as u8, ctr as u8]; - hasher.update(&ctrs); - hasher.update(secret.as_bytes()); - hasher.update(s1); - let d = hasher.finish(); - &mut dest[written..(written + 32)].copy_from_slice(&d); - written += 32; - ctr += 1; - } - } -} - -#[cfg(test)] -mod tests { - use super::ecies; - use {Random, Generator}; - - #[test] - fn ecies_shared() { - let kp = Random.generate().unwrap(); - let message = b"So many books, so little time"; - - let shared = b"shared"; - let wrong_shared = b"incorrect"; - let encrypted = ecies::encrypt(kp.public(), shared, message).unwrap(); - assert!(encrypted[..] != message[..]); - assert_eq!(encrypted[0], 0x04); - - assert!(ecies::decrypt(kp.secret(), wrong_shared, &encrypted).is_err()); - let decrypted = ecies::decrypt(kp.secret(), shared, &encrypted).unwrap(); - assert_eq!(decrypted[..message.len()], message[..]); - } -} diff --git a/accounts/ethkey/src/error.rs b/accounts/ethkey/src/error.rs deleted file mode 100644 index ee191157453..00000000000 --- a/accounts/ethkey/src/error.rs +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright 2015-2019 Parity Technologies (UK) Ltd. -// This file is part of Parity Ethereum. - -// Parity Ethereum is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Parity Ethereum is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Parity Ethereum. If not, see . - -use std::{fmt, error}; - -#[derive(Debug)] -/// Crypto error -pub enum Error { - /// Invalid secret key - InvalidSecret, - /// Invalid public key - InvalidPublic, - /// Invalid address - InvalidAddress, - /// Invalid EC signature - InvalidSignature, - /// Invalid AES message - InvalidMessage, - /// IO Error - Io(::std::io::Error), - /// Custom - Custom(String), -} - -impl fmt::Display for Error { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - let msg = match *self { - Error::InvalidSecret => "Invalid secret".into(), - Error::InvalidPublic => "Invalid public".into(), - Error::InvalidAddress => "Invalid address".into(), - Error::InvalidSignature => "Invalid EC signature".into(), - Error::InvalidMessage => "Invalid AES message".into(), - Error::Io(ref err) => format!("I/O error: {}", err), - Error::Custom(ref s) => s.clone(), - }; - - f.write_fmt(format_args!("Crypto error ({})", msg)) - } -} - -impl error::Error for Error { - fn description(&self) -> &str { - "Crypto error" - } -} - -impl Into for Error { - fn into(self) -> String { - format!("{}", self) - } -} - -impl From<::secp256k1::Error> for Error { - fn from(e: ::secp256k1::Error) -> Error { - match e { - ::secp256k1::Error::InvalidMessage => Error::InvalidMessage, - ::secp256k1::Error::InvalidPublicKey => Error::InvalidPublic, - ::secp256k1::Error::InvalidSecretKey => Error::InvalidSecret, - _ => Error::InvalidSignature, - } - } -} - -impl From<::std::io::Error> for Error { - fn from(err: ::std::io::Error) -> Error { - Error::Io(err) - } -} diff --git a/accounts/ethkey/src/extended.rs b/accounts/ethkey/src/extended.rs deleted file mode 100644 index 005f4ba6616..00000000000 --- a/accounts/ethkey/src/extended.rs +++ /dev/null @@ -1,517 +0,0 @@ -// Copyright 2015-2019 Parity Technologies (UK) Ltd. -// This file is part of Parity Ethereum. - -// Parity Ethereum is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Parity Ethereum is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Parity Ethereum. If not, see . - -//! Extended keys - -use secret::Secret; -use Public; -use ethereum_types::H256; -pub use self::derivation::Error as DerivationError; - -/// Represents label that can be stored as a part of key derivation -pub trait Label { - /// Length of the data that label occupies - fn len() -> usize; - - /// Store label data to the key derivation sequence - /// Must not use more than `len()` bytes from slice - fn store(&self, target: &mut [u8]); -} - -impl Label for u32 { - fn len() -> usize { 4 } - - fn store(&self, target: &mut [u8]) { - let bytes = self.to_be_bytes(); - target[0..4].copy_from_slice(&bytes); - } -} - -/// Key derivation over generic label `T` -pub enum Derivation { - /// Soft key derivation (allow proof of parent) - Soft(T), - /// Hard key derivation (does not allow proof of parent) - Hard(T), -} - -impl From for Derivation { - fn from(index: u32) -> Self { - if index < (2 << 30) { - Derivation::Soft(index) - } - else { - Derivation::Hard(index) - } - } -} - -impl Label for H256 { - fn len() -> usize { 32 } - - fn store(&self, target: &mut [u8]) { - (&mut target[0..32]).copy_from_slice(self.as_bytes()); - } -} - -/// Extended secret key, allows deterministic derivation of subsequent keys. -pub struct ExtendedSecret { - secret: Secret, - chain_code: H256, -} - -impl ExtendedSecret { - /// New extended key from given secret and chain code. - pub fn with_code(secret: Secret, chain_code: H256) -> ExtendedSecret { - ExtendedSecret { - secret: secret, - chain_code: chain_code, - } - } - - /// New extended key from given secret with the random chain code. - pub fn new_random(secret: Secret) -> ExtendedSecret { - ExtendedSecret::with_code(secret, H256::random()) - } - - /// New extended key from given secret. - /// Chain code will be derived from the secret itself (in a deterministic way). - pub fn new(secret: Secret) -> ExtendedSecret { - let chain_code = derivation::chain_code(*secret); - ExtendedSecret::with_code(secret, chain_code) - } - - /// Derive new private key - pub fn derive(&self, index: Derivation) -> ExtendedSecret where T: Label { - let (derived_key, next_chain_code) = derivation::private(*self.secret, self.chain_code, index); - - let derived_secret = Secret::from(derived_key.0); - - ExtendedSecret::with_code(derived_secret, next_chain_code) - } - - /// Private key component of the extended key. - pub fn as_raw(&self) -> &Secret { - &self.secret - } -} - -/// Extended public key, allows deterministic derivation of subsequent keys. -pub struct ExtendedPublic { - public: Public, - chain_code: H256, -} - -impl ExtendedPublic { - /// New extended public key from known parent and chain code - pub fn new(public: Public, chain_code: H256) -> Self { - ExtendedPublic { public: public, chain_code: chain_code } - } - - /// Create new extended public key from known secret - pub fn from_secret(secret: &ExtendedSecret) -> Result { - Ok( - ExtendedPublic::new( - derivation::point(**secret.as_raw())?, - secret.chain_code.clone(), - ) - ) - } - - /// Derive new public key - /// Operation is defined only for index belongs [0..2^31) - pub fn derive(&self, index: Derivation) -> Result where T: Label { - let (derived_key, next_chain_code) = derivation::public(self.public, self.chain_code, index)?; - Ok(ExtendedPublic::new(derived_key, next_chain_code)) - } - - pub fn public(&self) -> &Public { - &self.public - } -} - -pub struct ExtendedKeyPair { - secret: ExtendedSecret, - public: ExtendedPublic, -} - -impl ExtendedKeyPair { - pub fn new(secret: Secret) -> Self { - let extended_secret = ExtendedSecret::new(secret); - let extended_public = ExtendedPublic::from_secret(&extended_secret) - .expect("Valid `Secret` always produces valid public; qed"); - ExtendedKeyPair { - secret: extended_secret, - public: extended_public, - } - } - - pub fn with_code(secret: Secret, public: Public, chain_code: H256) -> Self { - ExtendedKeyPair { - secret: ExtendedSecret::with_code(secret, chain_code.clone()), - public: ExtendedPublic::new(public, chain_code), - } - } - - pub fn with_secret(secret: Secret, chain_code: H256) -> Self { - let extended_secret = ExtendedSecret::with_code(secret, chain_code); - let extended_public = ExtendedPublic::from_secret(&extended_secret) - .expect("Valid `Secret` always produces valid public; qed"); - ExtendedKeyPair { - secret: extended_secret, - public: extended_public, - } - } - - pub fn with_seed(seed: &[u8]) -> Result { - let (master_key, chain_code) = derivation::seed_pair(seed); - Ok(ExtendedKeyPair::with_secret( - Secret::from_unsafe_slice(master_key.as_bytes()).map_err(|_| DerivationError::InvalidSeed)?, - chain_code, - )) - } - - pub fn secret(&self) -> &ExtendedSecret { - &self.secret - } - - pub fn public(&self) -> &ExtendedPublic { - &self.public - } - - pub fn derive(&self, index: Derivation) -> Result where T: Label { - let derived = self.secret.derive(index); - - Ok(ExtendedKeyPair { - public: ExtendedPublic::from_secret(&derived)?, - secret: derived, - }) - } -} - -// Derivation functions for private and public keys -// Work is based on BIP0032 -// https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki -mod derivation { - use parity_crypto::hmac; - use ethereum_types::{BigEndianHash, U256, U512, H512, H256}; - use secp256k1::key::{SecretKey, PublicKey}; - use SECP256K1; - use keccak; - use math::curve_order; - use super::{Label, Derivation}; - use std::convert::TryInto; - - #[derive(Debug)] - pub enum Error { - InvalidHardenedUse, - InvalidPoint, - MissingIndex, - InvalidSeed, - } - - // Deterministic derivation of the key using secp256k1 elliptic curve. - // Derivation can be either hardened or not. - // For hardened derivation, pass u32 index at least 2^31 or custom Derivation::Hard(T) enum - // - // Can panic if passed `private_key` is not a valid secp256k1 private key - // (outside of (0..curve_order()]) field - pub fn private(private_key: H256, chain_code: H256, index: Derivation) -> (H256, H256) where T: Label { - match index { - Derivation::Soft(index) => private_soft(private_key, chain_code, index), - Derivation::Hard(index) => private_hard(private_key, chain_code, index), - } - } - - fn hmac_pair(data: &[u8], private_key: H256, chain_code: H256) -> (H256, H256) { - let private: U256 = private_key.into_uint(); - - // produces 512-bit derived hmac (I) - let skey = hmac::SigKey::sha512(chain_code.as_bytes()); - let i_512 = hmac::sign(&skey, &data[..]); - - // left most 256 bits are later added to original private key - let hmac_key: U256 = H256::from_slice(&i_512[0..32]).into_uint(); - // right most 256 bits are new chain code for later derivations - let next_chain_code = H256::from_slice(&i_512[32..64]); - - let child_key = BigEndianHash::from_uint(&private_add(hmac_key, private)); - (child_key, next_chain_code) - } - - // Can panic if passed `private_key` is not a valid secp256k1 private key - // (outside of (0..curve_order()]) field - fn private_soft(private_key: H256, chain_code: H256, index: T) -> (H256, H256) where T: Label { - let mut data = vec![0u8; 33 + T::len()]; - - let sec_private = SecretKey::from_slice(&SECP256K1, private_key.as_bytes()) - .expect("Caller should provide valid private key"); - let sec_public = PublicKey::from_secret_key(&SECP256K1, &sec_private) - .expect("Caller should provide valid private key"); - let public_serialized = sec_public.serialize_vec(&SECP256K1, true); - - // curve point (compressed public key) -- index - // 0.33 -- 33..end - data[0..33].copy_from_slice(&public_serialized); - index.store(&mut data[33..]); - - hmac_pair(&data, private_key, chain_code) - } - - // Deterministic derivation of the key using secp256k1 elliptic curve - // This is hardened derivation and does not allow to associate - // corresponding public keys of the original and derived private keys - fn private_hard(private_key: H256, chain_code: H256, index: T) -> (H256, H256) where T: Label { - let mut data: Vec = vec![0u8; 33 + T::len()]; - let private: U256 = private_key.into_uint(); - - // 0x00 (padding) -- private_key -- index - // 0 -- 1..33 -- 33..end - private.to_big_endian(&mut data[1..33]); - index.store(&mut data[33..(33 + T::len())]); - - hmac_pair(&data, private_key, chain_code) - } - - fn private_add(k1: U256, k2: U256) -> U256 { - let sum = U512::from(k1) + U512::from(k2); - modulo(sum, curve_order()) - } - - // todo: surely can be optimized - fn modulo(u1: U512, u2: U256) -> U256 { - let m = u1 % U512::from(u2); - m.try_into().expect("U512 modulo U256 should fit into U256; qed") - } - - pub fn public(public_key: H512, chain_code: H256, derivation: Derivation) -> Result<(H512, H256), Error> where T: Label { - let index = match derivation { - Derivation::Soft(index) => index, - Derivation::Hard(_) => { return Err(Error::InvalidHardenedUse); } - }; - - let mut public_sec_raw = [0u8; 65]; - public_sec_raw[0] = 4; - public_sec_raw[1..65].copy_from_slice(public_key.as_bytes()); - let public_sec = PublicKey::from_slice(&SECP256K1, &public_sec_raw).map_err(|_| Error::InvalidPoint)?; - let public_serialized = public_sec.serialize_vec(&SECP256K1, true); - - let mut data = vec![0u8; 33 + T::len()]; - // curve point (compressed public key) -- index - // 0.33 -- 33..end - data[0..33].copy_from_slice(&public_serialized); - index.store(&mut data[33..(33 + T::len())]); - - // HMAC512SHA produces [derived private(256); new chain code(256)] - let skey = hmac::SigKey::sha512(chain_code.as_bytes()); - let i_512 = hmac::sign(&skey, &data[..]); - - let new_private = H256::from_slice(&i_512[0..32]); - let new_chain_code = H256::from_slice(&i_512[32..64]); - - // Generated private key can (extremely rarely) be out of secp256k1 key field - if curve_order() <= new_private.into_uint() { return Err(Error::MissingIndex); } - let new_private_sec = SecretKey::from_slice(&SECP256K1, new_private.as_bytes()) - .expect("Private key belongs to the field [0..CURVE_ORDER) (checked above); So initializing can never fail; qed"); - let mut new_public = PublicKey::from_secret_key(&SECP256K1, &new_private_sec) - .expect("Valid private key produces valid public key"); - - // Adding two points on the elliptic curves (combining two public keys) - new_public.add_assign(&SECP256K1, &public_sec) - .expect("Addition of two valid points produce valid point"); - - let serialized = new_public.serialize_vec(&SECP256K1, false); - - Ok(( - H512::from_slice(&serialized[1..65]), - new_chain_code, - )) - } - - fn sha3(slc: &[u8]) -> H256 { - keccak::Keccak256::keccak256(slc).into() - } - - pub fn chain_code(secret: H256) -> H256 { - // 10,000 rounds of sha3 - let mut running_sha3 = sha3(secret.as_bytes()); - for _ in 0..99999 { running_sha3 = sha3(running_sha3.as_bytes()); } - running_sha3 - } - - pub fn point(secret: H256) -> Result { - let sec = SecretKey::from_slice(&SECP256K1, secret.as_bytes()) - .map_err(|_| Error::InvalidPoint)?; - let public_sec = PublicKey::from_secret_key(&SECP256K1, &sec) - .map_err(|_| Error::InvalidPoint)?; - let serialized = public_sec.serialize_vec(&SECP256K1, false); - Ok(H512::from_slice(&serialized[1..65])) - } - - pub fn seed_pair(seed: &[u8]) -> (H256, H256) { - let skey = hmac::SigKey::sha512(b"Bitcoin seed"); - let i_512 = hmac::sign(&skey, seed); - - let master_key = H256::from_slice(&i_512[0..32]); - let chain_code = H256::from_slice(&i_512[32..64]); - - (master_key, chain_code) - } -} - -#[cfg(test)] -mod tests { - use super::{ExtendedSecret, ExtendedPublic, ExtendedKeyPair}; - use secret::Secret; - use std::str::FromStr; - use ethereum_types::{H128, H256, H512}; - use super::{derivation, Derivation}; - - fn master_chain_basic() -> (H256, H256) { - let seed = H128::from_str("000102030405060708090a0b0c0d0e0f") - .expect("Seed should be valid H128") - .as_bytes() - .to_vec(); - - derivation::seed_pair(&*seed) - } - - fn test_extended(f: F, test_private: H256) where F: Fn(ExtendedSecret) -> ExtendedSecret { - let (private_seed, chain_code) = master_chain_basic(); - let extended_secret = ExtendedSecret::with_code(Secret::from(private_seed.0), chain_code); - let derived = f(extended_secret); - assert_eq!(**derived.as_raw(), test_private); - } - - #[test] - fn smoky() { - let secret = Secret::from_str("a100df7a048e50ed308ea696dc600215098141cb391e9527329df289f9383f65").unwrap(); - let extended_secret = ExtendedSecret::with_code(secret.clone(), H256::zero()); - - // hardened - assert_eq!(&**extended_secret.as_raw(), &*secret); - assert_eq!( - **extended_secret.derive(2147483648.into()).as_raw(), - H256::from_str("0927453daed47839608e414a3738dfad10aed17c459bbd9ab53f89b026c834b6").unwrap(), - ); - assert_eq!( - **extended_secret.derive(2147483649.into()).as_raw(), - H256::from_str("44238b6a29c6dcbe9b401364141ba11e2198c289a5fed243a1c11af35c19dc0f").unwrap(), - ); - - // normal - assert_eq!(**extended_secret.derive(0.into()).as_raw(), H256::from_str("bf6a74e3f7b36fc4c96a1e12f31abc817f9f5904f5a8fc27713163d1f0b713f6").unwrap()); - assert_eq!(**extended_secret.derive(1.into()).as_raw(), H256::from_str("bd4fca9eb1f9c201e9448c1eecd66e302d68d4d313ce895b8c134f512205c1bc").unwrap()); - assert_eq!(**extended_secret.derive(2.into()).as_raw(), H256::from_str("86932b542d6cab4d9c65490c7ef502d89ecc0e2a5f4852157649e3251e2a3268").unwrap()); - - let extended_public = ExtendedPublic::from_secret(&extended_secret).expect("Extended public should be created"); - let derived_public = extended_public.derive(0.into()).expect("First derivation of public should succeed"); - assert_eq!( - *derived_public.public(), - H512::from_str("f7b3244c96688f92372bfd4def26dc4151529747bab9f188a4ad34e141d47bd66522ff048bc6f19a0a4429b04318b1a8796c000265b4fa200dae5f6dda92dd94").unwrap(), - ); - - let keypair = ExtendedKeyPair::with_secret( - Secret::from_str("a100df7a048e50ed308ea696dc600215098141cb391e9527329df289f9383f65").unwrap(), - H256::from_low_u64_be(64), - ); - assert_eq!( - **keypair.derive(2147483648u32.into()).expect("Derivation of keypair should succeed").secret().as_raw(), - H256::from_str("edef54414c03196557cf73774bc97a645c9a1df2164ed34f0c2a78d1375a930c").unwrap(), - ); - } - - #[test] - fn h256_soft_match() { - let secret = Secret::from_str("a100df7a048e50ed308ea696dc600215098141cb391e9527329df289f9383f65").unwrap(); - let derivation_secret = H256::from_str("51eaf04f9dbbc1417dc97e789edd0c37ecda88bac490434e367ea81b71b7b015").unwrap(); - - let extended_secret = ExtendedSecret::with_code(secret.clone(), H256::zero()); - let extended_public = ExtendedPublic::from_secret(&extended_secret).expect("Extended public should be created"); - - let derived_secret0 = extended_secret.derive(Derivation::Soft(derivation_secret)); - let derived_public0 = extended_public.derive(Derivation::Soft(derivation_secret)).expect("First derivation of public should succeed"); - - let public_from_secret0 = ExtendedPublic::from_secret(&derived_secret0).expect("Extended public should be created"); - - assert_eq!(public_from_secret0.public(), derived_public0.public()); - } - - #[test] - fn h256_hard() { - let secret = Secret::from_str("a100df7a048e50ed308ea696dc600215098141cb391e9527329df289f9383f65").unwrap(); - let derivation_secret = H256::from_str("51eaf04f9dbbc1417dc97e789edd0c37ecda88bac490434e367ea81b71b7b015").unwrap(); - let extended_secret = ExtendedSecret::with_code(secret.clone(), H256::from_low_u64_be(1)); - - assert_eq!( - **extended_secret.derive(Derivation::Hard(derivation_secret)).as_raw(), - H256::from_str("2bc2d696fb744d77ff813b4a1ef0ad64e1e5188b622c54ba917acc5ebc7c5486").unwrap(), - ); - } - - #[test] - fn match_() { - let secret = Secret::from_str("a100df7a048e50ed308ea696dc600215098141cb391e9527329df289f9383f65").unwrap(); - let extended_secret = ExtendedSecret::with_code(secret.clone(), H256::from_low_u64_be(1)); - let extended_public = ExtendedPublic::from_secret(&extended_secret).expect("Extended public should be created"); - - let derived_secret0 = extended_secret.derive(0.into()); - let derived_public0 = extended_public.derive(0.into()).expect("First derivation of public should succeed"); - - let public_from_secret0 = ExtendedPublic::from_secret(&derived_secret0).expect("Extended public should be created"); - - assert_eq!(public_from_secret0.public(), derived_public0.public()); - } - - #[test] - fn test_seeds() { - let seed = H128::from_str("000102030405060708090a0b0c0d0e0f") - .expect("Seed should be valid H128") - .as_bytes() - .to_vec(); - - // private key from bitcoin test vector - // xprv9wTYmMFdV23N2TdNG573QoEsfRrWKQgWeibmLntzniatZvR9BmLnvSxqu53Kw1UmYPxLgboyZQaXwTCg8MSY3H2EU4pWcQDnRnrVA1xe8fs - let test_private = H256::from_str("e8f32e723decf4051aefac8e2c93c9c5b214313817cdb01a1494b917c8436b35") - .expect("Private should be decoded ok"); - - let (private_seed, _) = derivation::seed_pair(&*seed); - - assert_eq!(private_seed, test_private); - } - - #[test] - fn test_vector_1() { - // xprv9uHRZZhk6KAJC1avXpDAp4MDc3sQKNxDiPvvkX8Br5ngLNv1TxvUxt4cV1rGL5hj6KCesnDYUhd7oWgT11eZG7XnxHrnYeSvkzY7d2bhkJ7 - // H(0) - test_extended( - |secret| secret.derive(2147483648.into()), - H256::from_str("edb2e14f9ee77d26dd93b4ecede8d16ed408ce149b6cd80b0715a2d911a0afea") - .expect("Private should be decoded ok") - ); - } - - #[test] - fn test_vector_2() { - // xprv9wTYmMFdV23N2TdNG573QoEsfRrWKQgWeibmLntzniatZvR9BmLnvSxqu53Kw1UmYPxLgboyZQaXwTCg8MSY3H2EU4pWcQDnRnrVA1xe8fs - // H(0)/1 - test_extended( - |secret| secret.derive(2147483648.into()).derive(1.into()), - H256::from_str("3c6cb8d0f6a264c91ea8b5030fadaa8e538b020f0a387421a12de9319dc93368") - .expect("Private should be decoded ok") - ); - } -} diff --git a/accounts/ethkey/src/keccak.rs b/accounts/ethkey/src/keccak.rs deleted file mode 100644 index 202c211933c..00000000000 --- a/accounts/ethkey/src/keccak.rs +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2015-2019 Parity Technologies (UK) Ltd. -// This file is part of Parity Ethereum. - -// Parity Ethereum is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Parity Ethereum is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Parity Ethereum. If not, see . - -use tiny_keccak::Keccak; - -pub trait Keccak256 { - fn keccak256(&self) -> T where T: Sized; -} - -impl Keccak256<[u8; 32]> for [u8] { - fn keccak256(&self) -> [u8; 32] { - let mut keccak = Keccak::new_keccak256(); - let mut result = [0u8; 32]; - keccak.update(self); - keccak.finalize(&mut result); - result - } -} diff --git a/accounts/ethkey/src/keypair.rs b/accounts/ethkey/src/keypair.rs deleted file mode 100644 index 7b350788bb5..00000000000 --- a/accounts/ethkey/src/keypair.rs +++ /dev/null @@ -1,114 +0,0 @@ -// Copyright 2015-2019 Parity Technologies (UK) Ltd. -// This file is part of Parity Ethereum. - -// Parity Ethereum is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Parity Ethereum is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Parity Ethereum. If not, see . - -use std::fmt; -use secp256k1::key; -use super::{Secret, Public, Address, SECP256K1, Error}; -use parity_crypto::Keccak256 as _; - -pub fn public_to_address(public: &Public) -> Address { - let hash = public.keccak256(); - let mut result = Address::zero(); - result.as_bytes_mut().copy_from_slice(&hash[12..]); - result -} - -#[derive(Debug, Clone, PartialEq)] -/// secp256k1 key pair -pub struct KeyPair { - secret: Secret, - public: Public, -} - -impl fmt::Display for KeyPair { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - writeln!(f, "secret: {:x}", self.secret)?; - writeln!(f, "public: {:x}", self.public)?; - write!(f, "address: {:x}", self.address()) - } -} - -impl KeyPair { - /// Create a pair from secret key - pub fn from_secret(secret: Secret) -> Result { - let context = &SECP256K1; - let s: key::SecretKey = key::SecretKey::from_slice(context, &secret[..])?; - let pub_key = key::PublicKey::from_secret_key(context, &s)?; - let serialized = pub_key.serialize_vec(context, false); - - let mut public = Public::default(); - public.as_bytes_mut().copy_from_slice(&serialized[1..65]); - - let keypair = KeyPair { - secret: secret, - public: public, - }; - - Ok(keypair) - } - - pub fn from_secret_slice(slice: &[u8]) -> Result { - Self::from_secret(Secret::from_unsafe_slice(slice)?) - } - - pub fn from_keypair(sec: key::SecretKey, publ: key::PublicKey) -> Self { - let context = &SECP256K1; - let serialized = publ.serialize_vec(context, false); - let secret = Secret::from(sec); - let mut public = Public::default(); - public.as_bytes_mut().copy_from_slice(&serialized[1..65]); - - KeyPair { - secret: secret, - public: public, - } - } - - pub fn secret(&self) -> &Secret { - &self.secret - } - - pub fn public(&self) -> &Public { - &self.public - } - - pub fn address(&self) -> Address { - public_to_address(&self.public) - } -} - -#[cfg(test)] -mod tests { - use std::str::FromStr; - use {KeyPair, Secret}; - - #[test] - fn from_secret() { - let secret = Secret::from_str("a100df7a048e50ed308ea696dc600215098141cb391e9527329df289f9383f65").unwrap(); - let _ = KeyPair::from_secret(secret).unwrap(); - } - - #[test] - fn keypair_display() { - let expected = -"secret: a100df7a048e50ed308ea696dc600215098141cb391e9527329df289f9383f65 -public: 8ce0db0b0359ffc5866ba61903cc2518c3675ef2cf380a7e54bde7ea20e6fa1ab45b7617346cd11b7610001ee6ae5b0155c41cad9527cbcdff44ec67848943a4 -address: 5b073e9233944b5e729e46d618f0d8edf3d9c34a".to_owned(); - let secret = Secret::from_str("a100df7a048e50ed308ea696dc600215098141cb391e9527329df289f9383f65").unwrap(); - let kp = KeyPair::from_secret(secret).unwrap(); - assert_eq!(format!("{}", kp), expected); - } -} diff --git a/accounts/ethkey/src/lib.rs b/accounts/ethkey/src/lib.rs index 4f55f056d07..185d254ba67 100644 --- a/accounts/ethkey/src/lib.rs +++ b/accounts/ethkey/src/lib.rs @@ -18,19 +18,9 @@ extern crate edit_distance; extern crate parity_crypto; -extern crate ethereum_types; extern crate parity_wordlist; -#[macro_use] -extern crate quick_error; -extern crate rand; -extern crate rustc_hex; -extern crate secp256k1; extern crate serde; -extern crate tiny_keccak; -extern crate zeroize; -#[macro_use] -extern crate lazy_static; #[macro_use] extern crate log; #[macro_use] @@ -38,50 +28,13 @@ extern crate serde_derive; mod brain; mod brain_prefix; -mod error; -mod keypair; -mod keccak; mod password; mod prefix; -mod random; -mod signature; -mod secret; -mod extended; pub mod brain_recover; -pub mod crypto; -pub mod math; pub use self::parity_wordlist::Error as WordlistError; pub use self::brain::Brain; pub use self::brain_prefix::BrainPrefix; -pub use self::error::Error; -pub use self::keypair::{KeyPair, public_to_address}; -pub use self::math::public_is_valid; pub use self::password::Password; -pub use self::prefix::Prefix; -pub use self::random::Random; -pub use self::signature::{sign, verify_public, verify_address, recover, Signature}; -pub use self::secret::Secret; -pub use self::extended::{ExtendedPublic, ExtendedSecret, ExtendedKeyPair, DerivationError, Derivation}; - -use ethereum_types::H256; - -pub use ethereum_types::{Address, Public}; -pub type Message = H256; - -lazy_static! { - pub static ref SECP256K1: secp256k1::Secp256k1 = secp256k1::Secp256k1::new(); -} - -/// Uninstantiatable error type for infallible generators. -#[derive(Debug)] -pub enum Void {} - -/// Generates new keypair. -pub trait Generator { - type Error; - - /// Should be called to generate new keypair. - fn generate(&mut self) -> Result; -} +pub use self::prefix::Prefix; \ No newline at end of file diff --git a/accounts/ethkey/src/math.rs b/accounts/ethkey/src/math.rs deleted file mode 100644 index 5025efeb654..00000000000 --- a/accounts/ethkey/src/math.rs +++ /dev/null @@ -1,129 +0,0 @@ -// Copyright 2015-2019 Parity Technologies (UK) Ltd. -// This file is part of Parity Ethereum. - -// Parity Ethereum is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Parity Ethereum is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Parity Ethereum. If not, see . - -use super::{SECP256K1, Public, Secret, Error}; -use secp256k1::key; -use secp256k1::constants::{GENERATOR_X, GENERATOR_Y, CURVE_ORDER}; -use ethereum_types::{BigEndianHash as _, U256, H256}; - -/// Whether the public key is valid. -pub fn public_is_valid(public: &Public) -> bool { - to_secp256k1_public(public).ok() - .map_or(false, |p| p.is_valid()) -} - -/// Inplace multiply public key by secret key (EC point * scalar) -pub fn public_mul_secret(public: &mut Public, secret: &Secret) -> Result<(), Error> { - let key_secret = secret.to_secp256k1_secret()?; - let mut key_public = to_secp256k1_public(public)?; - key_public.mul_assign(&SECP256K1, &key_secret)?; - set_public(public, &key_public); - Ok(()) -} - -/// Inplace add one public key to another (EC point + EC point) -pub fn public_add(public: &mut Public, other: &Public) -> Result<(), Error> { - let mut key_public = to_secp256k1_public(public)?; - let other_public = to_secp256k1_public(other)?; - key_public.add_assign(&SECP256K1, &other_public)?; - set_public(public, &key_public); - Ok(()) -} - -/// Inplace sub one public key from another (EC point - EC point) -pub fn public_sub(public: &mut Public, other: &Public) -> Result<(), Error> { - let mut key_neg_other = to_secp256k1_public(other)?; - key_neg_other.mul_assign(&SECP256K1, &key::MINUS_ONE_KEY)?; - - let mut key_public = to_secp256k1_public(public)?; - key_public.add_assign(&SECP256K1, &key_neg_other)?; - set_public(public, &key_public); - Ok(()) -} - -/// Replace public key with its negation (EC point = - EC point) -pub fn public_negate(public: &mut Public) -> Result<(), Error> { - let mut key_public = to_secp256k1_public(public)?; - key_public.mul_assign(&SECP256K1, &key::MINUS_ONE_KEY)?; - set_public(public, &key_public); - Ok(()) -} - -/// Return base point of secp256k1 -pub fn generation_point() -> Public { - let mut public_sec_raw = [0u8; 65]; - public_sec_raw[0] = 4; - public_sec_raw[1..33].copy_from_slice(&GENERATOR_X); - public_sec_raw[33..65].copy_from_slice(&GENERATOR_Y); - - let public_key = key::PublicKey::from_slice(&SECP256K1, &public_sec_raw) - .expect("constructing using predefined constants; qed"); - let mut public = Public::default(); - set_public(&mut public, &public_key); - public -} - -/// Return secp256k1 elliptic curve order -pub fn curve_order() -> U256 { - H256::from_slice(&CURVE_ORDER).into_uint() -} - -fn to_secp256k1_public(public: &Public) -> Result { - let public_data = { - let mut temp = [4u8; 65]; - (&mut temp[1..65]).copy_from_slice(&public[0..64]); - temp - }; - - Ok(key::PublicKey::from_slice(&SECP256K1, &public_data)?) -} - -fn set_public(public: &mut Public, key_public: &key::PublicKey) { - let key_public_serialized = key_public.serialize_vec(&SECP256K1, false); - public.as_bytes_mut().copy_from_slice(&key_public_serialized[1..65]); -} - -#[cfg(test)] -mod tests { - use super::super::{Random, Generator}; - use super::{public_add, public_sub}; - - #[test] - fn public_addition_is_commutative() { - let public1 = Random.generate().unwrap().public().clone(); - let public2 = Random.generate().unwrap().public().clone(); - - let mut left = public1.clone(); - public_add(&mut left, &public2).unwrap(); - - let mut right = public2.clone(); - public_add(&mut right, &public1).unwrap(); - - assert_eq!(left, right); - } - - #[test] - fn public_addition_is_reversible_with_subtraction() { - let public1 = Random.generate().unwrap().public().clone(); - let public2 = Random.generate().unwrap().public().clone(); - - let mut sum = public1.clone(); - public_add(&mut sum, &public2).unwrap(); - public_sub(&mut sum, &public2).unwrap(); - - assert_eq!(sum, public1); - } -} diff --git a/accounts/ethkey/src/prefix.rs b/accounts/ethkey/src/prefix.rs index 32d92c1862c..0a595de42c3 100644 --- a/accounts/ethkey/src/prefix.rs +++ b/accounts/ethkey/src/prefix.rs @@ -14,7 +14,7 @@ // You should have received a copy of the GNU General Public License // along with Parity Ethereum. If not, see . -use super::{Random, Generator, KeyPair, Error}; +use parity_crypto::publickey::{Random, Generator, KeyPair, Error}; /// Tries to find keypair with address starting with given prefix. pub struct Prefix { @@ -48,7 +48,8 @@ impl Generator for Prefix { #[cfg(test)] mod tests { - use {Generator, Prefix}; + use Prefix; + use parity_crypto::publickey::Generator; #[test] fn prefix_generator() { diff --git a/accounts/ethkey/src/random.rs b/accounts/ethkey/src/random.rs deleted file mode 100644 index 08ccd2624c4..00000000000 --- a/accounts/ethkey/src/random.rs +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright 2015-2019 Parity Technologies (UK) Ltd. -// This file is part of Parity Ethereum. - -// Parity Ethereum is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Parity Ethereum is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Parity Ethereum. If not, see . - -use rand::rngs::OsRng; -use super::{Generator, KeyPair, SECP256K1}; - -/// Randomly generates new keypair, instantiating the RNG each time. -pub struct Random; - -impl Generator for Random { - type Error = std::io::Error; - - fn generate(&mut self) -> Result { - Generator::generate(&mut OsRng).map_err(|void| { - match void {} // LLVM unreachable - }) - } -} - -impl Generator for OsRng { - type Error = ::Void; - - fn generate(&mut self) -> Result { - let (sec, publ) = SECP256K1.generate_keypair(self) - .expect("context always created with full capabilities; qed"); - - Ok(KeyPair::from_keypair(sec, publ)) - } -} diff --git a/accounts/ethkey/src/secret.rs b/accounts/ethkey/src/secret.rs deleted file mode 100644 index c850fa70ee8..00000000000 --- a/accounts/ethkey/src/secret.rs +++ /dev/null @@ -1,304 +0,0 @@ -// Copyright 2015-2019 Parity Technologies (UK) Ltd. -// This file is part of Parity Ethereum. - -// Parity Ethereum is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Parity Ethereum is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Parity Ethereum. If not, see . - -use std::fmt; -use std::ops::Deref; -use std::str::FromStr; -use rustc_hex::ToHex; -use secp256k1::constants::{SECRET_KEY_SIZE as SECP256K1_SECRET_KEY_SIZE}; -use secp256k1::key; -use ethereum_types::H256; -use zeroize::Zeroize; -use {Error, SECP256K1}; - -#[derive(Clone, PartialEq, Eq)] -pub struct Secret { - inner: H256, -} - -impl Drop for Secret { - fn drop(&mut self) { - self.inner.0.zeroize() - } -} - -impl ToHex for Secret { - fn to_hex(&self) -> String { - format!("{:x}", self.inner) - } -} - -impl fmt::LowerHex for Secret { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - self.inner.fmt(fmt) - } -} - -impl fmt::Debug for Secret { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - self.inner.fmt(fmt) - } -} - -impl fmt::Display for Secret { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - write!(fmt, "Secret: 0x{:x}{:x}..{:x}{:x}", self.inner[0], self.inner[1], self.inner[30], self.inner[31]) - } -} - -impl Secret { - /// Creates a `Secret` from the given slice, returning `None` if the slice length != 32. - pub fn from_slice(key: &[u8]) -> Option { - if key.len() != 32 { - return None - } - let mut h = H256::zero(); - h.as_bytes_mut().copy_from_slice(&key[0..32]); - Some(Secret { inner: h }) - } - - /// Creates zero key, which is invalid for crypto operations, but valid for math operation. - pub fn zero() -> Self { - Secret { inner: H256::zero() } - } - - /// Imports and validates the key. - pub fn from_unsafe_slice(key: &[u8]) -> Result { - let secret = key::SecretKey::from_slice(&super::SECP256K1, key)?; - Ok(secret.into()) - } - - /// Checks validity of this key. - pub fn check_validity(&self) -> Result<(), Error> { - self.to_secp256k1_secret().map(|_| ()) - } - - /// Inplace add one secret key to another (scalar + scalar) - pub fn add(&mut self, other: &Secret) -> Result<(), Error> { - match (self.is_zero(), other.is_zero()) { - (true, true) | (false, true) => Ok(()), - (true, false) => { - *self = other.clone(); - Ok(()) - }, - (false, false) => { - let mut key_secret = self.to_secp256k1_secret()?; - let other_secret = other.to_secp256k1_secret()?; - key_secret.add_assign(&SECP256K1, &other_secret)?; - - *self = key_secret.into(); - Ok(()) - }, - } - } - - /// Inplace subtract one secret key from another (scalar - scalar) - pub fn sub(&mut self, other: &Secret) -> Result<(), Error> { - match (self.is_zero(), other.is_zero()) { - (true, true) | (false, true) => Ok(()), - (true, false) => { - *self = other.clone(); - self.neg() - }, - (false, false) => { - let mut key_secret = self.to_secp256k1_secret()?; - let mut other_secret = other.to_secp256k1_secret()?; - other_secret.mul_assign(&SECP256K1, &key::MINUS_ONE_KEY)?; - key_secret.add_assign(&SECP256K1, &other_secret)?; - - *self = key_secret.into(); - Ok(()) - }, - } - } - - /// Inplace decrease secret key (scalar - 1) - pub fn dec(&mut self) -> Result<(), Error> { - match self.is_zero() { - true => { - *self = key::MINUS_ONE_KEY.into(); - Ok(()) - }, - false => { - let mut key_secret = self.to_secp256k1_secret()?; - key_secret.add_assign(&SECP256K1, &key::MINUS_ONE_KEY)?; - - *self = key_secret.into(); - Ok(()) - }, - } - } - - /// Inplace multiply one secret key to another (scalar * scalar) - pub fn mul(&mut self, other: &Secret) -> Result<(), Error> { - match (self.is_zero(), other.is_zero()) { - (true, true) | (true, false) => Ok(()), - (false, true) => { - *self = Self::zero(); - Ok(()) - }, - (false, false) => { - let mut key_secret = self.to_secp256k1_secret()?; - let other_secret = other.to_secp256k1_secret()?; - key_secret.mul_assign(&SECP256K1, &other_secret)?; - - *self = key_secret.into(); - Ok(()) - }, - } - } - - /// Inplace negate secret key (-scalar) - pub fn neg(&mut self) -> Result<(), Error> { - match self.is_zero() { - true => Ok(()), - false => { - let mut key_secret = self.to_secp256k1_secret()?; - key_secret.mul_assign(&SECP256K1, &key::MINUS_ONE_KEY)?; - - *self = key_secret.into(); - Ok(()) - }, - } - } - - /// Inplace inverse secret key (1 / scalar) - pub fn inv(&mut self) -> Result<(), Error> { - let mut key_secret = self.to_secp256k1_secret()?; - key_secret.inv_assign(&SECP256K1)?; - - *self = key_secret.into(); - Ok(()) - } - - /// Compute power of secret key inplace (secret ^ pow). - /// This function is not intended to be used with large powers. - pub fn pow(&mut self, pow: usize) -> Result<(), Error> { - if self.is_zero() { - return Ok(()); - } - - match pow { - 0 => *self = key::ONE_KEY.into(), - 1 => (), - _ => { - let c = self.clone(); - for _ in 1..pow { - self.mul(&c)?; - } - }, - } - - Ok(()) - } - - /// Create `secp256k1::key::SecretKey` based on this secret - pub fn to_secp256k1_secret(&self) -> Result { - Ok(key::SecretKey::from_slice(&SECP256K1, &self[..])?) - } -} - -impl FromStr for Secret { - type Err = Error; - fn from_str(s: &str) -> Result { - Ok(H256::from_str(s).map_err(|e| Error::Custom(format!("{:?}", e)))?.into()) - } -} - -impl From<[u8; 32]> for Secret { - fn from(k: [u8; 32]) -> Self { - Secret { inner: H256(k) } - } -} - -impl From for Secret { - fn from(s: H256) -> Self { - s.0.into() - } -} - -impl From<&'static str> for Secret { - fn from(s: &'static str) -> Self { - s.parse().expect(&format!("invalid string literal for {}: '{}'", stringify!(Self), s)) - } -} - -impl From for Secret { - fn from(key: key::SecretKey) -> Self { - let mut a = [0; SECP256K1_SECRET_KEY_SIZE]; - a.copy_from_slice(&key[0 .. SECP256K1_SECRET_KEY_SIZE]); - a.into() - } -} - -impl Deref for Secret { - type Target = H256; - - fn deref(&self) -> &Self::Target { - &self.inner - } -} - -#[cfg(test)] -mod tests { - use std::str::FromStr; - use super::super::{Random, Generator}; - use super::Secret; - - #[test] - fn multiplicating_secret_inversion_with_secret_gives_one() { - let secret = Random.generate().unwrap().secret().clone(); - let mut inversion = secret.clone(); - inversion.inv().unwrap(); - inversion.mul(&secret).unwrap(); - assert_eq!(inversion, Secret::from_str("0000000000000000000000000000000000000000000000000000000000000001").unwrap()); - } - - #[test] - fn secret_inversion_is_reversible_with_inversion() { - let secret = Random.generate().unwrap().secret().clone(); - let mut inversion = secret.clone(); - inversion.inv().unwrap(); - inversion.inv().unwrap(); - assert_eq!(inversion, secret); - } - - #[test] - fn secret_pow() { - let secret = Random.generate().unwrap().secret().clone(); - - let mut pow0 = secret.clone(); - pow0.pow(0).unwrap(); - assert_eq!(pow0, Secret::from_str("0000000000000000000000000000000000000000000000000000000000000001").unwrap()); - - let mut pow1 = secret.clone(); - pow1.pow(1).unwrap(); - assert_eq!(pow1, secret); - - let mut pow2 = secret.clone(); - pow2.pow(2).unwrap(); - let mut pow2_expected = secret.clone(); - pow2_expected.mul(&secret).unwrap(); - assert_eq!(pow2, pow2_expected); - - let mut pow3 = secret.clone(); - pow3.pow(3).unwrap(); - let mut pow3_expected = secret.clone(); - pow3_expected.mul(&secret).unwrap(); - pow3_expected.mul(&secret).unwrap(); - assert_eq!(pow3, pow3_expected); - } -} diff --git a/accounts/ethkey/src/signature.rs b/accounts/ethkey/src/signature.rs deleted file mode 100644 index c4c4bfd9e63..00000000000 --- a/accounts/ethkey/src/signature.rs +++ /dev/null @@ -1,314 +0,0 @@ -// Copyright 2015-2019 Parity Technologies (UK) Ltd. -// This file is part of Parity Ethereum. - -// Parity Ethereum is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Parity Ethereum is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Parity Ethereum. If not, see . - -use std::ops::{Deref, DerefMut}; -use std::cmp::PartialEq; -use std::fmt; -use std::str::FromStr; -use std::hash::{Hash, Hasher}; -use secp256k1::{Message as SecpMessage, RecoverableSignature, RecoveryId, Error as SecpError}; -use secp256k1::key::{SecretKey, PublicKey}; -use rustc_hex::{ToHex, FromHex}; -use ethereum_types::{H520, H256}; -use {Secret, Public, SECP256K1, Error, Message, public_to_address, Address}; - -/// Signature encoded as RSV components -#[repr(C)] -pub struct Signature([u8; 65]); - -impl Signature { - /// Get a slice into the 'r' portion of the data. - pub fn r(&self) -> &[u8] { - &self.0[0..32] - } - - /// Get a slice into the 's' portion of the data. - pub fn s(&self) -> &[u8] { - &self.0[32..64] - } - - /// Get the recovery byte. - pub fn v(&self) -> u8 { - self.0[64] - } - - /// Encode the signature into RSV array (V altered to be in "Electrum" notation). - pub fn into_electrum(mut self) -> [u8; 65] { - self.0[64] += 27; - self.0 - } - - /// Parse bytes as a signature encoded as RSV (V in "Electrum" notation). - /// May return empty (invalid) signature if given data has invalid length. - pub fn from_electrum(data: &[u8]) -> Self { - if data.len() != 65 || data[64] < 27 { - // fallback to empty (invalid) signature - return Signature::default(); - } - - let mut sig = [0u8; 65]; - sig.copy_from_slice(data); - sig[64] -= 27; - Signature(sig) - } - - /// Create a signature object from the sig. - pub fn from_rsv(r: &H256, s: &H256, v: u8) -> Self { - let mut sig = [0u8; 65]; - sig[0..32].copy_from_slice(r.as_ref()); - sig[32..64].copy_from_slice(s.as_ref()); - sig[64] = v; - Signature(sig) - } - - /// Check if this is a "low" signature. - pub fn is_low_s(&self) -> bool { - // "7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0" - const MASK: H256 = H256([ - 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0x5D, 0x57, 0x6E, 0x73, 0x57, 0xA4, 0x50, 0x1D, - 0xDF, 0xE9, 0x2F, 0x46, 0x68, 0x1B, 0x20, 0xA0, - ]); - H256::from_slice(self.s()) <= MASK - } - - /// Check if each component of the signature is in range. - pub fn is_valid(&self) -> bool { - // "fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141" - const MASK: H256 = H256([ - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, - 0xba, 0xae, 0xdc, 0xe6, 0xaf, 0x48, 0xa0, 0x3b, - 0xbf, 0xd2, 0x5e, 0x8c, 0xd0, 0x36, 0x41, 0x41, - ]); - const ONE: H256 = H256([ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, - ]); - let r = H256::from_slice(self.r()); - let s = H256::from_slice(self.s()); - self.v() <= 1 && - r < MASK && r >= ONE && - s < MASK && s >= ONE - } -} - -// manual implementation large arrays don't have trait impls by default. -// remove when integer generics exist -impl PartialEq for Signature { - fn eq(&self, other: &Self) -> bool { - &self.0[..] == &other.0[..] - } -} - -// manual implementation required in Rust 1.13+, see `std::cmp::AssertParamIsEq`. -impl Eq for Signature { } - -// also manual for the same reason, but the pretty printing might be useful. -impl fmt::Debug for Signature { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - f.debug_struct("Signature") - .field("r", &self.0[0..32].to_hex()) - .field("s", &self.0[32..64].to_hex()) - .field("v", &self.0[64..65].to_hex()) - .finish() - } -} - -impl fmt::Display for Signature { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - write!(f, "{}", self.to_hex()) - } -} - -impl FromStr for Signature { - type Err = Error; - - fn from_str(s: &str) -> Result { - match s.from_hex() { - Ok(ref hex) if hex.len() == 65 => { - let mut data = [0; 65]; - data.copy_from_slice(&hex[0..65]); - Ok(Signature(data)) - }, - _ => Err(Error::InvalidSignature) - } - } -} - -impl Default for Signature { - fn default() -> Self { - Signature([0; 65]) - } -} - -impl Hash for Signature { - fn hash(&self, state: &mut H) { - H520::from(self.0).hash(state); - } -} - -impl Clone for Signature { - fn clone(&self) -> Self { - Signature(self.0) - } -} - -impl From<[u8; 65]> for Signature { - fn from(s: [u8; 65]) -> Self { - Signature(s) - } -} - -impl Into<[u8; 65]> for Signature { - fn into(self) -> [u8; 65] { - self.0 - } -} - -impl From for H520 { - fn from(s: Signature) -> Self { - H520::from(s.0) - } -} - -impl From for Signature { - fn from(bytes: H520) -> Self { - Signature(bytes.into()) - } -} - -impl Deref for Signature { - type Target = [u8; 65]; - - fn deref(&self) -> &Self::Target { - &self.0 - } -} - -impl DerefMut for Signature { - fn deref_mut(&mut self) -> &mut Self::Target { - &mut self.0 - } -} - -pub fn sign(secret: &Secret, message: &Message) -> Result { - let context = &SECP256K1; - let sec = SecretKey::from_slice(context, secret.as_ref())?; - let s = context.sign_recoverable(&SecpMessage::from_slice(&message[..])?, &sec)?; - let (rec_id, data) = s.serialize_compact(context); - let mut data_arr = [0; 65]; - - // no need to check if s is low, it always is - data_arr[0..64].copy_from_slice(&data[0..64]); - data_arr[64] = rec_id.to_i32() as u8; - Ok(Signature(data_arr)) -} - -pub fn verify_public(public: &Public, signature: &Signature, message: &Message) -> Result { - let context = &SECP256K1; - let rsig = RecoverableSignature::from_compact(context, &signature[0..64], RecoveryId::from_i32(signature[64] as i32)?)?; - let sig = rsig.to_standard(context); - - let pdata: [u8; 65] = { - let mut temp = [4u8; 65]; - temp[1..65].copy_from_slice(public.as_bytes()); - temp - }; - - let publ = PublicKey::from_slice(context, &pdata)?; - match context.verify(&SecpMessage::from_slice(&message[..])?, &sig, &publ) { - Ok(_) => Ok(true), - Err(SecpError::IncorrectSignature) => Ok(false), - Err(x) => Err(Error::from(x)) - } -} - -pub fn verify_address(address: &Address, signature: &Signature, message: &Message) -> Result { - let public = recover(signature, message)?; - let recovered_address = public_to_address(&public); - Ok(address == &recovered_address) -} - -pub fn recover(signature: &Signature, message: &Message) -> Result { - let context = &SECP256K1; - let rsig = RecoverableSignature::from_compact(context, &signature[0..64], RecoveryId::from_i32(signature[64] as i32)?)?; - let pubkey = context.recover(&SecpMessage::from_slice(&message[..])?, &rsig)?; - let serialized = pubkey.serialize_vec(context, false); - - let mut public = Public::default(); - public.as_bytes_mut().copy_from_slice(&serialized[1..65]); - Ok(public) -} - -#[cfg(test)] -mod tests { - use std::str::FromStr; - use {Generator, Random, Message}; - use super::{sign, verify_public, verify_address, recover, Signature}; - - #[test] - fn vrs_conversion() { - // given - let keypair = Random.generate().unwrap(); - let message = Message::default(); - let signature = sign(keypair.secret(), &message).unwrap(); - - // when - let vrs = signature.clone().into_electrum(); - let from_vrs = Signature::from_electrum(&vrs); - - // then - assert_eq!(signature, from_vrs); - } - - #[test] - fn signature_to_and_from_str() { - let keypair = Random.generate().unwrap(); - let message = Message::default(); - let signature = sign(keypair.secret(), &message).unwrap(); - let string = format!("{}", signature); - let deserialized = Signature::from_str(&string).unwrap(); - assert_eq!(signature, deserialized); - } - - #[test] - fn sign_and_recover_public() { - let keypair = Random.generate().unwrap(); - let message = Message::default(); - let signature = sign(keypair.secret(), &message).unwrap(); - assert_eq!(keypair.public(), &recover(&signature, &message).unwrap()); - } - - #[test] - fn sign_and_verify_public() { - let keypair = Random.generate().unwrap(); - let message = Message::default(); - let signature = sign(keypair.secret(), &message).unwrap(); - assert!(verify_public(keypair.public(), &signature, &message).unwrap()); - } - - #[test] - fn sign_and_verify_address() { - let keypair = Random.generate().unwrap(); - let message = Message::default(); - let signature = sign(keypair.secret(), &message).unwrap(); - assert!(verify_address(&keypair.address(), &signature, &message).unwrap()); - } -} diff --git a/accounts/ethstore/Cargo.toml b/accounts/ethstore/Cargo.toml index 99943611c54..ac343b6efce 100644 --- a/accounts/ethstore/Cargo.toml +++ b/accounts/ethstore/Cargo.toml @@ -17,7 +17,7 @@ tiny-keccak = "1.4" time = "0.1.34" itertools = "0.5" parking_lot = "0.9" -parity-crypto = "0.4.0" +parity-crypto = { version = "0.4.2", features = ["publickey"] } ethereum-types = "0.8.0" dir = { path = "../../util/dir" } smallvec = "0.6" diff --git a/accounts/ethstore/cli/Cargo.toml b/accounts/ethstore/cli/Cargo.toml index 2793acc6e21..f6d12e67fee 100644 --- a/accounts/ethstore/cli/Cargo.toml +++ b/accounts/ethstore/cli/Cargo.toml @@ -13,6 +13,8 @@ serde = "1.0" serde_derive = "1.0" parking_lot = "0.9" ethstore = { path = "../" } +ethkey = { path = "../../ethkey" } +parity-crypto = { version = "0.4.2", features = ["publickey"] } dir = { path = '../../../util/dir' } panic_hook = { path = "../../../util/panic-hook" } diff --git a/accounts/ethstore/cli/src/crack.rs b/accounts/ethstore/cli/src/crack.rs index abe171c3560..8e65b02193c 100644 --- a/accounts/ethstore/cli/src/crack.rs +++ b/accounts/ethstore/cli/src/crack.rs @@ -19,7 +19,8 @@ use std::sync::Arc; use std::collections::VecDeque; use parking_lot::Mutex; -use ethstore::{ethkey::Password, PresaleWallet, Error}; +use ethstore::{PresaleWallet, Error}; +use ethkey::Password; use num_cpus; pub fn run(passwords: VecDeque, wallet_path: &str) -> Result<(), Error> { diff --git a/accounts/ethstore/cli/src/main.rs b/accounts/ethstore/cli/src/main.rs index 8fc0054be7f..7c7011837d4 100644 --- a/accounts/ethstore/cli/src/main.rs +++ b/accounts/ethstore/cli/src/main.rs @@ -17,9 +17,11 @@ extern crate dir; extern crate docopt; extern crate ethstore; +extern crate ethkey; extern crate num_cpus; extern crate panic_hook; extern crate parking_lot; +extern crate parity_crypto; extern crate rustc_hex; extern crate serde; @@ -34,7 +36,8 @@ use std::{env, process, fs, fmt}; use docopt::Docopt; use ethstore::accounts_dir::{KeyDirectory, RootDiskDirectory}; -use ethstore::ethkey::{Address, Password}; +use ethkey::Password; +use parity_crypto::publickey::Address; use ethstore::{EthStore, SimpleSecretStore, SecretStore, import_accounts, PresaleWallet, SecretVaultRef, StoreAccountRef}; mod crack; diff --git a/accounts/ethstore/src/account/crypto.rs b/accounts/ethstore/src/account/crypto.rs index de5b4d8572f..8abe799bc7b 100644 --- a/accounts/ethstore/src/account/crypto.rs +++ b/accounts/ethstore/src/account/crypto.rs @@ -15,7 +15,8 @@ // along with Parity Ethereum. If not, see . use std::str; -use ethkey::{Password, Secret}; +use crypto::publickey::Secret; +use ethkey::Password; use {json, Error, crypto}; use crypto::Keccak256; use random::Random; @@ -120,7 +121,7 @@ impl Crypto { } let secret = self.do_decrypt(password, 32)?; - Ok(Secret::from_unsafe_slice(&secret)?) + Ok(Secret::import_key(&secret)?) } /// Try to decrypt and return result as is @@ -158,7 +159,7 @@ impl Crypto { #[cfg(test)] mod tests { - use ethkey::{Generator, Random}; + use crypto::publickey::{Generator, Random}; use super::{Crypto, Error}; #[test] diff --git a/accounts/ethstore/src/account/safe_account.rs b/accounts/ethstore/src/account/safe_account.rs index 7a38e79fa26..4bd393fac45 100644 --- a/accounts/ethstore/src/account/safe_account.rs +++ b/accounts/ethstore/src/account/safe_account.rs @@ -14,8 +14,9 @@ // You should have received a copy of the GNU General Public License // along with Parity Ethereum. If not, see . -use ethkey::{self, KeyPair, sign, Address, Password, Signature, Message, Public, Secret}; -use ethkey::crypto::ecdh::agree; +use crypto::publickey::{KeyPair, sign, Address, Signature, Message, Public, Secret}; +use ethkey::Password; +use crypto::publickey::ecdh::agree; use {json, Error}; use account::Version; use crypto; @@ -161,7 +162,7 @@ impl SafeAccount { /// Decrypt a message. pub fn decrypt(&self, password: &Password, shared_mac: &[u8], message: &[u8]) -> Result, Error> { let secret = self.crypto.secret(password)?; - ethkey::crypto::ecies::decrypt(&secret, shared_mac, message).map_err(From::from) + crypto::publickey::ecies::decrypt(&secret, shared_mac, message).map_err(From::from) } /// Agree on shared key. @@ -199,7 +200,7 @@ impl SafeAccount { #[cfg(test)] mod tests { - use ethkey::{Generator, Random, verify_public, Message}; + use crypto::publickey::{Generator, Random, verify_public, Message}; use super::SafeAccount; #[test] diff --git a/accounts/ethstore/src/accounts_dir/disk.rs b/accounts/ethstore/src/accounts_dir/disk.rs index b70029785e7..10e88095c73 100644 --- a/accounts/ethstore/src/accounts_dir/disk.rs +++ b/accounts/ethstore/src/accounts_dir/disk.rs @@ -356,7 +356,7 @@ mod test { use std::{env, fs}; use super::{KeyDirectory, RootDiskDirectory, VaultKey}; use account::SafeAccount; - use ethkey::{Random, Generator}; + use crypto::publickey::{Random, Generator}; use self::tempdir::TempDir; #[test] diff --git a/accounts/ethstore/src/accounts_dir/memory.rs b/accounts/ethstore/src/accounts_dir/memory.rs index 7f623aa3a14..a1403e240f5 100644 --- a/accounts/ethstore/src/accounts_dir/memory.rs +++ b/accounts/ethstore/src/accounts_dir/memory.rs @@ -17,7 +17,7 @@ use std::collections::HashMap; use parking_lot::RwLock; use itertools; -use ethkey::Address; +use crypto::publickey::Address; use {SafeAccount, Error}; use super::KeyDirectory; diff --git a/accounts/ethstore/src/error.rs b/accounts/ethstore/src/error.rs index fceaf16768b..9798b5cc12f 100644 --- a/accounts/ethstore/src/error.rs +++ b/accounts/ethstore/src/error.rs @@ -16,9 +16,8 @@ use std::fmt; use std::io::Error as IoError; -use ethkey::{self, Error as EthKeyError}; use crypto::{self, Error as EthCryptoError}; -use ethkey::DerivationError; +use crypto::publickey::{Error as EthPublicKeyCryptoError, DerivationError}; /// Account-related errors. #[derive(Debug)] @@ -47,12 +46,10 @@ pub enum Error { VaultNotFound, /// Account creation failed. CreationFailed, - /// `EthKey` error - EthKey(EthKeyError), - /// `ethkey::crypto::Error` - EthKeyCrypto(ethkey::crypto::Error), /// `EthCrypto` error EthCrypto(EthCryptoError), + /// `EthPublicKeyCryptoError` error + EthPublicKeyCrypto(EthPublicKeyCryptoError), /// Derivation error Derivation(DerivationError), /// Custom error @@ -74,9 +71,8 @@ impl fmt::Display for Error { Error::InvalidVaultName => "Invalid vault name".into(), Error::VaultNotFound => "Vault not found".into(), Error::CreationFailed => "Account creation failed".into(), - Error::EthKey(ref err) => err.to_string(), - Error::EthKeyCrypto(ref err) => err.to_string(), Error::EthCrypto(ref err) => err.to_string(), + Error::EthPublicKeyCrypto(ref err) => err.to_string(), Error::Derivation(ref err) => format!("Derivation error: {:?}", err), Error::Custom(ref s) => s.clone(), }; @@ -91,15 +87,9 @@ impl From for Error { } } -impl From for Error { - fn from(err: EthKeyError) -> Self { - Error::EthKey(err) - } -} - -impl From for Error { - fn from(err: ethkey::crypto::Error) -> Self { - Error::EthKeyCrypto(err) +impl From for Error { + fn from(err: EthPublicKeyCryptoError) -> Self { + Error::EthPublicKeyCrypto(err) } } diff --git a/accounts/ethstore/src/ethkey.rs b/accounts/ethstore/src/ethkey.rs deleted file mode 100644 index 8cd2c533adc..00000000000 --- a/accounts/ethstore/src/ethkey.rs +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright 2015-2019 Parity Technologies (UK) Ltd. -// This file is part of Parity Ethereum. - -// Parity Ethereum is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Parity Ethereum is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Parity Ethereum. If not, see . - -//! ethkey reexport to make documentation look pretty. -pub use _ethkey::*; -use json; - -impl Into for Address { - fn into(self) -> json::H160 { - let a: [u8; 20] = self.into(); - From::from(a) - } -} - -impl From for Address { - fn from(json: json::H160) -> Self { - let a: [u8; 20] = json.into(); - From::from(a) - } -} - -impl<'a> From<&'a json::H160> for Address { - fn from(json: &'a json::H160) -> Self { - let mut a = [0u8; 20]; - a.copy_from_slice(json); - From::from(a) - } -} diff --git a/accounts/ethstore/src/ethstore.rs b/accounts/ethstore/src/ethstore.rs index 36416c5e79f..ab8d4644f89 100644 --- a/accounts/ethstore/src/ethstore.rs +++ b/accounts/ethstore/src/ethstore.rs @@ -22,7 +22,8 @@ use std::time::{Instant, Duration}; use crypto::KEY_ITERATIONS; use random::Random; -use ethkey::{self, Signature, Password, Address, Message, Secret, Public, KeyPair, ExtendedKeyPair}; +use crypto::publickey::{Signature, Address, Message, Secret, Public, KeyPair, ExtendedKeyPair}; +use ethkey::Password; use accounts_dir::{KeyDirectory, VaultKeyDirectory, VaultKey, SetKeyError}; use account::SafeAccount; use presale::PresaleWallet; @@ -442,13 +443,13 @@ impl EthMultiStore { Derivation::Hierarchical(path) => { for path_item in path { extended = extended.derive( - if path_item.soft { ethkey::Derivation::Soft(path_item.index) } - else { ethkey::Derivation::Hard(path_item.index) } + if path_item.soft { crypto::publickey::Derivation::Soft(path_item.index) } + else { crypto::publickey::Derivation::Hard(path_item.index) } )?; } }, - Derivation::SoftHash(h256) => { extended = extended.derive(ethkey::Derivation::Soft(h256))?; } - Derivation::HardHash(h256) => { extended = extended.derive(ethkey::Derivation::Hard(h256))?; } + Derivation::SoftHash(h256) => { extended = extended.derive(crypto::publickey::Derivation::Soft(h256))?; } + Derivation::HardHash(h256) => { extended = extended.derive(crypto::publickey::Derivation::Hard(h256))?; } } Ok(extended) } @@ -479,7 +480,7 @@ impl SimpleSecretStore for EthMultiStore { let accounts = self.get_matching(&account_ref, password)?; for account in accounts { let extended = self.generate(account.crypto.secret(password)?, derivation)?; - return Ok(ethkey::public_to_address(extended.public().public())); + return Ok(crypto::publickey::public_to_address(extended.public().public())); } Err(Error::InvalidPassword) } @@ -491,7 +492,7 @@ impl SimpleSecretStore for EthMultiStore { for account in accounts { let extended = self.generate(account.crypto.secret(password)?, derivation)?; let secret = extended.secret().as_raw(); - return Ok(ethkey::sign(&secret, message)?) + return Ok(crypto::publickey::sign(&secret, message)?) } Err(Error::InvalidPassword) } @@ -690,7 +691,7 @@ mod tests { extern crate tempdir; use accounts_dir::{KeyDirectory, MemoryDirectory, RootDiskDirectory}; - use ethkey::{Random, Generator, KeyPair}; + use crypto::publickey::{Random, Generator, KeyPair}; use secret_store::{SimpleSecretStore, SecretStore, SecretVaultRef, StoreAccountRef, Derivation}; use super::{EthStore, EthMultiStore}; use self::tempdir::TempDir; diff --git a/accounts/ethstore/src/import.rs b/accounts/ethstore/src/import.rs index 3fe9763e8f2..abf8572446a 100644 --- a/accounts/ethstore/src/import.rs +++ b/accounts/ethstore/src/import.rs @@ -18,7 +18,7 @@ use std::collections::HashSet; use std::path::Path; use std::fs; -use ethkey::Address; +use crypto::publickey::Address; use accounts_dir::{KeyDirectory, RootDiskDirectory, DiskKeyFileManager, KeyFileManager}; use dir; use Error; diff --git a/accounts/ethstore/src/lib.rs b/accounts/ethstore/src/lib.rs index aa2bb86a471..ddd1d4bb8ca 100644 --- a/accounts/ethstore/src/lib.rs +++ b/accounts/ethstore/src/lib.rs @@ -33,7 +33,7 @@ extern crate tempdir; extern crate parity_crypto as crypto; extern crate ethereum_types; -extern crate ethkey as _ethkey; +extern crate ethkey as ethkey; extern crate parity_wordlist; #[macro_use] @@ -46,7 +46,6 @@ extern crate serde_derive; extern crate matches; pub mod accounts_dir; -pub mod ethkey; mod account; mod json; @@ -72,4 +71,30 @@ pub use self::random::random_string; pub use self::parity_wordlist::random_phrase; /// An opaque wrapper for secret. -pub struct OpaqueSecret(::ethkey::Secret); +pub struct OpaqueSecret(crypto::publickey::Secret); + +// Additional converters for Address +use crypto::publickey::Address; + +impl Into for Address { + fn into(self) -> json::H160 { + let a: [u8; 20] = self.into(); + From::from(a) + } +} + +impl From for Address { + fn from(json: json::H160) -> Self { + let a: [u8; 20] = json.into(); + From::from(a) + } +} + +impl<'a> From<&'a json::H160> for Address { + fn from(json: &'a json::H160) -> Self { + let mut a = [0u8; 20]; + a.copy_from_slice(json); + From::from(a) + } +} + diff --git a/accounts/ethstore/src/presale.rs b/accounts/ethstore/src/presale.rs index c1be05f0f02..a050fbf237b 100644 --- a/accounts/ethstore/src/presale.rs +++ b/accounts/ethstore/src/presale.rs @@ -17,7 +17,8 @@ use std::fs; use std::path::Path; use json; -use ethkey::{Address, Secret, KeyPair, Password}; +use crypto::publickey::{Address, Secret, KeyPair}; +use ethkey::Password; use crypto::{Keccak256, pbkdf2}; use {crypto, Error}; @@ -65,7 +66,7 @@ impl PresaleWallet { .map_err(|_| Error::InvalidPassword)?; let unpadded = &key[..len]; - let secret = Secret::from_unsafe_slice(&unpadded.keccak256())?; + let secret = Secret::import_key(&unpadded.keccak256())?; if let Ok(kp) = KeyPair::from_secret(secret) { if kp.address() == self.address { return Ok(kp) diff --git a/accounts/ethstore/src/secret_store.rs b/accounts/ethstore/src/secret_store.rs index d3ca1a12fba..aa619be41c5 100644 --- a/accounts/ethstore/src/secret_store.rs +++ b/accounts/ethstore/src/secret_store.rs @@ -17,7 +17,8 @@ use std::hash::{Hash, Hasher}; use std::path::PathBuf; use std::cmp::Ordering; -use ethkey::{Address, Message, Signature, Secret, Password, Public}; +use crypto::publickey::{Address, Message, Signature, Secret, Public}; +use ethkey::Password; use Error; use json::{Uuid, OpaqueKeyFile}; use ethereum_types::H256; @@ -110,7 +111,7 @@ pub trait SecretStore: SimpleSecretStore { /// Signs a message with raw secret. fn sign_with_secret(&self, secret: &OpaqueSecret, message: &Message) -> Result { - Ok(::ethkey::sign(&secret.0, message)?) + Ok(crypto::publickey::sign(&secret.0, message)?) } /// Imports presale wallet diff --git a/accounts/ethstore/tests/api.rs b/accounts/ethstore/tests/api.rs index 74d66a66665..6554c4da796 100644 --- a/accounts/ethstore/tests/api.rs +++ b/accounts/ethstore/tests/api.rs @@ -17,11 +17,12 @@ extern crate rand; extern crate ethstore; extern crate ethereum_types; +extern crate parity_crypto; mod util; use ethstore::{EthStore, SimpleSecretStore, SecretVaultRef, StoreAccountRef}; -use ethstore::ethkey::{Random, Generator, Secret, KeyPair, verify_address}; +use parity_crypto::publickey::{Random, Generator, Secret, KeyPair, verify_address}; use ethstore::accounts_dir::RootDiskDirectory; use util::TransientDir; use ethereum_types::Address; diff --git a/accounts/src/account_data.rs b/accounts/src/account_data.rs index a36d38740e4..3f874c41da5 100644 --- a/accounts/src/account_data.rs +++ b/accounts/src/account_data.rs @@ -21,7 +21,8 @@ use std::{ time::Instant, }; -use ethkey::{Address, Password}; +use parity_crypto::publickey::Address; +use ethkey::Password; use serde_derive::{Serialize, Deserialize}; use serde_json; diff --git a/accounts/src/lib.rs b/accounts/src/lib.rs index ac87a2ee332..29b8c303945 100644 --- a/accounts/src/lib.rs +++ b/accounts/src/lib.rs @@ -28,7 +28,8 @@ use self::stores::AddressBook; use std::collections::HashMap; use std::time::{Instant, Duration}; -use ethkey::{Address, Message, Public, Secret, Password, Random, Generator}; +use ethkey::Password; +use parity_crypto::publickey::{Address, Message, Public, Secret, Random, Generator, Signature}; use ethstore::accounts_dir::MemoryDirectory; use ethstore::{ SimpleSecretStore, SecretStore, EthStore, EthMultiStore, @@ -37,7 +38,6 @@ use ethstore::{ use log::warn; use parking_lot::RwLock; -pub use ethkey::Signature; pub use ethstore::{Derivation, IndexDerivation, KeyFile, Error}; pub use self::account_data::AccountMeta; @@ -503,7 +503,7 @@ impl AccountProvider { mod tests { use super::{AccountProvider, Unlock}; use std::time::{Duration, Instant}; - use ethkey::{Generator, Random, Address}; + use parity_crypto::publickey::{Generator, Random, Address}; use ethstore::{StoreAccountRef, Derivation}; use ethereum_types::H256; diff --git a/accounts/src/stores.rs b/accounts/src/stores.rs index 90e36374e09..72d0a7df7d5 100644 --- a/accounts/src/stores.rs +++ b/accounts/src/stores.rs @@ -20,7 +20,7 @@ use std::{fs, fmt, hash, ops}; use std::collections::HashMap; use std::path::{Path, PathBuf}; -use ethkey::Address; +use parity_crypto::publickey::Address; use log::{trace, warn}; use crate::AccountMeta; diff --git a/ethcore/Cargo.toml b/ethcore/Cargo.toml index aca6a924319..f036010c5ac 100644 --- a/ethcore/Cargo.toml +++ b/ethcore/Cargo.toml @@ -17,7 +17,6 @@ engine = { path = "./engine" } env_logger = { version = "0.5", optional = true } ethash = { path = "../ethash", optional = true } ethjson = { path = "../json", optional = true } -ethkey = { path = "../accounts/ethkey", optional = true } ethcore-blockchain = { path = "./blockchain" } ethcore-call-contract = { path = "./call-contract" } ethcore-db = { path = "./db" } @@ -44,6 +43,7 @@ parity-bytes = "0.1" parking_lot = "0.9" pod = { path = "pod", optional = true } trie-db = "0.15.0" +parity-crypto = { version = "0.4.2", features = ["publickey"], optional = true } patricia-trie-ethereum = { path = "../util/patricia-trie-ethereum" } rand = "0.7" rand_xorshift = "0.2" @@ -76,7 +76,7 @@ ethash = { path = "../ethash" } ethcore-accounts = { path = "../accounts" } ethcore-builtin = { path = "./builtin" } ethjson = { path = "../json", features = ["test-helpers"] } -ethkey = { path = "../accounts/ethkey" } +parity-crypto = { version = "0.4.2", features = ["publickey"] } fetch = { path = "../util/fetch" } kvdb-memorydb = "0.1.2" kvdb-rocksdb = "0.1.5" @@ -124,7 +124,7 @@ test-heavy = [] test-helpers = [ "blooms-db", "ethjson/test-helpers", - "ethkey", + "parity-crypto", "kvdb-memorydb", "kvdb-rocksdb", "macros", diff --git a/ethcore/blockchain/Cargo.toml b/ethcore/blockchain/Cargo.toml index 5552e966fcd..3eb0b2ecb3e 100644 --- a/ethcore/blockchain/Cargo.toml +++ b/ethcore/blockchain/Cargo.toml @@ -29,7 +29,7 @@ triehash-ethereum = { version = "0.2", path = "../../util/triehash-ethereum" } [dev-dependencies] env_logger = "0.5" -ethkey = { path = "../../accounts/ethkey" } +parity-crypto = { version = "0.4.2", features = ["publickey"] } rustc-hex = "1.0" tempdir = "0.3" kvdb-memorydb = "0.1.2" diff --git a/ethcore/blockchain/src/blockchain.rs b/ethcore/blockchain/src/blockchain.rs index 870a29de6b1..efafef7a44c 100644 --- a/ethcore/blockchain/src/blockchain.rs +++ b/ethcore/blockchain/src/blockchain.rs @@ -1625,7 +1625,7 @@ mod tests { use common_types::receipt::{Receipt, TransactionOutcome}; use common_types::transaction::{Transaction, Action}; use crate::generator::{BlockGenerator, BlockBuilder, BlockOptions}; - use ethkey::Secret; + use parity_crypto::publickey::Secret; use keccak_hash::keccak; use rustc_hex::FromHex; use tempdir::TempDir; diff --git a/ethcore/builtin/Cargo.toml b/ethcore/builtin/Cargo.toml index 441e68a954e..f69b65d974b 100644 --- a/ethcore/builtin/Cargo.toml +++ b/ethcore/builtin/Cargo.toml @@ -10,13 +10,12 @@ bn = { git = "https://github.com/paritytech/bn", default-features = false } common-types = { path = "../types" } ethereum-types = "0.8.0" ethjson = { path = "../../json" } -ethkey = { path = "../../accounts/ethkey" } keccak-hash = "0.4.0" log = "0.4" num = { version = "0.1", default-features = false, features = ["bigint"] } parity-bytes = "0.1" eip-152 = { path = "../../util/EIP-152" } -parity-crypto = "0.4.0" +parity-crypto = { version = "0.4.2", features = ["publickey"] } byteorder = "1.3.2" [dev-dependencies] diff --git a/ethcore/builtin/src/lib.rs b/ethcore/builtin/src/lib.rs index 3ecc1499fab..d0b0e93ec4b 100644 --- a/ethcore/builtin/src/lib.rs +++ b/ethcore/builtin/src/lib.rs @@ -28,7 +28,7 @@ use byteorder::{BigEndian, LittleEndian, ReadBytesExt}; use common_types::errors::EthcoreError; use ethereum_types::{H256, U256}; use ethjson; -use ethkey::{Signature, recover as ec_recover}; +use parity_crypto::publickey::{Signature, recover as ec_recover}; use keccak_hash::keccak; use log::{warn, trace}; use num::{BigUint, Zero, One}; diff --git a/ethcore/engine/Cargo.toml b/ethcore/engine/Cargo.toml index 6165ef85806..fe527ade8be 100644 --- a/ethcore/engine/Cargo.toml +++ b/ethcore/engine/Cargo.toml @@ -13,17 +13,19 @@ bytes = { package = "parity-bytes", version = "0.1.0" } client-traits = { path = "../client-traits" } common-types = { path = "../types" } ethereum-types = "0.8.0" -ethkey = { path = "../../accounts/ethkey" } +parity-crypto = { version = "0.4.2", features = ["publickey"] } machine = { path = "../machine" } vm = { path = "../vm" } # used from test-helpers accounts = { package = "ethcore-accounts", path = "../../accounts", optional = true } log = { version = "0.4.8", optional = true } +ethkey = { path = "../../accounts/ethkey", optional = true } [dev-dependencies] accounts = { package = "ethcore-accounts", path = "../../accounts" } +ethkey = { path = "../../accounts/ethkey" } log = "0.4.8" [features] -test-helpers = ["accounts", "log"] +test-helpers = ["accounts", "log", "ethkey"] diff --git a/ethcore/engine/src/engine.rs b/ethcore/engine/src/engine.rs index 357a184c7af..f5e90234319 100644 --- a/ethcore/engine/src/engine.rs +++ b/ethcore/engine/src/engine.rs @@ -37,7 +37,7 @@ use common_types::{ use client_traits::EngineClient; use ethereum_types::{H256, U256, Address}; -use ethkey::Signature; +use parity_crypto::publickey::Signature; use machine::{ Machine, executed_block::ExecutedBlock, diff --git a/ethcore/engine/src/signer.rs b/ethcore/engine/src/signer.rs index 1e932feefc3..baacf7c0984 100644 --- a/ethcore/engine/src/signer.rs +++ b/ethcore/engine/src/signer.rs @@ -17,27 +17,27 @@ //! A signer used by Engines which need to sign messages. use ethereum_types::{H256, Address}; -use ethkey::{self, Signature}; +use parity_crypto::publickey::{Signature, KeyPair, Error}; /// Everything that an Engine needs to sign messages. pub trait EngineSigner: Send + Sync { /// Sign a consensus message hash. - fn sign(&self, hash: H256) -> Result; + fn sign(&self, hash: H256) -> Result; /// Signing address fn address(&self) -> Address; } /// Creates a new `EngineSigner` from given key pair. -pub fn from_keypair(keypair: ethkey::KeyPair) -> Box { +pub fn from_keypair(keypair: KeyPair) -> Box { Box::new(Signer(keypair)) } -struct Signer(ethkey::KeyPair); +struct Signer(KeyPair); impl EngineSigner for Signer { - fn sign(&self, hash: H256) -> Result { - ethkey::sign(self.0.secret(), &hash) + fn sign(&self, hash: H256) -> Result { + parity_crypto::publickey::sign(self.0.secret(), &hash) } fn address(&self) -> Address { diff --git a/ethcore/engine/src/test_helpers.rs b/ethcore/engine/src/test_helpers.rs index 92ba66ff480..6423590b3a3 100644 --- a/ethcore/engine/src/test_helpers.rs +++ b/ethcore/engine/src/test_helpers.rs @@ -19,25 +19,26 @@ use std::sync::Arc; use ethereum_types::{Address, H256}; -use ethkey::{Password, Signature}; +use ethkey::Password; +use parity_crypto::publickey::{Signature, Error}; use log::warn; use accounts::{self, AccountProvider, SignError}; use crate::signer::EngineSigner; impl EngineSigner for (Arc, Address, Password) { - fn sign(&self, hash: H256) -> Result { + fn sign(&self, hash: H256) -> Result { match self.0.sign(self.1, Some(self.2.clone()), hash) { Err(SignError::NotUnlocked) => unreachable!(), - Err(SignError::NotFound) => Err(ethkey::Error::InvalidAddress), - Err(SignError::SStore(accounts::Error::EthKey(err))) => Err(err), - Err(SignError::SStore(accounts::Error::EthKeyCrypto(err))) => { + Err(SignError::NotFound) => Err(Error::InvalidAddress), + Err(SignError::SStore(accounts::Error::EthCrypto(err))) => Err(Error::Custom(err.to_string())), + Err(SignError::SStore(accounts::Error::EthPublicKeyCrypto(err))) => { warn!("Low level crypto error: {:?}", err); - Err(ethkey::Error::InvalidSecret) + Err(Error::InvalidSecretKey) }, Err(SignError::SStore(err)) => { warn!("Error signing for engine: {:?}", err); - Err(ethkey::Error::InvalidSignature) + Err(Error::InvalidSignature) }, Ok(ok) => Ok(ok), } diff --git a/ethcore/engines/authority-round/Cargo.toml b/ethcore/engines/authority-round/Cargo.toml index 79083299adb..5bca87fb806 100644 --- a/ethcore/engines/authority-round/Cargo.toml +++ b/ethcore/engines/authority-round/Cargo.toml @@ -12,7 +12,7 @@ client-traits = { path = "../../client-traits" } common-types = { path = "../../types" } ethereum-types = "0.8.0" ethjson = { path = "../../../json" } -ethkey = { path = "../../../accounts/ethkey" } +parity-crypto = { version = "0.4.2", features = ["publickey"] } engine = { path = "../../engine" } io = { package = "ethcore-io", path = "../../../util/io" } itertools = "0.5" diff --git a/ethcore/engines/authority-round/src/lib.rs b/ethcore/engines/authority-round/src/lib.rs index 2f4202f168e..fd3585fc72c 100644 --- a/ethcore/engines/authority-round/src/lib.rs +++ b/ethcore/engines/authority-round/src/lib.rs @@ -51,7 +51,7 @@ use macros::map; use keccak_hash::keccak; use log::{info, debug, error, trace, warn}; use engine::signer::EngineSigner; -use ethkey::{self, Signature}; +use parity_crypto::publickey::Signature; use io::{IoContext, IoHandler, TimerToken, IoService}; use itertools::{self, Itertools}; use rlp::{encode, Decodable, DecoderError, Encodable, RlpStream, Rlp}; @@ -385,14 +385,14 @@ impl EmptyStep { let message = keccak(empty_step_rlp(self.step, &self.parent_hash)); let correct_proposer = step_proposer(validators, &self.parent_hash, self.step); - ethkey::verify_address(&correct_proposer, &self.signature.into(), &message) + parity_crypto::publickey::verify_address(&correct_proposer, &self.signature.into(), &message) .map_err(|e| e.into()) } fn author(&self) -> Result { let message = keccak(empty_step_rlp(self.step, &self.parent_hash)); - let public = ethkey::recover(&self.signature.into(), &message)?; - Ok(ethkey::public_to_address(&public)) + let public = parity_crypto::publickey::recover(&self.signature.into(), &message)?; + Ok(parity_crypto::publickey::public_to_address(&public)) } fn sealed(&self) -> SealedEmptyStep { @@ -673,7 +673,7 @@ fn verify_external(header: &Header, validators: &dyn ValidatorSet, empty_steps_t }; let header_seal_hash = header_seal_hash(header, empty_steps_rlp); - !ethkey::verify_address(&correct_proposer, &proposer_signature, &header_seal_hash)? + !parity_crypto::publickey::verify_address(&correct_proposer, &proposer_signature, &header_seal_hash)? }; if is_invalid_proposer { @@ -1663,7 +1663,7 @@ impl Engine for AuthorityRound { fn sign(&self, hash: H256) -> Result { Ok(self.signer.read() .as_ref() - .ok_or(ethkey::Error::InvalidAddress)? + .ok_or(parity_crypto::publickey::Error::InvalidAddress)? .sign(hash)? ) } @@ -1703,7 +1703,7 @@ mod tests { use keccak_hash::keccak; use accounts::AccountProvider; use ethereum_types::{Address, H520, H256, U256}; - use ethkey::Signature; + use parity_crypto::publickey::Signature; use common_types::{ header::Header, engines::{Seal, params::CommonParams}, @@ -2112,7 +2112,7 @@ mod tests { SealedEmptyStep { signature, step } } - fn set_empty_steps_seal(header: &mut Header, step: u64, block_signature: ðkey::Signature, empty_steps: &[SealedEmptyStep]) { + fn set_empty_steps_seal(header: &mut Header, step: u64, block_signature: &Signature, empty_steps: &[SealedEmptyStep]) { header.set_seal(vec![ encode(&(step as usize)), encode(&(&**block_signature as &[u8])), diff --git a/ethcore/engines/basic-authority/Cargo.toml b/ethcore/engines/basic-authority/Cargo.toml index 9c04fa37c79..849014aec49 100644 --- a/ethcore/engines/basic-authority/Cargo.toml +++ b/ethcore/engines/basic-authority/Cargo.toml @@ -12,7 +12,7 @@ common-types = { path = "../../types" } engine = { path = "../../engine" } ethereum-types = "0.8.0" ethjson = { path = "../../../json" } -ethkey = { path = "../../../accounts/ethkey" } +parity-crypto = { version = "0.4.2", features = ["publickey"] } log = "0.4.8" machine = { path = "../../machine" } parking_lot = "0.9" diff --git a/ethcore/engines/basic-authority/src/lib.rs b/ethcore/engines/basic-authority/src/lib.rs index bae548781b4..2587d598697 100644 --- a/ethcore/engines/basic-authority/src/lib.rs +++ b/ethcore/engines/basic-authority/src/lib.rs @@ -34,7 +34,7 @@ use client_traits::EngineClient; use ethereum_types::{H256, H520}; use parking_lot::RwLock; use engine::{Engine, ConstructedVerifier, signer::EngineSigner}; -use ethkey::{self, Signature}; +use parity_crypto::publickey::Signature; use ethjson; use log::trace; use machine::{Machine, executed_block::ExecutedBlock}; @@ -69,7 +69,7 @@ impl engine::EpochVerifier for EpochVerifier { fn verify_external(header: &Header, validators: &dyn ValidatorSet) -> Result<(), Error> { // Check if the signature belongs to a validator, can depend on parent state. let sig = Rlp::new(&header.seal()[0]).as_val::()?; - let signer = ethkey::public_to_address(ðkey::recover(&sig.into(), &header.bare_hash())?); + let signer = parity_crypto::publickey::public_to_address(&parity_crypto::publickey::recover(&sig.into(), &header.bare_hash())?); if *header.author() != signer { return Err(EngineError::NotAuthorized(*header.author()).into()) @@ -201,7 +201,7 @@ impl Engine for BasicAuthority { fn sign(&self, hash: H256) -> Result { Ok(self.signer.read() .as_ref() - .ok_or_else(|| ethkey::Error::InvalidAddress)? + .ok_or_else(|| parity_crypto::publickey::Error::InvalidAddress)? .sign(hash)? ) } diff --git a/ethcore/engines/clique/Cargo.toml b/ethcore/engines/clique/Cargo.toml index 2c831813c83..7a73f04c815 100644 --- a/ethcore/engines/clique/Cargo.toml +++ b/ethcore/engines/clique/Cargo.toml @@ -11,7 +11,7 @@ client-traits = { path = "../../client-traits" } common-types = { path = "../../types" } ethereum-types = "0.8.0" ethjson = { path = "../../../json" } -ethkey = { path = "../../../accounts/ethkey" } +parity-crypto = { version = "0.4.2", features = ["publickey"] } engine = { path = "../../engine" } keccak-hash = "0.4.0" lazy_static = "1.3.0" diff --git a/ethcore/engines/clique/src/lib.rs b/ethcore/engines/clique/src/lib.rs index ac8ed4b86d2..50dad03acc7 100644 --- a/ethcore/engines/clique/src/lib.rs +++ b/ethcore/engines/clique/src/lib.rs @@ -72,7 +72,7 @@ use engine::{ signer::EngineSigner, }; use ethereum_types::{Address, H64, H160, H256, U256}; -use ethkey::Signature; +use parity_crypto::publickey::Signature; use keccak_hash::KECCAK_EMPTY_LIST_RLP; use log::{trace, warn}; use lru_cache::LruCache; diff --git a/ethcore/engines/clique/src/tests.rs b/ethcore/engines/clique/src/tests.rs index 90ed67fcf58..084758c4399 100644 --- a/ethcore/engines/clique/src/tests.rs +++ b/ethcore/engines/clique/src/tests.rs @@ -26,7 +26,7 @@ use ethcore::{ }; use engine::Engine; use ethereum_types::{Address, H256}; -use ethkey::{Secret, KeyPair}; +use parity_crypto::publickey::{Secret, KeyPair}; use state_db::StateDB; use super::*; @@ -183,7 +183,7 @@ impl CliqueTester { b.header.set_difficulty(difficulty); b.header.set_seal(seal); - let sign = ethkey::sign(self.signers[&signer].secret(), &b.header.hash()).unwrap(); + let sign = parity_crypto::publickey::sign(self.signers[&signer].secret(), &b.header.hash()).unwrap(); let mut extra_data = b.header.extra_data().clone(); extra_data.extend_from_slice(&*sign); b.header.set_extra_data(extra_data); diff --git a/ethcore/engines/clique/src/util.rs b/ethcore/engines/clique/src/util.rs index 007f49a2c21..a18fb21a6e7 100644 --- a/ethcore/engines/clique/src/util.rs +++ b/ethcore/engines/clique/src/util.rs @@ -21,7 +21,7 @@ use common_types::{ errors::{EthcoreError as Error, EngineError}, }; use ethereum_types::{Address, H256}; -use ethkey::{public_to_address, recover as ec_recover, Signature}; +use parity_crypto::publickey::{public_to_address, recover as ec_recover, Signature}; use lazy_static::lazy_static; use lru_cache::LruCache; use parking_lot::RwLock; diff --git a/ethcore/engines/validator-set/Cargo.toml b/ethcore/engines/validator-set/Cargo.toml index 9dfd33c2c01..958ea4b480d 100644 --- a/ethcore/engines/validator-set/Cargo.toml +++ b/ethcore/engines/validator-set/Cargo.toml @@ -36,7 +36,7 @@ call-contract = { package = "ethcore-call-contract", path = "../../call-contract engine = { path = "../../engine", features = ["test-helpers"] } env_logger = "0.6.2" ethcore = { path = "../..", features = ["test-helpers"] } -ethkey = { path = "../../../accounts/ethkey" } +parity-crypto = { version = "0.4.2", features = ["publickey"] } keccak-hash = "0.4.0" rustc-hex = "1.0" spec = { path = "../../spec" } diff --git a/ethcore/engines/validator-set/src/multi.rs b/ethcore/engines/validator-set/src/multi.rs index 72b653041c6..76b3e9a1c83 100644 --- a/ethcore/engines/validator-set/src/multi.rs +++ b/ethcore/engines/validator-set/src/multi.rs @@ -168,7 +168,7 @@ mod tests { test_helpers::{generate_dummy_client_with_spec, generate_dummy_client_with_spec_and_data}, }; use ethereum_types::Address; - use ethkey::Secret; + use parity_crypto::publickey::Secret; use keccak_hash::keccak; use spec; diff --git a/ethcore/engines/validator-set/src/safe_contract.rs b/ethcore/engines/validator-set/src/safe_contract.rs index 666d43eac56..cf1a23b1aab 100644 --- a/ethcore/engines/validator-set/src/safe_contract.rs +++ b/ethcore/engines/validator-set/src/safe_contract.rs @@ -470,7 +470,7 @@ mod tests { miner::{self, MinerService}, test_helpers::{generate_dummy_client_with_spec, generate_dummy_client_with_spec_and_data} }; - use ethkey::Secret; + use parity_crypto::publickey::Secret; use ethereum_types::Address; use keccak_hash::keccak; use rustc_hex::FromHex; diff --git a/ethcore/executive-state/Cargo.toml b/ethcore/executive-state/Cargo.toml index 590334e1c58..311d99ecc9b 100644 --- a/ethcore/executive-state/Cargo.toml +++ b/ethcore/executive-state/Cargo.toml @@ -24,7 +24,7 @@ vm = { path = "../vm" } [dev-dependencies] env_logger = "0.5" ethcore = { path = "..", features = ["test-helpers"] } -ethkey = { path = "../../accounts/ethkey" } +parity-crypto = { version = "0.4.2", features = ["publickey"] } evm = { path = "../evm" } keccak-hash = "0.4.0" pod = { path = "../pod" } diff --git a/ethcore/executive-state/src/lib.rs b/ethcore/executive-state/src/lib.rs index 29b4cd78395..b9468a7a750 100644 --- a/ethcore/executive-state/src/lib.rs +++ b/ethcore/executive-state/src/lib.rs @@ -270,7 +270,7 @@ mod tests { use account_state::{Account, CleanupMode}; use common_types::transaction::*; use keccak_hash::{keccak, KECCAK_NULL_RLP}; - use ethkey::Secret; + use parity_crypto::publickey::Secret; use ethereum_types::{H256, U256, Address, BigEndianHash}; use ethcore::{ test_helpers::{get_temp_state, get_temp_state_db} diff --git a/ethcore/machine/Cargo.toml b/ethcore/machine/Cargo.toml index 92df515db5d..dc33e75a968 100644 --- a/ethcore/machine/Cargo.toml +++ b/ethcore/machine/Cargo.toml @@ -37,7 +37,7 @@ common-types = { path = "../types", features = ["test-helpers"] } ethcore = { path = "../", features = ["test-helpers"] } ethcore-io = { path = "../../util/io" } ethjson = { path = "../../json" } -ethkey = { path = "../../accounts/ethkey" } +parity-crypto = { version = "0.4.2", features = ["publickey"] } macros = { path = "../../util/macros" } rustc-hex = "1.0" spec = { path = "../spec" } diff --git a/ethcore/machine/src/executive.rs b/ethcore/machine/src/executive.rs index 44de252a980..e473ec3f20f 100644 --- a/ethcore/machine/src/executive.rs +++ b/ethcore/machine/src/executive.rs @@ -1233,7 +1233,7 @@ mod tests { errors::ExecutionError, transaction::{Action, Transaction}, }; - use ethkey::{Generator, Random}; + use parity_crypto::publickey::{Generator, Random}; use evm::{Factory, VMType, evm_test, evm_test_ignore}; use macros::vec_into; use vm::{ActionParams, ActionValue, CallType, EnvInfo, CreateContractAddress}; diff --git a/ethcore/machine/src/machine.rs b/ethcore/machine/src/machine.rs index 5006ac26f1f..144320acbf3 100644 --- a/ethcore/machine/src/machine.rs +++ b/ethcore/machine/src/machine.rs @@ -435,7 +435,7 @@ mod tests { header.set_number(15); let res = machine.verify_transaction_basic(&transaction, &header); - assert_eq!(res, Err(transaction::Error::InvalidSignature("Crypto error (Invalid EC signature)".into()))); + assert_eq!(res, Err(transaction::Error::InvalidSignature("invalid EC signature".into()))); } #[test] diff --git a/ethcore/machine/src/tx_filter.rs b/ethcore/machine/src/tx_filter.rs index 18074330ed6..1a02a0071cc 100644 --- a/ethcore/machine/src/tx_filter.rs +++ b/ethcore/machine/src/tx_filter.rs @@ -178,7 +178,7 @@ mod test { miner::Miner, test_helpers, }; - use ethkey::{Secret, KeyPair}; + use parity_crypto::publickey::{Secret, KeyPair}; use ethcore_io::IoChannel; use spec::Spec; @@ -200,13 +200,13 @@ mod test { Arc::new(Miner::new_for_tests(&spec, None)), IoChannel::disconnected(), ).unwrap(); - let key1 = KeyPair::from_secret(Secret::from("0000000000000000000000000000000000000000000000000000000000000001")).unwrap(); - let key2 = KeyPair::from_secret(Secret::from("0000000000000000000000000000000000000000000000000000000000000002")).unwrap(); - let key3 = KeyPair::from_secret(Secret::from("0000000000000000000000000000000000000000000000000000000000000003")).unwrap(); - let key4 = KeyPair::from_secret(Secret::from("0000000000000000000000000000000000000000000000000000000000000004")).unwrap(); - let key5 = KeyPair::from_secret(Secret::from("0000000000000000000000000000000000000000000000000000000000000005")).unwrap(); - let key6 = KeyPair::from_secret(Secret::from("0000000000000000000000000000000000000000000000000000000000000006")).unwrap(); - let key7 = KeyPair::from_secret(Secret::from("0000000000000000000000000000000000000000000000000000000000000007")).unwrap(); + let key1 = KeyPair::from_secret(Secret::from_str("0000000000000000000000000000000000000000000000000000000000000001").unwrap()).unwrap(); + let key2 = KeyPair::from_secret(Secret::from_str("0000000000000000000000000000000000000000000000000000000000000002").unwrap()).unwrap(); + let key3 = KeyPair::from_secret(Secret::from_str("0000000000000000000000000000000000000000000000000000000000000003").unwrap()).unwrap(); + let key4 = KeyPair::from_secret(Secret::from_str("0000000000000000000000000000000000000000000000000000000000000004").unwrap()).unwrap(); + let key5 = KeyPair::from_secret(Secret::from_str("0000000000000000000000000000000000000000000000000000000000000005").unwrap()).unwrap(); + let key6 = KeyPair::from_secret(Secret::from_str("0000000000000000000000000000000000000000000000000000000000000006").unwrap()).unwrap(); + let key7 = KeyPair::from_secret(Secret::from_str("0000000000000000000000000000000000000000000000000000000000000007").unwrap()).unwrap(); let filter = TransactionFilter::from_params(spec.params()).unwrap(); let mut basic_tx = Transaction::default(); @@ -279,7 +279,7 @@ mod test { Arc::new(Miner::new_for_tests(&spec, None)), IoChannel::disconnected(), ).unwrap(); - let key1 = KeyPair::from_secret(Secret::from("0000000000000000000000000000000000000000000000000000000000000001")).unwrap(); + let key1 = KeyPair::from_secret(Secret::from_str("0000000000000000000000000000000000000000000000000000000000000001").unwrap()).unwrap(); // The only difference to version 2 is that the contract now knows the transaction's gas price and data. // So we only test those: The contract allows only transactions with either nonzero gas price or short data. @@ -321,10 +321,10 @@ mod test { Arc::new(Miner::new_for_tests(&spec, None)), IoChannel::disconnected(), ).unwrap(); - let key1 = KeyPair::from_secret(Secret::from("0000000000000000000000000000000000000000000000000000000000000001")).unwrap(); - let key2 = KeyPair::from_secret(Secret::from("0000000000000000000000000000000000000000000000000000000000000002")).unwrap(); - let key3 = KeyPair::from_secret(Secret::from("0000000000000000000000000000000000000000000000000000000000000003")).unwrap(); - let key4 = KeyPair::from_secret(Secret::from("0000000000000000000000000000000000000000000000000000000000000004")).unwrap(); + let key1 = KeyPair::from_secret(Secret::from_str("0000000000000000000000000000000000000000000000000000000000000001").unwrap()).unwrap(); + let key2 = KeyPair::from_secret(Secret::from_str("0000000000000000000000000000000000000000000000000000000000000002").unwrap()).unwrap(); + let key3 = KeyPair::from_secret(Secret::from_str("0000000000000000000000000000000000000000000000000000000000000003").unwrap()).unwrap(); + let key4 = KeyPair::from_secret(Secret::from_str("0000000000000000000000000000000000000000000000000000000000000004").unwrap()).unwrap(); let filter = TransactionFilter::from_params(spec.params()).unwrap(); let mut basic_tx = Transaction::default(); diff --git a/ethcore/private-tx/Cargo.toml b/ethcore/private-tx/Cargo.toml index e3fae4e6139..6cc26383b3d 100644 --- a/ethcore/private-tx/Cargo.toml +++ b/ethcore/private-tx/Cargo.toml @@ -20,7 +20,6 @@ ethcore-io = { path = "../../util/io" } ethcore-miner = { path = "../../miner" } ethereum-types = "0.8.0" ethjson = { path = "../../json" } -ethkey = { path = "../../accounts/ethkey" } fetch = { path = "../../util/fetch" } futures = "0.1" parity-util-mem = "0.2.0" @@ -32,7 +31,7 @@ log = "0.4" machine = { path = "../machine" } journaldb = { path = "../../util/journaldb" } parity-bytes = "0.1" -parity-crypto = "0.4.0" +parity-crypto = { version = "0.4.2", features = ["publickey"] } parking_lot = "0.9" trie-db = "0.15.0" patricia-trie-ethereum = { path = "../../util/patricia-trie-ethereum" } diff --git a/ethcore/private-tx/src/encryptor.rs b/ethcore/private-tx/src/encryptor.rs index d62ba546b6a..682c99c345d 100644 --- a/ethcore/private-tx/src/encryptor.rs +++ b/ethcore/private-tx/src/encryptor.rs @@ -26,7 +26,7 @@ use std::collections::hash_map::Entry; use parking_lot::Mutex; use ethereum_types::{H128, H256, Address}; use ethjson; -use ethkey::{Signature, Public}; +use crypto::publickey::{Signature, Public}; use crypto; use futures::Future; use fetch::{Fetch, Client as FetchClient, Method, BodyReader, Request}; diff --git a/ethcore/private-tx/src/error.rs b/ethcore/private-tx/src/error.rs index b9167675ff0..b249b417326 100644 --- a/ethcore/private-tx/src/error.rs +++ b/ethcore/private-tx/src/error.rs @@ -23,8 +23,7 @@ use types::{ errors::{EthcoreError, ExecutionError}, transaction::Error as TransactionError, }; -use ethkey::Error as KeyError; -use ethkey::crypto::Error as CryptoError; +use crypto::publickey::Error as CryptoError; use txpool::VerifiedTransaction; use private_transactions::VerifiedPrivateTransaction; use serde_json::{Error as SerdeError}; @@ -123,9 +122,6 @@ pub enum Error { /// VM execution error. #[display(fmt = "VM execution error {}", _0)] Execution(ExecutionError), - /// General signing error. - #[display(fmt = "General signing error {}", _0)] - Key(KeyError), /// Error of transactions processing. #[display(fmt = "Error of transactions processing {}", _0)] Transaction(TransactionError), @@ -147,7 +143,6 @@ impl error::Error for Error { Error::Json(e) => Some(e), Error::Crypto(e) => Some(e), Error::Execution(e) => Some(e), - Error::Key(e) => Some(e), Error::Transaction(e) => Some(e), Error::Ethcore(e) => Some(e), _ => None, @@ -167,12 +162,6 @@ impl From for Error { } } -impl From for Error { - fn from(err: KeyError) -> Self { - Error::Key(err).into() - } -} - impl From for Error { fn from(err: CryptoError) -> Self { Error::Crypto(err).into() diff --git a/ethcore/private-tx/src/key_server_keys.rs b/ethcore/private-tx/src/key_server_keys.rs index b0ac9353fca..26fe6a6a79c 100644 --- a/ethcore/private-tx/src/key_server_keys.rs +++ b/ethcore/private-tx/src/key_server_keys.rs @@ -145,7 +145,8 @@ impl KeyProvider for StoringKeyProvider { #[cfg(test)] mod tests { use std::sync::Arc; - use ethkey::{Secret, KeyPair}; + use std::str::FromStr; + use crypto::publickey::{Secret, KeyPair}; use bytes::Bytes; use super::*; use registrar::RegistrarClient; @@ -185,7 +186,7 @@ mod tests { #[test] fn should_update_acl_contract() { - let key = KeyPair::from_secret(Secret::from("0000000000000000000000000000000000000000000000000000000000000011")).unwrap(); + let key = KeyPair::from_secret(Secret::from_str("0000000000000000000000000000000000000000000000000000000000000011").unwrap()).unwrap(); let client = DummyRegistryClient::new(Some(key.address())); let keys_data = SecretStoreKeys::new(Arc::new(client), None); keys_data.update_acl_contract(); diff --git a/ethcore/private-tx/src/lib.rs b/ethcore/private-tx/src/lib.rs index a1caf5d9b34..712c19afe8e 100644 --- a/ethcore/private-tx/src/lib.rs +++ b/ethcore/private-tx/src/lib.rs @@ -36,7 +36,6 @@ extern crate ethcore_io as io; extern crate ethcore_miner; extern crate ethereum_types; extern crate ethjson; -extern crate ethkey; extern crate fetch; extern crate futures; extern crate parity_util_mem; @@ -95,7 +94,7 @@ use hash::keccak; use rlp::*; use parking_lot::RwLock; use bytes::Bytes; -use ethkey::{Signature, recover, public_to_address}; +use crypto::publickey::{Signature, recover, public_to_address, Message, KeyPair}; use io::{IoChannel, IoHandler, IoContext, TimerToken}; use machine::{ executive::{Executive, TransactOptions, contract_address as ethcore_contract_address}, @@ -172,7 +171,7 @@ pub trait Signer: Send + Sync { /// Decrypt payload using private key of given address. fn decrypt(&self, account: Address, shared_mac: &[u8], payload: &[u8]) -> Result, Error>; /// Sign given hash using provided account. - fn sign(&self, account: Address, hash: ethkey::Message) -> Result; + fn sign(&self, account: Address, hash: Message) -> Result; } /// Signer implementation that errors on any request. @@ -182,22 +181,22 @@ impl Signer for DummySigner { Err("Decrypting is not supported.".to_owned())? } - fn sign(&self, _account: Address, _hash: ethkey::Message) -> Result { + fn sign(&self, _account: Address, _hash: Message) -> Result { Err("Signing is not supported.".to_owned())? } } /// Signer implementation using multiple keypairs -pub struct KeyPairSigner(pub Vec); +pub struct KeyPairSigner(pub Vec); impl Signer for KeyPairSigner { fn decrypt(&self, account: Address, shared_mac: &[u8], payload: &[u8]) -> Result, Error> { - let kp = self.0.iter().find(|k| k.address() == account).ok_or(ethkey::Error::InvalidAddress)?; - Ok(ethkey::crypto::ecies::decrypt(kp.secret(), shared_mac, payload)?) + let kp = self.0.iter().find(|k| k.address() == account).ok_or(crypto::publickey::Error::InvalidAddress)?; + Ok(crypto::publickey::ecies::decrypt(kp.secret(), shared_mac, payload)?) } - fn sign(&self, account: Address, hash: ethkey::Message) -> Result { - let kp = self.0.iter().find(|k| k.address() == account).ok_or(ethkey::Error::InvalidAddress)?; - Ok(ethkey::sign(kp.secret(), &hash)?) + fn sign(&self, account: Address, hash: Message) -> Result { + let kp = self.0.iter().find(|k| k.address() == account).ok_or(crypto::publickey::Error::InvalidAddress)?; + Ok(crypto::publickey::sign(kp.secret(), &hash)?) } } diff --git a/ethcore/private-tx/src/messages.rs b/ethcore/private-tx/src/messages.rs index 5130b83e534..c2bc43b34fd 100644 --- a/ethcore/private-tx/src/messages.rs +++ b/ethcore/private-tx/src/messages.rs @@ -18,7 +18,7 @@ use ethereum_types::{H256, U256, Address, BigEndianHash}; use bytes::Bytes; use hash::keccak; use rlp::Encodable; -use ethkey::Signature; +use crypto::publickey::Signature; use types::transaction::signature::{add_chain_replay_protection, check_replay_protection}; /// Message with private transaction encrypted diff --git a/ethcore/private-tx/src/private_transactions.rs b/ethcore/private-tx/src/private_transactions.rs index b9108289135..48335eda0a4 100644 --- a/ethcore/private-tx/src/private_transactions.rs +++ b/ethcore/private-tx/src/private_transactions.rs @@ -22,7 +22,7 @@ use bytes::Bytes; use ethcore_miner::pool; use ethereum_types::{H256, U256, Address}; use parity_util_mem::MallocSizeOfExt; -use ethkey::Signature; +use crypto::publickey::Signature; use messages::PrivateTransaction; use parking_lot::RwLock; use types::transaction::{UnverifiedTransaction, SignedTransaction}; diff --git a/ethcore/private-tx/tests/private_contract.rs b/ethcore/private-tx/tests/private_contract.rs index 6c3e57a095e..f7514c456d3 100644 --- a/ethcore/private-tx/tests/private_contract.rs +++ b/ethcore/private-tx/tests/private_contract.rs @@ -22,7 +22,7 @@ extern crate env_logger; extern crate ethcore; extern crate ethcore_io; extern crate ethcore_private_tx; -extern crate ethkey; +extern crate parity_crypto; extern crate keccak_hash as hash; extern crate rustc_hex; extern crate machine; @@ -32,6 +32,7 @@ extern crate spec; extern crate log; use std::sync::Arc; +use std::str::FromStr; use rustc_hex::{FromHex, ToHex}; use types::ids::BlockId; use types::transaction::{Transaction, Action}; @@ -40,7 +41,7 @@ use ethcore::{ miner::Miner, }; use client_traits::BlockChainClient; -use ethkey::{Secret, KeyPair, Signature}; +use parity_crypto::publickey::{Secret, KeyPair, Signature}; use machine::executive::contract_address; use hash::keccak; @@ -52,10 +53,10 @@ fn private_contract() { let _ = ::env_logger::try_init(); let client = generate_dummy_client(0); let chain_id = client.signing_chain_id(); - let key1 = KeyPair::from_secret(Secret::from("0000000000000000000000000000000000000000000000000000000000000011")).unwrap(); - let _key2 = KeyPair::from_secret(Secret::from("0000000000000000000000000000000000000000000000000000000000000012")).unwrap(); - let key3 = KeyPair::from_secret(Secret::from("0000000000000000000000000000000000000000000000000000000000000013")).unwrap(); - let key4 = KeyPair::from_secret(Secret::from("0000000000000000000000000000000000000000000000000000000000000014")).unwrap(); + let key1 = KeyPair::from_secret(Secret::from_str("0000000000000000000000000000000000000000000000000000000000000011").unwrap()).unwrap(); + let _key2 = KeyPair::from_secret(Secret::from_str("0000000000000000000000000000000000000000000000000000000000000012").unwrap()).unwrap(); + let key3 = KeyPair::from_secret(Secret::from_str("0000000000000000000000000000000000000000000000000000000000000013").unwrap()).unwrap(); + let key4 = KeyPair::from_secret(Secret::from_str("0000000000000000000000000000000000000000000000000000000000000014").unwrap()).unwrap(); let signer = Arc::new(ethcore_private_tx::KeyPairSigner(vec![key1.clone(), key3.clone(), key4.clone()])); @@ -118,7 +119,7 @@ fn private_contract() { let private_state = pm.execute_private_transaction(BlockId::Latest, &private_tx).unwrap(); let nonced_state_hash = pm.calculate_state_hash(&private_state, private_contract_nonce); let signatures: Vec<_> = [&key3, &key4].iter().map(|k| - Signature::from(::ethkey::sign(&k.secret(), &nonced_state_hash).unwrap().into_electrum())).collect(); + Signature::from(parity_crypto::publickey::sign(&k.secret(), &nonced_state_hash).unwrap().into_electrum())).collect(); let public_tx = pm.public_transaction(private_state, &private_tx, &signatures, 1.into(), 0.into()).unwrap(); let public_tx = public_tx.sign(&key1.secret(), chain_id); push_block_with_transactions(&client, &[public_tx]); @@ -145,7 +146,7 @@ fn private_contract() { let private_state = pm.execute_private_transaction(BlockId::Latest, &private_tx).unwrap(); let private_state_hash = keccak(&private_state); let signatures: Vec<_> = [&key4].iter().map(|k| - Signature::from(::ethkey::sign(&k.secret(), &private_state_hash).unwrap().into_electrum())).collect(); + Signature::from(parity_crypto::publickey::sign(&k.secret(), &private_state_hash).unwrap().into_electrum())).collect(); let public_tx = pm.public_transaction(private_state, &private_tx, &signatures, 2.into(), 0.into()).unwrap(); let public_tx = public_tx.sign(&key1.secret(), chain_id); push_block_with_transactions(&client, &[public_tx]); @@ -191,10 +192,10 @@ fn call_other_private_contract() { // Create client and provider let client = generate_dummy_client(0); let chain_id = client.signing_chain_id(); - let key1 = KeyPair::from_secret(Secret::from("0000000000000000000000000000000000000000000000000000000000000011")).unwrap(); - let _key2 = KeyPair::from_secret(Secret::from("0000000000000000000000000000000000000000000000000000000000000012")).unwrap(); - let key3 = KeyPair::from_secret(Secret::from("0000000000000000000000000000000000000000000000000000000000000013")).unwrap(); - let key4 = KeyPair::from_secret(Secret::from("0000000000000000000000000000000000000000000000000000000000000014")).unwrap(); + let key1 = KeyPair::from_secret(Secret::from_str("0000000000000000000000000000000000000000000000000000000000000011").unwrap()).unwrap(); + let _key2 = KeyPair::from_secret(Secret::from_str("0000000000000000000000000000000000000000000000000000000000000012").unwrap()).unwrap(); + let key3 = KeyPair::from_secret(Secret::from_str("0000000000000000000000000000000000000000000000000000000000000013").unwrap()).unwrap(); + let key4 = KeyPair::from_secret(Secret::from_str("0000000000000000000000000000000000000000000000000000000000000014").unwrap()).unwrap(); let signer = Arc::new(ethcore_private_tx::KeyPairSigner(vec![key1.clone(), key3.clone(), key4.clone()])); let config = ProviderConfig{ @@ -268,7 +269,7 @@ fn call_other_private_contract() { let private_state = pm.execute_private_transaction(BlockId::Latest, &private_tx).unwrap(); let nonced_state_hash = pm.calculate_state_hash(&private_state, private_contract_nonce); let signatures: Vec<_> = [&key3, &key4].iter().map(|k| - Signature::from(::ethkey::sign(&k.secret(), &nonced_state_hash).unwrap().into_electrum())).collect(); + Signature::from(parity_crypto::publickey::sign(&k.secret(), &nonced_state_hash).unwrap().into_electrum())).collect(); let public_tx = pm.public_transaction(private_state, &private_tx, &signatures, 2.into(), 0.into()).unwrap(); let public_tx = public_tx.sign(&key1.secret(), chain_id); push_block_with_transactions(&client, &[public_tx]); diff --git a/ethcore/snapshot/snapshot-tests/Cargo.toml b/ethcore/snapshot/snapshot-tests/Cargo.toml index efe6ec190d3..fbdfc2e7072 100644 --- a/ethcore/snapshot/snapshot-tests/Cargo.toml +++ b/ethcore/snapshot/snapshot-tests/Cargo.toml @@ -18,7 +18,6 @@ ethcore = { path = "../..", features = ["test-helpers"] } ethcore-db = { path = "../../db" } ethcore-io = { path = "../../../util/io" } ethereum-types = "0.8.0" -ethkey = { path = "../../../accounts/ethkey" } ethtrie = { package = "patricia-trie-ethereum", path = "../../../util/patricia-trie-ethereum" } hash-db = "0.15.0" journaldb = { path = "../../../util/journaldb" } @@ -28,6 +27,7 @@ kvdb = "0.1" kvdb-rocksdb = { version = "0.1.5" } log = "0.4.8" parking_lot = "0.9" +parity-crypto = { version = "0.4.2", features = ["publickey"] } rand = "0.7" rand_xorshift = "0.2" rlp = "0.4.2" diff --git a/ethcore/snapshot/snapshot-tests/src/proof_of_authority.rs b/ethcore/snapshot/snapshot-tests/src/proof_of_authority.rs index b36ab4674dd..976d747e593 100644 --- a/ethcore/snapshot/snapshot-tests/src/proof_of_authority.rs +++ b/ethcore/snapshot/snapshot-tests/src/proof_of_authority.rs @@ -30,7 +30,7 @@ use ethcore::{ miner::{self, MinerService}, }; use ethereum_types::Address; -use ethkey::Secret; +use parity_crypto::publickey::Secret; use keccak_hash::keccak; use lazy_static::lazy_static; use log::trace; diff --git a/ethcore/src/client/client.rs b/ethcore/src/client/client.rs index 795a0e6deaf..4527dba8152 100644 --- a/ethcore/src/client/client.rs +++ b/ethcore/src/client/client.rs @@ -2785,7 +2785,7 @@ mod tests { use blockchain::{ExtrasInsert, BlockProvider}; use client_traits::{BlockChainClient, ChainInfo}; - use ethkey::KeyPair; + use parity_crypto::publickey::KeyPair; use types::{ encoded, engines::ForkChoice, diff --git a/ethcore/src/lib.rs b/ethcore/src/lib.rs index 500bf20688d..f573da498fa 100644 --- a/ethcore/src/lib.rs +++ b/ethcore/src/lib.rs @@ -73,7 +73,7 @@ extern crate ethcore_stratum; extern crate ethash; #[cfg(any(test, feature = "test-helpers"))] -extern crate ethkey; +extern crate parity_crypto; #[cfg(any(test, feature = "test-helpers"))] extern crate ethjson; #[cfg(any(test, feature = "test-helpers"))] diff --git a/ethcore/src/miner/miner.rs b/ethcore/src/miner/miner.rs index 3d55f88eea1..96e5d760b17 100644 --- a/ethcore/src/miner/miner.rs +++ b/ethcore/src/miner/miner.rs @@ -1509,7 +1509,7 @@ mod tests { use super::*; use accounts::AccountProvider; - use ethkey::{Generator, Random}; + use parity_crypto::publickey::{Generator, Random}; use hash::keccak; use rustc_hex::FromHex; diff --git a/ethcore/src/test_helpers/mod.rs b/ethcore/src/test_helpers/mod.rs index 44b298cdbe1..4c427afcd80 100644 --- a/ethcore/src/test_helpers/mod.rs +++ b/ethcore/src/test_helpers/mod.rs @@ -36,7 +36,7 @@ use blockchain::{BlockChain, BlockChainDB, BlockChainDBHandler, Config as BlockC use blooms_db; use bytes::Bytes; use ethereum_types::{H256, U256, Address}; -use ethkey::KeyPair; +use parity_crypto::publickey::KeyPair; use evm::Factory as EvmFactory; use hash::keccak; use io::IoChannel; diff --git a/ethcore/src/test_helpers/test_client.rs b/ethcore/src/test_helpers/test_client.rs index 0409e8249d4..683b08dda1a 100644 --- a/ethcore/src/test_helpers/test_client.rs +++ b/ethcore/src/test_helpers/test_client.rs @@ -28,7 +28,7 @@ use bytes::Bytes; use db::{NUM_COLUMNS, COL_STATE}; use ethcore_miner::pool::VerifiedTransaction; use ethereum_types::{H256, U256, Address}; -use ethkey::{Generator, Random}; +use parity_crypto::publickey::{Generator, Random}; use ethtrie; use hash::keccak; use itertools::Itertools; diff --git a/ethcore/src/tests/client.rs b/ethcore/src/tests/client.rs index 3fb946e0154..ea5675705ef 100644 --- a/ethcore/src/tests/client.rs +++ b/ethcore/src/tests/client.rs @@ -19,7 +19,7 @@ use std::sync::Arc; use account_state::state::StateInfo; use ethereum_types::{U256, Address}; -use ethkey::KeyPair; +use parity_crypto::publickey::KeyPair; use hash::keccak; use io::IoChannel; use tempdir::TempDir; diff --git a/ethcore/src/tests/trace.rs b/ethcore/src/tests/trace.rs index 76d7234d176..ad6f9bbf90a 100644 --- a/ethcore/src/tests/trace.rs +++ b/ethcore/src/tests/trace.rs @@ -16,7 +16,7 @@ //! Client tests of tracing -use ethkey::KeyPair; +use parity_crypto::publickey::KeyPair; use hash::keccak; use block::*; use ethereum_types::{U256, Address}; diff --git a/ethcore/sync/Cargo.toml b/ethcore/sync/Cargo.toml index f8018599abb..8356249d914 100644 --- a/ethcore/sync/Cargo.toml +++ b/ethcore/sync/Cargo.toml @@ -17,7 +17,6 @@ enum_primitive = "0.1.1" ethcore-io = { path = "../../util/io" } ethcore-private-tx = { path = "../private-tx" } ethereum-types = "0.8.0" -ethkey = { path = "../../accounts/ethkey" } fastmap = { path = "../../util/fastmap" } futures = "0.1" keccak-hash = "0.4.0" @@ -26,6 +25,7 @@ log = "0.4" macros = { path = "../../util/macros" } network = { package = "ethcore-network", path = "../../util/network" } parity-runtime = { path = "../../util/runtime" } +parity-crypto = { version = "0.4.2", features = ["publickey"] } parity-util-mem = "0.2.0" rand = "0.7" parking_lot = "0.9" diff --git a/ethcore/sync/src/api.rs b/ethcore/sync/src/api.rs index d8d20bad3aa..17c32eca5de 100644 --- a/ethcore/sync/src/api.rs +++ b/ethcore/sync/src/api.rs @@ -39,7 +39,7 @@ use devp2p::NetworkService; use ethcore_io::TimerToken; use ethcore_private_tx::PrivateStateDB; use ethereum_types::{H256, H512, U256}; -use ethkey::Secret; +use parity_crypto::publickey::Secret; use futures::sync::mpsc as futures_mpsc; use futures::Stream; use light::client::AsLightClient; diff --git a/ethcore/sync/src/block_sync.rs b/ethcore/sync/src/block_sync.rs index 126799a3dd0..8c9ede44767 100644 --- a/ethcore/sync/src/block_sync.rs +++ b/ethcore/sync/src/block_sync.rs @@ -647,7 +647,7 @@ mod tests { use crate::tests::{helpers::TestIo, snapshot::TestSnapshotService}; use ethcore::test_helpers::TestBlockChainClient; - use ethkey::{Random, Generator}; + use parity_crypto::publickey::{Random, Generator}; use keccak_hash::keccak; use parking_lot::RwLock; use rlp::{encode_list, RlpStream}; diff --git a/ethcore/sync/src/chain/mod.rs b/ethcore/sync/src/chain/mod.rs index 780bda34d66..c37a7a6a04a 100644 --- a/ethcore/sync/src/chain/mod.rs +++ b/ethcore/sync/src/chain/mod.rs @@ -1616,7 +1616,7 @@ pub mod tests { #[test] fn should_add_transactions_to_queue() { fn sender(tx: &UnverifiedTransaction) -> Address { - ethkey::public_to_address(&tx.recover_public().unwrap()) + parity_crypto::publickey::public_to_address(&tx.recover_public().unwrap()) } // given diff --git a/ethcore/sync/src/tests/consensus.rs b/ethcore/sync/src/tests/consensus.rs index 6c444a27889..9ee42441b6d 100644 --- a/ethcore/sync/src/tests/consensus.rs +++ b/ethcore/sync/src/tests/consensus.rs @@ -27,7 +27,7 @@ use ethcore::client::Client; use ethcore::miner::{self, MinerService}; use ethcore_io::{IoHandler, IoChannel}; use ethereum_types::{U256, Address}; -use ethkey::{KeyPair, Secret}; +use parity_crypto::publickey::{KeyPair, Secret}; use keccak_hash::keccak; use common_types::{ io_message::ClientIoMessage, diff --git a/ethcore/sync/src/tests/private.rs b/ethcore/sync/src/tests/private.rs index 2a71973326e..7b5f6a36cce 100644 --- a/ethcore/sync/src/tests/private.rs +++ b/ethcore/sync/src/tests/private.rs @@ -37,7 +37,7 @@ use ethcore_io::{IoHandler, IoChannel}; use ethcore_private_tx::{ Provider, ProviderConfig, NoopEncryptor, Importer, SignedPrivateTransaction, StoringKeyProvider }; -use ethkey::KeyPair; +use parity_crypto::publickey::KeyPair; use keccak_hash::keccak; use machine::executive::contract_address; use rustc_hex::FromHex; diff --git a/ethcore/types/Cargo.toml b/ethcore/types/Cargo.toml index 4aa5d8b5dba..509b9d13dd7 100644 --- a/ethcore/types/Cargo.toml +++ b/ethcore/types/Cargo.toml @@ -10,9 +10,9 @@ ethbloom = "0.8.0" ethcore-io = { path = "../../util/io" } ethereum-types = "0.8.0" ethjson = { path = "../../json" } -ethkey = { path = "../../accounts/ethkey" } keccak-hash = "0.4.0" parity-bytes = "0.1" +parity-crypto = { version = "0.4.2", features = ["publickey"] } parity-util-mem = "0.2.0" parity-snappy = "0.1" patricia-trie-ethereum = { path = "../../util/patricia-trie-ethereum" } diff --git a/ethcore/types/src/errors/ethcore_error.rs b/ethcore/types/src/errors/ethcore_error.rs index f7b5abc9ef9..e995dab430a 100644 --- a/ethcore/types/src/errors/ethcore_error.rs +++ b/ethcore/types/src/errors/ethcore_error.rs @@ -21,7 +21,7 @@ use derive_more::{Display, From}; use ethereum_types::{U256, U512}; use ethtrie::TrieError; use parity_snappy::InvalidInput; -use ethkey::Error as EthkeyError; +use parity_crypto::publickey::{Error as EthPublicKeyCryptoError}; use errors::{BlockError, EngineError, ImportError, SnapshotError}; use transaction::Error as TransactionError; @@ -64,7 +64,7 @@ pub enum EthcoreError { Engine(EngineError), /// Ethkey error." #[display(fmt = "Ethkey error: {}", _0)] - Ethkey(EthkeyError), + Ethkey(EthPublicKeyCryptoError), /// RLP decoding errors #[display(fmt = "Decoder error: {}", _0)] Decoder(rlp::DecoderError), diff --git a/ethcore/types/src/lib.rs b/ethcore/types/src/lib.rs index d78995d0c15..58ca86cae94 100644 --- a/ethcore/types/src/lib.rs +++ b/ethcore/types/src/lib.rs @@ -36,7 +36,7 @@ extern crate ethbloom; extern crate ethereum_types; extern crate ethjson; -extern crate ethkey; +extern crate parity_crypto; #[macro_use] extern crate derive_more; extern crate keccak_hash as hash; diff --git a/ethcore/types/src/transaction/error.rs b/ethcore/types/src/transaction/error.rs index 1ad9d535803..1e27b63375c 100644 --- a/ethcore/types/src/transaction/error.rs +++ b/ethcore/types/src/transaction/error.rs @@ -17,7 +17,7 @@ use std::{fmt, error}; use ethereum_types::U256; -use ethkey; +use parity_crypto::publickey::{Error as EthPublicKeyCryptoError}; use rlp; use unexpected::OutOfBounds; @@ -88,8 +88,8 @@ pub enum Error { InvalidRlp(String), } -impl From for Error { - fn from(err: ethkey::Error) -> Self { +impl From for Error { + fn from(err: EthPublicKeyCryptoError) -> Self { Error::InvalidSignature(format!("{}", err)) } } diff --git a/ethcore/types/src/transaction/transaction.rs b/ethcore/types/src/transaction/transaction.rs index bdbc302fcc6..aaa0da216cb 100644 --- a/ethcore/types/src/transaction/transaction.rs +++ b/ethcore/types/src/transaction/transaction.rs @@ -20,7 +20,7 @@ use std::ops::Deref; use ethereum_types::{H256, H160, Address, U256, BigEndianHash}; use ethjson; -use ethkey::{self, Signature, Secret, Public, recover, public_to_address}; +use parity_crypto::publickey::{Signature, Secret, Public, recover, public_to_address}; use hash::keccak; use parity_util_mem::MallocSizeOf; @@ -193,7 +193,7 @@ impl Transaction { /// Signs the transaction as coming from `sender`. pub fn sign(self, secret: &Secret, chain_id: Option) -> SignedTransaction { - let sig = ::ethkey::sign(secret, &self.hash(chain_id)) + let sig = parity_crypto::publickey::sign(secret, &self.hash(chain_id)) .expect("data is valid and context has signing capabilities; qed"); SignedTransaction::new(self.with_signature(sig, chain_id)) .expect("secret is valid so it's recoverable") @@ -367,9 +367,9 @@ impl UnverifiedTransaction { } /// Checks whether the signature has a low 's' value. - pub fn check_low_s(&self) -> Result<(), ethkey::Error> { + pub fn check_low_s(&self) -> Result<(), parity_crypto::publickey::Error> { if !self.signature().is_low_s() { - Err(ethkey::Error::InvalidSignature.into()) + Err(parity_crypto::publickey::Error::InvalidSignature.into()) } else { Ok(()) } @@ -381,7 +381,7 @@ impl UnverifiedTransaction { } /// Recovers the public key of the sender. - pub fn recover_public(&self) -> Result { + pub fn recover_public(&self) -> Result { Ok(recover(&self.signature(), &self.unsigned.hash(self.chain_id()))?) } @@ -392,11 +392,11 @@ impl UnverifiedTransaction { } // Disallow unsigned transactions in case EIP-86 is disabled. if !allow_empty_signature && self.is_unsigned() { - return Err(ethkey::Error::InvalidSignature.into()); + return Err(parity_crypto::publickey::Error::InvalidSignature.into()); } // EIP-86: Transactions of this form MUST have gasprice = 0, nonce = 0, value = 0, and do NOT increment the nonce of account 0. if allow_empty_signature && self.is_unsigned() && !(self.gas_price.is_zero() && self.value.is_zero() && self.nonce.is_zero()) { - return Err(ethkey::Error::InvalidSignature.into()) + return Err(parity_crypto::publickey::Error::InvalidSignature.into()) } match (self.chain_id(), chain_id) { (None, _) => {}, @@ -407,7 +407,7 @@ impl UnverifiedTransaction { } /// Try to verify transaction and recover sender. - pub fn verify_unordered(self) -> Result { + pub fn verify_unordered(self) -> Result { SignedTransaction::new(self) } } @@ -439,7 +439,7 @@ impl From for UnverifiedTransaction { impl SignedTransaction { /// Try to verify transaction and recover sender. - pub fn new(transaction: UnverifiedTransaction) -> Result { + pub fn new(transaction: UnverifiedTransaction) -> Result { if transaction.is_unsigned() { Ok(SignedTransaction { transaction: transaction, @@ -591,7 +591,7 @@ mod tests { #[test] fn signing_eip155_zero_chainid() { - use ethkey::{Random, Generator}; + use parity_crypto::publickey::{Random, Generator}; let key = Random.generate().unwrap(); let t = Transaction { @@ -604,7 +604,7 @@ mod tests { }; let hash = t.hash(Some(0)); - let sig = ::ethkey::sign(&key.secret(), &hash).unwrap(); + let sig = parity_crypto::publickey::sign(&key.secret(), &hash).unwrap(); let u = t.with_signature(sig, Some(0)); assert!(SignedTransaction::new(u).is_ok()); @@ -612,7 +612,7 @@ mod tests { #[test] fn signing() { - use ethkey::{Random, Generator}; + use parity_crypto::publickey::{Random, Generator}; let key = Random.generate().unwrap(); let t = Transaction { @@ -647,7 +647,7 @@ mod tests { #[test] fn should_recover_from_chain_specific_signing() { - use ethkey::{Random, Generator}; + use parity_crypto::publickey::{Random, Generator}; let key = Random.generate().unwrap(); let t = Transaction { action: Action::Create, diff --git a/ethcore/verification/Cargo.toml b/ethcore/verification/Cargo.toml index 41a020e0693..ef86ab86137 100644 --- a/ethcore/verification/Cargo.toml +++ b/ethcore/verification/Cargo.toml @@ -34,7 +34,7 @@ unexpected = { path = "../../util/unexpected" } [dev-dependencies] criterion = "0.3" ethcore = { path = "../", features = ["test-helpers"] } -ethkey = { path = "../../accounts/ethkey" } +parity-crypto = { version = "0.4.2", features = ["publickey"] } machine = { path = "../machine" } null-engine = { path = "../engines/null-engine" } spec = { path = "../spec" } diff --git a/ethcore/verification/src/verification.rs b/ethcore/verification/src/verification.rs index 8cf152b4af7..3f06c39ad66 100644 --- a/ethcore/verification/src/verification.rs +++ b/ethcore/verification/src/verification.rs @@ -375,7 +375,7 @@ mod tests { use parity_bytes::Bytes; use keccak_hash::keccak; use engine::Engine; - use ethkey::{Random, Generator}; + use parity_crypto::publickey::{Random, Generator}; use spec; use ethcore::test_helpers::{ create_test_block_with_data, create_test_block, TestBlockChainClient @@ -587,7 +587,7 @@ mod tests { bad_header.set_transactions_root(eip86_transactions_root.clone()); bad_header.set_uncles_hash(good_uncles_hash.clone()); match basic_test(&create_test_block_with_data(&bad_header, &eip86_transactions, &good_uncles), engine) { - Err(Error::Transaction(ref e)) if e == &::ethkey::Error::InvalidSignature.into() => (), + Err(Error::Transaction(ref e)) if e == &parity_crypto::publickey::Error::InvalidSignature.into() => (), e => panic!("Block verification failed.\nExpected: Transaction Error (Invalid Signature)\nGot: {:?}", e), } diff --git a/miner/Cargo.toml b/miner/Cargo.toml index 297c8a64a57..4cb90abdf30 100644 --- a/miner/Cargo.toml +++ b/miner/Cargo.toml @@ -39,7 +39,7 @@ transaction-pool = "2.0.1" [dev-dependencies] env_logger = "0.5" -ethkey = { path = "../accounts/ethkey" } +parity-crypto = { version = "0.4.2", features = ["publickey"] } rustc-hex = "1.0" [features] diff --git a/miner/local-store/Cargo.toml b/miner/local-store/Cargo.toml index 45ec72a671d..6af34096696 100644 --- a/miner/local-store/Cargo.toml +++ b/miner/local-store/Cargo.toml @@ -17,4 +17,5 @@ serde_json = "1.0" [dev-dependencies] ethkey = { path = "../../accounts/ethkey" } +parity-crypto = { version = "0.4.2", features = ["publickey"] } kvdb-memorydb = "0.1.2" diff --git a/miner/local-store/src/lib.rs b/miner/local-store/src/lib.rs index 7c3a12776b3..6782bf447f6 100644 --- a/miner/local-store/src/lib.rs +++ b/miner/local-store/src/lib.rs @@ -201,7 +201,8 @@ mod tests { use std::sync::Arc; use common_types::transaction::{Transaction, Condition, PendingTransaction}; - use ethkey::{Brain, Generator}; + use ethkey::Brain; + use parity_crypto::publickey::Generator; // we want to test: round-trip of good transactions. // failure to roundtrip bad transactions (but that it doesn't panic) diff --git a/miner/src/lib.rs b/miner/src/lib.rs index f67c437708d..ce9a5ceee60 100644 --- a/miner/src/lib.rs +++ b/miner/src/lib.rs @@ -50,7 +50,7 @@ extern crate trace_time; #[cfg(test)] extern crate rustc_hex; #[cfg(test)] -extern crate ethkey; +extern crate parity_crypto; #[cfg(test)] extern crate env_logger; diff --git a/miner/src/pool/local_transactions.rs b/miner/src/pool/local_transactions.rs index a83af5b72e4..e18c0a4d7b1 100644 --- a/miner/src/pool/local_transactions.rs +++ b/miner/src/pool/local_transactions.rs @@ -235,7 +235,7 @@ impl txpool::Listener for LocalTransactionsList { mod tests { use super::*; use ethereum_types::U256; - use ethkey::{Random, Generator}; + use parity_crypto::publickey::{Random, Generator}; use types::transaction; use txpool::Listener; diff --git a/miner/src/pool/replace.rs b/miner/src/pool/replace.rs index 9ed15bad26a..6b60b562e54 100644 --- a/miner/src/pool/replace.rs +++ b/miner/src/pool/replace.rs @@ -119,7 +119,7 @@ mod tests { use super::*; use std::sync::Arc; - use ethkey::{Random, Generator, KeyPair}; + use parity_crypto::publickey::{Random, Generator, KeyPair}; use pool::tests::tx::{Tx, TxExt}; use pool::tests::client::TestClient; use pool::scoring::*; diff --git a/miner/src/pool/tests/tx.rs b/miner/src/pool/tests/tx.rs index b8f6dca676d..69ba0863db6 100644 --- a/miner/src/pool/tests/tx.rs +++ b/miner/src/pool/tests/tx.rs @@ -15,7 +15,7 @@ // along with Parity Ethereum. If not, see . use ethereum_types::{U256, H256}; -use ethkey::{Random, Generator}; +use parity_crypto::publickey::{Random, Generator}; use rustc_hex::FromHex; use types::transaction::{self, Transaction, SignedTransaction, UnverifiedTransaction}; diff --git a/parity/account_utils.rs b/parity/account_utils.rs index 4f65336315d..727bb875222 100644 --- a/parity/account_utils.rs +++ b/parity/account_utils.rs @@ -166,7 +166,7 @@ mod accounts { mod private_tx { use super::*; - use ethkey::{Signature, Message}; + use parity_crypto::publickey::{Signature, Message}; use ethcore_private_tx::{Error}; pub struct AccountSigner { @@ -211,8 +211,8 @@ mod accounts { } fn insert_dev_account(account_provider: &AccountProvider) { - let secret: ethkey::Secret = "4d5db4107d237df6a3d58ee5f70ae63d73d7658d4026f2eefd2f204c81682cb7".into(); - let dev_account = ethkey::KeyPair::from_secret(secret.clone()).expect("Valid secret produces valid key;qed"); + let secret = parity_crypto::publickey::Secret::from_str("4d5db4107d237df6a3d58ee5f70ae63d73d7658d4026f2eefd2f204c81682cb7".into()).expect("Valid account;qed"); + let dev_account = parity_crypto::publickey::KeyPair::from_secret(secret.clone()).expect("Valid secret produces valid key;qed"); if !account_provider.has_account(dev_account.address()) { match account_provider.insert_account(secret, &Password::from(String::new())) { Err(e) => warn!("Unable to add development account: {}", e), diff --git a/parity/configuration.rs b/parity/configuration.rs index 9fe6c879229..4c99e51c35d 100644 --- a/parity/configuration.rs +++ b/parity/configuration.rs @@ -28,7 +28,7 @@ use parity_version::{version_data, version}; use bytes::Bytes; use ansi_term::Colour; use sync::{NetworkConfiguration, validate_node_url, self}; -use ethkey::{Secret, Public}; +use parity_crypto::publickey::{Secret, Public}; use ethcore::client::VMType; use ethcore::miner::{stratum, MinerOptions}; use snapshot::SnapshotConfiguration; @@ -749,7 +749,7 @@ impl Configuration { ret.listen_address = Some(format!("{}", listen)); ret.public_address = public.map(|p| format!("{}", p)); ret.use_secret = match self.args.arg_node_key.as_ref() - .map(|s| s.parse::().or_else(|_| Secret::from_unsafe_slice(keccak(s).as_bytes())).map_err(|e| format!("Invalid key: {:?}", e)) + .map(|s| s.parse::().or_else(|_| Secret::import_key(keccak(s).as_bytes())).map_err(|e| format!("Invalid key: {:?}", e)) ) { None => None, Some(Ok(key)) => Some(key), diff --git a/parity/lib.rs b/parity/lib.rs index 492c3187515..7e856505374 100644 --- a/parity/lib.rs +++ b/parity/lib.rs @@ -63,6 +63,7 @@ extern crate keccak_hash as hash; extern crate kvdb; extern crate node_filter; extern crate parity_bytes as bytes; +extern crate parity_crypto; extern crate parity_hash_fetch as hash_fetch; extern crate parity_ipfs_api; extern crate parity_local_store as local_store; diff --git a/parity/presale.rs b/parity/presale.rs index 9940fb50c64..a09e05d8c17 100644 --- a/parity/presale.rs +++ b/parity/presale.rs @@ -43,7 +43,7 @@ pub fn execute(cmd: ImportWallet) -> Result { } #[cfg(feature = "accounts")] -pub fn import_account(cmd: &ImportWallet, kp: ethkey::KeyPair, password: Password) { +pub fn import_account(cmd: &ImportWallet, kp: parity_crypto::publickey::KeyPair, password: Password) { use accounts::{AccountProvider, AccountProviderSettings}; use ethstore::EthStore; use ethstore::accounts_dir::RootDiskDirectory; @@ -55,4 +55,4 @@ pub fn import_account(cmd: &ImportWallet, kp: ethkey::KeyPair, password: Passwor } #[cfg(not(feature = "accounts"))] -pub fn import_account(_cmd: &ImportWallet, _kp: ethkey::KeyPair, _password: Password) {} +pub fn import_account(_cmd: &ImportWallet, _kp: parity_crypto::publickey::KeyPair, _password: Password) {} diff --git a/parity/secretstore.rs b/parity/secretstore.rs index 27424e2752b..f4af29e67b4 100644 --- a/parity/secretstore.rs +++ b/parity/secretstore.rs @@ -21,7 +21,8 @@ use dir::default_data_path; use dir::helpers::replace_home; use ethcore::client::Client; use ethcore::miner::Miner; -use ethkey::{Secret, Public, Password}; +use ethkey::Password; +use parity_crypto::publickey::{Secret, Public}; use sync::SyncProvider; use ethereum_types::Address; use parity_runtime::Executor; @@ -121,7 +122,7 @@ mod server { mod server { use std::sync::Arc; use ethcore_secretstore; - use ethkey::KeyPair; + use parity_crypto::publickey::KeyPair; use ansi_term::Colour::{Red, White}; use db; use super::{Configuration, Dependencies, NodeSecretKey, ContractAddress, Executor}; diff --git a/rpc/Cargo.toml b/rpc/Cargo.toml index b392c6f61fd..3e927f699b0 100644 --- a/rpc/Cargo.toml +++ b/rpc/Cargo.toml @@ -51,7 +51,7 @@ ethereum-types = "0.8.0" fastmap = { path = "../util/fastmap" } machine = { path = "../ethcore/machine" } parity-bytes = "0.1" -parity-crypto = "0.4.0" +parity-crypto = { version = "0.4.2", features = ["publickey"] } eip-712 = { path = "../util/EIP-712" } ethjson = { path = "../json" } diff --git a/rpc/src/v1/helpers/dispatch/mod.rs b/rpc/src/v1/helpers/dispatch/mod.rs index 81a865f0fba..f9eee8d0a38 100644 --- a/rpc/src/v1/helpers/dispatch/mod.rs +++ b/rpc/src/v1/helpers/dispatch/mod.rs @@ -78,7 +78,8 @@ use bytes::Bytes; use client_traits::BlockChainClient; use ethcore::miner::MinerService; use ethereum_types::{H520, H256, U256, Address}; -use ethkey::{Password, Signature}; +use ethkey::Password; +use crypto::publickey::Signature; use hash::keccak; use types::transaction::{SignedTransaction, PendingTransaction}; diff --git a/rpc/src/v1/helpers/dispatch/signing.rs b/rpc/src/v1/helpers/dispatch/signing.rs index 8f16bb78ae1..db9cab09590 100644 --- a/rpc/src/v1/helpers/dispatch/signing.rs +++ b/rpc/src/v1/helpers/dispatch/signing.rs @@ -20,7 +20,7 @@ use accounts::AccountProvider; use bytes::Bytes; use crypto::DEFAULT_MAC; use ethereum_types::{H256, U256, Address}; -use ethkey::{Signature}; +use crypto::publickey::Signature; use types::transaction::{Transaction, Action, SignedTransaction}; use jsonrpc_core::Result; diff --git a/rpc/src/v1/helpers/engine_signer.rs b/rpc/src/v1/helpers/engine_signer.rs index fd40dc95e24..c6b86a01a79 100644 --- a/rpc/src/v1/helpers/engine_signer.rs +++ b/rpc/src/v1/helpers/engine_signer.rs @@ -17,7 +17,8 @@ use std::sync::Arc; use accounts::AccountProvider; -use ethkey::{self, Address, Password}; +use ethkey::Password; +use crypto::publickey::{Address, Message, Signature, Error}; /// An implementation of EngineSigner using internal account management. pub struct EngineSigner { @@ -34,10 +35,10 @@ impl EngineSigner { } impl engine::signer::EngineSigner for EngineSigner { - fn sign(&self, message: ethkey::Message) -> Result { + fn sign(&self, message: Message) -> Result { match self.accounts.sign(self.address, Some(self.password.clone()), message) { Ok(ok) => Ok(ok), - Err(_) => Err(ethkey::Error::InvalidSecret), + Err(_) => Err(Error::InvalidSecretKey), } } diff --git a/rpc/src/v1/helpers/secretstore.rs b/rpc/src/v1/helpers/secretstore.rs index 3db4578eb2f..ba93c7d2c25 100644 --- a/rpc/src/v1/helpers/secretstore.rs +++ b/rpc/src/v1/helpers/secretstore.rs @@ -17,7 +17,7 @@ use std::collections::BTreeSet; use rand::{RngCore, rngs::OsRng}; use ethereum_types::{H256, H512}; -use ethkey::{self, Public, Secret, Random, Generator, math}; +use crypto::publickey::{Public, Secret, Random, Generator, ec_math_utils}; use crypto; use bytes::Bytes; use jsonrpc_core::Error; @@ -37,7 +37,7 @@ pub fn generate_document_key(account_public: Public, server_key_public: Public) let (common_point, encrypted_point) = encrypt_secret(document_key.public(), &server_key_public)?; // ..and now encrypt document key with account public - let encrypted_key = ethkey::crypto::ecies::encrypt( + let encrypted_key = crypto::publickey::ecies::encrypt( &account_public, &crypto::DEFAULT_MAC, document_key.public().as_bytes(), @@ -130,9 +130,9 @@ fn decrypt_with_shadow_coefficients(mut decrypted_shadow: Public, mut common_sha .map_err(errors::encryption)?; } - math::public_mul_secret(&mut common_shadow_point, &shadow_coefficients_sum) + ec_math_utils::public_mul_secret(&mut common_shadow_point, &shadow_coefficients_sum) .map_err(errors::encryption)?; - math::public_add(&mut decrypted_shadow, &common_shadow_point) + ec_math_utils::public_add(&mut decrypted_shadow, &common_shadow_point) .map_err(errors::encryption)?; Ok(decrypted_shadow) } @@ -145,15 +145,15 @@ fn encrypt_secret(secret: &Public, joint_public: &Public) -> Result<(Public, Pub .map_err(errors::encryption)?; // k * T - let mut common_point = math::generation_point(); - math::public_mul_secret(&mut common_point, key_pair.secret()) + let mut common_point = ec_math_utils::generation_point(); + ec_math_utils::public_mul_secret(&mut common_point, key_pair.secret()) .map_err(errors::encryption)?; // M + k * y let mut encrypted_point = joint_public.clone(); - math::public_mul_secret(&mut encrypted_point, key_pair.secret()) + ec_math_utils::public_mul_secret(&mut encrypted_point, key_pair.secret()) .map_err(errors::encryption)?; - math::public_add(&mut encrypted_point, secret) + ec_math_utils::public_add(&mut encrypted_point, secret) .map_err(errors::encryption)?; Ok((common_point, encrypted_point)) diff --git a/rpc/src/v1/helpers/signature.rs b/rpc/src/v1/helpers/signature.rs index b191a3737e8..f9ca0ea2e8c 100644 --- a/rpc/src/v1/helpers/signature.rs +++ b/rpc/src/v1/helpers/signature.rs @@ -14,7 +14,7 @@ // You should have received a copy of the GNU General Public License // along with Parity Ethereum. If not, see . -use ethkey::{recover, public_to_address, Signature}; +use crypto::publickey::{recover, public_to_address, Signature}; use ethereum_types::{H256, U64}; use jsonrpc_core::Result; use v1::types::{Bytes, RecoveredAccount}; @@ -54,7 +54,7 @@ pub fn verify_signature( #[cfg(test)] mod tests { use super::*; - use ethkey::Generator; + use crypto::publickey::{Generator, Random}; use ethereum_types::{H160, U64}; pub fn add_chain_replay_protection(v: u64, chain_id: Option) -> u64 { @@ -71,9 +71,9 @@ mod tests { /// mocked signer fn sign(should_prefix: bool, data: Vec, signing_chain_id: Option) -> (H160, [u8; 32], [u8; 32], U64) { let hash = if should_prefix { eth_data_hash(data) } else { keccak(data) }; - let account = ethkey::Random.generate().unwrap(); + let account = Random.generate().unwrap(); let address = account.address(); - let sig = ethkey::sign(account.secret(), &hash).unwrap(); + let sig = crypto::publickey::sign(account.secret(), &hash).unwrap(); let (r, s, v) = (sig.r(), sig.s(), sig.v()); let v = add_chain_replay_protection(v as u64, signing_chain_id); let (r_buf, s_buf) = { diff --git a/rpc/src/v1/impls/light/parity.rs b/rpc/src/v1/impls/light/parity.rs index 4171df78dd6..9f929ee3f55 100644 --- a/rpc/src/v1/impls/light/parity.rs +++ b/rpc/src/v1/impls/light/parity.rs @@ -21,7 +21,8 @@ use std::collections::BTreeMap; use version::version_data; use crypto::DEFAULT_MAC; -use ethkey::{crypto::ecies, Brain, Generator}; +use ethkey::Brain; +use crypto::publickey::{Generator, ecies}; use ethstore::random_phrase; use sync::{LightSyncInfo, LightSyncProvider, LightNetworkDispatcher, ManageNetwork}; use updater::VersionInfo as UpdaterVersionInfo; diff --git a/rpc/src/v1/impls/parity.rs b/rpc/src/v1/impls/parity.rs index 2151ecc9419..83ea0e799fd 100644 --- a/rpc/src/v1/impls/parity.rs +++ b/rpc/src/v1/impls/parity.rs @@ -26,7 +26,8 @@ use ethcore::miner::{self, MinerService, FilterOptions}; use snapshot::SnapshotService; use account_state::state::StateInfo; use ethcore_logger::RotatingLogger; -use ethkey::{crypto::ecies, Brain, Generator}; +use ethkey::Brain; +use crypto::publickey::{ecies, Generator}; use ethstore::random_phrase; use jsonrpc_core::futures::future; use jsonrpc_core::{BoxFuture, Result}; diff --git a/rpc/src/v1/impls/parity_accounts.rs b/rpc/src/v1/impls/parity_accounts.rs index 62bc6d1ccef..c0549282666 100644 --- a/rpc/src/v1/impls/parity_accounts.rs +++ b/rpc/src/v1/impls/parity_accounts.rs @@ -22,7 +22,8 @@ use std::collections::{ }; use ethereum_types::{Address, H160, H256, H520}; -use ethkey::{Brain, Generator, Secret}; +use ethkey::{Brain, Password}; +use crypto::publickey::{Generator, Secret}; use ethstore::KeyFile; use accounts::AccountProvider; use jsonrpc_core::Result; @@ -30,7 +31,6 @@ use v1::helpers::deprecated::{self, DeprecationNotice}; use v1::helpers::errors; use v1::traits::{ParityAccounts, ParityAccountsInfo}; use v1::types::{Derive, DeriveHierarchical, DeriveHash, ExtAccountInfo, AccountInfo}; -use ethkey::Password; /// Account management (personal) rpc implementation. pub struct ParityAccountsClient { @@ -134,7 +134,7 @@ impl ParityAccounts for ParityAccountsClient { fn new_account_from_secret(&self, secret: H256, pass: Password) -> Result { self.deprecation_notice("parity_newAccountFromSecret"); - let secret = Secret::from_unsafe_slice(&secret.0) + let secret = Secret::import_key(&secret.0) .map_err(|e| errors::account("Could not create account.", e))?; self.accounts.insert_account(secret, &pass) .map(Into::into) diff --git a/rpc/src/v1/impls/parity_set.rs b/rpc/src/v1/impls/parity_set.rs index 0db3c99ca27..84b335cb96a 100644 --- a/rpc/src/v1/impls/parity_set.rs +++ b/rpc/src/v1/impls/parity_set.rs @@ -23,7 +23,7 @@ use client_traits::BlockChainClient; use types::client_types::Mode; use ethcore::miner::{self, MinerService}; use ethereum_types::{H160, H256, U256}; -use ethkey; +use crypto::publickey::KeyPair; use fetch::{self, Fetch}; use hash::keccak_buffer; use sync::ManageNetwork; @@ -161,7 +161,7 @@ impl ParitySet for ParitySetClient where } fn set_engine_signer_secret(&self, secret: H256) -> Result { - let keypair = ethkey::KeyPair::from_secret(secret.into()).map_err(|e| errors::account("Invalid secret", e))?; + let keypair = KeyPair::from_secret(secret.into()).map_err(|e| errors::account("Invalid secret", e))?; self.miner.set_author(miner::Author::Sealer(engine::signer::from_keypair(keypair))); Ok(true) } diff --git a/rpc/src/v1/impls/personal.rs b/rpc/src/v1/impls/personal.rs index e0d6a97fe28..458154a9965 100644 --- a/rpc/src/v1/impls/personal.rs +++ b/rpc/src/v1/impls/personal.rs @@ -22,7 +22,7 @@ use accounts::AccountProvider; use bytes::Bytes; use eip_712::{EIP712, hash_structured_data}; use ethereum_types::{H160, H256, H520, U128, Address}; -use ethkey::{public_to_address, recover, Signature}; +use crypto::publickey::{public_to_address, recover, Signature}; use types::transaction::{PendingTransaction, SignedTransaction}; use jsonrpc_core::futures::{future, Future}; diff --git a/rpc/src/v1/impls/secretstore.rs b/rpc/src/v1/impls/secretstore.rs index b6526b85d5f..3e5ed0a8112 100644 --- a/rpc/src/v1/impls/secretstore.rs +++ b/rpc/src/v1/impls/secretstore.rs @@ -22,7 +22,7 @@ use std::sync::Arc; use accounts::AccountProvider; use crypto::DEFAULT_MAC; use ethereum_types::{H160, H256, H512}; -use ethkey::Secret; +use crypto::publickey::Secret; use jsonrpc_core::Result; use v1::helpers::errors; @@ -54,7 +54,7 @@ impl SecretStoreClient { /// Decrypt secret key using account' private key fn decrypt_secret(&self, address: H160, password: Password, key: Bytes) -> Result { self.decrypt_key(address, password, key) - .and_then(|s| Secret::from_unsafe_slice(&s).map_err(|e| errors::account("invalid secret", e))) + .and_then(|s| Secret::import_key(&s).map_err(|e| errors::account("invalid secret", e))) } } diff --git a/rpc/src/v1/impls/signer.rs b/rpc/src/v1/impls/signer.rs index b135a1fbaa4..a115ab531a8 100644 --- a/rpc/src/v1/impls/signer.rs +++ b/rpc/src/v1/impls/signer.rs @@ -19,7 +19,6 @@ use std::sync::Arc; use ethereum_types::{U256, H520}; -use ethkey; use parity_runtime::Executor; use parking_lot::Mutex; use rlp::Rlp; @@ -216,16 +215,16 @@ impl Signer for SignerClient { }, ConfirmationPayload::EthSignMessage(address, data) => { let expected_hash = eth_data_hash(data); - let signature = ethkey::Signature::from_electrum(&bytes.0); - match ethkey::verify_address(&address, &signature, &expected_hash) { + let signature = crypto::publickey::Signature::from_electrum(&bytes.0); + match crypto::publickey::verify_address(&address, &signature, &expected_hash) { Ok(true) => Ok(ConfirmationResponse::Signature(H520::from_slice(bytes.0.as_slice()))), Ok(false) => Err(errors::invalid_params("Sender address does not match the signature.", ())), Err(err) => Err(errors::invalid_params("Invalid signature received.", err)), } }, ConfirmationPayload::SignMessage(address, hash) => { - let signature = ethkey::Signature::from_electrum(&bytes.0); - match ethkey::verify_address(&address, &signature, &hash) { + let signature = crypto::publickey::Signature::from_electrum(&bytes.0); + match crypto::publickey::verify_address(&address, &signature, &hash) { Ok(true) => Ok(ConfirmationResponse::Signature(H520::from_slice(bytes.0.as_slice()))), Ok(false) => Err(errors::invalid_params("Sender address does not match the signature.", ())), Err(err) => Err(errors::invalid_params("Invalid signature received.", err)), diff --git a/rpc/src/v1/tests/mocked/parity.rs b/rpc/src/v1/tests/mocked/parity.rs index 85f80350337..06da1861e4a 100644 --- a/rpc/src/v1/tests/mocked/parity.rs +++ b/rpc/src/v1/tests/mocked/parity.rs @@ -18,7 +18,7 @@ use std::sync::Arc; use ethcore::test_helpers::TestBlockChainClient; use ethcore_logger::RotatingLogger; use ethereum_types::{Address, U256, H256, BigEndianHash, Bloom}; -use ethstore::ethkey::{Generator, Random}; +use crypto::publickey::{Generator, Random}; use machine::executed::Executed; use miner::pool::local_transactions::Status as LocalTransactionStatus; use sync::ManageNetwork; diff --git a/rpc/src/v1/tests/mocked/personal.rs b/rpc/src/v1/tests/mocked/personal.rs index b9c3cb6d77d..5e6d3a1c394 100644 --- a/rpc/src/v1/tests/mocked/personal.rs +++ b/rpc/src/v1/tests/mocked/personal.rs @@ -34,7 +34,7 @@ use v1::tests::helpers::TestMinerService; use v1::types::{EIP191Version, PresignedTransaction}; use rustc_hex::ToHex; use serde_json::to_value; -use ethkey::Secret; +use crypto::publickey::Secret; struct PersonalTester { _runtime: Runtime, diff --git a/rpc/src/v1/tests/mocked/secretstore.rs b/rpc/src/v1/tests/mocked/secretstore.rs index 96e20d0028b..386a2455f72 100644 --- a/rpc/src/v1/tests/mocked/secretstore.rs +++ b/rpc/src/v1/tests/mocked/secretstore.rs @@ -19,7 +19,7 @@ use std::sync::Arc; use crypto::DEFAULT_MAC; use accounts::AccountProvider; use ethereum_types::H256; -use ethkey::{KeyPair, Signature, verify_public}; +use crypto::publickey::{KeyPair, Signature, verify_public}; use serde_json; use jsonrpc_core::{IoHandler, Success}; diff --git a/rpc/src/v1/tests/mocked/signing.rs b/rpc/src/v1/tests/mocked/signing.rs index cf7da360e68..184d3d8b6ec 100644 --- a/rpc/src/v1/tests/mocked/signing.rs +++ b/rpc/src/v1/tests/mocked/signing.rs @@ -35,8 +35,7 @@ use accounts::AccountProvider; use bytes::ToPretty; use ethcore::test_helpers::TestBlockChainClient; use ethereum_types::{U256, Address, Signature, H256}; -use ethkey::Secret; -use ethstore::ethkey::{Generator, Random}; +use crypto::publickey::{Generator, Random, Secret}; use parity_runtime::{Runtime, Executor}; use parking_lot::Mutex; use serde_json; diff --git a/secret-store/Cargo.toml b/secret-store/Cargo.toml index 9402a163188..24af2a798f6 100644 --- a/secret-store/Cargo.toml +++ b/secret-store/Cargo.toml @@ -17,7 +17,6 @@ ethcore-accounts = { path = "../accounts", optional = true} ethcore-call-contract = { path = "../ethcore/call-contract" } ethcore-sync = { path = "../ethcore/sync" } ethereum-types = "0.8.0" -ethkey = { path = "../accounts/ethkey" } futures = "0.1" hyper = { version = "0.12", default-features = false } keccak-hash = "0.4.0" @@ -25,7 +24,7 @@ kvdb = "0.1" lazy_static = "1.0" log = "0.4" parity-bytes = "0.1" -parity-crypto = "0.4.0" +parity-crypto = { version = "0.4.2", features = ["publickey"] } parity-runtime = { path = "../util/runtime" } parking_lot = "0.9" percent-encoding = "2.1.0" @@ -43,6 +42,7 @@ jsonrpc-server-utils = "14.0.1" [dev-dependencies] env_logger = "0.5" +ethkey = { path = "../accounts/ethkey" } ethcore = { path = "../ethcore", features = ["test-helpers"] } tempdir = "0.3" kvdb-rocksdb = "0.1.5" diff --git a/secret-store/src/key_server.rs b/secret-store/src/key_server.rs index 233a9b3db4f..bbb45b5afdd 100644 --- a/secret-store/src/key_server.rs +++ b/secret-store/src/key_server.rs @@ -19,7 +19,7 @@ use std::sync::Arc; use futures::{future::{err, result}, Future}; use parking_lot::Mutex; use crypto::DEFAULT_MAC; -use ethkey::{crypto, public_to_address}; +use crypto::publickey::public_to_address; use parity_runtime::Executor; use super::acl_storage::AclStorage; use super::key_storage::KeyStorage; @@ -164,7 +164,7 @@ impl DocumentKeyServer for KeyServerImpl { // encrypt document key with requestor public key let encrypted_document_key = stored_document_key - .and_then(|(public, document_key)| crypto::ecies::encrypt(&public, &DEFAULT_MAC, document_key.as_bytes()) + .and_then(|(public, document_key)| crypto::publickey::ecies::encrypt(&public, &DEFAULT_MAC, document_key.as_bytes()) .map_err(|err| Error::Internal(format!("Error encrypting document key: {}", err)))); Box::new(encrypted_document_key) @@ -190,7 +190,7 @@ impl DocumentKeyServer for KeyServerImpl { // encrypt document key with requestor public key let encrypted_document_key = stored_document_key .and_then(|(public, document_key)| - crypto::ecies::encrypt(&public, &DEFAULT_MAC, document_key.decrypted_secret.as_bytes()) + crypto::publickey::ecies::encrypt(&public, &DEFAULT_MAC, document_key.decrypted_secret.as_bytes()) .map_err(|err| Error::Internal(format!("Error encrypting document key: {}", err)))); Box::new(encrypted_document_key) @@ -235,7 +235,7 @@ impl MessageSigner for KeyServerImpl { // encrypt signature with requestor public key let encrypted_signature = combined_signature - .and_then(|(public, combined_signature)| crypto::ecies::encrypt(&public, &DEFAULT_MAC, &combined_signature) + .and_then(|(public, combined_signature)| crypto::publickey::ecies::encrypt(&public, &DEFAULT_MAC, &combined_signature) .map_err(|err| Error::Internal(format!("Error encrypting message signature: {}", err)))); Box::new(encrypted_signature) @@ -261,7 +261,7 @@ impl MessageSigner for KeyServerImpl { // encrypt combined signature with requestor public key let encrypted_signature = signature - .and_then(|(public, signature)| crypto::ecies::encrypt(&public, &DEFAULT_MAC, &*signature) + .and_then(|(public, signature)| crypto::publickey::ecies::encrypt(&public, &DEFAULT_MAC, &*signature) .map_err(|err| Error::Internal(format!("Error encrypting message signature: {}", err)))); Box::new(encrypted_signature) @@ -314,7 +314,7 @@ pub mod tests { use std::collections::BTreeMap; use futures::Future; use crypto::DEFAULT_MAC; - use ethkey::{self, crypto, Secret, Random, Generator, verify_public}; + use crypto::publickey::{Secret, Random, Generator, verify_public}; use acl_storage::DummyAclStorage; use key_storage::KeyStorage; use key_storage::tests::DummyKeyStorage; @@ -489,13 +489,13 @@ pub mod tests { let threshold = 0; let document = Random.generate().unwrap().secret().clone(); let secret = Random.generate().unwrap().secret().clone(); - let signature: Requester = ethkey::sign(&secret, &document).unwrap().into(); + let signature: Requester = crypto::publickey::sign(&secret, &document).unwrap().into(); let generated_key = key_servers[0].generate_document_key( *document, signature.clone(), threshold, ).wait().unwrap(); - let generated_key = crypto::ecies::decrypt(&secret, &DEFAULT_MAC, &generated_key).unwrap(); + let generated_key = crypto::publickey::ecies::decrypt(&secret, &DEFAULT_MAC, &generated_key).unwrap(); // now let's try to retrieve key back for key_server in key_servers.iter() { @@ -503,7 +503,7 @@ pub mod tests { *document, signature.clone(), ).wait().unwrap(); - let retrieved_key = crypto::ecies::decrypt(&secret, &DEFAULT_MAC, &retrieved_key).unwrap(); + let retrieved_key = crypto::publickey::ecies::decrypt(&secret, &DEFAULT_MAC, &retrieved_key).unwrap(); assert_eq!(retrieved_key, generated_key); } drop(runtime); @@ -519,13 +519,13 @@ pub mod tests { // generate document key let document = Random.generate().unwrap().secret().clone(); let secret = Random.generate().unwrap().secret().clone(); - let signature: Requester = ethkey::sign(&secret, &document).unwrap().into(); + let signature: Requester = crypto::publickey::sign(&secret, &document).unwrap().into(); let generated_key = key_servers[0].generate_document_key( *document, signature.clone(), *threshold, ).wait().unwrap(); - let generated_key = crypto::ecies::decrypt(&secret, &DEFAULT_MAC, &generated_key).unwrap(); + let generated_key = crypto::publickey::ecies::decrypt(&secret, &DEFAULT_MAC, &generated_key).unwrap(); // now let's try to retrieve key back for (i, key_server) in key_servers.iter().enumerate() { @@ -533,7 +533,7 @@ pub mod tests { *document, signature.clone(), ).wait().unwrap(); - let retrieved_key = crypto::ecies::decrypt(&secret, &DEFAULT_MAC, &retrieved_key).unwrap(); + let retrieved_key = crypto::publickey::ecies::decrypt(&secret, &DEFAULT_MAC, &retrieved_key).unwrap(); assert_eq!(retrieved_key, generated_key); let key_share = key_storages[i].get(&document).unwrap().unwrap(); @@ -554,7 +554,7 @@ pub mod tests { // generate server key let server_key_id = Random.generate().unwrap().secret().clone(); let requestor_secret = Random.generate().unwrap().secret().clone(); - let signature: Requester = ethkey::sign(&requestor_secret, &server_key_id).unwrap().into(); + let signature: Requester = crypto::publickey::sign(&requestor_secret, &server_key_id).unwrap().into(); let server_public = key_servers[0].generate_key( *server_key_id, signature.clone(), @@ -572,7 +572,7 @@ pub mod tests { // now let's try to retrieve key back for key_server in key_servers.iter() { let retrieved_key = key_server.restore_document_key(*server_key_id, signature.clone()).wait().unwrap(); - let retrieved_key = crypto::ecies::decrypt(&requestor_secret, &DEFAULT_MAC, &retrieved_key).unwrap(); + let retrieved_key = crypto::publickey::ecies::decrypt(&requestor_secret, &DEFAULT_MAC, &retrieved_key).unwrap(); let retrieved_key = Public::from_slice(&retrieved_key); assert_eq!(retrieved_key, generated_key); } @@ -590,7 +590,7 @@ pub mod tests { // generate server key let server_key_id = Random.generate().unwrap().secret().clone(); let requestor_secret = Random.generate().unwrap().secret().clone(); - let signature: Requester = ethkey::sign(&requestor_secret, &server_key_id).unwrap().into(); + let signature: Requester = crypto::publickey::sign(&requestor_secret, &server_key_id).unwrap().into(); let server_public = key_servers[0].generate_key( *server_key_id, signature.clone(), @@ -604,9 +604,9 @@ pub mod tests { signature, message_hash, ).wait().unwrap(); - let combined_signature = crypto::ecies::decrypt(&requestor_secret, &DEFAULT_MAC, &combined_signature).unwrap(); - let signature_c = Secret::from_slice(&combined_signature[..32]).unwrap(); - let signature_s = Secret::from_slice(&combined_signature[32..]).unwrap(); + let combined_signature = crypto::publickey::ecies::decrypt(&requestor_secret, &DEFAULT_MAC, &combined_signature).unwrap(); + let signature_c = Secret::copy_from_slice(&combined_signature[..32]).unwrap(); + let signature_s = Secret::copy_from_slice(&combined_signature[32..]).unwrap(); // check signature assert_eq!(math::verify_schnorr_signature(&server_public, &(signature_c, signature_s), &message_hash), Ok(true)); @@ -623,20 +623,20 @@ pub mod tests { let threshold = 0; let document = Random.generate().unwrap().secret().clone(); let secret = Random.generate().unwrap().secret().clone(); - let signature: Requester = ethkey::sign(&secret, &document).unwrap().into(); + let signature: Requester = crypto::publickey::sign(&secret, &document).unwrap().into(); let generated_key = key_servers[0].generate_document_key( *document, signature.clone(), threshold, ).wait().unwrap(); - let generated_key = crypto::ecies::decrypt(&secret, &DEFAULT_MAC, &generated_key).unwrap(); + let generated_key = crypto::publickey::ecies::decrypt(&secret, &DEFAULT_MAC, &generated_key).unwrap(); // remove key from node0 key_storages[0].remove(&document).unwrap(); // now let's try to retrieve key back by requesting it from node0, so that session must be delegated let retrieved_key = key_servers[0].restore_document_key(*document, signature).wait().unwrap(); - let retrieved_key = crypto::ecies::decrypt(&secret, &DEFAULT_MAC, &retrieved_key).unwrap(); + let retrieved_key = crypto::publickey::ecies::decrypt(&secret, &DEFAULT_MAC, &retrieved_key).unwrap(); assert_eq!(retrieved_key, generated_key); drop(runtime); } @@ -650,7 +650,7 @@ pub mod tests { // generate server key let server_key_id = Random.generate().unwrap().secret().clone(); let requestor_secret = Random.generate().unwrap().secret().clone(); - let signature: Requester = ethkey::sign(&requestor_secret, &server_key_id).unwrap().into(); + let signature: Requester = crypto::publickey::sign(&requestor_secret, &server_key_id).unwrap().into(); let server_public = key_servers[0].generate_key(*server_key_id, signature.clone(), threshold).wait().unwrap(); // remove key from node0 @@ -663,9 +663,9 @@ pub mod tests { signature, message_hash, ).wait().unwrap(); - let combined_signature = crypto::ecies::decrypt(&requestor_secret, &DEFAULT_MAC, &combined_signature).unwrap(); - let signature_c = Secret::from_slice(&combined_signature[..32]).unwrap(); - let signature_s = Secret::from_slice(&combined_signature[32..]).unwrap(); + let combined_signature = crypto::publickey::ecies::decrypt(&requestor_secret, &DEFAULT_MAC, &combined_signature).unwrap(); + let signature_c = Secret::copy_from_slice(&combined_signature[..32]).unwrap(); + let signature_s = Secret::copy_from_slice(&combined_signature[32..]).unwrap(); // check signature assert_eq!(math::verify_schnorr_signature(&server_public, &(signature_c, signature_s), &message_hash), Ok(true)); @@ -681,7 +681,7 @@ pub mod tests { // generate server key let server_key_id = Random.generate().unwrap().secret().clone(); let requestor_secret = Random.generate().unwrap().secret().clone(); - let signature = ethkey::sign(&requestor_secret, &server_key_id).unwrap(); + let signature = crypto::publickey::sign(&requestor_secret, &server_key_id).unwrap(); let server_public = key_servers[0].generate_key( *server_key_id, signature.clone().into(), @@ -698,7 +698,7 @@ pub mod tests { signature.clone().into(), message_hash, ).wait().unwrap(); - let signature = crypto::ecies::decrypt(&requestor_secret, &DEFAULT_MAC, &signature).unwrap(); + let signature = crypto::publickey::ecies::decrypt(&requestor_secret, &DEFAULT_MAC, &signature).unwrap(); let signature = H520::from_slice(&signature[0..65]); // check signature diff --git a/secret-store/src/key_server_cluster/admin_sessions/key_version_negotiation_session.rs b/secret-store/src/key_server_cluster/admin_sessions/key_version_negotiation_session.rs index 841aa889e5c..2790f9da174 100644 --- a/secret-store/src/key_server_cluster/admin_sessions/key_version_negotiation_session.rs +++ b/secret-store/src/key_server_cluster/admin_sessions/key_version_negotiation_session.rs @@ -17,7 +17,7 @@ use std::sync::Arc; use std::collections::{BTreeSet, BTreeMap}; use ethereum_types::{Address, H256}; -use ethkey::Secret; +use crypto::publickey::Secret; use futures::Oneshot; use parking_lot::Mutex; use key_server_cluster::{Error, SessionId, NodeId, DocumentKeyShare}; @@ -617,7 +617,7 @@ mod tests { use std::sync::Arc; use std::collections::{VecDeque, BTreeMap, BTreeSet}; use ethereum_types::{H512, H160, Address}; - use ethkey::public_to_address; + use crypto::publickey::public_to_address; use key_server_cluster::{NodeId, SessionId, Error, KeyStorage, DummyKeyStorage, DocumentKeyShare, DocumentKeyShareVersion}; use key_server_cluster::math; diff --git a/secret-store/src/key_server_cluster/admin_sessions/servers_set_change_session.rs b/secret-store/src/key_server_cluster/admin_sessions/servers_set_change_session.rs index 5dcc7ea7093..9bc6d1df81f 100644 --- a/secret-store/src/key_server_cluster/admin_sessions/servers_set_change_session.rs +++ b/secret-store/src/key_server_cluster/admin_sessions/servers_set_change_session.rs @@ -20,7 +20,7 @@ use std::collections::btree_map::Entry; use futures::Oneshot; use parking_lot::Mutex; use ethereum_types::H256; -use ethkey::{Public, Signature}; +use crypto::publickey::{Public, Signature}; use key_server_cluster::{Error, NodeId, SessionId, KeyStorage}; use key_server_cluster::math; use key_server_cluster::cluster::Cluster; @@ -1050,7 +1050,7 @@ pub mod tests { use std::sync::Arc; use std::collections::{VecDeque, BTreeMap, BTreeSet}; use ethereum_types::H256; - use ethkey::{Random, Generator, Public, Signature, KeyPair, sign}; + use crypto::publickey::{Random, Generator, Public, Signature, KeyPair, sign}; use key_server_cluster::{NodeId, SessionId, Error, KeyStorage, NodeKeyPair, PlainNodeKeyPair}; use key_server_cluster::cluster_sessions::ClusterSession; use key_server_cluster::cluster::tests::MessageLoop as ClusterMessageLoop; diff --git a/secret-store/src/key_server_cluster/admin_sessions/share_add_session.rs b/secret-store/src/key_server_cluster/admin_sessions/share_add_session.rs index c190396a507..94e6e989379 100644 --- a/secret-store/src/key_server_cluster/admin_sessions/share_add_session.rs +++ b/secret-store/src/key_server_cluster/admin_sessions/share_add_session.rs @@ -17,7 +17,7 @@ use std::sync::Arc; use std::collections::{BTreeSet, BTreeMap}; use ethereum_types::{H256, Address}; -use ethkey::{Public, Secret, Signature}; +use crypto::publickey::{Public, Secret, Signature}; use futures::Oneshot; use parking_lot::Mutex; use key_server_cluster::{Error, SessionId, NodeId, DocumentKeyShare, DocumentKeyShareVersion, KeyStorage}; @@ -888,7 +888,7 @@ impl SessionTransport for IsolatedSessionTransport { #[cfg(test)] pub mod tests { use std::collections::BTreeSet; - use ethkey::{Random, Generator, Public}; + use crypto::publickey::{Random, Generator, Public}; use key_server_cluster::{NodeId, Error, KeyStorage, NodeKeyPair}; use key_server_cluster::cluster::tests::MessageLoop as ClusterMessageLoop; use key_server_cluster::servers_set_change_session::tests::{MessageLoop, AdminSessionAdapter, generate_key}; diff --git a/secret-store/src/key_server_cluster/admin_sessions/share_change_session.rs b/secret-store/src/key_server_cluster/admin_sessions/share_change_session.rs index 18d2671f569..d69c29b30d2 100644 --- a/secret-store/src/key_server_cluster/admin_sessions/share_change_session.rs +++ b/secret-store/src/key_server_cluster/admin_sessions/share_change_session.rs @@ -17,7 +17,7 @@ use std::sync::Arc; use std::collections::{BTreeSet, BTreeMap}; use ethereum_types::H256; -use ethkey::Secret; +use crypto::publickey::Secret; use key_server_cluster::{Error, NodeId, SessionId, ServerKeyId, KeyStorage}; use key_server_cluster::cluster::Cluster; use key_server_cluster::cluster_sessions::ClusterSession; diff --git a/secret-store/src/key_server_cluster/client_sessions/decryption_session.rs b/secret-store/src/key_server_cluster/client_sessions/decryption_session.rs index 46691f58b40..ce6e2a1492f 100644 --- a/secret-store/src/key_server_cluster/client_sessions/decryption_session.rs +++ b/secret-store/src/key_server_cluster/client_sessions/decryption_session.rs @@ -19,7 +19,7 @@ use std::sync::Arc; use futures::Oneshot; use parking_lot::Mutex; use ethereum_types::{Address, H256}; -use ethkey::Secret; +use crypto::publickey::Secret; use key_server_cluster::{Error, AclStorage, DocumentKeyShare, NodeId, SessionId, Requester, EncryptedDocumentKeyShadow, SessionMeta}; use key_server_cluster::cluster::Cluster; @@ -846,7 +846,7 @@ mod tests { use std::sync::Arc; use std::collections::{BTreeMap, VecDeque}; use acl_storage::DummyAclStorage; - use ethkey::{self, KeyPair, Random, Generator, Public, Secret, public_to_address}; + use crypto::publickey::{KeyPair, Random, Generator, Public, Secret, public_to_address}; use key_server_cluster::{NodeId, DocumentKeyShare, DocumentKeyShareVersion, SessionId, Requester, Error, EncryptedDocumentKeyShadow, SessionMeta}; use key_server_cluster::cluster::tests::DummyCluster; @@ -906,7 +906,7 @@ mod tests { cluster }).collect(); let requester = Random.generate().unwrap(); - let signature = Some(ethkey::sign(requester.secret(), &SessionId::default()).unwrap()); + let signature = Some(crypto::publickey::sign(requester.secret(), &SessionId::default()).unwrap()); let sessions: Vec<_> = (0..5).map(|i| SessionImpl::new(SessionParams { meta: SessionMeta { id: session_id.clone(), @@ -997,7 +997,7 @@ mod tests { acl_storage: Arc::new(DummyAclStorage::default()), cluster: Arc::new(DummyCluster::new(self_node_id.clone())), nonce: 0, - }, Some(Requester::Signature(ethkey::sign(Random.generate().unwrap().secret(), &SessionId::default()).unwrap()))) { + }, Some(Requester::Signature(crypto::publickey::sign(Random.generate().unwrap().secret(), &SessionId::default()).unwrap()))) { Ok(_) => (), _ => panic!("unexpected"), } @@ -1021,7 +1021,7 @@ mod tests { cluster: Arc::new(DummyCluster::new(self_node_id.clone())), nonce: 0, }, Some(Requester::Signature( - ethkey::sign(Random.generate().unwrap().secret(), &SessionId::default()).unwrap() + crypto::publickey::sign(Random.generate().unwrap().secret(), &SessionId::default()).unwrap() ))).unwrap().0; assert_eq!(session.initialize(Default::default(), Default::default(), false, false), Err(Error::InvalidMessage)); } @@ -1058,7 +1058,7 @@ mod tests { cluster: Arc::new(DummyCluster::new(self_node_id.clone())), nonce: 0, }, Some(Requester::Signature( - ethkey::sign(Random.generate().unwrap().secret(), &SessionId::default()).unwrap() + crypto::publickey::sign(Random.generate().unwrap().secret(), &SessionId::default()).unwrap() ))).unwrap().0; assert_eq!(session.initialize(Default::default(), Default::default(), false, false), Err(Error::ConsensusUnreachable)); } @@ -1080,7 +1080,7 @@ mod tests { session_nonce: 0, origin: None, message: message::ConsensusMessage::InitializeConsensusSession(message::InitializeConsensusSession { - requester: Requester::Signature(ethkey::sign( + requester: Requester::Signature(crypto::publickey::sign( Random.generate().unwrap().secret(), &SessionId::default()).unwrap()).into(), version: Default::default(), }), @@ -1096,7 +1096,7 @@ mod tests { session_nonce: 0, origin: None, message: message::ConsensusMessage::InitializeConsensusSession(message::InitializeConsensusSession { - requester: Requester::Signature(ethkey::sign(Random.generate().unwrap().secret(), + requester: Requester::Signature(crypto::publickey::sign(Random.generate().unwrap().secret(), &SessionId::default()).unwrap()).into(), version: Default::default(), }), @@ -1121,7 +1121,7 @@ mod tests { session_nonce: 0, origin: None, message: message::ConsensusMessage::InitializeConsensusSession(message::InitializeConsensusSession { - requester: Requester::Signature(ethkey::sign(Random.generate().unwrap().secret(), + requester: Requester::Signature(crypto::publickey::sign(Random.generate().unwrap().secret(), &SessionId::default()).unwrap()).into(), version: Default::default(), }), @@ -1314,9 +1314,9 @@ mod tests { assert!(decrypted_secret.decrypt_shadows.is_some()); // check that KS client is able to restore original secret use crypto::DEFAULT_MAC; - use ethkey::crypto::ecies::decrypt; + use crypto::publickey::ecies::decrypt; let decrypt_shadows: Vec<_> = decrypted_secret.decrypt_shadows.unwrap().into_iter() - .map(|c| Secret::from_slice(&decrypt(key_pair.secret(), &DEFAULT_MAC, &c).unwrap()).unwrap()) + .map(|c| Secret::copy_from_slice(&decrypt(key_pair.secret(), &DEFAULT_MAC, &c).unwrap()).unwrap()) .collect(); let decrypted_secret = math::decrypt_with_shadow_coefficients(decrypted_secret.decrypted_secret, decrypted_secret.common_point.unwrap(), decrypt_shadows).unwrap(); assert_eq!(decrypted_secret, H512::from_str(SECRET_PLAIN).unwrap()); @@ -1458,11 +1458,11 @@ mod tests { // 4 nodes must be able to recover original secret use crypto::DEFAULT_MAC; - use ethkey::crypto::ecies::decrypt; + use crypto::publickey::ecies::decrypt; let result = sessions[0].decrypted_secret().unwrap().unwrap(); assert_eq!(3, sessions.iter().skip(1).filter(|s| s.decrypted_secret() == Some(Ok(result.clone()))).count()); let decrypt_shadows: Vec<_> = result.decrypt_shadows.unwrap().into_iter() - .map(|c| Secret::from_slice(&decrypt(key_pair.secret(), &DEFAULT_MAC, &c).unwrap()).unwrap()) + .map(|c| Secret::copy_from_slice(&decrypt(key_pair.secret(), &DEFAULT_MAC, &c).unwrap()).unwrap()) .collect(); let decrypted_secret = math::decrypt_with_shadow_coefficients(result.decrypted_secret, result.common_point.unwrap(), decrypt_shadows).unwrap(); assert_eq!(decrypted_secret, H512::from_str(SECRET_PLAIN).unwrap()); diff --git a/secret-store/src/key_server_cluster/client_sessions/encryption_session.rs b/secret-store/src/key_server_cluster/client_sessions/encryption_session.rs index 46181001394..6d0f52540c2 100644 --- a/secret-store/src/key_server_cluster/client_sessions/encryption_session.rs +++ b/secret-store/src/key_server_cluster/client_sessions/encryption_session.rs @@ -20,7 +20,7 @@ use std::sync::Arc; use futures::Oneshot; use parking_lot::Mutex; use ethereum_types::Address; -use ethkey::Public; +use crypto::publickey::Public; use key_server_cluster::{Error, NodeId, SessionId, Requester, KeyStorage, DocumentKeyShare, ServerKeyId}; use key_server_cluster::cluster::Cluster; diff --git a/secret-store/src/key_server_cluster/client_sessions/generation_session.rs b/secret-store/src/key_server_cluster/client_sessions/generation_session.rs index 806173854a3..b81cbfeac92 100644 --- a/secret-store/src/key_server_cluster/client_sessions/generation_session.rs +++ b/secret-store/src/key_server_cluster/client_sessions/generation_session.rs @@ -20,7 +20,7 @@ use std::sync::Arc; use futures::Oneshot; use parking_lot::Mutex; use ethereum_types::Address; -use ethkey::{Public, Secret}; +use crypto::publickey::{Public, Secret}; use key_server_cluster::{Error, NodeId, SessionId, KeyStorage, DocumentKeyShare, DocumentKeyShareVersion}; use key_server_cluster::math; use key_server_cluster::cluster::Cluster; @@ -951,7 +951,7 @@ fn check_threshold(threshold: usize, nodes: &BTreeSet) -> Result<(), Err pub mod tests { use std::sync::Arc; use ethereum_types::H256; - use ethkey::{Random, Generator, KeyPair, Secret}; + use crypto::publickey::{Random, Generator, KeyPair, Secret}; use key_server_cluster::{NodeId, Error, KeyStorage}; use key_server_cluster::message::{self, Message, GenerationMessage, KeysDissemination, PublicKeyShare, ConfirmInitialization}; diff --git a/secret-store/src/key_server_cluster/client_sessions/signing_session_ecdsa.rs b/secret-store/src/key_server_cluster/client_sessions/signing_session_ecdsa.rs index 4f913a53602..70f40c3d890 100644 --- a/secret-store/src/key_server_cluster/client_sessions/signing_session_ecdsa.rs +++ b/secret-store/src/key_server_cluster/client_sessions/signing_session_ecdsa.rs @@ -19,7 +19,7 @@ use std::collections::btree_map::Entry; use std::sync::Arc; use futures::Oneshot; use parking_lot::Mutex; -use ethkey::{Public, Secret, Signature, sign}; +use crypto::publickey::{Public, Secret, Signature, sign}; use ethereum_types::H256; use key_server_cluster::{Error, NodeId, SessionId, SessionMeta, AclStorage, DocumentKeyShare, Requester}; use key_server_cluster::cluster::{Cluster}; @@ -1070,7 +1070,7 @@ impl JobTransport for SigningJobTransport { mod tests { use std::sync::Arc; use ethereum_types::H256; - use ethkey::{self, Random, Generator, Public, verify_public, public_to_address}; + use crypto::publickey::{Random, Generator, Public, verify_public, public_to_address}; use key_server_cluster::{SessionId, Error, KeyStorage}; use key_server_cluster::cluster::tests::{MessageLoop as ClusterMessageLoop}; use key_server_cluster::signing_session_ecdsa::SessionImpl; @@ -1090,7 +1090,7 @@ mod tests { pub fn init_with_version(self, key_version: Option) -> Result<(Self, Public, H256), Error> { let message_hash = H256::random(); let requester = Random.generate().unwrap(); - let signature = ethkey::sign(requester.secret(), &SessionId::default()).unwrap(); + let signature = crypto::publickey::sign(requester.secret(), &SessionId::default()).unwrap(); self.0.cluster(0).client() .new_ecdsa_signing_session(Default::default(), signature.into(), key_version, message_hash) .map(|_| (self, *requester.public(), message_hash)) diff --git a/secret-store/src/key_server_cluster/client_sessions/signing_session_schnorr.rs b/secret-store/src/key_server_cluster/client_sessions/signing_session_schnorr.rs index ae0aa69d462..023e5132068 100644 --- a/secret-store/src/key_server_cluster/client_sessions/signing_session_schnorr.rs +++ b/secret-store/src/key_server_cluster/client_sessions/signing_session_schnorr.rs @@ -18,7 +18,7 @@ use std::collections::BTreeSet; use std::sync::Arc; use futures::Oneshot; use parking_lot::Mutex; -use ethkey::{Public, Secret}; +use crypto::publickey::{Public, Secret}; use ethereum_types::H256; use key_server_cluster::{Error, NodeId, SessionId, Requester, SessionMeta, AclStorage, DocumentKeyShare}; use key_server_cluster::cluster::{Cluster}; @@ -819,7 +819,7 @@ mod tests { use std::str::FromStr; use std::collections::BTreeMap; use ethereum_types::{Address, H256}; - use ethkey::{self, Random, Generator, Public, Secret, public_to_address}; + use crypto::publickey::{Random, Generator, Public, Secret, public_to_address}; use acl_storage::DummyAclStorage; use key_server_cluster::{SessionId, Requester, SessionMeta, Error, KeyStorage}; use key_server_cluster::cluster::tests::MessageLoop as ClusterMessageLoop; @@ -842,7 +842,7 @@ mod tests { } pub fn into_session(&self, at_node: usize) -> SessionImpl { - let requester = Some(Requester::Signature(ethkey::sign(Random.generate().unwrap().secret(), + let requester = Some(Requester::Signature(crypto::publickey::sign(Random.generate().unwrap().secret(), &SessionId::default()).unwrap())); SessionImpl::new(SessionParams { meta: SessionMeta { @@ -864,7 +864,7 @@ mod tests { pub fn init_with_version(self, key_version: Option) -> Result<(Self, Public, H256), Error> { let message_hash = H256::random(); let requester = Random.generate().unwrap(); - let signature = ethkey::sign(requester.secret(), &SessionId::default()).unwrap(); + let signature = crypto::publickey::sign(requester.secret(), &SessionId::default()).unwrap(); self.0.cluster(0).client().new_schnorr_signing_session( Default::default(), signature.into(), diff --git a/secret-store/src/key_server_cluster/cluster.rs b/secret-store/src/key_server_cluster/cluster.rs index f1d34709119..44e6a22fed4 100644 --- a/secret-store/src/key_server_cluster/cluster.rs +++ b/secret-store/src/key_server_cluster/cluster.rs @@ -17,7 +17,7 @@ use std::sync::Arc; use std::collections::{BTreeMap, BTreeSet}; use parking_lot::RwLock; -use ethkey::{Public, Signature, Random, Generator}; +use crypto::publickey::{Public, Signature, Random, Generator}; use ethereum_types::{Address, H256}; use parity_runtime::Executor; use key_server_cluster::{Error, NodeId, SessionId, Requester, AclStorage, KeyStorage, KeyServerSet, NodeKeyPair}; @@ -655,7 +655,7 @@ pub mod tests { use futures::Future; use parking_lot::{Mutex, RwLock}; use ethereum_types::{Address, H256}; - use ethkey::{Random, Generator, Public, Signature, sign}; + use crypto::publickey::{Random, Generator, Public, Signature, sign}; use key_server_cluster::{NodeId, SessionId, Requester, Error, DummyAclStorage, DummyKeyStorage, MapKeyServerSet, PlainNodeKeyPair, NodeKeyPair}; use key_server_cluster::message::Message; diff --git a/secret-store/src/key_server_cluster/cluster_connections_net.rs b/secret-store/src/key_server_cluster/cluster_connections_net.rs index 155c0604d23..b402d001875 100644 --- a/secret-store/src/key_server_cluster/cluster_connections_net.rs +++ b/secret-store/src/key_server_cluster/cluster_connections_net.rs @@ -25,7 +25,7 @@ use parking_lot::{Mutex, RwLock}; use tokio::net::{TcpListener, TcpStream}; use tokio::timer::{Interval, timeout::Error as TimeoutError}; use tokio_io::IoFuture; -use ethkey::KeyPair; +use crypto::publickey::KeyPair; use parity_runtime::Executor; use key_server_cluster::{Error, NodeId, ClusterConfiguration, NodeKeyPair}; use key_server_cluster::cluster_connections::{ConnectionProvider, Connection, ConnectionManager}; diff --git a/secret-store/src/key_server_cluster/cluster_sessions.rs b/secret-store/src/key_server_cluster/cluster_sessions.rs index 3db72395d28..1e5a046b993 100644 --- a/secret-store/src/key_server_cluster/cluster_sessions.rs +++ b/secret-store/src/key_server_cluster/cluster_sessions.rs @@ -21,7 +21,7 @@ use std::collections::{VecDeque, BTreeMap, BTreeSet}; use futures::{oneshot, Oneshot, Complete, Future}; use parking_lot::{Mutex, RwLock, Condvar}; use ethereum_types::H256; -use ethkey::Secret; +use crypto::publickey::Secret; use key_server_cluster::{Error, NodeId, SessionId, NodeKeyPair}; use key_server_cluster::cluster::{Cluster, ClusterConfiguration, ClusterView}; use key_server_cluster::cluster_connections::ConnectionProvider; @@ -668,7 +668,7 @@ pub fn create_cluster_view(self_key_pair: Arc, connections: Arc mod tests { use std::sync::Arc; use std::sync::atomic::{AtomicUsize, Ordering}; - use ethkey::{Random, Generator}; + use crypto::publickey::{Random, Generator}; use key_server_cluster::{Error, DummyAclStorage, DummyKeyStorage, MapKeyServerSet, PlainNodeKeyPair}; use key_server_cluster::cluster::ClusterConfiguration; use key_server_cluster::connection_trigger::SimpleServersSetChangeSessionCreatorConnector; diff --git a/secret-store/src/key_server_cluster/cluster_sessions_creator.rs b/secret-store/src/key_server_cluster/cluster_sessions_creator.rs index d0559be4852..0bdf0ccd481 100644 --- a/secret-store/src/key_server_cluster/cluster_sessions_creator.rs +++ b/secret-store/src/key_server_cluster/cluster_sessions_creator.rs @@ -18,7 +18,7 @@ use std::sync::Arc; use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering}; use std::collections::BTreeMap; use parking_lot::RwLock; -use ethkey::Public; +use crypto::publickey::Public; use key_server_cluster::{Error, NodeId, SessionId, Requester, AclStorage, KeyStorage, DocumentKeyShare, SessionMeta}; use key_server_cluster::cluster::{Cluster, ClusterConfiguration}; use key_server_cluster::connection_trigger::ServersSetChangeSessionCreatorConnector; diff --git a/secret-store/src/key_server_cluster/connection_trigger.rs b/secret-store/src/key_server_cluster/connection_trigger.rs index d8ad995a922..40d415dffe0 100644 --- a/secret-store/src/key_server_cluster/connection_trigger.rs +++ b/secret-store/src/key_server_cluster/connection_trigger.rs @@ -19,7 +19,7 @@ use std::collections::btree_map::Entry; use std::net::SocketAddr; use std::sync::Arc; use ethereum_types::H256; -use ethkey::Public; +use crypto::publickey::Public; use key_server_cluster::{KeyServerSet, KeyServerSetSnapshot}; use key_server_cluster::cluster::{ClusterConfiguration, ServersSetChangeParams}; use key_server_cluster::cluster_sessions::AdminSession; @@ -215,7 +215,7 @@ fn select_nodes_to_disconnect(current_set: &BTreeMap, new_se mod tests { use std::collections::BTreeSet; use std::sync::Arc; - use ethkey::{Random, Generator}; + use crypto::publickey::{Random, Generator}; use key_server_cluster::{MapKeyServerSet, PlainNodeKeyPair, KeyServerSetSnapshot, KeyServerSetMigration}; use key_server_cluster::cluster_connections_net::NetConnectionsContainer; use super::{Maintain, TriggerConnections, ConnectionsAction, ConnectionTrigger, SimpleConnectionTrigger, diff --git a/secret-store/src/key_server_cluster/connection_trigger_with_migration.rs b/secret-store/src/key_server_cluster/connection_trigger_with_migration.rs index 00ea42571c0..92db652d5ec 100644 --- a/secret-store/src/key_server_cluster/connection_trigger_with_migration.rs +++ b/secret-store/src/key_server_cluster/connection_trigger_with_migration.rs @@ -18,7 +18,7 @@ use std::collections::{BTreeSet, BTreeMap}; use std::net::SocketAddr; use std::sync::Arc; use ethereum_types::H256; -use ethkey::Public; +use crypto::publickey::Public; use parking_lot::Mutex; use key_server_cluster::{KeyServerSet, KeyServerSetSnapshot, KeyServerSetMigration, is_migration_required}; use key_server_cluster::cluster::{ClusterConfiguration, ServersSetChangeParams}; diff --git a/secret-store/src/key_server_cluster/io/handshake.rs b/secret-store/src/key_server_cluster/io/handshake.rs index b266d8681e1..a09e035e43a 100644 --- a/secret-store/src/key_server_cluster/io/handshake.rs +++ b/secret-store/src/key_server_cluster/io/handshake.rs @@ -37,8 +37,8 @@ use std::sync::Arc; use std::collections::BTreeSet; use futures::{Future, Poll, Async}; use tokio_io::{AsyncRead, AsyncWrite}; -use ethkey::crypto::ecdh::agree; -use ethkey::{Random, Generator, KeyPair, Public, Signature, verify_public, sign, recover}; +use crypto::publickey::ecdh::agree; +use crypto::publickey::{Random, Generator, KeyPair, Public, Signature, verify_public, sign, recover}; use ethereum_types::H256; use key_server_cluster::{NodeId, Error, NodeKeyPair}; use key_server_cluster::message::{Message, ClusterMessage, NodePublicKey, NodePrivateKeySignature}; @@ -317,7 +317,7 @@ mod tests { use std::sync::Arc; use std::collections::BTreeSet; use futures::Future; - use ethkey::{Random, Generator, sign}; + use crypto::publickey::{Random, Generator, sign}; use ethereum_types::H256; use key_server_cluster::PlainNodeKeyPair; use key_server_cluster::io::message::tests::TestIo; diff --git a/secret-store/src/key_server_cluster/io/message.rs b/secret-store/src/key_server_cluster/io/message.rs index 5707bd809f2..b45e4f062e3 100644 --- a/secret-store/src/key_server_cluster/io/message.rs +++ b/secret-store/src/key_server_cluster/io/message.rs @@ -19,9 +19,9 @@ use std::u16; use std::ops::Deref; use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt}; use serde_json; -use ethkey::crypto::ecies; -use ethkey::{Secret, KeyPair}; -use ethkey::math::curve_order; +use crypto::publickey::ecies; +use crypto::publickey::{Secret, KeyPair}; +use crypto::publickey::ec_math_utils::CURVE_ORDER; use ethereum_types::{H256, U256, BigEndianHash}; use key_server_cluster::Error; use key_server_cluster::message::{Message, ClusterMessage, GenerationMessage, EncryptionMessage, DecryptionMessage, @@ -258,7 +258,7 @@ pub fn fix_shared_key(shared_secret: &Secret) -> Result { // => let's do it manually let shared_secret: H256 = (**shared_secret).into(); let shared_secret: U256 = shared_secret.into_uint(); - let shared_secret: H256 = BigEndianHash::from_uint(&(shared_secret % curve_order())); + let shared_secret: H256 = BigEndianHash::from_uint(&(shared_secret % *CURVE_ORDER)); let shared_key_pair = KeyPair::from_secret_slice(shared_secret.as_bytes())?; Ok(shared_key_pair) } @@ -305,8 +305,8 @@ pub mod tests { use std::io; use futures::Poll; use tokio_io::{AsyncRead, AsyncWrite}; - use ethkey::{Random, Generator, KeyPair}; - use ethkey::crypto::ecdh::agree; + use crypto::publickey::{Random, Generator, KeyPair}; + use crypto::publickey::ecdh::agree; use key_server_cluster::Error; use key_server_cluster::message::Message; use super::{MESSAGE_HEADER_SIZE, CURRENT_HEADER_VERSION, MessageHeader, fix_shared_key, encrypt_message, diff --git a/secret-store/src/key_server_cluster/io/read_message.rs b/secret-store/src/key_server_cluster/io/read_message.rs index e16de57a36e..0549dd23a67 100644 --- a/secret-store/src/key_server_cluster/io/read_message.rs +++ b/secret-store/src/key_server_cluster/io/read_message.rs @@ -17,7 +17,7 @@ use std::io; use futures::{Poll, Future, Async}; use tokio_io::AsyncRead; -use ethkey::KeyPair; +use crypto::publickey::KeyPair; use key_server_cluster::Error; use key_server_cluster::message::Message; use key_server_cluster::io::{read_header, ReadHeader, read_payload, read_encrypted_payload, ReadPayload}; diff --git a/secret-store/src/key_server_cluster/io/read_payload.rs b/secret-store/src/key_server_cluster/io/read_payload.rs index 9f3a47f6624..9fbde6815f5 100644 --- a/secret-store/src/key_server_cluster/io/read_payload.rs +++ b/secret-store/src/key_server_cluster/io/read_payload.rs @@ -18,7 +18,7 @@ use std::io; use futures::{Poll, Future}; use tokio_io::AsyncRead; use tokio_io::io::{read_exact, ReadExact}; -use ethkey::KeyPair; +use crypto::publickey::KeyPair; use key_server_cluster::Error; use key_server_cluster::message::Message; use key_server_cluster::io::message::{MessageHeader, deserialize_message, decrypt_message}; diff --git a/secret-store/src/key_server_cluster/io/write_message.rs b/secret-store/src/key_server_cluster/io/write_message.rs index 15823730a24..771451e2d89 100644 --- a/secret-store/src/key_server_cluster/io/write_message.rs +++ b/secret-store/src/key_server_cluster/io/write_message.rs @@ -18,7 +18,7 @@ use std::io; use futures::{Future, Poll}; use tokio_io::AsyncWrite; use tokio_io::io::{WriteAll, write_all}; -use ethkey::KeyPair; +use crypto::publickey::KeyPair; use key_server_cluster::message::Message; use key_server_cluster::io::{serialize_message, encrypt_message}; diff --git a/secret-store/src/key_server_cluster/jobs/consensus_session.rs b/secret-store/src/key_server_cluster/jobs/consensus_session.rs index 7f293387084..597484321f8 100644 --- a/secret-store/src/key_server_cluster/jobs/consensus_session.rs +++ b/secret-store/src/key_server_cluster/jobs/consensus_session.rs @@ -367,7 +367,7 @@ impl) -> Error { pub mod tests { use std::collections::{VecDeque, BTreeMap, BTreeSet}; use parking_lot::Mutex; - use ethkey::Public; + use crypto::publickey::Public; use key_server_cluster::{Error, NodeId, SessionId, SessionMeta}; use super::{JobPartialResponseAction, JobPartialRequestAction, JobExecutor, JobTransport, JobSession, JobSessionState}; diff --git a/secret-store/src/key_server_cluster/jobs/servers_set_change_access_job.rs b/secret-store/src/key_server_cluster/jobs/servers_set_change_access_job.rs index a37e0749972..e31add62ee7 100644 --- a/secret-store/src/key_server_cluster/jobs/servers_set_change_access_job.rs +++ b/secret-store/src/key_server_cluster/jobs/servers_set_change_access_job.rs @@ -15,7 +15,7 @@ // along with Parity Ethereum. If not, see . use std::collections::{BTreeSet, BTreeMap}; -use ethkey::{Public, Signature, recover}; +use crypto::publickey::{Public, Signature, recover}; use tiny_keccak::Keccak; use key_server_cluster::{Error, NodeId, SessionId}; use key_server_cluster::message::{InitializeConsensusSessionWithServersSet, InitializeConsensusSessionOfShareAdd}; diff --git a/secret-store/src/key_server_cluster/jobs/signing_job_ecdsa.rs b/secret-store/src/key_server_cluster/jobs/signing_job_ecdsa.rs index 0628b1e75cb..9fa8959b3fe 100644 --- a/secret-store/src/key_server_cluster/jobs/signing_job_ecdsa.rs +++ b/secret-store/src/key_server_cluster/jobs/signing_job_ecdsa.rs @@ -15,7 +15,7 @@ // along with Parity Ethereum. If not, see . use std::collections::{BTreeSet, BTreeMap}; -use ethkey::{Public, Secret, Signature}; +use crypto::publickey::{Public, Secret, Signature}; use ethereum_types::H256; use key_server_cluster::{Error, NodeId, DocumentKeyShare}; use key_server_cluster::math; @@ -33,7 +33,7 @@ pub struct EcdsaSigningJob { nonce_public: Public, /// Request id. request_id: Option, - /// + /// ECDSA reversed-nonce coefficient inversed_nonce_coeff: Option, /// Message hash. message_hash: Option, @@ -43,7 +43,7 @@ pub struct EcdsaSigningJob { pub struct EcdsaPartialSigningRequest { /// Request id. pub id: Secret, - /// + /// ECDSA reversed-nonce coefficient pub inversed_nonce_coeff: Secret, /// Message hash to sign. pub message_hash: H256, diff --git a/secret-store/src/key_server_cluster/jobs/signing_job_schnorr.rs b/secret-store/src/key_server_cluster/jobs/signing_job_schnorr.rs index 7e41dce47ce..31fc1b8c7c2 100644 --- a/secret-store/src/key_server_cluster/jobs/signing_job_schnorr.rs +++ b/secret-store/src/key_server_cluster/jobs/signing_job_schnorr.rs @@ -15,7 +15,7 @@ // along with Parity Ethereum. If not, see . use std::collections::{BTreeSet, BTreeMap}; -use ethkey::{Public, Secret}; +use crypto::publickey::{Public, Secret}; use ethereum_types::H256; use key_server_cluster::{Error, NodeId, DocumentKeyShare}; use key_server_cluster::math; diff --git a/secret-store/src/key_server_cluster/math.rs b/secret-store/src/key_server_cluster/math.rs index 99340e492ff..3ba0298d530 100644 --- a/secret-store/src/key_server_cluster/math.rs +++ b/secret-store/src/key_server_cluster/math.rs @@ -14,7 +14,7 @@ // You should have received a copy of the GNU General Public License // along with Parity Ethereum. If not, see . -use ethkey::{Public, Secret, Signature, Random, Generator, math}; +use crypto::publickey::{Public, Secret, Signature, Random, Generator, ec_math_utils}; use ethereum_types::{H256, U256, BigEndianHash}; use hash::keccak; use key_server_cluster::Error; @@ -36,7 +36,7 @@ pub fn zero_scalar() -> Secret { /// Convert hash to EC scalar (modulo curve order). pub fn to_scalar(hash: H256) -> Result { let scalar: U256 = hash.into_uint(); - let scalar: H256 = BigEndianHash::from_uint(&(scalar % math::curve_order())); + let scalar: H256 = BigEndianHash::from_uint(&(scalar % *ec_math_utils::CURVE_ORDER)); let scalar = Secret::from(scalar.0); scalar.check_validity()?; Ok(scalar) @@ -66,7 +66,7 @@ fn public_y(public: &Public) -> H256 { pub fn compute_public_sum<'a, I>(mut publics: I) -> Result where I: Iterator { let mut sum = publics.next().expect("compute_public_sum is called when there's at least one public; qed").clone(); while let Some(public) = publics.next() { - math::public_add(&mut sum, &public)?; + ec_math_utils::public_add(&mut sum, &public)?; } Ok(sum) } @@ -113,7 +113,7 @@ pub fn compute_shadow_mul<'a, I>(coeff: &Secret, self_secret: &Secret, mut other /// Update point by multiplying to random scalar pub fn update_random_point(point: &mut Public) -> Result<(), Error> { - Ok(math::public_mul_secret(point, &generate_random_scalar()?)?) + Ok(ec_math_utils::public_mul_secret(point, &generate_random_scalar()?)?) } /// Generate random polynom of threshold degree @@ -153,14 +153,14 @@ pub fn public_values_generation(threshold: usize, derived_point: &Public, polyno for i in 0..threshold + 1 { let coeff1 = &polynom1[i]; - let mut multiplication1 = math::generation_point(); - math::public_mul_secret(&mut multiplication1, &coeff1)?; + let mut multiplication1 = ec_math_utils::generation_point(); + ec_math_utils::public_mul_secret(&mut multiplication1, &coeff1)?; let coeff2 = &polynom2[i]; let mut multiplication2 = derived_point.clone(); - math::public_mul_secret(&mut multiplication2, &coeff2)?; + ec_math_utils::public_mul_secret(&mut multiplication2, &coeff2)?; - math::public_add(&mut multiplication1, &multiplication2)?; + ec_math_utils::public_add(&mut multiplication1, &multiplication2)?; publics.push(multiplication1); } @@ -172,13 +172,13 @@ pub fn public_values_generation(threshold: usize, derived_point: &Public, polyno /// Check keys passed by other participants. pub fn keys_verification(threshold: usize, derived_point: &Public, number_id: &Secret, secret1: &Secret, secret2: &Secret, publics: &[Public]) -> Result { // calculate left part - let mut multiplication1 = math::generation_point(); - math::public_mul_secret(&mut multiplication1, secret1)?; + let mut multiplication1 = ec_math_utils::generation_point(); + ec_math_utils::public_mul_secret(&mut multiplication1, secret1)?; let mut multiplication2 = derived_point.clone(); - math::public_mul_secret(&mut multiplication2, secret2)?; + ec_math_utils::public_mul_secret(&mut multiplication2, secret2)?; - math::public_add(&mut multiplication1, &multiplication2)?; + ec_math_utils::public_add(&mut multiplication1, &multiplication2)?; let left = multiplication1; // calculate right part @@ -188,9 +188,9 @@ pub fn keys_verification(threshold: usize, derived_point: &Public, number_id: &S secret_pow.pow(i)?; let mut public_k = publics[i].clone(); - math::public_mul_secret(&mut public_k, &secret_pow)?; + ec_math_utils::public_mul_secret(&mut public_k, &secret_pow)?; - math::public_add(&mut right, &public_k)?; + ec_math_utils::public_add(&mut right, &public_k)?; } Ok(left == right) @@ -213,8 +213,8 @@ pub fn compute_secret_share<'a, I>(secret_values: I) -> Result wh /// Compute public key share. pub fn compute_public_share(self_secret_value: &Secret) -> Result { - let mut public_share = math::generation_point(); - math::public_mul_secret(&mut public_share, self_secret_value)?; + let mut public_share = ec_math_utils::generation_point(); + ec_math_utils::public_mul_secret(&mut public_share, self_secret_value)?; Ok(public_share) } @@ -256,13 +256,13 @@ pub fn encrypt_secret(secret: &Public, joint_public: &Public) -> Result(access_key: &Secret, common_point: joint_shadow.mul(access_key)?; let mut joint_shadow_point = common_point.clone(); - math::public_mul_secret(&mut joint_shadow_point, &joint_shadow)?; + ec_math_utils::public_mul_secret(&mut joint_shadow_point, &joint_shadow)?; Ok(joint_shadow_point) } @@ -318,13 +318,13 @@ pub fn decrypt_with_joint_shadow(threshold: usize, access_key: &Secret, encrypte inv_access_key.inv()?; let mut mul = joint_shadow_point.clone(); - math::public_mul_secret(&mut mul, &inv_access_key)?; + ec_math_utils::public_mul_secret(&mut mul, &inv_access_key)?; let mut decrypted_point = encrypted_point.clone(); if threshold % 2 != 0 { - math::public_add(&mut decrypted_point, &mul)?; + ec_math_utils::public_add(&mut decrypted_point, &mul)?; } else { - math::public_sub(&mut decrypted_point, &mul)?; + ec_math_utils::public_sub(&mut decrypted_point, &mul)?; } Ok(decrypted_point) @@ -335,7 +335,7 @@ pub fn make_common_shadow_point(threshold: usize, mut common_point: Public) -> R if threshold % 2 != 1 { Ok(common_point) } else { - math::public_negate(&mut common_point)?; + ec_math_utils::public_negate(&mut common_point)?; Ok(common_point) } } @@ -344,8 +344,8 @@ pub fn make_common_shadow_point(threshold: usize, mut common_point: Public) -> R #[cfg(test)] pub fn decrypt_with_shadow_coefficients(mut decrypted_shadow: Public, mut common_shadow_point: Public, shadow_coefficients: Vec) -> Result { let shadow_coefficients_sum = compute_secret_sum(shadow_coefficients.iter())?; - math::public_mul_secret(&mut common_shadow_point, &shadow_coefficients_sum)?; - math::public_add(&mut decrypted_shadow, &common_shadow_point)?; + ec_math_utils::public_mul_secret(&mut common_shadow_point, &shadow_coefficients_sum)?; + ec_math_utils::public_add(&mut decrypted_shadow, &common_shadow_point)?; Ok(decrypted_shadow) } @@ -353,10 +353,10 @@ pub fn decrypt_with_shadow_coefficients(mut decrypted_shadow: Public, mut common #[cfg(test)] pub fn decrypt_with_joint_secret(encrypted_point: &Public, common_point: &Public, joint_secret: &Secret) -> Result { let mut common_point_mul = common_point.clone(); - math::public_mul_secret(&mut common_point_mul, joint_secret)?; + ec_math_utils::public_mul_secret(&mut common_point_mul, joint_secret)?; let mut decrypted_point = encrypted_point.clone(); - math::public_sub(&mut decrypted_point, &common_point_mul)?; + ec_math_utils::public_sub(&mut decrypted_point, &common_point_mul)?; Ok(decrypted_point) } @@ -417,8 +417,8 @@ pub fn compute_schnorr_signature<'a, I>(signature_shares: I) -> Result Result<(Secret, Secret), Error> { - let mut nonce_public = math::generation_point(); - math::public_mul_secret(&mut nonce_public, &nonce).unwrap(); + let mut nonce_public = ec_math_utils::generation_point(); + ec_math_utils::public_mul_secret(&mut nonce_public, &nonce).unwrap(); let combined_hash = combine_message_hash_with_public(message_hash, &nonce_public)?; @@ -433,11 +433,11 @@ pub fn local_compute_schnorr_signature(nonce: &Secret, secret: &Secret, message_ /// Verify Schnorr signature as described in https://en.wikipedia.org/wiki/Schnorr_signature#Verifying. #[cfg(test)] pub fn verify_schnorr_signature(public: &Public, signature: &(Secret, Secret), message_hash: &H256) -> Result { - let mut addendum = math::generation_point(); - math::public_mul_secret(&mut addendum, &signature.1)?; + let mut addendum = ec_math_utils::generation_point(); + ec_math_utils::public_mul_secret(&mut addendum, &signature.1)?; let mut nonce_public = public.clone(); - math::public_mul_secret(&mut nonce_public, &signature.0)?; - math::public_add(&mut nonce_public, &addendum)?; + ec_math_utils::public_mul_secret(&mut nonce_public, &signature.0)?; + ec_math_utils::public_add(&mut nonce_public, &addendum)?; let combined_hash = combine_message_hash_with_public(message_hash, &nonce_public)?; Ok(combined_hash == signature.0) @@ -486,11 +486,10 @@ pub fn serialize_ecdsa_signature(nonce_public: &Public, signature_r: Secret, mut }; // fix high S - let curve_order = math::curve_order(); - let curve_order_half = curve_order / 2; + let curve_order_half = *ec_math_utils::CURVE_ORDER / 2; let s_numeric: U256 = (*signature_s).into_uint(); if s_numeric > curve_order_half { - let signature_s_hash: H256 = BigEndianHash::from_uint(&(curve_order - s_numeric)); + let signature_s_hash: H256 = BigEndianHash::from_uint(&(*ec_math_utils::CURVE_ORDER - s_numeric)); signature_s = signature_s_hash.into(); signature_v ^= 1; } @@ -534,7 +533,7 @@ pub fn compute_ecdsa_inversed_secret_coeff_from_shares(t: usize, id_numbers: &[S #[cfg(test)] pub mod tests { use std::iter::once; - use ethkey::{KeyPair, recover, verify_public}; + use crypto::publickey::{KeyPair, recover, verify_public}; use super::*; #[derive(Clone)] diff --git a/secret-store/src/key_server_cluster/message.rs b/secret-store/src/key_server_cluster/message.rs index 98520564fe8..1f21a7caf14 100644 --- a/secret-store/src/key_server_cluster/message.rs +++ b/secret-store/src/key_server_cluster/message.rs @@ -16,7 +16,7 @@ use std::fmt; use std::collections::{BTreeSet, BTreeMap}; -use ethkey::Secret; +use crypto::publickey::Secret; use key_server_cluster::SessionId; use super::{Error, SerializableH256, SerializablePublic, SerializableSecret, SerializableSignature, SerializableMessageHash, SerializableRequester, SerializableAddress}; @@ -240,7 +240,7 @@ pub enum KeyVersionNegotiationMessage { pub struct NodePublicKey { /// Node identifier (aka node public key). pub node_id: MessageNodeId, - /// Random data, which must be signed by peer to prove that he owns the corresponding private key. + /// Random data, which must be signed by peer to prove that he owns the corresponding private key. pub confirmation_plain: SerializableH256, /// The same random `confirmation_plain`, signed with one-time session key. pub confirmation_signed_session: SerializableSignature, @@ -633,7 +633,7 @@ pub struct EcdsaRequestPartialSignature { pub session_nonce: u64, /// Request id. pub request_id: SerializableSecret, - /// + /// ECDSA reversed-nonce coefficient pub inversed_nonce_coeff: SerializableSecret, /// Message hash. pub message_hash: SerializableMessageHash, diff --git a/secret-store/src/key_server_cluster/net/connection.rs b/secret-store/src/key_server_cluster/net/connection.rs index 8688db2897c..cc7e882b090 100644 --- a/secret-store/src/key_server_cluster/net/connection.rs +++ b/secret-store/src/key_server_cluster/net/connection.rs @@ -15,7 +15,7 @@ // along with Parity Ethereum. If not, see . use std::net; -use ethkey::KeyPair; +use crypto::publickey::KeyPair; use key_server_cluster::NodeId; use key_server_cluster::io::SharedTcpStream; diff --git a/secret-store/src/key_server_set.rs b/secret-store/src/key_server_set.rs index 2ced583c68c..4b09e69cab1 100644 --- a/secret-store/src/key_server_set.rs +++ b/secret-store/src/key_server_set.rs @@ -27,7 +27,7 @@ use common_types::{ ids::BlockId, }; use ethereum_types::{H256, Address}; -use ethkey::public_to_address; +use crypto::publickey::public_to_address; use bytes::Bytes; use types::{Error, Public, NodeAddress, NodeId}; use trusted_client::TrustedClient; @@ -592,7 +592,7 @@ pub mod tests { use std::collections::BTreeMap; use std::net::SocketAddr; use ethereum_types::{H256, H512}; - use ethkey::Public; + use crypto::publickey::Public; use super::{update_future_set, update_number_of_confirmations, FutureNewSet, KeyServerSet, KeyServerSetSnapshot, MIGRATION_CONFIRMATIONS_REQUIRED}; diff --git a/secret-store/src/key_storage.rs b/secret-store/src/key_storage.rs index d670417f9bb..088adc4f44b 100644 --- a/secret-store/src/key_storage.rs +++ b/secret-store/src/key_storage.rs @@ -19,7 +19,7 @@ use std::sync::Arc; use serde_json; use tiny_keccak::Keccak; use ethereum_types::{H256, Address}; -use ethkey::{Secret, Public}; +use crypto::publickey::{Secret, Public}; use kvdb::KeyValueDB; use types::{Error, ServerKeyId, NodeId}; use serialization::{SerializablePublic, SerializableSecret, SerializableH256, SerializableAddress}; @@ -296,7 +296,7 @@ pub mod tests { use std::sync::Arc; use parking_lot::RwLock; use self::tempdir::TempDir; - use ethkey::{Random, Generator, Public}; + use crypto::publickey::{Random, Generator, Public}; use kvdb_rocksdb::Database; use types::{Error, ServerKeyId}; use super::{KeyStorage, PersistentKeyStorage, DocumentKeyShare, DocumentKeyShareVersion}; diff --git a/secret-store/src/lib.rs b/secret-store/src/lib.rs index bdf3f638d28..e4d521cc007 100644 --- a/secret-store/src/lib.rs +++ b/secret-store/src/lib.rs @@ -22,7 +22,6 @@ extern crate ethcore; extern crate ethcore_call_contract as call_contract; extern crate ethcore_sync as sync; extern crate ethereum_types; -extern crate ethkey; extern crate hyper; extern crate keccak_hash as hash; extern crate kvdb; @@ -54,6 +53,8 @@ extern crate lazy_static; #[macro_use] extern crate log; +#[cfg(test)] +extern crate ethkey; #[cfg(test)] extern crate env_logger; #[cfg(test)] diff --git a/secret-store/src/listener/http_listener.rs b/secret-store/src/listener/http_listener.rs index 93dbed7c4db..91102bc6081 100644 --- a/secret-store/src/listener/http_listener.rs +++ b/secret-store/src/listener/http_listener.rs @@ -452,7 +452,7 @@ mod tests { use std::sync::Arc; use std::str::FromStr; use hyper::Method as HttpMethod; - use ethkey::Public; + use crypto::publickey::Public; use traits::KeyServer; use key_server::tests::DummyKeyServer; use types::NodeAddress; diff --git a/secret-store/src/listener/service_contract.rs b/secret-store/src/listener/service_contract.rs index f286a1f090a..78acdaf582e 100644 --- a/secret-store/src/listener/service_contract.rs +++ b/secret-store/src/listener/service_contract.rs @@ -23,7 +23,7 @@ use call_contract::CallContract; use ethcore::client::Client; use client_traits::BlockChainClient; use common_types::ids::BlockId; -use ethkey::{Public, public_to_address}; +use crypto::publickey::{Public, public_to_address}; use hash::keccak; use bytes::Bytes; use ethereum_types::{H256, U256, Address, H512}; @@ -754,7 +754,7 @@ fn serialize_threshold(threshold: usize) -> Result { pub mod tests { use parking_lot::Mutex; use bytes::Bytes; - use ethkey::Public; + use crypto::publickey::Public; use ethereum_types::Address; use listener::service_contract_listener::ServiceTask; use {ServerKeyId}; diff --git a/secret-store/src/listener/service_contract_aggregate.rs b/secret-store/src/listener/service_contract_aggregate.rs index 13e1a79687e..8916a13d823 100644 --- a/secret-store/src/listener/service_contract_aggregate.rs +++ b/secret-store/src/listener/service_contract_aggregate.rs @@ -17,7 +17,7 @@ use std::sync::Arc; use bytes::Bytes; use ethereum_types::Address; -use ethkey::Public; +use crypto::publickey::Public; use listener::service_contract::ServiceContract; use listener::service_contract_listener::ServiceTask; use {ServerKeyId}; diff --git a/secret-store/src/listener/service_contract_listener.rs b/secret-store/src/listener/service_contract_listener.rs index c5d540224ff..63cacf01de2 100644 --- a/secret-store/src/listener/service_contract_listener.rs +++ b/secret-store/src/listener/service_contract_listener.rs @@ -21,7 +21,7 @@ use std::thread; use client_traits::ChainNotify; use common_types::chain_notify::NewBlocks; use bytes::Bytes; -use ethkey::{Public, public_to_address}; +use crypto::publickey::{Public, public_to_address}; use ethereum_types::{H256, U256, Address, BigEndianHash as _}; use key_server_set::KeyServerSet; use key_server_cluster::{NodeId, ClusterClient, ClusterSessionsListener, ClusterSession}; @@ -587,7 +587,7 @@ fn is_processed_by_this_key_server(key_server_set: &dyn KeyServerSet, node: &Nod mod tests { use std::sync::Arc; use std::sync::atomic::Ordering; - use ethkey::{Random, Generator, KeyPair}; + use crypto::publickey::{Random, Generator, KeyPair}; use listener::service_contract::ServiceContract; use listener::service_contract::tests::DummyServiceContract; use key_server_cluster::DummyClusterClient; diff --git a/secret-store/src/node_key_pair.rs b/secret-store/src/node_key_pair.rs index f50f75ad1b9..ecf950d7f51 100644 --- a/secret-store/src/node_key_pair.rs +++ b/secret-store/src/node_key_pair.rs @@ -14,8 +14,8 @@ // You should have received a copy of the GNU General Public License // along with Parity Ethereum. If not, see . -use ethkey::crypto::ecdh::agree; -use ethkey::{KeyPair, Public, Signature, Error as EthKeyError, sign, public_to_address}; +use crypto::publickey::ecdh::agree; +use crypto::publickey::{KeyPair, Public, Signature, Error as EthKeyError, sign, public_to_address}; use ethereum_types::{H256, Address}; use traits::NodeKeyPair; diff --git a/secret-store/src/serialization.rs b/secret-store/src/serialization.rs index c75d0992faa..ee49bf6b8ea 100644 --- a/secret-store/src/serialization.rs +++ b/secret-store/src/serialization.rs @@ -19,35 +19,35 @@ use std::ops::Deref; use rustc_hex::{self, FromHex}; use serde::{Serialize, Deserialize, Serializer, Deserializer}; use serde::de::{Visitor, Error as SerdeError}; -use ethkey::{Public, Secret, Signature}; +use crypto::publickey::{Public, Secret, Signature}; use ethereum_types::{H160, H256}; use bytes::Bytes; use types::Requester; trait ToHex { - fn to_hex(&self) -> String; + fn to_hex(&self) -> String; } impl ToHex for Bytes { - fn to_hex(&self) -> String { + fn to_hex(&self) -> String { format!("0x{}", rustc_hex::ToHex::to_hex(&self[..])) } } impl ToHex for Signature { - fn to_hex(&self) -> String { + fn to_hex(&self) -> String { format!("0x{}", self) } } impl ToHex for Secret { - fn to_hex(&self) -> String { - format!("0x{}", rustc_hex::ToHex::to_hex(self)) + fn to_hex(&self) -> String { + format!("0x{}", self.to_hex()) } } macro_rules! impl_to_hex { - ($name: ident) => ( + ($name: ident) => ( impl ToHex for $name { fn to_hex(&self) -> String { format!("{:#x}", self) @@ -92,7 +92,7 @@ macro_rules! impl_bytes { impl Serialize for $name { fn serialize(&self, serializer: S) -> Result where S: Serializer { - serializer.serialize_str(self.0.to_hex().as_ref()) + serializer.serialize_str(<$other as ToHex>::to_hex(&self.0).as_ref()) } } @@ -228,7 +228,7 @@ mod tests { #[test] fn serialize_and_deserialize_secret() { let s = "5a39ed1020c04d4d84539975b893a4e7c53eab6c2965db8bc3468093a31bc5ae"; - let secret = SerializableSecret(Secret::from(s)); + let secret = SerializableSecret(Secret::from_str(s).unwrap()); do_test!(secret, format!("\"0x{}\"", s), SerializableSecret); } diff --git a/secret-store/src/traits.rs b/secret-store/src/traits.rs index 149087d6339..d62210ed1e0 100644 --- a/secret-store/src/traits.rs +++ b/secret-store/src/traits.rs @@ -16,7 +16,7 @@ use std::collections::BTreeSet; use futures::Future; -use ethkey::{KeyPair, Signature, Error as EthKeyError}; +use crypto::publickey::{KeyPair, Signature, Error as EthKeyError}; use ethereum_types::{H256, Address}; use types::{Error, Public, ServerKeyId, MessageHash, EncryptedMessageSignature, RequestSignature, Requester, EncryptedDocumentKey, EncryptedDocumentKeyShadow, NodeId}; diff --git a/secret-store/src/types/all.rs b/secret-store/src/types/all.rs index 1cacb75507b..65ebbbc96da 100644 --- a/secret-store/src/types/all.rs +++ b/secret-store/src/types/all.rs @@ -16,10 +16,10 @@ use std::collections::BTreeMap; -use {ethkey, bytes, ethereum_types}; +use {bytes, ethereum_types}; /// Node id. -pub type NodeId = ethkey::Public; +pub type NodeId = crypto::publickey::Public; /// Server key id. When key is used to encrypt document, it could be document contents hash. pub type ServerKeyId = ethereum_types::H256; /// Encrypted document key type. @@ -29,9 +29,9 @@ pub type MessageHash = ethereum_types::H256; /// Message signature. pub type EncryptedMessageSignature = bytes::Bytes; /// Request signature type. -pub type RequestSignature = ethkey::Signature; +pub type RequestSignature = crypto::publickey::Signature; /// Public key type. -pub use ethkey::Public; +pub use crypto::publickey::Public; /// Secret store configuration #[derive(Debug, Clone)] @@ -48,7 +48,7 @@ pub enum ContractAddress { /// Address is read from registry. Registry, /// Address is specified. - Address(ethkey::Address), + Address(crypto::publickey::Address), } /// Secret store configuration @@ -80,7 +80,7 @@ pub struct ClusterConfiguration { /// This node address. pub listener_address: NodeAddress, /// All cluster nodes addresses. - pub nodes: BTreeMap, + pub nodes: BTreeMap, /// Key Server Set contract address. If None, servers from 'nodes' map are used. pub key_server_set_contract_address: Option, /// Allow outbound connections to 'higher' nodes. @@ -97,9 +97,9 @@ pub struct ClusterConfiguration { #[derive(Clone, Debug, PartialEq)] pub struct EncryptedDocumentKeyShadow { /// Decrypted secret point. It is partially decrypted if shadow decryption was requested. - pub decrypted_secret: ethkey::Public, + pub decrypted_secret: crypto::publickey::Public, /// Shared common point. - pub common_point: Option, + pub common_point: Option, /// If shadow decryption was requested: shadow decryption coefficients, encrypted with requestor public. pub decrypt_shadows: Option>>, } @@ -108,9 +108,9 @@ pub struct EncryptedDocumentKeyShadow { #[derive(Debug, Clone)] pub enum Requester { /// Requested with server key id signature. - Signature(ethkey::Signature), + Signature(crypto::publickey::Signature), /// Requested with public key. - Public(ethkey::Public), + Public(crypto::publickey::Public), /// Requested with verified address. Address(ethereum_types::Address), } @@ -124,21 +124,21 @@ impl Default for Requester { impl Requester { pub fn public(&self, server_key_id: &ServerKeyId) -> Result { match *self { - Requester::Signature(ref signature) => ethkey::recover(signature, server_key_id) + Requester::Signature(ref signature) => crypto::publickey::recover(signature, server_key_id) .map_err(|e| format!("bad signature: {}", e)), Requester::Public(ref public) => Ok(public.clone()), Requester::Address(_) => Err("cannot recover public from address".into()), } } - pub fn address(&self, server_key_id: &ServerKeyId) -> Result { + pub fn address(&self, server_key_id: &ServerKeyId) -> Result { self.public(server_key_id) - .map(|p| ethkey::public_to_address(&p)) + .map(|p| crypto::publickey::public_to_address(&p)) } } -impl From for Requester { - fn from(signature: ethkey::Signature) -> Requester { +impl From for Requester { + fn from(signature: crypto::publickey::Signature) -> Requester { Requester::Signature(signature) } } diff --git a/secret-store/src/types/error.rs b/secret-store/src/types/error.rs index 72dfded78e2..64cc1228e3d 100644 --- a/secret-store/src/types/error.rs +++ b/secret-store/src/types/error.rs @@ -18,7 +18,7 @@ use std::fmt; use std::net; use std::io::Error as IoError; -use {ethkey, crypto}; +use crypto; /// Secret store error. #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] @@ -162,18 +162,12 @@ impl fmt::Display for Error { } } -impl From for Error { - fn from(err: ethkey::Error) -> Self { +impl From for Error { + fn from(err: crypto::publickey::Error) -> Self { Error::EthKey(err.into()) } } -impl From for Error { - fn from(err: ethkey::crypto::Error) -> Self { - Error::EthKey(err.to_string()) - } -} - impl From for Error { fn from(err: crypto::Error) -> Self { Error::EthKey(err.to_string()) diff --git a/util/network-devp2p/Cargo.toml b/util/network-devp2p/Cargo.toml index bc9ead6b3f0..f019334b97b 100644 --- a/util/network-devp2p/Cargo.toml +++ b/util/network-devp2p/Cargo.toml @@ -21,10 +21,9 @@ ansi_term = "0.11" rustc-hex = "1.0" ethcore-io = { path = "../io", features = ["mio"] } parity-bytes = "0.1" -crypto = { package = "parity-crypto", version = "0.4.0"} +parity-crypto = { version = "0.4.2", features = ["publickey"] } network = { package = "ethcore-network", path = "../network" } ethereum-types = "0.8.0" -ethkey = { path = "../../accounts/ethkey" } rlp = "0.4.0" parity-path = "0.1" ipnetwork = "0.12.6" diff --git a/util/network-devp2p/src/connection.rs b/util/network-devp2p/src/connection.rs index 4892d0be6e3..f77094e9f0c 100644 --- a/util/network-devp2p/src/connection.rs +++ b/util/network-devp2p/src/connection.rs @@ -21,7 +21,8 @@ use std::sync::atomic::{AtomicBool, Ordering as AtomicOrdering}; use std::time::Duration; use bytes::{Buf, BufMut}; -use crypto::aes::{AesCtr256, AesEcb256}; +use parity_crypto::aes::{AesCtr256, AesEcb256}; +use parity_crypto::publickey::Secret; use ethereum_types::{H128, H256, H512}; use keccak_hash::{keccak, write_keccak}; use log::{debug, trace, warn}; @@ -33,7 +34,6 @@ use rlp::{Rlp, RlpStream}; use tiny_keccak::Keccak; use ethcore_io::{IoContext, StreamToken}; -use ethkey::{crypto as ethcrypto, Secret}; use network::Error; use crate::handshake::Handshake; @@ -302,7 +302,7 @@ const NULL_IV : [u8; 16] = [0;16]; impl EncryptedConnection { /// Create an encrypted connection out of the handshake. pub fn new(handshake: &mut Handshake) -> Result { - let shared = ethcrypto::ecdh::agree(handshake.ecdhe.secret(), &handshake.remote_ephemeral)?; + let shared = parity_crypto::publickey::ecdh::agree(handshake.ecdhe.secret(), &handshake.remote_ephemeral)?; let mut nonce_material = H512::default(); if handshake.originated { (&mut nonce_material[0..32]).copy_from_slice(handshake.remote_nonce.as_bytes()); @@ -328,7 +328,7 @@ impl EncryptedConnection { let decoder = AesCtr256::new(&key_material[32..64], &NULL_IV)?; let key_material_keccak = keccak(&key_material); (&mut key_material[32..64]).copy_from_slice(key_material_keccak.as_bytes()); - let mac_encoder_key: Secret = Secret::from_slice(&key_material[32..64]).expect("can create Secret from 32 bytes; qed"); + let mac_encoder_key: Secret = Secret::copy_from_slice(&key_material[32..64]).expect("can create Secret from 32 bytes; qed"); let mut egress_mac = Keccak::new_keccak256(); let mut mac_material = H256::from_slice(&key_material[32..64]) ^ handshake.remote_nonce; diff --git a/util/network-devp2p/src/discovery.rs b/util/network-devp2p/src/discovery.rs index 392c67b8a98..aa76e32f872 100644 --- a/util/network-devp2p/src/discovery.rs +++ b/util/network-devp2p/src/discovery.rs @@ -27,7 +27,7 @@ use lru_cache::LruCache; use parity_bytes::Bytes; use rlp::{Rlp, RlpStream}; -use ethkey::{KeyPair, recover, Secret, sign}; +use parity_crypto::publickey::{KeyPair, recover, Secret, sign}; use network::Error; use network::IpFilter; @@ -901,7 +901,7 @@ mod tests { use rustc_hex::FromHex; - use ethkey::{Generator, Random}; + use parity_crypto::publickey::{Generator, Random}; use crate::node_table::{Node, NodeEndpoint, NodeId}; diff --git a/util/network-devp2p/src/handshake.rs b/util/network-devp2p/src/handshake.rs index d0aadd313df..4534a660db2 100644 --- a/util/network-devp2p/src/handshake.rs +++ b/util/network-devp2p/src/handshake.rs @@ -25,8 +25,7 @@ use rand::random; use rlp::{Rlp, RlpStream}; use ethcore_io::{IoContext, StreamToken}; -use ethkey::{Generator, KeyPair, Public, Random, recover, Secret, sign}; -use ethkey::crypto::{ecdh, ecies}; +use parity_crypto::publickey::{Generator, KeyPair, Public, Random, recover, Secret, sign, ecdh, ecies}; use network::Error; use crate::connection::Connection; @@ -329,7 +328,7 @@ mod test { use rustc_hex::FromHex; use ethcore_io::*; - use ethkey::Public; + use parity_crypto::publickey::Public; use super::*; diff --git a/util/network-devp2p/src/host.rs b/util/network-devp2p/src/host.rs index 27949839f41..dba69e33773 100644 --- a/util/network-devp2p/src/host.rs +++ b/util/network-devp2p/src/host.rs @@ -40,7 +40,7 @@ use rlp::{Encodable, RlpStream}; use rustc_hex::ToHex; use ethcore_io::{IoContext, IoHandler, IoManager, StreamToken, TimerToken}; -use ethkey::{Generator, KeyPair, Random, Secret}; +use parity_crypto::publickey::{Generator, KeyPair, Random, Secret}; use network::{ client_version::ClientVersion, ConnectionDirection, ConnectionFilter, DisconnectReason, Error, NetworkConfiguration, NetworkContext as NetworkContextTrait, NetworkIoMessage, NetworkProtocolHandler, diff --git a/util/network-devp2p/tests/tests.rs b/util/network-devp2p/tests/tests.rs index 9a0fc72d595..a3b51ff7494 100644 --- a/util/network-devp2p/tests/tests.rs +++ b/util/network-devp2p/tests/tests.rs @@ -26,7 +26,7 @@ use parking_lot::Mutex; use network::{PeerId, NetworkContext, NetworkProtocolHandler, NetworkConfiguration}; use ethcore_network_devp2p::NetworkService; -use ethkey::{Generator, Random}; +use parity_crypto::publickey::{Generator, Random}; use ethcore_io::TimerToken; pub struct TestProtocol { diff --git a/util/network/Cargo.toml b/util/network/Cargo.toml index ea3e6e99e2b..8b71a3e7e68 100644 --- a/util/network/Cargo.toml +++ b/util/network/Cargo.toml @@ -8,10 +8,9 @@ authors = ["Parity Technologies "] [dependencies] derive_more = "0.14.0" -parity-crypto = "0.4.0" +parity-crypto = { version = "0.4.2", features = ["publickey"] } ethcore-io = { path = "../io" } ethereum-types = "0.8.0" -ethkey = { path = "../../accounts/ethkey" } ipnetwork = "0.12.6" lazy_static = "1.0" rlp = "0.4.0" diff --git a/util/network/src/error.rs b/util/network/src/error.rs index c43de6b8d58..ec0c57941db 100644 --- a/util/network/src/error.rs +++ b/util/network/src/error.rs @@ -17,7 +17,7 @@ use std::{error, io, net, fmt}; use libc::{ENFILE, EMFILE}; use io::IoError; -use {rlp, ethkey, crypto, snappy}; +use {rlp, crypto, snappy}; #[derive(Debug, Copy, Clone, PartialEq, Eq)] pub enum DisconnectReason @@ -182,14 +182,8 @@ impl From for Error { } } -impl From for Error { - fn from(_err: ethkey::Error) -> Self { - Error::Auth - } -} - -impl From for Error { - fn from(_err: ethkey::crypto::Error) -> Self { +impl From for Error { + fn from(_err: crypto::publickey::Error) -> Self { Error::Auth } } @@ -218,7 +212,7 @@ fn test_errors() { _ => panic!("Unexpected error"), } - match >::from(ethkey::crypto::Error::InvalidMessage) { + match >::from(crypto::publickey::Error::InvalidMessage) { Error::Auth => {}, _ => panic!("Unexpected error"), } diff --git a/util/network/src/lib.rs b/util/network/src/lib.rs index e94d35ba193..42bc8d6c3ee 100644 --- a/util/network/src/lib.rs +++ b/util/network/src/lib.rs @@ -19,7 +19,6 @@ extern crate parity_crypto as crypto; extern crate ethcore_io as io; extern crate ethereum_types; -extern crate ethkey; extern crate rlp; extern crate ipnetwork; extern crate parity_snappy as snappy; @@ -54,7 +53,7 @@ use std::str::{self, FromStr}; use std::sync::Arc; use std::time::Duration; use ipnetwork::{IpNetwork, IpNetworkError}; -use ethkey::Secret; +use crypto::publickey::Secret; use ethereum_types::H512; use rlp::{Decodable, DecoderError, Rlp}; From acf7c48d7e0fcd67a6a409e47827febcd330ac69 Mon Sep 17 00:00:00 2001 From: Fabio Lama Date: Wed, 23 Oct 2019 14:20:47 +0200 Subject: [PATCH 04/21] Type annotation for next_key() matching of json filter options (#11192) * type annotation for next_key matching of json filter options * rpc tests for pending transactions * mention git submodules in the readme --- README.md | 2 +- ethcore/src/miner/filter_options.rs | 8 +++---- rpc/src/v1/tests/mocked/parity.rs | 35 ++++++++++++++++++++++++++++- 3 files changed, 39 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 3b79d295fad..be31c49243e 100644 --- a/README.md +++ b/README.md @@ -151,7 +151,7 @@ To start Parity Ethereum as a regular user using `systemd` init: ## 4. Testing -You can run tests with the following commands: +Download the required test files: `git submodule update --init --recursive`. You can run tests with the following commands: * **All** packages ``` diff --git a/ethcore/src/miner/filter_options.rs b/ethcore/src/miner/filter_options.rs index db0e67378ad..ae1a206b01a 100644 --- a/ethcore/src/miner/filter_options.rs +++ b/ethcore/src/miner/filter_options.rs @@ -160,8 +160,8 @@ impl<'de> Deserialize<'de> for FilterOptions { M: MapAccess<'de>, { let mut filter = FilterOptions::default(); - while let Some(key) = map.next_key()? { - match key { + while let Some(key) = map.next_key::()? { + match key.as_str() { "from" => { filter.from = map.validate_from()?; }, @@ -221,8 +221,8 @@ impl<'de> Deserialize<'de> for FilterOptions { let mut counter = 0; let mut f_op = Wrapper::O(FilterOperator::Any); - while let Some(key) = map.next_key()? { - match key { + while let Some(key) = map.next_key::()? { + match key.as_str() { "eq" => f_op = W::O(FilterOperator::Eq(map.next_value()?)), "gt" => f_op = W::O(FilterOperator::GreaterThan(map.next_value()?)), "lt" => f_op = W::O(FilterOperator::LessThan(map.next_value()?)), diff --git a/rpc/src/v1/tests/mocked/parity.rs b/rpc/src/v1/tests/mocked/parity.rs index 06da1861e4a..05c9c97d77c 100644 --- a/rpc/src/v1/tests/mocked/parity.rs +++ b/rpc/src/v1/tests/mocked/parity.rs @@ -316,7 +316,7 @@ fn rpc_parity_unsigned_transactions_count_when_signer_disabled() { } #[test] -fn rpc_parity_pending_transactions() { +fn rpc_parity_pending_transactions_without_limit_without_filter() { let deps = Dependencies::new(); let io = deps.default_client(); @@ -326,6 +326,39 @@ fn rpc_parity_pending_transactions() { assert_eq!(io.handle_request_sync(request), Some(response.to_owned())); } +#[test] +fn rpc_parity_pending_transactions_with_limit_without_filter() { + let deps = Dependencies::new(); + let io = deps.default_client(); + + let request = r#"{"jsonrpc": "2.0", "method": "parity_pendingTransactions", "params":[5], "id": 1}"#; + let response = r#"{"jsonrpc":"2.0","result":[],"id":1}"#; + + assert_eq!(io.handle_request_sync(request), Some(response.to_owned())); +} + +#[test] +fn rpc_parity_pending_transactions_without_limit_with_filter() { + let deps = Dependencies::new(); + let io = deps.default_client(); + + let request = r#"{"jsonrpc": "2.0", "method": "parity_pendingTransactions", "params":[null,{"to":{"eq":"0xe8b2d01ffa0a15736b2370b6e5064f9702c891b6"},"gas":{"gt":"0x493e0"}}], "id": 1}"#; + let response = r#"{"jsonrpc":"2.0","result":[],"id":1}"#; + + assert_eq!(io.handle_request_sync(request), Some(response.to_owned())); +} + +#[test] +fn rpc_parity_pending_transactions_with_limit_with_filter() { + let deps = Dependencies::new(); + let io = deps.default_client(); + + let request = r#"{"jsonrpc": "2.0", "method": "parity_pendingTransactions", "params":[5,{"to":{"eq":"0xe8b2d01ffa0a15736b2370b6e5064f9702c891b6"},"gas":{"gt":"0x493e0"}}], "id": 1}"#; + let response = r#"{"jsonrpc":"2.0","result":[],"id":1}"#; + + assert_eq!(io.handle_request_sync(request), Some(response.to_owned())); +} + #[test] fn rpc_parity_encrypt() { let deps = Dependencies::new(); From ffeaee778c0eaa60a7e0f6381cf069135c3ef5c3 Mon Sep 17 00:00:00 2001 From: David Date: Thu, 24 Oct 2019 16:46:32 +0200 Subject: [PATCH 05/21] Pause pruning while snapshotting (#11178) * WIP. Typos and logging. * Format todos * Pause pruning while a snapshot is under way Logs, docs and todos * Allocate memory for the full chunk * Name snapshotting threads * Ensure `taking_snapshot` is set to false whenever and however `take_snapshot`returns Rename `take_at` to `request_snapshot_at` Cleanup * Let "in_progress" deletion fail Fix tests * Just use an atomic * Review grumbles * Finish the sentence * Resolve a few todos and clarify comments. * Calculate progress rate since last update * Lockfile * Fix tests * typo * Reinstate default snapshotting frequency Cut down on the logging noise * address grumble * Log memory use with `journal_size()` and explain why. --- Cargo.lock | 134 ++++++++++++------ ethcore/Cargo.toml | 1 + ethcore/service/src/service.rs | 2 - ethcore/snapshot/Cargo.toml | 1 + .../snapshot/snapshot-tests/src/account.rs | 12 +- .../snapshot/snapshot-tests/src/helpers.rs | 5 +- .../snapshot-tests/src/proof_of_work.rs | 2 +- .../snapshot/snapshot-tests/src/service.rs | 4 +- ethcore/snapshot/snapshot-tests/src/state.rs | 6 +- .../snapshot/snapshot-tests/src/watcher.rs | 4 +- ethcore/snapshot/src/consensus/work.rs | 2 +- ethcore/snapshot/src/lib.rs | 41 +++--- ethcore/snapshot/src/service.rs | 106 +++++++------- ethcore/snapshot/src/traits.rs | 4 +- ethcore/snapshot/src/watcher.rs | 36 ++--- ethcore/src/client/client.rs | 97 ++++++++----- ethcore/src/client/config.rs | 2 +- ethcore/types/Cargo.toml | 1 + ethcore/types/src/lib.rs | 1 + ethcore/types/src/snapshot.rs | 65 ++++++++- parity/run.rs | 4 +- parity/snapshot_cmd.rs | 6 +- util/journaldb/src/lib.rs | 4 +- util/journaldb/src/overlayrecentdb.rs | 11 +- 24 files changed, 345 insertions(+), 206 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 291ba89d3ed..79e018c7e80 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5,7 +5,7 @@ name = "account-db" version = "0.1.0" dependencies = [ "ethereum-types 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "hash-db 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", + "hash-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", "keccak-hash 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "keccak-hasher 0.1.1", "kvdb 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -20,7 +20,7 @@ dependencies = [ "common-types 0.1.0", "derive_more 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", "ethereum-types 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "hash-db 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", + "hash-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", "journaldb 0.2.0", "keccak-hash 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "keccak-hasher 0.1.1", @@ -37,7 +37,7 @@ dependencies = [ "rlp_compress 0.1.0", "serde 1.0.99 (registry+https://github.com/rust-lang/crates.io-index)", "trace 0.1.0", - "trie-db 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", + "trie-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", "trie-vm-factories 0.1.0", ] @@ -82,6 +82,14 @@ dependencies = [ "stream-cipher 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "ahash" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "const-random 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "aho-corasick" version = "0.6.8" @@ -598,6 +606,7 @@ dependencies = [ "parity-crypto 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "parity-snappy 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-util-mem 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "patricia-trie-ethereum 0.1.0", "rlp 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "rlp_derive 0.1.0", @@ -606,6 +615,24 @@ dependencies = [ "vm 0.1.0", ] +[[package]] +name = "const-random" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "const-random-macro 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro-hack 0.5.9 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "const-random-macro" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro-hack 0.5.9 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "criterion" version = "0.3.0" @@ -645,7 +672,7 @@ version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "crossbeam-epoch 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", - "crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -654,7 +681,7 @@ version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "crossbeam-epoch 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", - "crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -664,7 +691,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "arrayvec 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "memoffset 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "scopeguard 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -675,7 +702,7 @@ name = "crossbeam-queue" version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -685,7 +712,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "crossbeam-utils" -version = "0.6.5" +version = "0.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1043,7 +1070,7 @@ dependencies = [ "executive-state 0.1.0", "fetch 0.1.0", "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "hash-db 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", + "hash-db 0.15.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.2.0", "keccak-hash 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1067,6 +1094,7 @@ dependencies = [ "registrar 0.0.1", "rlp 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "scopeguard 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.99 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1077,7 +1105,7 @@ dependencies = [ "tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", "trace 0.1.0", "trace-time 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "trie-db 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", + "trie-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", "trie-standardmap 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", "trie-vm-factories 0.1.0", "triehash-ethereum 0.2.0", @@ -1216,7 +1244,7 @@ dependencies = [ "failsafe 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "fastmap 0.1.0", "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "hash-db 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", + "hash-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", "journaldb 0.2.0", "keccak-hash 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "keccak-hasher 0.1.1", @@ -1239,7 +1267,7 @@ dependencies = [ "spec 0.1.0", "stats 0.1.0", "tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", - "trie-db 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", + "trie-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", "triehash-ethereum 0.2.0", "verification 0.1.0", "vm 0.1.0", @@ -1368,7 +1396,7 @@ dependencies = [ "ethjson 0.1.0", "fetch 0.1.0", "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "hash-db 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", + "hash-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", "journaldb 0.2.0", "keccak-hash 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "keccak-hasher 0.1.1", @@ -1393,7 +1421,7 @@ dependencies = [ "tiny-keccak 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "trace 0.1.0", "transaction-pool 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "trie-db 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", + "trie-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", "url 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "vm 0.1.0", ] @@ -1668,7 +1696,7 @@ dependencies = [ "ethcore 1.12.0", "ethereum-types 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "evm 0.1.0", - "hash-db 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", + "hash-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", "keccak-hash 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "keccak-hasher 0.1.1", "kvdb 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1681,7 +1709,7 @@ dependencies = [ "rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "spec 0.1.0", "trace 0.1.0", - "trie-db 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", + "trie-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", "trie-vm-factories 0.1.0", "vm 0.1.0", ] @@ -1909,7 +1937,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "hash-db" -version = "0.15.0" +version = "0.15.2" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -1920,6 +1948,15 @@ dependencies = [ "crunchy 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "hashbrown" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "ahash 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "hashmap_core" version = "0.1.10" @@ -2224,7 +2261,7 @@ dependencies = [ "env_logger 0.5.13 (registry+https://github.com/rust-lang/crates.io-index)", "ethereum-types 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "fastmap 0.1.0", - "hash-db 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", + "hash-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", "keccak-hash 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "keccak-hasher 0.1.1", "kvdb 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2352,7 +2389,7 @@ name = "keccak-hasher" version = "0.1.1" dependencies = [ "ethereum-types 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "hash-db 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", + "hash-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", "plain_hasher 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "tiny-keccak 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2362,7 +2399,7 @@ name = "keccak-hasher" version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "hash-db 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", + "hash-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", "hash256-std-hasher 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", "tiny-keccak 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2525,7 +2562,7 @@ dependencies = [ "account-state 0.1.0", "client-traits 0.1.0", "common-types 0.1.0", - "crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", "ethabi 9.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "ethabi-contract 9.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "ethabi-derive 9.0.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2610,7 +2647,7 @@ name = "memory-db" version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "hash-db 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", + "hash-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", "hashmap_core 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "parity-util-mem 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -3393,14 +3430,14 @@ version = "0.1.0" dependencies = [ "elastic-array 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", "ethereum-types 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "hash-db 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", + "hash-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", "journaldb 0.2.0", "keccak-hash 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "keccak-hasher 0.1.1", "memory-db 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-bytes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "rlp 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "trie-db 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", + "trie-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3486,7 +3523,7 @@ dependencies = [ "common-types 0.1.0", "ethereum-types 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "ethjson 0.1.0", - "hash-db 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", + "hash-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", "itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "keccak-hash 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "keccak-hasher 0.1.1", @@ -3498,7 +3535,7 @@ dependencies = [ "rlp 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.99 (registry+https://github.com/rust-lang/crates.io-index)", - "trie-db 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", + "trie-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", "triehash-ethereum 0.2.0", ] @@ -3854,7 +3891,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "crossbeam-deque 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam-queue 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -4216,7 +4253,7 @@ dependencies = [ "account-state 0.1.0", "client-traits 0.1.0", "common-types 0.1.0", - "crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", "engine 0.1.0", "env_logger 0.5.13 (registry+https://github.com/rust-lang/crates.io-index)", "ethabi 9.0.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4230,7 +4267,7 @@ dependencies = [ "ethcore-io 1.12.0", "ethereum-types 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "ethkey 0.4.0", - "hash-db 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", + "hash-db 0.15.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.2.0", "keccak-hash 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4248,11 +4285,12 @@ dependencies = [ "rand_xorshift 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "rlp 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "rlp_derive 0.1.0", + "scopeguard 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "snapshot-tests 0.1.0", "spec 0.1.0", "state-db 0.1.0", "tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", - "trie-db 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", + "trie-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", "trie-standardmap 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", "triehash-ethereum 0.2.0", ] @@ -4276,7 +4314,7 @@ dependencies = [ "ethcore-db 0.1.0", "ethcore-io 1.12.0", "ethereum-types 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "hash-db 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", + "hash-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", "journaldb 0.2.0", "keccak-hash 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "keccak-hasher 0.1.1", @@ -4295,7 +4333,7 @@ dependencies = [ "snapshot 0.1.0", "spec 0.1.0", "tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", - "trie-db 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", + "trie-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", "trie-standardmap 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", "triehash-ethereum 0.2.0", ] @@ -4330,7 +4368,7 @@ dependencies = [ "ethjson 0.1.0", "evm 0.1.0", "executive-state 0.1.0", - "hash-db 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", + "hash-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", "instant-seal 0.1.0", "journaldb 0.2.0", "keccak-hash 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4368,7 +4406,7 @@ dependencies = [ "ethcore-bloom-journal 0.1.0", "ethcore-db 0.1.0", "ethereum-types 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "hash-db 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", + "hash-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", "journaldb 0.2.0", "keccak-hash 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "keccak-hasher 0.1.1", @@ -4633,7 +4671,7 @@ name = "tokio-executor" version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -4734,7 +4772,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "crossbeam-deque 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam-queue 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4757,7 +4795,7 @@ name = "tokio-timer" version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", "slab 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-executor 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4862,12 +4900,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "trie-db" -version = "0.15.0" +version = "0.15.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "elastic-array 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", - "hash-db 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", - "hashmap_core 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "hash-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", + "hashbrown 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -4877,7 +4915,7 @@ name = "trie-standardmap" version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "hash-db 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", + "hash-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", "keccak-hasher 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -4889,7 +4927,7 @@ dependencies = [ "evm 0.1.0", "keccak-hasher 0.1.1", "patricia-trie-ethereum 0.1.0", - "trie-db 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", + "trie-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", "vm 0.1.0", "wasm 0.1.0", ] @@ -4899,7 +4937,7 @@ name = "triehash" version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "hash-db 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", + "hash-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", "rlp 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -5344,6 +5382,7 @@ dependencies = [ "checksum aes-ctr 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d2e5b0458ea3beae0d1d8c0f3946564f8e10f90646cf78c06b4351052058d1ee" "checksum aes-soft 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "cfd7e7ae3f9a1fb5c03b389fc6bb9a51400d0c13053f0dca698c832bfd893a0d" "checksum aesni 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2f70a6b5f971e473091ab7cfb5ffac6cde81666c4556751d8d5620ead8abf100" +"checksum ahash 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)" = "b35dfc96a657c1842b4eb73180b65e37152d4b94d0eb5cb51708aee7826950b4" "checksum aho-corasick 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)" = "68f56c7353e5a9547cbd76ed90f7bb5ffc3ba09d4ea9bd1d8c06c8b1142eeb5a" "checksum aho-corasick 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)" = "58fb5e95d83b38284460a5fda7d6470aa0b8844d283a0b614b8535e880800d2d" "checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" @@ -5390,6 +5429,8 @@ dependencies = [ "checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" "checksum cmake 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)" = "6ec65ee4f9c9d16f335091d23693457ed4928657ba4982289d7fafee03bc614a" "checksum combine 3.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "fc1d011beeed29187b8db2ac3925c8dd4d3e87db463dc9d2d2833985388fc5bc" +"checksum const-random 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "7b641a8c9867e341f3295564203b1c250eb8ce6cb6126e007941f78c4d2ed7fe" +"checksum const-random-macro 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c750ec12b83377637110d5a57f5ae08e895b06c4b16e2bdbf1a94ef717428c59" "checksum criterion 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "938703e165481c8d612ea3479ac8342e5615185db37765162e762ec3523e2fc6" "checksum criterion-plot 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "eccdc6ce8bbe352ca89025bee672aa6d24f4eb8c53e3a8b5d1bc58011da072a2" "checksum crossbeam-deque 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "05e44b8cf3e1a625844d1750e1f7820da46044ff6d28f4d43e455ba3e5bb2c13" @@ -5397,7 +5438,7 @@ dependencies = [ "checksum crossbeam-epoch 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "fedcd6772e37f3da2a9af9bf12ebe046c0dfe657992377b4df982a2b54cd37a9" "checksum crossbeam-queue 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7c979cd6cfe72335896575c6b5688da489e420d36a27a0b9eb0c73db574b4a4b" "checksum crossbeam-utils 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "677d453a17e8bd2b913fa38e8b9cf04bcdbb5be790aa294f2389661d72036015" -"checksum crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "f8306fcef4a7b563b76b7dd949ca48f52bc1141aa067d2ea09565f3e2652aa5c" +"checksum crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)" = "04973fa96e96579258a5091af6003abde64af786b860f18622b82e026cca60e6" "checksum crunchy 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "a2f4a431c5c9f662e1200b7c7f02c34e91361150e382089a8f2dec3ba680cbda" "checksum crunchy 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" "checksum crypto-mac 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4434400df11d95d556bac068ddfedd482915eb18fe8bea89bc80b6e4b1c179e5" @@ -5447,8 +5488,9 @@ dependencies = [ "checksum globset 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "4743617a7464bbda3c8aec8558ff2f9429047e025771037df561d383337ff865" "checksum h2 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)" = "a5b34c246847f938a410a03c5458c7fee2274436675e76d8b903c08efc29c462" "checksum hamming 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "65043da274378d68241eb9a8f8f8aa54e349136f7b8e12f63e3ef44043cc30e1" -"checksum hash-db 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)" = "32c87fec93c4a2d264483ef843ac1930ae7c7999d97d73721305a5188b4c23a4" +"checksum hash-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d23bd4e7b5eda0d0f3a307e8b381fdc8ba9000f26fbe912250c0a4cc3956364a" "checksum hash256-std-hasher 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)" = "16293646125e09e5bc216d9f73fa81ab31c4f97007d56c036bbf15a58e970540" +"checksum hashbrown 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6587d09be37fb98a11cb08b9000a3f592451c1b1b613ca69d949160e313a430a" "checksum hashmap_core 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "8e04cb7a5051270ef3fa79f8c7604d581ecfa73d520e74f554e45541c4b5881a" "checksum heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1679e6ea370dee694f91f1dc469bf94cf8f52051d147aec3e1f9497c6fc22461" "checksum heck 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ea04fa3ead4e05e51a7c806fc07271fdbde4e246a6c6d1efd52e72230b771b82" @@ -5698,7 +5740,7 @@ dependencies = [ "checksum trace-time 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dbe82f2f0bf1991e163e757baf044282823155dd326e70f44ce2186c3c320cc9" "checksum transaction-pool 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "454adc482e32785c3beab9415dd0f3c689f29cc2d16717eb62f6a784d53544b4" "checksum transient-hashmap 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "aeb4b191d033a35edfce392a38cdcf9790b6cebcb30fa690c312c29da4dc433e" -"checksum trie-db 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9b65d609ae631d808c6c1cc23a622733d5a0b66a7d67e9f5cd5171562a1f4cb5" +"checksum trie-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d0b62d27e8aa1c07414549ac872480ac82380bab39e730242ab08d82d7cc098a" "checksum trie-standardmap 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)" = "64fda153c00484d640bc91334624be22ead0e5baca917d9fd53ff29bdebcf9b2" "checksum triehash 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "61d0a66fa2412c7eb7816640e8ea14cf6bd63b6c824e72315b6ca76d33851134" "checksum try-lock 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e604eb7b43c06650e854be16a2a03155743d3752dd1c943f6829e26b7a36e382" diff --git a/ethcore/Cargo.toml b/ethcore/Cargo.toml index f036010c5ac..ffbcdeaf662 100644 --- a/ethcore/Cargo.toml +++ b/ethcore/Cargo.toml @@ -51,6 +51,7 @@ rayon = "1.1" registrar = { path = "../util/registrar" } rlp = "0.4.0" rustc-hex = "2" +scopeguard = "1.0.0" serde = "1.0" serde_derive = "1.0" snapshot = { path = "snapshot" } diff --git a/ethcore/service/src/service.rs b/ethcore/service/src/service.rs index 06f1efe7658..597ee6d3d4e 100644 --- a/ethcore/service/src/service.rs +++ b/ethcore/service/src/service.rs @@ -270,14 +270,12 @@ where ClientIoMessage::TakeSnapshot(num) => { let client = self.client.clone(); let snapshot = self.snapshot.clone(); - let res = thread::Builder::new().name("Periodic Snapshot".into()).spawn(move || { if let Err(e) = snapshot.take_snapshot(&*client, num) { match e { EthcoreError::Snapshot(SnapshotError::SnapshotAborted) => info!("Snapshot aborted"), _ => warn!("Failed to take snapshot at block #{}: {}", num, e), } - } }); diff --git a/ethcore/snapshot/Cargo.toml b/ethcore/snapshot/Cargo.toml index 882c9c5c91c..00b9ab6ea10 100644 --- a/ethcore/snapshot/Cargo.toml +++ b/ethcore/snapshot/Cargo.toml @@ -33,6 +33,7 @@ rand_xorshift = "0.2" parking_lot = "0.9" rlp = "0.4.2" rlp_derive = { path = "../../util/rlp-derive" } +scopeguard = "1.0.0" snappy = { package = "parity-snappy", version ="0.1.0" } state-db = { path = "../state-db" } trie-db = "0.15.0" diff --git a/ethcore/snapshot/snapshot-tests/src/account.rs b/ethcore/snapshot/snapshot-tests/src/account.rs index 09707c31156..fd1e5941bfa 100644 --- a/ethcore/snapshot/snapshot-tests/src/account.rs +++ b/ethcore/snapshot/snapshot-tests/src/account.rs @@ -48,7 +48,7 @@ fn encoding_basic() { let thin_rlp = ::rlp::encode(&account); assert_eq!(::rlp::decode::(&thin_rlp).unwrap(), account); - let p = Progress::default(); + let p = Progress::new(); let fat_rlps = to_fat_rlps(&keccak(&addr), &account, &AccountDB::from_hash(db.as_hash_db(), keccak(addr)), &mut Default::default(), usize::max_value(), usize::max_value(), &p).unwrap(); let fat_rlp = Rlp::new(&fat_rlps[0]).at(1).unwrap(); assert_eq!(from_fat_rlp(&mut AccountDBMut::from_hash(db.as_hash_db_mut(), keccak(addr)), fat_rlp, H256::zero()).unwrap().0, account); @@ -69,7 +69,7 @@ fn encoding_version() { let thin_rlp = ::rlp::encode(&account); assert_eq!(::rlp::decode::(&thin_rlp).unwrap(), account); - let p = Progress::default(); + let p = Progress::new(); let fat_rlps = to_fat_rlps(&keccak(&addr), &account, &AccountDB::from_hash(db.as_hash_db(), keccak(addr)), &mut Default::default(), usize::max_value(), usize::max_value(), &p).unwrap(); let fat_rlp = Rlp::new(&fat_rlps[0]).at(1).unwrap(); assert_eq!(from_fat_rlp(&mut AccountDBMut::from_hash(db.as_hash_db_mut(), keccak(addr)), fat_rlp, H256::zero()).unwrap().0, account); @@ -96,7 +96,7 @@ fn encoding_storage() { let thin_rlp = ::rlp::encode(&account); assert_eq!(::rlp::decode::(&thin_rlp).unwrap(), account); - let p = Progress::default(); + let p = Progress::new(); let fat_rlp = to_fat_rlps(&keccak(&addr), &account, &AccountDB::from_hash(db.as_hash_db(), keccak(addr)), &mut Default::default(), usize::max_value(), usize::max_value(), &p).unwrap(); let fat_rlp = Rlp::new(&fat_rlp[0]).at(1).unwrap(); @@ -124,7 +124,7 @@ fn encoding_storage_split() { let thin_rlp = ::rlp::encode(&account); assert_eq!(::rlp::decode::(&thin_rlp).unwrap(), account); - let p = Progress::default(); + let p = Progress::new(); let fat_rlps = to_fat_rlps(&keccak(addr), &account, &AccountDB::from_hash(db.as_hash_db(), keccak(addr)), &mut Default::default(), 500, 1000, &p).unwrap(); let mut root = KECCAK_NULL_RLP; let mut restored_account = None; @@ -170,8 +170,8 @@ fn encoding_code() { }; let mut used_code = HashSet::new(); - let p1 = Progress::default(); - let p2 = Progress::default(); + let p1 = Progress::new(); + let p2 = Progress::new(); let fat_rlp1 = to_fat_rlps(&keccak(&addr1), &account1, &AccountDB::from_hash(db.as_hash_db(), keccak(addr1)), &mut used_code, usize::max_value(), usize::max_value(), &p1).unwrap(); let fat_rlp2 = to_fat_rlps(&keccak(&addr2), &account2, &AccountDB::from_hash(db.as_hash_db(), keccak(addr2)), &mut used_code, usize::max_value(), usize::max_value(), &p2).unwrap(); assert_eq!(used_code.len(), 1); diff --git a/ethcore/snapshot/snapshot-tests/src/helpers.rs b/ethcore/snapshot/snapshot-tests/src/helpers.rs index afc4979068d..0c419dd71bb 100644 --- a/ethcore/snapshot/snapshot-tests/src/helpers.rs +++ b/ethcore/snapshot/snapshot-tests/src/helpers.rs @@ -27,7 +27,8 @@ use client_traits::ChainInfo; use common_types::{ ids::BlockId, basic_account::BasicAccount, - errors::EthcoreError + errors::EthcoreError, + snapshot::Progress, }; use engine::Engine; use ethcore::client::Client; @@ -145,7 +146,7 @@ pub fn snap(client: &Client) -> (Box, TempDir) { let tempdir = TempDir::new("").unwrap(); let path = tempdir.path().join("file"); let writer = PackedWriter::new(&path).unwrap(); - let progress = Default::default(); + let progress = Progress::new(); let hash = client.chain_info().best_block_hash; client.take_snapshot(writer, BlockId::Hash(hash), &progress).unwrap(); diff --git a/ethcore/snapshot/snapshot-tests/src/proof_of_work.rs b/ethcore/snapshot/snapshot-tests/src/proof_of_work.rs index 81dcfe2cd5b..9d01432fff3 100644 --- a/ethcore/snapshot/snapshot-tests/src/proof_of_work.rs +++ b/ethcore/snapshot/snapshot-tests/src/proof_of_work.rs @@ -74,7 +74,7 @@ fn chunk_and_restore(amount: u64) { &bc, best_hash, &writer, - &Progress::default() + &Progress::new() ).unwrap(); let manifest = ManifestData { diff --git a/ethcore/snapshot/snapshot-tests/src/service.rs b/ethcore/snapshot/snapshot-tests/src/service.rs index b2e7a98256f..ebedd5472c9 100644 --- a/ethcore/snapshot/snapshot-tests/src/service.rs +++ b/ethcore/snapshot/snapshot-tests/src/service.rs @@ -278,7 +278,7 @@ fn keep_ancient_blocks() { &bc, best_hash, &writer, - &Progress::default() + &Progress::new() ).unwrap(); let state_db = client.state_db().journal_db().boxed_clone(); let start_header = bc.block_header_data(&best_hash).unwrap(); @@ -287,7 +287,7 @@ fn keep_ancient_blocks() { state_db.as_hash_db(), &state_root, &writer, - &Progress::default(), + &Progress::new(), None, 0 ).unwrap(); diff --git a/ethcore/snapshot/snapshot-tests/src/state.rs b/ethcore/snapshot/snapshot-tests/src/state.rs index 4cccd0d82e9..ef905796404 100644 --- a/ethcore/snapshot/snapshot-tests/src/state.rs +++ b/ethcore/snapshot/snapshot-tests/src/state.rs @@ -62,7 +62,7 @@ fn snap_and_restore() { let mut state_hashes = Vec::new(); for part in 0..SNAPSHOT_SUBPARTS { - let mut hashes = chunk_state(&old_db, &state_root, &writer, &Progress::default(), Some(part), 0).unwrap(); + let mut hashes = chunk_state(&old_db, &state_root, &writer, &Progress::new(), Some(part), 0).unwrap(); state_hashes.append(&mut hashes); } @@ -133,7 +133,7 @@ fn get_code_from_prev_chunk() { let mut make_chunk = |acc, hash| { let mut db = journaldb::new_memory_db(); AccountDBMut::from_hash(&mut db, hash).insert(EMPTY_PREFIX, &code[..]); - let p = Progress::default(); + let p = Progress::new(); let fat_rlp = to_fat_rlps(&hash, &acc, &AccountDB::from_hash(&db, hash), &mut used_code, usize::max_value(), usize::max_value(), &p).unwrap(); let mut stream = RlpStream::new_list(1); stream.append_raw(&fat_rlp[0], 1); @@ -178,7 +178,7 @@ fn checks_flag() { let state_root = producer.state_root(); let writer = Mutex::new(PackedWriter::new(&snap_file).unwrap()); - let state_hashes = chunk_state(&old_db, &state_root, &writer, &Progress::default(), None, 0).unwrap(); + let state_hashes = chunk_state(&old_db, &state_root, &writer, &Progress::new(), None, 0).unwrap(); writer.into_inner().finish(ManifestData { version: 2, diff --git a/ethcore/snapshot/snapshot-tests/src/watcher.rs b/ethcore/snapshot/snapshot-tests/src/watcher.rs index d7cf35ced3e..95e932a2a35 100644 --- a/ethcore/snapshot/snapshot-tests/src/watcher.rs +++ b/ethcore/snapshot/snapshot-tests/src/watcher.rs @@ -41,8 +41,8 @@ impl Oracle for TestOracle { struct TestBroadcast(Option); impl Broadcast for TestBroadcast { - fn take_at(&self, num: Option) { - if num != self.0 { + fn request_snapshot_at(&self, num: u64) { + if Some(num) != self.0 { panic!("Watcher broadcast wrong number. Expected {:?}, found {:?}", self.0, num); } } diff --git a/ethcore/snapshot/src/consensus/work.rs b/ethcore/snapshot/src/consensus/work.rs index fede7e9d624..819e95ca063 100644 --- a/ethcore/snapshot/src/consensus/work.rs +++ b/ethcore/snapshot/src/consensus/work.rs @@ -178,7 +178,7 @@ impl<'a> PowWorker<'a> { let parent_hash = last_header.parent_hash(); let parent_total_difficulty = last_details.total_difficulty - last_header.difficulty(); - trace!(target: "snapshot", "parent last written block: {}", parent_hash); + trace!(target: "snapshot", "parent last written block: #{}/{}", parent_number, parent_hash); let num_entries = self.rlps.len(); let mut rlp_stream = RlpStream::new_list(3 + num_entries); diff --git a/ethcore/snapshot/src/lib.rs b/ethcore/snapshot/src/lib.rs index e6797a661a9..406aeeddb93 100644 --- a/ethcore/snapshot/src/lib.rs +++ b/ethcore/snapshot/src/lib.rs @@ -129,35 +129,34 @@ pub fn take_snapshot( let state_root = start_header.state_root(); let block_number = start_header.number(); - info!("Taking snapshot starting at block {}", block_number); - + info!("Taking snapshot starting at block #{}/{:?}", block_number, block_hash); let version = chunker.current_version(); let writer = Mutex::new(writer); let (state_hashes, block_hashes) = thread::scope(|scope| -> Result<(Vec, Vec), Error> { let writer = &writer; - let block_guard = scope.spawn(move |_| { + let tb = scope.builder().name("Snapshot Worker - Blocks".to_string()); + let block_guard = tb.spawn(move |_| { chunk_secondary(chunker, chain, block_hash, writer, p) - }); + })?; // The number of threads must be between 1 and SNAPSHOT_SUBPARTS assert!(processing_threads >= 1, "Cannot use less than 1 threads for creating snapshots"); - let num_threads: usize = cmp::min(processing_threads, SNAPSHOT_SUBPARTS); + let num_threads = cmp::min(processing_threads, SNAPSHOT_SUBPARTS); info!(target: "snapshot", "Using {} threads for Snapshot creation.", num_threads); - let mut state_guards = Vec::with_capacity(num_threads as usize); + let mut state_guards = Vec::with_capacity(num_threads); for thread_idx in 0..num_threads { - let state_guard = scope.spawn(move |_| -> Result, Error> { + let tb = scope.builder().name(format!("Snapshot Worker #{} - State", thread_idx).to_string()); + let state_guard = tb.spawn(move |_| -> Result, Error> { let mut chunk_hashes = Vec::new(); - for part in (thread_idx..SNAPSHOT_SUBPARTS).step_by(num_threads) { - debug!(target: "snapshot", "Chunking part {} in thread {}", part, thread_idx); + debug!(target: "snapshot", "Chunking part {} of the state at {} in thread {}", part, block_number, thread_idx); let mut hashes = chunk_state(state_db, &state_root, writer, p, Some(part), thread_idx)?; chunk_hashes.append(&mut hashes); } - Ok(chunk_hashes) - }); + })?; state_guards.push(state_guard); } @@ -169,7 +168,8 @@ pub fn take_snapshot( state_hashes.extend(part_state_hashes); } - debug!(target: "snapshot", "Took a snapshot of {} accounts", p.accounts.load(Ordering::SeqCst)); + info!("Took a snapshot at #{} of {} accounts", block_number, p.accounts()); + Ok((state_hashes, block_hashes)) }).expect("Sub-thread never panics; qed")?; @@ -218,7 +218,7 @@ pub fn chunk_secondary<'a>( trace!(target: "snapshot", "wrote secondary chunk. hash: {:x}, size: {}, uncompressed size: {}", hash, size, raw_data.len()); - progress.size.fetch_add(size as u64, Ordering::SeqCst); + progress.update(0, size); chunk_hashes.push(hash); Ok(()) }; @@ -275,8 +275,7 @@ impl<'a> StateChunker<'a> { self.writer.lock().write_state_chunk(hash, compressed)?; trace!(target: "snapshot", "Thread {} wrote state chunk. size: {}, uncompressed size: {}", self.thread_idx, compressed_size, raw_data.len()); - self.progress.accounts.fetch_add(num_entries, Ordering::SeqCst); - self.progress.size.fetch_add(compressed_size as u64, Ordering::SeqCst); + self.progress.update(num_entries, compressed_size); self.hashes.push(hash); self.cur_size = 0; @@ -327,7 +326,7 @@ pub fn chunk_state<'a>( if let Some(part) = part { assert!(part < 16, "Wrong chunk state part number (must be <16) in snapshot creation."); - let part_offset = MAX_SNAPSHOT_SUBPARTS / SNAPSHOT_SUBPARTS; + let part_offset = MAX_SNAPSHOT_SUBPARTS / SNAPSHOT_SUBPARTS; // 16 let mut seek_from = vec![0; 32]; seek_from[0] = (part * part_offset) as u8; account_iter.seek(&seek_from)?; @@ -349,7 +348,15 @@ pub fn chunk_state<'a>( let account = ::rlp::decode(&*account_data)?; let account_db = AccountDB::from_hash(db, account_key_hash); - let fat_rlps = account::to_fat_rlps(&account_key_hash, &account, &account_db, &mut used_code, PREFERRED_CHUNK_SIZE - chunker.chunk_size(), PREFERRED_CHUNK_SIZE, progress)?; + let fat_rlps = account::to_fat_rlps( + &account_key_hash, + &account, + &account_db, + &mut used_code, + PREFERRED_CHUNK_SIZE - chunker.chunk_size(), + PREFERRED_CHUNK_SIZE, + progress + )?; for (i, fat_rlp) in fat_rlps.into_iter().enumerate() { if i > 0 { chunker.write_chunk()?; diff --git a/ethcore/snapshot/src/service.rs b/ethcore/snapshot/src/service.rs index 141a32360c9..da84482db71 100644 --- a/ethcore/snapshot/src/service.rs +++ b/ethcore/snapshot/src/service.rs @@ -39,7 +39,7 @@ use ethcore_io::IoChannel; use journaldb::Algorithm; use keccak_hash::keccak; use kvdb::DBTransaction; -use log::{error, info, trace, warn}; +use log::{debug, error, info, trace, warn}; use parking_lot::{Mutex, RwLock, RwLockReadGuard}; use snappy; use trie_db::TrieError; @@ -212,7 +212,7 @@ impl Restoration { } self.guard.disarm(); - trace!(target: "snapshot", "restoration finalised correctly"); + trace!(target: "snapshot", "Restoration finalised correctly"); Ok(()) } @@ -280,7 +280,7 @@ impl Service where C: SnapshotClient + ChainInfo { state_chunks: AtomicUsize::new(0), block_chunks: AtomicUsize::new(0), client: params.client, - progress: Default::default(), + progress: Progress::new(), taking_snapshot: AtomicBool::new(false), restoring_snapshot: AtomicBool::new(false), }; @@ -413,7 +413,10 @@ impl Service where C: SnapshotClient + ChainInfo { Some(x) => x, None => return Ok(0), }; - + info!(target: "snapshot", "Migrating blocks from old db to new. Start: #{}/{:?}, Target: #{}/{:?}", + self.client.block_number(BlockId::Hash(start_hash)).unwrap_or_default(), start_hash, + self.client.block_number(BlockId::Hash(target_hash)).unwrap_or_default(), target_hash, + ); let mut batch = DBTransaction::new(); let mut parent_hash = start_hash; while parent_hash != target_hash { @@ -455,10 +458,10 @@ impl Service where C: SnapshotClient + ChainInfo { next_chain.commit(); next_db.key_value().flush().expect("DB flush failed."); batch = DBTransaction::new(); - } - if block_number % 10_000 == 0 { - info!(target: "snapshot", "Block restoration at #{}", block_number); + if block_number % 10_000 == 0 { + info!(target: "snapshot", "Block restoration at #{}", block_number); + } } } @@ -483,11 +486,13 @@ impl Service where C: SnapshotClient + ChainInfo { if self.progress.done() || !self.taking_snapshot.load(Ordering::SeqCst) { return } let p = &self.progress; - info!("Snapshot: {} accounts {} blocks {} bytes", p.accounts(), p.blocks(), p.size()); + info!("Snapshot: {} accounts, {} blocks, {} bytes", p.accounts(), p.blocks(), p.bytes()); + let rate = p.rate(); + debug!(target: "snapshot", "Current progress rate: {:.0} acc/s, {:.0} bytes/s (compressed)", rate.0, rate.1); } /// Take a snapshot at the block with the given number. - /// calling this while a restoration is in progress or vice versa + /// Calling this while a restoration is in progress or vice versa /// will lead to a race condition where the first one to finish will /// have their produced snapshot overwritten. pub fn take_snapshot(&self, client: &C, num: u64) -> Result<(), Error> { @@ -497,45 +502,40 @@ impl Service where C: SnapshotClient + ChainInfo { } info!("Taking snapshot at #{}", num); - self.progress.reset(); - - let temp_dir = self.temp_snapshot_dir(); - let snapshot_dir = self.snapshot_dir(); + { + scopeguard::defer! {{ + self.taking_snapshot.store(false, Ordering::SeqCst); + }} + let start_time = std::time::Instant::now(); + self.progress.reset(); + + let temp_dir = self.temp_snapshot_dir(); + let snapshot_dir = self.snapshot_dir(); - let _ = fs::remove_dir_all(&temp_dir); + let _ = fs::remove_dir_all(&temp_dir); // expected to fail - let writer = LooseWriter::new(temp_dir.clone())?; + let writer = LooseWriter::new(temp_dir.clone())?; - let guard = Guard::new(temp_dir.clone()); - let res = client.take_snapshot(writer, BlockId::Number(num), &self.progress); - self.taking_snapshot.store(false, Ordering::SeqCst); - if let Err(e) = res { - if client.chain_info().best_block_number >= num + client.pruning_history() { - // The state we were snapshotting was pruned before we could finish. - info!("Periodic snapshot failed: block state pruned. Run with a longer `--pruning-history` or with `--no-periodic-snapshot`"); - return Err(e); - } else { - return Err(e); - } - } + let guard = Guard::new(temp_dir.clone()); + let _ = client.take_snapshot(writer, BlockId::Number(num), &self.progress)?; + info!("Finished taking snapshot at #{}, in {:.0?}", num, start_time.elapsed()); - info!("Finished taking snapshot at #{}", num); + // destroy the old snapshot reader. + let mut reader = self.reader.write(); + *reader = None; - let mut reader = self.reader.write(); + if snapshot_dir.exists() { + trace!(target: "snapshot", "Removing previous snapshot at {:?}", &snapshot_dir); + fs::remove_dir_all(&snapshot_dir)?; + } - // destroy the old snapshot reader. - *reader = None; + fs::rename(temp_dir, &snapshot_dir)?; + trace!(target: "snapshot", "Moved new snapshot into place at {:?}", &snapshot_dir); + *reader = Some(LooseReader::new(snapshot_dir)?); - if snapshot_dir.exists() { - fs::remove_dir_all(&snapshot_dir)?; + guard.disarm(); + Ok(()) } - - fs::rename(temp_dir, &snapshot_dir)?; - - *reader = Some(LooseReader::new(snapshot_dir)?); - - guard.disarm(); - Ok(()) } /// Initialize the restoration synchronously. @@ -654,13 +654,19 @@ impl Service where C: SnapshotClient + ChainInfo { Ok(()) } - /// Import a previous chunk at the given path. Returns whether the block was imported or not - fn import_prev_chunk(&self, restoration: &mut Option, manifest: &ManifestData, file: io::Result) -> Result { + /// Import a previous chunk at the given path. Returns whether the chunk was imported or not + fn import_prev_chunk( + &self, + restoration: &mut Option, + manifest: &ManifestData, + file: io::Result + ) -> Result { let file = file?; let path = file.path(); let mut file = File::open(path.clone())?; - let mut buffer = Vec::new(); + let filesize = file.metadata()?.len(); + let mut buffer = Vec::with_capacity(filesize as usize + 1); // +1 for EOF file.read_to_end(&mut buffer)?; let hash = keccak(&buffer); @@ -670,6 +676,7 @@ impl Service where C: SnapshotClient + ChainInfo { } else if manifest.state_hashes.contains(&hash) { true } else { + warn!(target: "snapshot", "Hash of the content of {:?} not present in the manifest block/state hashes.", path); return Ok(false); }; @@ -680,11 +687,10 @@ impl Service where C: SnapshotClient + ChainInfo { Ok(true) } - // finalize the restoration. this accepts an already-locked - // restoration as an argument -- so acquiring it again _will_ - // lead to deadlock. + // Finalize the restoration. This accepts an already-locked restoration as an argument -- so + // acquiring it again _will_ lead to deadlock. fn finalize_restoration(&self, rest: &mut Option) -> Result<(), Error> { - trace!(target: "snapshot", "finalizing restoration"); + trace!(target: "snapshot", "Finalizing restoration"); *self.status.lock() = RestorationStatus::Finalizing; let recover = rest.as_ref().map_or(false, |rest| rest.writer.is_some()); @@ -695,7 +701,7 @@ impl Service where C: SnapshotClient + ChainInfo { .unwrap_or(Ok(()))?; let migrated_blocks = self.migrate_blocks()?; - info!(target: "snapshot", "Migrated {} ancient blocks", migrated_blocks); + info!(target: "snapshot", "Migrated {} ancient blocks from the old DB", migrated_blocks); // replace the Client's database with the new one (restart the Client). self.client.restore_db(&*self.restoration_db().to_string_lossy())?; @@ -707,11 +713,11 @@ impl Service where C: SnapshotClient + ChainInfo { let snapshot_dir = self.snapshot_dir(); if snapshot_dir.exists() { - trace!(target: "snapshot", "removing old snapshot dir at {}", snapshot_dir.to_string_lossy()); + trace!(target: "snapshot", "Removing old snapshot dir at {}", snapshot_dir.to_string_lossy()); fs::remove_dir_all(&snapshot_dir)?; } - trace!(target: "snapshot", "copying restored snapshot files over"); + trace!(target: "snapshot", "Copying restored snapshot files over"); fs::rename(self.temp_recovery_dir(), &snapshot_dir)?; *reader = Some(LooseReader::new(snapshot_dir)?); diff --git a/ethcore/snapshot/src/traits.rs b/ethcore/snapshot/src/traits.rs index b72d6b7afe0..8f5e12a119c 100644 --- a/ethcore/snapshot/src/traits.rs +++ b/ethcore/snapshot/src/traits.rs @@ -136,7 +136,7 @@ pub trait SnapshotComponents: Send { /// Snapshot related functionality pub trait SnapshotClient: BlockChainClient + BlockInfo + DatabaseRestore + BlockChainReset { /// Take a snapshot at the given block. - /// If the ID given is "latest", this will default to 1000 blocks behind. + /// If the BlockId is 'Latest', this will default to 1000 blocks behind. fn take_snapshot( &self, writer: W, @@ -148,7 +148,7 @@ pub trait SnapshotClient: BlockChainClient + BlockInfo + DatabaseRestore + Block /// Helper trait for broadcasting a block to take a snapshot at. pub trait Broadcast: Send + Sync { /// Start a snapshot from the given block number. - fn take_at(&self, num: Option); + fn request_snapshot_at(&self, num: u64); } diff --git a/ethcore/snapshot/src/watcher.rs b/ethcore/snapshot/src/watcher.rs index d6d9bcef8c0..34ed5189bbd 100644 --- a/ethcore/snapshot/src/watcher.rs +++ b/ethcore/snapshot/src/watcher.rs @@ -49,16 +49,11 @@ impl Oracle for StandardOracle } impl Broadcast for Mutex>> { - fn take_at(&self, num: Option) { - let num = match num { - Some(n) => n, - None => return, - }; - - trace!(target: "snapshot_watcher", "Snapshot requested at block #{}", num); - + fn request_snapshot_at(&self, num: u64) { if let Err(e) = self.lock().send(ClientIoMessage::TakeSnapshot(num)) { - warn!("Snapshot watcher disconnected from IoService: {}", e); + warn!(target: "snapshot_watcher", "Snapshot watcher disconnected from IoService: {}", e); + } else { + trace!(target: "snapshot_watcher", "Snapshot requested at block #{}", num); } } } @@ -68,7 +63,10 @@ impl Broadcast for Mutex>> { pub struct Watcher { oracle: Box, broadcast: Box, + // How often we attempt to take a snapshot: only snapshot on blocknumbers that are multiples of + // `period`. Always set to `SNAPSHOT_PERIOD`, i.e. 5000. period: u64, + // Start snapshots `history` blocks from the tip. Always set to `SNAPSHOT_HISTORY`, i.e. 100. history: u64, } @@ -106,18 +104,22 @@ impl ChainNotify for Watcher { fn new_blocks(&self, new_blocks: NewBlocks) { if self.oracle.is_major_importing() || new_blocks.has_more_blocks_to_import { return } - trace!(target: "snapshot_watcher", "{} imported", new_blocks.imported.len()); - + // Decide if it's time for a snapshot: the highest of the imported blocks is a multiple of 5000? let highest = new_blocks.imported.into_iter() + // Convert block hashes to block numbers for all newly imported blocks .filter_map(|h| self.oracle.to_number(h)) - .filter(|&num| num >= self.period + self.history) - .map(|num| num - self.history) - .filter(|num| num % self.period == 0) + // Subtract `history` (i.e. `SNAPSHOT_HISTORY`, i.e. 100) from the block numbers to stay + // clear of reorgs. + .map(|num| num.saturating_sub(self.history) ) + // …filter out blocks that do not fall on the a multiple of `period`. This regulates the + // frequency of snapshots and ensures more snapshots are produced from similar points in + // the chain. + .filter(|num| num % self.period == 0 ) + // Pick newest of the candidates: this is where we want to snapshot from. .fold(0, ::std::cmp::max); - match highest { - 0 => self.broadcast.take_at(None), - _ => self.broadcast.take_at(Some(highest)), + if highest > 0 { + self.broadcast.request_snapshot_at(highest); } } } diff --git a/ethcore/src/client/client.rs b/ethcore/src/client/client.rs index 4527dba8152..c1c450486fe 100644 --- a/ethcore/src/client/client.rs +++ b/ethcore/src/client/client.rs @@ -20,7 +20,7 @@ use std::convert::TryFrom; use std::io::{BufRead, BufReader}; use std::str::from_utf8; use std::sync::{Arc, Weak}; -use std::sync::atomic::{AtomicBool, AtomicI64, Ordering as AtomicOrdering}; +use std::sync::atomic::{AtomicBool, AtomicI64, Ordering as AtomicOrdering, Ordering, AtomicU64}; use std::time::{Duration, Instant}; use ansi_term::Colour; @@ -204,6 +204,9 @@ pub struct Client { /// Database pruning strategy to use for StateDB pruning: journaldb::Algorithm, + /// Don't prune the state we're currently snapshotting + snapshotting_at: AtomicU64, + /// Client uses this to store blocks, traces, etc. db: RwLock>, @@ -780,6 +783,7 @@ impl Client { tracedb, engine, pruning: config.pruning.clone(), + snapshotting_at: AtomicU64::new(0), db: RwLock::new(db.clone()), state_db: RwLock::new(state_db), report: RwLock::new(Default::default()), @@ -964,13 +968,15 @@ impl Client { return Ok(()) } - let number = match state_db.journal_db().latest_era() { + let latest_era = match state_db.journal_db().latest_era() { Some(n) => n, None => return Ok(()), }; - // prune all ancient eras until we're below the memory target, - // but have at least the minimum number of states. + // Prune all ancient eras until we're below the memory target (default: 32Mb), + // but have at least the minimum number of states, i.e. `history`. + // If a snapshot is under way, no pruning happens and memory consumption is allowed to + // increase above the memory target until the snapshot has finished. loop { let needs_pruning = state_db.journal_db().journal_size() >= self.config.history_mem; @@ -979,17 +985,27 @@ impl Client { } match state_db.journal_db().earliest_era() { - Some(era) if era + self.history <= number => { - trace!(target: "client", "Pruning state for ancient era {}", era); - match chain.block_hash(era) { + Some(earliest_era) if earliest_era + self.history <= latest_era => { + let freeze_at = self.snapshotting_at.load(Ordering::SeqCst); + if freeze_at > 0 && freeze_at == earliest_era { + // Note: journal_db().mem_used() can be used for a more accurate memory + // consumption measurement but it can be expensive so sticking with the + // faster `journal_size()` instead. + trace!(target: "pruning", "Pruning is paused at era {} (snapshot under way); earliest era={}, latest era={}, journal_size={} – Not pruning.", + freeze_at, earliest_era, latest_era, state_db.journal_db().journal_size()); + break; + } + trace!(target: "pruning", "Pruning state for ancient era #{}; latest era={}, journal_size={}", + earliest_era, latest_era, state_db.journal_db().journal_size()); + match chain.block_hash(earliest_era) { Some(ancient_hash) => { let mut batch = DBTransaction::new(); - state_db.mark_canonical(&mut batch, era, &ancient_hash)?; + state_db.mark_canonical(&mut batch, earliest_era, &ancient_hash)?; self.db.read().key_value().write_buffered(batch); state_db.journal_db().flush(); } None => - debug!(target: "client", "Missing expected hash for block {}", era), + debug!(target: "pruning", "Missing expected hash for block {}", earliest_era), } } _ => break, // means that every era is kept, no pruning necessary. @@ -2533,48 +2549,61 @@ impl SnapshotClient for Client { return Err(EthcoreError::Snapshot(SnapshotError::SnapshotsUnsupported)); } let db = self.state_db.read().journal_db().boxed_clone(); - let best_block_number = self.chain_info().best_block_number; - let block_number = self.block_number(at).ok_or_else(|| SnapshotError::InvalidStartingBlock(at))?; - if db.is_prunable() && self.pruning_info().earliest_state > block_number { + let block_number = self.block_number(at).ok_or_else(|| SnapshotError::InvalidStartingBlock(at))?; + let earliest_era = db.earliest_era().unwrap_or(0); + if db.is_prunable() && earliest_era > block_number { return Err(SnapshotError::OldBlockPrunedDB.into()); } - let history = cmp::min(self.history, 1000); - let start_hash = match at { + let (actual_block_nr, block_hash) = match at { BlockId::Latest => { - let start_num = match db.earliest_era() { - Some(era) => cmp::max(era, best_block_number.saturating_sub(history)), - None => best_block_number.saturating_sub(history), - }; + // Start `self.history` blocks from the best block, but no further back than 1000 + // blocks (or earliest era, whichever is greatest). + let history = cmp::min(self.history, 1000); + let best_block_number = self.chain_info().best_block_number; + let start_num = cmp::max(earliest_era, best_block_number.saturating_sub(history)); match self.block_hash(BlockId::Number(start_num)) { - Some(h) => h, - None => return Err(SnapshotError::InvalidStartingBlock(at).into()), + Some(hash) => (start_num, hash), + None => { + error!(target: "snapshot", "Can't take snapshot at {:?}: missing hash for the starting block #{}", at, start_num); + return Err(SnapshotError::InvalidStartingBlock(at).into()) + }, } } _ => match self.block_hash(at) { - Some(hash) => hash, + Some(hash) => (block_number, hash), None => return Err(SnapshotError::InvalidStartingBlock(at).into()), }, }; let processing_threads = self.config.snapshot.processing_threads; - let chunker = snapshot::chunker(self.engine.snapshot_mode()).ok_or_else(|| SnapshotError::SnapshotsUnsupported)?; - snapshot::take_snapshot( - chunker, - &self.chain.read(), - start_hash, - db.as_hash_db(), - writer, - p, - processing_threads, - )?; - Ok(()) + trace!(target: "snapshot", "Snapshot requested at block {:?}. Using block #{}/{:?}. Earliest block: #{}, earliest state era #{}. Using {} threads.", + at, actual_block_nr, block_hash, self.pruning_info().earliest_chain, earliest_era, processing_threads, + ); + // Stop pruning from happening while the snapshot is under way. + self.snapshotting_at.store(actual_block_nr, Ordering::SeqCst); + { + scopeguard::defer! {{ + trace!(target: "snapshot", "Re-enabling pruning."); + self.snapshotting_at.store(0, Ordering::SeqCst) + }}; + let chunker = snapshot::chunker(self.engine.snapshot_mode()).ok_or_else(|| SnapshotError::SnapshotsUnsupported)?; + // Spawn threads and take snapshot + snapshot::take_snapshot( + chunker, + &self.chain.read(), + block_hash, + db.as_hash_db(), + writer, + p, + processing_threads, + )?; + Ok(()) + } } - - } impl ImportExportBlocks for Client { diff --git a/ethcore/src/client/config.rs b/ethcore/src/client/config.rs index 5a1c2b87e75..23104c48b56 100644 --- a/ethcore/src/client/config.rs +++ b/ethcore/src/client/config.rs @@ -90,7 +90,7 @@ pub struct ClientConfig { pub history: u64, /// Ideal memory usage for state pruning history. pub history_mem: usize, - /// Check seal valididity on block import + /// Check seal validity on block import pub check_seal: bool, /// Maximal number of transactions queued for verification in a separate thread. pub transaction_verification_queue_size: usize, diff --git a/ethcore/types/Cargo.toml b/ethcore/types/Cargo.toml index 509b9d13dd7..dd1dff2fb5a 100644 --- a/ethcore/types/Cargo.toml +++ b/ethcore/types/Cargo.toml @@ -15,6 +15,7 @@ parity-bytes = "0.1" parity-crypto = { version = "0.4.2", features = ["publickey"] } parity-util-mem = "0.2.0" parity-snappy = "0.1" +parking_lot = "0.9.0" patricia-trie-ethereum = { path = "../../util/patricia-trie-ethereum" } rlp = "0.4.0" rlp_derive = { path = "../../util/rlp-derive" } diff --git a/ethcore/types/src/lib.rs b/ethcore/types/src/lib.rs index 58ca86cae94..ab17b8837db 100644 --- a/ethcore/types/src/lib.rs +++ b/ethcore/types/src/lib.rs @@ -40,6 +40,7 @@ extern crate parity_crypto; #[macro_use] extern crate derive_more; extern crate keccak_hash as hash; +extern crate parking_lot; extern crate parity_bytes as bytes; extern crate patricia_trie_ethereum as ethtrie; extern crate rlp; diff --git a/ethcore/types/src/snapshot.rs b/ethcore/types/src/snapshot.rs index ed305d68919..a3be631bebf 100644 --- a/ethcore/types/src/snapshot.rs +++ b/ethcore/types/src/snapshot.rs @@ -16,11 +16,13 @@ //! Snapshot type definitions -use std::sync::atomic::{AtomicBool, AtomicUsize, AtomicU64, Ordering}; +use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering}; +use std::time::Instant; +use bytes::Bytes; use ethereum_types::H256; +use parking_lot::RwLock; use rlp::{Rlp, RlpStream, DecoderError}; -use bytes::Bytes; /// Modes of snapshotting pub enum Snapshotting { @@ -39,31 +41,53 @@ pub enum Snapshotting { } /// A progress indicator for snapshots. -#[derive(Debug, Default)] +#[derive(Debug)] pub struct Progress { /// Number of accounts processed so far - pub accounts: AtomicUsize, + accounts: AtomicUsize, + // Number of accounts processed at last tick. + prev_accounts: AtomicUsize, /// Number of blocks processed so far pub blocks: AtomicUsize, /// Size in bytes of a all compressed chunks processed so far - pub size: AtomicU64, + bytes: AtomicUsize, + // Number of bytes processed at last tick. + prev_bytes: AtomicUsize, /// Signals that the snapshotting process is completed pub done: AtomicBool, /// Signal snapshotting process to abort pub abort: AtomicBool, + + last_tick: RwLock, } impl Progress { + /// Create a new progress tracker. + pub fn new() -> Progress { + Progress { + accounts: AtomicUsize::new(0), + prev_accounts: AtomicUsize::new(0), + blocks: AtomicUsize::new(0), + bytes: AtomicUsize::new(0), + prev_bytes: AtomicUsize::new(0), + abort: AtomicBool::new(false), + done: AtomicBool::new(false), + last_tick: RwLock::new(Instant::now()), + } + } + /// Reset the progress. pub fn reset(&self) { self.accounts.store(0, Ordering::Release); self.blocks.store(0, Ordering::Release); - self.size.store(0, Ordering::Release); + self.bytes.store(0, Ordering::Release); self.abort.store(false, Ordering::Release); // atomic fence here to ensure the others are written first? // logs might very rarely get polluted if not. self.done.store(false, Ordering::Release); + + *self.last_tick.write() = Instant::now(); } /// Get the number of accounts snapshotted thus far. @@ -73,10 +97,37 @@ impl Progress { pub fn blocks(&self) -> usize { self.blocks.load(Ordering::Acquire) } /// Get the written size of the snapshot in bytes. - pub fn size(&self) -> u64 { self.size.load(Ordering::Acquire) } + pub fn bytes(&self) -> usize { self.bytes.load(Ordering::Acquire) } /// Whether the snapshot is complete. pub fn done(&self) -> bool { self.done.load(Ordering::Acquire) } + + /// Return the progress rate over the last tick (i.e. since last update). + pub fn rate(&self) -> (f64, f64) { + let last_tick = *self.last_tick.read(); + let dt = last_tick.elapsed().as_secs_f64(); + if dt < 1.0 { + return (0f64, 0f64); + } + let delta_acc = self.accounts.load(Ordering::Relaxed) + .saturating_sub(self.prev_accounts.load(Ordering::Relaxed)); + let delta_bytes = self.bytes.load(Ordering::Relaxed) + .saturating_sub(self.prev_bytes.load(Ordering::Relaxed)); + (delta_acc as f64 / dt, delta_bytes as f64 / dt) + } + + /// Update state progress counters and set the last tick. + pub fn update(&self, accounts_delta: usize, bytes_delta: usize) { + *self.last_tick.write() = Instant::now(); + self.prev_accounts.store( + self.accounts.fetch_add(accounts_delta, Ordering::SeqCst), + Ordering::SeqCst + ); + self.prev_bytes.store( + self.bytes.fetch_add(bytes_delta, Ordering::SeqCst), + Ordering::SeqCst + ); + } } /// Manifest data. diff --git a/parity/run.rs b/parity/run.rs index 891424eebb2..98781943134 100644 --- a/parity/run.rs +++ b/parity/run.rs @@ -68,10 +68,10 @@ use signer; use db; use registrar::RegistrarClient; -// how often to take periodic snapshots. +// How often we attempt to take a snapshot: only snapshot on blocknumbers that are multiples of this. const SNAPSHOT_PERIOD: u64 = 5000; -// how many blocks to wait before starting a periodic snapshot. +// Start snapshots `history` blocks from the tip. Should be smaller than `SNAPSHOT_HISTORY`. const SNAPSHOT_HISTORY: u64 = 100; // Number of minutes before a given gas price corpus should expire. diff --git a/parity/snapshot_cmd.rs b/parity/snapshot_cmd.rs index bd41400a3cd..8a9157ad62c 100644 --- a/parity/snapshot_cmd.rs +++ b/parity/snapshot_cmd.rs @@ -257,18 +257,18 @@ impl SnapshotCommand { let writer = PackedWriter::new(&file_path) .map_err(|e| format!("Failed to open snapshot writer: {}", e))?; - let progress = Arc::new(Progress::default()); + let progress = Arc::new(Progress::new()); let p = progress.clone(); let informant_handle = ::std::thread::spawn(move || { ::std::thread::sleep(Duration::from_secs(5)); let mut last_size = 0; while !p.done() { - let cur_size = p.size(); + let cur_size = p.bytes(); if cur_size != last_size { last_size = cur_size; let bytes = ::informant::format_bytes(cur_size as usize); - info!("Snapshot: {} accounts {} blocks {}", p.accounts(), p.blocks(), bytes); + info!("Snapshot: {} accounts (state), {} blocks, {} bytes", p.accounts(), p.blocks(), bytes); } ::std::thread::sleep(Duration::from_secs(5)); diff --git a/util/journaldb/src/lib.rs b/util/journaldb/src/lib.rs index 0024b3638c0..739c25807a1 100644 --- a/util/journaldb/src/lib.rs +++ b/util/journaldb/src/lib.rs @@ -84,8 +84,8 @@ pub trait JournalDB: HashDB { /// Get backing database. fn backing(&self) -> &Arc; - /// Clear internal strucutres. This should called after changes have been written - /// to the backing strage + /// Clear internal structure. This should be called after changes have been written + /// to the backing storage. fn flush(&self) {} /// Consolidate all the insertions and deletions in the given memory overlay. diff --git a/util/journaldb/src/overlayrecentdb.rs b/util/journaldb/src/overlayrecentdb.rs index 0c0f92d5eb0..6ea285cd173 100644 --- a/util/journaldb/src/overlayrecentdb.rs +++ b/util/journaldb/src/overlayrecentdb.rs @@ -228,10 +228,10 @@ impl OverlayRecentDB { JournalOverlay { backing_overlay: overlay, pending_overlay: HashMap::default(), - journal: journal, - latest_era: latest_era, - earliest_era: earliest_era, - cumulative_size: cumulative_size, + journal, + latest_era, + earliest_era, + cumulative_size, } } @@ -264,7 +264,6 @@ impl JournalDB for OverlayRecentDB { fn journal_size(&self) -> usize { self.journal_overlay.read().cumulative_size - } fn is_empty(&self) -> bool { @@ -351,7 +350,7 @@ impl JournalDB for OverlayRecentDB { let mut ops = 0; // apply old commits' details - if let Some(ref mut records) = journal_overlay.journal.get_mut(&end_era) { + if let Some(records) = journal_overlay.journal.get_mut(&end_era) { let mut canon_insertions: Vec<(H256, DBValue)> = Vec::new(); let mut canon_deletions: Vec = Vec::new(); let mut overlay_deletions: Vec = Vec::new(); From c4ca84cdf3af699247a49ece581f02784b3b2190 Mon Sep 17 00:00:00 2001 From: Niklas Adolfsson Date: Fri, 25 Oct 2019 18:12:14 +0200 Subject: [PATCH 06/21] [export hardcoded sync]: use debug for `H256` (#11204) Fixes #11202 The `Display` implementation for `SpecHardcodedSync` used the `Display` implementation of `ethereum_types::H256` which doesn't show the full hash which this fixes. --- ethcore/spec/src/spec.rs | 2 +- parity/export_hardcoded_sync.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ethcore/spec/src/spec.rs b/ethcore/spec/src/spec.rs index 79f1bdd41b8..093e6905dbe 100644 --- a/ethcore/spec/src/spec.rs +++ b/ethcore/spec/src/spec.rs @@ -252,7 +252,7 @@ impl fmt::Display for SpecHardcodedSync { writeln!(f, "{{")?; writeln!(f, r#"header": "{:?},"#, self.header)?; writeln!(f, r#"total_difficulty": "{:?},"#, self.total_difficulty)?; - writeln!(f, r#"chts": {:#?}"#, self.chts.iter().map(|x| format!(r#"{}"#, x)).collect::>())?; + writeln!(f, r#"chts": {:#?}"#, self.chts.iter().map(|x| format!(r#"{:?}"#, x)).collect::>())?; writeln!(f, "}}") } } diff --git a/parity/export_hardcoded_sync.rs b/parity/export_hardcoded_sync.rs index ba01965c062..3d914f8537a 100644 --- a/parity/export_hardcoded_sync.rs +++ b/parity/export_hardcoded_sync.rs @@ -96,7 +96,7 @@ pub fn execute(cmd: ExportHsyncCmd) -> Result { let hs = service.client().read_hardcoded_sync() .map_err(|e| format!("Error reading hardcoded sync: {}", e))?; if let Some(hs) = hs { - Ok(format!("{}", hs)) + Ok(hs.to_string()) } else { Err("Error: cannot generate hardcoded sync because the database is empty.".into()) } From 2c97bcc1a4f61415cc26a076fa1054b2be64de17 Mon Sep 17 00:00:00 2001 From: David Date: Sat, 26 Oct 2019 11:26:04 +0200 Subject: [PATCH 07/21] Upgrade jsonrpc to latest (#11206) --- Cargo.lock | 80 ++++++++++++++++---------------- Cargo.toml | 2 +- cli-signer/rpc-client/Cargo.toml | 4 +- ipfs/Cargo.toml | 4 +- miner/stratum/Cargo.toml | 4 +- rpc/Cargo.toml | 12 ++--- secret-store/Cargo.toml | 2 +- 7 files changed, 54 insertions(+), 54 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 79e018c7e80..823091e8b15 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1445,7 +1445,7 @@ dependencies = [ "ethkey 0.4.0", "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", "hyper 0.12.19 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-server-utils 14.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-server-utils 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "keccak-hash 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "kvdb 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "kvdb-rocksdb 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1498,8 +1498,8 @@ version = "1.12.0" dependencies = [ "env_logger 0.5.13 (registry+https://github.com/rust-lang/crates.io-index)", "ethereum-types 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-core 14.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-tcp-server 14.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-core 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-tcp-server 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "keccak-hash 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2276,7 +2276,7 @@ dependencies = [ [[package]] name = "jsonrpc-core" -version = "14.0.1" +version = "14.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2288,7 +2288,7 @@ dependencies = [ [[package]] name = "jsonrpc-derive" -version = "14.0.1" +version = "14.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro-crate 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2299,12 +2299,12 @@ dependencies = [ [[package]] name = "jsonrpc-http-server" -version = "14.0.1" +version = "14.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "hyper 0.12.19 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-core 14.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-server-utils 14.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-core 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-server-utils 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2313,11 +2313,11 @@ dependencies = [ [[package]] name = "jsonrpc-ipc-server" -version = "14.0.1" +version = "14.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "jsonrpc-core 14.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-server-utils 14.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-core 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-server-utils 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-tokio-ipc 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2326,10 +2326,10 @@ dependencies = [ [[package]] name = "jsonrpc-pubsub" -version = "14.0.1" +version = "14.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "jsonrpc-core 14.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-core 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.99 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2337,12 +2337,12 @@ dependencies = [ [[package]] name = "jsonrpc-server-utils" -version = "14.0.1" +version = "14.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "globset 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-core 14.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-core 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "tokio 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2352,11 +2352,11 @@ dependencies = [ [[package]] name = "jsonrpc-tcp-server" -version = "14.0.1" +version = "14.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "jsonrpc-core 14.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-server-utils 14.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-core 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-server-utils 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-service 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2364,11 +2364,11 @@ dependencies = [ [[package]] name = "jsonrpc-ws-server" -version = "14.0.1" +version = "14.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "jsonrpc-core 14.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-server-utils 14.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-core 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-server-utils 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "slab 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3024,7 +3024,7 @@ dependencies = [ "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", "ipnetwork 0.12.8 (registry+https://github.com/rust-lang/crates.io-index)", "journaldb 0.2.0", - "jsonrpc-core 14.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-core 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "keccak-hash 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "kvdb 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "kvdb-rocksdb 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3102,8 +3102,8 @@ dependencies = [ "common-types 0.1.0", "ethcore 1.12.0", "ethereum-types 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-core 14.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-http-server 14.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-core 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-http-server 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "multihash 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-bytes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "rlp 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3183,12 +3183,12 @@ dependencies = [ "fetch 0.1.0", "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", "itertools 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-core 14.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-derive 14.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-http-server 14.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-ipc-server 14.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-pubsub 14.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-ws-server 14.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-core 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-derive 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-http-server 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-ipc-server 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-pubsub 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-ws-server 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "keccak-hash 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "machine 0.1.0", @@ -3229,8 +3229,8 @@ version = "1.4.0" dependencies = [ "ethereum-types 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-core 14.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-ws-server 14.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-core 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-ws-server 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "keccak-hash 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5523,14 +5523,14 @@ dependencies = [ "checksum jemallocator 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "9f0cd42ac65f758063fea55126b0148b1ce0a6354ff78e07a4d6806bc65c4ab3" "checksum jni 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "294eca097d1dc0bf59de5ab9f7eafa5f77129e9f6464c957ed3ddeb705fb4292" "checksum jni-sys 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8eaf4bc02d17cbdd7ff4c7438cafcdf7fb9a4613313ad11b4f8fefe7d3fa0130" -"checksum jsonrpc-core 14.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9b392c9e8e43a12e6b21160903f473b1066e57fe18477394a93a1efd25654003" -"checksum jsonrpc-derive 14.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f79f30bf70049564c507b968162b8fd4bf114514bdacc1e90f9d891f8a66fce3" -"checksum jsonrpc-http-server 14.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dd3d54c822dc67707f21b15f13995b24eb090501c8ad67782b5484c9be36255b" -"checksum jsonrpc-ipc-server 14.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "bed0288dfe341a68a5a54d824db5db0cbb9acb8f642cc5e1ac3e58239f24baed" -"checksum jsonrpc-pubsub 14.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dbe9faf8ba7ea28c58937cfbca538db1af11a9e72eae1aa8e6a83926b6b4dc46" -"checksum jsonrpc-server-utils 14.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "629792d44acc93f39800cd4c6524d7f33b30d66f24d3a9374af7ecbe71a4f8bf" -"checksum jsonrpc-tcp-server 14.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2ad0831b17761fa226e54d36284977cab07a29153242e41f67b7fdb2bfd147d5" -"checksum jsonrpc-ws-server 14.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "338664631e75cf752468a0d8ec3ba82df4caaacd942b4c34ea67db2556308e20" +"checksum jsonrpc-core 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "34651edf3417637cc45e70ed0182ecfa9ced0b7e8131805fccf7400d989845ca" +"checksum jsonrpc-derive 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "d5d5c31575cc70a8b21542599028472c80a9248394aeea4d8918a045a0ab08a3" +"checksum jsonrpc-http-server 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "aa54c4c2d88cb5e04b251a5031ba0f2ee8c6ef30970e31228955b89a80c3b611" +"checksum jsonrpc-ipc-server 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b579cd0840d7db3ebaadf52f6f31ec601a260e78d610e44f68634f919e34497a" +"checksum jsonrpc-pubsub 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3ee1b8da0b9219a231c4b7cbc7110bfdb457cbcd8d90a6224d0b3cab8aae8443" +"checksum jsonrpc-server-utils 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "87bc3c0a9a282211b2ec14abb3e977de33016bbec495332e9f7be858de7c5117" +"checksum jsonrpc-tcp-server 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "9c7807563cd721401285b59b54358f5b2325b4de6ff6f1de5494a5879e890fc1" +"checksum jsonrpc-ws-server 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "af36a129cef77a9db8028ac7552d927e1bb7b6928cd96b23dd25cc38bff974ab" "checksum keccak-hash 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e563fa6fe52b2686094846118bf2cb2e6f75e6b8cec6c3aba09be8e835c7f998" "checksum keccak-hasher 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3bf18164fd7ce989041f8fc4a1ae72a8bd1bec3575f2aeaf1d4968fc053aabef" "checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" diff --git a/Cargo.toml b/Cargo.toml index 7783237f054..c81f5acb356 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -37,7 +37,7 @@ ethstore = { path = "accounts/ethstore" } fdlimit = "0.1" futures = "0.1" journaldb = { path = "util/journaldb" } -jsonrpc-core = "14.0.1" +jsonrpc-core = "14.0.3" keccak-hash = "0.4.0" kvdb = "0.1" kvdb-rocksdb = "0.1.5" diff --git a/cli-signer/rpc-client/Cargo.toml b/cli-signer/rpc-client/Cargo.toml index 224ba3bcb6c..c8c568fc199 100644 --- a/cli-signer/rpc-client/Cargo.toml +++ b/cli-signer/rpc-client/Cargo.toml @@ -15,7 +15,7 @@ serde_json = "1.0" url = "2.1.0" matches = "0.1" parking_lot = "0.9" -jsonrpc-core = "14.0.1" -jsonrpc-ws-server = "14.0.1" +jsonrpc-core = "14.0.3" +jsonrpc-ws-server = "14.0.3" parity-rpc = { path = "../../rpc" } keccak-hash = "0.4.0" diff --git a/ipfs/Cargo.toml b/ipfs/Cargo.toml index 79ad7e26c93..adb42f9e5a0 100644 --- a/ipfs/Cargo.toml +++ b/ipfs/Cargo.toml @@ -12,8 +12,8 @@ common-types = { path = "../ethcore/types" } ethcore = { path = "../ethcore" } bytes = { package = "parity-bytes", version = "0.1"} ethereum-types = "0.8.0" -jsonrpc-core = "14.0.1" -http = { package = "jsonrpc-http-server", version = "14.0.1"} +jsonrpc-core = "14.0.3" +http = { package = "jsonrpc-http-server", version = "14.0.3"} rlp = "0.4.0" cid = "0.3" multihash = "0.8" diff --git a/miner/stratum/Cargo.toml b/miner/stratum/Cargo.toml index 9fbb54f937d..971dd440049 100644 --- a/miner/stratum/Cargo.toml +++ b/miner/stratum/Cargo.toml @@ -8,8 +8,8 @@ authors = ["Parity Technologies "] [dependencies] ethereum-types = "0.8.0" keccak-hash = "0.4.0" -jsonrpc-core = "14.0.1" -jsonrpc-tcp-server = "14.0.1" +jsonrpc-core = "14.0.3" +jsonrpc-tcp-server = "14.0.3" log = "0.4" parking_lot = "0.9" diff --git a/rpc/Cargo.toml b/rpc/Cargo.toml index 3e927f699b0..3b8abd49484 100644 --- a/rpc/Cargo.toml +++ b/rpc/Cargo.toml @@ -28,12 +28,12 @@ tokio-timer = "0.1" transient-hashmap = "0.4" itertools = "0.5" -jsonrpc-core = "14.0.1" -jsonrpc-derive = "14.0.1" -jsonrpc-http-server = "14.0.1" -jsonrpc-ws-server = "14.0.1" -jsonrpc-ipc-server = "14.0.1" -jsonrpc-pubsub = "14.0.1" +jsonrpc-core = "14.0.3" +jsonrpc-derive = "14.0.3" +jsonrpc-http-server = "14.0.3" +jsonrpc-ws-server = "14.0.3" +jsonrpc-ipc-server = "14.0.3" +jsonrpc-pubsub = "14.0.3" client-traits = { path = "../ethcore/client-traits" } common-types = { path = "../ethcore/types" } diff --git a/secret-store/Cargo.toml b/secret-store/Cargo.toml index 24af2a798f6..37a8e1a5fae 100644 --- a/secret-store/Cargo.toml +++ b/secret-store/Cargo.toml @@ -38,7 +38,7 @@ tokio = "0.1.22" tokio-io = "0.1" tokio-service = "0.1" url = "2.1.0" -jsonrpc-server-utils = "14.0.1" +jsonrpc-server-utils = "14.0.3" [dev-dependencies] env_logger = "0.5" From e0e79fdee0834109923afdf9f309330cf5eac1c1 Mon Sep 17 00:00:00 2001 From: Vladimir Komendantskiy Date: Mon, 28 Oct 2019 13:39:18 +0000 Subject: [PATCH 08/21] Step duration map configuration parameter ported from the POA Network fork (#10902) * step duration map configuration parameter ported from POA Network fork * step duration map refactoring * added a test of step duration change * refactoring of vector search; return Err instead of panicking * removed dead code and the Config engine error variant * doc correction * converted triples to struct StepDurationInfo --- ethcore/engines/authority-round/src/lib.rs | 278 ++++++++++++++++----- json/src/spec/authority_round.rs | 8 +- json/src/spec/mod.rs | 2 + json/src/spec/step_duration.rs | 36 +++ 4 files changed, 253 insertions(+), 71 deletions(-) create mode 100644 json/src/spec/step_duration.rs diff --git a/ethcore/engines/authority-round/src/lib.rs b/ethcore/engines/authority-round/src/lib.rs index fd3585fc72c..54980e4f48e 100644 --- a/ethcore/engines/authority-round/src/lib.rs +++ b/ethcore/engines/authority-round/src/lib.rs @@ -33,11 +33,12 @@ use std::collections::{BTreeMap, BTreeSet, HashSet}; use std::{cmp, fmt}; -use std::iter::FromIterator; +use std::iter::{self, FromIterator}; use std::ops::Deref; -use std::sync::atomic::{AtomicUsize, AtomicBool, Ordering as AtomicOrdering}; +use std::sync::atomic::{AtomicU64, AtomicBool, Ordering as AtomicOrdering}; use std::sync::{Weak, Arc}; use std::time::{UNIX_EPOCH, Duration}; +use std::u64; use client_traits::EngineClient; use engine::{Engine, ConstructedVerifier}; @@ -83,12 +84,13 @@ use self::finality::RollingFinality; /// `AuthorityRound` params. pub struct AuthorityRoundParams { - /// Time to wait before next block or authority switching, - /// in seconds. + /// A map defining intervals of blocks with the given times (in seconds) to wait before next + /// block or authority switching. The keys in the map are steps of starting blocks of those + /// periods. The entry at `0` should be defined. /// - /// Deliberately typed as u16 as too high of a value leads - /// to slow block issuance. - pub step_duration: u16, + /// Wait times (durations) are additionally required to be less than 65535 since larger values + /// lead to slow block issuance. + pub step_durations: BTreeMap, /// Starting step, pub start_step: Option, /// Valid validators. @@ -121,11 +123,27 @@ const U16_MAX: usize = ::std::u16::MAX as usize; impl From for AuthorityRoundParams { fn from(p: ethjson::spec::AuthorityRoundParams) -> Self { - let mut step_duration_usize: usize = p.step_duration.into(); - if step_duration_usize > U16_MAX { - step_duration_usize = U16_MAX; - warn!(target: "engine", "step_duration is too high ({}), setting it to {}", step_duration_usize, U16_MAX); - } + let map_step_duration = |u: ethjson::uint::Uint| { + let mut step_duration_usize: usize = u.into(); + if step_duration_usize == 0 { + panic!("AuthorityRoundParams: step duration cannot be 0"); + } + if step_duration_usize > U16_MAX { + warn!(target: "engine", "step duration is too high ({}), setting it to {}", step_duration_usize, U16_MAX); + step_duration_usize = U16_MAX; + } + step_duration_usize as u64 + }; + let step_durations: BTreeMap<_, _> = match p.step_duration { + ethjson::spec::StepDuration::Single(u) => + iter::once((0, map_step_duration(u))).collect(), + ethjson::spec::StepDuration::Transitions(tr) => { + if tr.is_empty() { + panic!("AuthorityRoundParams: step duration transitions cannot be empty"); + } + tr.into_iter().map(|(timestamp, u)| (timestamp.into(), map_step_duration(u))).collect() + } + }; let transition_block_num = p.block_reward_contract_transition.map_or(0, Into::into); let mut br_transitions: BTreeMap<_, _> = p.block_reward_contract_transitions .unwrap_or_default() @@ -151,7 +169,7 @@ impl From for AuthorityRoundParams { ); } AuthorityRoundParams { - step_duration: step_duration_usize as u16, + step_durations, validators: new_validator_set(p.validators), start_step: p.start_step.map(Into::into), validate_score_transition: p.validate_score_transition.map_or(0, Into::into), @@ -169,54 +187,89 @@ impl From for AuthorityRoundParams { } } -// Helper for managing the step. +/// A triple containing the first step number and the starting timestamp of the given step duration. +#[derive(Clone, Debug)] +struct StepDurationInfo { + transition_step: u64, + transition_timestamp: u64, + step_duration: u64, +} + +/// Helper for managing the step. #[derive(Debug)] struct Step { calibrate: bool, // whether calibration is enabled. - inner: AtomicUsize, - duration: u16, + inner: AtomicU64, + /// Planned durations of steps. + durations: Vec, } impl Step { - fn load(&self) -> u64 { self.inner.load(AtomicOrdering::SeqCst) as u64 } + fn load(&self) -> u64 { self.inner.load(AtomicOrdering::SeqCst) } + + /// Finds the remaining duration of the current step. Panics if there was a counter under- or + /// overflow. fn duration_remaining(&self) -> Duration { - let now = unix_now(); - let expected_seconds = self.load() - .checked_add(1) - .and_then(|ctr| ctr.checked_mul(self.duration as u64)) - .map(Duration::from_secs); - - match expected_seconds { - Some(step_end) if step_end > now => step_end - now, - Some(_) => Duration::from_secs(0), - None => { - let ctr = self.load(); - error!(target: "engine", "Step counter is too high: {}, aborting", ctr); - panic!("step counter is too high: {}", ctr) - }, - } + self.opt_duration_remaining().unwrap_or_else(|| { + let ctr = self.load(); + error!(target: "engine", "Step counter under- or overflow: {}, aborting", ctr); + panic!("step counter under- or overflow: {}", ctr) + }) + } + /// Finds the remaining duration of the current step. Returns `None` if there was a counter + /// under- or overflow. + fn opt_duration_remaining(&self) -> Option { + let next_step = self.load().checked_add(1)?; + let StepDurationInfo { transition_step, transition_timestamp, step_duration } = + self.durations.iter() + .take_while(|info| info.transition_step < next_step) + .last() + .expect("durations cannot be empty") + .clone(); + let next_time = transition_timestamp + .checked_add(next_step.checked_sub(transition_step)?.checked_mul(step_duration)?)?; + Some(Duration::from_secs(next_time.saturating_sub(unix_now().as_secs()))) } + /// Increments the step number. + /// + /// Panics if the new step number is `u64::MAX`. fn increment(&self) { - use std::usize; // fetch_add won't panic on overflow but will rather wrap // around, leading to zero as the step counter, which might // lead to unexpected situations, so it's better to shut down. - if self.inner.fetch_add(1, AtomicOrdering::SeqCst) == usize::MAX { - error!(target: "engine", "Step counter is too high: {}, aborting", usize::MAX); - panic!("step counter is too high: {}", usize::MAX); + if self.inner.fetch_add(1, AtomicOrdering::SeqCst) == u64::MAX { + error!(target: "engine", "Step counter is too high: {}, aborting", u64::MAX); + panic!("step counter is too high: {}", u64::MAX); } - } fn calibrate(&self) { if self.calibrate { - let new_step = unix_now().as_secs() / (self.duration as u64); - self.inner.store(new_step as usize, AtomicOrdering::SeqCst); + if self.opt_calibrate().is_none() { + let ctr = self.load(); + error!(target: "engine", "Step counter under- or overflow: {}, aborting", ctr); + panic!("step counter under- or overflow: {}", ctr) + } } } + /// Calibrates the AuRa step number according to the current time. + fn opt_calibrate(&self) -> Option<()> { + let now = unix_now().as_secs(); + let StepDurationInfo { transition_step, transition_timestamp, step_duration } = + self.durations.iter() + .take_while(|info| info.transition_timestamp < now) + .last() + .expect("durations cannot be empty") + .clone(); + let new_step = (now.checked_sub(transition_timestamp)? / step_duration) + .checked_add(transition_step)?; + self.inner.store(new_step, AtomicOrdering::SeqCst); + Some(()) + } + fn check_future(&self, given: u64) -> Result<(), Option>> { const REJECTED_STEP_DRIFT: u64 = 4; @@ -234,7 +287,9 @@ impl Step { Err(None) // wait a bit for blocks in near future } else if given > current { - let d = self.duration as u64; + let d = self.durations.iter().take_while(|info| info.transition_step <= current).last() + .expect("Duration map has at least a 0 entry.") + .step_duration; Err(Some(OutOfBounds { min: None, max: Some(d * current), @@ -730,23 +785,54 @@ impl<'a, A: ?Sized, B> Deref for CowLike<'a, A, B> where B: AsRef { impl AuthorityRound { /// Create a new instance of AuthorityRound engine. pub fn new(our_params: AuthorityRoundParams, machine: Machine) -> Result, Error> { - if our_params.step_duration == 0 { - error!(target: "engine", "Authority Round step duration can't be zero, aborting"); - panic!("authority_round: step duration can't be zero") + if !our_params.step_durations.contains_key(&0) { + error!(target: "engine", "Authority Round step 0 duration is undefined, aborting"); + return Err(Error::Engine(EngineError::Custom(String::from("step 0 duration is undefined")))); + } + if our_params.step_durations.values().any(|v| *v == 0) { + error!(target: "engine", "Authority Round step duration cannot be 0"); + return Err(Error::Engine(EngineError::Custom(String::from("step duration cannot be 0")))); } let should_timeout = our_params.start_step.is_none(); - let initial_step = our_params.start_step.unwrap_or_else(|| (unix_now().as_secs() / (our_params.step_duration as u64))); + let initial_step = our_params.start_step.unwrap_or(0); + + let mut durations = Vec::new(); + let mut prev_step = 0u64; + let mut prev_time = 0u64; + let mut prev_dur = our_params.step_durations[&0]; + durations.push(StepDurationInfo { + transition_step: prev_step, + transition_timestamp: prev_time, + step_duration: prev_dur + }); + for (time, dur) in our_params.step_durations.iter().skip(1) { + let (step, time) = next_step_time_duration( + StepDurationInfo{ + transition_step: prev_step, + transition_timestamp: prev_time, + step_duration: prev_dur, + }, *time) + .ok_or(BlockError::TimestampOverflow)?; + durations.push(StepDurationInfo { + transition_step: step, + transition_timestamp: time, + step_duration: *dur + }); + prev_step = step; + prev_time = time; + prev_dur = *dur; + } + + let step = Step { + inner: AtomicU64::new(initial_step), + calibrate: our_params.start_step.is_none(), + durations, + }; + step.calibrate(); let engine = Arc::new( AuthorityRound { transition_service: IoService::<()>::start()?, - step: Arc::new(PermissionedStep { - inner: Step { - inner: AtomicUsize::new(initial_step as usize), - calibrate: our_params.start_step.is_none(), - duration: our_params.step_duration, - }, - can_propose: AtomicBool::new(true), - }), + step: Arc::new(PermissionedStep { inner: step, can_propose: AtomicBool::new(true) }), client: Arc::new(RwLock::new(None)), signer: RwLock::new(None), validators: our_params.validators, @@ -994,8 +1080,10 @@ impl IoHandler<()> for TransitionHandler { } } - let next_run_at = AsMillis::as_millis(&self.step.inner.duration_remaining()) >> 2; - io.register_timer_once(ENGINE_TIMEOUT_TOKEN, Duration::from_millis(next_run_at)) + let next_run_at = Duration::from_millis( + AsMillis::as_millis(&self.step.inner.duration_remaining()) >> 2 + ); + io.register_timer_once(ENGINE_TIMEOUT_TOKEN, next_run_at) .unwrap_or_else(|e| warn!(target: "engine", "Failed to restart consensus step timer: {}.", e)) } } @@ -1694,12 +1782,27 @@ impl Engine for AuthorityRound { } } +/// A helper accumulator function mapping a step duration and a step duration transition timestamp +/// to the corresponding step number and the correct starting second of the step. +fn next_step_time_duration(info: StepDurationInfo, time: u64) -> Option<(u64, u64)> +{ + let step_diff = time.checked_add(info.step_duration)? + .checked_sub(1)? + .checked_sub(info.transition_timestamp)? + .checked_div(info.step_duration)?; + Some(( + info.transition_step.checked_add(step_diff)?, + step_diff.checked_mul(info.step_duration)?.checked_add(time)?, + )) +} + #[cfg(test)] mod tests { use std::collections::BTreeMap; use std::str::FromStr; use std::sync::Arc; - use std::sync::atomic::{AtomicUsize, Ordering as AtomicOrdering}; + use std::sync::atomic::{AtomicUsize, AtomicU64, Ordering as AtomicOrdering}; + use std::time::Duration; use keccak_hash::keccak; use accounts::AccountProvider; use ethereum_types::{Address, H520, H256, U256}; @@ -1726,13 +1829,16 @@ mod tests { use ethjson; use serde_json; - use super::{AuthorityRoundParams, AuthorityRound, EmptyStep, SealedEmptyStep, calculate_score}; + use super::{ + AuthorityRoundParams, AuthorityRound, EmptyStep, SealedEmptyStep, StepDurationInfo, + calculate_score, + }; fn build_aura(f: F) -> Arc where F: FnOnce(&mut AuthorityRoundParams), { let mut params = AuthorityRoundParams { - step_duration: 1, + step_durations: [(0, 1)].to_vec().into_iter().collect(), start_step: Some(1), validators: Box::new(TestSet::default()), validate_score_transition: 0, @@ -2061,29 +2167,67 @@ mod tests { use super::Step; let step = Step { calibrate: false, - inner: AtomicUsize::new(::std::usize::MAX), - duration: 1, + inner: AtomicU64::new(::std::u64::MAX), + durations: [StepDurationInfo { + transition_step: 0, + transition_timestamp: 0, + step_duration: 1, + }].to_vec().into_iter().collect(), }; step.increment(); } #[test] - #[should_panic(expected="counter is too high")] + #[should_panic(expected="step counter under- or overflow")] fn test_counter_duration_remaining_too_high() { use super::Step; let step = Step { calibrate: false, - inner: AtomicUsize::new(::std::usize::MAX), - duration: 1, + inner: AtomicU64::new(::std::u64::MAX), + durations: [StepDurationInfo { + transition_step: 0, + transition_timestamp: 0, + step_duration: 1, + }].to_vec().into_iter().collect(), }; step.duration_remaining(); } #[test] - #[should_panic(expected="authority_round: step duration can't be zero")] + fn test_change_step_duration() { + use super::Step; + use std::thread; + + let now = super::unix_now().as_secs(); + let step = Step { + calibrate: true, + inner: AtomicU64::new(::std::u64::MAX), + durations: [ + StepDurationInfo { transition_step: 0, transition_timestamp: 0, step_duration: 1 }, + StepDurationInfo { transition_step: now, transition_timestamp: now, step_duration: 2 }, + StepDurationInfo { transition_step: now + 1, transition_timestamp: now + 2, step_duration: 4 }, + ].to_vec().into_iter().collect(), + }; + // calibrated step `now` + step.calibrate(); + let duration_remaining = step.duration_remaining(); + assert_eq!(step.inner.load(AtomicOrdering::SeqCst), now); + assert!(duration_remaining <= Duration::from_secs(2)); + thread::sleep(duration_remaining); + step.increment(); + // calibrated step `now + 1` + step.calibrate(); + let duration_remaining = step.duration_remaining(); + assert_eq!(step.inner.load(AtomicOrdering::SeqCst), now + 1); + assert!(duration_remaining > Duration::from_secs(2)); + assert!(duration_remaining <= Duration::from_secs(4)); + } + + #[test] + #[should_panic(expected="called `Result::unwrap()` on an `Err` value: Engine(Custom(\"step duration cannot be 0\"))")] fn test_step_duration_zero() { build_aura(|params| { - params.step_duration = 0; + params.step_durations = [(0, 0)].to_vec().into_iter().collect(); }); } @@ -2473,7 +2617,7 @@ mod tests { #[test] fn test_empty_steps() { let engine = build_aura(|p| { - p.step_duration = 4; + p.step_durations = [(0, 4)].to_vec().into_iter().collect(); p.empty_steps_transition = 0; p.maximum_empty_steps = 0; }); @@ -2507,7 +2651,7 @@ mod tests { let (_spec, tap, accounts) = setup_empty_steps(); let engine = build_aura(|p| { p.validators = Box::new(SimpleList::new(accounts.clone())); - p.step_duration = 4; + p.step_durations = [(0, 4)].to_vec().into_iter().collect(); p.empty_steps_transition = 0; p.maximum_empty_steps = 0; }); @@ -2544,7 +2688,7 @@ mod tests { let (_spec, tap, accounts) = setup_empty_steps(); let engine = build_aura(|p| { p.validators = Box::new(SimpleList::new(accounts.clone())); - p.step_duration = 4; + p.step_durations = [(0, 4)].to_vec().into_iter().collect(); p.empty_steps_transition = 0; p.maximum_empty_steps = 0; }); diff --git a/json/src/spec/authority_round.rs b/json/src/spec/authority_round.rs index 0a31203f62f..ba5ad63b39b 100644 --- a/json/src/spec/authority_round.rs +++ b/json/src/spec/authority_round.rs @@ -41,7 +41,7 @@ use std::collections::BTreeMap; use crate::{bytes::Bytes, hash::Address, uint::Uint}; use serde::Deserialize; -use super::ValidatorSet; +use super::{StepDuration, ValidatorSet}; /// Authority params deserialization. #[derive(Debug, PartialEq, Deserialize)] @@ -49,7 +49,7 @@ use super::ValidatorSet; #[serde(rename_all = "camelCase")] pub struct AuthorityRoundParams { /// Block duration, in seconds. - pub step_duration: Uint, + pub step_duration: StepDuration, /// Valid authorities pub validators: ValidatorSet, /// Starting step. Determined automatically if not specified. @@ -107,7 +107,7 @@ pub struct AuthorityRound { #[cfg(test)] mod tests { - use super::{Address, Uint}; + use super::{Address, Uint, StepDuration}; use ethereum_types::{U256, H160}; use crate::spec::{validator_set::ValidatorSet, authority_round::AuthorityRound}; use std::str::FromStr; @@ -129,7 +129,7 @@ mod tests { }"#; let deserialized: AuthorityRound = serde_json::from_str(s).unwrap(); - assert_eq!(deserialized.params.step_duration, Uint(U256::from(0x02))); + assert_eq!(deserialized.params.step_duration, StepDuration::Single(Uint(U256::from(2)))); assert_eq!( deserialized.params.validators, ValidatorSet::List(vec![Address(H160::from_str("c6d9d2cd449a754c494264e1809c50e34d64562b").unwrap())]), diff --git a/json/src/spec/mod.rs b/json/src/spec/mod.rs index e2569c28685..75b8014559c 100644 --- a/json/src/spec/mod.rs +++ b/json/src/spec/mod.rs @@ -32,6 +32,7 @@ pub mod null_engine; pub mod instant_seal; pub mod hardcoded_sync; pub mod clique; +pub mod step_duration; pub use self::account::Account; pub use self::builtin::{Builtin, Pricing, Linear}; @@ -49,3 +50,4 @@ pub use self::clique::{Clique, CliqueParams}; pub use self::null_engine::{NullEngine, NullEngineParams}; pub use self::instant_seal::{InstantSeal, InstantSealParams}; pub use self::hardcoded_sync::HardcodedSync; +pub use self::step_duration::StepDuration; diff --git a/json/src/spec/step_duration.rs b/json/src/spec/step_duration.rs new file mode 100644 index 00000000000..628e2dd7d23 --- /dev/null +++ b/json/src/spec/step_duration.rs @@ -0,0 +1,36 @@ +// Copyright 2015-2019 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 . + +//! Step duration configuration parameter + +use std::collections::BTreeMap; + +use serde::Deserialize; + +use crate::uint::Uint; + +/// Step duration can be specified either as a `Uint` (in seconds), in which case it will be +/// constant, or as a list of pairs consisting of a timestamp of type `Uint` and a duration, in +/// which case the duration of a step will be determined by a mapping arising from that list. +#[derive(Debug, PartialEq, Deserialize)] +#[serde(deny_unknown_fields)] +#[serde(untagged)] +pub enum StepDuration { + /// Duration of all steps. + Single(Uint), + /// Step duration transitions: a mapping of timestamp to step durations. + Transitions(BTreeMap), +} From 293e06e0f43af03da4006e8da1ec06c1ca8bae71 Mon Sep 17 00:00:00 2001 From: Niklas Adolfsson Date: Mon, 28 Oct 2019 15:03:28 +0100 Subject: [PATCH 09/21] [informant]: `MillisecondDuration` -> `as_millis()` (#11211) * [informant]: `MillisecondDuration` -> `as_millis()` This commit removes the trait `MillisecondDuration` and replaces it with `Duration::as_millis` instead * [grumble]: extract `elapsed()` to variable --- parity/blockchain.rs | 20 ++++++++++---------- parity/informant.rs | 30 ++++++++---------------------- 2 files changed, 18 insertions(+), 32 deletions(-) diff --git a/parity/blockchain.rs b/parity/blockchain.rs index 008da39ef38..a3fa2239524 100644 --- a/parity/blockchain.rs +++ b/parity/blockchain.rs @@ -33,7 +33,7 @@ use ethcore::{ }; use ethcore_service::ClientService; use cache::CacheConfig; -use informant::{Informant, FullNodeInformantData, MillisecondDuration}; +use informant::{Informant, FullNodeInformantData}; use params::{SpecType, Pruning, Switch, tracing_switch_to_bool, fatdb_switch_to_bool}; use helpers::{to_client_config, execute_upgrades}; use dir::Directories; @@ -294,13 +294,13 @@ fn execute_import_light(cmd: ImportBlockchain) -> Result<(), String> { } client.flush_queue(); - let ms = timer.elapsed().as_milliseconds(); + let elapsed = timer.elapsed(); let report = client.report(); info!("Import completed in {} seconds, {} headers, {} hdr/s", - ms / 1000, + elapsed.as_secs(), report.blocks_imported, - (report.blocks_imported * 1000) as u64 / ms, + (report.blocks_imported as u128 * 1000) / elapsed.as_millis(), ); Ok(()) @@ -415,16 +415,16 @@ fn execute_import(cmd: ImportBlockchain) -> Result<(), String> { user_defaults.save(&user_defaults_path)?; let report = client.report(); - - let ms = timer.elapsed().as_milliseconds(); + let elapsed = timer.elapsed(); + let ms = timer.elapsed().as_millis(); info!("Import completed in {} seconds, {} blocks, {} blk/s, {} transactions, {} tx/s, {} Mgas, {} Mgas/s", - ms / 1000, + elapsed.as_secs(), report.blocks_imported, - (report.blocks_imported * 1000) as u64 / ms, + (report.blocks_imported as u128 * 1000) / ms, report.transactions_applied, - (report.transactions_applied * 1000) as u64 / ms, + (report.transactions_applied as u128 * 1000) / ms, report.gas_processed / 1_000_000, - (report.gas_processed / (ms * 1000)).low_u64(), + report.gas_processed / (ms * 1000), ); Ok(()) } diff --git a/parity/informant.rs b/parity/informant.rs index 38f02d45859..b53ffe14eff 100644 --- a/parity/informant.rs +++ b/parity/informant.rs @@ -14,14 +14,12 @@ // You should have received a copy of the GNU General Public License // along with Parity Ethereum. If not, see . -extern crate ansi_term; -use self::ansi_term::Colour::{White, Yellow, Green, Cyan, Blue}; -use self::ansi_term::{Colour, Style}; - -use std::sync::{Arc}; +use std::sync::Arc; use std::sync::atomic::{AtomicUsize, AtomicBool, Ordering as AtomicOrdering}; use std::time::{Instant, Duration}; +use ansi_term::Colour::{White, Yellow, Green, Cyan, Blue}; +use ansi_term::{Colour, Style}; use atty; use ethcore::client::Client; use client_traits::{BlockInfo, ChainInfo, BlockChainClient, ChainNotify}; @@ -55,18 +53,6 @@ pub fn format_bytes(b: usize) -> String { } } -/// Something that can be converted to milliseconds. -pub trait MillisecondDuration { - /// Get the value in milliseconds. - fn as_milliseconds(&self) -> u64; -} - -impl MillisecondDuration for Duration { - fn as_milliseconds(&self) -> u64 { - self.as_secs() * 1000 + self.subsec_nanos() as u64 / 1_000_000 - } -} - #[derive(Default)] struct CacheSizes { sizes: ::std::collections::BTreeMap<&'static str, usize>, @@ -308,13 +294,13 @@ impl Informant { paint(White.bold(), format!("{}", chain_info.best_block_hash)), if self.target.executes_transactions() { format!("{} blk/s {} tx/s {} Mgas/s", - paint(Yellow.bold(), format!("{:7.2}", (client_report.blocks_imported * 1000) as f64 / elapsed.as_milliseconds() as f64)), - paint(Yellow.bold(), format!("{:6.1}", (client_report.transactions_applied * 1000) as f64 / elapsed.as_milliseconds() as f64)), - paint(Yellow.bold(), format!("{:6.1}", (client_report.gas_processed / 1000).low_u64() as f64 / elapsed.as_milliseconds() as f64)) + paint(Yellow.bold(), format!("{:7.2}", (client_report.blocks_imported * 1000) as f64 / elapsed.as_millis() as f64)), + paint(Yellow.bold(), format!("{:6.1}", (client_report.transactions_applied * 1000) as f64 / elapsed.as_millis() as f64)), + paint(Yellow.bold(), format!("{:6.1}", (client_report.gas_processed / 1000).low_u64() as f64 / elapsed.as_millis() as f64)) ) } else { format!("{} hdr/s", - paint(Yellow.bold(), format!("{:6.1}", (client_report.blocks_imported * 1000) as f64 / elapsed.as_milliseconds() as f64)) + paint(Yellow.bold(), format!("{:6.1}", (client_report.blocks_imported * 1000) as f64 / elapsed.as_millis() as f64)) ) }, paint(Green.bold(), format!("{:5}", queue_info.unverified_queue_size)), @@ -401,7 +387,7 @@ impl ChainNotify for Informant { Colour::White.bold().paint(format!("{}", header_view.hash())), Colour::Yellow.bold().paint(format!("{}", block.transactions_count())), Colour::Yellow.bold().paint(format!("{:.2}", header_view.gas_used().low_u64() as f32 / 1000000f32)), - Colour::Purple.bold().paint(format!("{}", new_blocks.duration.as_milliseconds())), + Colour::Purple.bold().paint(format!("{}", new_blocks.duration.as_millis())), Colour::Blue.bold().paint(format!("{:.2}", size as f32 / 1024f32)), if skipped > 0 { format!(" + another {} block(s) containing {} tx(s)", From 0d3423cbe0b70964aa33d2c71685e663adae0315 Mon Sep 17 00:00:00 2001 From: David Date: Mon, 28 Oct 2019 18:24:45 +0100 Subject: [PATCH 10/21] Use a lock instead of atomics for snapshot Progress (#11197) * WIP. Typos and logging. * Format todos * Pause pruning while a snapshot is under way Logs, docs and todos * Allocate memory for the full chunk * Name snapshotting threads * Ensure `taking_snapshot` is set to false whenever and however `take_snapshot`returns Rename `take_at` to `request_snapshot_at` Cleanup * Let "in_progress" deletion fail Fix tests * Just use an atomic * Review grumbles * Finish the sentence * Resolve a few todos and clarify comments. * Calculate progress rate since last update * Lockfile * Fix tests * typo * Reinstate default snapshotting frequency Cut down on the logging noise * Use a lock instead of atomics for snapshot Progress * Update ethcore/types/src/snapshot.rs Co-Authored-By: Andronik Ordian * Avoid truncating cast Cleanup --- Cargo.lock | 1 - .../snapshot/snapshot-tests/src/account.rs | 13 +-- .../snapshot/snapshot-tests/src/helpers.rs | 3 +- .../snapshot-tests/src/proof_of_work.rs | 4 +- .../snapshot/snapshot-tests/src/service.rs | 6 +- ethcore/snapshot/snapshot-tests/src/state.rs | 20 +++-- ethcore/snapshot/src/account.rs | 6 +- ethcore/snapshot/src/consensus/authority.rs | 3 +- ethcore/snapshot/src/consensus/work.rs | 7 +- ethcore/snapshot/src/lib.rs | 18 ++--- ethcore/snapshot/src/service.rs | 12 +-- ethcore/snapshot/src/traits.rs | 5 +- ethcore/src/client/client.rs | 2 +- ethcore/types/Cargo.toml | 1 - ethcore/types/src/lib.rs | 1 - ethcore/types/src/snapshot.rs | 81 +++++++------------ parity/informant.rs | 7 +- parity/snapshot_cmd.rs | 26 +++--- 18 files changed, 105 insertions(+), 111 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 823091e8b15..4305a617cc5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -606,7 +606,6 @@ dependencies = [ "parity-crypto 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "parity-snappy 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-util-mem 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "patricia-trie-ethereum 0.1.0", "rlp 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "rlp_derive 0.1.0", diff --git a/ethcore/snapshot/snapshot-tests/src/account.rs b/ethcore/snapshot/snapshot-tests/src/account.rs index fd1e5941bfa..7e3b10a8eb9 100644 --- a/ethcore/snapshot/snapshot-tests/src/account.rs +++ b/ethcore/snapshot/snapshot-tests/src/account.rs @@ -28,6 +28,7 @@ use ethereum_types::{H256, Address}; use hash_db::{HashDB, EMPTY_PREFIX}; use keccak_hash::{KECCAK_EMPTY, KECCAK_NULL_RLP, keccak}; use kvdb::DBValue; +use parking_lot::RwLock; use rlp::Rlp; use snapshot::test_helpers::{ACC_EMPTY, to_fat_rlps, from_fat_rlp}; @@ -48,7 +49,7 @@ fn encoding_basic() { let thin_rlp = ::rlp::encode(&account); assert_eq!(::rlp::decode::(&thin_rlp).unwrap(), account); - let p = Progress::new(); + let p = RwLock::new(Progress::new()); let fat_rlps = to_fat_rlps(&keccak(&addr), &account, &AccountDB::from_hash(db.as_hash_db(), keccak(addr)), &mut Default::default(), usize::max_value(), usize::max_value(), &p).unwrap(); let fat_rlp = Rlp::new(&fat_rlps[0]).at(1).unwrap(); assert_eq!(from_fat_rlp(&mut AccountDBMut::from_hash(db.as_hash_db_mut(), keccak(addr)), fat_rlp, H256::zero()).unwrap().0, account); @@ -69,7 +70,7 @@ fn encoding_version() { let thin_rlp = ::rlp::encode(&account); assert_eq!(::rlp::decode::(&thin_rlp).unwrap(), account); - let p = Progress::new(); + let p = RwLock::new(Progress::new()); let fat_rlps = to_fat_rlps(&keccak(&addr), &account, &AccountDB::from_hash(db.as_hash_db(), keccak(addr)), &mut Default::default(), usize::max_value(), usize::max_value(), &p).unwrap(); let fat_rlp = Rlp::new(&fat_rlps[0]).at(1).unwrap(); assert_eq!(from_fat_rlp(&mut AccountDBMut::from_hash(db.as_hash_db_mut(), keccak(addr)), fat_rlp, H256::zero()).unwrap().0, account); @@ -96,7 +97,7 @@ fn encoding_storage() { let thin_rlp = ::rlp::encode(&account); assert_eq!(::rlp::decode::(&thin_rlp).unwrap(), account); - let p = Progress::new(); + let p = RwLock::new(Progress::new()); let fat_rlp = to_fat_rlps(&keccak(&addr), &account, &AccountDB::from_hash(db.as_hash_db(), keccak(addr)), &mut Default::default(), usize::max_value(), usize::max_value(), &p).unwrap(); let fat_rlp = Rlp::new(&fat_rlp[0]).at(1).unwrap(); @@ -124,7 +125,7 @@ fn encoding_storage_split() { let thin_rlp = ::rlp::encode(&account); assert_eq!(::rlp::decode::(&thin_rlp).unwrap(), account); - let p = Progress::new(); + let p = RwLock::new(Progress::new()); let fat_rlps = to_fat_rlps(&keccak(addr), &account, &AccountDB::from_hash(db.as_hash_db(), keccak(addr)), &mut Default::default(), 500, 1000, &p).unwrap(); let mut root = KECCAK_NULL_RLP; let mut restored_account = None; @@ -170,8 +171,8 @@ fn encoding_code() { }; let mut used_code = HashSet::new(); - let p1 = Progress::new(); - let p2 = Progress::new(); + let p1 = RwLock::new(Progress::new()); + let p2 = RwLock::new(Progress::new()); let fat_rlp1 = to_fat_rlps(&keccak(&addr1), &account1, &AccountDB::from_hash(db.as_hash_db(), keccak(addr1)), &mut used_code, usize::max_value(), usize::max_value(), &p1).unwrap(); let fat_rlp2 = to_fat_rlps(&keccak(&addr2), &account2, &AccountDB::from_hash(db.as_hash_db(), keccak(addr2)), &mut used_code, usize::max_value(), usize::max_value(), &p2).unwrap(); assert_eq!(used_code.len(), 1); diff --git a/ethcore/snapshot/snapshot-tests/src/helpers.rs b/ethcore/snapshot/snapshot-tests/src/helpers.rs index 0c419dd71bb..c83e14da69f 100644 --- a/ethcore/snapshot/snapshot-tests/src/helpers.rs +++ b/ethcore/snapshot/snapshot-tests/src/helpers.rs @@ -40,6 +40,7 @@ use keccak_hash::{KECCAK_NULL_RLP}; use keccak_hasher::KeccakHasher; use kvdb::DBValue; use log::trace; +use parking_lot::RwLock; use rand::Rng; use rlp; use snapshot::{ @@ -146,7 +147,7 @@ pub fn snap(client: &Client) -> (Box, TempDir) { let tempdir = TempDir::new("").unwrap(); let path = tempdir.path().join("file"); let writer = PackedWriter::new(&path).unwrap(); - let progress = Progress::new(); + let progress = RwLock::new(Progress::new()); let hash = client.chain_info().best_block_hash; client.take_snapshot(writer, BlockId::Hash(hash), &progress).unwrap(); diff --git a/ethcore/snapshot/snapshot-tests/src/proof_of_work.rs b/ethcore/snapshot/snapshot-tests/src/proof_of_work.rs index 9d01432fff3..90e6bee5755 100644 --- a/ethcore/snapshot/snapshot-tests/src/proof_of_work.rs +++ b/ethcore/snapshot/snapshot-tests/src/proof_of_work.rs @@ -31,7 +31,7 @@ use snapshot::{ io::{PackedReader, PackedWriter, SnapshotReader, SnapshotWriter}, PowSnapshot, }; -use parking_lot::Mutex; +use parking_lot::{Mutex, RwLock}; use snappy; use keccak_hash::KECCAK_NULL_RLP; use kvdb::DBTransaction; @@ -74,7 +74,7 @@ fn chunk_and_restore(amount: u64) { &bc, best_hash, &writer, - &Progress::new() + &RwLock::new(Progress::new()) ).unwrap(); let manifest = ManifestData { diff --git a/ethcore/snapshot/snapshot-tests/src/service.rs b/ethcore/snapshot/snapshot-tests/src/service.rs index ebedd5472c9..9b85f324f57 100644 --- a/ethcore/snapshot/snapshot-tests/src/service.rs +++ b/ethcore/snapshot/snapshot-tests/src/service.rs @@ -42,7 +42,7 @@ use ethcore::{ test_helpers::{new_db, new_temp_db, generate_dummy_client_with_spec_and_data, restoration_db_handler} }; -use parking_lot::Mutex; +use parking_lot::{Mutex, RwLock}; use ethcore_io::{IoChannel, IoService}; use kvdb_rocksdb::DatabaseConfig; use journaldb::Algorithm; @@ -278,7 +278,7 @@ fn keep_ancient_blocks() { &bc, best_hash, &writer, - &Progress::new() + &RwLock::new(Progress::new()) ).unwrap(); let state_db = client.state_db().journal_db().boxed_clone(); let start_header = bc.block_header_data(&best_hash).unwrap(); @@ -287,7 +287,7 @@ fn keep_ancient_blocks() { state_db.as_hash_db(), &state_root, &writer, - &Progress::new(), + &RwLock::new(Progress::new()), None, 0 ).unwrap(); diff --git a/ethcore/snapshot/snapshot-tests/src/state.rs b/ethcore/snapshot/snapshot-tests/src/state.rs index ef905796404..f53354e6930 100644 --- a/ethcore/snapshot/snapshot-tests/src/state.rs +++ b/ethcore/snapshot/snapshot-tests/src/state.rs @@ -35,7 +35,7 @@ use rand_xorshift::XorShiftRng; use ethereum_types::H256; use journaldb::{self, Algorithm}; use kvdb_rocksdb::{Database, DatabaseConfig}; -use parking_lot::Mutex; +use parking_lot::{Mutex, RwLock}; use tempdir::TempDir; use crate::helpers::StateProducer; @@ -61,8 +61,9 @@ fn snap_and_restore() { let writer = Mutex::new(PackedWriter::new(&snap_file).unwrap()); let mut state_hashes = Vec::new(); + let progress = RwLock::new(Progress::new()); for part in 0..SNAPSHOT_SUBPARTS { - let mut hashes = chunk_state(&old_db, &state_root, &writer, &Progress::new(), Some(part), 0).unwrap(); + let mut hashes = chunk_state(&old_db, &state_root, &writer, &progress, Some(part), 0).unwrap(); state_hashes.append(&mut hashes); } @@ -133,8 +134,16 @@ fn get_code_from_prev_chunk() { let mut make_chunk = |acc, hash| { let mut db = journaldb::new_memory_db(); AccountDBMut::from_hash(&mut db, hash).insert(EMPTY_PREFIX, &code[..]); - let p = Progress::new(); - let fat_rlp = to_fat_rlps(&hash, &acc, &AccountDB::from_hash(&db, hash), &mut used_code, usize::max_value(), usize::max_value(), &p).unwrap(); + let p = RwLock::new(Progress::new()); + let fat_rlp = to_fat_rlps( + &hash, + &acc, + &AccountDB::from_hash(&db, hash), + &mut used_code, + usize::max_value(), + usize::max_value(), + &p + ).unwrap(); let mut stream = RlpStream::new_list(1); stream.append_raw(&fat_rlp[0], 1); stream.out() @@ -177,8 +186,9 @@ fn checks_flag() { let state_root = producer.state_root(); let writer = Mutex::new(PackedWriter::new(&snap_file).unwrap()); + let progress = RwLock::new(Progress::new()); - let state_hashes = chunk_state(&old_db, &state_root, &writer, &Progress::new(), None, 0).unwrap(); + let state_hashes = chunk_state(&old_db, &state_root, &writer, &progress, None, 0).unwrap(); writer.into_inner().finish(ManifestData { version: 2, diff --git a/ethcore/snapshot/src/account.rs b/ethcore/snapshot/src/account.rs index da227f17657..f7d0657d0fe 100644 --- a/ethcore/snapshot/src/account.rs +++ b/ethcore/snapshot/src/account.rs @@ -17,7 +17,6 @@ //! Account state encoding and decoding use std::collections::HashSet; -use std::sync::atomic::Ordering; use account_db::{AccountDB, AccountDBMut}; use bytes::Bytes; @@ -31,6 +30,7 @@ use ethtrie::{TrieDB, TrieDBMut}; use hash_db::HashDB; use keccak_hash::{KECCAK_EMPTY, KECCAK_NULL_RLP}; use log::{trace, warn}; +use parking_lot::RwLock; use rlp::{RlpStream, Rlp}; use trie_db::{Trie, TrieMut}; @@ -79,7 +79,7 @@ pub fn to_fat_rlps( used_code: &mut HashSet, first_chunk_size: usize, max_chunk_size: usize, - p: &Progress, + p: &RwLock, ) -> Result, Error> { let db = &(acct_db as &dyn HashDB<_,_>); let db = TrieDB::new(db, &acc.storage_root)?; @@ -135,7 +135,7 @@ pub fn to_fat_rlps( } loop { - if p.abort.load(Ordering::SeqCst) { + if p.read().abort { trace!(target: "snapshot", "to_fat_rlps: aborting snapshot"); return Err(Error::SnapshotAborted); } diff --git a/ethcore/snapshot/src/consensus/authority.rs b/ethcore/snapshot/src/consensus/authority.rs index 6135ba8820f..b80d4075c06 100644 --- a/ethcore/snapshot/src/consensus/authority.rs +++ b/ethcore/snapshot/src/consensus/authority.rs @@ -38,6 +38,7 @@ use ethereum_types::{H256, U256}; use itertools::{Position, Itertools}; use kvdb::KeyValueDB; use log::trace; +use parking_lot::RwLock; use rlp::{RlpStream, Rlp}; use crate::{SnapshotComponents, Rebuilder}; @@ -62,7 +63,7 @@ impl SnapshotComponents for PoaSnapshot { chain: &BlockChain, block_at: H256, sink: &mut ChunkSink, - _progress: &Progress, + _progress: &RwLock, preferred_size: usize, ) -> Result<(), SnapshotError> { let number = chain.block_number(&block_at) diff --git a/ethcore/snapshot/src/consensus/work.rs b/ethcore/snapshot/src/consensus/work.rs index 819e95ca063..9295399a4e5 100644 --- a/ethcore/snapshot/src/consensus/work.rs +++ b/ethcore/snapshot/src/consensus/work.rs @@ -37,6 +37,7 @@ use engine::Engine; use ethereum_types::{H256, U256}; use kvdb::KeyValueDB; use log::trace; +use parking_lot::RwLock; use rand::rngs::OsRng; use rlp::{RlpStream, Rlp}; use triehash::ordered_trie_root; @@ -72,7 +73,7 @@ impl SnapshotComponents for PowSnapshot { chain: &BlockChain, block_at: H256, chunk_sink: &mut ChunkSink, - progress: &Progress, + progress: &RwLock, preferred_size: usize, ) -> Result<(), SnapshotError> { PowWorker { @@ -110,7 +111,7 @@ struct PowWorker<'a> { rlps: VecDeque, current_hash: H256, writer: &'a mut ChunkSink<'a>, - progress: &'a Progress, + progress: &'a RwLock, preferred_size: usize, } @@ -153,7 +154,7 @@ impl<'a> PowWorker<'a> { last = self.current_hash; self.current_hash = block.header_view().parent_hash(); - self.progress.blocks.fetch_add(1, Ordering::SeqCst); + self.progress.write().blocks += 1; } if loaded_size != 0 { diff --git a/ethcore/snapshot/src/lib.rs b/ethcore/snapshot/src/lib.rs index 406aeeddb93..38b2a440310 100644 --- a/ethcore/snapshot/src/lib.rs +++ b/ethcore/snapshot/src/lib.rs @@ -44,7 +44,7 @@ use ethtrie::{TrieDB, TrieDBMut}; use hash_db::HashDB; use journaldb::{self, Algorithm, JournalDB}; use keccak_hasher::KeccakHasher; -use parking_lot::Mutex; +use parking_lot::{Mutex, RwLock}; use kvdb::{KeyValueDB, DBValue}; use log::{debug, info, trace}; use num_cpus; @@ -121,7 +121,7 @@ pub fn take_snapshot( block_hash: H256, state_db: &dyn HashDB, writer: W, - p: &Progress, + p: &RwLock, processing_threads: usize, ) -> Result<(), Error> { let start_header = chain.block_header_data(&block_hash) @@ -168,7 +168,7 @@ pub fn take_snapshot( state_hashes.extend(part_state_hashes); } - info!("Took a snapshot at #{} of {} accounts", block_number, p.accounts()); + info!("Took a snapshot at #{} of {} accounts", block_number, p.read().accounts()); Ok((state_hashes, block_hashes)) }).expect("Sub-thread never panics; qed")?; @@ -186,7 +186,7 @@ pub fn take_snapshot( writer.into_inner().finish(manifest_data)?; - p.done.store(true, Ordering::SeqCst); + p.write().done = true; Ok(()) } @@ -202,7 +202,7 @@ pub fn chunk_secondary<'a>( chain: &'a BlockChain, start_hash: H256, writer: &Mutex, - progress: &'a Progress + progress: &'a RwLock ) -> Result, Error> { let mut chunk_hashes = Vec::new(); let mut snappy_buffer = vec![0; snappy::max_compressed_len(PREFERRED_CHUNK_SIZE)]; @@ -218,7 +218,7 @@ pub fn chunk_secondary<'a>( trace!(target: "snapshot", "wrote secondary chunk. hash: {:x}, size: {}, uncompressed size: {}", hash, size, raw_data.len()); - progress.update(0, size); + progress.write().update(0, size as u64); chunk_hashes.push(hash); Ok(()) }; @@ -242,7 +242,7 @@ struct StateChunker<'a> { cur_size: usize, snappy_buffer: Vec, writer: &'a Mutex, - progress: &'a Progress, + progress: &'a RwLock, thread_idx: usize, } @@ -275,7 +275,7 @@ impl<'a> StateChunker<'a> { self.writer.lock().write_state_chunk(hash, compressed)?; trace!(target: "snapshot", "Thread {} wrote state chunk. size: {}, uncompressed size: {}", self.thread_idx, compressed_size, raw_data.len()); - self.progress.update(num_entries, compressed_size); + self.progress.write().update(num_entries as u64, compressed_size as u64); self.hashes.push(hash); self.cur_size = 0; @@ -300,7 +300,7 @@ pub fn chunk_state<'a>( db: &dyn HashDB, root: &H256, writer: &Mutex, - progress: &'a Progress, + progress: &'a RwLock, part: Option, thread_idx: usize, ) -> Result, Error> { diff --git a/ethcore/snapshot/src/service.rs b/ethcore/snapshot/src/service.rs index da84482db71..ad51d3095a0 100644 --- a/ethcore/snapshot/src/service.rs +++ b/ethcore/snapshot/src/service.rs @@ -259,7 +259,7 @@ pub struct Service { state_chunks: AtomicUsize, block_chunks: AtomicUsize, client: Arc, - progress: Progress, + progress: RwLock, taking_snapshot: AtomicBool, restoring_snapshot: AtomicBool, } @@ -280,7 +280,7 @@ impl Service where C: SnapshotClient + ChainInfo { state_chunks: AtomicUsize::new(0), block_chunks: AtomicUsize::new(0), client: params.client, - progress: Progress::new(), + progress: RwLock::new(Progress::new()), taking_snapshot: AtomicBool::new(false), restoring_snapshot: AtomicBool::new(false), }; @@ -483,9 +483,9 @@ impl Service where C: SnapshotClient + ChainInfo { /// Tick the snapshot service. This will log any active snapshot /// being taken. pub fn tick(&self) { - if self.progress.done() || !self.taking_snapshot.load(Ordering::SeqCst) { return } + if self.progress.read().done() || !self.taking_snapshot.load(Ordering::SeqCst) { return } - let p = &self.progress; + let p = &self.progress.read(); info!("Snapshot: {} accounts, {} blocks, {} bytes", p.accounts(), p.blocks(), p.bytes()); let rate = p.rate(); debug!(target: "snapshot", "Current progress rate: {:.0} acc/s, {:.0} bytes/s (compressed)", rate.0, rate.1); @@ -507,7 +507,7 @@ impl Service where C: SnapshotClient + ChainInfo { self.taking_snapshot.store(false, Ordering::SeqCst); }} let start_time = std::time::Instant::now(); - self.progress.reset(); + *self.progress.write() = Progress::new(); let temp_dir = self.temp_snapshot_dir(); let snapshot_dir = self.snapshot_dir(); @@ -893,7 +893,7 @@ impl SnapshotService for Service { fn abort_snapshot(&self) { if self.taking_snapshot.load(Ordering::SeqCst) { trace!(target: "snapshot", "Aborting snapshot – Snapshot under way"); - self.progress.abort.store(true, Ordering::SeqCst); + self.progress.write().abort = true; } } diff --git a/ethcore/snapshot/src/traits.rs b/ethcore/snapshot/src/traits.rs index 8f5e12a119c..7cf812d30f7 100644 --- a/ethcore/snapshot/src/traits.rs +++ b/ethcore/snapshot/src/traits.rs @@ -26,6 +26,7 @@ use common_types::{ }; use engine::Engine; use ethereum_types::H256; +use parking_lot::RwLock; use crate::io::SnapshotWriter; @@ -108,7 +109,7 @@ pub trait SnapshotComponents: Send { chain: &BlockChain, block_at: H256, chunk_sink: &mut ChunkSink, - progress: &Progress, + progress: &RwLock, preferred_size: usize, ) -> Result<(), SnapshotError>; @@ -141,7 +142,7 @@ pub trait SnapshotClient: BlockChainClient + BlockInfo + DatabaseRestore + Block &self, writer: W, at: BlockId, - p: &Progress, + p: &RwLock, ) -> Result<(), Error>; } diff --git a/ethcore/src/client/client.rs b/ethcore/src/client/client.rs index c1c450486fe..93e5ca2ec29 100644 --- a/ethcore/src/client/client.rs +++ b/ethcore/src/client/client.rs @@ -2543,7 +2543,7 @@ impl SnapshotClient for Client { &self, writer: W, at: BlockId, - p: &Progress, + p: &RwLock, ) -> Result<(), EthcoreError> { if let Snapshotting::Unsupported = self.engine.snapshot_mode() { return Err(EthcoreError::Snapshot(SnapshotError::SnapshotsUnsupported)); diff --git a/ethcore/types/Cargo.toml b/ethcore/types/Cargo.toml index dd1dff2fb5a..509b9d13dd7 100644 --- a/ethcore/types/Cargo.toml +++ b/ethcore/types/Cargo.toml @@ -15,7 +15,6 @@ parity-bytes = "0.1" parity-crypto = { version = "0.4.2", features = ["publickey"] } parity-util-mem = "0.2.0" parity-snappy = "0.1" -parking_lot = "0.9.0" patricia-trie-ethereum = { path = "../../util/patricia-trie-ethereum" } rlp = "0.4.0" rlp_derive = { path = "../../util/rlp-derive" } diff --git a/ethcore/types/src/lib.rs b/ethcore/types/src/lib.rs index ab17b8837db..58ca86cae94 100644 --- a/ethcore/types/src/lib.rs +++ b/ethcore/types/src/lib.rs @@ -40,7 +40,6 @@ extern crate parity_crypto; #[macro_use] extern crate derive_more; extern crate keccak_hash as hash; -extern crate parking_lot; extern crate parity_bytes as bytes; extern crate patricia_trie_ethereum as ethtrie; extern crate rlp; diff --git a/ethcore/types/src/snapshot.rs b/ethcore/types/src/snapshot.rs index a3be631bebf..48b27f137e3 100644 --- a/ethcore/types/src/snapshot.rs +++ b/ethcore/types/src/snapshot.rs @@ -16,12 +16,10 @@ //! Snapshot type definitions -use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering}; use std::time::Instant; use bytes::Bytes; use ethereum_types::H256; -use parking_lot::RwLock; use rlp::{Rlp, RlpStream, DecoderError}; /// Modes of snapshotting @@ -44,89 +42,68 @@ pub enum Snapshotting { #[derive(Debug)] pub struct Progress { /// Number of accounts processed so far - accounts: AtomicUsize, + accounts: u64, // Number of accounts processed at last tick. - prev_accounts: AtomicUsize, + prev_accounts: u64, /// Number of blocks processed so far - pub blocks: AtomicUsize, + pub blocks: u64, /// Size in bytes of a all compressed chunks processed so far - bytes: AtomicUsize, + bytes: u64, // Number of bytes processed at last tick. - prev_bytes: AtomicUsize, + prev_bytes: u64, /// Signals that the snapshotting process is completed - pub done: AtomicBool, + pub done: bool, /// Signal snapshotting process to abort - pub abort: AtomicBool, + pub abort: bool, - last_tick: RwLock, + last_tick: Instant, } impl Progress { /// Create a new progress tracker. pub fn new() -> Progress { Progress { - accounts: AtomicUsize::new(0), - prev_accounts: AtomicUsize::new(0), - blocks: AtomicUsize::new(0), - bytes: AtomicUsize::new(0), - prev_bytes: AtomicUsize::new(0), - abort: AtomicBool::new(false), - done: AtomicBool::new(false), - last_tick: RwLock::new(Instant::now()), + accounts: 0, + prev_accounts: 0, + blocks: 0, + bytes: 0, + prev_bytes: 0, + abort: false, + done: false, + last_tick: Instant::now(), } } - /// Reset the progress. - pub fn reset(&self) { - self.accounts.store(0, Ordering::Release); - self.blocks.store(0, Ordering::Release); - self.bytes.store(0, Ordering::Release); - self.abort.store(false, Ordering::Release); - - // atomic fence here to ensure the others are written first? - // logs might very rarely get polluted if not. - self.done.store(false, Ordering::Release); - - *self.last_tick.write() = Instant::now(); - } - /// Get the number of accounts snapshotted thus far. - pub fn accounts(&self) -> usize { self.accounts.load(Ordering::Acquire) } + pub fn accounts(&self) -> u64 { self.accounts } /// Get the number of blocks snapshotted thus far. - pub fn blocks(&self) -> usize { self.blocks.load(Ordering::Acquire) } + pub fn blocks(&self) -> u64 { self.blocks } /// Get the written size of the snapshot in bytes. - pub fn bytes(&self) -> usize { self.bytes.load(Ordering::Acquire) } + pub fn bytes(&self) -> u64 { self.bytes } /// Whether the snapshot is complete. - pub fn done(&self) -> bool { self.done.load(Ordering::Acquire) } + pub fn done(&self) -> bool { self.done } /// Return the progress rate over the last tick (i.e. since last update). pub fn rate(&self) -> (f64, f64) { - let last_tick = *self.last_tick.read(); - let dt = last_tick.elapsed().as_secs_f64(); + let dt = self.last_tick.elapsed().as_secs_f64(); if dt < 1.0 { return (0f64, 0f64); } - let delta_acc = self.accounts.load(Ordering::Relaxed) - .saturating_sub(self.prev_accounts.load(Ordering::Relaxed)); - let delta_bytes = self.bytes.load(Ordering::Relaxed) - .saturating_sub(self.prev_bytes.load(Ordering::Relaxed)); + let delta_acc = self.accounts.saturating_sub(self.prev_accounts); + let delta_bytes = self.bytes.saturating_sub(self.prev_bytes); (delta_acc as f64 / dt, delta_bytes as f64 / dt) } /// Update state progress counters and set the last tick. - pub fn update(&self, accounts_delta: usize, bytes_delta: usize) { - *self.last_tick.write() = Instant::now(); - self.prev_accounts.store( - self.accounts.fetch_add(accounts_delta, Ordering::SeqCst), - Ordering::SeqCst - ); - self.prev_bytes.store( - self.bytes.fetch_add(bytes_delta, Ordering::SeqCst), - Ordering::SeqCst - ); + pub fn update(&mut self, accounts_delta: u64, bytes_delta: u64) { + self.last_tick = Instant::now(); + self.prev_accounts = self.accounts; + self.prev_bytes = self.bytes; + self.accounts += accounts_delta; + self.bytes += bytes_delta; } } diff --git a/parity/informant.rs b/parity/informant.rs index b53ffe14eff..08ef6423c22 100644 --- a/parity/informant.rs +++ b/parity/informant.rs @@ -46,7 +46,7 @@ use ethereum_types::H256; use parking_lot::{RwLock, Mutex}; /// Format byte counts to standard denominations. -pub fn format_bytes(b: usize) -> String { +pub fn format_bytes(b: u64) -> String { match binary_prefix(b as f64) { Standalone(bytes) => format!("{} bytes", bytes), Prefixed(prefix, n) => format!("{:.0} {}B", n, prefix), @@ -69,9 +69,8 @@ impl CacheSizes { use std::fmt::Write; let mut buf = String::new(); - for (name, &size) in &self.sizes { - - write!(buf, " {:>8} {}", paint(style, format_bytes(size)), name) + for (name, size) in &self.sizes { + write!(buf, " {:>8} {}", paint(style, format_bytes(*size as u64)), name) .expect("writing to string won't fail unless OOM; qed") } diff --git a/parity/snapshot_cmd.rs b/parity/snapshot_cmd.rs index 8a9157ad62c..94144ddf371 100644 --- a/parity/snapshot_cmd.rs +++ b/parity/snapshot_cmd.rs @@ -27,6 +27,7 @@ use snapshot::service::Service as SnapshotService; use ethcore::client::{Client, DatabaseCompactionProfile, VMType}; use ethcore::miner::Miner; use ethcore_service::ClientService; +use parking_lot::RwLock; use types::{ ids::BlockId, snapshot::Progress, @@ -257,20 +258,25 @@ impl SnapshotCommand { let writer = PackedWriter::new(&file_path) .map_err(|e| format!("Failed to open snapshot writer: {}", e))?; - let progress = Arc::new(Progress::new()); + let progress = Arc::new(RwLock::new(Progress::new())); let p = progress.clone(); let informant_handle = ::std::thread::spawn(move || { ::std::thread::sleep(Duration::from_secs(5)); - let mut last_size = 0; - while !p.done() { - let cur_size = p.bytes(); - if cur_size != last_size { - last_size = cur_size; - let bytes = ::informant::format_bytes(cur_size as usize); - info!("Snapshot: {} accounts (state), {} blocks, {} bytes", p.accounts(), p.blocks(), bytes); + loop { + { + let progress = p.read(); + if !progress.done() { + let cur_size = progress.bytes(); + if cur_size != last_size { + last_size = cur_size; + let bytes = ::informant::format_bytes(cur_size); + info!("Snapshot: {} accounts (state), {} blocks, {} bytes", progress.accounts(), progress.blocks(), bytes); + } + } else { + break; + } } - ::std::thread::sleep(Duration::from_secs(5)); } }); @@ -282,7 +288,7 @@ impl SnapshotCommand { info!("snapshot creation complete"); - assert!(progress.done()); + assert!(progress.read().done()); informant_handle.join().map_err(|_| "failed to join logger thread")?; Ok(()) From 6993ec95312f3ee446345ecb2591f0c66a9b4fcb Mon Sep 17 00:00:00 2001 From: Rakan Alhneiti Date: Tue, 29 Oct 2019 12:18:30 +0100 Subject: [PATCH 11/21] Use provided usd-per-eth value if an endpoint is specified (#11209) * Fix `invalid transaction price` error message * Setup Calibrated GasPriceConfig when usd-per-eth is an endpoint The change will try to check if the specified value is an endpoint. If the value of `auto` is specified, the default endpoint URL will be used otherwise, the user-provided value will be taken as-is for an endpoint. * Use if-let and check for usd-per-eth arg: 1. auto = use etherscan 2. value = use fixed pricer 3. endpoint = use the provided endpoint as-is * Fix typo in to_pricce error message * Correct whitespace indentation * Use arg_usd_per_eth directly --- ethcore/src/miner/miner.rs | 1 + miner/price-info/src/lib.rs | 7 +++---- miner/src/gas_price_calibrator.rs | 4 ++-- parity/configuration.rs | 34 +++++++++++++++++++------------ parity/helpers.rs | 2 +- parity/params.rs | 7 ++++++- 6 files changed, 34 insertions(+), 21 deletions(-) diff --git a/ethcore/src/miner/miner.rs b/ethcore/src/miner/miner.rs index 96e5d760b17..1671fbffa99 100644 --- a/ethcore/src/miner/miner.rs +++ b/ethcore/src/miner/miner.rs @@ -1910,6 +1910,7 @@ mod tests { }, fetch, p, + "fake_endpoint".to_owned() ) ) } diff --git a/miner/price-info/src/lib.rs b/miner/price-info/src/lib.rs index d249704b5ec..397c2f94f49 100644 --- a/miner/price-info/src/lib.rs +++ b/miner/price-info/src/lib.rs @@ -57,8 +57,7 @@ impl cmp::PartialEq for Client { impl Client { /// Creates a new instance of the `Client` given a `fetch::Client`. - pub fn new(fetch: F, pool: Executor) -> Client { - let api_endpoint = "https://api.etherscan.io/api?module=stats&action=ethprice".to_owned(); + pub fn new(fetch: F, pool: Executor, api_endpoint: String) -> Client { Client { pool, api_endpoint, fetch } } @@ -105,11 +104,11 @@ mod test { use super::Client; fn price_info_ok(response: &str, executor: Executor) -> Client> { - Client::new(FakeFetch::new(Some(response.to_owned())), executor) + Client::new(FakeFetch::new(Some(response.to_owned())), executor, "fake_endpoint".to_owned()) } fn price_info_not_found(executor: Executor) -> Client> { - Client::new(FakeFetch::new(None::), executor) + Client::new(FakeFetch::new(None::), executor, "fake_endpoint".to_owned()) } #[test] diff --git a/miner/src/gas_price_calibrator.rs b/miner/src/gas_price_calibrator.rs index 7a0943640cf..e91b880fadd 100644 --- a/miner/src/gas_price_calibrator.rs +++ b/miner/src/gas_price_calibrator.rs @@ -43,11 +43,11 @@ pub struct GasPriceCalibrator { impl GasPriceCalibrator { /// Create a new gas price calibrator. - pub fn new(options: GasPriceCalibratorOptions, fetch: FetchClient, p: Executor) -> GasPriceCalibrator { + pub fn new(options: GasPriceCalibratorOptions, fetch: FetchClient, p: Executor, api_endpoint: String) -> GasPriceCalibrator { GasPriceCalibrator { options: options, next_calibration: Instant::now(), - price_info: PriceInfoClient::new(fetch, p), + price_info: PriceInfoClient::new(fetch, p, api_endpoint), } } diff --git a/parity/configuration.rs b/parity/configuration.rs index 4c99e51c35d..0ca62f07275 100644 --- a/parity/configuration.rs +++ b/parity/configuration.rs @@ -58,6 +58,7 @@ use network::{IpFilter}; const DEFAULT_MAX_PEERS: u16 = 50; const DEFAULT_MIN_PEERS: u16 = 25; +pub const ETHERSCAN_ETH_PRICE_ENDPOINT: &str = "https://api.etherscan.io/api?module=stats&action=ethprice"; #[derive(Debug, PartialEq)] pub enum Cmd { @@ -666,23 +667,30 @@ impl Configuration { } let usd_per_tx = to_price(&self.args.arg_usd_per_tx)?; - if "auto" == self.args.arg_usd_per_eth.as_str() { - return Ok(GasPricerConfig::Calibrated { + + if "auto" == self.args.arg_usd_per_eth { + Ok(GasPricerConfig::Calibrated { usd_per_tx: usd_per_tx, recalibration_period: to_duration(self.args.arg_price_update_period.as_str())?, - }); - } - - let usd_per_eth = to_price(&self.args.arg_usd_per_eth)?; - let wei_per_gas = wei_per_gas(usd_per_tx, usd_per_eth); + api_endpoint: ETHERSCAN_ETH_PRICE_ENDPOINT.to_string(), + }) + } else if let Ok(usd_per_eth_parsed) = to_price(&self.args.arg_usd_per_eth) { + let wei_per_gas = wei_per_gas(usd_per_tx, usd_per_eth_parsed); - info!( - "Using a fixed conversion rate of Ξ1 = {} ({} wei/gas)", - Colour::White.bold().paint(format!("US${:.2}", usd_per_eth)), - Colour::Yellow.bold().paint(format!("{}", wei_per_gas)) - ); + info!( + "Using a fixed conversion rate of Ξ1 = {} ({} wei/gas)", + Colour::White.bold().paint(format!("US${:.2}", usd_per_eth_parsed)), + Colour::Yellow.bold().paint(format!("{}", wei_per_gas)) + ); - Ok(GasPricerConfig::Fixed(wei_per_gas)) + Ok(GasPricerConfig::Fixed(wei_per_gas)) + } else { + Ok(GasPricerConfig::Calibrated { + usd_per_tx: usd_per_tx, + recalibration_period: to_duration(self.args.arg_price_update_period.as_str())?, + api_endpoint: self.args.arg_usd_per_eth.clone(), + }) + } } fn extra_data(&self) -> Result { diff --git a/parity/helpers.rs b/parity/helpers.rs index 2404630ccd2..a0a973b94cb 100644 --- a/parity/helpers.rs +++ b/parity/helpers.rs @@ -146,7 +146,7 @@ pub fn to_addresses(s: &Option) -> Result, String> { /// Tries to parse string as a price. pub fn to_price(s: &str) -> Result { - s.parse::().map_err(|_| format!("Invalid transaciton price 's' given. Must be a decimal number.")) + s.parse::().map_err(|_| format!("Invalid transaction price {:?} given. Must be a decimal number.", s)) } pub fn join_set(set: Option<&HashSet>) -> Option { diff --git a/parity/params.rs b/parity/params.rs index fafc94d806b..45547b46b9b 100644 --- a/parity/params.rs +++ b/parity/params.rs @@ -29,6 +29,8 @@ use parity_version::version_data; use user_defaults::UserDefaults; use types::client_types::Mode; +use crate::configuration; + #[derive(Debug, PartialEq)] pub enum SpecType { Foundation, @@ -248,6 +250,7 @@ pub enum GasPricerConfig { Calibrated { usd_per_tx: f32, recalibration_period: Duration, + api_endpoint: String } } @@ -256,6 +259,7 @@ impl Default for GasPricerConfig { GasPricerConfig::Calibrated { usd_per_tx: 0.0001f32, recalibration_period: Duration::from_secs(3600), + api_endpoint: configuration::ETHERSCAN_ETH_PRICE_ENDPOINT.to_string(), } } } @@ -264,7 +268,7 @@ impl GasPricerConfig { pub fn to_gas_pricer(&self, fetch: FetchClient, p: Executor) -> GasPricer { match *self { GasPricerConfig::Fixed(u) => GasPricer::Fixed(u), - GasPricerConfig::Calibrated { usd_per_tx, recalibration_period, .. } => { + GasPricerConfig::Calibrated { usd_per_tx, recalibration_period, ref api_endpoint } => { GasPricer::new_calibrated( GasPriceCalibrator::new( GasPriceCalibratorOptions { @@ -273,6 +277,7 @@ impl GasPricerConfig { }, fetch, p, + api_endpoint.clone(), ) ) } From 29c364be43a532c4edd00927e8632461e84c50a2 Mon Sep 17 00:00:00 2001 From: Jonathan Brown Date: Tue, 29 Oct 2019 18:43:46 +0700 Subject: [PATCH 12/21] Update bootnodes. (#11203) --- ethcore/res/ethereum/mix.json | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/ethcore/res/ethereum/mix.json b/ethcore/res/ethereum/mix.json index f788191c96f..4be009ada2f 100644 --- a/ethcore/res/ethereum/mix.json +++ b/ethcore/res/ethereum/mix.json @@ -48,13 +48,23 @@ }, "nodes": [ "enode://aeb6070deb50efeb41c5e4283a6a3b08ff701fef90e3522161c145f30df2852af3dfc51ba74591f7c9d96b11ca4c3c2b354bf58dd243f2d877f6eecc2373fd1d@139.162.15.124:30313", + "enode://cb4b0568607c97a3af4857700152fad9c79908a89319310268c7f49184e3f7e0c88c8d3504696f521c8aafcd00644f9325f76cba9427181b1493ff7ce230df00@139.162.15.124:30303", "enode://e0c926dcdc5c1cf58b2ecba371c577c28c28c91f9b210093178a812389b65e5b53f0e478753b94fceb0b36645b779a915ca57c0c48507fe4d7f786508653656c@74.207.240.177:30313", + "enode://37fe8c0f8d667f110316de3109dcc2e9c9247219998e9ac395db39511bef697f9646f73d86a43da491efce35458f53ac3ac0994b85f7086bbf244809d4e7eb7f@74.207.240.177:30303", "enode://a2a2adb8c12b9b189306050013a44f28db30f92fb3670db9675a049b98b96eb18901d6ff7b961b6e96cfa3923ac29e8f647ef452f0a23ddfef3903ac1cf826af@173.255.195.214:30313", + "enode://ed6fea8e7389bb75ff34846e4aaefa9157c9c79828c6404f4a0ab6b997a613f777aecaed5092c3f51abdf918926c925f7ee4f4cffdb0ac37775d03070a3d6b55@173.255.195.214:30303", "enode://5460fd1ad217941befd0f8d060e6729a0535a0738770aba56827d1313c09aeb68e3098d458aace59faba2c6780b8c9c30cb140b80cd8e30ca3a074ce6d3344d3@50.116.38.52:30313", + "enode://9109e01dec60b67afa5aea77da17e0cb9a716a547469be378eb122c545a3fda9082e553624ff9e673195a715d5628ebf046a6c4ff315e566420e3bdde003bd9a@50.116.38.52:30303", "enode://99fff4ed887d6a6a7b6e03a657c35c06d0eede1909ec289a362bad9d37dd4085886461bbce83aa484ce1327badb3c5958365caa851d71de49dc4530e075b64bc@45.79.128.151:30313", + "enode://4b4c06445175b77ac07eba03ac624f72e4e86065ee8bbdbca5f882a2a333e2608e6ef2ae5b5779816abd8d07ae6ec08f75888edeab3bc06f2b75871feb14afef@45.79.128.151:30303", "enode://fd80e04c75559cfdd9ed8c08ef2c39c5bc95021f7cbaf31acb601914bc7dac7c34b470b90a05e519bc8a8435a46e1ce51053ae07fac31a83567285c34a79c6bf@139.162.224.203:30313", + "enode://d2e678247450c0a7aefdcf03787d4905deda2a6889f02071b241a1309a6bec6ea1c8b1160f69635dee0b4e00cc83656a601b4528cccbd85744b811654ab24b13@139.162.224.203:30303", "enode://4742134a153c108855eb16563424887ed3aa5b6b74e4b713c8e93a10c376d954ff3041442716bdf9ee28fab2ea09f04d07e3366f834ea472c19820b7337eb27a@172.104.130.233:30313", - "enode://799d0a8836e17ef7fcc58b3d5ced5bb1fe474b31a09851f938d381f4556fa8954ca308f6a178d22ed56769a8b878ac8f9cc62c889f9cafab45a3bd4f6024bb29@172.104.68.7:30313" + "enode://9aaeae0129af1bbb2e3590a71cd1ad0c320aa1c03e15c9eb3563cee2d8a7ca43473f43197b6dc0befe5bcef6185196360fa8b4b0d82d8ef11e2ff65553a1efa5@172.104.130.233:30303", + "enode://799d0a8836e17ef7fcc58b3d5ced5bb1fe474b31a09851f938d381f4556fa8954ca308f6a178d22ed56769a8b878ac8f9cc62c889f9cafab45a3bd4f6024bb29@172.104.68.7:30313", + "enode://ab7b1aab2439aafadcb52f8353e60fc1eea55ee5a01b4ddf46ecdeaa2e869c4bf305249757dc74baa78cf05c5d98ffe5c2a008851f08cab6096c78a08dee7c17@172.104.68.7:30303", + "enode://ab4a7fb0963e4951bebbefd2ec09ddac018bb27600a6063d755dfc10be118cbfe3954ada561afbce4cbda6f62364c12902b9e6bdef258aff36b8a73db3c0f161@172.105.16.240:30313", + "enode://30ff1bd89f58a1adae1f2b2ed1e36fa95caf5c2c7e085cf3a49f14705427ca7d7b2508060d058ceda57c708e8aa4661304f3c17eaae4da2e9cea6b64b3893c2f@172.105.16.240:30303" ], "accounts": { "0000000000000000000000000000000000000001": { "builtin": { "name": "ecrecover", "pricing": { "linear": { "base": 3000, "word": 0 } } } }, From f743829759e12b7f469e4a83673303cec1dad742 Mon Sep 17 00:00:00 2001 From: Denis Pisarev Date: Wed, 30 Oct 2019 19:16:18 +0100 Subject: [PATCH 13/21] retry on gitlab system failures (#11222) --- .gitlab-ci.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 524def00a7e..e0a4cb11602 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -37,6 +37,12 @@ variables: before_script: - rustup show - cargo --version + retry: + max: 2 + when: + - runner_system_failure + - unknown_failure + - api_failure tags: - linux-docker From 6b17e321dfbcd3db7b60f52ab8530a9dd77a4e46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis=20P=C3=A9rez?= <53609911+luosprz@users.noreply.github.com> Date: Thu, 31 Oct 2019 14:59:51 +0100 Subject: [PATCH 14/21] Fix docker centos build (#11226) - Update shell script to build docker centos image with the new path. - Update REAMDE.md with build instructions. Closes [#11224](https://github.com/paritytech/parity-ethereum/issues/11224) --- scripts/docker/README.md | 4 ++-- scripts/docker/centos/build.sh | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/scripts/docker/README.md b/scripts/docker/README.md index 86b2fcb6aad..1b970699d60 100644 --- a/scripts/docker/README.md +++ b/scripts/docker/README.md @@ -8,7 +8,7 @@ Builds a lightweight non-root Parity docker image: ``` git clone https://github.com/paritytech/parity-ethereum.git cd parity-ethereum -./docker/centos/build.sh +./scripts/docker/centos/build.sh ``` Fully customised build: @@ -16,7 +16,7 @@ Fully customised build: PARITY_IMAGE_REPO=my-personal/parity \ PARITY_BUILDER_IMAGE_TAG=build-latest \ PARITY_RUNNER_IMAGE_TAG=centos-parity-experimental \ -./docker/centos/build.sh +./scripts/docker/centos/build.sh ``` Default values: diff --git a/scripts/docker/centos/build.sh b/scripts/docker/centos/build.sh index 7215e745f0e..df4796b9137 100755 --- a/scripts/docker/centos/build.sh +++ b/scripts/docker/centos/build.sh @@ -8,18 +8,18 @@ PARITY_BUILDER_IMAGE_TAG=${PARITY_BUILDER_IMAGE_TAG:-build} PARITY_RUNNER_IMAGE_TAG=${PARITY_RUNNER_IMAGE_TAG:-latest} echo Building $PARITY_IMAGE_REPO:$PARITY_BUILDER_IMAGE_TAG-$(git log -1 --format="%H") -docker build --no-cache -t $PARITY_IMAGE_REPO:$PARITY_BUILDER_IMAGE_TAG-$(git log -1 --format="%H") . -f docker/centos/Dockerfile.build +docker build --no-cache -t $PARITY_IMAGE_REPO:$PARITY_BUILDER_IMAGE_TAG-$(git log -1 --format="%H") . -f scripts/docker/centos/Dockerfile.build echo Creating $PARITY_BUILDER_IMAGE_TAG-$(git log -1 --format="%H"), extracting binary docker create --name extract $PARITY_IMAGE_REPO:$PARITY_BUILDER_IMAGE_TAG-$(git log -1 --format="%H") -mkdir docker/centos/parity -docker cp extract:/build/parity-ethereum/target/release/parity docker/centos/parity +mkdir scripts/docker/centos/parity +docker cp extract:/build/parity-ethereum/target/release/parity scripts/docker/centos/parity echo Building $PARITY_IMAGE_REPO:$PARITY_RUNNER_IMAGE_TAG -docker build --no-cache -t $PARITY_IMAGE_REPO:$PARITY_RUNNER_IMAGE_TAG docker/centos/ -f docker/centos/Dockerfile +docker build --no-cache -t $PARITY_IMAGE_REPO:$PARITY_RUNNER_IMAGE_TAG scripts/docker/centos/ -f scripts/docker/centos/Dockerfile echo Cleaning up ... -rm -rf docker/centos/parity +rm -rf scripts/docker/centos/parity docker rm -f extract docker rmi -f $PARITY_IMAGE_REPO:$PARITY_BUILDER_IMAGE_TAG-$(git log -1 --format="%H") From 8c2199dd2a4ff51a0ee969c9c299460bf157b1ff Mon Sep 17 00:00:00 2001 From: David Date: Thu, 31 Oct 2019 16:07:21 +0100 Subject: [PATCH 15/21] Snapshot restoration overhaul (#11219) * Comments and todos Use `snapshot_sync` as logging target * fix compilation * More todos, more logs * Fix picking snapshot peer: prefer the one with the highest block number More docs, comments, todos * Adjust WAIT_PEERS_TIMEOUT to be a multiple of MAINTAIN_SYNC_TIMER to try to fix snapshot startup problems Docs, todos, comments * Tabs * Formatting * Don't build new rlp::EMPTY_LIST_RLP instances * Dial down debug logging * Don't warn about missing hashes in the manifest: it's normal Log client version on peer connect * Cleanup * Do not skip snapshots further away than 30k block from the highest block seen Currently we look for peers that seed snapshots that are close to the highest block seen on the network (where "close" means withing 30k blocks). When a node starts up we wait for some time (5sec, increased here to 10sec) to let peers connect and if we have found a suitable peer to sync a snapshot from at the end of that delay, we start the download; if none is found and --warp-barrier is used we stall, otherwise we start a slow-sync. When looking for a suitable snapshot, we use the highest block seen on the network to check if a peer has a snapshot that is within 30k blocks of that highest block number. This means that in a situation where all available snapshots are older than that, we will often fail to start a snapshot at all. What's worse is that the longer we delay starting a snapshot sync (to let more peers connect, in the hope of finding a good snapshot), the more likely we are to have seen a high block and thus the more likely we become to accept a snapshot. This commit removes this comparison with the highest blocknumber criteria entirely and picks the best snapshot we find in 10sec. * lockfile * Add a `ChunkType::Dupe` variant so that we do not disconnect a peer if they happen to send us a duplicate chunk (just ignore the chunk and keep going) Resolve some documentation todos, add more * tweak log message * Don't warp sync twice Check if our own block is beyond the given warp barrier (can happen after we've completed a warp sync but are not quite yet synced up to the tip) and if so, don't sync. More docs, resolve todos. Dial down some `sync` debug level logging to trace * Avoid iterating over all snapshot block/state hashes to find the next work item Use a HashSet instead of a Vec and remove items from the set as chunks are processed. Calculate and store the total number of chunks in the `Snapshot` struct instead of counting pending chunks each time. * Address review grumbles * Log correct number of bytes written to disk * Revert ChunkType::Dup change * whitespace grumble * Cleanup debugging code * Fix docs * Fix import and a typo * Fix test impl * Use `indexmap::IndexSet` to ensure chunk hashes are accessed in order * Revert increased SNAPSHOT_MANIFEST_TIMEOUT: 5sec should be enough --- Cargo.lock | 100 +++++------ ethcore/snapshot/src/lib.rs | 1 - ethcore/snapshot/src/service.rs | 4 +- ethcore/snapshot/src/traits.rs | 3 +- ethcore/sync/Cargo.toml | 1 + ethcore/sync/src/api.rs | 2 +- ethcore/sync/src/block_sync.rs | 2 +- ethcore/sync/src/chain/handler.rs | 62 +++---- ethcore/sync/src/chain/mod.rs | 247 ++++++++++++++++++---------- ethcore/sync/src/chain/requester.rs | 9 +- ethcore/sync/src/chain/supplier.rs | 2 +- ethcore/sync/src/snapshot_sync.rs | 147 +++++++++++------ ethcore/sync/src/sync_io.rs | 30 ++-- ethcore/sync/src/tests/helpers.rs | 40 ++--- ethcore/types/src/snapshot.rs | 6 +- util/network-devp2p/src/host.rs | 1 - util/network/src/lib.rs | 64 +++---- 17 files changed, 426 insertions(+), 295 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4305a617cc5..506ac7f8864 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -145,7 +145,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "ascii" -version = "0.7.1" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -189,7 +189,7 @@ dependencies = [ "ethjson 0.1.0", "itertools 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)", "keccak-hash 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "lru-cache 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "machine 0.1.0", @@ -207,7 +207,7 @@ dependencies = [ [[package]] name = "autocfg" -version = "0.1.4" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -280,7 +280,7 @@ name = "bincode" version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.99 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -392,7 +392,7 @@ source = "git+https://github.com/paritytech/bn#6beba2ed6c9351622f9e948ccee406384 dependencies = [ "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "crunchy 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -402,7 +402,7 @@ name = "bstr" version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "regex-automata 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.99 (registry+https://github.com/rust-lang/crates.io-index)", @@ -442,7 +442,7 @@ name = "c2-chacha" version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "ppv-lite86 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -549,7 +549,7 @@ dependencies = [ "ethereum-types 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "ethjson 0.1.0", "keccak-hash 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "lru-cache 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "machine 0.1.0", @@ -582,10 +582,10 @@ dependencies = [ [[package]] name = "combine" -version = "3.6.1" +version = "3.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "ascii 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "ascii 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "either 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -643,7 +643,7 @@ dependencies = [ "criterion-plot 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "csv 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand_os 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -691,7 +691,7 @@ dependencies = [ "arrayvec 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "memoffset 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "scopeguard 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -715,7 +715,7 @@ version = "0.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -800,7 +800,7 @@ name = "derive_more" version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)", "regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -844,7 +844,7 @@ name = "docopt" version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.99 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", @@ -872,10 +872,10 @@ dependencies = [ "ethabi 9.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "ethereum-types 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "indexmap 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "itertools 0.7.8 (registry+https://github.com/rust-lang/crates.io-index)", "keccak-hash 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "lunarity-lexer 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1076,7 +1076,7 @@ dependencies = [ "kvdb 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "kvdb-memorydb 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "kvdb-rocksdb 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "machine 0.1.0", "macros 0.1.0", @@ -1280,7 +1280,7 @@ dependencies = [ "arrayvec 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", "atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.5.13 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1331,7 +1331,7 @@ dependencies = [ "ethcore-io 1.12.0", "ethereum-types 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "ipnetwork 0.12.8 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", "parity-crypto 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "parity-snappy 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1448,7 +1448,7 @@ dependencies = [ "keccak-hash 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "kvdb 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "kvdb-rocksdb 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-bytes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-crypto 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1524,6 +1524,7 @@ dependencies = [ "ethereum-types 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "fastmap 0.1.0", "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", + "indexmap 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "keccak-hash 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "kvdb-memorydb 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1649,7 +1650,7 @@ dependencies = [ "ethereum-types 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "hex-literal 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "keccak-hash 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "memory-cache 0.1.0", "parity-bytes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1814,7 +1815,7 @@ name = "fs-swap" version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", "libloading 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1922,7 +1923,7 @@ dependencies = [ "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", "http 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", - "indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "indexmap 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "slab 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "string 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1953,7 +1954,7 @@ version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "ahash 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)", - "autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2144,8 +2145,11 @@ dependencies = [ [[package]] name = "indexmap" -version = "1.0.2" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", +] [[package]] name = "instant-seal" @@ -2241,7 +2245,7 @@ version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cesu8 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "combine 3.6.1 (registry+https://github.com/rust-lang/crates.io-index)", + "combine 3.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", "jni-sys 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2342,7 +2346,7 @@ dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "globset 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "jsonrpc-core 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "tokio 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2448,7 +2452,7 @@ dependencies = [ [[package]] name = "lazy_static" -version = "1.3.0" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -2962,7 +2966,7 @@ dependencies = [ "digest 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "ethereum-types 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "hmac 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-secp256k1 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "pbkdf2 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3318,7 +3322,7 @@ dependencies = [ "ethcore-sync 1.12.0", "ethereum-types 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "keccak-hash 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-bytes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3371,7 +3375,7 @@ name = "parity-wordlist" version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -3891,7 +3895,7 @@ dependencies = [ "crossbeam-deque 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam-queue 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -3966,7 +3970,7 @@ version = "0.14.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cc 1.0.46 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", "spin 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "untrusted 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3996,7 +4000,7 @@ name = "rlp_compress" version = "0.1.0" dependencies = [ "elastic-array 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "rlp 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -4273,7 +4277,7 @@ dependencies = [ "keccak-hasher 0.1.1", "kvdb 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "kvdb-rocksdb 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)", "parity-bytes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4319,7 +4323,7 @@ dependencies = [ "keccak-hasher 0.1.1", "kvdb 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "kvdb-rocksdb 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-bytes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-crypto 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4573,7 +4577,7 @@ name = "thread_local" version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -4713,7 +4717,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "crossbeam-utils 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4773,7 +4777,7 @@ dependencies = [ "crossbeam-queue 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)", "slab 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5070,7 +5074,7 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "idna 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.99 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5097,7 +5101,7 @@ dependencies = [ "executive-state 0.1.0", "keccak-hash 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "kvdb 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "machine 0.1.0", "memory-cache 0.1.0", @@ -5119,7 +5123,7 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "if_chain 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)", "regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5389,11 +5393,11 @@ dependencies = [ "checksum arrayref 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "0d382e583f07208808f6b1249e60848879ba3543f57c32277bf52d69c2f0f0ee" "checksum arrayvec 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)" = "b8d73f9beda665eaa98ab9e4f7442bd4e7de6652587de55b2525e52e29c1b0ba" "checksum arrayvec 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cff77d8686867eceff3105329d4698d96c2391c176d5d03adc90c7389162b5b8" -"checksum ascii 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3ae7d751998c189c1d4468cf0a39bb2eae052a9c58d50ebb3b9591ee3813ad50" +"checksum ascii 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)" = "eab1c04a571841102f5345a8fc0f6bb3d31c315dec879b5c6e42e40ce7ffa34e" "checksum assert_matches 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7deb0a829ca7bcfaf5da70b073a8d128619259a7be8216a355e23f00763059e5" "checksum attohttpc 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "eaf0ec4b0e00f61ee75556ca027485b7b354f4a714d88cc03f4468abd9378c86" "checksum atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "9a7d5b8723950951411ee34d271d99dddcc2035a16ab25310ea2c8cfd4369652" -"checksum autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "0e49efa51329a5fd37e7c79db4621af617cd4e3e5bc224939808d076077077bf" +"checksum autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "1d49d90015b3c36167a20fe2810c5cd875ad504b39cff3d4eae7977e6b7c1cb2" "checksum backtrace 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "89a47830402e9981c5c41223151efcced65a0510c13097c769cede7efb34782a" "checksum backtrace-sys 0.1.24 (registry+https://github.com/rust-lang/crates.io-index)" = "c66d56ac8dabd07f6aacdaf633f4b8262f5b3601a810a0dcddffd5c22c69daa0" "checksum base-x 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "5cda5d0f5584d129112ad8bf4775b9fd2b9f1e30738c7b1a25314ba2244d6a51" @@ -5427,7 +5431,7 @@ dependencies = [ "checksum clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5067f5bb2d80ef5d68b4c87db81601f0b75bca627bc2ef76b141d7b846a3c6d9" "checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" "checksum cmake 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)" = "6ec65ee4f9c9d16f335091d23693457ed4928657ba4982289d7fafee03bc614a" -"checksum combine 3.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "fc1d011beeed29187b8db2ac3925c8dd4d3e87db463dc9d2d2833985388fc5bc" +"checksum combine 3.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "da3da6baa321ec19e1cc41d31bf599f00c783d0517095cdaf0332e3fe8d20680" "checksum const-random 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "7b641a8c9867e341f3295564203b1c250eb8ce6cb6126e007941f78c4d2ed7fe" "checksum const-random-macro 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c750ec12b83377637110d5a57f5ae08e895b06c4b16e2bdbf1a94ef717428c59" "checksum criterion 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "938703e165481c8d612ea3479ac8342e5615185db37765162e762ec3523e2fc6" @@ -5509,7 +5513,7 @@ dependencies = [ "checksum impl-codec 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3fa0086251524c50fd53b32e7b05eb6d79e2f97221eaf0c53c0ca9c3096f21d3" "checksum impl-rlp 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f39b9963cf5f12fcc4ae4b30a6927ed67d6b4ea4cbe7d17a41131163b401303b" "checksum impl-serde 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "bbb1ea6188aca47a0eaeeb330d8a82f16cd500f30b897062d23922568727333a" -"checksum indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7e81a7c05f79578dbc15793d8b619db9ba32b4577003ef3af1a91c416798c58d" +"checksum indexmap 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712d7b3ea5827fcb9d4fda14bf4da5f136f0db2ae9c8f4bd4e2d1c6fde4e6db2" "checksum integer-encoding 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "26746cbc2e680af687e88d717f20ff90079bd10fc984ad57d277cd0e37309fa5" "checksum interleaved-ordered 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "141340095b15ed7491bd3d4ced9d20cebfb826174b6bb03386381f62b01e3d77" "checksum iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dbe6e417e7d0975db6512b90796e8ce223145ac4e33c377e4a42882a0e88bb08" @@ -5536,7 +5540,7 @@ dependencies = [ "checksum kvdb 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "72ae89206cea31c32014b39d5a454b96135894221610dbfd19cf4d2d044fa546" "checksum kvdb-memorydb 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "296c12309ed36cb74d59206406adbf1971c3baa56d5410efdb508d8f1c60a351" "checksum kvdb-rocksdb 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "96eb0e0112bb66fe5401294ca0f43c9cb771456af9270443545026e55fd00912" -"checksum lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bc5729f27f159ddd61f4df6228e827e86643d4d3e7c32183cb30a1c08f604a14" +"checksum lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" "checksum lazycell 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ddba4c30a78328befecec92fc94970e53b3ae385827d28620f0f5bb2493081e0" "checksum libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)" = "34fcd2c08d2f832f376f4173a231990fa5aef4e99fb569867318a227ef4c06ba" "checksum libloading 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9c3ad660d7cb8c5822cd83d10897b0f1f1526792737a179e73896152f85b88c2" diff --git a/ethcore/snapshot/src/lib.rs b/ethcore/snapshot/src/lib.rs index 38b2a440310..22c7a58ded0 100644 --- a/ethcore/snapshot/src/lib.rs +++ b/ethcore/snapshot/src/lib.rs @@ -452,7 +452,6 @@ impl StateRebuilder { StateDB::commit_bloom(&mut batch, bloom_journal)?; self.db.inject(&mut batch)?; backing.write_buffered(batch); - trace!(target: "snapshot", "current state root: {:?}", self.state_root); Ok(()) } diff --git a/ethcore/snapshot/src/service.rs b/ethcore/snapshot/src/service.rs index ad51d3095a0..64ceab5df14 100644 --- a/ethcore/snapshot/src/service.rs +++ b/ethcore/snapshot/src/service.rs @@ -161,6 +161,7 @@ impl Restoration { if let Some(ref mut writer) = self.writer.as_mut() { writer.write_state_chunk(hash, chunk)?; + trace!(target: "snapshot", "Wrote {}/{} bytes of state to db/disk. Current state root: {:?}", len, chunk.len(), self.state.state_root()); } self.state_chunks_left.remove(&hash); @@ -676,7 +677,6 @@ impl Service where C: SnapshotClient + ChainInfo { } else if manifest.state_hashes.contains(&hash) { true } else { - warn!(target: "snapshot", "Hash of the content of {:?} not present in the manifest block/state hashes.", path); return Ok(false); }; @@ -788,7 +788,7 @@ impl Service where C: SnapshotClient + ChainInfo { false => Ok(()) } } - other => other.map(drop), + Err(e) => Err(e) }; (res, db) } diff --git a/ethcore/snapshot/src/traits.rs b/ethcore/snapshot/src/traits.rs index 7cf812d30f7..466f7bf98df 100644 --- a/ethcore/snapshot/src/traits.rs +++ b/ethcore/snapshot/src/traits.rs @@ -52,8 +52,7 @@ pub trait SnapshotService : Sync + Send { fn status(&self) -> RestorationStatus; /// Begin snapshot restoration. - /// If restoration in-progress, this will reset it. - /// From this point on, any previous snapshot may become unavailable. + /// If a restoration is in progress, this will reset it and clear all data. fn begin_restore(&self, manifest: ManifestData); /// Abort an in-progress restoration if there is one. diff --git a/ethcore/sync/Cargo.toml b/ethcore/sync/Cargo.toml index 8356249d914..db07e294f04 100644 --- a/ethcore/sync/Cargo.toml +++ b/ethcore/sync/Cargo.toml @@ -19,6 +19,7 @@ ethcore-private-tx = { path = "../private-tx" } ethereum-types = "0.8.0" fastmap = { path = "../../util/fastmap" } futures = "0.1" +indexmap = "1.3.0" keccak-hash = "0.4.0" light = { package = "ethcore-light", path = "../light" } log = "0.4" diff --git a/ethcore/sync/src/api.rs b/ethcore/sync/src/api.rs index 17c32eca5de..a8a7a99fc3c 100644 --- a/ethcore/sync/src/api.rs +++ b/ethcore/sync/src/api.rs @@ -295,7 +295,7 @@ pub struct EthSync { light_subprotocol_name: [u8; 3], /// Priority tasks notification channel priority_tasks: Mutex>, - /// for state tracking + /// Track the sync state: are we importing or verifying blocks? is_major_syncing: Arc } diff --git a/ethcore/sync/src/block_sync.rs b/ethcore/sync/src/block_sync.rs index 8c9ede44767..7eb324a0689 100644 --- a/ethcore/sync/src/block_sync.rs +++ b/ethcore/sync/src/block_sync.rs @@ -309,7 +309,7 @@ impl BlockDownloader { } } } - + // Update the highest block number seen on the network from the header. if let Some((number, _)) = last_header { if self.highest_block.as_ref().map_or(true, |n| number > *n) { self.highest_block = Some(number); diff --git a/ethcore/sync/src/chain/handler.rs b/ethcore/sync/src/chain/handler.rs index 08ed6503511..18212ad1405 100644 --- a/ethcore/sync/src/chain/handler.rs +++ b/ethcore/sync/src/chain/handler.rs @@ -43,7 +43,7 @@ use ethereum_types::{H256, U256}; use keccak_hash::keccak; use network::PeerId; use network::client_version::ClientVersion; -use log::{debug, trace, error}; +use log::{debug, trace, error, warn}; use rlp::Rlp; use common_types::{ BlockNumber, @@ -76,14 +76,14 @@ impl SyncHandler { SignedPrivateTransactionPacket => SyncHandler::on_signed_private_transaction(sync, io, peer, &rlp), PrivateStatePacket => SyncHandler::on_private_state_data(sync, io, peer, &rlp), _ => { - debug!(target: "sync", "{}: Unknown packet {}", peer, packet_id.id()); + trace!(target: "sync", "{}: Unknown packet {}", peer, packet_id.id()); Ok(()) } }; match result { Err(DownloaderImportError::Invalid) => { - debug!(target:"sync", "{} -> Invalid packet {}", peer, packet_id.id()); + trace!(target:"sync", "{} -> Invalid packet {}", peer, packet_id.id()); io.disable_peer(peer); sync.deactivate_peer(io, peer); }, @@ -96,7 +96,7 @@ impl SyncHandler { }, } } else { - debug!(target: "sync", "{}: Unknown packet {}", peer, packet_id); + trace!(target: "sync", "{}: Unknown packet {}", peer, packet_id); } } @@ -117,14 +117,14 @@ impl SyncHandler { sync.active_peers.remove(&peer_id); if sync.state == SyncState::SnapshotManifest { - // Check if we are asking other peers for - // the snapshot manifest as well. - // If not, return to initial state - let still_asking_manifest = sync.peers.iter() + // Check if we are asking other peers for a snapshot manifest as well. If not, + // set our state to initial state (`Idle` or `WaitingPeers`). + let still_seeking_manifest = sync.peers.iter() .filter(|&(id, p)| sync.active_peers.contains(id) && p.asking == PeerAsking::SnapshotManifest) - .next().is_none(); + .next().is_some(); - if still_asking_manifest { + if !still_seeking_manifest { + warn!(target: "snapshot_sync", "The peer we were downloading a snapshot from ({}) went away. Retrying.", peer_id); sync.state = ChainSync::get_init_state(sync.warp_sync, io.chain()); } } @@ -371,18 +371,18 @@ impl SyncHandler { let block_set = sync.peers.get(&peer_id).and_then(|p| p.block_set).unwrap_or(BlockSet::NewBlocks); if !sync.reset_peer_asking(peer_id, PeerAsking::BlockHeaders) { - debug!(target: "sync", "{}: Ignored unexpected headers", peer_id); + trace!(target: "sync", "{}: Ignored unexpected headers", peer_id); return Ok(()); } let expected_hash = match expected_hash { Some(hash) => hash, None => { - debug!(target: "sync", "{}: Ignored unexpected headers (expected_hash is None)", peer_id); + trace!(target: "sync", "{}: Ignored unexpected headers (expected_hash is None)", peer_id); return Ok(()); } }; if !allowed { - debug!(target: "sync", "{}: Ignored unexpected headers (peer not allowed)", peer_id); + trace!(target: "sync", "{}: Ignored unexpected headers (peer not allowed)", peer_id); return Ok(()); } @@ -466,12 +466,12 @@ impl SyncHandler { /// Called when snapshot manifest is downloaded from a peer. fn on_snapshot_manifest(sync: &mut ChainSync, io: &mut dyn SyncIo, peer_id: PeerId, r: &Rlp) -> Result<(), DownloaderImportError> { if !sync.peers.get(&peer_id).map_or(false, |p| p.can_sync()) { - trace!(target: "sync", "Ignoring snapshot manifest from unconfirmed peer {}", peer_id); + trace!(target: "snapshot_sync", "Ignoring snapshot manifest from unconfirmed peer {}", peer_id); return Ok(()); } sync.clear_peer_download(peer_id); if !sync.reset_peer_asking(peer_id, PeerAsking::SnapshotManifest) || sync.state != SyncState::SnapshotManifest { - trace!(target: "sync", "{}: Ignored unexpected/expired manifest", peer_id); + trace!(target: "snapshot_sync", "{}: Ignored unexpected/expired manifest", peer_id); return Ok(()); } @@ -482,10 +482,12 @@ impl SyncHandler { .map_or(false, |(l, h)| manifest.version >= l && manifest.version <= h); if !is_supported_version { - trace!(target: "sync", "{}: Snapshot manifest version not supported: {}", peer_id, manifest.version); + warn!(target: "snapshot_sync", "{}: Snapshot manifest version not supported: {}", peer_id, manifest.version); return Err(DownloaderImportError::Invalid); } sync.snapshot.reset_to(&manifest, &keccak(manifest_rlp.as_raw())); + debug!(target: "snapshot_sync", "{}: Peer sent a snapshot manifest we can use. Block number #{}, block chunks: {}, state chunks: {}", + peer_id, manifest.block_number, manifest.block_hashes.len(), manifest.state_hashes.len()); io.snapshot_service().begin_restore(manifest); sync.state = SyncState::SnapshotData; @@ -495,12 +497,12 @@ impl SyncHandler { /// Called when snapshot data is downloaded from a peer. fn on_snapshot_data(sync: &mut ChainSync, io: &mut dyn SyncIo, peer_id: PeerId, r: &Rlp) -> Result<(), DownloaderImportError> { if !sync.peers.get(&peer_id).map_or(false, |p| p.can_sync()) { - trace!(target: "sync", "Ignoring snapshot data from unconfirmed peer {}", peer_id); + trace!(target: "snapshot_sync", "Ignoring snapshot data from unconfirmed peer {}", peer_id); return Ok(()); } sync.clear_peer_download(peer_id); if !sync.reset_peer_asking(peer_id, PeerAsking::SnapshotData) || (sync.state != SyncState::SnapshotData && sync.state != SyncState::SnapshotWaiting) { - trace!(target: "sync", "{}: Ignored unexpected snapshot data", peer_id); + trace!(target: "snapshot_sync", "{}: Ignored unexpected snapshot data", peer_id); return Ok(()); } @@ -508,12 +510,12 @@ impl SyncHandler { let status = io.snapshot_service().status(); match status { RestorationStatus::Inactive | RestorationStatus::Failed => { - trace!(target: "sync", "{}: Snapshot restoration aborted", peer_id); + trace!(target: "snapshot_sync", "{}: Snapshot restoration status: {:?}", peer_id, status); sync.state = SyncState::WaitingPeers; // only note bad if restoration failed. if let (Some(hash), RestorationStatus::Failed) = (sync.snapshot.snapshot_hash(), status) { - trace!(target: "sync", "Noting snapshot hash {} as bad", hash); + debug!(target: "snapshot_sync", "Marking snapshot manifest hash {} as bad", hash); sync.snapshot.note_bad(hash); } @@ -521,30 +523,30 @@ impl SyncHandler { return Ok(()); }, RestorationStatus::Initializing { .. } => { - trace!(target: "warp", "{}: Snapshot restoration is initializing", peer_id); + trace!(target: "snapshot_sync", "{}: Snapshot restoration is initializing. Can't accept data right now.", peer_id); return Ok(()); } RestorationStatus::Finalizing => { - trace!(target: "warp", "{}: Snapshot finalizing restoration", peer_id); + trace!(target: "snapshot_sync", "{}: Snapshot finalizing restoration. Can't accept data right now.", peer_id); return Ok(()); } RestorationStatus::Ongoing { .. } => { - trace!(target: "sync", "{}: Snapshot restoration is ongoing", peer_id); + trace!(target: "snapshot_sync", "{}: Snapshot restoration is ongoing", peer_id); }, } let snapshot_data: Bytes = r.val_at(0)?; match sync.snapshot.validate_chunk(&snapshot_data) { Ok(ChunkType::Block(hash)) => { - trace!(target: "sync", "{}: Processing block chunk", peer_id); + trace!(target: "snapshot_sync", "{}: Processing block chunk", peer_id); io.snapshot_service().restore_block_chunk(hash, snapshot_data); } Ok(ChunkType::State(hash)) => { - trace!(target: "sync", "{}: Processing state chunk", peer_id); + trace!(target: "snapshot_sync", "{}: Processing state chunk", peer_id); io.snapshot_service().restore_state_chunk(hash, snapshot_data); } Err(()) => { - trace!(target: "sync", "{}: Got bad snapshot chunk", peer_id); + trace!(target: "snapshot_sync", "{}: Got bad snapshot chunk", peer_id); io.disconnect_peer(peer_id); return Ok(()); } @@ -566,7 +568,7 @@ impl SyncHandler { let warp_protocol = warp_protocol_version != 0; let private_tx_protocol = warp_protocol_version >= PAR_PROTOCOL_VERSION_3.0; let peer = PeerInfo { - protocol_version: protocol_version, + protocol_version, network_id: r.val_at(1)?, difficulty: Some(r.val_at(2)?), latest_hash: r.val_at(3)?, @@ -595,7 +597,8 @@ impl SyncHandler { latest:{}, \ genesis:{}, \ snapshot:{:?}, \ - private_tx_enabled:{})", + private_tx_enabled:{}, \ + client_version: {})", peer_id, peer.protocol_version, peer.network_id, @@ -603,7 +606,8 @@ impl SyncHandler { peer.latest_hash, peer.genesis, peer.snapshot_number, - peer.private_tx_enabled + peer.private_tx_enabled, + peer.client_version, ); if io.is_expired() { trace!(target: "sync", "Status packet from expired session {}:{}", peer_id, io.peer_version(peer_id)); diff --git a/ethcore/sync/src/chain/mod.rs b/ethcore/sync/src/chain/mod.rs index c37a7a6a04a..488e358ced3 100644 --- a/ethcore/sync/src/chain/mod.rs +++ b/ethcore/sync/src/chain/mod.rs @@ -115,7 +115,7 @@ use ethereum_types::{H256, U256}; use fastmap::{H256FastMap, H256FastSet}; use futures::sync::mpsc as futures_mpsc; use keccak_hash::keccak; -use log::{error, trace, debug}; +use log::{error, trace, debug, warn}; use network::client_version::ClientVersion; use network::{self, PeerId, PacketId}; use parity_util_mem::{MallocSizeOfExt, malloc_size_of_is_0}; @@ -172,18 +172,29 @@ const MAX_NEW_BLOCK_AGE: BlockNumber = 20; // maximal packet size with transactions (cannot be greater than 16MB - protocol limitation). // keep it under 8MB as well, cause it seems that it may result oversized after compression. const MAX_TRANSACTION_PACKET_SIZE: usize = 5 * 1024 * 1024; -// Min number of blocks to be behind for a snapshot sync +// Min number of blocks to be behind the tip for a snapshot sync to be considered useful to us. const SNAPSHOT_RESTORE_THRESHOLD: BlockNumber = 30000; +/// We prefer to sync snapshots that are available from this many peers. If we have not found a +/// snapshot available from `SNAPSHOT_MIN_PEERS` peers within `WAIT_PEERS_TIMEOUT`, then we make do +/// with a single peer to sync from. const SNAPSHOT_MIN_PEERS: usize = 3; - -const MAX_SNAPSHOT_CHUNKS_DOWNLOAD_AHEAD: usize = 3; - -const WAIT_PEERS_TIMEOUT: Duration = Duration::from_secs(5); -const STATUS_TIMEOUT: Duration = Duration::from_secs(5); +/// To keep memory from growing uncontrollably we restore chunks as we download them and write them +/// to disk only after we have processed them; we also want to avoid pausing the chunk download too +/// often, so we allow a little bit of leeway here and let the downloading be +/// `MAX_SNAPSHOT_CHUNKS_DOWNLOAD_AHEAD` chunks ahead of the restoration. +const MAX_SNAPSHOT_CHUNKS_DOWNLOAD_AHEAD: usize = 5; + +/// Time to wait for snapshotting peers to show up with a snapshot we want to use. Beyond this time, +/// a single peer is enough to start downloading. +const WAIT_PEERS_TIMEOUT: Duration = Duration::from_secs(10); +/// Time to wait for a peer to start being useful to us in some form. After this they are +/// disconnected. +const STATUS_TIMEOUT: Duration = Duration::from_secs(10); const HEADERS_TIMEOUT: Duration = Duration::from_secs(15); const BODIES_TIMEOUT: Duration = Duration::from_secs(20); const RECEIPTS_TIMEOUT: Duration = Duration::from_secs(10); const FORK_HEADER_TIMEOUT: Duration = Duration::from_secs(3); +/// Max time to wait for the Snapshot Manifest packet to arrive from a peer after it's being asked. const SNAPSHOT_MANIFEST_TIMEOUT: Duration = Duration::from_secs(5); const SNAPSHOT_DATA_TIMEOUT: Duration = Duration::from_secs(120); const PRIVATE_STATE_TIMEOUT: Duration = Duration::from_secs(120); @@ -276,7 +287,7 @@ impl SyncStatus { } #[derive(PartialEq, Eq, Debug, Clone)] -/// Peer data type requested +/// Peer data type requested from a peer by us. pub enum PeerAsking { Nothing, ForkHeader, @@ -296,7 +307,7 @@ pub enum BlockSet { /// Missing old blocks OldBlocks, } -#[derive(Clone, Eq, PartialEq)] +#[derive(Clone, Eq, PartialEq, Debug)] pub enum ForkConfirmation { /// Fork block confirmation pending. Unconfirmed, @@ -306,7 +317,7 @@ pub enum ForkConfirmation { Confirmed, } -#[derive(Clone)] +#[derive(Clone, Debug)] /// Syncing peer information pub struct PeerInfo { /// eth protocol version @@ -319,7 +330,7 @@ pub struct PeerInfo { latest_hash: H256, /// Peer total difficulty if known difficulty: Option, - /// Type of data currenty being requested from peer. + /// Type of data currently being requested by us from a peer. asking: PeerAsking, /// A set of block numbers being requested asking_blocks: Vec, @@ -455,6 +466,7 @@ impl ChainSyncApi { /// /// NOTE This method should only handle stuff that can be canceled and would reach other peers /// by other means. + /// Called every `PRIORITY_TIMER` (0.25sec) pub fn process_priority_queue(&self, io: &mut dyn SyncIo) { fn check_deadline(deadline: Instant) -> Option { let now = Instant::now(); @@ -589,12 +601,26 @@ impl ChainSync { peers } + /// Reset the client to its initial state: + /// - if warp sync is enabled, start looking for peers to sync a snapshot from + /// - if `--warp-barrier` is used, ensure we're not synced beyond the barrier and start + /// looking for peers to sync a snapshot from + /// - otherwise, go `Idle`. fn get_init_state(warp_sync: WarpSync, chain: &dyn BlockChainClient) -> SyncState { let best_block = chain.chain_info().best_block_number; match warp_sync { - WarpSync::Enabled => SyncState::WaitingPeers, - WarpSync::OnlyAndAfter(block) if block > best_block => SyncState::WaitingPeers, - _ => SyncState::Idle, + WarpSync::Enabled => { + debug!(target: "sync", "Setting the initial state to `WaitingPeers`. Our best block: #{}; warp_sync: {:?}", best_block, warp_sync); + SyncState::WaitingPeers + }, + WarpSync::OnlyAndAfter(block) if block > best_block => { + debug!(target: "sync", "Setting the initial state to `WaitingPeers`. Our best block: #{}; warp_sync: {:?}", best_block, warp_sync); + SyncState::WaitingPeers + }, + _ => { + debug!(target: "sync", "Setting the initial state to `Idle`. Our best block: #{}", best_block); + SyncState::Idle + }, } } } @@ -615,7 +641,7 @@ pub struct ChainSync { state: SyncState, /// Last block number for the start of sync starting_block: BlockNumber, - /// Highest block number seen + /// Highest block number seen on the network. highest_block: Option, /// All connected peers peers: Peers, @@ -687,7 +713,7 @@ impl ChainSync { sync } - /// Returns synchonization status + /// Returns synchronization status pub fn status(&self) -> SyncStatus { let last_imported_number = self.new_blocks.last_imported_block_number(); SyncStatus { @@ -745,7 +771,7 @@ impl ChainSync { receiver } - /// notify all subscibers of a new SyncState + /// Notify all subscribers of a new SyncState fn notify_sync_state(&mut self, state: SyncState) { // remove any sender whose receiving end has been dropped self.status_sinks.retain(|sender| { @@ -765,7 +791,7 @@ impl ChainSync { fn reset(&mut self, io: &mut dyn SyncIo, state: Option) { self.new_blocks.reset(); let chain_info = io.chain().chain_info(); - for (_, ref mut p) in &mut self.peers { + for (_, mut p) in &mut self.peers { if p.block_set != Some(BlockSet::OldBlocks) { p.reset_asking(); if p.difficulty.is_none() { @@ -787,10 +813,12 @@ impl ChainSync { pub fn reset_and_continue(&mut self, io: &mut dyn SyncIo) { trace!(target: "sync", "Restarting"); if self.state == SyncState::SnapshotData { - debug!(target:"sync", "Aborting snapshot restore"); + debug!(target:"snapshot_sync", "Aborting snapshot restore"); io.snapshot_service().abort_restore(); } self.snapshot.clear(); + // Passing `None` here means we'll end up in either `SnapshotWaiting` or `Idle` depending on + // the warp sync settings. self.reset(io, None); self.continue_sync(io); } @@ -798,17 +826,17 @@ impl ChainSync { /// Remove peer from active peer set. Peer will be reactivated on the next sync /// round. fn deactivate_peer(&mut self, _io: &mut dyn SyncIo, peer_id: PeerId) { - trace!(target: "sync", "Deactivating peer {}", peer_id); + debug!(target: "sync", "Deactivating peer {}", peer_id); self.active_peers.remove(&peer_id); } + /// Decide if we should start downloading a snapshot and from who. Called once per second. fn maybe_start_snapshot_sync(&mut self, io: &mut dyn SyncIo) { if !self.warp_sync.is_enabled() || io.snapshot_service().supported_versions().is_none() { - trace!(target: "sync", "Skipping warp sync. Disabled or not supported."); return; } - if self.state != SyncState::WaitingPeers && self.state != SyncState::Blocks && self.state != SyncState::Waiting { - trace!(target: "sync", "Skipping warp sync. State: {:?}", self.state); + use SyncState::*; + if self.state != WaitingPeers && self.state != Blocks && self.state != Waiting { return; } // Make sure the snapshot block is not too far away from best block and network best block and @@ -816,71 +844,112 @@ impl ChainSync { let our_best_block = io.chain().chain_info().best_block_number; let fork_block = self.fork_block.map_or(0, |(n, _)| n); - let (best_hash, max_peers, snapshot_peers) = { - let expected_warp_block = match self.warp_sync { - WarpSync::OnlyAndAfter(block) => block, - _ => 0, - }; - //collect snapshot infos from peers - let snapshots = self.peers.iter() - .filter(|&(_, p)| p.is_allowed() && p.snapshot_number.map_or(false, |sn| - // Snapshot must be old enough that it's usefull to sync with it - our_best_block < sn && (sn - our_best_block) > SNAPSHOT_RESTORE_THRESHOLD && - // Snapshot must have been taken after the Fork - sn > fork_block && - // Snapshot must be greater than the warp barrier if any - sn > expected_warp_block && - // If we know a highest block, snapshot must be recent enough - self.highest_block.map_or(true, |highest| { - highest < sn || (highest - sn) <= SNAPSHOT_RESTORE_THRESHOLD - }) - )) - .filter_map(|(p, peer)| peer.snapshot_hash.map(|hash| (p, hash.clone()))) - .filter(|&(_, ref hash)| !self.snapshot.is_known_bad(hash)); + let expected_warp_block = match self.warp_sync { + WarpSync::OnlyAndAfter(warp_block) => { + if our_best_block >= warp_block { + trace!(target: "snapshot_sync", + "Our best block (#{}) is already beyond the warp barrier block (#{})", + our_best_block, warp_block); + return; + } + warp_block + }, + _ => 0, + }; + // Collect snapshot info from peers and check if we can use their snapshots to sync. + let (best_snapshot_block, best_hash, max_peers, snapshot_peers) = { + let mut snapshots = self.peers.iter() + .filter(|&(_, p)| + // filter out expired peers and peers from whom we do not have fork confirmation. + p.is_allowed() && + p.snapshot_number.map_or(false, |sn| + // Snapshot must be sufficiently better than what we have that it's useful to + // sync with it: more than 30k blocks beyond our best block + our_best_block < sn && (sn - our_best_block) > SNAPSHOT_RESTORE_THRESHOLD && + // Snapshot must have been taken after the fork block (if any is configured) + sn > fork_block && + // Snapshot must be greater or equal to the warp barrier, if any + sn >= expected_warp_block + ) + ) + .filter_map(|(p, peer)| { + peer.snapshot_hash.map(|hash| (p, hash)) + .filter(|(_, hash)| !self.snapshot.is_known_bad(&hash) ) + .and_then(|(p, hash)| peer.snapshot_number.map(|n| (*p, n, hash) ) ) + }) + .collect::>(); + + // Sort collection of peers by highest block number. + snapshots.sort_by(|&(_, ref b1, _), &(_, ref b2, _)| b2.cmp(b1) ); let mut snapshot_peers = HashMap::new(); let mut max_peers: usize = 0; let mut best_hash = None; - for (p, hash) in snapshots { + let mut best_snapshot_block = None; + // Of the available snapshots, find the one seeded by the most peers. On a tie, the + // snapshot closest to the tip will be used (unfortunately this is the common case). + for (p, snapshot_block, hash) in snapshots { let peers = snapshot_peers.entry(hash).or_insert_with(Vec::new); - peers.push(*p); + peers.push(p); if peers.len() > max_peers { + trace!(target: "snapshot_sync", "{} is the new best snapshotting peer, has snapshot at block #{}/{}", p, snapshot_block, hash); max_peers = peers.len(); best_hash = Some(hash); + best_snapshot_block = Some(snapshot_block); } } - (best_hash, max_peers, snapshot_peers) + (best_snapshot_block, best_hash, max_peers, snapshot_peers) }; - - let timeout = (self.state == SyncState::WaitingPeers) && self.sync_start_time.map_or(false, |t| t.elapsed() > WAIT_PEERS_TIMEOUT); - - if let (Some(hash), Some(peers)) = (best_hash, best_hash.map_or(None, |h| snapshot_peers.get(&h))) { + // If we've waited long enough (10sec), a single peer will have to be enough for the snapshot sync to start. + let timeout = (self.state == WaitingPeers) && + self.sync_start_time.map_or(false, |t| t.elapsed() > WAIT_PEERS_TIMEOUT); + + + if let (Some(block), Some(hash), Some(peers)) = ( + best_snapshot_block, + best_hash, + best_hash.map_or(None, |h| snapshot_peers.get(&h)) + ) { + trace!(target: "snapshot_sync", "We can sync a snapshot at #{:?}/{:?} from {} peer(s): {:?}", + best_snapshot_block, best_hash, max_peers, snapshot_peers.values()); if max_peers >= SNAPSHOT_MIN_PEERS { - trace!(target: "sync", "Starting confirmed snapshot sync {:?} with {:?}", hash, peers); + debug!(target: "snapshot_sync", "Starting confirmed snapshot sync for a snapshot at #{}/{:?} with peer {:?}", block, hash, peers); self.start_snapshot_sync(io, peers); } else if timeout { - trace!(target: "sync", "Starting unconfirmed snapshot sync {:?} with {:?}", hash, peers); + debug!(target: "snapshot_sync", "Starting unconfirmed snapshot sync for a snapshot at #{}/{:?} with peer {:?}", block, hash, peers); self.start_snapshot_sync(io, peers); + } else { + trace!(target: "snapshot_sync", "Waiting a little more to let more snapshot peers connect.") + } + } else if timeout { + if !self.warp_sync.is_warp_only() { + debug!(target: "snapshot_sync", "Not syncing snapshots (or none found), proceeding with normal sync."); + self.set_state(SyncState::Idle); + self.continue_sync(io); + } else { + warn!(target: "snapshot_sync", "No snapshots currently available at #{}. Try using a smaller value for --warp-barrier", expected_warp_block); } - } else if timeout && !self.warp_sync.is_warp_only() { - trace!(target: "sync", "No snapshots found, starting full sync"); - self.set_state(SyncState::Idle); - self.continue_sync(io); } } + /// Start a snapshot with all peers that we are not currently asking something else from. If + /// we're already snapshotting with a peer, set sync state to `SnapshotData` and continue + /// fetching the snapshot. Note that we only ever sync snapshots from one peer so here we send + /// out the request for a manifest to all the peers that have it and start syncing the snapshot + /// with the first that responds. fn start_snapshot_sync(&mut self, io: &mut dyn SyncIo, peers: &[PeerId]) { if !self.snapshot.have_manifest() { for p in peers { if self.peers.get(p).map_or(false, |p| p.asking == PeerAsking::Nothing) { + // When we get a response we call `SyncHandler::on_snapshot_manifest` SyncRequester::request_snapshot_manifest(self, io, *p); } } self.set_state(SyncState::SnapshotManifest); - trace!(target: "sync", "New snapshot sync with {:?}", peers); + trace!(target: "snapshot_sync", "New snapshot sync with {:?}", peers); } else { self.set_state(SyncState::SnapshotData); - trace!(target: "sync", "Resumed snapshot sync with {:?}", peers); + trace!(target: "snapshot_sync", "Resumed snapshot sync with {:?}", peers); } } @@ -910,7 +979,8 @@ impl ChainSync { } } - /// Resume downloading + /// Resume downloading. + /// Called every `CONTINUE_SYNC_TIMER` (2.5sec) pub fn continue_sync(&mut self, io: &mut dyn SyncIo) { if self.state == SyncState::Waiting { trace!(target: "sync", "Waiting for the block queue"); @@ -927,7 +997,7 @@ impl ChainSync { ).collect(); if peers.len() > 0 { - trace!( + debug!( target: "sync", "Syncing with peers: {} active, {} available, {} total", self.active_peers.len(), peers.len(), self.peers.len() @@ -943,9 +1013,8 @@ impl ChainSync { } } - if - (self.state == SyncState::Blocks || self.state == SyncState::NewBlocks) && - !self.peers.values().any(|p| p.asking != PeerAsking::Nothing && p.block_set != Some(BlockSet::OldBlocks) && p.can_sync()) + if (self.state == SyncState::Blocks || self.state == SyncState::NewBlocks) + && !self.peers.values().any(|p| p.asking != PeerAsking::Nothing && p.block_set != Some(BlockSet::OldBlocks) && p.can_sync()) { self.complete_sync(io); } @@ -987,13 +1056,14 @@ impl ChainSync { let higher_difficulty = peer_difficulty.map_or(true, |pd| pd > syncing_difficulty); if force || higher_difficulty || self.old_blocks.is_some() { match self.state { - SyncState::WaitingPeers => { + SyncState::WaitingPeers if peer_snapshot_number > 0 => { trace!( - target: "sync", - "Checking snapshot sync: {} vs {} (peer: {})", + target: "snapshot_sync", + "{}: Potential snapshot sync peer; their highest block: #{} vs our highest: #{} (peer: {})", + peer_id, peer_snapshot_number, chain_info.best_block_number, - peer_id + io.peer_enode(peer_id).unwrap_or_else(|| "enode://???".to_string()), ); self.maybe_start_snapshot_sync(io); }, @@ -1038,17 +1108,18 @@ impl ChainSync { }, SyncState::SnapshotData => { match io.snapshot_service().status() { - RestorationStatus::Ongoing { state_chunks_done, block_chunks_done, .. } => { + RestorationStatus::Ongoing { state_chunks_done, block_chunks_done, state_chunks, block_chunks } => { // Initialize the snapshot if not already done - self.snapshot.initialize(io.snapshot_service()); + self.snapshot.initialize(io.snapshot_service(), block_chunks as usize + state_chunks as usize); if self.snapshot.done_chunks() - (state_chunks_done + block_chunks_done) as usize > MAX_SNAPSHOT_CHUNKS_DOWNLOAD_AHEAD { - trace!(target: "sync", "Snapshot queue full, pausing sync"); + trace!(target: "snapshot_sync", "Snapshot queue full, pausing sync"); self.set_state(SyncState::SnapshotWaiting); return; } }, - RestorationStatus::Initializing { .. } => { - trace!(target: "warp", "Snapshot is stil initializing."); + RestorationStatus::Initializing { state_chunks, block_chunks, chunks_done } => { + debug!(target: "snapshot_sync", "Snapshot is initializing: state chunks={}, block chunks={}, chunks done={}", + state_chunks, block_chunks, chunks_done); return; }, _ => { @@ -1063,16 +1134,17 @@ impl ChainSync { }, SyncState::SnapshotManifest | //already downloading from other peer SyncState::Waiting | - SyncState::SnapshotWaiting => () + SyncState::SnapshotWaiting => (), + _ => () } } else { trace!(target: "sync", "Skipping peer {}, force={}, td={:?}, our td={}, state={:?}", peer_id, force, peer_difficulty, syncing_difficulty, self.state); } } - /// Clear all blocks/headers marked as being downloaded by a peer. + /// Clear all blocks/headers marked as being downloaded by us from a peer. fn clear_peer_download(&mut self, peer_id: PeerId) { - if let Some(ref peer) = self.peers.get(&peer_id) { + if let Some(peer) = self.peers.get(&peer_id) { match peer.asking { PeerAsking::BlockHeaders => { if let Some(ref hash) = peer.asking_hash { @@ -1150,7 +1222,7 @@ impl ChainSync { peer.expired = false; peer.block_set = None; if peer.asking != asking { - trace!(target:"sync", "Asking {:?} while expected {:?}", peer.asking, asking); + trace!(target:"sync", "{}: Asking {:?} while expected {:?}", peer_id, peer.asking, asking); peer.asking = PeerAsking::Nothing; return false; } else { @@ -1190,6 +1262,9 @@ impl ChainSync { io.respond(StatusPacket.id(), packet.out()) } + /// Check if any tasks we have on-going with a peer is taking too long (if so, disconnect them). + /// Also checks handshaking peers. + /// Called every `PEERS_TIMER` (0.7sec). pub fn maintain_peers(&mut self, io: &mut dyn SyncIo) { let tick = Instant::now(); let mut aborting = Vec::new(); @@ -1206,7 +1281,7 @@ impl ChainSync { PeerAsking::PrivateState => elapsed > PRIVATE_STATE_TIMEOUT, }; if timeout { - debug!(target:"sync", "Timeout {}", peer_id); + debug!(target:"sync", "Peer {} timeout while we were asking them for {:?}; disconnecting.", peer_id, peer.asking); io.disconnect_peer(*peer_id); aborting.push(*peer_id); } @@ -1240,24 +1315,24 @@ impl ChainSync { SyncState::SnapshotWaiting => { match io.snapshot_service().status() { RestorationStatus::Inactive => { - trace!(target:"sync", "Snapshot restoration is complete"); + trace!(target:"snapshot_sync", "Snapshot restoration is complete"); self.restart(io); }, RestorationStatus::Initializing { .. } => { - trace!(target:"sync", "Snapshot restoration is initializing"); + trace!(target:"snapshot_sync", "Snapshot restoration is initializing"); }, RestorationStatus::Finalizing { .. } => { - trace!(target:"sync", "Snapshot finalizing restoration"); + trace!(target:"snapshot_sync", "Snapshot finalizing restoration"); }, RestorationStatus::Ongoing { state_chunks_done, block_chunks_done, .. } => { if !self.snapshot.is_complete() && self.snapshot.done_chunks() - (state_chunks_done + block_chunks_done) as usize <= MAX_SNAPSHOT_CHUNKS_DOWNLOAD_AHEAD { - trace!(target:"sync", "Resuming snapshot sync"); + trace!(target:"snapshot_sync", "Resuming snapshot sync"); self.set_state(SyncState::SnapshotData); self.continue_sync(io); } }, RestorationStatus::Failed => { - trace!(target: "sync", "Snapshot restoration aborted"); + trace!(target: "snapshot_sync", "Snapshot restoration aborted"); self.set_state(SyncState::WaitingPeers); self.snapshot.clear(); self.continue_sync(io); @@ -1322,7 +1397,8 @@ impl ChainSync { ).collect() } - /// Maintain other peers. Send out any new blocks and transactions + /// Maintain other peers. Send out any new blocks and transactions. Called every + /// `MAINTAIN_SYNC_TIMER` (1.1sec). pub fn maintain_sync(&mut self, io: &mut dyn SyncIo) { self.maybe_start_snapshot_sync(io); self.check_resume(io); @@ -1369,7 +1445,8 @@ impl ChainSync { SyncHandler::on_peer_connected(self, io, peer); } - /// propagates new transactions to all peers + /// Propagates new transactions to all peers. + /// Called every `TX_TIMER` (1.3sec). pub fn propagate_new_transactions(&mut self, io: &mut dyn SyncIo) { let deadline = Instant::now() + Duration::from_millis(500); SyncPropagator::propagate_new_transactions(self, io, || { diff --git a/ethcore/sync/src/chain/requester.rs b/ethcore/sync/src/chain/requester.rs index c090f9ca9f7..d91af8902ce 100644 --- a/ethcore/sync/src/chain/requester.rs +++ b/ethcore/sync/src/chain/requester.rs @@ -87,11 +87,11 @@ impl SyncRequester { SyncRequester::send_request(sync, io, peer_id, PeerAsking::ForkHeader, GetBlockHeadersPacket, rlp.out()); } - /// Find some headers or blocks to download for a peer. + /// Find some headers or blocks to download from a peer. pub fn request_snapshot_data(sync: &mut ChainSync, io: &mut dyn SyncIo, peer_id: PeerId) { // find chunk data to download if let Some(hash) = sync.snapshot.needed_chunk() { - if let Some(ref mut peer) = sync.peers.get_mut(&peer_id) { + if let Some(mut peer) = sync.peers.get_mut(&peer_id) { peer.asking_snapshot_data = Some(hash.clone()); } SyncRequester::request_snapshot_chunk(sync, io, peer_id, &hash); @@ -100,9 +100,8 @@ impl SyncRequester { /// Request snapshot manifest from a peer. pub fn request_snapshot_manifest(sync: &mut ChainSync, io: &mut dyn SyncIo, peer_id: PeerId) { - trace!(target: "sync", "{} <- GetSnapshotManifest", peer_id); - let rlp = RlpStream::new_list(0); - SyncRequester::send_request(sync, io, peer_id, PeerAsking::SnapshotManifest, GetSnapshotManifestPacket, rlp.out()); + trace!(target: "sync", "{}: requesting a snapshot manifest", peer_id); + SyncRequester::send_request(sync, io, peer_id, PeerAsking::SnapshotManifest, GetSnapshotManifestPacket, rlp::EMPTY_LIST_RLP.to_vec()); } pub fn request_private_state(sync: &mut ChainSync, io: &mut dyn SyncIo, peer_id: PeerId, hash: &H256) { diff --git a/ethcore/sync/src/chain/supplier.rs b/ethcore/sync/src/chain/supplier.rs index cd322106247..4bc407ea286 100644 --- a/ethcore/sync/src/chain/supplier.rs +++ b/ethcore/sync/src/chain/supplier.rs @@ -116,7 +116,7 @@ impl SyncSupplier { debug!(target:"sync", "Unexpected packet {} from unregistered peer: {}:{}", packet_id, peer, io.peer_version(peer)); return; } - debug!(target: "sync", "{} -> Dispatching packet: {}", peer, packet_id); + trace!(target: "sync", "{} -> Dispatching packet: {}", peer, packet_id); match id { ConsensusDataPacket => { diff --git a/ethcore/sync/src/snapshot_sync.rs b/ethcore/sync/src/snapshot_sync.rs index 84b7b3e71a3..71e1bd57f5c 100644 --- a/ethcore/sync/src/snapshot_sync.rs +++ b/ethcore/sync/src/snapshot_sync.rs @@ -22,20 +22,43 @@ use keccak_hash::keccak; use log::trace; use snapshot::SnapshotService; use common_types::snapshot::ManifestData; +use indexmap::IndexSet; #[derive(PartialEq, Eq, Debug)] +/// The type of data contained in a chunk: state or block. pub enum ChunkType { + /// The chunk contains state data (aka account data). State(H256), + /// The chunk contains block data. Block(H256), } #[derive(Default, MallocSizeOf)] pub struct Snapshot { - pending_state_chunks: Vec, - pending_block_chunks: Vec, + /// List of hashes of the state chunks we need to complete the warp sync from this snapshot. + /// These hashes are contained in the Manifest we downloaded from the peer(s). + /// Note: this is an ordered set so that state restoration happens in order, which keeps + /// memory usage down. + // See https://github.com/paritytech/parity-common/issues/255 + #[ignore_malloc_size_of = "no impl for IndexSet (yet)"] + pending_state_chunks: IndexSet, + /// List of hashes of the block chunks we need to complete the warp sync from this snapshot. + /// These hashes are contained in the Manifest we downloaded from the peer(s). + /// Note: this is an ordered set so that state restoration happens in order, which keeps + /// memory usage down. + // See https://github.com/paritytech/parity-common/issues/255 + #[ignore_malloc_size_of = "no impl for IndexSet (yet)"] + pending_block_chunks: IndexSet, + /// Set of hashes of chunks we are currently downloading. downloading_chunks: HashSet, + /// The set of chunks (block or state) that we have successfully downloaded. completed_chunks: HashSet, + /// The hash of the the `ManifestData` RLP that we're downloading. snapshot_hash: Option, + /// Total number of chunks in the current snapshot. + total_chunks: Option, + /// Set of snapshot hashes we failed to import. We will not try to sync with + /// this snapshot again until restart. bad_hashes: HashSet, initialized: bool, } @@ -47,7 +70,7 @@ impl Snapshot { } /// Sync the Snapshot completed chunks with the Snapshot Service - pub fn initialize(&mut self, snapshot_service: &dyn SnapshotService) { + pub fn initialize(&mut self, snapshot_service: &dyn SnapshotService, total_chunks: usize) { if self.initialized { return; } @@ -57,111 +80,122 @@ impl Snapshot { } trace!( - target: "snapshot", - "Snapshot is now initialized with {} completed chunks.", - self.completed_chunks.len(), + target: "snapshot_sync", + "Snapshot initialized. {}/{} completed chunks.", + self.completed_chunks.len(), total_chunks ); - + self.total_chunks = Some(total_chunks); self.initialized = true; } - /// Clear everything. + /// Clear everything and set `initialized` to false. pub fn clear(&mut self) { self.pending_state_chunks.clear(); self.pending_block_chunks.clear(); self.downloading_chunks.clear(); self.completed_chunks.clear(); self.snapshot_hash = None; + self.total_chunks = None; self.initialized = false; } - /// Check if currently downloading a snapshot. + /// Check if we're currently downloading a snapshot. pub fn have_manifest(&self) -> bool { self.snapshot_hash.is_some() } - /// Reset collection for a manifest RLP + /// Clear the `Snapshot` and reset it with data from a `ManifestData` (i.e. the lists of + /// block&state chunk hashes contained in the `ManifestData`). pub fn reset_to(&mut self, manifest: &ManifestData, hash: &H256) { self.clear(); - self.pending_state_chunks = manifest.state_hashes.clone(); - self.pending_block_chunks = manifest.block_hashes.clone(); + self.pending_state_chunks = IndexSet::from_iter(manifest.state_hashes.clone()); + self.pending_block_chunks = IndexSet::from_iter(manifest.block_hashes.clone()); + self.total_chunks = Some(self.pending_block_chunks.len() + self.pending_state_chunks.len()); self.snapshot_hash = Some(hash.clone()); } - /// Validate chunk and mark it as downloaded + /// Check if the the chunk is known, i.e. downloaded already or currently downloading; if so add + /// it to the `completed_chunks` set. + /// Returns a `ChunkType` with the hash of the chunk. 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: {:x}", hash); + trace!(target: "snapshot_sync", "Already proccessed chunk {:x}. Ignoring.", hash); return Err(()); } self.downloading_chunks.remove(&hash); - if self.pending_block_chunks.iter().any(|h| h == &hash) { - self.completed_chunks.insert(hash.clone()); - return Ok(ChunkType::Block(hash)); - } - if self.pending_state_chunks.iter().any(|h| h == &hash) { - self.completed_chunks.insert(hash.clone()); - return Ok(ChunkType::State(hash)); - } - trace!(target: "sync", "Ignored unknown chunk: {:x}", hash); - Err(()) + + self.pending_block_chunks.take(&hash) + .and_then(|h| { + self.completed_chunks.insert(h); + Some(ChunkType::Block(hash)) + }) + .or( + self.pending_state_chunks.take(&hash) + .and_then(|h| { + self.completed_chunks.insert(h); + Some(ChunkType::State(hash)) + }) + ).ok_or_else(|| { + trace!(target: "snapshot_sync", "Ignoring unknown chunk: {:x}", hash); + () + }) } - /// Find a chunk to download + /// Pick a chunk to download. + /// Note: the order in which chunks are processed is somewhat important. The account state + /// sometimes spills over into more than one chunk and the parts of state that are missing + /// pieces are held in memory while waiting for the next chunk(s) to show up. This means that + /// when chunks are processed out-of-order, memory usage goes up, sometimes significantly (see + /// e.g. https://github.com/paritytech/parity-ethereum/issues/8825). pub fn needed_chunk(&mut self) -> Option { // Find next needed chunk: first block, then state chunks let chunk = { - let chunk_filter = |h| !self.downloading_chunks.contains(h) && !self.completed_chunks.contains(h); - - let needed_block_chunk = self.pending_block_chunks.iter() - .filter(|&h| chunk_filter(h)) + let filter = |h| !self.downloading_chunks.contains(h) && !self.completed_chunks.contains(h); + self.pending_block_chunks.iter() + .find(|&h| filter(h)) + .or(self.pending_state_chunks.iter() + .find(|&h| filter(h)) + ) .map(|h| *h) - .next(); - - // If no block chunks to download, get the state chunks - if needed_block_chunk.is_none() { - self.pending_state_chunks.iter() - .filter(|&h| chunk_filter(h)) - .map(|h| *h) - .next() - } else { - needed_block_chunk - } }; - if let Some(hash) = chunk { self.downloading_chunks.insert(hash.clone()); } chunk } + /// Remove a chunk from the set of chunks we're interested in downloading. pub fn clear_chunk_download(&mut self, hash: &H256) { self.downloading_chunks.remove(hash); } - // note snapshot hash as bad. + /// Mark a snapshot hash as bad. pub fn note_bad(&mut self, hash: H256) { self.bad_hashes.insert(hash); } - // whether snapshot hash is known to be bad. + /// Whether a snapshot hash is known to be bad. pub fn is_known_bad(&self, hash: &H256) -> bool { self.bad_hashes.contains(hash) } + /// Hash of the snapshot we're currently downloading/importing. pub fn snapshot_hash(&self) -> Option { self.snapshot_hash } + /// Total number of chunks in the snapshot we're currently working on (state + block chunks). pub fn total_chunks(&self) -> usize { - self.pending_block_chunks.len() + self.pending_state_chunks.len() + self.total_chunks.unwrap_or_default() } + /// Number of chunks we've processed so far (state and block chunks). pub fn done_chunks(&self) -> usize { self.completed_chunks.len() } + /// Are we done downloading all chunks? pub fn is_complete(&self) -> bool { self.total_chunks() == self.completed_chunks.len() } @@ -214,25 +248,30 @@ mod test { let mut snapshot = Snapshot::new(); let (manifest, mhash, state_chunks, block_chunks) = test_manifest(); snapshot.reset_to(&manifest, &mhash); - assert_eq!(snapshot.done_chunks(), 0); - assert!(snapshot.validate_chunk(&H256::random().as_bytes().to_vec()).is_err()); + assert_eq!(snapshot.done_chunks(), 0, "no chunks done at outset"); + assert!(snapshot.validate_chunk(&H256::random().as_bytes().to_vec()).is_err(), "random chunk is invalid"); + // request all 20 + 20 chunks let requested: Vec = (0..40).map(|_| snapshot.needed_chunk().unwrap()).collect(); - assert!(snapshot.needed_chunk().is_none()); + assert!(snapshot.needed_chunk().is_none(), "no chunks left after all are drained"); let requested_all_block_chunks = manifest.block_hashes.iter() .all(|h| requested.iter().any(|rh| rh == h)); - assert!(requested_all_block_chunks); + assert!(requested_all_block_chunks, "all block chunks in the manifest accounted for"); let requested_all_state_chunks = manifest.state_hashes.iter() .all(|h| requested.iter().any(|rh| rh == h)); - assert!(requested_all_state_chunks); + assert!(requested_all_state_chunks, "all state chunks in the manifest accounted for"); - assert_eq!(snapshot.downloading_chunks.len(), 40); + assert_eq!(snapshot.downloading_chunks.len(), 40, "all requested chunks are downloading"); - assert_eq!(snapshot.validate_chunk(&state_chunks[4]), Ok(ChunkType::State(manifest.state_hashes[4].clone()))); - assert_eq!(snapshot.completed_chunks.len(), 1); - assert_eq!(snapshot.downloading_chunks.len(), 39); + assert_eq!( + snapshot.validate_chunk(&state_chunks[4]), + Ok(ChunkType::State(manifest.state_hashes[4].clone())), + "4th state chunk hash validates as such" + ); + assert_eq!(snapshot.completed_chunks.len(), 1, "after validating a chunk, it's in the completed set"); + assert_eq!(snapshot.downloading_chunks.len(), 39, "after validating a chunk, there's one less in the downloading set"); assert_eq!(snapshot.validate_chunk(&block_chunks[10]), Ok(ChunkType::Block(manifest.block_hashes[10].clone()))); assert_eq!(snapshot.completed_chunks.len(), 2); @@ -250,7 +289,7 @@ mod test { } } - assert!(snapshot.is_complete()); + assert!(snapshot.is_complete(), "when all chunks have been validated, we're done"); assert_eq!(snapshot.done_chunks(), 40); assert_eq!(snapshot.done_chunks(), snapshot.total_chunks()); assert_eq!(snapshot.snapshot_hash(), Some(keccak(manifest.into_rlp()))); diff --git a/ethcore/sync/src/sync_io.rs b/ethcore/sync/src/sync_io.rs index 50fc74afcf7..15b99e649c3 100644 --- a/ethcore/sync/src/sync_io.rs +++ b/ethcore/sync/src/sync_io.rs @@ -50,6 +50,8 @@ pub trait SyncIo { fn peer_version(&self, peer_id: PeerId) -> ClientVersion { ClientVersion::from(peer_id.to_string()) } + /// Returns the peer enode string + fn peer_enode(&self, peer_id: PeerId) -> Option; /// Returns information on p2p session fn peer_session_info(&self, peer_id: PeerId) -> Option; /// Maximum mutually supported ETH protocol version @@ -115,10 +117,6 @@ impl<'s> SyncIo for NetSyncIo<'s> { self.chain } - fn chain_overlay(&self) -> &RwLock> { - self.chain_overlay - } - fn snapshot_service(&self) -> &dyn SnapshotService { self.snapshot_service } @@ -127,12 +125,20 @@ impl<'s> SyncIo for NetSyncIo<'s> { self.private_state.clone() } - fn peer_session_info(&self, peer_id: PeerId) -> Option { - self.network.session_info(peer_id) + fn peer_version(&self, peer_id: PeerId) -> ClientVersion { + self.network.peer_client_version(peer_id) } - fn is_expired(&self) -> bool { - self.network.is_expired() + fn peer_enode(&self, peer_id: PeerId) -> Option { + self.network.session_info(peer_id).and_then(|info| { + info.id.map(|node_id| { + format!("enode:://{}@{}", node_id, info.remote_address) + }) + }) + } + + fn peer_session_info(&self, peer_id: PeerId) -> Option { + self.network.session_info(peer_id) } fn eth_protocol_version(&self, peer_id: PeerId) -> u8 { @@ -143,8 +149,12 @@ impl<'s> SyncIo for NetSyncIo<'s> { self.network.protocol_version(*protocol, peer_id).unwrap_or(0) } - fn peer_version(&self, peer_id: PeerId) -> ClientVersion { - self.network.peer_client_version(peer_id) + fn is_expired(&self) -> bool { + self.network.is_expired() + } + + fn chain_overlay(&self) -> &RwLock> { + self.chain_overlay } fn payload_soft_limit(&self) -> usize { diff --git a/ethcore/sync/src/tests/helpers.rs b/ethcore/sync/src/tests/helpers.rs index 2e91e2490c2..98a4adfe195 100644 --- a/ethcore/sync/src/tests/helpers.rs +++ b/ethcore/sync/src/tests/helpers.rs @@ -114,25 +114,17 @@ impl<'p, C> SyncIo for TestIo<'p, C> where C: FlushingBlockChainClient, C: 'p { self.to_disconnect.insert(peer_id); } - fn is_expired(&self) -> bool { - false - } - fn respond(&mut self, packet_id: PacketId, data: Vec) -> Result<(), network::Error> { - self.packets.push(TestPacket { - data: data, - packet_id: packet_id, - recipient: self.sender.unwrap() - }); + self.packets.push( + TestPacket { data, packet_id, recipient: self.sender.unwrap() } + ); Ok(()) } fn send(&mut self,peer_id: PeerId, packet_id: SyncPacket, data: Vec) -> Result<(), network::Error> { - self.packets.push(TestPacket { - data, - packet_id: packet_id.id(), - recipient: peer_id, - }); + self.packets.push( + TestPacket { data, packet_id: packet_id.id(), recipient: peer_id } + ); Ok(()) } @@ -140,6 +132,14 @@ impl<'p, C> SyncIo for TestIo<'p, C> where C: FlushingBlockChainClient, C: 'p { &*self.chain } + fn snapshot_service(&self) -> &dyn SnapshotService { + self.snapshot_service + } + + fn private_state(&self) -> Option> { + self.private_state_db.clone() + } + fn peer_version(&self, peer_id: PeerId) -> ClientVersion { self.peers_info.get(&peer_id) .cloned() @@ -147,12 +147,8 @@ impl<'p, C> SyncIo for TestIo<'p, C> where C: FlushingBlockChainClient, C: 'p { .into() } - fn snapshot_service(&self) -> &dyn SnapshotService { - self.snapshot_service - } - - fn private_state(&self) -> Option> { - self.private_state_db.clone() + fn peer_enode(&self, _peer_id: usize) -> Option { + unimplemented!() } fn peer_session_info(&self, _peer_id: PeerId) -> Option { @@ -167,6 +163,10 @@ impl<'p, C> SyncIo for TestIo<'p, C> where C: FlushingBlockChainClient, C: 'p { if protocol == &WARP_SYNC_PROTOCOL_ID { PAR_PROTOCOL_VERSION_4.0 } else { self.eth_protocol_version(peer_id) } } + fn is_expired(&self) -> bool { + false + } + fn chain_overlay(&self) -> &RwLock> { &self.overlay } diff --git a/ethcore/types/src/snapshot.rs b/ethcore/types/src/snapshot.rs index 48b27f137e3..7b04bb9eb6e 100644 --- a/ethcore/types/src/snapshot.rs +++ b/ethcore/types/src/snapshot.rs @@ -170,9 +170,9 @@ pub type ChunkSink<'a> = dyn FnMut(&[u8]) -> std::io::Result<()> + 'a; /// Statuses for snapshot restoration. #[derive(PartialEq, Eq, Clone, Copy, Debug)] pub enum RestorationStatus { - /// No restoration. + /// No restoration activity currently. Inactive, - /// Restoration is initializing + /// Restoration is initializing. Initializing { /// Total number of state chunks. state_chunks: u32, @@ -192,7 +192,7 @@ pub enum RestorationStatus { /// Number of block chunks completed. block_chunks_done: u32, }, - /// Finalizing restoration + /// Finalizing restoration. Finalizing, /// Failed restoration. Failed, diff --git a/util/network-devp2p/src/host.rs b/util/network-devp2p/src/host.rs index dba69e33773..47c2d5321c9 100644 --- a/util/network-devp2p/src/host.rs +++ b/util/network-devp2p/src/host.rs @@ -37,7 +37,6 @@ use mio::{ use parity_path::restrict_permissions_owner; use parking_lot::{Mutex, RwLock}; use rlp::{Encodable, RlpStream}; -use rustc_hex::ToHex; use ethcore_io::{IoContext, IoHandler, IoManager, StreamToken, TimerToken}; use parity_crypto::publickey::{Generator, KeyPair, Random, Secret}; diff --git a/util/network/src/lib.rs b/util/network/src/lib.rs index 42bc8d6c3ee..e8ec1cf75a7 100644 --- a/util/network/src/lib.rs +++ b/util/network/src/lib.rs @@ -393,42 +393,42 @@ impl NonReservedPeerMode { #[derive(Clone, Debug, PartialEq, Eq)] pub struct IpFilter { - pub predefined: AllowIP, - pub custom_allow: Vec, - pub custom_block: Vec, + pub predefined: AllowIP, + pub custom_allow: Vec, + pub custom_block: Vec, } impl Default for IpFilter { - fn default() -> Self { - IpFilter { - predefined: AllowIP::All, - custom_allow: vec![], - custom_block: vec![], - } - } + fn default() -> Self { + IpFilter { + predefined: AllowIP::All, + custom_allow: vec![], + custom_block: vec![], + } + } } impl IpFilter { - /// Attempt to parse the peer mode from a string. - pub fn parse(s: &str) -> Result { - let mut filter = IpFilter::default(); - for f in s.split_whitespace() { - match f { - "all" => filter.predefined = AllowIP::All, - "private" => filter.predefined = AllowIP::Private, - "public" => filter.predefined = AllowIP::Public, - "none" => filter.predefined = AllowIP::None, - custom => { - if custom.starts_with("-") { - filter.custom_block.push(IpNetwork::from_str(&custom.to_owned().split_off(1))?) - } else { - filter.custom_allow.push(IpNetwork::from_str(custom)?) - } - } - } - } - Ok(filter) - } + /// Attempt to parse the peer mode from a string. + pub fn parse(s: &str) -> Result { + let mut filter = IpFilter::default(); + for f in s.split_whitespace() { + match f { + "all" => filter.predefined = AllowIP::All, + "private" => filter.predefined = AllowIP::Private, + "public" => filter.predefined = AllowIP::Public, + "none" => filter.predefined = AllowIP::None, + custom => { + if custom.starts_with("-") { + filter.custom_block.push(IpNetwork::from_str(&custom.to_owned().split_off(1))?) + } else { + filter.custom_allow.push(IpNetwork::from_str(custom)?) + } + } + } + } + Ok(filter) + } } /// IP fiter @@ -440,6 +440,6 @@ pub enum AllowIP { Private, /// Connect to public network only Public, - /// Block all addresses - None, + /// Block all addresses + None, } From 80754c34264f35a40173fef5d2f2ad2f30cc181c Mon Sep 17 00:00:00 2001 From: Anton Gavrilov Date: Thu, 31 Oct 2019 16:17:12 +0100 Subject: [PATCH 16/21] Insert explicit warning into the panic hook (#11225) --- parity/main.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/parity/main.rs b/parity/main.rs index 066061cbafd..60ad8cad613 100644 --- a/parity/main.rs +++ b/parity/main.rs @@ -285,6 +285,7 @@ fn main_direct(force_can_restart: bool) -> i32 { let e = exit.clone(); let exiting = exiting.clone(); move |panic_msg| { + warn!("Panic occured, see stderr for details"); eprintln!("{}", panic_msg); if !exiting.swap(true, Ordering::SeqCst) { *e.0.lock() = ExitStatus { From 13729a0f7fbfa5b31de17f68f7a05db1d7da4353 Mon Sep 17 00:00:00 2001 From: Niklas Adolfsson Date: Thu, 31 Oct 2019 17:09:08 +0100 Subject: [PATCH 17/21] [builtin]: support `multiple prices and activations` in chain spec (#11039) * [builtin]: impl new builtin type Have an enum to deserialize either a builtin of a single price or several prices * [builtin]: style cleanup * [builtin]: fix tests * [builtin]: replace boxing with wrapper enum * cleanup * fix: make it backward compatible with old builtin * fix: update chain specs * fix: revert use of `type alias` on enum The CI doesn't use the latest rust. This commit reverts that change * fix: builtin tests * fix: revert use of `type alias` on enum * [basic-authority]: update test-chainspec * fix failing tests * [builtin]: multi-prices add `info field` It might be hard to read chain specs with several activations points. This commit introduces a `info` field which may be used to write some information about the current activation such as: `Istanbul hardfork EIP-1108` or something similar. * fix: bad rebase Co-Authored-By: David * fix(grumbles): make it backward compatible * grumbles: resolve `NOTE` * revert chain specs changes * rename test Co-Authored-By: David * [builtin docs]: price -> Fixed price Co-Authored-By: Andronik Ordian * [json]: address naming grumbles InnerPricing -> PricingInner PriceWithActivationAt -> PricingAt * docs: revert changes for `AltBn128ConstOperations` * [json]: usize -> u64 Use explicit types to cope with platform dependent issues for `usize` * grumble: simplify `spec_backward_compability.json` * docs: add issue link to `TODO` * [builtin]: replace `match` with `map` * [builtin]: add deprecation message `eip1108` params * nits * [json spec tests]: fix json indentation * [json docs]: fix typos * [json]: `compability layer` + deser to BTreeMap Previously we had to match `Pricing::Single` and `PricingMulti` which this fixes. It does by introducing a compability layer and into() implemenentation. In addition, I switched the deserialization to `BTreeMap` instead of `Vec`. That changes the format of the chain spec again * [json]: rename `BuiltinCombat` -> `BuiltinCompat` * Update ethcore/builtin/src/lib.rs Co-Authored-By: David * [json builtin]: improve docs Co-Authored-By: David * [json builtin]: improve docs Co-Authored-By: David * chore(builtin): sort dependencies * [json builtin]: deprecate `eip1108` params * [machine]: add bench for calling builtin contract * [machine]: reduce calls to `Builtin::is_active` * [builtin]: fix nits * [json]: revert breakage of chain specs * [json builtin]: remove `eip1108` params * [chain specs]: update to new format * [machine]: revert changes * [devp2p]: revert change * [builtin]: doc nits --- Cargo.lock | 2 + ethcore/builtin/Cargo.toml | 5 +- ethcore/builtin/src/lib.rs | 536 +++++++++++------- .../basic-authority/res/basic_authority.json | 32 +- ethcore/engines/basic-authority/src/lib.rs | 1 - ethcore/machine/Cargo.toml | 6 + ethcore/machine/benches/builtin_contract.rs | 149 +++++ ethcore/machine/src/test_helpers.rs | 2 - ethcore/res/authority_round.json | 35 +- ...authority_round_block_reward_contract.json | 35 +- ethcore/res/constructor.json | 35 +- ethcore/res/ethereum/builtin_multi_bench.json | 112 ++++ .../builtin_one_activation_bench.json | 54 ++ ethcore/res/ethereum/byzantium_test.json | 35 +- ethcore/res/ethereum/callisto.json | 32 +- ethcore/res/ethereum/classic.json | 32 +- ethcore/res/ethereum/constantinople_test.json | 35 +- ethcore/res/ethereum/eip210_test.json | 35 +- ethcore/res/ethereum/ellaism.json | 35 +- ethcore/res/ethereum/ewc.json | 39 +- ethcore/res/ethereum/expanse.json | 35 +- ethcore/res/ethereum/foundation.json | 35 +- ethcore/res/ethereum/goerli.json | 35 +- ethcore/res/ethereum/istanbul_test.json | 35 +- ethcore/res/ethereum/kotti.json | 35 +- ethcore/res/ethereum/kovan.json | 35 +- ethcore/res/ethereum/kovan_wasm_test.json | 35 +- ethcore/res/ethereum/mcip3_test.json | 35 +- ethcore/res/ethereum/mix.json | 35 +- ethcore/res/ethereum/morden.json | 43 +- ethcore/res/ethereum/musicoin.json | 35 +- ethcore/res/ethereum/poacore.json | 35 +- ethcore/res/ethereum/poasokol.json | 36 +- ethcore/res/ethereum/rinkeby.json | 35 +- ethcore/res/ethereum/ropsten.json | 35 +- ethcore/res/ethereum/st_peters_test.json | 35 +- ethcore/res/ethereum/transition_test.json | 35 +- ethcore/res/ethereum/volta.json | 43 +- ethcore/res/ethereum/xdai.json | 43 +- ethcore/res/instant_seal.json | 35 +- ethcore/res/null.json | 35 +- ethcore/res/spec_backward_compability.json | 155 +++++ ethcore/spec/src/spec.rs | 6 +- json/src/spec/account.rs | 27 +- json/src/spec/builtin.rs | 146 +++-- json/src/spec/spec.rs | 262 +++++---- json/src/spec/state.rs | 2 +- 47 files changed, 1700 insertions(+), 905 deletions(-) create mode 100644 ethcore/machine/benches/builtin_contract.rs create mode 100644 ethcore/res/ethereum/builtin_multi_bench.json create mode 100644 ethcore/res/ethereum/builtin_one_activation_bench.json create mode 100644 ethcore/res/spec_backward_compability.json diff --git a/Cargo.lock b/Cargo.lock index 506ac7f8864..9f44e710c40 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1179,6 +1179,7 @@ dependencies = [ "hex-literal 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "keccak-hash 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "macros 0.1.0", "num 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", "parity-bytes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-crypto 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2565,6 +2566,7 @@ dependencies = [ "account-state 0.1.0", "client-traits 0.1.0", "common-types 0.1.0", + "criterion 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", "ethabi 9.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "ethabi-contract 9.0.0 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/ethcore/builtin/Cargo.toml b/ethcore/builtin/Cargo.toml index f69b65d974b..d36a3e7620d 100644 --- a/ethcore/builtin/Cargo.toml +++ b/ethcore/builtin/Cargo.toml @@ -7,16 +7,17 @@ edition = "2018" [dependencies] bn = { git = "https://github.com/paritytech/bn", default-features = false } +byteorder = "1.3.2" common-types = { path = "../types" } +eip-152 = { path = "../../util/EIP-152" } ethereum-types = "0.8.0" ethjson = { path = "../../json" } keccak-hash = "0.4.0" log = "0.4" +macros = { path = "../../util/macros" } num = { version = "0.1", default-features = false, features = ["bigint"] } parity-bytes = "0.1" -eip-152 = { path = "../../util/EIP-152" } parity-crypto = { version = "0.4.2", features = ["publickey"] } -byteorder = "1.3.2" [dev-dependencies] hex-literal = "0.2.1" diff --git a/ethcore/builtin/src/lib.rs b/ethcore/builtin/src/lib.rs index d0b0e93ec4b..d39f980d30c 100644 --- a/ethcore/builtin/src/lib.rs +++ b/ethcore/builtin/src/lib.rs @@ -16,18 +16,20 @@ //! Standard built-in contracts. +#![warn(missing_docs)] + use std::{ cmp::{max, min}, + collections::BTreeMap, convert::{TryFrom, TryInto}, io::{self, Read, Cursor}, mem::size_of, + str::FromStr }; -use bn; use byteorder::{BigEndian, LittleEndian, ReadBytesExt}; use common_types::errors::EthcoreError; use ethereum_types::{H256, U256}; -use ethjson; use parity_crypto::publickey::{Signature, recover as ec_recover}; use keccak_hash::keccak; use log::{warn, trace}; @@ -43,10 +45,9 @@ pub trait Implementation: Send + Sync { } /// A gas pricing scheme for built-in contracts. -// TODO: refactor this trait, see https://github.com/paritytech/parity-ethereum/issues/11014 trait Pricer: Send + Sync { /// The gas cost of running this built-in for the given input data at block number `at` - fn cost(&self, input: &[u8], at: u64) -> U256; + fn cost(&self, input: &[u8]) -> U256; } /// Pricing for the Blake2 compression function (aka "F"). @@ -55,7 +56,7 @@ trait Pricer: Send + Sync { pub type Blake2FPricer = u64; impl Pricer for Blake2FPricer { - fn cost(&self, input: &[u8], _at: u64) -> U256 { + fn cost(&self, input: &[u8]) -> U256 { const FOUR: usize = std::mem::size_of::(); // Returning zero if the conversion fails is fine because `execute()` will check the length // and bail with the appropriate error. @@ -68,68 +69,81 @@ impl Pricer for Blake2FPricer { } } +/// Pricing model +#[derive(Debug)] +enum Pricing { + AltBn128Pairing(AltBn128PairingPricer), + AltBn128ConstOperations(AltBn128ConstOperations), + Blake2F(Blake2FPricer), + Linear(Linear), + Modexp(ModexpPricer), +} + +impl Pricer for Pricing { + fn cost(&self, input: &[u8]) -> U256 { + match self { + Pricing::AltBn128Pairing(inner) => inner.cost(input), + Pricing::AltBn128ConstOperations(inner) => inner.cost(input), + Pricing::Blake2F(inner) => inner.cost(input), + Pricing::Linear(inner) => inner.cost(input), + Pricing::Modexp(inner) => inner.cost(input), + } + } +} + /// A linear pricing model. This computes a price using a base cost and a cost per-word. +#[derive(Debug)] struct Linear { - base: usize, - word: usize, + base: u64, + word: u64, } /// A special pricing model for modular exponentiation. +#[derive(Debug)] struct ModexpPricer { - divisor: usize, + divisor: u64, } impl Pricer for Linear { - fn cost(&self, input: &[u8], _at: u64) -> U256 { + fn cost(&self, input: &[u8]) -> U256 { U256::from(self.base) + U256::from(self.word) * U256::from((input.len() + 31) / 32) } } -/// alt_bn128 constant operations (add and mul) pricing model. -struct AltBn128ConstOperations { - price: usize, - eip1108_transition_at: u64, - eip1108_transition_price: usize, -} - -impl Pricer for AltBn128ConstOperations { - fn cost(&self, _input: &[u8], at: u64) -> U256 { - if at >= self.eip1108_transition_at { - self.eip1108_transition_price.into() - } else { - self.price.into() - } - } -} - /// alt_bn128 pairing price #[derive(Debug, Copy, Clone)] struct AltBn128PairingPrice { - base: usize, - pair: usize, + base: u64, + pair: u64, } /// alt_bn128_pairing pricing model. This computes a price using a base cost and a cost per pair. +#[derive(Debug)] struct AltBn128PairingPricer { price: AltBn128PairingPrice, - eip1108_transition_at: u64, - eip1108_transition_price: AltBn128PairingPrice, } -impl Pricer for AltBn128PairingPricer { - fn cost(&self, input: &[u8], at: u64) -> U256 { - let price = if at >= self.eip1108_transition_at { - self.eip1108_transition_price - } else { - self.price - }; +/// Pricing for constant alt_bn128 operations (ECADD and ECMUL) +#[derive(Debug, Copy, Clone)] +pub struct AltBn128ConstOperations { + /// Fixed price. + pub price: u64, +} - U256::from(price.base) + U256::from(price.pair) * U256::from(input.len() / 192) +impl Pricer for AltBn128ConstOperations { + fn cost(&self, _input: &[u8]) -> U256 { + self.price.into() + } +} + +impl Pricer for AltBn128PairingPricer { + fn cost(&self, input: &[u8]) -> U256 { + U256::from(self.price.base) + U256::from(self.price.pair) * U256::from(input.len() / 192) } } impl Pricer for ModexpPricer { - fn cost(&self, input: &[u8], _at: u64) -> U256 { + fn cost(&self, input: &[u8]) -> U256 { let mut reader = input.chain(io::repeat(0)); let mut buf = [0; 32]; @@ -154,8 +168,10 @@ impl Pricer for ModexpPricer { let m = max(mod_len, base_len); // read fist 32-byte word of the exponent. - let exp_low = if base_len + 96 >= input.len() as u64 { U256::zero() } else { - let mut buf = [0; 32]; + let exp_low = if base_len + 96 >= input.len() as u64 { + U256::zero() + } else { + buf.iter_mut().for_each(|b| *b = 0); let mut reader = input[(96 + base_len as usize)..].chain(io::repeat(0)); let len = min(exp_len, 32) as usize; reader.read_exact(&mut buf[(32 - len)..]).expect("reading from zero-extended memory cannot fail; qed"); @@ -186,7 +202,7 @@ impl ModexpPricer { match x { x if x <= 64 => x * x, x if x <= 1024 => (x * x) / 4 + 96 * x - 3072, - x => (x * x) / 16 + 480 * x - 199680, + x => (x * x) / 16 + 480 * x - 199_680, } } } @@ -195,114 +211,152 @@ impl ModexpPricer { /// /// Call `cost` to compute cost for the given input, `execute` to execute the contract /// on the given input, and `is_active` to determine whether the contract is active. -/// -/// Unless `is_active` is true, pub struct Builtin { - pricer: Box, - native: Box, - activate_at: u64, + pricer: BTreeMap, + native: EthereumBuiltin, } impl Builtin { /// Simple forwarder for cost. + /// + /// Return the cost of the most recently activated pricer at the current block number. + /// + /// If no pricer is actived `zero` is returned + /// + /// If multiple `activation_at` has the same block number the last one is used + /// (follows `BTreeMap` semantics). + #[inline] pub fn cost(&self, input: &[u8], at: u64) -> U256 { - self.pricer.cost(input, at) + if let Some((_, pricer)) = self.pricer.range(0..=at).last() { + pricer.cost(input) + } else { + U256::zero() + } } /// Simple forwarder for execute. + #[inline] pub fn execute(&self, input: &[u8], output: &mut BytesRef) -> Result<(), &'static str> { self.native.execute(input, output) } /// Whether the builtin is activated at the given block number. + #[inline] pub fn is_active(&self, at: u64) -> bool { - at >= self.activate_at + self.pricer.range(0..=at).last().is_some() } } -impl TryFrom for Builtin { +impl TryFrom for Builtin { type Error = EthcoreError; - fn try_from(b: ethjson::spec::Builtin) -> Result { - let pricer: Box = match b.pricing { - ethjson::spec::Pricing::Blake2F { gas_per_round } => { - Box::new(gas_per_round) - }, - ethjson::spec::Pricing::Linear(linear) => { - Box::new(Linear { + fn try_from(b: ethjson::spec::builtin::Builtin) -> Result { + let native = EthereumBuiltin::from_str(&b.name)?; + let mut pricer = BTreeMap::new(); + + for (activate_at, p) in b.pricing { + pricer.insert(activate_at, p.price.into()); + } + + Ok(Self { pricer, native }) + } +} + +impl From for Pricing { + fn from(pricing: ethjson::spec::builtin::Pricing) -> Self { + match pricing { + ethjson::spec::builtin::Pricing::Blake2F { gas_per_round } => { + Pricing::Blake2F(gas_per_round) + } + ethjson::spec::builtin::Pricing::Linear(linear) => { + Pricing::Linear(Linear { base: linear.base, word: linear.word, }) } - ethjson::spec::Pricing::Modexp(exp) => { - Box::new(ModexpPricer { + ethjson::spec::builtin::Pricing::Modexp(exp) => { + Pricing::Modexp(ModexpPricer { divisor: if exp.divisor == 0 { - warn!(target: "builtin", "Zero modexp divisor specified. Falling back to default."); + warn!(target: "builtin", "Zero modexp divisor specified. Falling back to default: 10."); 10 } else { exp.divisor } }) } - ethjson::spec::Pricing::AltBn128Pairing(pricer) => { - Box::new(AltBn128PairingPricer { + ethjson::spec::builtin::Pricing::AltBn128Pairing(pricer) => { + Pricing::AltBn128Pairing(AltBn128PairingPricer { price: AltBn128PairingPrice { base: pricer.base, pair: pricer.pair, }, - eip1108_transition_at: b.eip1108_transition.map_or(u64::max_value(), Into::into), - eip1108_transition_price: AltBn128PairingPrice { - base: pricer.eip1108_transition_base, - pair: pricer.eip1108_transition_pair, - }, }) } - ethjson::spec::Pricing::AltBn128ConstOperations(pricer) => { - Box::new(AltBn128ConstOperations { - price: pricer.price, - eip1108_transition_price: pricer.eip1108_transition_price, - eip1108_transition_at: b.eip1108_transition.map_or(u64::max_value(), Into::into) + ethjson::spec::builtin::Pricing::AltBn128ConstOperations(pricer) => { + Pricing::AltBn128ConstOperations(AltBn128ConstOperations { + price: pricer.price }) } - }; - - let native = ethereum_builtin(&b.name)?; - Ok(Builtin { - pricer, - native, - activate_at: b.activate_at.map_or(0, Into::into), - }) + } } } -/// Ethereum built-in factory. -fn ethereum_builtin(name: &str) -> Result, EthcoreError> { - let implementation = match name { - "identity" => Box::new(Identity) as Box, - "ecrecover" => Box::new(EcRecover) as Box, - "sha256" => Box::new(Sha256) as Box, - "ripemd160" => Box::new(Ripemd160) as Box, - "modexp" => Box::new(Modexp) as Box, - "alt_bn128_add" => Box::new(Bn128Add) as Box, - "alt_bn128_mul" => Box::new(Bn128Mul) as Box, - "alt_bn128_pairing" => Box::new(Bn128Pairing) as Box, - "blake2_f" => Box::new(Blake2F) as Box, - _ => return Err(EthcoreError::Msg(format!("invalid builtin name: {}", name))), - }; - Ok(implementation) +/// Ethereum builtins: +enum EthereumBuiltin { + /// The identity function + Identity(Identity), + /// ec recovery + EcRecover(EcRecover), + /// sha256 + Sha256(Sha256), + /// ripemd160 + Ripemd160(Ripemd160), + /// modexp (EIP 198) + Modexp(Modexp), + /// alt_bn128_add + Bn128Add(Bn128Add), + /// alt_bn128_mul + Bn128Mul(Bn128Mul), + /// alt_bn128_pairing + Bn128Pairing(Bn128Pairing), + /// blake2_f (The Blake2 compression function F, EIP-152) + Blake2F(Blake2F) } -// Ethereum builtins: -// -// - The identity function -// - ec recovery -// - sha256 -// - ripemd160 -// - modexp (EIP198) -// - alt_bn128_add -// - alt_bn128_mul -// - alt_bn128_pairing -// - blake2_f (The Blake2 compression function F, EIP-152) +impl FromStr for EthereumBuiltin { + type Err = EthcoreError; + + fn from_str(name: &str) -> Result { + match name { + "identity" => Ok(EthereumBuiltin::Identity(Identity)), + "ecrecover" => Ok(EthereumBuiltin::EcRecover(EcRecover)), + "sha256" => Ok(EthereumBuiltin::Sha256(Sha256)), + "ripemd160" => Ok(EthereumBuiltin::Ripemd160(Ripemd160)), + "modexp" => Ok(EthereumBuiltin::Modexp(Modexp)), + "alt_bn128_add" => Ok(EthereumBuiltin::Bn128Add(Bn128Add)), + "alt_bn128_mul" => Ok(EthereumBuiltin::Bn128Mul(Bn128Mul)), + "alt_bn128_pairing" => Ok(EthereumBuiltin::Bn128Pairing(Bn128Pairing)), + "blake2_f" => Ok(EthereumBuiltin::Blake2F(Blake2F)), + _ => return Err(EthcoreError::Msg(format!("invalid builtin name: {}", name))), + } + } +} + +impl Implementation for EthereumBuiltin { + fn execute(&self, input: &[u8], output: &mut BytesRef) -> Result<(), &'static str> { + match self { + EthereumBuiltin::Identity(inner) => inner.execute(input, output), + EthereumBuiltin::EcRecover(inner) => inner.execute(input, output), + EthereumBuiltin::Sha256(inner) => inner.execute(input, output), + EthereumBuiltin::Ripemd160(inner) => inner.execute(input, output), + EthereumBuiltin::Modexp(inner) => inner.execute(input, output), + EthereumBuiltin::Bn128Add(inner) => inner.execute(input, output), + EthereumBuiltin::Bn128Mul(inner) => inner.execute(input, output), + EthereumBuiltin::Bn128Pairing(inner) => inner.execute(input, output), + EthereumBuiltin::Blake2F(inner) => inner.execute(input, output), + } + } +} #[derive(Debug)] pub struct Identity; @@ -351,7 +405,7 @@ impl Implementation for EcRecover { let s = H256::from_slice(&input[96..128]); let bit = match v[31] { - 27 | 28 if &v.0[..31] == &[0; 31] => v[31] - 27, + 27 | 28 if v.0[..31] == [0; 31] => v[31] - 27, _ => { return Ok(()); }, }; @@ -393,13 +447,13 @@ impl Implementation for Blake2F { // state vector, h let mut h = [0u64; 8]; - for state_word in h.iter_mut() { + for state_word in &mut h { *state_word = cursor.read_u64::().expect(PROOF); } // message block vector, m let mut m = [0u64; 16]; - for msg_word in m.iter_mut() { + for msg_word in &mut m { *msg_word = cursor.read_u64::().expect(PROOF); } @@ -452,7 +506,7 @@ fn modexp(mut base: BigUint, exp: Vec, modulus: BigUint) -> BigUint { let mut exp = exp.into_iter().skip_while(|d| *d == 0).peekable(); // n^0 % m - if let None = exp.peek() { + if exp.peek().is_none() { return BigUint::one(); } @@ -461,7 +515,7 @@ fn modexp(mut base: BigUint, exp: Vec, modulus: BigUint) -> BigUint { return BigUint::zero(); } - base = base % &modulus; + base %= &modulus; // Fast path for base divisible by modulus. if base.is_zero() { return BigUint::zero() } @@ -630,10 +684,11 @@ impl Bn128Pairing { fn execute_with_error(&self, input: &[u8], output: &mut BytesRef) -> Result<(), &'static str> { use bn::{AffineG1, AffineG2, Fq, Fq2, pairing_batch, G1, G2, Gt, Group}; - let elements = input.len() / 192; // (a, b_a, b_b - each 64-byte affine coordinates) - let ret_val = if input.len() == 0 { + let ret_val = if input.is_empty() { U256::one() } else { + // (a, b_a, b_b - each 64-byte affine coordinates) + let elements = input.len() / 192; let mut vals = Vec::new(); for idx in 0..elements { let a_x = Fq::from_slice(&input[idx*192..idx*192+32]) @@ -690,18 +745,24 @@ impl Bn128Pairing { mod tests { use std::convert::TryFrom; use ethereum_types::U256; - use ethjson::uint::Uint; + use ethjson::spec::builtin::{ + Builtin as JsonBuiltin, Linear as JsonLinearPricing, + PricingAt, AltBn128Pairing as JsonAltBn128PairingPricing, Pricing as JsonPricing, + }; + use hex_literal::hex; + use macros::map; use num::{BigUint, Zero, One}; use parity_bytes::BytesRef; - use hex_literal::hex; - use super::{Builtin, Linear, ethereum_builtin, Pricer, ModexpPricer, modexp as me}; + use super::{ + BTreeMap, Builtin, EthereumBuiltin, FromStr, Implementation, Linear, + ModexpPricer, modexp as me, Pricing + }; #[test] fn blake2f_cost() { let f = Builtin { - pricer: Box::new(123), - native: ethereum_builtin("blake2_f").expect("known builtin"), - activate_at: 0, + pricer: map![0 => Pricing::Blake2F(123)], + native: EthereumBuiltin::from_str("blake2_f").unwrap(), }; // 5 rounds let input = hex!("0000000548c9bdf267e6096a3ba7ca8485ae67bb2bf894fe72f36e3cf1361d5f3af54fa5d182e6ad7f520e511f6c3e2b8c68059b6bbd41fbabd9831f79217e1319cde05b61626300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000001"); @@ -714,9 +775,8 @@ mod tests { #[test] fn blake2f_cost_on_invalid_length() { let f = Builtin { - pricer: Box::new(123), - native: ethereum_builtin("blake2_f").expect("known builtin"), - activate_at: 0, + pricer: map![0 => Pricing::Blake2F(123)], + native: EthereumBuiltin::from_str("blake2_f").expect("known builtin"), }; // invalid input (too short) let input = hex!("00"); @@ -726,7 +786,7 @@ mod tests { #[test] fn blake2_f_is_err_on_invalid_length() { - let blake2 = ethereum_builtin("blake2_f").expect("known builtin"); + let blake2 = EthereumBuiltin::from_str("blake2_f").unwrap(); // Test vector 1 and expected output from https://github.com/ethereum/EIPs/blob/master/EIPS/eip-152.md#test-vector-1 let input = hex!("00000c48c9bdf267e6096a3ba7ca8485ae67bb2bf894fe72f36e3cf1361d5f3af54fa5d182e6ad7f520e511f6c3e2b8c68059b6bbd41fbabd9831f79217e1319cde05b61626300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000001"); let mut out = [0u8; 64]; @@ -738,7 +798,7 @@ mod tests { #[test] fn blake2_f_is_err_on_invalid_length_2() { - let blake2 = ethereum_builtin("blake2_f").expect("known builtin"); + let blake2 = EthereumBuiltin::from_str("blake2_f").unwrap(); // Test vector 2 and expected output from https://github.com/ethereum/EIPs/blob/master/EIPS/eip-152.md#test-vector-2 let input = hex!("000000000c48c9bdf267e6096a3ba7ca8485ae67bb2bf894fe72f36e3cf1361d5f3af54fa5d182e6ad7f520e511f6c3e2b8c68059b6bbd41fbabd9831f79217e1319cde05b61626300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000001"); let mut out = [0u8; 64]; @@ -750,7 +810,7 @@ mod tests { #[test] fn blake2_f_is_err_on_bad_finalization_flag() { - let blake2 = ethereum_builtin("blake2_f").expect("known builtin"); + let blake2 = EthereumBuiltin::from_str("blake2_f").unwrap(); // Test vector 3 and expected output from https://github.com/ethereum/EIPs/blob/master/EIPS/eip-152.md#test-vector-3 let input = hex!("0000000c48c9bdf267e6096a3ba7ca8485ae67bb2bf894fe72f36e3cf1361d5f3af54fa5d182e6ad7f520e511f6c3e2b8c68059b6bbd41fbabd9831f79217e1319cde05b61626300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000002"); let mut out = [0u8; 64]; @@ -762,7 +822,7 @@ mod tests { #[test] fn blake2_f_zero_rounds_is_ok_test_vector_4() { - let blake2 = ethereum_builtin("blake2_f").expect("known builtin"); + let blake2 = EthereumBuiltin::from_str("blake2_f").unwrap(); // Test vector 4 and expected output from https://github.com/ethereum/EIPs/blob/master/EIPS/eip-152.md#test-vector-4 let input = hex!("0000000048c9bdf267e6096a3ba7ca8485ae67bb2bf894fe72f36e3cf1361d5f3af54fa5d182e6ad7f520e511f6c3e2b8c68059b6bbd41fbabd9831f79217e1319cde05b61626300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000001"); let expected = hex!("08c9bcf367e6096a3ba7ca8485ae67bb2bf894fe72f36e3cf1361d5f3af54fa5d282e6ad7f520e511f6c3e2b8c68059b9442be0454267ce079217e1319cde05b"); @@ -773,7 +833,7 @@ mod tests { #[test] fn blake2_f_test_vector_5() { - let blake2 = ethereum_builtin("blake2_f").expect("known builtin"); + let blake2 = EthereumBuiltin::from_str("blake2_f").unwrap(); // Test vector 5 and expected output from https://github.com/ethereum/EIPs/blob/master/EIPS/eip-152.md#test-vector-5 let input = hex!("0000000c48c9bdf267e6096a3ba7ca8485ae67bb2bf894fe72f36e3cf1361d5f3af54fa5d182e6ad7f520e511f6c3e2b8c68059b6bbd41fbabd9831f79217e1319cde05b61626300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000001"); let expected = hex!("ba80a53f981c4d0d6a2797b69f12f6e94c212f14685ac4b74b12bb6fdbffa2d17d87c5392aab792dc252d5de4533cc9518d38aa8dbf1925ab92386edd4009923"); @@ -784,7 +844,7 @@ mod tests { #[test] fn blake2_f_test_vector_6() { - let blake2 = ethereum_builtin("blake2_f").expect("known builtin"); + let blake2 = EthereumBuiltin::from_str("blake2_f").unwrap(); // Test vector 6 and expected output from https://github.com/ethereum/EIPs/blob/master/EIPS/eip-152.md#test-vector-6 let input = hex!("0000000c48c9bdf267e6096a3ba7ca8485ae67bb2bf894fe72f36e3cf1361d5f3af54fa5d182e6ad7f520e511f6c3e2b8c68059b6bbd41fbabd9831f79217e1319cde05b61626300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000"); let expected = hex!("75ab69d3190a562c51aef8d88f1c2775876944407270c42c9844252c26d2875298743e7f6d5ea2f2d3e8d226039cd31b4e426ac4f2d3d666a610c2116fde4735"); @@ -795,7 +855,7 @@ mod tests { #[test] fn blake2_f_test_vector_7() { - let blake2 = ethereum_builtin("blake2_f").expect("known builtin"); + let blake2 = EthereumBuiltin::from_str("blake2_f").unwrap(); // Test vector 7 and expected output from https://github.com/ethereum/EIPs/blob/master/EIPS/eip-152.md#test-vector-7 let input = hex!("0000000148c9bdf267e6096a3ba7ca8485ae67bb2bf894fe72f36e3cf1361d5f3af54fa5d182e6ad7f520e511f6c3e2b8c68059b6bbd41fbabd9831f79217e1319cde05b61626300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000001"); let expected = hex!("b63a380cb2897d521994a85234ee2c181b5f844d2c624c002677e9703449d2fba551b3a8333bcdf5f2f7e08993d53923de3d64fcc68c034e717b9293fed7a421"); @@ -807,7 +867,7 @@ mod tests { #[ignore] #[test] fn blake2_f_test_vector_8() { - let blake2 = ethereum_builtin("blake2_f").expect("known builtin"); + let blake2 = EthereumBuiltin::from_str("blake2_f").unwrap(); // Test vector 8 and expected output from https://github.com/ethereum/EIPs/blob/master/EIPS/eip-152.md#test-vector-8 // Note this test is slow, 4294967295/0xffffffff rounds take a while. let input = hex!("ffffffff48c9bdf267e6096a3ba7ca8485ae67bb2bf894fe72f36e3cf1361d5f3af54fa5d182e6ad7f520e511f6c3e2b8c68059b6bbd41fbabd9831f79217e1319cde05b61626300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000001"); @@ -852,8 +912,7 @@ mod tests { #[test] fn identity() { - let f = ethereum_builtin("identity").expect("known builtin"); - + let f = EthereumBuiltin::from_str("identity").unwrap(); let i = [0u8, 1, 2, 3]; let mut o2 = [255u8; 2]; @@ -872,8 +931,7 @@ mod tests { #[test] fn sha256() { - let f = ethereum_builtin("sha256").expect("known builtin"); - + let f = EthereumBuiltin::from_str("sha256").unwrap(); let i = [0u8; 0]; let mut o = [255u8; 32]; @@ -895,8 +953,7 @@ mod tests { #[test] fn ripemd160() { - let f = ethereum_builtin("ripemd160").expect("known builtin"); - + let f = EthereumBuiltin::from_str("ripemd160").unwrap(); let i = [0u8; 0]; let mut o = [255u8; 32]; @@ -914,7 +971,7 @@ mod tests { #[test] fn ecrecover() { - let f = ethereum_builtin("ecrecover").expect("known builtin"); + let f = EthereumBuiltin::from_str("ecrecover").unwrap(); let i = hex!("47173285a8d7341e5e972fc677286384f802f8ef42a5ec5f03bbfa254cb01fad000000000000000000000000000000000000000000000000000000000000001b650acf9d3f5f0a2c799776a1254355d5f4061762a237396a99a0e0e3fc2bcd6729514a0dacb2e623ac4abd157cb18163ff942280db4d5caad66ddf941ba12e03"); @@ -964,18 +1021,16 @@ mod tests { #[test] fn modexp() { - let f = Builtin { - pricer: Box::new(ModexpPricer { divisor: 20 }), - native: ethereum_builtin("modexp").expect("known builtin"), - activate_at: 0, + pricer: map![0 => Pricing::Modexp(ModexpPricer { divisor: 20 })], + native: EthereumBuiltin::from_str("modexp").unwrap(), }; // test for potential gas cost multiplication overflow { let input = hex!("0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000003b27bafd00000000000000000000000000000000000000000000000000000000503c8ac3"); let expected_cost = U256::max_value(); - assert_eq!(f.cost(&input[..], 0), expected_cost.into()); + assert_eq!(f.cost(&input[..], 0), expected_cost); } // test for potential exp len overflow @@ -992,7 +1047,7 @@ mod tests { f.execute(&input[..], &mut BytesRef::Fixed(&mut output[..])).expect("Builtin should fail"); assert_eq!(output, expected); - assert_eq!(f.cost(&input[..], 0), expected_cost.into()); + assert_eq!(f.cost(&input[..], 0), expected_cost); } // fermat's little theorem example. @@ -1077,9 +1132,8 @@ mod tests { fn bn128_add() { let f = Builtin { - pricer: Box::new(Linear { base: 0, word: 0 }), - native: ethereum_builtin("alt_bn128_add").expect("known builtin"), - activate_at: 0, + pricer: map![0 => Pricing::Linear(Linear { base: 0, word: 0 })], + native: EthereumBuiltin::from_str("alt_bn128_add").unwrap(), }; // zero-points additions @@ -1136,9 +1190,8 @@ mod tests { fn bn128_mul() { let f = Builtin { - pricer: Box::new(Linear { base: 0, word: 0 }), - native: ethereum_builtin("alt_bn128_mul").expect("known builtin"), - activate_at: 0, + pricer: map![0 => Pricing::Linear(Linear { base: 0, word: 0 })], + native: EthereumBuiltin::from_str("alt_bn128_mul").unwrap(), }; // zero-point multiplication @@ -1176,9 +1229,8 @@ mod tests { fn builtin_pairing() -> Builtin { Builtin { - pricer: Box::new(Linear { base: 0, word: 0 }), - native: ethereum_builtin("alt_bn128_pairing").expect("known builtin"), - activate_at: 0, + pricer: map![0 => Pricing::Linear(Linear { base: 0, word: 0 })], + native: EthereumBuiltin::from_str("alt_bn128_pairing").unwrap(), } } @@ -1249,16 +1301,15 @@ mod tests { #[test] #[should_panic] fn from_unknown_linear() { - let _ = ethereum_builtin("foo").unwrap(); + let _ = EthereumBuiltin::from_str("foo").unwrap(); } #[test] fn is_active() { - let pricer = Box::new(Linear { base: 10, word: 20} ); + let pricer = Pricing::Linear(Linear { base: 10, word: 20 }); let b = Builtin { - pricer: pricer as Box, - native: ethereum_builtin("identity").expect("known builtin"), - activate_at: 100_000, + pricer: map![100_000 => pricer], + native: EthereumBuiltin::from_str("identity").unwrap(), }; assert!(!b.is_active(99_999)); @@ -1268,11 +1319,10 @@ mod tests { #[test] fn from_named_linear() { - let pricer = Box::new(Linear { base: 10, word: 20 }); + let pricer = Pricing::Linear(Linear { base: 10, word: 20 }); let b = Builtin { - pricer: pricer as Box, - native: ethereum_builtin("identity").expect("known builtin"), - activate_at: 1, + pricer: map![0 => pricer], + native: EthereumBuiltin::from_str("identity").unwrap(), }; assert_eq!(b.cost(&[0; 0], 0), U256::from(10)); @@ -1290,12 +1340,12 @@ mod tests { fn from_json() { let b = Builtin::try_from(ethjson::spec::Builtin { name: "identity".to_owned(), - pricing: ethjson::spec::Pricing::Linear(ethjson::spec::Linear { - base: 10, - word: 20, - }), - activate_at: None, - eip1108_transition: None, + pricing: map![ + 0 => PricingAt { + info: None, + price: JsonPricing::Linear(JsonLinearPricing { base: 10, word: 20 }) + } + ] }).expect("known builtin"); assert_eq!(b.cost(&[0; 0], 0), U256::from(10)); @@ -1311,17 +1361,25 @@ mod tests { #[test] fn bn128_pairing_eip1108_transition() { - let b = Builtin::try_from(ethjson::spec::Builtin { + let b = Builtin::try_from(JsonBuiltin { name: "alt_bn128_pairing".to_owned(), - pricing: ethjson::spec::Pricing::AltBn128Pairing(ethjson::spec::builtin::AltBn128Pairing { - base: 100_000, - pair: 80_000, - eip1108_transition_base: 45_000, - eip1108_transition_pair: 34_000, - }), - activate_at: Some(Uint(U256::from(10))), - eip1108_transition: Some(Uint(U256::from(20))), - }).expect("known builtin"); + pricing: map![ + 10 => PricingAt { + info: None, + price: JsonPricing::AltBn128Pairing(JsonAltBn128PairingPricing { + base: 100_000, + pair: 80_000, + }), + }, + 20 => PricingAt { + info: None, + price: JsonPricing::AltBn128Pairing(JsonAltBn128PairingPricing { + base: 45_000, + pair: 34_000, + }), + } + ], + }).unwrap(); assert_eq!(b.cost(&[0; 192 * 3], 10), U256::from(340_000), "80 000 * 3 + 100 000 == 340 000"); assert_eq!(b.cost(&[0; 192 * 7], 20), U256::from(283_000), "34 000 * 7 + 45 000 == 283 000"); @@ -1329,15 +1387,25 @@ mod tests { #[test] fn bn128_add_eip1108_transition() { - let b = Builtin::try_from(ethjson::spec::Builtin { + let b = Builtin::try_from(JsonBuiltin { name: "alt_bn128_add".to_owned(), - pricing: ethjson::spec::Pricing::AltBn128ConstOperations(ethjson::spec::builtin::AltBn128ConstOperations { - price: 500, - eip1108_transition_price: 150, - }), - activate_at: Some(Uint(U256::from(10))), - eip1108_transition: Some(Uint(U256::from(20))), - }).expect("known builtin"); + pricing: map![ + 10 => PricingAt { + info: None, + price: JsonPricing::Linear(JsonLinearPricing { + base: 500, + word: 0, + }), + }, + 20 => PricingAt { + info: None, + price: JsonPricing::Linear(JsonLinearPricing { + base: 150, + word: 0, + }), + } + ], + }).unwrap(); assert_eq!(b.cost(&[0; 192], 10), U256::from(500)); assert_eq!(b.cost(&[0; 10], 20), U256::from(150), "after istanbul hardfork gas cost for add should be 150"); @@ -1345,17 +1413,99 @@ mod tests { #[test] fn bn128_mul_eip1108_transition() { - let b = Builtin::try_from(ethjson::spec::Builtin { + let b = Builtin::try_from(JsonBuiltin { name: "alt_bn128_mul".to_owned(), - pricing: ethjson::spec::Pricing::AltBn128ConstOperations(ethjson::spec::builtin::AltBn128ConstOperations { - price: 40_000, - eip1108_transition_price: 6000, - }), - activate_at: Some(Uint(U256::from(10))), - eip1108_transition: Some(Uint(U256::from(20))), - }).expect("known builtin"); + pricing: map![ + 10 => PricingAt { + info: None, + price: JsonPricing::Linear(JsonLinearPricing { + base: 40_000, + word: 0, + }), + }, + 20 => PricingAt { + info: None, + price: JsonPricing::Linear(JsonLinearPricing { + base: 6_000, + word: 0, + }), + } + ], + }).unwrap(); assert_eq!(b.cost(&[0; 192], 10), U256::from(40_000)); assert_eq!(b.cost(&[0; 10], 20), U256::from(6_000), "after istanbul hardfork gas cost for mul should be 6 000"); } + + + #[test] + fn multimap_use_most_recent_on_activate() { + let b = Builtin::try_from(JsonBuiltin { + name: "alt_bn128_mul".to_owned(), + pricing: map![ + 10 => PricingAt { + info: None, + price: JsonPricing::Linear(JsonLinearPricing { + base: 40_000, + word: 0, + }), + }, + 20 => PricingAt { + info: None, + price: JsonPricing::Linear(JsonLinearPricing { + base: 6_000, + word: 0, + }) + }, + 100 => PricingAt { + info: None, + price: JsonPricing::Linear(JsonLinearPricing { + base: 1_337, + word: 0, + }) + } + ] + }).unwrap(); + + assert_eq!(b.cost(&[0; 2], 0), U256::zero(), "not activated yet; should be zero"); + assert_eq!(b.cost(&[0; 3], 10), U256::from(40_000), "use price #1"); + assert_eq!(b.cost(&[0; 4], 20), U256::from(6_000), "use price #2"); + assert_eq!(b.cost(&[0; 1], 99), U256::from(6_000), "use price #2"); + assert_eq!(b.cost(&[0; 1], 100), U256::from(1_337), "use price #3"); + assert_eq!(b.cost(&[0; 1], u64::max_value()), U256::from(1_337), "use price #3 indefinitely"); + } + + + #[test] + fn multimap_use_last_with_same_activate_at() { + let b = Builtin::try_from(JsonBuiltin { + name: "alt_bn128_mul".to_owned(), + pricing: map![ + 1 => PricingAt { + info: None, + price: JsonPricing::Linear(JsonLinearPricing { + base: 40_000, + word: 0, + }), + }, + 1 => PricingAt { + info: None, + price: JsonPricing::Linear(JsonLinearPricing { + base: 6_000, + word: 0, + }), + }, + 1 => PricingAt { + info: None, + price: JsonPricing::Linear(JsonLinearPricing { + base: 1_337, + word: 0, + }), + } + ], + }).unwrap(); + + assert_eq!(b.cost(&[0; 1], 0), U256::from(0), "not activated yet"); + assert_eq!(b.cost(&[0; 1], 1), U256::from(1_337), "use price #3"); + } } diff --git a/ethcore/engines/basic-authority/res/basic_authority.json b/ethcore/engines/basic-authority/res/basic_authority.json index 2d92355e3af..463b14afca8 100644 --- a/ethcore/engines/basic-authority/res/basic_authority.json +++ b/ethcore/engines/basic-authority/res/basic_authority.json @@ -42,12 +42,12 @@ "balance": "1", "builtin": { "name": "alt_bn128_add", - "activate_at": "0x0", - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_const_operations": { - "price": 500, - "eip1108_transition_price": 150 + "0x0": { + "price": { "linear": { "base": 500, "word": 0 }} + }, + "0x7fffffffffffff": { + "price": { "linear": { "base": 150, "word": 0 }} } } } @@ -56,12 +56,12 @@ "balance": "1", "builtin": { "name": "alt_bn128_mul", - "activate_at": "0x0", - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_const_operations": { - "price": 40000, - "eip1108_transition_price": 6000 + "0x0": { + "price": { "linear": { "base": 40000, "word": 0 }} + }, + "0x7fffffffffffff": { + "price": { "linear": { "base": 6000, "word": 0 }} } } } @@ -70,14 +70,12 @@ "balance": "1", "builtin": { "name": "alt_bn128_pairing", - "activate_at": "0x0", - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_pairing": { - "base": 100000, - "pair": 80000, - "eip1108_transition_base": 45000, - "eip1108_transition_pair": 34000 + "0x0": { + "price": { "alt_bn128_pairing": { "base": 100000, "pair": 80000 }} + }, + "0x7fffffffffffff": { + "price": { "alt_bn128_pairing": { "base": 45000, "pair": 34000 }} } } } diff --git a/ethcore/engines/basic-authority/src/lib.rs b/ethcore/engines/basic-authority/src/lib.rs index 2587d598697..99cb55ee648 100644 --- a/ethcore/engines/basic-authority/src/lib.rs +++ b/ethcore/engines/basic-authority/src/lib.rs @@ -35,7 +35,6 @@ use ethereum_types::{H256, H520}; use parking_lot::RwLock; use engine::{Engine, ConstructedVerifier, signer::EngineSigner}; use parity_crypto::publickey::Signature; -use ethjson; use log::trace; use machine::{Machine, executed_block::ExecutedBlock}; use rlp::Rlp; diff --git a/ethcore/machine/Cargo.toml b/ethcore/machine/Cargo.toml index dc33e75a968..f4db91a6f52 100644 --- a/ethcore/machine/Cargo.toml +++ b/ethcore/machine/Cargo.toml @@ -6,6 +6,11 @@ authors = ["Parity Technologies "] edition = "2018" license = "GPL-3.0" +[[bench]] +name = "builtin_contract" +harness = false +required-features = ["test-helpers"] + [dependencies] account-state = { path = "../account-state" } client-traits = { path = "../client-traits" } @@ -34,6 +39,7 @@ vm = { path = "../vm" } [dev-dependencies] common-types = { path = "../types", features = ["test-helpers"] } +criterion = "0.3" ethcore = { path = "../", features = ["test-helpers"] } ethcore-io = { path = "../../util/io" } ethjson = { path = "../../json" } diff --git a/ethcore/machine/benches/builtin_contract.rs b/ethcore/machine/benches/builtin_contract.rs new file mode 100644 index 00000000000..626c249d34a --- /dev/null +++ b/ethcore/machine/benches/builtin_contract.rs @@ -0,0 +1,149 @@ +// Copyright 2015-2019 Parity Technologies (UK) Ltd. +// This file is part of Parity Ethereum. + +// Parity Ethereum is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Parity Ethereum is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Parity Ethereum. If not, see . + +//! Benchmarking of calling builtin contract + +use std::str::FromStr; + +use account_state::State; +use parity_bytes::Bytes; +use ethcore::test_helpers::get_temp_state_db; +use ethereum_types::{H160, U256}; +use criterion::{black_box, criterion_main, criterion_group, Criterion}; +use machine::{test_helpers, Machine}; +use machine::executive::CallCreateExecutive; +use machine::substate::Substate; +use trace::{NoopTracer, NoopVMTracer}; +use trie_vm_factories::VmFactory; +use vm::{ActionParams, EnvInfo, Schedule}; + +const ECRECOVER: &str = "0000000000000000000000000000000000000001"; +const SHA256: &str = "0000000000000000000000000000000000000002"; +const SIGNED_DATA: &str = "hash000000000001v000000000000002r000000000000003s000000000000004"; + +fn single_builtin_pricing() -> Machine { + test_helpers::load_machine(include_bytes!("../../res/ethereum/builtin_one_activation_bench.json")) +} + +fn multiple_builtin_pricing() -> Machine { + test_helpers::load_machine(include_bytes!("../../res/ethereum/builtin_multi_bench.json")) +} + +fn builtin_params(address: H160, execute: bool) -> ActionParams { + let mut params = ActionParams::default(); + params.code_address = address; + params.gas = u64::max_value().into(); + if execute { + params.data = Some(SIGNED_DATA.bytes().collect::()); + } + params +} + +fn single_activation(c: &mut Criterion) { + let contract = H160::from_str(ECRECOVER).unwrap(); + let params = builtin_params(contract, false); + + let env_info = EnvInfo::default(); + let machine = single_builtin_pricing(); + let schedule = Schedule::default(); + let factory = VmFactory::default(); + let depth = 0; + let stack_depth = 0; + let parent_static_flag = false; + + let db = get_temp_state_db(); + let mut state = State::new(db, U256::from(0), Default::default()); + let mut substate = Substate::new(); + + c.bench_function("single activation", move |b| { + b.iter(|| black_box(CallCreateExecutive::new_call_raw( + params.clone(), + &env_info, + &machine, + &schedule, + &factory, + depth, + stack_depth, + parent_static_flag, + ).exec(&mut state, &mut substate, &mut NoopTracer, &mut NoopVMTracer)) + ) + }); +} + +fn ten_multiple_activations(c: &mut Criterion) { + let contract = H160::from_str(ECRECOVER).unwrap(); + let params = builtin_params(contract, false); + + let env_info = EnvInfo::default(); + let machine = multiple_builtin_pricing(); + let schedule = Schedule::default(); + let factory = VmFactory::default(); + let depth = 0; + let stack_depth = 0; + let parent_static_flag = false; + + let db = get_temp_state_db(); + let mut state = State::new(db, U256::from(0), Default::default()); + let mut substate = Substate::new(); + + c.bench_function("ten activations", move |b| { + b.iter(|| black_box(CallCreateExecutive::new_call_raw( + params.clone(), + &env_info, + &machine, + &schedule, + &factory, + depth, + stack_depth, + parent_static_flag, + ).exec(&mut state, &mut substate, &mut NoopTracer, &mut NoopVMTracer)) + ) + }); +} + +fn fourty_multiple_activations(c: &mut Criterion) { + let contract = H160::from_str(SHA256).unwrap(); + let params = builtin_params(contract, false); + + let env_info = EnvInfo::default(); + let machine = multiple_builtin_pricing(); + let schedule = Schedule::default(); + let factory = VmFactory::default(); + let depth = 0; + let stack_depth = 0; + let parent_static_flag = false; + + let db = get_temp_state_db(); + let mut state = State::new(db, U256::from(0), Default::default()); + let mut substate = Substate::new(); + + c.bench_function("fourty activations", move |b| { + b.iter(|| black_box(CallCreateExecutive::new_call_raw( + params.clone(), + &env_info, + &machine, + &schedule, + &factory, + depth, + stack_depth, + parent_static_flag, + ).exec(&mut state, &mut substate, &mut NoopTracer, &mut NoopVMTracer)) + ) + }); +} + +criterion_group!(benches, single_activation, ten_multiple_activations, fourty_multiple_activations); +criterion_main!(benches); diff --git a/ethcore/machine/src/test_helpers.rs b/ethcore/machine/src/test_helpers.rs index aac33b9a92d..8f534b2f293 100644 --- a/ethcore/machine/src/test_helpers.rs +++ b/ethcore/machine/src/test_helpers.rs @@ -19,7 +19,6 @@ use std::convert::TryFrom; use common_types::engines::params::CommonParams; use ethcore_builtin::Builtin; -use ethjson; use crate::Machine; pub fn load_machine(reader: &[u8]) -> Machine { @@ -35,7 +34,6 @@ pub fn load_machine(reader: &[u8]) -> Machine { } } - /// Create a new Foundation Frontier-era chain spec as though it never changes to Homestead. pub fn new_frontier_test_machine() -> Machine { load_machine(include_bytes!("../../res/ethereum/frontier_test.json")) } diff --git a/ethcore/res/authority_round.json b/ethcore/res/authority_round.json index 33afa45871c..292760444d6 100644 --- a/ethcore/res/authority_round.json +++ b/ethcore/res/authority_round.json @@ -50,12 +50,13 @@ "balance": "1", "builtin": { "name": "alt_bn128_add", - "activate_at": 0, - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_const_operations": { - "price": 500, - "eip1108_transition_price": 150 + "0": { + "price": { "alt_bn128_const_operations": { "price": 500 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_const_operations": { "price": 150 }} } } } @@ -64,12 +65,13 @@ "balance": "1", "builtin": { "name": "alt_bn128_mul", - "activate_at": 0, - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_const_operations": { - "price": 40000, - "eip1108_transition_price": 6000 + "0": { + "price": { "alt_bn128_const_operations": { "price": 40000 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_const_operations": { "price": 6000 }} } } } @@ -78,14 +80,13 @@ "balance": "1", "builtin": { "name": "alt_bn128_pairing", - "activate_at": 0, - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_pairing": { - "base": 100000, - "pair": 80000, - "eip1108_transition_base": 45000, - "eip1108_transition_pair": 34000 + "0": { + "price": { "alt_bn128_pairing": { "base": 100000, "pair": 80000 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_pairing": { "base": 45000, "pair": 34000 }} } } } diff --git a/ethcore/res/authority_round_block_reward_contract.json b/ethcore/res/authority_round_block_reward_contract.json index 73893d44d1d..4adb9a8d43c 100644 --- a/ethcore/res/authority_round_block_reward_contract.json +++ b/ethcore/res/authority_round_block_reward_contract.json @@ -53,12 +53,13 @@ "balance": "1", "builtin": { "name": "alt_bn128_add", - "activate_at": 0, - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_const_operations": { - "price": 500, - "eip1108_transition_price": 150 + "0": { + "price": { "alt_bn128_const_operations": { "price": 500 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_const_operations": { "price": 150 }} } } } @@ -67,12 +68,13 @@ "balance": "1", "builtin": { "name": "alt_bn128_mul", - "activate_at": 0, - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_const_operations": { - "price": 40000, - "eip1108_transition_price": 6000 + "0": { + "price": { "alt_bn128_const_operations": { "price": 40000 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_const_operations": { "price": 6000 }} } } } @@ -81,14 +83,13 @@ "balance": "1", "builtin": { "name": "alt_bn128_pairing", - "activate_at": 0, - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_pairing": { - "base": 100000, - "pair": 80000, - "eip1108_transition_base": 45000, - "eip1108_transition_pair": 34000 + "0": { + "price": { "alt_bn128_pairing": { "base": 100000, "pair": 80000 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_pairing": { "base": 45000, "pair": 34000 }} } } } diff --git a/ethcore/res/constructor.json b/ethcore/res/constructor.json index 1383337351a..2e64335b58a 100644 --- a/ethcore/res/constructor.json +++ b/ethcore/res/constructor.json @@ -38,12 +38,13 @@ "balance": "1", "builtin": { "name": "alt_bn128_add", - "activate_at": 0, - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_const_operations": { - "price": 500, - "eip1108_transition_price": 150 + "0": { + "price": { "linear": { "base": 500, "word": 0 }} + }, + "0x7fffffffffffff": { + "info": "EIP1108 transition", + "price": { "linear": { "base": 150, "word": 0 }} } } } @@ -52,12 +53,13 @@ "balance": "1", "builtin": { "name": "alt_bn128_mul", - "activate_at": 0, - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_const_operations": { - "price": 40000, - "eip1108_transition_price": 6000 + "0": { + "price": { "linear": {"base": 40000, "word": 0 }} + }, + "0x7fffffffffffff": { + "info": "EIP1108 transition", + "price": { "linear": { "base": 6000, "word": 0 }} } } } @@ -66,14 +68,13 @@ "balance": "1", "builtin": { "name": "alt_bn128_pairing", - "activate_at": 0, - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_pairing": { - "base": 100000, - "pair": 80000, - "eip1108_transition_base": 45000, - "eip1108_transition_pair": 34000 + "0": { + "price": { "alt_bn128_pairing": { "base": 100000, "pair": 80000 }} + }, + "0x7fffffffffffff": { + "info": "EIP1108 transition", + "price": { "alt_bn128_pairing": { "base": 45000, "pair": 34000 }} } } } diff --git a/ethcore/res/ethereum/builtin_multi_bench.json b/ethcore/res/ethereum/builtin_multi_bench.json new file mode 100644 index 00000000000..a37273936fb --- /dev/null +++ b/ethcore/res/ethereum/builtin_multi_bench.json @@ -0,0 +1,112 @@ +{ + "name": "ecrecover legacy", + "engine": { + "Ethash": { + "params": { + "minimumDifficulty": "0x020000", + "difficultyBoundDivisor": "0x0800", + "durationLimit": "0x0d", + "blockReward": "0x4563918244F40000", + "homesteadTransition": "0x0" + } + } + }, + "params": { + "gasLimitBoundDivisor": "0x0400", + "registrar" : "0xc6d9d2cd449a754c494264e1809c50e34d64562b", + "accountStartNonce": "0x00", + "maximumExtraDataSize": "0x20", + "minGasLimit": "0x1388", + "networkID" : "0x1", + "eip150Transition": "0x0", + "eip160Transition": "0x7fffffffffffffff", + "eip161abcTransition": "0x7fffffffffffffff", + "eip161dTransition": "0x7fffffffffffffff", + "eip155Transition": "0x7fffffffffffffff", + "maxCodeSize": 24576, + "maxCodeSizeTransition": "0x7fffffffffffffff" + }, + "genesis": { + "seal": { + "ethereum": { + "nonce": "0x0000000000000042", + "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000" + } + }, + "difficulty": "0x400000000", + "author": "0x0000000000000000000000000000000000000000", + "timestamp": "0x00", + "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000", + "extraData": "0x11bbe8db4e347b4e8c937c1c8370e4b5ed33adb3db69cbdb7a38e1e50b1b82fa", + "gasLimit": "0x1388" + }, + "accounts": { + "0000000000000000000000000000000000000001": { + "balance": "1", + "builtin": { + "name": "ecrecover", + "pricing": { + "0": {"price": {"linear": { "base": 1, "word": 0 }}}, + "1": {"price": {"linear": { "base": 2, "word": 0 }}}, + "2": {"price": {"linear": { "base": 3, "word": 0 }}}, + "3": {"price": {"linear": { "base": 4, "word": 0 }}}, + "4": {"price": {"linear": { "base": 5, "word": 0 }}}, + "5": {"price": {"linear": { "base": 6, "word": 0 }}}, + "6": {"price": {"linear": { "base": 7, "word": 0 }}}, + "7": {"price": {"linear": { "base": 8, "word": 0 }}}, + "8": {"price": {"linear": { "base": 9, "word": 0 }}}, + "9": {"price": {"linear": { "base": 1, "word": 0 }}}, + "10": {"price": {"linear": { "base": 2, "word": 0 }}} + } + } + }, + "0000000000000000000000000000000000000002": { + "balance": "1", + "builtin": { + "name": "sha256", + "pricing": { + "0": {"price": {"linear": { "base": 1, "word": 0 }}}, + "1": {"price": {"linear": { "base": 2, "word": 0 }}}, + "2": {"price": {"linear": { "base": 3, "word": 0 }}}, + "3": {"price": {"linear": { "base": 4, "word": 0 }}}, + "4": {"price": {"linear": { "base": 5, "word": 0 }}}, + "5": {"price": {"linear": { "base": 6, "word": 0 }}}, + "6": {"price": {"linear": { "base": 7, "word": 0 }}}, + "7": {"price": {"linear": { "base": 8, "word": 0 }}}, + "8": {"price": {"linear": { "base": 9, "word": 0 }}}, + "9": {"price": {"linear": { "base": 1, "word": 0 }}}, + "10": {"price": {"linear": { "base": 2, "word": 0 }}}, + "11": {"price": {"linear": { "base": 3, "word": 0 }}}, + "12": {"price": {"linear": { "base": 4, "word": 0 }}}, + "13": {"price": {"linear": { "base": 5, "word": 0 }}}, + "14": {"price": {"linear": { "base": 6, "word": 0 }}}, + "15": {"price": {"linear": { "base": 7, "word": 0 }}}, + "16": {"price": {"linear": { "base": 8, "word": 0 }}}, + "17": {"price": {"linear": { "base": 9, "word": 0 }}}, + "18": {"price": {"linear": { "base": 1, "word": 0 }}}, + "19": {"price": {"linear": { "base": 2, "word": 0 }}}, + "20": {"price": {"linear": { "base": 3, "word": 0 }}}, + "21": {"price": {"linear": { "base": 4, "word": 0 }}}, + "22": {"price": {"linear": { "base": 5, "word": 0 }}}, + "23": {"price": {"linear": { "base": 6, "word": 0 }}}, + "24": {"price": {"linear": { "base": 7, "word": 0 }}}, + "25": {"price": {"linear": { "base": 8, "word": 0 }}}, + "26": {"price": {"linear": { "base": 9, "word": 0 }}}, + "27": {"price": {"linear": { "base": 1, "word": 0 }}}, + "28": {"price": {"linear": { "base": 2, "word": 0 }}}, + "29": {"price": {"linear": { "base": 3, "word": 0 }}}, + "30": {"price": {"linear": { "base": 4, "word": 0 }}}, + "31": {"price": {"linear": { "base": 5, "word": 0 }}}, + "32": {"price": {"linear": { "base": 6, "word": 0 }}}, + "33": {"price": {"linear": { "base": 7, "word": 0 }}}, + "34": {"price": {"linear": { "base": 8, "word": 0 }}}, + "35": {"price": {"linear": { "base": 9, "word": 0 }}}, + "36": {"price": {"linear": { "base": 10, "word": 0 }}}, + "37": {"price": {"linear": { "base": 10, "word": 0 }}}, + "38": {"price": {"linear": { "base": 10, "word": 0 }}}, + "39": {"price": {"linear": { "base": 10, "word": 0 }}} + } + } + } + } +} diff --git a/ethcore/res/ethereum/builtin_one_activation_bench.json b/ethcore/res/ethereum/builtin_one_activation_bench.json new file mode 100644 index 00000000000..e746d7b2a12 --- /dev/null +++ b/ethcore/res/ethereum/builtin_one_activation_bench.json @@ -0,0 +1,54 @@ +{ + "name": "ecrecover legacy chain spec for benchmarking", + "engine": { + "Ethash": { + "params": { + "minimumDifficulty": "0x020000", + "difficultyBoundDivisor": "0x0800", + "durationLimit": "0x0d", + "blockReward": "0x4563918244F40000", + "homesteadTransition": "0x0" + } + } + }, + "params": { + "gasLimitBoundDivisor": "0x0400", + "registrar" : "0xc6d9d2cd449a754c494264e1809c50e34d64562b", + "accountStartNonce": "0x00", + "maximumExtraDataSize": "0x20", + "minGasLimit": "0x1388", + "networkID" : "0x1", + "eip150Transition": "0x0", + "eip160Transition": "0x7fffffffffffffff", + "eip161abcTransition": "0x7fffffffffffffff", + "eip161dTransition": "0x7fffffffffffffff", + "eip155Transition": "0x7fffffffffffffff", + "maxCodeSize": 24576, + "maxCodeSizeTransition": "0x7fffffffffffffff" + }, + "genesis": { + "seal": { + "ethereum": { + "nonce": "0x0000000000000042", + "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000" + } + }, + "difficulty": "0x400000000", + "author": "0x0000000000000000000000000000000000000000", + "timestamp": "0x00", + "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000", + "extraData": "0x11bbe8db4e347b4e8c937c1c8370e4b5ed33adb3db69cbdb7a38e1e50b1b82fa", + "gasLimit": "0x1388" + }, + "accounts": { + "0000000000000000000000000000000000000001": { + "balance": "1", + "builtin": { + "name": "ecrecover", + "pricing": { + "linear": { "base": 3000, "word": 0 } + } + } + } + } +} diff --git a/ethcore/res/ethereum/byzantium_test.json b/ethcore/res/ethereum/byzantium_test.json index b4df953739b..bc5ac30207e 100644 --- a/ethcore/res/ethereum/byzantium_test.json +++ b/ethcore/res/ethereum/byzantium_test.json @@ -57,12 +57,13 @@ "0000000000000000000000000000000000000006": { "builtin": { "name": "alt_bn128_add", - "activate_at": "0x00", - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_const_operations": { - "price": 500, - "eip1108_transition_price": 150 + "0": { + "price": { "alt_bn128_const_operations": { "price": 500 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_const_operations": { "price": 150 }} } } } @@ -70,12 +71,13 @@ "0000000000000000000000000000000000000007": { "builtin": { "name": "alt_bn128_mul", - "activate_at": "0x00", - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_const_operations": { - "price": 40000, - "eip1108_transition_price": 6000 + "0": { + "price": { "alt_bn128_const_operations": { "price": 40000 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_const_operations": { "price": 6000 }} } } } @@ -83,14 +85,13 @@ "0000000000000000000000000000000000000008": { "builtin": { "name": "alt_bn128_pairing", - "activate_at": "0x00", - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_pairing": { - "base": 100000, - "pair": 80000, - "eip1108_transition_base": 45000, - "eip1108_transition_pair": 34000 + "0": { + "price": { "alt_bn128_pairing": { "base": 100000, "pair": 80000 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_pairing": { "base": 45000, "pair": 34000 }} } } } diff --git a/ethcore/res/ethereum/callisto.json b/ethcore/res/ethereum/callisto.json index 02dc3d27638..a1cae6f3c5a 100644 --- a/ethcore/res/ethereum/callisto.json +++ b/ethcore/res/ethereum/callisto.json @@ -76,12 +76,12 @@ "balance": "1", "builtin": { "name": "alt_bn128_add", - "activate_at": 20, - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_const_operations": { - "price": 500, - "eip1108_transition_price": 150 + "20": { + "price": { "alt_bn128_const_operations": { "price": 500 }} + }, + "0x7fffffffffffff": { + "price": { "alt_bn128_const_operations": { "price": 150 }} } } } @@ -90,12 +90,12 @@ "balance": "1", "builtin": { "name": "alt_bn128_mul", - "activate_at": 20, - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_const_operations": { - "price": 40000, - "eip1108_transition_price": 6000 + "20": { + "price": { "alt_bn128_const_operations": { "price": 40000 }} + }, + "0x7fffffffffffff": { + "price": { "alt_bn128_const_operations": { "price": 6000 }} } } } @@ -104,14 +104,12 @@ "balance": "1", "builtin": { "name": "alt_bn128_pairing", - "activate_at": 20, - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_pairing": { - "base": 100000, - "pair": 80000, - "eip1108_transition_base": 45000, - "eip1108_transition_pair": 34000 + "20": { + "price": { "alt_bn128_pairing": { "base": 100000, "pair": 80000 }} + }, + "0x7fffffffffffff": { + "price": { "alt_bn128_pairing": { "base": 45000, "pair": 34000 }} } } } diff --git a/ethcore/res/ethereum/classic.json b/ethcore/res/ethereum/classic.json index 24cf47769b7..413fcabec79 100644 --- a/ethcore/res/ethereum/classic.json +++ b/ethcore/res/ethereum/classic.json @@ -4418,12 +4418,12 @@ "0x0000000000000000000000000000000000000006": { "builtin": { "name": "alt_bn128_add", - "activate_at": "0x85d9a0", - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_const_operations": { - "price": 500, - "eip1108_transition_price": 150 + "0x85d9a0": { + "price": { "alt_bn128_const_operations": { "price": 500 }} + }, + "0x7fffffffffffff": { + "price": { "alt_bn128_const_operations": { "price": 150 }} } } } @@ -4431,12 +4431,12 @@ "0x0000000000000000000000000000000000000007": { "builtin": { "name": "alt_bn128_mul", - "activate_at": "0x85d9a0", - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_const_operations": { - "price": 40000, - "eip1108_transition_price": 6000 + "0x85d9a0": { + "price": { "alt_bn128_const_operations": { "price": 40000 }} + }, + "0x7fffffffffffff": { + "price": { "alt_bn128_const_operations": { "price": 6000 }} } } } @@ -4444,14 +4444,12 @@ "0x0000000000000000000000000000000000000008": { "builtin": { "name": "alt_bn128_pairing", - "activate_at": "0x85d9a0", - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_pairing": { - "base": 100000, - "pair": 80000, - "eip1108_transition_base": 45000, - "eip1108_transition_pair": 34000 + "0x85d9a0": { + "price": { "alt_bn128_pairing": { "base": 100000, "pair": 80000 }} + }, + "0x7fffffffffffff": { + "price": { "alt_bn128_pairing": { "base": 45000, "pair": 34000 }} } } } diff --git a/ethcore/res/ethereum/constantinople_test.json b/ethcore/res/ethereum/constantinople_test.json index c61711e7a7f..cc5690e0d3d 100644 --- a/ethcore/res/ethereum/constantinople_test.json +++ b/ethcore/res/ethereum/constantinople_test.json @@ -61,12 +61,13 @@ "0000000000000000000000000000000000000006": { "builtin": { "name": "alt_bn128_add", - "activate_at": "0x00", - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_const_operations": { - "price": 500, - "eip1108_transition_price": 150 + "0": { + "price": { "alt_bn128_const_operations": { "price": 500 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_const_operations": { "price": 150 }} } } } @@ -74,12 +75,13 @@ "0000000000000000000000000000000000000007": { "builtin": { "name": "alt_bn128_mul", - "activate_at": "0x00", - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_const_operations": { - "price": 40000, - "eip1108_transition_price": 6000 + "0": { + "price": { "alt_bn128_const_operations": { "price": 40000 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_const_operations": { "price": 6000 }} } } } @@ -87,14 +89,13 @@ "0000000000000000000000000000000000000008": { "builtin": { "name": "alt_bn128_pairing", - "activate_at": "0x00", - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_pairing": { - "base": 100000, - "pair": 80000, - "eip1108_transition_base": 45000, - "eip1108_transition_pair": 34000 + "0": { + "price": { "alt_bn128_pairing": { "base": 100000, "pair": 80000 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_pairing": { "base": 45000, "pair": 34000 }} } } } diff --git a/ethcore/res/ethereum/eip210_test.json b/ethcore/res/ethereum/eip210_test.json index 782e99e5e9e..2cfeb7c61c2 100644 --- a/ethcore/res/ethereum/eip210_test.json +++ b/ethcore/res/ethereum/eip210_test.json @@ -49,12 +49,13 @@ "0000000000000000000000000000000000000006": { "builtin": { "name": "alt_bn128_add", - "activate_at": "0x00", - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_const_operations": { - "price": 500, - "eip1108_transition_price": 150 + "0": { + "price": { "alt_bn128_const_operations": { "price": 500 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_const_operations": { "price": 150 }} } } } @@ -62,12 +63,13 @@ "0000000000000000000000000000000000000007": { "builtin": { "name": "alt_bn128_mul", - "activate_at": "0x00", - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_const_operations": { - "price": 40000, - "eip1108_transition_price": 6000 + "0": { + "price": { "alt_bn128_const_operations": { "price": 40000 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_const_operations": { "price": 6000 }} } } } @@ -75,14 +77,13 @@ "0000000000000000000000000000000000000008": { "builtin": { "name": "alt_bn128_pairing", - "activate_at": "0x00", - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_pairing": { - "base": 100000, - "pair": 80000, - "eip1108_transition_base": 45000, - "eip1108_transition_pair": 34000 + "0": { + "price": { "alt_bn128_pairing": { "base": 100000, "pair": 80000 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_pairing": { "base": 45000, "pair": 34000 }} } } } diff --git a/ethcore/res/ethereum/ellaism.json b/ethcore/res/ethereum/ellaism.json index d1333fb7f3a..77fa6e347d0 100644 --- a/ethcore/res/ethereum/ellaism.json +++ b/ethcore/res/ethereum/ellaism.json @@ -69,12 +69,13 @@ "0000000000000000000000000000000000000006": { "builtin": { "name": "alt_bn128_add", - "activate_at": 2000000, - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_const_operations": { - "price": 500, - "eip1108_transition_price": 150 + "2000000": { + "price": { "alt_bn128_const_operations": { "price": 500 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_const_operations": { "price": 150 }} } } } @@ -82,12 +83,13 @@ "0000000000000000000000000000000000000007": { "builtin": { "name": "alt_bn128_mul", - "activate_at": 2000000, - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_const_operations": { - "price": 40000, - "eip1108_transition_price": 6000 + "2000000": { + "price": { "alt_bn128_const_operations": { "price": 40000 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_const_operations": { "price": 6000 }} } } } @@ -95,14 +97,13 @@ "0000000000000000000000000000000000000008": { "builtin": { "name": "alt_bn128_pairing", - "activate_at": 2000000, - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_pairing": { - "base": 100000, - "pair": 80000, - "eip1108_transition_base": 45000, - "eip1108_transition_pair": 34000 + "2000000": { + "price": { "alt_bn128_pairing": { "base": 100000, "pair": 80000 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_pairing": { "base": 45000, "pair": 34000 }} } } } diff --git a/ethcore/res/ethereum/ewc.json b/ethcore/res/ethereum/ewc.json index 53ceedd1744..f281e6533d4 100644 --- a/ethcore/res/ethereum/ewc.json +++ b/ethcore/res/ethereum/ewc.json @@ -849,13 +849,14 @@ "balance": "1", "builtin": { "name": "alt_bn128_add", - "activate_at": "0", - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_const_operations": { - "price": 500, - "eip1108_transition_price": 150 - } + "0": { + "price": { "alt_bn128_const_operations": { "price": 500 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_const_operations": { "price": 150 }} + } } } }, @@ -863,12 +864,13 @@ "balance": "1", "builtin": { "name": "alt_bn128_mul", - "activate_at": "0", - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_const_operations": { - "price": 40000, - "eip1108_transition_price": 6000 + "0": { + "price": { "alt_bn128_const_operations": { "price": 40000 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_const_operations": { "price": 6000 }} } } } @@ -877,16 +879,15 @@ "balance": "1", "builtin": { "name": "alt_bn128_pairing", - "activate_at": "0", - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_pairing": { - "base": 100000, - "pair": 80000, - "eip1108_transition_base": 45000, - "eip1108_transition_pair": 34000 + "0": { + "price": { "alt_bn128_pairing": { "base": 100000, "pair": 80000 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_pairing": { "base": 45000, "pair": 34000 }} } - } + } } }, "0x1204700000000000000000000000000000000005": { diff --git a/ethcore/res/ethereum/expanse.json b/ethcore/res/ethereum/expanse.json index 5b950e28b02..bbaa4275d2e 100644 --- a/ethcore/res/ethereum/expanse.json +++ b/ethcore/res/ethereum/expanse.json @@ -79,12 +79,13 @@ "0000000000000000000000000000000000000006": { "builtin": { "name": "alt_bn128_add", - "activate_at": "0xC3500", - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_const_operations": { - "price": 500, - "eip1108_transition_price": 150 + "0xC3500": { + "price": { "alt_bn128_const_operations": { "price": 500 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_const_operations": { "price": 150 }} } } } @@ -92,12 +93,13 @@ "0000000000000000000000000000000000000007": { "builtin": { "name": "alt_bn128_mul", - "activate_at": "0xC3500", - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_const_operations": { - "price": 40000, - "eip1108_transition_price": 6000 + "0xC3500": { + "price": { "alt_bn128_const_operations": { "price": 40000 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_const_operations": { "price": 6000 }} } } } @@ -105,14 +107,13 @@ "0000000000000000000000000000000000000008": { "builtin": { "name": "alt_bn128_pairing", - "activate_at": "0xC3500", - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_pairing": { - "base": 100000, - "pair": 80000, - "eip1108_transition_base": 45000, - "eip1108_transition_pair": 34000 + "0xC3500": { + "price": { "alt_bn128_pairing": { "base": 100000, "pair": 80000 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_pairing": { "base": 45000, "pair": 34000 }} } } } diff --git a/ethcore/res/ethereum/foundation.json b/ethcore/res/ethereum/foundation.json index 13c0e81793f..0549568d9c9 100644 --- a/ethcore/res/ethereum/foundation.json +++ b/ethcore/res/ethereum/foundation.json @@ -4446,12 +4446,13 @@ "0x0000000000000000000000000000000000000006": { "builtin": { "name": "alt_bn128_add", - "activate_at": "0x42ae50", - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_const_operations": { - "price": 500, - "eip1108_transition_price": 150 + "0x42ae50": { + "price": { "alt_bn128_const_operations": { "price": 500 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_const_operations": { "price": 150 }} } } } @@ -4459,12 +4460,13 @@ "0x0000000000000000000000000000000000000007": { "builtin": { "name": "alt_bn128_mul", - "activate_at": "0x42ae50", - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_const_operations": { - "price": 40000, - "eip1108_transition_price": 6000 + "0x42ae50": { + "price": { "alt_bn128_const_operations": { "price": 40000 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_const_operations": { "price": 6000 }} } } } @@ -4472,14 +4474,13 @@ "0x0000000000000000000000000000000000000008": { "builtin": { "name": "alt_bn128_pairing", - "activate_at": "0x42ae50", - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_pairing": { - "base": 100000, - "pair": 80000, - "eip1108_transition_base": 45000, - "eip1108_transition_pair": 34000 + "0x42ae50": { + "price": { "alt_bn128_pairing": { "base": 100000, "pair": 80000 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_pairing": { "base": 45000, "pair": 34000 }} } } } diff --git a/ethcore/res/ethereum/goerli.json b/ethcore/res/ethereum/goerli.json index e7aaa4c485a..92b77b55c85 100644 --- a/ethcore/res/ethereum/goerli.json +++ b/ethcore/res/ethereum/goerli.json @@ -130,12 +130,13 @@ "balance": "0x1", "builtin": { "name": "alt_bn128_add", - "activate_at": "0x00", - "eip1108_transition": "0x17d433", "pricing": { - "alt_bn128_const_operations": { - "price": 500, - "eip1108_transition_price": 150 + "0": { + "price": { "alt_bn128_const_operations": { "price": 500 }} + }, + "0x17d433": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_const_operations": { "price": 150 }} } } } @@ -144,12 +145,13 @@ "balance": "0x1", "builtin": { "name": "alt_bn128_mul", - "activate_at": "0x00", - "eip1108_transition": "0x17d433", "pricing": { - "alt_bn128_const_operations": { - "price": 40000, - "eip1108_transition_price": 6000 + "0": { + "price": { "alt_bn128_const_operations": { "price": 40000 }} + }, + "0x17d433": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_const_operations": { "price": 6000 }} } } } @@ -158,14 +160,13 @@ "balance": "0x1", "builtin": { "name": "alt_bn128_pairing", - "activate_at": "0x00", - "eip1108_transition": "0x17d433", "pricing": { - "alt_bn128_pairing": { - "base": 100000, - "pair": 80000, - "eip1108_transition_base": 45000, - "eip1108_transition_pair": 34000 + "0": { + "price": { "alt_bn128_pairing": { "base": 100000, "pair": 80000 }} + }, + "0x17d433": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_pairing": { "base": 45000, "pair": 34000 }} } } } diff --git a/ethcore/res/ethereum/istanbul_test.json b/ethcore/res/ethereum/istanbul_test.json index 1276dc4c53c..0139d10c2da 100644 --- a/ethcore/res/ethereum/istanbul_test.json +++ b/ethcore/res/ethereum/istanbul_test.json @@ -67,12 +67,13 @@ "0000000000000000000000000000000000000006": { "builtin": { "name": "alt_bn128_add", - "activate_at": "0x00", - "eip1108_transition": "0x0", "pricing": { - "alt_bn128_const_operations": { - "price": 500, - "eip1108_transition_price": 150 + "0": { + "price": { "alt_bn128_const_operations": { "price": 500 }} + }, + "0": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_const_operations": { "price": 150 }} } } } @@ -80,12 +81,13 @@ "0000000000000000000000000000000000000007": { "builtin": { "name": "alt_bn128_mul", - "activate_at": "0x00", - "eip1108_transition": "0x0", "pricing": { - "alt_bn128_const_operations": { - "price": 40000, - "eip1108_transition_price": 6000 + "0": { + "price": { "alt_bn128_const_operations": { "price": 40000 }} + }, + "0": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_const_operations": { "price": 6000 }} } } } @@ -93,14 +95,13 @@ "0000000000000000000000000000000000000008": { "builtin": { "name": "alt_bn128_pairing", - "activate_at": "0x00", - "eip1108_transition": "0x0", "pricing": { - "alt_bn128_pairing": { - "base": 100000, - "pair": 80000, - "eip1108_transition_base": 45000, - "eip1108_transition_pair": 34000 + "0": { + "price": { "alt_bn128_pairing": { "base": 100000, "pair": 80000 }} + }, + "0": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_pairing": { "base": 45000, "pair": 34000 }} } } } diff --git a/ethcore/res/ethereum/kotti.json b/ethcore/res/ethereum/kotti.json index bc696a7db5a..81bd2c29608 100644 --- a/ethcore/res/ethereum/kotti.json +++ b/ethcore/res/ethereum/kotti.json @@ -116,12 +116,13 @@ "balance": "0x1", "builtin": { "name": "alt_bn128_add", - "activate_at": "0xaef49", - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_const_operations": { - "price": 500, - "eip1108_transition_price": 150 + "0xaef49": { + "price": { "alt_bn128_const_operations": { "price": 500 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_const_operations": { "price": 150 }} } } } @@ -130,12 +131,13 @@ "balance": "0x1", "builtin": { "name": "alt_bn128_mul", - "activate_at": "0xaef49", - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_const_operations": { - "price": 40000, - "eip1108_transition_price": 6000 + "0xaef49": { + "price": { "alt_bn128_const_operations": { "price": 40000 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_const_operations": { "price": 6000 }} } } } @@ -144,14 +146,13 @@ "balance": "0x1", "builtin": { "name": "alt_bn128_pairing", - "activate_at": "0xaef49", - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_pairing": { - "base": 100000, - "pair": 80000, - "eip1108_transition_base": 45000, - "eip1108_transition_pair": 34000 + "0xaef49": { + "price": { "alt_bn128_pairing": { "base": 100000, "pair": 80000 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_pairing": { "base": 45000, "pair": 34000 }} } } } diff --git a/ethcore/res/ethereum/kovan.json b/ethcore/res/ethereum/kovan.json index cba31899bd4..dd5c3f65710 100644 --- a/ethcore/res/ethereum/kovan.json +++ b/ethcore/res/ethereum/kovan.json @@ -6726,12 +6726,13 @@ "0x0000000000000000000000000000000000000006": { "builtin": { "name": "alt_bn128_add", - "activate_at": "0x4d50f8", - "eip1108_transition": "0xd751a5", "pricing": { - "alt_bn128_const_operations": { - "price": 500, - "eip1108_transition_price": 150 + "0x4d50f8": { + "price": { "alt_bn128_const_operations": { "price": 500 }} + }, + "0xd751a5": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_const_operations": { "price": 150 }} } } } @@ -6739,12 +6740,13 @@ "0x0000000000000000000000000000000000000007": { "builtin": { "name": "alt_bn128_mul", - "activate_at": "0x4d50f8", - "eip1108_transition": "0xd751a5", "pricing": { - "alt_bn128_const_operations": { - "price": 40000, - "eip1108_transition_price": 6000 + "0x4d50f8": { + "price": { "alt_bn128_const_operations": { "price": 40000 }} + }, + "0xd751a5": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_const_operations": { "price": 6000 }} } } } @@ -6752,14 +6754,13 @@ "0x0000000000000000000000000000000000000008": { "builtin": { "name": "alt_bn128_pairing", - "activate_at": "0x4d50f8", - "eip1108_transition": "0xd751a5", "pricing": { - "alt_bn128_pairing": { - "base": 100000, - "pair": 80000, - "eip1108_transition_base": 45000, - "eip1108_transition_pair": 34000 + "0x4d50f8": { + "price": { "alt_bn128_pairing": { "base": 100000, "pair": 80000 }} + }, + "0xd751a5": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_pairing": { "base": 45000, "pair": 34000 }} } } } diff --git a/ethcore/res/ethereum/kovan_wasm_test.json b/ethcore/res/ethereum/kovan_wasm_test.json index 54c4a1b83f1..70143d8a8de 100644 --- a/ethcore/res/ethereum/kovan_wasm_test.json +++ b/ethcore/res/ethereum/kovan_wasm_test.json @@ -63,12 +63,13 @@ "0x0000000000000000000000000000000000000006": { "builtin": { "name": "alt_bn128_add", - "activate_at": 5067000, - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_const_operations": { - "price": 500, - "eip1108_transition_price": 150 + "5067000": { + "price": { "alt_bn128_const_operations": { "price": 500 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_const_operations": { "price": 150 }} } } } @@ -76,12 +77,13 @@ "0x0000000000000000000000000000000000000007": { "builtin": { "name": "alt_bn128_mul", - "activate_at": 5067000, - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_const_operations": { - "price": 40000, - "eip1108_transition_price": 6000 + "5067000": { + "price": { "alt_bn128_const_operations": { "price": 40000 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_const_operations": { "price": 6000 }} } } } @@ -89,14 +91,13 @@ "0x0000000000000000000000000000000000000008": { "builtin": { "name": "alt_bn128_pairing", - "activate_at": 5067000, - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_pairing": { - "base": 100000, - "pair": 80000, - "eip1108_transition_base": 45000, - "eip1108_transition_pair": 34000 + "5067000": { + "price": { "alt_bn128_pairing": { "base": 100000, "pair": 80000 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_pairing": { "base": 45000, "pair": 34000 }} } } } diff --git a/ethcore/res/ethereum/mcip3_test.json b/ethcore/res/ethereum/mcip3_test.json index 8f1426b992a..aee04b36574 100644 --- a/ethcore/res/ethereum/mcip3_test.json +++ b/ethcore/res/ethereum/mcip3_test.json @@ -123,12 +123,13 @@ "0000000000000000000000000000000000000006": { "builtin": { "name": "alt_bn128_add", - "activate_at":"0x7fffffffffffff", - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_const_operations": { - "price": 500, - "eip1108_transition_price": 150 + "0x7fffffffffffff": { + "price": { "alt_bn128_const_operations": { "price": 500 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_const_operations": { "price": 150 }} } } } @@ -136,12 +137,13 @@ "0000000000000000000000000000000000000007": { "builtin": { "name": "alt_bn128_mul", - "activate_at":"0x7fffffffffffff", - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_const_operations": { - "price": 40000, - "eip1108_transition_price": 6000 + "0x7fffffffffffff": { + "price": { "alt_bn128_const_operations": { "price": 40000 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_const_operations": { "price": 6000 }} } } } @@ -149,14 +151,13 @@ "0000000000000000000000000000000000000008": { "builtin": { "name": "alt_bn128_pairing", - "activate_at":"0x7fffffffffffff", - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_pairing": { - "base": 100000, - "pair": 80000, - "eip1108_transition_base": 45000, - "eip1108_transition_pair": 34000 + "0x7fffffffffffff": { + "price": { "alt_bn128_pairing": { "base": 100000, "pair": 80000 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_pairing": { "base": 45000, "pair": 34000 }} } } } diff --git a/ethcore/res/ethereum/mix.json b/ethcore/res/ethereum/mix.json index 4be009ada2f..ae247a92f83 100644 --- a/ethcore/res/ethereum/mix.json +++ b/ethcore/res/ethereum/mix.json @@ -75,12 +75,13 @@ "0000000000000000000000000000000000000006": { "builtin": { "name": "alt_bn128_add", - "activate_at": 3000000, - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_const_operations": { - "price": 500, - "eip1108_transition_price": 150 + "3000000": { + "price": { "alt_bn128_const_operations": { "price": 500 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_const_operations": { "price": 150 }} } } } @@ -88,12 +89,13 @@ "0000000000000000000000000000000000000007": { "builtin": { "name": "alt_bn128_mul", - "activate_at": 3000000, - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_const_operations": { - "price": 40000, - "eip1108_transition_price": 6000 + "3000000": { + "price": { "alt_bn128_const_operations": { "price": 40000 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_const_operations": { "price": 6000 }} } } } @@ -101,14 +103,13 @@ "0000000000000000000000000000000000000008": { "builtin": { "name": "alt_bn128_pairing", - "activate_at": 3000000, - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_pairing": { - "base": 100000, - "pair": 80000, - "eip1108_transition_base": 45000, - "eip1108_transition_pair": 34000 + "3000000": { + "price": { "alt_bn128_pairing": { "base": 100000, "pair": 80000 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_pairing": { "base": 45000, "pair": 34000 }} } } } diff --git a/ethcore/res/ethereum/morden.json b/ethcore/res/ethereum/morden.json index a4be222c16c..442baea4bfb 100644 --- a/ethcore/res/ethereum/morden.json +++ b/ethcore/res/ethereum/morden.json @@ -75,7 +75,7 @@ "0000000000000000000000000000000000000002": { "balance": "1", "nonce": "1048576", "builtin": { "name": "sha256", "pricing": { "linear": { "base": 60, "word": 12 } } } }, "0000000000000000000000000000000000000003": { "balance": "1", "nonce": "1048576", "builtin": { "name": "ripemd160", "pricing": { "linear": { "base": 600, "word": 120 } } } }, "0000000000000000000000000000000000000004": { "balance": "1", "nonce": "1048576", "builtin": { "name": "identity", "pricing": { "linear": { "base": 15, "word": 3 } } } }, - "0x0000000000000000000000000000000000000005": { + "0000000000000000000000000000000000000005": { "builtin": { "name": "modexp", "activate_at": "0x4829ba", @@ -86,43 +86,44 @@ } } }, - "0x0000000000000000000000000000000000000006": { + "0000000000000000000000000000000000000006": { "builtin": { "name": "alt_bn128_add", - "activate_at": "0x4829ba", - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_const_operations": { - "price": 500, - "eip1108_transition_price": 150 + "0x4829ba": { + "price": { "alt_bn128_const_operations": { "price": 500 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_const_operations": { "price": 150 }} } } } }, - "0x0000000000000000000000000000000000000007": { + "0000000000000000000000000000000000000007": { "builtin": { "name": "alt_bn128_mul", - "activate_at": "0x4829ba", - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_const_operations": { - "price": 40000, - "eip1108_transition_price": 6000 + "0x4829ba": { + "price": { "alt_bn128_const_operations": { "price": 40000 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_const_operations": { "price": 6000 }} } } } }, - "0x0000000000000000000000000000000000000008": { + "0000000000000000000000000000000000000008": { "builtin": { "name": "alt_bn128_pairing", - "activate_at": "0x4829ba", - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_pairing": { - "base": 100000, - "pair": 80000, - "eip1108_transition_base": 45000, - "eip1108_transition_pair": 34000 + "0x4829ba": { + "price": { "alt_bn128_pairing": { "base": 100000, "pair": 80000 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_pairing": { "base": 45000, "pair": 34000 }} } } } diff --git a/ethcore/res/ethereum/musicoin.json b/ethcore/res/ethereum/musicoin.json index a7cc956b47d..cc60dc1bd5b 100644 --- a/ethcore/res/ethereum/musicoin.json +++ b/ethcore/res/ethereum/musicoin.json @@ -131,12 +131,13 @@ "0000000000000000000000000000000000000006": { "builtin": { "name": "alt_bn128_add", - "activate_at":"0x21e88e", - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_const_operations": { - "price": 500, - "eip1108_transition_price": 150 + "0x21e88e": { + "price": { "alt_bn128_const_operations": { "price": 500 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_const_operations": { "price": 150 }} } } } @@ -144,12 +145,13 @@ "0000000000000000000000000000000000000007": { "builtin": { "name": "alt_bn128_mul", - "activate_at":"0x21e88e", - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_const_operations": { - "price": 40000, - "eip1108_transition_price": 6000 + "0x21e88e": { + "price": { "alt_bn128_const_operations": { "price": 40000 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_const_operations": { "price": 6000 }} } } } @@ -157,14 +159,13 @@ "0000000000000000000000000000000000000008": { "builtin": { "name": "alt_bn128_pairing", - "activate_at":"0x21e88e", - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_pairing": { - "base": 100000, - "pair": 80000, - "eip1108_transition_base": 45000, - "eip1108_transition_pair": 34000 + "0x21e88e": { + "price": { "alt_bn128_pairing": { "base": 100000, "pair": 80000 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_pairing": { "base": 45000, "pair": 34000 }} } } } diff --git a/ethcore/res/ethereum/poacore.json b/ethcore/res/ethereum/poacore.json index 4372f51f464..36c26fc1d47 100644 --- a/ethcore/res/ethereum/poacore.json +++ b/ethcore/res/ethereum/poacore.json @@ -5410,12 +5410,13 @@ "0000000000000000000000000000000000000006": { "builtin": { "name": "alt_bn128_add", - "activate_at": "0x0", - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_const_operations": { - "price": 500, - "eip1108_transition_price": 150 + "0": { + "price": { "alt_bn128_const_operations": { "price": 500 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_const_operations": { "price": 150 }} } } } @@ -5423,12 +5424,13 @@ "0000000000000000000000000000000000000007": { "builtin": { "name": "alt_bn128_mul", - "activate_at": "0x0", - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_const_operations": { - "price": 40000, - "eip1108_transition_price": 6000 + "0": { + "price": { "alt_bn128_const_operations": { "price": 40000 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_const_operations": { "price": 6000 }} } } } @@ -5436,14 +5438,13 @@ "0000000000000000000000000000000000000008": { "builtin": { "name": "alt_bn128_pairing", - "activate_at": "0x0", - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_pairing": { - "base": 100000, - "pair": 80000, - "eip1108_transition_base": 45000, - "eip1108_transition_pair": 34000 + "0": { + "price": { "alt_bn128_pairing": { "base": 100000, "pair": 80000 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_pairing": { "base": 45000, "pair": 34000 }} } } } diff --git a/ethcore/res/ethereum/poasokol.json b/ethcore/res/ethereum/poasokol.json index 11dc67d3559..c8f1f03e5ed 100644 --- a/ethcore/res/ethereum/poasokol.json +++ b/ethcore/res/ethereum/poasokol.json @@ -5316,12 +5316,13 @@ "0000000000000000000000000000000000000006": { "builtin": { "name": "alt_bn128_add", - "activate_at": "0x0", - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_const_operations": { - "price": 500, - "eip1108_transition_price": 150 + "0": { + "price": { "alt_bn128_const_operations": { "price": 500 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_const_operations": { "price": 150 }} } } } @@ -5329,12 +5330,13 @@ "0000000000000000000000000000000000000007": { "builtin": { "name": "alt_bn128_mul", - "activate_at": "0x0", - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_const_operations": { - "price": 40000, - "eip1108_transition_price": 6000 + "0": { + "price": { "alt_bn128_const_operations": { "price": 40000 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_const_operations": { "price": 6000 }} } } } @@ -5342,19 +5344,17 @@ "0000000000000000000000000000000000000008": { "builtin": { "name": "alt_bn128_pairing", - "activate_at": "0x0", - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_pairing": { - "base": 100000, - "pair": 80000, - "eip1108_transition_base": 45000, - "eip1108_transition_pair": 34000 + "0": { + "price": { "alt_bn128_pairing": { "base": 100000, "pair": 80000 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_pairing": { "base": 45000, "pair": 34000 }} } } } }, - "0x0000000000000000000000000000000000000001": { "balance": "1", "builtin": { diff --git a/ethcore/res/ethereum/rinkeby.json b/ethcore/res/ethereum/rinkeby.json index 790d6d33eaf..bcc96a80129 100644 --- a/ethcore/res/ethereum/rinkeby.json +++ b/ethcore/res/ethereum/rinkeby.json @@ -125,12 +125,13 @@ "balance": "0x1", "builtin": { "name": "alt_bn128_add", - "activate_at": "0xfcc25", - "eip1108_transition": "0x52efd1", "pricing": { - "alt_bn128_const_operations": { - "price": 500, - "eip1108_transition_price": 150 + "0xfcc25": { + "price": { "alt_bn128_const_operations": { "price": 500 }} + }, + "0x52efd1": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_const_operations": { "price": 150 }} } } } @@ -139,12 +140,13 @@ "balance": "0x1", "builtin": { "name": "alt_bn128_mul", - "activate_at": "0xfcc25", - "eip1108_transition": "0x52efd1", "pricing": { - "alt_bn128_const_operations": { - "price": 40000, - "eip1108_transition_price": 6000 + "0xfcc25": { + "price": { "alt_bn128_const_operations": { "price": 40000 }} + }, + "0x52efd1": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_const_operations": { "price": 6000 }} } } } @@ -153,14 +155,13 @@ "balance": "0x1", "builtin": { "name": "alt_bn128_pairing", - "activate_at": "0xfcc25", - "eip1108_transition": "0x52efd1", "pricing": { - "alt_bn128_pairing": { - "base": 100000, - "pair": 80000, - "eip1108_transition_base": 45000, - "eip1108_transition_pair": 34000 + "0xfcc25": { + "price": { "alt_bn128_pairing": { "base": 100000, "pair": 80000 }} + }, + "0x52efd1": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_pairing": { "base": 45000, "pair": 34000 }} } } } diff --git a/ethcore/res/ethereum/ropsten.json b/ethcore/res/ethereum/ropsten.json index aefca8682cc..f65a77ac750 100644 --- a/ethcore/res/ethereum/ropsten.json +++ b/ethcore/res/ethereum/ropsten.json @@ -2739,12 +2739,13 @@ "nonce": "0x0", "builtin": { "name": "alt_bn128_add", - "activate_at": "0x19f0a0", - "eip1108_transition": "0x62f756", "pricing": { - "alt_bn128_const_operations": { - "price": 500, - "eip1108_transition_price": 150 + "0x19f0a0": { + "price": { "alt_bn128_const_operations": { "price": 500 }} + }, + "0x62f756": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_const_operations": { "price": 150 }} } } } @@ -2754,12 +2755,13 @@ "nonce": "0x0", "builtin": { "name": "alt_bn128_mul", - "activate_at": "0x19f0a0", - "eip1108_transition": "0x62f756", "pricing": { - "alt_bn128_const_operations": { - "price": 40000, - "eip1108_transition_price": 6000 + "0x19f0a0": { + "price": { "alt_bn128_const_operations": { "price": 40000 }} + }, + "0x62f756": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_const_operations": { "price": 6000 }} } } } @@ -2769,14 +2771,13 @@ "nonce": "0x0", "builtin": { "name": "alt_bn128_pairing", - "activate_at": "0x19f0a0", - "eip1108_transition": "0x62f756", "pricing": { - "alt_bn128_pairing": { - "base": 100000, - "pair": 80000, - "eip1108_transition_base": 45000, - "eip1108_transition_pair": 34000 + "0x19f0a0": { + "price": { "alt_bn128_pairing": { "base": 100000, "pair": 80000 }} + }, + "0x62f756": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_pairing": { "base": 45000, "pair": 34000 }} } } } diff --git a/ethcore/res/ethereum/st_peters_test.json b/ethcore/res/ethereum/st_peters_test.json index 768e6057fd2..ac404c7dca1 100644 --- a/ethcore/res/ethereum/st_peters_test.json +++ b/ethcore/res/ethereum/st_peters_test.json @@ -62,12 +62,13 @@ "0000000000000000000000000000000000000006": { "builtin": { "name": "alt_bn128_add", - "activate_at": "0x0", - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_const_operations": { - "price": 500, - "eip1108_transition_price": 150 + "0": { + "price": { "alt_bn128_const_operations": { "price": 500 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_const_operations": { "price": 150 }} } } } @@ -75,12 +76,13 @@ "0000000000000000000000000000000000000007": { "builtin": { "name": "alt_bn128_mul", - "activate_at": "0x0", - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_const_operations": { - "price": 40000, - "eip1108_transition_price": 6000 + "0": { + "price": { "alt_bn128_const_operations": { "price": 40000 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_const_operations": { "price": 6000 }} } } } @@ -88,14 +90,13 @@ "0000000000000000000000000000000000000008": { "builtin": { "name": "alt_bn128_pairing", - "activate_at": "0x0", - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_pairing": { - "base": 100000, - "pair": 80000, - "eip1108_transition_base": 45000, - "eip1108_transition_pair": 34000 + "0": { + "price": { "alt_bn128_pairing": { "base": 100000, "pair": 80000 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_pairing": { "base": 45000, "pair": 34000 }} } } } diff --git a/ethcore/res/ethereum/transition_test.json b/ethcore/res/ethereum/transition_test.json index bc28ebd509b..901f4dfded3 100644 --- a/ethcore/res/ethereum/transition_test.json +++ b/ethcore/res/ethereum/transition_test.json @@ -60,12 +60,13 @@ "0000000000000000000000000000000000000006": { "builtin": { "name": "alt_bn128_add", - "activate_at": "5", - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_const_operations": { - "price": 500, - "eip1108_transition_price": 150 + "5": { + "price": { "alt_bn128_const_operations": { "price": 500 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_const_operations": { "price": 150 }} } } } @@ -73,12 +74,13 @@ "0000000000000000000000000000000000000007": { "builtin": { "name": "alt_bn128_mul", - "activate_at": "5", - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_const_operations": { - "price": 40000, - "eip1108_transition_price": 6000 + "5": { + "price": { "alt_bn128_const_operations": { "price": 40000 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_const_operations": { "price": 6000 }} } } } @@ -86,14 +88,13 @@ "0000000000000000000000000000000000000008": { "builtin": { "name": "alt_bn128_pairing", - "activate_at": "5", - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_pairing": { - "base": 100000, - "pair": 80000, - "eip1108_transition_base": 45000, - "eip1108_transition_pair": 34000 + "5": { + "price": { "alt_bn128_pairing": { "base": 100000, "pair": 80000 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_pairing": { "base": 45000, "pair": 34000 }} } } } diff --git a/ethcore/res/ethereum/volta.json b/ethcore/res/ethereum/volta.json index 62745086b67..55cc39d9997 100644 --- a/ethcore/res/ethereum/volta.json +++ b/ethcore/res/ethereum/volta.json @@ -1207,46 +1207,47 @@ "balance": "1", "builtin": { "name": "alt_bn128_add", - "activate_at": "0", - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_const_operations": { - "price": 500, - "eip1108_transition_price": 150 + "0": { + "price": { "alt_bn128_const_operations": { "price": 500 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_const_operations": { "price": 150 }} } } } - }, - "0x0000000000000000000000000000000000000007": { + }, + "0x0000000000000000000000000000000000000007": { "balance": "1", "builtin": { "name": "alt_bn128_mul", - "activate_at": "0", - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_const_operations": { - "price": 40000, - "eip1108_transition_price": 6000 + "0": { + "price": { "alt_bn128_const_operations": { "price": 40000 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_const_operations": { "price": 6000 }} } } - } + } }, "0x0000000000000000000000000000000000000008": { "balance": "1", "builtin": { "name": "alt_bn128_pairing", - "activate_at": "0", - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_pairing": { - "base": 100000, - "pair": 80000, - "eip1108_transition_base": 45000, - "eip1108_transition_pair": 34000 + "0": { + "price": { "alt_bn128_pairing": { "base": 100000, "pair": 80000 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_pairing": { "base": 45000, "pair": 34000 }} } } } - }, + }, "0x1204700000000000000000000000000000000005": { "constructor": "0x606060405234156200001057600080fd5b6040516200240138038062002401833981016040528080518201919060200180519060200190919050505b600082518260328211158015620000525750818111155b801562000060575060008114155b80156200006e575060008214155b15156200007a57600080fd5b600092505b8451831015620001b6576002600086858151811015156200009c57fe5b9060200190602002015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161580156200012b5750600085848151811015156200010857fe5b9060200190602002015173ffffffffffffffffffffffffffffffffffffffff1614155b15156200013757600080fd5b60016002600087868151811015156200014c57fe5b9060200190602002015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055505b82806001019350506200007f565b8460039080519060200190620001ce929190620001e3565b50836004819055505b5b5050505050620002b8565b8280548282559060005260206000209081019282156200025f579160200282015b828111156200025e5782518260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055509160200191906001019062000204565b5b5090506200026e919062000272565b5090565b620002b591905b80821115620002b157600081816101000a81549073ffffffffffffffffffffffffffffffffffffffff02191690555060010162000279565b5090565b90565b61213980620002c86000396000f3006060604052361561011b576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063025e7c2714610177578063173825d9146101da57806320ea8d86146102135780632f54bf6e146102365780633411c81c1461028757806354741525146102e15780637065cb4814610325578063784547a71461035e5780638b51d13f146103995780639ace38c2146103d0578063a0e67e2b146104ce578063a8abe69a14610539578063b5dc40c3146105d1578063b77bf6001461064a578063ba51a6df14610673578063c01a8c8414610696578063c6427474146106b9578063d74f8edd14610752578063dc8452cd1461077b578063e20056e6146107a4578063ee22610b146107fc575b5b6000341115610174573373ffffffffffffffffffffffffffffffffffffffff167fe1fffcc4923d04b559f4d29a8bfc6cda04eb5b0d3c460751c2402c5c5cc9109c346040518082815260200191505060405180910390a25b5b005b341561018257600080fd5b610198600480803590602001909190505061081f565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34156101e557600080fd5b610211600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190505061085f565b005b341561021e57600080fd5b6102346004808035906020019091905050610b02565b005b341561024157600080fd5b61026d600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610cae565b604051808215151515815260200191505060405180910390f35b341561029257600080fd5b6102c7600480803590602001909190803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610cce565b604051808215151515815260200191505060405180910390f35b34156102ec57600080fd5b61030f600480803515159060200190919080351515906020019091905050610cfd565b6040518082815260200191505060405180910390f35b341561033057600080fd5b61035c600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610d91565b005b341561036957600080fd5b61037f6004808035906020019091905050610f99565b604051808215151515815260200191505060405180910390f35b34156103a457600080fd5b6103ba6004808035906020019091905050611081565b6040518082815260200191505060405180910390f35b34156103db57600080fd5b6103f16004808035906020019091905050611150565b604051808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200184815260200180602001831515151581526020018281038252848181546001816001161561010002031660029004815260200191508054600181600116156101000203166002900480156104bc5780601f10610491576101008083540402835291602001916104bc565b820191906000526020600020905b81548152906001019060200180831161049f57829003601f168201915b50509550505050505060405180910390f35b34156104d957600080fd5b6104e16111ac565b6040518080602001828103825283818151815260200191508051906020019060200280838360005b838110156105255780820151818401525b602081019050610509565b505050509050019250505060405180910390f35b341561054457600080fd5b610579600480803590602001909190803590602001909190803515159060200190919080351515906020019091905050611241565b6040518080602001828103825283818151815260200191508051906020019060200280838360005b838110156105bd5780820151818401525b6020810190506105a1565b505050509050019250505060405180910390f35b34156105dc57600080fd5b6105f260048080359060200190919050506113a2565b6040518080602001828103825283818151815260200191508051906020019060200280838360005b838110156106365780820151818401525b60208101905061061a565b505050509050019250505060405180910390f35b341561065557600080fd5b61065d6115d3565b6040518082815260200191505060405180910390f35b341561067e57600080fd5b61069460048080359060200190919050506115d9565b005b34156106a157600080fd5b6106b76004808035906020019091905050611696565b005b34156106c457600080fd5b61073c600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803590602001909190803590602001908201803590602001908080601f01602080910402602001604051908101604052809392919081815260200183838082843782019150505050505091905050611877565b6040518082815260200191505060405180910390f35b341561075d57600080fd5b610765611897565b6040518082815260200191505060405180910390f35b341561078657600080fd5b61078e61189c565b6040518082815260200191505060405180910390f35b34156107af57600080fd5b6107fa600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff169060200190919050506118a2565b005b341561080757600080fd5b61081d6004808035906020019091905050611bc0565b005b60038181548110151561082e57fe5b906000526020600020900160005b915054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60003073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561089b57600080fd5b81600260008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615156108f457600080fd5b6000600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff021916908315150217905550600091505b600160038054905003821015610a80578273ffffffffffffffffffffffffffffffffffffffff1660038381548110151561098757fe5b906000526020600020900160005b9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161415610a725760036001600380549050038154811015156109e757fe5b906000526020600020900160005b9054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600383815481101515610a2357fe5b906000526020600020900160005b6101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550610a80565b5b8180600101925050610951565b6001600381818054905003915081610a989190611fe8565b506003805490506004541115610ab757610ab66003805490506115d9565b5b8273ffffffffffffffffffffffffffffffffffffffff167f8001553a916ef2f495d26a907cc54d96ed840d7bda71e73194bf5a9df7a76b9060405160405180910390a25b5b505b5050565b33600260008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161515610b5b57600080fd5b81336001600083815260200190815260200160002060008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161515610bc657600080fd5b8360008082815260200190815260200160002060030160009054906101000a900460ff16151515610bf657600080fd5b60006001600087815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff021916908315150217905550843373ffffffffffffffffffffffffffffffffffffffff167ff6a317157440607f36269043eb55f1287a5a19ba2216afeab88cd46cbcfb88e960405160405180910390a35b5b505b50505b5050565b60026020528060005260406000206000915054906101000a900460ff1681565b60016020528160005260406000206020528060005260406000206000915091509054906101000a900460ff1681565b600080600090505b600554811015610d8957838015610d3c575060008082815260200190815260200160002060030160009054906101000a900460ff16155b80610d6f5750828015610d6e575060008082815260200190815260200160002060030160009054906101000a900460ff165b5b15610d7b576001820191505b5b8080600101915050610d05565b5b5092915050565b3073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610dcb57600080fd5b80600260008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16151515610e2557600080fd5b8160008173ffffffffffffffffffffffffffffffffffffffff1614151515610e4c57600080fd5b60016003805490500160045460328211158015610e695750818111155b8015610e76575060008114155b8015610e83575060008214155b1515610e8e57600080fd5b6001600260008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555060038054806001018281610efa9190612014565b916000526020600020900160005b87909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550508473ffffffffffffffffffffffffffffffffffffffff167ff39e6e1eb0edcf53c221607b54b00cd28f3196fed0a24994dc308b8f611b682d60405160405180910390a25b5b50505b505b505b50565b6000806000809150600090505b60038054905081101561107957600160008581526020019081526020016000206000600383815481101515610fd757fe5b906000526020600020900160005b9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615611058576001820191505b60045482141561106b576001925061107a565b5b8080600101915050610fa6565b5b5050919050565b600080600090505b600380549050811015611149576001600084815260200190815260200160002060006003838154811015156110ba57fe5b906000526020600020900160005b9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161561113b576001820191505b5b8080600101915050611089565b5b50919050565b60006020528060005260406000206000915090508060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169080600101549080600201908060030160009054906101000a900460ff16905084565b6111b4612040565b600380548060200260200160405190810160405280929190818152602001828054801561123657602002820191906000526020600020905b8160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190600101908083116111ec575b505050505090505b90565b611249612054565b611251612054565b6000806005546040518059106112645750595b908082528060200260200182016040525b50925060009150600090505b600554811015611322578580156112b8575060008082815260200190815260200160002060030160009054906101000a900460ff16155b806112eb57508480156112ea575060008082815260200190815260200160002060030160009054906101000a900460ff165b5b15611314578083838151811015156112ff57fe5b90602001906020020181815250506001820191505b5b8080600101915050611281565b8787036040518059106113325750595b908082528060200260200182016040525b5093508790505b8681101561139657828181518110151561136057fe5b906020019060200201518489830381518110151561137a57fe5b90602001906020020181815250505b808060010191505061134a565b5b505050949350505050565b6113aa612040565b6113b2612040565b6000806003805490506040518059106113c85750595b908082528060200260200182016040525b50925060009150600090505b60038054905081101561152b5760016000868152602001908152602001600020600060038381548110151561141657fe5b906000526020600020900160005b9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161561151d5760038181548110151561149f57fe5b906000526020600020900160005b9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1683838151811015156114da57fe5b9060200190602002019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250506001820191505b5b80806001019150506113e5565b816040518059106115395750595b908082528060200260200182016040525b509350600090505b818110156115ca57828181518110151561156857fe5b90602001906020020151848281518110151561158057fe5b9060200190602002019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250505b8080600101915050611552565b5b505050919050565b60055481565b3073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561161357600080fd5b600380549050816032821115801561162b5750818111155b8015611638575060008114155b8015611645575060008214155b151561165057600080fd5b826004819055507fa3f1ee9126a074d9326c682f561767f710e927faa811f7a99829d49dc421797a836040518082815260200191505060405180910390a15b5b50505b50565b33600260008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615156116ef57600080fd5b81600080600083815260200190815260200160002060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161415151561174b57600080fd5b82336001600083815260200190815260200160002060008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161515156117b757600080fd5b600180600087815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff021916908315150217905550843373ffffffffffffffffffffffffffffffffffffffff167f4a504a94899432a9846e1aa406dceb1bcfd538bb839071d49d1e5e23f5be30ef60405160405180910390a361186c85611bc0565b5b5b50505b505b5050565b6000611884848484611e6c565b905061188f81611696565b5b9392505050565b603281565b60045481565b60003073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156118de57600080fd5b82600260008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16151561193757600080fd5b82600260008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615151561199157600080fd5b600092505b600380549050831015611a7f578473ffffffffffffffffffffffffffffffffffffffff166003848154811015156119c957fe5b906000526020600020900160005b9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161415611a715783600384815481101515611a2257fe5b906000526020600020900160005b6101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550611a7f565b5b8280600101935050611996565b6000600260008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506001600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508473ffffffffffffffffffffffffffffffffffffffff167f8001553a916ef2f495d26a907cc54d96ed840d7bda71e73194bf5a9df7a76b9060405160405180910390a28373ffffffffffffffffffffffffffffffffffffffff167ff39e6e1eb0edcf53c221607b54b00cd28f3196fed0a24994dc308b8f611b682d60405160405180910390a25b5b505b505b505050565b600033600260008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161515611c1b57600080fd5b82336001600083815260200190815260200160002060008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161515611c8657600080fd5b8460008082815260200190815260200160002060030160009054906101000a900460ff16151515611cb657600080fd5b611cbf86610f99565b15611e6057600080878152602001908152602001600020945060018560030160006101000a81548160ff021916908315150217905550611ddd8560000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16866001015487600201805460018160011615610100020316600290049050886002018054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015611dd35780601f10611da857610100808354040283529160200191611dd3565b820191906000526020600020905b815481529060010190602001808311611db657829003601f168201915b5050505050611fc0565b15611e1457857f33e13ecb54c3076d8e8bb8c2881800a4d972b792045ffae98fdf46df365fed7560405160405180910390a2611e5f565b857f526441bb6c1aba3c9a4a6ca1d6545da9c2333c8c48343ef398eb858d72b7923660405160405180910390a260008560030160006101000a81548160ff0219169083151502179055505b5b5b5b505b50505b505050565b60008360008173ffffffffffffffffffffffffffffffffffffffff1614151515611e9557600080fd5b60055491506080604051908101604052808673ffffffffffffffffffffffffffffffffffffffff1681526020018581526020018481526020016000151581525060008084815260200190815260200160002060008201518160000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550602082015181600101556040820151816002019080519060200190611f54929190612068565b5060608201518160030160006101000a81548160ff0219169083151502179055509050506001600560008282540192505081905550817fc0ba8fe4b176c1714197d43b9cc6bcf797a4a7461c5fe8d0ef6e184ae7601e5160405160405180910390a25b5b509392505050565b6000806040516020840160008287838a8c6187965a03f1925050508091505b50949350505050565b81548183558181151161200f5781836000526020600020918201910161200e91906120e8565b5b505050565b81548183558181151161203b5781836000526020600020918201910161203a91906120e8565b5b505050565b602060405190810160405280600081525090565b602060405190810160405280600081525090565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106120a957805160ff19168380011785556120d7565b828001600101855582156120d7579182015b828111156120d65782518255916020019190600101906120bb565b5b5090506120e491906120e8565b5090565b61210a91905b808211156121065760008160009055506001016120ee565b5090565b905600a165627a7a72305820f1129b699b3017535535a920e15503cd06af1f5c77637c0637cc29355b1dad3400290000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000040000000000000000000000000cb1437200aea736788f1fc56f327c0456c3598d00000000000000000000000074dd76e24b2cfb43c1b1a4498295d553d0843746000000000000000000000000eeb4ceee443f9e0d17bdbd6daa241681ee5e51c2000000000000000000000000a005caea55375ae20e3aaef746113535503abc19" }, diff --git a/ethcore/res/ethereum/xdai.json b/ethcore/res/ethereum/xdai.json index f83ae524ff0..f57c982e07b 100644 --- a/ethcore/res/ethereum/xdai.json +++ b/ethcore/res/ethereum/xdai.json @@ -2862,7 +2862,7 @@ ] }, "accounts": { - "0000000000000000000000000000000000000005": { + "0x0000000000000000000000000000000000000005": { "builtin": { "name": "modexp", "activate_at": "0x0", @@ -2873,43 +2873,44 @@ } } }, - "0000000000000000000000000000000000000006": { + "0x0000000000000000000000000000000000000006": { "builtin": { "name": "alt_bn128_add", - "activate_at": "0x0", - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_const_operations": { - "price": 500, - "eip1108_transition_price": 150 + "0": { + "price": { "alt_bn128_const_operations": { "price": 500 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_const_operations": { "price": 150 }} } } } }, - "0000000000000000000000000000000000000007": { + "0x0000000000000000000000000000000000000007": { "builtin": { "name": "alt_bn128_mul", - "activate_at": "0x0", - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_const_operations": { - "price": 40000, - "eip1108_transition_price": 6000 + "0": { + "price": { "alt_bn128_const_operations": { "price": 40000 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_const_operations": { "price": 6000 }} } } } }, - "0000000000000000000000000000000000000008": { + "0x0000000000000000000000000000000000000008": { "builtin": { "name": "alt_bn128_pairing", - "activate_at": "0x0", - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_pairing": { - "base": 100000, - "pair": 80000, - "eip1108_transition_base": 45000, - "eip1108_transition_pair": 34000 + "0": { + "price": { "alt_bn128_pairing": { "base": 100000, "pair": 80000 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_pairing": { "base": 45000, "pair": 34000 }} } } } diff --git a/ethcore/res/instant_seal.json b/ethcore/res/instant_seal.json index 0bd79204fb9..b2199ebc35a 100644 --- a/ethcore/res/instant_seal.json +++ b/ethcore/res/instant_seal.json @@ -50,12 +50,13 @@ "balance": "1", "builtin": { "name": "alt_bn128_add", - "activate_at": 0, - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_const_operations": { - "price": 500, - "eip1108_transition_price": 150 + "0": { + "price": { "alt_bn128_const_operations": { "price": 500 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_const_operations": { "price": 150 }} } } } @@ -64,12 +65,13 @@ "balance": "1", "builtin": { "name": "alt_bn128_mul", - "activate_at": 0, - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_const_operations": { - "price": 40000, - "eip1108_transition_price": 6000 + "0": { + "price": { "alt_bn128_const_operations": { "price": 40000 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_const_operations": { "price": 6000 }} } } } @@ -78,14 +80,13 @@ "balance": "1", "builtin": { "name": "alt_bn128_pairing", - "activate_at": 0, - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_pairing": { - "base": 100000, - "pair": 80000, - "eip1108_transition_base": 45000, - "eip1108_transition_pair": 34000 + "0": { + "price": { "alt_bn128_pairing": { "base": 100000, "pair": 80000 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_pairing": { "base": 45000, "pair": 34000 }} } } } diff --git a/ethcore/res/null.json b/ethcore/res/null.json index 5128f26c59c..82062366d8d 100644 --- a/ethcore/res/null.json +++ b/ethcore/res/null.json @@ -40,12 +40,13 @@ "balance": "1", "builtin": { "name": "alt_bn128_add", - "activate_at": 0, - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_const_operations": { - "price": 500, - "eip1108_transition_price": 150 + "0": { + "price": { "alt_bn128_const_operations": { "price": 500 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_const_operations": { "price": 150 }} } } } @@ -54,12 +55,13 @@ "balance": "1", "builtin": { "name": "alt_bn128_mul", - "activate_at": 0, - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_const_operations": { - "price": 40000, - "eip1108_transition_price": 6000 + "0": { + "price": { "alt_bn128_const_operations": { "price": 40000 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_const_operations": { "price": 6000 }} } } } @@ -68,14 +70,13 @@ "balance": "1", "builtin": { "name": "alt_bn128_pairing", - "activate_at": 0, - "eip1108_transition": "0x7fffffffffffff", "pricing": { - "alt_bn128_pairing": { - "base": 100000, - "pair": 80000, - "eip1108_transition_base": 45000, - "eip1108_transition_pair": 34000 + "0": { + "price": { "alt_bn128_pairing": { "base": 100000, "pair": 80000 }} + }, + "0x7fffffffffffff": { + "info": "EIP 1108 transition", + "price": { "alt_bn128_pairing": { "base": 45000, "pair": 34000 }} } } } diff --git a/ethcore/res/spec_backward_compability.json b/ethcore/res/spec_backward_compability.json new file mode 100644 index 00000000000..e8ce98a6ec4 --- /dev/null +++ b/ethcore/res/spec_backward_compability.json @@ -0,0 +1,155 @@ +{ + "name": "Volta", + "engine": { + "authorityRound": { + "params": { + "stepDuration": "5", + "validators": { + "contract": "0x1204700000000000000000000000000000000000" + }, + "maximumUncleCountTransition": "0", + "maximumUncleCount": "0", + "blockRewardContractAddress": "0x1204700000000000000000000000000000000002", + "blockRewardContractTransition": "0" + } + } + }, + "params": { + "networkID": "0x12047", + "maximumExtraDataSize": "0x20", + "gasLimitBoundDivisor": "0x400", + "minGasLimit": "0x1388", + "maxCodeSize": "0x6000", + "eip140Transition": "0x0", + "eip211Transition": "0x0", + "eip214Transition": "0x0", + "eip658Transition": "0x0", + "eip145Transition": "0x0", + "eip1014Transition": "0x0", + "eip1052Transition": "0x0", + "registrar": "0x1204700000000000000000000000000000000006" + }, + "genesis": { + "seal": { + "authorityRound": { + "step": "0x0", + "signature": "0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" + } + }, + "difficulty": "0x20000", + "gasLimit": "0x5B8D80" + }, + "accounts": { + "0x0000000000000000000000000000000000000001": { + "balance": "1", + "builtin": { + "name": "ecrecover", + "activate_at": "0", + "pricing": { + "linear": { + "base": 3000, + "word": 0 + } + } + } + }, + "0x0000000000000000000000000000000000000002": { + "balance": "1", + "builtin": { + "name": "sha256", + "activate_at": "0", + "pricing": { + "linear": { + "base": 60, + "word": 12 + } + } + } + }, + "0x0000000000000000000000000000000000000003": { + "balance": "1", + "builtin": { + "name": "ripemd160", + "activate_at": "0", + "pricing": { + "linear": { + "base": 600, + "word": 120 + } + } + } + }, + "0x0000000000000000000000000000000000000004": { + "balance": "1", + "builtin": { + "name": "identity", + "activate_at": "0", + "pricing": { + "linear": { + "base": 15, + "word": 3 + } + } + } + }, + "0x0000000000000000000000000000000000000005": { + "balance": "1", + "builtin": { + "name": "modexp", + "activate_at": "0", + "pricing": { + "modexp": { + "divisor": 20 + } + } + } + }, + "0x0000000000000000000000000000000000000006": { + "balance": "1", + "builtin": { + "name": "alt_bn128_add", + "activate_at": "0", + "pricing": { + "linear": { + "base": 500, + "word": 0 + } + } + } + }, + "0x0000000000000000000000000000000000000007": { + "balance": "1", + "builtin": { + "name": "alt_bn128_mul", + "activate_at": "0", + "pricing": { + "linear": { + "base": 40000, + "word": 0 + } + } + } + }, + "0x0000000000000000000000000000000000000008": { + "balance": "1", + "builtin": { + "name": "alt_bn128_pairing", + "activate_at": "0", + "pricing": { + "alt_bn128_pairing": { + "base": 100000, + "pair": 80000 + } + } + } + } + }, + "nodes": [ + "enode://59c9250cb805409e84c9cd0038e97d8e5e4605b928663675869ebdfd4c251d80ccad76267a5eb2f4362ddceb5ec671f7595463adfc0a12e9f68dbf233072db41@54.70.158.106:30303", + "enode://e487ebacbdad3418905d2ed7f009fa5dbd17d73880854884acc604c0afc1a60a396aa90cb2741278c555a4e30ffc6ffc1c29e83840aa22009ec92fe53f81ec04@99.81.92.124:30303", + "enode://563f12602a117201b39ebeea108185abb15d9286830c074640c9fccbaaaabcc7fe2c95682cc43f95b95059f6d0dc4c9becbc1b2bd78e0c5ef5fddff07d85ba0e@54.201.62.74:30303", + "enode://5903b3acebdc4a34800f6923e5f3aec3ca7e5d1285bec4adb9f20ebb0f87a3bebdd748b1849ca1108a9f1e37ff9ced0b475292b8effc29e95d49ec438f244b02@3.121.165.10:30303", + "enode://8f8e35a6dcacfee946f46447b4703c84f4e485e478143997f86b1834e1b0bb78dab363d700dff3147442b9d3e2a1c521f79340c436eb7245a97c7fe385b89a5d@54.93.159.98:30303", + "enode://bd228aa03cf4a88491c81c5f3ab4a1437df3b463081cc93943c4d3ab37f1e4f8081c6995eca076f717d4fdf9a277c750bd0289477ac151f1e2b024747dcd1747@52.31.129.130:30303" + ] +} diff --git a/ethcore/spec/src/spec.rs b/ethcore/spec/src/spec.rs index 093e6905dbe..017d21bb81f 100644 --- a/ethcore/spec/src/spec.rs +++ b/ethcore/spec/src/spec.rs @@ -258,10 +258,10 @@ impl fmt::Display for SpecHardcodedSync { } fn convert_json_to_spec( - pair: (ethjson::hash::Address, ethjson::spec::Builtin), + (address, builtin): (ethjson::hash::Address, ethjson::spec::builtin::Builtin), ) -> Result<(Address, Builtin), Error> { - let builtin = Builtin::try_from(pair.1)?; - Ok((pair.0.into(), builtin)) + let builtin = Builtin::try_from(builtin)?; + Ok((address.into(), builtin)) } /// Load from JSON object. diff --git a/json/src/spec/account.rs b/json/src/spec/account.rs index 6d722ea2385..72cdb3607fd 100644 --- a/json/src/spec/account.rs +++ b/json/src/spec/account.rs @@ -18,16 +18,17 @@ use std::collections::BTreeMap; -use crate::{bytes::Bytes, spec::builtin::Builtin, uint::Uint}; +use crate::{bytes::Bytes, spec::builtin::BuiltinCompat, uint::Uint}; use serde::Deserialize; /// Spec account. #[cfg_attr(any(test, feature = "test-helpers"), derive(Clone))] #[derive(Debug, PartialEq, Deserialize)] #[serde(deny_unknown_fields)] +#[serde(rename_all = "camelCase")] pub struct Account { /// Builtin contract. - pub builtin: Option, + pub builtin: Option, /// Balance. pub balance: Option, /// Nonce. @@ -101,7 +102,15 @@ mod tests { #[test] fn account_empty() { let s = r#"{ - "builtin": { "name": "ecrecover", "pricing": { "linear": { "base": 3000, "word": 0 } } } + "builtin": { + "name": "ecrecover", + "pricing": { + "linear": { + "base": 3000, + "word": 0 + } + } + } }"#; let deserialized: Account = serde_json::from_str(s).unwrap(); assert!(deserialized.is_empty()); @@ -112,8 +121,16 @@ mod tests { let s = r#"{ "balance": "1", "nonce": "0", - "builtin": { "name": "ecrecover", "pricing": { "linear": { "base": 3000, "word": 0 } } }, - "code": "1234" + "code": "1234", + "builtin": { + "name": "ecrecover", + "pricing": { + "linear": { + "base": 3000, + "word": 0 + } + } + } }"#; let deserialized: Account = serde_json::from_str(s).unwrap(); assert!(!deserialized.is_empty()); diff --git a/json/src/spec/builtin.rs b/json/src/spec/builtin.rs index f751750dd25..471b738573f 100644 --- a/json/src/spec/builtin.rs +++ b/json/src/spec/builtin.rs @@ -16,18 +16,19 @@ //! Spec builtin deserialization. +use std::collections::BTreeMap; + use crate::uint::Uint; use serde::Deserialize; - /// Linear pricing. #[derive(Debug, PartialEq, Deserialize, Clone)] #[serde(deny_unknown_fields)] pub struct Linear { /// Base price. - pub base: usize, + pub base: u64, /// Price for word. - pub word: usize, + pub word: u64, } /// Pricing for modular exponentiation. @@ -35,7 +36,7 @@ pub struct Linear { #[serde(deny_unknown_fields)] pub struct Modexp { /// Price divisor. - pub divisor: usize, + pub divisor: u64, } /// Pricing for constant alt_bn128 operations (ECADD and ECMUL) @@ -43,9 +44,7 @@ pub struct Modexp { #[serde(deny_unknown_fields)] pub struct AltBn128ConstOperations { /// price - pub price: usize, - /// EIP 1108 transition price - pub eip1108_transition_price: usize, + pub price: u64, } /// Pricing for alt_bn128_pairing. @@ -53,13 +52,9 @@ pub struct AltBn128ConstOperations { #[serde(deny_unknown_fields)] pub struct AltBn128Pairing { /// Base price. - pub base: usize, + pub base: u64, /// Price per point pair. - pub pair: usize, - /// EIP 1108 transition base price - pub eip1108_transition_base: usize, - /// EIP 1108 transition price per point pair - pub eip1108_transition_pair: usize, + pub pair: u64, } /// Pricing variants. @@ -82,23 +77,70 @@ pub enum Pricing { AltBn128ConstOperations(AltBn128ConstOperations), } -/// Spec builtin. +/// Builtin compability layer #[derive(Debug, PartialEq, Deserialize, Clone)] #[serde(deny_unknown_fields)] +pub struct BuiltinCompat { + /// Builtin name. + name: String, + /// Builtin pricing. + pricing: PricingCompat, + /// Activation block. + activate_at: Option, +} + +/// Spec builtin. +#[derive(Debug, PartialEq, Clone)] pub struct Builtin { /// Builtin name. pub name: String, /// Builtin pricing. - pub pricing: Pricing, - /// Activation block. - pub activate_at: Option, - /// EIP 1108 - pub eip1108_transition: Option, + pub pricing: BTreeMap, +} + +impl From for Builtin { + fn from(legacy: BuiltinCompat) -> Self { + let pricing = match legacy.pricing { + PricingCompat::Single(pricing) => { + let mut map = BTreeMap::new(); + let activate_at: u64 = legacy.activate_at.map_or(0, Into::into); + map.insert(activate_at, PricingAt { info: None, price: pricing }); + map + } + PricingCompat::Multi(pricings) => { + pricings.into_iter().map(|(a, p)| (a.into(), p)).collect() + } + }; + Self { name: legacy.name, pricing } + } +} + +/// Compability layer for different pricings +#[derive(Debug, PartialEq, Deserialize, Clone)] +#[serde(rename_all = "snake_case")] +#[serde(deny_unknown_fields)] +#[serde(untagged)] +enum PricingCompat { + /// Single builtin + Single(Pricing), + /// Multiple builtins + Multi(BTreeMap), +} + +/// Price for a builtin, with the block number to activate it on +#[derive(Debug, PartialEq, Deserialize, Clone)] +#[serde(deny_unknown_fields)] +pub struct PricingAt { + /// Description of the activation, e.g. "PunyPony HF, March 12, 2025". + pub info: Option, + /// Builtin pricing. + pub price: Pricing, } #[cfg(test)] mod tests { - use super::{Builtin, Modexp, Linear, Pricing, Uint}; + use super::{Builtin, BuiltinCompat, BTreeMap, Pricing, PricingAt, Linear, Modexp, AltBn128ConstOperations}; + use macros::map; #[test] fn builtin_deserialization() { @@ -106,10 +148,42 @@ mod tests { "name": "ecrecover", "pricing": { "linear": { "base": 3000, "word": 0 } } }"#; - let deserialized: Builtin = serde_json::from_str(s).unwrap(); - assert_eq!(deserialized.name, "ecrecover"); - assert_eq!(deserialized.pricing, Pricing::Linear(Linear { base: 3000, word: 0 })); - assert!(deserialized.activate_at.is_none()); + let builtin: Builtin = serde_json::from_str::(s).unwrap().into(); + assert_eq!(builtin.name, "ecrecover"); + assert_eq!(builtin.pricing, map![ + 0 => PricingAt { + info: None, + price: Pricing::Linear(Linear { base: 3000, word: 0 }) + } + ]); + } + + #[test] + fn deserialize_multiple_pricings() { + let s = r#"{ + "name": "ecrecover", + "pricing": { + "0": { + "price": {"linear": { "base": 3000, "word": 0 }} + }, + "500": { + "info": "enable fake EIP at block 500", + "price": {"linear": { "base": 10, "word": 0 }} + } + } + }"#; + let builtin: Builtin = serde_json::from_str::(s).unwrap().into(); + assert_eq!(builtin.name, "ecrecover"); + assert_eq!(builtin.pricing, map![ + 0 => PricingAt { + info: None, + price: Pricing::Linear(Linear { base: 3000, word: 0 }) + }, + 500 => PricingAt { + info: Some(String::from("enable fake EIP at block 500")), + price: Pricing::Linear(Linear { base: 10, word: 0 }) + } + ]); } #[test] @@ -119,10 +193,14 @@ mod tests { "activate_at": "0xffffff", "pricing": { "blake2_f": { "gas_per_round": 123 } } }"#; - let deserialized: Builtin = serde_json::from_str(s).unwrap(); - assert_eq!(deserialized.name, "blake2_f"); - assert_eq!(deserialized.pricing, Pricing::Blake2F { gas_per_round: 123 }); - assert!(deserialized.activate_at.is_some()); + let builtin: Builtin = serde_json::from_str::(s).unwrap().into(); + assert_eq!(builtin.name, "blake2_f"); + assert_eq!(builtin.pricing, map![ + 0xffffff => PricingAt { + info: None, + price: Pricing::Blake2F { gas_per_round: 123 } + } + ]); } #[test] @@ -133,9 +211,13 @@ mod tests { "pricing": { "modexp": { "divisor": 5 } } }"#; - let deserialized: Builtin = serde_json::from_str(s).unwrap(); - assert_eq!(deserialized.name, "late_start"); - assert_eq!(deserialized.pricing, Pricing::Modexp(Modexp { divisor: 5 })); - assert_eq!(deserialized.activate_at, Some(Uint(100000.into()))); + let builtin: Builtin = serde_json::from_str::(s).unwrap().into(); + assert_eq!(builtin.name, "late_start"); + assert_eq!(builtin.pricing, map![ + 100_000 => PricingAt { + info: None, + price: Pricing::Modexp(Modexp { divisor: 5 }) + } + ]); } } diff --git a/json/src/spec/spec.rs b/json/src/spec/spec.rs index b8597987a7c..2e42737e81c 100644 --- a/json/src/spec/spec.rs +++ b/json/src/spec/spec.rs @@ -87,63 +87,63 @@ mod tests { #[test] fn should_error_on_unknown_fields() { let s = r#"{ - "name": "Morden", - "dataDir": "morden", - "engine": { - "Ethash": { - "params": { - "minimumDifficulty": "0x020000", - "difficultyBoundDivisor": "0x0800", - "durationLimit": "0x0d", - "homesteadTransition" : "0x", - "daoHardforkTransition": "0xffffffffffffffff", - "daoHardforkBeneficiary": "0x0000000000000000000000000000000000000000", - "daoHardforkAccounts": [] - } - } - }, - "params": { - "accountStartNonce": "0x0100000", - "maximumExtraDataSize": "0x20", - "minGasLimit": "0x1388", - "networkID" : "0x2", - "forkBlock": "0xffffffffffffffff", - "forkCanonHash": "0x0000000000000000000000000000000000000000000000000000000000000000", - "gasLimitBoundDivisor": "0x20", - "unknownField": "0x0" - }, - "genesis": { - "seal": { - "ethereum": { - "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000", - "nonce": "0x00006d6f7264656e" + "name": "Morden", + "dataDir": "morden", + "engine": { + "Ethash": { + "params": { + "minimumDifficulty": "0x020000", + "difficultyBoundDivisor": "0x0800", + "durationLimit": "0x0d", + "homesteadTransition" : "0x", + "daoHardforkTransition": "0xffffffffffffffff", + "daoHardforkBeneficiary": "0x0000000000000000000000000000000000000000", + "daoHardforkAccounts": [] + } } }, - "difficulty": "0x20000", - "author": "0x0000000000000000000000000000000000000000", - "timestamp": "0x00", - "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000", - "extraData": "0x", - "gasLimit": "0x2fefd8" - }, - "nodes": [ - "enode://b1217cbaa440e35ed471157123fe468e19e8b5ad5bedb4b1fdbcbdab6fb2f5ed3e95dd9c24a22a79fdb2352204cea207df27d92bfd21bfd41545e8b16f637499@104.44.138.37:30303" - ], - "accounts": { - "0000000000000000000000000000000000000001": { "balance": "1", "nonce": "1048576", "builtin": { "name": "ecrecover", "pricing": { "linear": { "base": 3000, "word": 0 } } } }, - "0000000000000000000000000000000000000002": { "balance": "1", "nonce": "1048576", "builtin": { "name": "sha256", "pricing": { "linear": { "base": 60, "word": 12 } } } }, - "0000000000000000000000000000000000000003": { "balance": "1", "nonce": "1048576", "builtin": { "name": "ripemd160", "pricing": { "linear": { "base": 600, "word": 120 } } } }, - "0000000000000000000000000000000000000004": { "balance": "1", "nonce": "1048576", "builtin": { "name": "identity", "pricing": { "linear": { "base": 15, "word": 3 } } } }, - "102e61f5d8f9bc71d0ad4a084df4e65e05ce0e1c": { "balance": "1606938044258990275541962092341162602522202993782792835301376", "nonce": "1048576" } - }, - "hardcodedSync": { - "header": "f901f9a0d405da4e66f1445d455195229624e133f5baafe72b5cf7b3c36c12c8146e98b7a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347948888f1f195afa192cfee860698584c030f4c9db1a05fb2b4bfdef7b314451cb138a534d225c922fc0e5fbe25e451142732c3e25c25a088d2ec6b9860aae1a2c3b299f72b6a5d70d7f7ba4722c78f2c49ba96273c2158a007c6fdfa8eea7e86b81f5b0fc0f78f90cc19f4aa60d323151e0cac660199e9a1b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008302008003832fefba82524d84568e932a80a0a0349d8c3df71f1a48a9df7d03fd5f14aeee7d91332c009ecaff0a71ead405bd88ab4e252a7e8c2a23", - "totalDifficulty": "0x400000000", - "CHTs": [ + "params": { + "accountStartNonce": "0x0100000", + "maximumExtraDataSize": "0x20", + "minGasLimit": "0x1388", + "networkID" : "0x2", + "forkBlock": "0xffffffffffffffff", + "forkCanonHash": "0x0000000000000000000000000000000000000000000000000000000000000000", + "gasLimitBoundDivisor": "0x20", + "unknownField": "0x0" + }, + "genesis": { + "seal": { + "ethereum": { + "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000", + "nonce": "0x00006d6f7264656e" + } + }, + "difficulty": "0x20000", + "author": "0x0000000000000000000000000000000000000000", + "timestamp": "0x00", + "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000", + "extraData": "0x", + "gasLimit": "0x2fefd8" + }, + "nodes": [ + "enode://b1217cbaa440e35ed471157123fe468e19e8b5ad5bedb4b1fdbcbdab6fb2f5ed3e95dd9c24a22a79fdb2352204cea207df27d92bfd21bfd41545e8b16f637499@104.44.138.37:30303" + ], + "accounts": { + "0000000000000000000000000000000000000001": { "balance": "1", "nonce": "1048576", "builtin": { "name": "ecrecover", "pricing": { "linear": { "base": 3000, "word": 0 } } } }, + "0000000000000000000000000000000000000002": { "balance": "1", "nonce": "1048576", "builtin": { "name": "sha256", "pricing": { "linear": { "base": 60, "word": 12 } } } }, + "0000000000000000000000000000000000000003": { "balance": "1", "nonce": "1048576", "builtin": { "name": "ripemd160", "pricing": { "linear": { "base": 600, "word": 120 } } } }, + "0000000000000000000000000000000000000004": { "balance": "1", "nonce": "1048576", "builtin": { "name": "identity", "pricing": { "linear": { "base": 15, "word": 3 } } } }, + "102e61f5d8f9bc71d0ad4a084df4e65e05ce0e1c": { "balance": "1606938044258990275541962092341162602522202993782792835301376", "nonce": "1048576" } + }, + "hardcodedSync": { + "header": "f901f9a0d405da4e66f1445d455195229624e133f5baafe72b5cf7b3c36c12c8146e98b7a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347948888f1f195afa192cfee860698584c030f4c9db1a05fb2b4bfdef7b314451cb138a534d225c922fc0e5fbe25e451142732c3e25c25a088d2ec6b9860aae1a2c3b299f72b6a5d70d7f7ba4722c78f2c49ba96273c2158a007c6fdfa8eea7e86b81f5b0fc0f78f90cc19f4aa60d323151e0cac660199e9a1b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008302008003832fefba82524d84568e932a80a0a0349d8c3df71f1a48a9df7d03fd5f14aeee7d91332c009ecaff0a71ead405bd88ab4e252a7e8c2a23", + "totalDifficulty": "0x400000000", + "CHTs": [ "0x11bbe8db4e347b4e8c937c1c8370e4b5ed33adb3db69cbdb7a38e1e50b1b82fa", "0xd7f8974fb5ac78d9ac099b9ad5018bedc2ce0a72dad1827a1709da30580f0544" - ] - } + ] + } }"#; let result: Result = serde_json::from_str(s); assert!(result.is_err()); @@ -152,62 +152,110 @@ mod tests { #[test] fn spec_deserialization() { let s = r#"{ - "name": "Morden", - "dataDir": "morden", - "engine": { - "Ethash": { - "params": { - "minimumDifficulty": "0x020000", - "difficultyBoundDivisor": "0x0800", - "durationLimit": "0x0d", - "homesteadTransition" : "0x", - "daoHardforkTransition": "0xffffffffffffffff", - "daoHardforkBeneficiary": "0x0000000000000000000000000000000000000000", - "daoHardforkAccounts": [] - } - } - }, - "params": { - "accountStartNonce": "0x0100000", - "maximumExtraDataSize": "0x20", - "minGasLimit": "0x1388", - "networkID" : "0x2", - "forkBlock": "0xffffffffffffffff", - "forkCanonHash": "0x0000000000000000000000000000000000000000000000000000000000000000", - "gasLimitBoundDivisor": "0x20" - }, - "genesis": { - "seal": { - "ethereum": { - "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000", - "nonce": "0x00006d6f7264656e" + "name": "Morden", + "dataDir": "morden", + "engine": { + "Ethash": { + "params": { + "minimumDifficulty": "0x020000", + "difficultyBoundDivisor": "0x0800", + "durationLimit": "0x0d", + "homesteadTransition" : "0x", + "daoHardforkTransition": "0xffffffffffffffff", + "daoHardforkBeneficiary": "0x0000000000000000000000000000000000000000", + "daoHardforkAccounts": [] + } } }, - "difficulty": "0x20000", - "author": "0x0000000000000000000000000000000000000000", - "timestamp": "0x00", - "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000", - "extraData": "0x", - "gasLimit": "0x2fefd8" - }, - "nodes": [ - "enode://b1217cbaa440e35ed471157123fe468e19e8b5ad5bedb4b1fdbcbdab6fb2f5ed3e95dd9c24a22a79fdb2352204cea207df27d92bfd21bfd41545e8b16f637499@104.44.138.37:30303" - ], - "accounts": { - "0000000000000000000000000000000000000001": { "balance": "1", "nonce": "1048576", "builtin": { "name": "ecrecover", "pricing": { "linear": { "base": 3000, "word": 0 } } } }, - "0000000000000000000000000000000000000002": { "balance": "1", "nonce": "1048576", "builtin": { "name": "sha256", "pricing": { "linear": { "base": 60, "word": 12 } } } }, - "0000000000000000000000000000000000000003": { "balance": "1", "nonce": "1048576", "builtin": { "name": "ripemd160", "pricing": { "linear": { "base": 600, "word": 120 } } } }, - "0000000000000000000000000000000000000004": { "balance": "1", "nonce": "1048576", "builtin": { "name": "identity", "pricing": { "linear": { "base": 15, "word": 3 } } } }, - "102e61f5d8f9bc71d0ad4a084df4e65e05ce0e1c": { "balance": "1606938044258990275541962092341162602522202993782792835301376", "nonce": "1048576" } - }, - "hardcodedSync": { - "header": "f901f9a0d405da4e66f1445d455195229624e133f5baafe72b5cf7b3c36c12c8146e98b7a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347948888f1f195afa192cfee860698584c030f4c9db1a05fb2b4bfdef7b314451cb138a534d225c922fc0e5fbe25e451142732c3e25c25a088d2ec6b9860aae1a2c3b299f72b6a5d70d7f7ba4722c78f2c49ba96273c2158a007c6fdfa8eea7e86b81f5b0fc0f78f90cc19f4aa60d323151e0cac660199e9a1b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008302008003832fefba82524d84568e932a80a0a0349d8c3df71f1a48a9df7d03fd5f14aeee7d91332c009ecaff0a71ead405bd88ab4e252a7e8c2a23", - "totalDifficulty": "0x400000000", - "CHTs": [ - "0x11bbe8db4e347b4e8c937c1c8370e4b5ed33adb3db69cbdb7a38e1e50b1b82fa", - "0xd7f8974fb5ac78d9ac099b9ad5018bedc2ce0a72dad1827a1709da30580f0544" - ] - } + "params": { + "accountStartNonce": "0x0100000", + "maximumExtraDataSize": "0x20", + "minGasLimit": "0x1388", + "networkID" : "0x2", + "forkBlock": "0xffffffffffffffff", + "forkCanonHash": "0x0000000000000000000000000000000000000000000000000000000000000000", + "gasLimitBoundDivisor": "0x20" + }, + "genesis": { + "seal": { + "ethereum": { + "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000", + "nonce": "0x00006d6f7264656e" + } + }, + "difficulty": "0x20000", + "author": "0x0000000000000000000000000000000000000000", + "timestamp": "0x00", + "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000", + "extraData": "0x", + "gasLimit": "0x2fefd8" + }, + "nodes": [ + "enode://b1217cbaa440e35ed471157123fe468e19e8b5ad5bedb4b1fdbcbdab6fb2f5ed3e95dd9c24a22a79fdb2352204cea207df27d92bfd21bfd41545e8b16f637499@104.44.138.37:30303" + ], + "accounts": { + "0000000000000000000000000000000000000001": { + "balance": "1", + "nonce": "1048576", + "builtin": { + "name": "ecrecover", + "pricing": { + "linear": { + "base": 3000, + "word": 0 + } + } + } + }, + "0000000000000000000000000000000000000002": { + "balance": "1", + "nonce": "1048576", + "builtin": { + "name": "sha256", + "pricing": { + "linear": { + "base": 60, + "word": 12 + } + } + } + }, + "0000000000000000000000000000000000000003": { + "balance": "1", + "nonce": "1048576", + "builtin": { + "name": "ripemd160", + "pricing": { + "linear": { + "base": 600, + "word": 120 + } + } + } + }, + "0000000000000000000000000000000000000004": { + "balance": "1", + "nonce": "1048576", + "builtin": { + "name": "identity", + "pricing": { + "linear": { + "base": 15, + "word": 3 + } + } + } + }, + "102e61f5d8f9bc71d0ad4a084df4e65e05ce0e1c": { "balance": "1606938044258990275541962092341162602522202993782792835301376", "nonce": "1048576" } + }, + "hardcodedSync": { + "header": "f901f9a0d405da4e66f1445d455195229624e133f5baafe72b5cf7b3c36c12c8146e98b7a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347948888f1f195afa192cfee860698584c030f4c9db1a05fb2b4bfdef7b314451cb138a534d225c922fc0e5fbe25e451142732c3e25c25a088d2ec6b9860aae1a2c3b299f72b6a5d70d7f7ba4722c78f2c49ba96273c2158a007c6fdfa8eea7e86b81f5b0fc0f78f90cc19f4aa60d323151e0cac660199e9a1b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008302008003832fefba82524d84568e932a80a0a0349d8c3df71f1a48a9df7d03fd5f14aeee7d91332c009ecaff0a71ead405bd88ab4e252a7e8c2a23", + "totalDifficulty": "0x400000000", + "CHTs": [ + "0x11bbe8db4e347b4e8c937c1c8370e4b5ed33adb3db69cbdb7a38e1e50b1b82fa", + "0xd7f8974fb5ac78d9ac099b9ad5018bedc2ce0a72dad1827a1709da30580f0544" + ] + } }"#; let _deserialized: Spec = serde_json::from_str(s).unwrap(); // TODO: validate all fields diff --git a/json/src/spec/state.rs b/json/src/spec/state.rs index 642d9b6eb2a..458c5e55997 100644 --- a/json/src/spec/state.rs +++ b/json/src/spec/state.rs @@ -50,7 +50,7 @@ impl State { HashOrMap::Hash(_) => BTreeMap::default(), HashOrMap::Map(map) => { map.iter().filter_map(|(add, ref acc)| { - acc.builtin.clone().map(|b| (add.clone(), b)) + acc.builtin.clone().map(|b| (add.clone(), b.into())) }).collect() } From 43dc9af03b2ba5b3b1981ad5f075b5ec993bfd66 Mon Sep 17 00:00:00 2001 From: Niklas Adolfsson Date: Fri, 1 Nov 2019 20:27:14 +0100 Subject: [PATCH 18/21] [chain specs]: activate `Istanbul` on mainnet (#11228) * [chains spec]: activate istanbul at mainnet * Activate `Block >= 9,069,000` on the Ethereum mainnet * Enable Blake2 compression function `F` precompile * [chain specs]: add comments for EIP1108 activation * [chainspec mainnet]: enable Istanbul transitions * [chainspec mainnet]: simply configuration --- ethcore/res/ethereum/foundation.json | 29 +++++++++++++++++++++------- ethcore/res/ethereum/goerli.json | 6 +++--- ethcore/res/ethereum/kovan.json | 6 +++--- ethcore/res/ethereum/rinkeby.json | 6 +++--- ethcore/res/ethereum/ropsten.json | 6 +++--- 5 files changed, 34 insertions(+), 19 deletions(-) diff --git a/ethcore/res/ethereum/foundation.json b/ethcore/res/ethereum/foundation.json index 0549568d9c9..c226bb72542 100644 --- a/ethcore/res/ethereum/foundation.json +++ b/ethcore/res/ethereum/foundation.json @@ -163,7 +163,11 @@ "eip658Transition": "0x42ae50", "eip145Transition": "0x6f1580", "eip1014Transition": "0x6f1580", - "eip1052Transition": "0x6f1580" + "eip1052Transition": "0x6f1580", + "eip1283Transition": "0x8a61c8", + "eip1706Transition": "0x8a61c8", + "eip1884Transition": "0x8a61c8", + "eip2028Transition": "0x8a61c8" }, "genesis": { "seal": { @@ -4450,8 +4454,8 @@ "0x42ae50": { "price": { "alt_bn128_const_operations": { "price": 500 }} }, - "0x7fffffffffffff": { - "info": "EIP 1108 transition", + "0x8a61c8": { + "info": "EIP 1108 transition at block 9_069_000 (0x8a61c8)", "price": { "alt_bn128_const_operations": { "price": 150 }} } } @@ -4464,8 +4468,8 @@ "0x42ae50": { "price": { "alt_bn128_const_operations": { "price": 40000 }} }, - "0x7fffffffffffff": { - "info": "EIP 1108 transition", + "0x8a61c8": { + "info": "EIP 1108 transition at block 9_069_000 (0x8a61c8)", "price": { "alt_bn128_const_operations": { "price": 6000 }} } } @@ -4478,13 +4482,24 @@ "0x42ae50": { "price": { "alt_bn128_pairing": { "base": 100000, "pair": 80000 }} }, - "0x7fffffffffffff": { - "info": "EIP 1108 transition", + "0x8a61c8": { + "info": "EIP 1108 transition at block 9_069_000 (0x8a61c8)", "price": { "alt_bn128_pairing": { "base": 45000, "pair": 34000 }} } } } }, + "0x0000000000000000000000000000000000000009": { + "builtin": { + "name": "blake2_f", + "activate_at": "0x8a61c8", + "pricing": { + "blake2_f": { + "gas_per_round": 1 + } + } + } + }, "0x3282791d6fd713f1e94f4bfd565eaa78b3a0599d": { "balance": "0x487a9a304539440000" }, diff --git a/ethcore/res/ethereum/goerli.json b/ethcore/res/ethereum/goerli.json index 92b77b55c85..4c00cc43ec0 100644 --- a/ethcore/res/ethereum/goerli.json +++ b/ethcore/res/ethereum/goerli.json @@ -135,7 +135,7 @@ "price": { "alt_bn128_const_operations": { "price": 500 }} }, "0x17d433": { - "info": "EIP 1108 transition", + "info": "EIP 1108 transition at block 1_561_651 (0x17d433)", "price": { "alt_bn128_const_operations": { "price": 150 }} } } @@ -150,7 +150,7 @@ "price": { "alt_bn128_const_operations": { "price": 40000 }} }, "0x17d433": { - "info": "EIP 1108 transition", + "info": "EIP 1108 transition at block 1_561_651 (0x17d433)", "price": { "alt_bn128_const_operations": { "price": 6000 }} } } @@ -165,7 +165,7 @@ "price": { "alt_bn128_pairing": { "base": 100000, "pair": 80000 }} }, "0x17d433": { - "info": "EIP 1108 transition", + "info": "EIP 1108 transition at block 1_561_651 (0x17d433)", "price": { "alt_bn128_pairing": { "base": 45000, "pair": 34000 }} } } diff --git a/ethcore/res/ethereum/kovan.json b/ethcore/res/ethereum/kovan.json index dd5c3f65710..8fef0cdfb74 100644 --- a/ethcore/res/ethereum/kovan.json +++ b/ethcore/res/ethereum/kovan.json @@ -6731,7 +6731,7 @@ "price": { "alt_bn128_const_operations": { "price": 500 }} }, "0xd751a5": { - "info": "EIP 1108 transition", + "info": "EIP 1108 transition at block 14_111_141 (0xd751a5)", "price": { "alt_bn128_const_operations": { "price": 150 }} } } @@ -6745,7 +6745,7 @@ "price": { "alt_bn128_const_operations": { "price": 40000 }} }, "0xd751a5": { - "info": "EIP 1108 transition", + "info": "EIP 1108 transition at block 14_111_141 (0xd751a5)", "price": { "alt_bn128_const_operations": { "price": 6000 }} } } @@ -6759,7 +6759,7 @@ "price": { "alt_bn128_pairing": { "base": 100000, "pair": 80000 }} }, "0xd751a5": { - "info": "EIP 1108 transition", + "info": "EIP 1108 transition at block 14_111_141 (0xd751a5)", "price": { "alt_bn128_pairing": { "base": 45000, "pair": 34000 }} } } diff --git a/ethcore/res/ethereum/rinkeby.json b/ethcore/res/ethereum/rinkeby.json index bcc96a80129..ee02408f6cc 100644 --- a/ethcore/res/ethereum/rinkeby.json +++ b/ethcore/res/ethereum/rinkeby.json @@ -130,7 +130,7 @@ "price": { "alt_bn128_const_operations": { "price": 500 }} }, "0x52efd1": { - "info": "EIP 1108 transition", + "info": "EIP 1108 transition at block 5_435_345 (0x52efd1)", "price": { "alt_bn128_const_operations": { "price": 150 }} } } @@ -145,7 +145,7 @@ "price": { "alt_bn128_const_operations": { "price": 40000 }} }, "0x52efd1": { - "info": "EIP 1108 transition", + "info": "EIP 1108 transition at block 5_435_345 (0x52efd1)", "price": { "alt_bn128_const_operations": { "price": 6000 }} } } @@ -160,7 +160,7 @@ "price": { "alt_bn128_pairing": { "base": 100000, "pair": 80000 }} }, "0x52efd1": { - "info": "EIP 1108 transition", + "info": "EIP 1108 transition at block 5_435_345 (0x52efd1)", "price": { "alt_bn128_pairing": { "base": 45000, "pair": 34000 }} } } diff --git a/ethcore/res/ethereum/ropsten.json b/ethcore/res/ethereum/ropsten.json index f65a77ac750..4912a16d2bb 100644 --- a/ethcore/res/ethereum/ropsten.json +++ b/ethcore/res/ethereum/ropsten.json @@ -2744,7 +2744,7 @@ "price": { "alt_bn128_const_operations": { "price": 500 }} }, "0x62f756": { - "info": "EIP 1108 transition", + "info": "EIP 1108 transition at block 6_485_846 (0x62f756)", "price": { "alt_bn128_const_operations": { "price": 150 }} } } @@ -2760,7 +2760,7 @@ "price": { "alt_bn128_const_operations": { "price": 40000 }} }, "0x62f756": { - "info": "EIP 1108 transition", + "info": "EIP 1108 transition at block 6_485_846 (0x62f756)", "price": { "alt_bn128_const_operations": { "price": 6000 }} } } @@ -2776,7 +2776,7 @@ "price": { "alt_bn128_pairing": { "base": 100000, "pair": 80000 }} }, "0x62f756": { - "info": "EIP 1108 transition", + "info": "EIP 1108 transition at block 6_485_846 (0x62f756)", "price": { "alt_bn128_pairing": { "base": 45000, "pair": 34000 }} } } From 1b4d23fd20c90d8c61f33c64cace740d0616f930 Mon Sep 17 00:00:00 2001 From: Talha Cross <47772477+soc1c@users.noreply.github.com> Date: Sat, 2 Nov 2019 12:26:38 +0100 Subject: [PATCH 19/21] ethcore/res: add mordor testnet configuration (#11200) * ethcore/res: add mordor testnet configuration * ethcore/spec: add mordor testnet configuration * parity/cli: add mordor testnet configuration * parity/config: fix tests * ethcore/res: update mordor spec with agharta hardfork block 301243 * ethcore/res: update kotti with agharta block 1705549 * ethcore/res: update morden with agharta block 5000381 * ethcore/res: multiple prices and activations for mordor testnet * fix mordor spec json * fix mordor spec json --- ethcore/res/ethereum/kotti.json | 3 + ethcore/res/ethereum/morden.json | 5 +- ethcore/res/ethereum/mordor.json | 189 +++++++++++++++++++++++++++++++ ethcore/spec/src/chain.rs | 2 + parity/account_utils.rs | 2 +- parity/cli/mod.rs | 8 +- parity/configuration.rs | 2 +- parity/params.rs | 29 ++--- 8 files changed, 220 insertions(+), 20 deletions(-) create mode 100644 ethcore/res/ethereum/mordor.json diff --git a/ethcore/res/ethereum/kotti.json b/ethcore/res/ethereum/kotti.json index 81bd2c29608..7876fe8cd2b 100644 --- a/ethcore/res/ethereum/kotti.json +++ b/ethcore/res/ethereum/kotti.json @@ -13,6 +13,7 @@ "accountStartNonce": "0x0", "chainID": "0x6", "eip140Transition": "0xaef49", + "eip145Transition": "0x1a064d", "eip150Transition": "0x0", "eip155Transition": "0x0", "eip160Transition": "0x0", @@ -21,6 +22,8 @@ "eip211Transition": "0xaef49", "eip214Transition": "0xaef49", "eip658Transition": "0xaef49", + "eip1014Transition": "0x1a064d", + "eip1052Transition": "0x1a064d", "gasLimitBoundDivisor": "0x400", "maxCodeSize": "0x6000", "maxCodeSizeTransition": "0xaef49", diff --git a/ethcore/res/ethereum/morden.json b/ethcore/res/ethereum/morden.json index 442baea4bfb..5db2a4c04b7 100644 --- a/ethcore/res/ethereum/morden.json +++ b/ethcore/res/ethereum/morden.json @@ -37,7 +37,10 @@ "eip140Transition": "0x4829ba", "eip211Transition": "0x4829ba", "eip214Transition": "0x4829ba", - "eip658Transition": "0x4829ba" + "eip658Transition": "0x4829ba", + "eip145Transition": "0x4c4cbd", + "eip1014Transition": "0x4c4cbd", + "eip1052Transition": "0x4c4cbd" }, "genesis": { "seal": { diff --git a/ethcore/res/ethereum/mordor.json b/ethcore/res/ethereum/mordor.json new file mode 100644 index 00000000000..ceaa9de6d51 --- /dev/null +++ b/ethcore/res/ethereum/mordor.json @@ -0,0 +1,189 @@ +{ + "name":"Mordor Classic Testnet", + "dataDir":"mordor", + "engine":{ + "Ethash":{ + "params":{ + "minimumDifficulty":"0x20000", + "difficultyBoundDivisor":"0x800", + "durationLimit":"0xd", + "blockReward":"0x4563918244F40000", + "homesteadTransition":"0x0", + "ecip1010PauseTransition":"0x0", + "ecip1010ContinueTransition":"0x0", + "ecip1017EraRounds":"0x1e8480", + "bombDefuseTransition":"0x0", + "eip100bTransition":"0x0" + } + } + }, + "params":{ + "gasLimitBoundDivisor":"0x400", + "accountStartNonce":"0x0", + "maximumExtraDataSize":"0x20", + "minGasLimit":"0x1388", + "networkID":"0x7", + "chainID":"0x3f", + "eip150Transition":"0x0", + "eip160Transition":"0x0", + "eip161abcTransition":"0x0", + "eip161dTransition":"0x0", + "eip155Transition":"0x0", + "maxCodeSize":"0x6000", + "maxCodeSizeTransition":"0x0", + "eip140Transition":"0x0", + "eip211Transition":"0x0", + "eip214Transition":"0x0", + "eip658Transition":"0x0", + "eip145Transition":"0x498bb", + "eip1014Transition":"0x498bb", + "eip1052Transition":"0x498bb" + }, + "genesis":{ + "seal":{ + "ethereum":{ + "nonce":"0x0000000000000000", + "mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000" + } + }, + "difficulty":"0x20000", + "author":"0x0000000000000000000000000000000000000000", + "timestamp":"0x5d9676db", + "parentHash":"0x0000000000000000000000000000000000000000000000000000000000000000", + "extraData":"0x70686f656e697820636869636b656e206162737572642062616e616e61", + "gasLimit":"0x2fefd8" + }, + "nodes":[ + "enode://03b133f731049e3f7be827339c3759be92778c05e54a1847d178c0fdb56fa168aa1e7e61fc77791a7afdd0328a00318f73c01212eb3f3bbe919f5ce8f5b4a314@192.227.105.4:32000", + "enode://06fdbeb591d26f53b2e7250025fe955ca013431ded930920cf1e3cd1f0c920e9a5e727949d209bc25a07288327b525279b11c5551315c50ff0db483e69fc159b@34.218.225.178:32000", + "enode://1813e90a0afdd7c1e4892c5376960e3577a9e6c5a4f86fa405a405c7421a4a1608248d77cc90333842f13d8954d82113dec480cfb76b4fef8cb475157cf4d5f2@10.28.224.3:30000", + "enode://2b69a3926f36a7748c9021c34050be5e0b64346225e477fe7377070f6289bd363b2be73a06010fd516e6ea3ee90778dd0399bc007bb1281923a79374f842675a@51.15.116.226:30303", + "enode://621e28e529146fd501709194885f50540c494f1a2985d1fb4ec8769226b5cb0b0d1a11545926077821474c2767cdd87888ead8a2509a2c9069dd5584e4b1c3b8@10.28.223.8:30000", + "enode://a59e33ccd2b3e52d578f1fbd70c6f9babda2650f0760d6ff3b37742fdcdfdb3defba5d56d315b40c46b70198c7621e63ffa3f987389c7118634b0fefbbdfa7fd@51.15.116.226:30303" + ], + "accounts":{ + "0x0000000000000000000000000000000000000001":{ + "builtin":{ + "name":"ecrecover", + "pricing":{ + "linear":{ + "base":3000, + "word":0 + } + } + } + }, + "0x0000000000000000000000000000000000000002":{ + "builtin":{ + "name":"sha256", + "pricing":{ + "linear":{ + "base":60, + "word":12 + } + } + } + }, + "0x0000000000000000000000000000000000000003":{ + "builtin":{ + "name":"ripemd160", + "pricing":{ + "linear":{ + "base":600, + "word":120 + } + } + } + }, + "0x0000000000000000000000000000000000000004":{ + "builtin":{ + "name":"identity", + "pricing":{ + "linear":{ + "base":15, + "word":3 + } + } + } + }, + "0x0000000000000000000000000000000000000005":{ + "builtin":{ + "activate_at":"0x0", + "name":"modexp", + "pricing":{ + "modexp":{ + "divisor":20 + } + } + } + }, + "0x0000000000000000000000000000000000000006":{ + "builtin":{ + "name":"alt_bn128_add", + "pricing":{ + "0x0":{ + "price":{ + "alt_bn128_const_operations":{ + "price":500 + } + } + }, + "0x7fffffffffffff":{ + "info":"EIP 1108 transition", + "price":{ + "alt_bn128_const_operations":{ + "price":150 + } + } + } + } + } + }, + "0x0000000000000000000000000000000000000007":{ + "builtin":{ + "name":"alt_bn128_mul", + "pricing":{ + "0x0":{ + "price":{ + "alt_bn128_const_operations":{ + "price":40000 + } + } + }, + "0x7fffffffffffff":{ + "info":"EIP 1108 transition", + "price":{ + "alt_bn128_const_operations":{ + "price":6000 + } + } + } + } + } + }, + "0x0000000000000000000000000000000000000008":{ + "builtin":{ + "name":"alt_bn128_pairing", + "pricing":{ + "0x0":{ + "price":{ + "alt_bn128_pairing":{ + "base":100000, + "pair":80000 + } + } + }, + "0x7fffffffffffff":{ + "info":"EIP 1108 transition", + "price":{ + "alt_bn128_pairing":{ + "base":45000, + "pair":34000 + } + } + } + } + } + } + } +} diff --git a/ethcore/spec/src/chain.rs b/ethcore/spec/src/chain.rs index 60bf84e3c5e..eaf73bfea0c 100644 --- a/ethcore/spec/src/chain.rs +++ b/ethcore/spec/src/chain.rs @@ -69,6 +69,7 @@ bundle_release_spec! { "ethereum/kovan" => new_kovan, "ethereum/mix" => new_mix, "ethereum/morden" => new_morden, + "ethereum/mordor" => new_mordor, "ethereum/musicoin" => new_musicoin, "ethereum/poacore" => new_poanet, "ethereum/xdai" => new_xdai, @@ -96,6 +97,7 @@ bundle_test_spec! { "ethereum/kovan_wasm_test" => new_kovan_wasm_test, "ethereum/mcip3_test" => new_mcip3_test, "ethereum/morden" => new_morden_test, + "ethereum/mordor" => new_mordor_test, "ethereum/ropsten" => new_ropsten_test, "ethereum/st_peters_test" => new_constantinople_fix_test, "ethereum/transition_test" => new_transition_test, diff --git a/parity/account_utils.rs b/parity/account_utils.rs index 727bb875222..056481af8bc 100644 --- a/parity/account_utils.rs +++ b/parity/account_utils.rs @@ -81,7 +81,7 @@ mod accounts { let account_settings = AccountProviderSettings { unlock_keep_secret: cfg.enable_fast_unlock, blacklisted_accounts: match *spec { - SpecType::Morden | SpecType::Ropsten | SpecType::Kovan | SpecType::Sokol | SpecType::Dev => vec![], + SpecType::Morden | SpecType::Mordor | SpecType::Ropsten | SpecType::Kovan | SpecType::Goerli | SpecType::Kotti | SpecType::Sokol | SpecType::Dev => vec![], _ => vec![ H160::from_str("00a329c0648769a73afac7f9381e08fb43dbea72").expect("the string is valid hex; qed"), ], diff --git a/parity/cli/mod.rs b/parity/cli/mod.rs index efa1429cf65..6ec06057894 100644 --- a/parity/cli/mod.rs +++ b/parity/cli/mod.rs @@ -300,7 +300,7 @@ usage! { ARG arg_chain: (String) = "foundation", or |c: &Config| c.parity.as_ref()?.chain.clone(), "--chain=[CHAIN]", - "Specify the blockchain type. CHAIN may be either a JSON chain specification file or ethereum, classic, poacore, xdai, volta, ewc, musicoin, ellaism, mix, callisto, morden, ropsten, kovan, rinkeby, goerli, kotti, poasokol, testnet, or dev.", + "Specify the blockchain type. CHAIN may be either a JSON chain specification file or ethereum, classic, poacore, xdai, volta, ewc, musicoin, ellaism, mix, callisto, morden, mordor, ropsten, kovan, rinkeby, goerli, kotti, poasokol, testnet, or dev.", ARG arg_keys_path: (String) = "$BASE/keys", or |c: &Config| c.parity.as_ref()?.keys_path.clone(), "--keys-path=[PATH]", @@ -1564,14 +1564,14 @@ mod tests { // given let mut config = Config::default(); let mut operating = Operating::default(); - operating.chain = Some("morden".into()); + operating.chain = Some("mordor".into()); config.parity = Some(operating); // when let args = Args::parse_with_config(&["parity"], config).unwrap(); // then - assert_eq!(args.arg_chain, "morden".to_owned()); + assert_eq!(args.arg_chain, "mordor".to_owned()); } #[test] @@ -1579,7 +1579,7 @@ mod tests { // given let mut config = Config::default(); let mut operating = Operating::default(); - operating.chain = Some("morden".into()); + operating.chain = Some("mordor".into()); config.parity = Some(operating); // when diff --git a/parity/configuration.rs b/parity/configuration.rs index 0ca62f07275..02527d247ea 100644 --- a/parity/configuration.rs +++ b/parity/configuration.rs @@ -1569,7 +1569,7 @@ mod tests { // then assert_eq!(conf.network_settings(), Ok(NetworkSettings { name: "testname".to_owned(), - chain: "kovan".to_owned(), + chain: "goerli".to_owned(), is_dev_chain: false, network_port: 30303, rpc_enabled: true, diff --git a/parity/params.rs b/parity/params.rs index 45547b46b9b..ae81a2e6b0b 100644 --- a/parity/params.rs +++ b/parity/params.rs @@ -44,6 +44,7 @@ pub enum SpecType { Mix, Callisto, Morden, + Mordor, Ropsten, Kovan, Rinkeby, @@ -65,8 +66,8 @@ impl str::FromStr for SpecType { fn from_str(s: &str) -> Result { let spec = match s { - "ethereum" | "frontier" | "homestead" | "byzantium" | "foundation" | "mainnet" => SpecType::Foundation, - "classic" | "frontier-dogmatic" | "homestead-dogmatic" => SpecType::Classic, + "eth" | "ethereum" | "foundation" | "mainnet" => SpecType::Foundation, + "etc" | "classic" => SpecType::Classic, "poanet" | "poacore" => SpecType::Poanet, "xdai" => SpecType::Xdai, "volta" => SpecType::Volta, @@ -75,11 +76,12 @@ impl str::FromStr for SpecType { "ellaism" => SpecType::Ellaism, "mix" => SpecType::Mix, "callisto" => SpecType::Callisto, - "morden" | "classic-testnet" => SpecType::Morden, + "morden" => SpecType::Morden, + "mordor" | "classic-testnet" => SpecType::Mordor, "ropsten" => SpecType::Ropsten, - "kovan" | "testnet" => SpecType::Kovan, + "kovan" => SpecType::Kovan, "rinkeby" => SpecType::Rinkeby, - "goerli" | "görli" => SpecType::Goerli, + "goerli" | "görli" | "testnet" => SpecType::Goerli, "kotti" => SpecType::Kotti, "sokol" | "poasokol" => SpecType::Sokol, "dev" => SpecType::Dev, @@ -103,6 +105,7 @@ impl fmt::Display for SpecType { SpecType::Mix => "mix", SpecType::Callisto => "callisto", SpecType::Morden => "morden", + SpecType::Mordor => "mordor", SpecType::Ropsten => "ropsten", SpecType::Kovan => "kovan", SpecType::Rinkeby => "rinkeby", @@ -130,6 +133,7 @@ impl SpecType { SpecType::Mix => Ok(spec::new_mix(params)), SpecType::Callisto => Ok(spec::new_callisto(params)), SpecType::Morden => Ok(spec::new_morden(params)), + SpecType::Mordor => Ok(spec::new_mordor(params)), SpecType::Ropsten => Ok(spec::new_ropsten(params)), SpecType::Kovan => Ok(spec::new_kovan(params)), SpecType::Rinkeby => Ok(spec::new_rinkeby(params)), @@ -369,15 +373,12 @@ mod tests { #[test] fn test_spec_type_parsing() { + assert_eq!(SpecType::Foundation, "eth".parse().unwrap()); + assert_eq!(SpecType::Foundation, "ethereum".parse().unwrap()); assert_eq!(SpecType::Foundation, "foundation".parse().unwrap()); - assert_eq!(SpecType::Foundation, "frontier".parse().unwrap()); - assert_eq!(SpecType::Foundation, "homestead".parse().unwrap()); - assert_eq!(SpecType::Foundation, "byzantium".parse().unwrap()); assert_eq!(SpecType::Foundation, "mainnet".parse().unwrap()); - assert_eq!(SpecType::Foundation, "ethereum".parse().unwrap()); + assert_eq!(SpecType::Classic, "etc".parse().unwrap()); assert_eq!(SpecType::Classic, "classic".parse().unwrap()); - assert_eq!(SpecType::Classic, "frontier-dogmatic".parse().unwrap()); - assert_eq!(SpecType::Classic, "homestead-dogmatic".parse().unwrap()); assert_eq!(SpecType::Poanet, "poanet".parse().unwrap()); assert_eq!(SpecType::Poanet, "poacore".parse().unwrap()); assert_eq!(SpecType::Xdai, "xdai".parse().unwrap()); @@ -389,13 +390,14 @@ mod tests { assert_eq!(SpecType::Mix, "mix".parse().unwrap()); assert_eq!(SpecType::Callisto, "callisto".parse().unwrap()); assert_eq!(SpecType::Morden, "morden".parse().unwrap()); - assert_eq!(SpecType::Morden, "classic-testnet".parse().unwrap()); + assert_eq!(SpecType::Mordor, "mordor".parse().unwrap()); + assert_eq!(SpecType::Mordor, "classic-testnet".parse().unwrap()); assert_eq!(SpecType::Ropsten, "ropsten".parse().unwrap()); assert_eq!(SpecType::Kovan, "kovan".parse().unwrap()); - assert_eq!(SpecType::Kovan, "testnet".parse().unwrap()); assert_eq!(SpecType::Rinkeby, "rinkeby".parse().unwrap()); assert_eq!(SpecType::Goerli, "goerli".parse().unwrap()); assert_eq!(SpecType::Goerli, "görli".parse().unwrap()); + assert_eq!(SpecType::Goerli, "testnet".parse().unwrap()); assert_eq!(SpecType::Kotti, "kotti".parse().unwrap()); assert_eq!(SpecType::Sokol, "sokol".parse().unwrap()); assert_eq!(SpecType::Sokol, "poasokol".parse().unwrap()); @@ -419,6 +421,7 @@ mod tests { assert_eq!(format!("{}", SpecType::Mix), "mix"); assert_eq!(format!("{}", SpecType::Callisto), "callisto"); assert_eq!(format!("{}", SpecType::Morden), "morden"); + assert_eq!(format!("{}", SpecType::Mordor), "mordor"); assert_eq!(format!("{}", SpecType::Ropsten), "ropsten"); assert_eq!(format!("{}", SpecType::Kovan), "kovan"); assert_eq!(format!("{}", SpecType::Rinkeby), "rinkeby"); From 5fdf6be798287e2d758e5404dabb652530ef52fb Mon Sep 17 00:00:00 2001 From: phahulin Date: Tue, 5 Nov 2019 14:07:52 +0300 Subject: [PATCH 20/21] Update list of bootnodes for xDai chain (#11236) Reference PR in POA repository: https://github.com/poanetwork/poa-chain-spec/pull/127 --- ethcore/res/ethereum/xdai.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ethcore/res/ethereum/xdai.json b/ethcore/res/ethereum/xdai.json index f57c982e07b..9e48f13d49f 100644 --- a/ethcore/res/ethereum/xdai.json +++ b/ethcore/res/ethereum/xdai.json @@ -2965,6 +2965,7 @@ } }, "nodes": [ - "enode://66786c15390cb4fef3743571e12ec54ca343e7f119018136d68b670edd93604eedf74e5013dc5c2439f89e0e05593e29c409a97e155ea4165c6b832de131ef1e@3.214.113.185:30303" + "enode://1c19ba0a77dd663b843c33beb9020e7eb41fc34b47b98424dbc427f74692115d74c7c27b6c0aa2b59bb1d8f710650cae1090153d10b6909ca7bdcdfb183b1c59@54.39.190.172:30303", + "enode://c1c3a604950119f82d78189792b73f5a82a239017c77465e3c32fc51c1d758a9a772ffddd58436d465342f2cfa6d4a442a49e526743f4d8354d7c5ce794c3ee5@95.179.222.48:30303" ] } From 8adde605e90097c25794ddc7b1ea16e827e65c66 Mon Sep 17 00:00:00 2001 From: Thibaut Sardan <33178835+Tbaut@users.noreply.github.com> Date: Tue, 5 Nov 2019 12:15:24 +0100 Subject: [PATCH 21/21] ropsten #6631425 foundation #8798209 (#11201) --- ethcore/res/ethereum/foundation.json | 135 +++++- ethcore/res/ethereum/ropsten.json | 658 ++++++++++++++++++++++++++- 2 files changed, 786 insertions(+), 7 deletions(-) diff --git a/ethcore/res/ethereum/foundation.json b/ethcore/res/ethereum/foundation.json index c226bb72542..1d51742c6e7 100644 --- a/ethcore/res/ethereum/foundation.json +++ b/ethcore/res/ethereum/foundation.json @@ -185,9 +185,9 @@ "stateRoot": "0xd7f8974fb5ac78d9ac099b9ad5018bedc2ce0a72dad1827a1709da30580f0544" }, "hardcodedSync": { - "header": "f90215a0557f77ff4e628bac793a289e210d75674ce75a4cac68f29f3e4209a19ba5da6ca01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d4934794ea674fdde714fd979de3edf0f56aa9716b898ec8a051bfe4cb118831840e2d4eb956204b4a319141c5f385fff86ac476b56e7a4639a0063575b691c250837964f1baa1c195ee4a47265b9dfe035dd32848410d44775ba0d3a849bcdffe85893354e17cdae8420f1f2cf5c208c8581a07701af2343d3f7fb90100244090470048102945c08412402016a4080d1101011042180401108021080000084000000070102440814002107c0500a248040008080ae9411a5d10203089d0c2010000002022084800900c0002600022448000a9088000028805608000008200042204262382a0400444000000194020889000582240c0300001931280090008102080000185050006040080002011004080058310080302803240841004b10001808802902010838523a020300800000000032909880022040290188504c0048010022000133c200040208405044404000001030c002001004208908424400921a000242440a020020000042c30081a2d0002008454c1820059000080800187088e239a0455ff83824801837a1200837a0221845d7ae02694505059452d65746865726d696e652d6575312d33a06bd4ceb33bd01a9f2bcb6e672dca63300212ca82e61c21f5b54e78c520b791c688b2563bd003666e1c", - "totalDifficulty": "11885312622716222978077", - "CHTs": [ + "header": "f90215a0ec6330e9082f796d1d40cd146f1c504efc5823b486633f81a9f8ee31e799d41aa01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d4934794ea674fdde714fd979de3edf0f56aa9716b898ec8a0d815854242c0f817a92beff41d66fc19dbfb2e4769762da7a2d4e49a9cf831c2a0e7e0ffc7d9a8ab82a7713cbf850628bf9a5227d80b0fe75d10b682be74bd90b9a0933423cb40b87bbcc53383c7d0a24d2ce5e8de99f2ba9213e51b4bb86b2fbb27b901008a0200250d21200aa00806e32495058b8880962440b0005dc4900000fc63451012c084c8c6224a0234ded20e96099533b08856aa0288a3bd00666137612c5680400000c4ec3ec5118ca2fa5c40804026c782e0188e4602502500c34460101adb47400d1b52c6884995204ac402d0bc10df7c1929827a9880b4a4051190406049368a1387c24c840a90b6c2b4e48e003e28459dc479c00042184824b2b8780308f3a660d05438a115a68804a16b209101020c0d9046812b61bc8004871b04402b1d904406114120beb0ea108a1cafe6983d9010c984882d2424301200000a78e0b03074ead02004044702412122423cbd2c5a4020ca9ca041998158050838033d8708cce2eaf2fd8b838640018397cc4d83979c13845db0992894505059452d65746865726d696e652d6575312d32a033a7c1a79360234b45773d79bb2d017ccf33414e59502691c87fea0a3ec26163880e5c7838013df6da", + "totalDifficulty": "12517645144159165893352", + "CHTs": [ "0x0eb474b7721727204978e92e27d31cddff56471911e424a4c8271c35f9c982cc", "0xe10e94515fb5ffb7ffa9bf50db4a959b3f50c2ff75e0b8bd5f5e038749e52a11", "0x816e7463af7b5d2fcb804ba55f09e8452182b0ba6c995a34e144245d76333d55", @@ -4356,7 +4356,134 @@ "0x7280b73efa14f10d39306f2d2dc7832c0e47fadbc14f990a821c76d60be529f9", "0x3cd2b491fa5228b4cae420d5c2a2da9a5e07a32f2147f45f3fa35dbde38224f8", "0xdcc642f2123fc607d991e9794210770453e1befdf52582df0bbaacf85a148048", - "0x79a1710d32bfb57c607c5bd23fbd2b8fe3356f586172e507d2688185be8993ca" + "0x79a1710d32bfb57c607c5bd23fbd2b8fe3356f586172e507d2688185be8993ca", + "0x9ed1335deff01eda0b660081d44718b7cfa0fc69c3e9946c9733dd7ea64d6f8f", + "0x37f70e002a78cb3e8266d5ce7959a45649359b6b6ada51482d097b9f32e93179", + "0x814f9b9e4af3c84c31f40af0028086d16900f9c63f519f7bc3c18c0eb5c407dc", + "0x9957e067f5e79fa6f40bef2036c6d19734146ef231ffc22263bda5c36a7a12ec", + "0xa1a240b8ce8973e91dec89bd147a3b7af274fa1e233cc56b9dd83bcc9311a029", + "0xac083bbbb8455d3e145f59424d19a8fd7c6162d32a193c67405291ff64113bab", + "0xf2182db4682212298b31bd8bd086171a719bd68424da98dc133c83ad043ae903", + "0xb3015688c0e0f55c6e97034615de00173151c4334c72aabe048c47c244ea5082", + "0x15ebd9c48235918e2d8b2260acda2610b71fe3c4ba7f853238df940d021cd60c", + "0x847729223cc8abde709cd283dcc4356375ff89651f39c9adab865fea75e10708", + "0x39c9a1bd9e21caf13132b33a272b429c68cb7af1b8db3df08280860dcce141b0", + "0x31f21eb219700c01c3d910b2a922788d790acf6ad91c8de739795f1a740c220e", + "0x7fee191fd2c31b723a1d4a57af9366662e62eec889d886b0325f0c1e2e4f9d57", + "0xc682c555d050a03b8164ca927920ac6f97be4f96eeb8efe8e4fe3d7b48cc8424", + "0x1b887661820a95c845fa5c8e0bf10028b81073bbfa072a2f81f82b4aaf3c68e2", + "0x4e86af7e8a0aaea28c67e2658b97540e84ebd4cd1a9dff33c99a45cdbd0de661", + "0xa93100e0dcab1d0799a13d40ddb459e32f6e95d2c661094d7e8d09e008ed2486", + "0x2d15cbd72ffe23920d63d6916f68c5a75d2400b0417283b54ade9dab8ba3af5c", + "0x72f199719868bb4b4546407f7dc690180b2e8359ab6e747fe3ca4861c59bcfdb", + "0xc3a9a2ad727ee7623ec35671a330ff150e504bd20365a7dfec0295909e9973a7", + "0xe4dec421f674d4917299076c9885c49c51e7cffdc5253696b552b9c3ab307cdc", + "0x426f724354ff7fb3114bc2e66360c996dfdb1e8585d3967738285a2030a89b07", + "0xf39f6051d26d8b21aa5592dffc3be99480a768a0be6afb8b8eb5bbcd4058d4e4", + "0x061bbe83ae46285c935b9bfd646cc54f4da034b33dfa8b3b8c902995a77b7d1e", + "0x37b7086aa13372623ea527ad0dbf08bb2162b274420972c55030c4001e86a1eb", + "0x2de6121506702ddf0eb5ec8e2eae6110ad41b3982c73cf8382bea329e77a8cfa", + "0x4e941c3da784368dc838b7b8a77ee51868160a79362aef6caf0981fed3ba3d36", + "0xad2e32669978cdc836e32d3dae7a7a89b1d0e28e5f938247d1a6233eb055b481", + "0x8d0d13cfe3e40eca8c6ec865aef23fee9f5af445131bf0aeffdc87e4640a1212", + "0x8bf162d69c4565050dd4496e244ebfffa69bf13abaa9e7770b8173999340009e", + "0x21a33a33d92a99de5af52ae238a799e3307258b8b91a959a485238bad31f913a", + "0x21a95996aa2f4abe48a35617de16894f14292afca769679a63a03d68350cc362", + "0x57bfa7d2037da6aaa07f44594cef60a598ed2bc1218b9f6af48dad1b42759e95", + "0x7324fefadaab09a26c065bd98d3e9a56eaa7ef78df1269c1152bbbaaa6693256", + "0x41722de103de41c72010d1f19166ae0ccee2bb72314c719945f4162ffa165ac1", + "0x19b2f1f42353f935f46f8f9421bcf06e2ee573304d0efa13071d676ea174e18d", + "0xd7fc39efd2a392efb8de6d7d1c7807ed7daee0c8b82115acc60beaa7f6d9b86f", + "0x5ae63df9ecf9aee8cac4d0ce1edd37a95069d61c8d8ef886a150eda4bad4c87b", + "0x6e7aba83a3654cae6b12a6f87a9739735dfeb43ff67e309fe4701b8b17937915", + "0xd624f46d01a186da11d15eef4d79250191605e51ce19b9e02b62e65d84dd1c38", + "0xbc134d2f8acb6a60d424d4c8c6087fbacbb5202251c89ef720dded9947e3c4d7", + "0x6e8e39dca2960de07134fc043f73c9757c42c6827ef22d063c44a5573ce6c8f1", + "0xe53089dd7ccb7e0e78f3cd7d7ea342ce5a2316b50d6bd033ae621f6ec4329a46", + "0xca3eca5da2a9ded537dcd471390b7d97716deb0c5cd9e0d6a7e2addbadd97cac", + "0xaa5799394d99d90642d013e8359a40f2cc72e6b49c91233ed930ea1d32b360f6", + "0x8ae22559b0296959ef540aec5702dcc03d2b2bd9411b69af756d7d9e12e6cb90", + "0x5067bf825ad66e89ae1c46f1ebbbee8a77c2d285fb66c01b732b6c3f629b2ca2", + "0xf2f1c4304b5ec8b314fc6a4f9a9df69472cf0a132577217eff1c0a80443885ae", + "0x4c888be868c74ae86a9c0648429bdb207d18794e3ad6b9ff79d9291dfb0d0b46", + "0x3083508ec1669fa69d5fa4ab1d84501868c7a054a24b0a432b74be1f3bd0ed1c", + "0x443f7e4cc89e3c798c788fd40185525d8402c2160e5f3434986922c6f8179ab1", + "0x16d395ee5e915ea950dfc7639f90a29fe04ccbb47a2b0cd303ea719acd48ed58", + "0x901df34bd40035ee95569ea61c8a9874fd9151fef5701e91f02578c896704f20", + "0x4ce474419d801fad788b158bbf40dc7d7bc2ba43e1c2424f91b858055a7b61ea", + "0x10b2d6126ce1183cb227e291b184d7541b3380e100a70d876587a0aef2fe588a", + "0xac68a6a550c4a40c723ae37abd07d9e2d8486a30cd4f2cf7285f6d74882368f7", + "0xa0800069211efb656d0df4a81f1febfb48f251c712ee973afdff37a2baf83b99", + "0x53293ec8346c1a44e3cf78017dd033dd90be4737045e1c55d27130d7f6f36dbf", + "0x0a92d75455eb5c2167e2c07e1575a9580c135debe7bafc8d15d1fc2a25b984ea", + "0x32e6f505ec66fa987746c67a470df78a7a0fd136ef814ed24f3b5e0988cb53b0", + "0x20e6f99aa4b002e35f97900a34322af373397dc98ec28ee668e9921bc41d7219", + "0xc309a8620421c52fdae475d4a29530a2e56dc0051a28f8c4205c09cba5443666", + "0x0fb5bbd851d3860876e1dd038fd3f8d9e5b8e8b4e0d3b83ba0bc3d06222ac9ed", + "0xd71830cb6f3ad0776795865aedf50ceee94ba9ec89533190d3dfe2107a9e0e9a", + "0x768040f6401331b029bb0222b7494ddd21525091d936641f4ef89f00cb5b20e8", + "0xc52b410050774495fb2e22e0a94bc97dc72aa86cba7b20e8ce6c8a20ff03c5e1", + "0x026072e68a13a5ae0721d9e47ace688b75e16ba76ef67ff01d0a11f10e80ddc3", + "0xcfb1040048b9312c0d274a6b2576c7907176a983f0c0e02b120c10bee28f438b", + "0xd3036d04273279c5fa5ec4a096b8fd8a68a46c0536c24519b0ee5368c5103d84", + "0xdb9bdc3edecf7280dabcc104885942eced615311e93c2fa06dea812adc626baf", + "0xa25ca25f83c418bbfcba8a16cf661902499d3651b497e75161aa0d0bc4c3717c", + "0x96221feae35068b02e1540f06be277c27e938459af8718a2c883406b2582ba31", + "0x5584e36296dc2cc61e21c1e6539f66d918b800025fd6460da31f869cbc357289", + "0x7a0de103b391af8b2a9af3e6e5c2c6bf309d61cebe805db82d3addfde5395b4d", + "0xc5b000944c368f67c77e6c6564c5be5bb1fb84eaac76ca2bb3c7ddfde64e5635", + "0x544ea39b4d37a698bcb0c2dbd689ef90590e160db52deefe446d65aa7b60b20b", + "0x32160ce8e604c62c09814f8e13e795b654cfda57fdfef4b01c38ae3d078aaab6", + "0x5def86fc59562b477277bd6a2c1f1bd5a9192cd969c4ac578b16ea73031d5aa5", + "0xc0fc111d2c0eea81e7d6e0221c0465cf950772fe8dad94476c0e33d528928f9a", + "0x1b803a048d3ab8e5b4a49b3550c6586d71dd6f5409da6df0bc6df76de94e64bd", + "0x549d98175538c94e098c93f77ccca9ca0cbd11ab7c270ffcf1d3a908adb4d8e4", + "0x17d331df92fe4d8b57acde9bff8eced101f461e3470691ba7b46df9ceeb8129f", + "0x7a496054ef706cf89c0c55d848cac64779091799d2d64d6cb43907d2222c000b", + "0xe86b6819e9a482600ce2c9b42d248dfa3262547eb7ed42a6c1ebdb138e62206e", + "0xfd49fc9e5f4eeabb74a7d9ab4ae8a0e583ca153ef4c09e697f5c0207e6505ff7", + "0x9a297101369d0cba7b6f7edfe1a4a432d91f74f88ed3473ce14dc91cf616e903", + "0xd66a19a2834cbd910f2278b2bd5cae2ab9b58fe1a9e583cce4e2d22903d767db", + "0xd9cf8987c12672ec0e2bb97b25567f3f914fa8fb89b1186c6b665967834025a2", + "0x54e18efcf10895d51cf8f8dd6541ca097899fbb1880abd3b68aefd6e657a0af2", + "0x759486342c0162d26a8d2a0881affeca579a7cad80c32c6885d910f9e966ed94", + "0x02b2d8cbcb7244efb913aac80895e6cfbc81b60cf831b0a19b2354e0c7e00b72", + "0x414736aea69a7be69bed90c56eea05e5df9db9667f3b0b07ee6622442628fd88", + "0x75db93f08ee2236e4cc9222f8167c15c5bb31b4b9cfa1fe62f5175bac9c4c6de", + "0x07c460d27a5df943f09d114d99cc39c05135953c416591a7dc9bad3e2c064796", + "0x42c32a832d8a9911eeafbf0ed6550cce1be3832304f22a63d6edf1b72d92053d", + "0x2f8226acee0e5cb949592c1e77ac3da86f43f3834df940349cd6a55626ec7d3c", + "0x3f3e88302fffecb9751ee31a36de3abc6fb7963e264988904daf8fe6aec18fc8", + "0x0ea47b2cb04403773d9420ccfde549fe763bcdfe350c7546e3293b4612e096bc", + "0xf03a38c16a3ee05197b7c77985c2640af18479ebfb7db342416bd0baf2645eab", + "0x32c9844dcd2794e987ab14af8aab52d9925d77279377185697bfa362907f4bf3", + "0x72985d640d5ee8da6a1e0aa3ab71a19168802c29e3ab915d61910523d2d8a550", + "0x4453f4c055057ac3fb2780fa8fe131b6e08ef90a5b30930a83d4cfa5120ff6ce", + "0xb13ff4f56efd0f41bdcbc06c8a917f81614ca363f8c06bb3bd748467e146f959", + "0x172419af274d54de1a3ec6b10e5e8f98d0941d07571f9a5eae977597f0ea6e2e", + "0xa70469fc4070b5a675838352457cb6b4566a7a95ef843b0cf49fc0e02a342b0a", + "0x15072136cb1235007413c137115f4246ff22dd33bce99dec813042d6638ee502", + "0xa883cb9646a12a6f13eb4e1fde9422767be38279eef669068db6572d449da45f", + "0xe752e1e6ddc10633853a0c997727644b92aff7e46710c2c3850f6994edf83072", + "0x880e73586a7d6d79b4a7bd30f551d04e928747962ec263867f53dc33709353c4", + "0xcca01d7edd840727db14e657c9edb63a5518b41115abbcd848a60c9800e8b244", + "0xdf231e025e5c85b82fac8c836df78f5ee23509bb7b363b018ab27cf83680ea52", + "0xb42b4d31d1838886a6cb91123748078b5d07384afb1e574146a0174b6e3609fb", + "0x243c0ef11b9cedb39146fc35149291ea31906f60f56642ec3af28753936c7b08", + "0xac496eba34056ac76fd2c20c300bbcb66bc9d5257859aa8b8480fb1ea44cc60f", + "0x1631a82a3927c93bcb93d055ef94963bd00c264816768d7a12b1e6844b65a226", + "0xee630ea7011dc95ef7c9dab11e2c89a8065a85b7ee3ffe35bacf38efc61706e6", + "0x8bcb73df8715723d55d5635d5b1d5332af85b2945871172d22e10a2f19cbc9f9", + "0xa498dea3b8eb89b40f963d9266a2d4e71e3492c614e597e08dcf565e54d2d8cb", + "0xe798586f9f5bd8def445e5b66e1cd1037df1fc1e043b7c4a804d1cf368aaff70", + "0xc7e9da2ee64ed53fa9306e35e019c7fd74030f3065b5514189c50931d70372dc", + "0x557acd95f593728a732f1ef04b94acfd5475da37a18dafda2cac957db46b24a2", + "0x303f4929efdd5f54365d8927aae229df99e222e76e42b494e216d5365a4330c2", + "0x6252147a7a16f988726467394919d25e24a28756726bdefbdec768cc84d125b5", + "0xd9bd80354f25a846ccf3a47dc928b1d47958598474749795d4f1885f172fc996", + "0x356cc71f2169917a76e87355c358eca62bb5c79fc4f38c4992ad57cb35ce493c", + "0xadf1135a2511fd2cdbd33006738725459f33edcc593b1aa936b55889fe9e9687", + "0x8359e90f401234e4a85695c7e369ef5c107b246088baf3355046934197705c89" ] }, "nodes": [ diff --git a/ethcore/res/ethereum/ropsten.json b/ethcore/res/ethereum/ropsten.json index 4912a16d2bb..58de06a9774 100644 --- a/ethcore/res/ethereum/ropsten.json +++ b/ethcore/res/ethereum/ropsten.json @@ -67,8 +67,8 @@ "gasLimit": "0x1000000" }, "hardcodedSync": { - "header": "f9021aa0a8da98b6ef1e12b6c49e85b0e965f1ed1688f5e3605f06bb3c6ce4f857aa0bc6a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d4934794635b4764d1939dfacd3a8014726159abc277becca0d03c319fe68a91e22fb3b945a8dfc73b817976e29cf57e6c8425e6a02e9bf034a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421b9010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000849fe1546f8350d001837a121d80845c9d55f29fde8302020b8f5061726974792d457468657265756d86312e33322e30826c69a04bf72e97bcf64717bfd655e2bca9ed1a5253cce5373268729161b1786ca4710488db3c50627f9321c4", - "totalDifficulty": "18787961645682286", + "header": "f90219a081352ab3cd380f66493aa270deeb239af085e68a83579dd8871a0b0a7c7fd4e2a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d4934794295856bcf02b2017607e4f61cfc1573fd05d511fa0a886a42f9a2733e392a5f9459f70bb133e5012f059d6cb6aeb360a7bb766571ea01ffc81fa17e357d368e82f1a658c8b129877818e34fdad26e32fa60ac4b12fc7a0946e845a5b468d8c679890632ab9fdff3349b307ce864c7b13195e4f80af4777b90100000000000000008c00021100000000000000000000010000400000000280000000000000000000000000008201000000010000010408010002010000000000002000010102080000008000080000000400000020100010000000200000200000000000000000000010080000000000008000000000080800000080100210000000080201006008210002000002004000000004a0000010800000000820c00010100000000000880000000800080000000020000000000000000100020000002000008002000200100000000000880840000000000242000000020100408800000202000000200000000000000000000200000008000001000000520080000000850340be271083653001837a12008344ded9845db0acc49ad983010906846765746889676f312e31312e3133856c696e7578a0a23e3a33f308378c4cb1eb9b34b40c224844aae072c0eba928a840f6d6ca69a28892892d000574e452", + "totalDifficulty": "26251713144679901", "CHTs": [ "0x614648fc0a459451850bdfe353a932b5ff824e1b568478394f78b3ed5427e37a", "0x1eae561c582dbb7f4e041998e084e165d0332c915d3a6da367638a8d24f3fafc", @@ -2655,7 +2655,659 @@ "0xebb3e8f76f3b6a95285154dc11d4bd94ac4c3a150383ed69f5373499b1983dc3", "0xb0919ed300acac5f912f01611a428861db27ffb8129a80495f735f0ac608ab35", "0x2ee321d9d805b78a97210df2977ab62b352705e308773b90e0f4e923adec377c", - "0xee00cb02e9b86978ae10b119924bbe6c38f730c1d1b621d32c9d697e11105871" + "0xee00cb02e9b86978ae10b119924bbe6c38f730c1d1b621d32c9d697e11105871", + "0x3138c1f196e8b3de9369c3c8ee1d556de1bae00896cac87b4083bdd7a691e738", + "0x0a777c53b3be3f3b136b24585dca1b7c85f7b0edd72f2173ddc70b0a1bc8bd93", + "0xbcb300ee517ac8356c36c002da6f2ad562c31c81a3353d63925e044b10d0412a", + "0x503c3b1da233bf2f9f9fa13b0488aa5384a3cc95dc21e6f2e73577dd3ddc1974", + "0x0d07a00e18f3db6896d0879fe87cf7aec13f30a957806f74cdb0c47ccac035db", + "0xb6e92e6a32c5434a79448503a269e6e5ccbf70bc59dc58957915621eb5951e26", + "0xc2381981c2a38689e6ca1121fd33eac2881b1aac64a850b7f5751d587a5a79f4", + "0x83c0f655616e7565d63333d8a5f99baf2f4e0a7dc1520d6c4142b1be6931cdf4", + "0xb17c34ad30548ca1889d7aa11aa12748f7c02431d64d7f53013a10b979ec7aa1", + "0x34ab63d2aea17cf800fc2aa3c8589fcded1a732bbfa2102315adfa03596a4221", + "0x6a7bae77e28fe9ea18b59e4bd4b81780daf520309808560d533604c0bdf76f84", + "0x64df132fc5319adc69249961df9830e5d63945564d912fe901d80e7859a87057", + "0x2323352a8e2f13d442fcebc760ece470dfe5542188f6fc2d38f4db6af48bc959", + "0xe9944f4b2d9e3fd7aad0446281d4971463c2e53029d7e7f40f8b0daad1a29d67", + "0xe012a3af1ddc10881cbc1c62c1e0e7205db5edebe74bd0c8d1c12bb9a3f47e2f", + "0x26672ff6f0f02089b7a67837aedea5e54acc3120ad4f2b936948d7053d74ccfe", + "0x70b1eb24d9c2544e26af43212c0cf70e3e2ba58316f5372db5daed02c45907bf", + "0x7156e65df46bc1d62e8f8ab4c6c2115a5129d28ae9e96ba779b4615fde08f267", + "0x15212b5fcc31d204cee80a4ba392e731a2fbe40e1a23d8fdcbc6ecdd665ac9ff", + "0x1508823c086bb5269f60b452fcaf3d58b6dece236704ad479205e1b6b870b7a2", + "0x73a9ba93b3a5444294b466acb8c560c0a62a16dcdb5c90eddeb19f9eb75dfd31", + "0x9658cab50473a5fdc06f3bf07b34981212f215bdd773439cda3a5a37dd96b7ed", + "0x1b76828d177851a98f2a4e4a5a28e2e50dc876878b4a44b7654c409ad6a58a4c", + "0x7345477276953426e16dc819818ba09988d1e2b552adfa47c5f7cf6c1bfdb3da", + "0x2419a94e778ed5aeff0552a884b87b12e3b4f9b87c2e5df66ebe9260f38f19fa", + "0x4c14ee271bcb543d5395324a6fae046e133bd3e34f6a3d1328c9d3c77593756f", + "0xcbd9935f32d758ec070e06c393f5bfb925515058237471ccc89a6c7126df2fbc", + "0xf945621e7c926f2739488d96c4e5fd42fa91a5be31e9a45876fe982166bd4cfd", + "0x427ae8d29c63525078a803c1e40554f77685866a46f2ad9d0f772ad0c10b43ea", + "0xe4a6753800fc0d20c0ddedd6c716f8fafbbe636256548170a871d2913c885c9a", + "0x4da6c6246e60c496e059dd80bcae5ff30dc285e2a2db142eb4da3f15b00c0df3", + "0x4d1ff252edc762f25066a466e26154162942ef71ad13c159c102d94e427cc926", + "0x663a98199d967f55acdb313e901cfa23768ae21e7b5efa6b6de88b93e96b08b2", + "0xf025c69018317e95880e27a96910c6a4fac0b5d7a52abaab7c616af08eab1090", + "0xa5dc8339e0b823dc3821867cc84bebff11fb0bb8fe2f54ca5748cd2d8066f68b", + "0x9b3835afa0d0f1aac1a603d1f322940f4b84da6c6352654fb10aea202b3b84b1", + "0x41cea6f1e1de2697e58cefefbd4ea1118acb43aaf9ec7a9c116d14a5310e925f", + "0x5f1e42931b16c26642f351b24bb063f6ae7dbceca760961fe4d07dee0286082a", + "0x9ab19e309d5a4fd3596f0979b268473eeccd04af6674968e1e340a47c6652d9f", + "0xd6dfe22679bc3590594bfa1ead582bd4639f1b3869915e802e8973666d29588d", + "0x92f5589f356fbf8e4c5b12bf11d5f148d94f0e9f9297bbb32a73ed8fc409ad8d", + "0xecdeb77e2b35647c59aeb935e6fa4404ddecf9287ffd84d02c090d6772f1a68b", + "0x18abbe4adfb8d2365a14201ceb3966e561817ae497754b65cb5441f64bfec184", + "0x4d57180d082ec586a97573b383a12a59664d9877d86140281af0eef88f8dc8fc", + "0xfd52e379ec75f3645ccd83653370e107970c5c61573ec688986895d5e825303d", + "0x9327212a8ca5d0139e6728f8b39caa571a7821782b49a2edb96371daf6320571", + "0x9d9b1cbc011a31b99943d9dc7a2a8ff2da0992a5e3d22bf24685723b85545452", + "0x8661975f8565dd506ee26d265ed78a06d0c60dc150df594b6a1cd09c5c383e5c", + "0x98574ee8064f0b276433b8d98f7db55b7387775c03d543f2a8d1f77cc9d9bd20", + "0x6fd37be595359e52e5482f53ab66c9e76ef393085485a4bcb344272607cf2c0d", + "0x1d2a15c07ac3b45c024b4c14c976ed18d0f2e4ddfc84fa153414e301115b70fb", + "0x1ebb4adc19ea75acf90cd66ded504674367b70506f4813e22cc856f10c36973a", + "0xcb0198d5b6883b582c6b389e6f98ed77494f3f6ed232056dff48a368bbc2b9c2", + "0x2bb53b3a72fd65a4a090b49301c448fe44fbe0c7773e938af9c511070b442957", + "0xbf8289e45461485d9ae0df36052adcc1c43089e173a54663330a4f1ccd6ff7ea", + "0x059c82830dd4ffb040cc75a4b354483d81bc6f16ffd0545029112845f8db7cbd", + "0x68fa73438a9093f1e2e5a88a244287cd1d068bc28ac0c7c88cecc70f2b7cfe74", + "0xf935992c7eea357445e47fceb2894d4c04c618fb238f6a84251c919cd2e5b97c", + "0xc2b6a5bf4ab7f6f43fa9f59269116929116e5f136faf8acc7a565eaf4f6f5a0e", + "0x0f06da2edc35f959f8f3c9f9b16b13df3d1ebc5de146d7467f342116648bcbb7", + "0x4cccb59e57aedae4c1aa83a19126e846b14701be2971f95868c9055b77461db0", + "0xb2a64c59c4a3878472f5fdc4365e61f6cb5a67a1b453dba34c2d257f97ac44cd", + "0x21d74f1e667bce1163c8da46d522bb39a6ce777b618c6d2551c01427a68a2316", + "0xe1d84da4146c25e3d89bece4bcfd19ebaf684086604c53e702c07b938057d88d", + "0x6ff86b85371f732a285b19e9372a2567529bae071a439e80be782c5e3c462c4b", + "0x86fce707891c52a94cb30d50c4bd08fdd5567b88f6676f35228523847c966032", + "0x59aeb5682b2a3443e6c8bcc4d425e3a59872090bc71dfbc6cacda9f02d9fb7c8", + "0x7bf9a30fae3402b8d0aa4f7b18842bbe082c1e11469f635792225c8e8e536f9a", + "0x3f13e2ce31229a9079f04f77131a170212bc64c1701c2ddd54713c0e59f03991", + "0x2daaafebbc63db1ea0a8fa6e5037c4da16a92fceda2dbcb9576fc2fa28b0ee74", + "0xb14610c614c0c0c59e295fde6c4ab0e4b4c174385fa734cc8a2095dd6a95358c", + "0x14ab25c7f34bb626f581d38faef3beee599300a51bb62d3e1e1dded92ddc95d3", + "0x409ca4196a8db10326ca032cd14b7295981f0a779a42c7f0233d71ebfec3b19f", + "0xa283859dca46f41b5ca2f403aaa9e2356bf41e06697b5722b245c68ea3f81b2c", + "0x1c917355509fab582d5556e340b71c6962577da9e189b703456dbb7fb55784c7", + "0xb928315f7ce4508f4014962fc95a5942a5c0ee66af2e125101ab02d04b6cccab", + "0x00c6a46b1b4eaf7f62e2133d454f850ef1dae798d5aff512f607dd8037e53bbc", + "0xc042c1ce9cc355d4e054e5880f7c09fa3bcd58047159fe6b08a02c80059acaea", + "0xbf7b1e204a760ae2782e926e202428312955404786b85ab00688da616682b085", + "0x36d29378eacf4d587bc5a569e8ed572cbcb71be0a016d69909a05457915962b0", + "0x27674967b0e43a5f70ec168cb00df61a1227da4ac61660769ac2a7a2cdcb2598", + "0x9bea8f7596f72268a51be1b993cde5adbbe175ad48334276295687a76f801fc1", + "0xd9e17222c824c8293b05702e3170a059543bfa3e4bdd19828203c7072f013eb4", + "0x170685db98bae956224b3a57e4cf50ae4a8874ddc988f70d5ea31357c2a83ed8", + "0xb8e7344df221731d25fc88dfd31f938005328202dffd0be8d28e9d0392a75c81", + "0x47abee9a0802d59dec86fbe5d9a13a7332d326b900cae4e3841c69e9b25ac788", + "0xc09452238c2890433e14e0fcf826051c752580f147750ca745d1b779f303ef9b", + "0x05bbb06eb270618437a1300c02964c8f854d4a6daaab2d59ff6cc69f46c7234b", + "0x89d752b94f59ad98d59ee317c3ebcd840dcc997efa7fb88797c35477831c695a", + "0x2dc622984dd44a2cbb4313c7efccba85b497e33214eb314dfd7f2be40fee6cd3", + "0xe23e51675985c6a4f887c843048487721da6ae6a6676adc87a805fdd46149f9c", + "0xa452ef2f6e358a534dfc4914a2c7ad3ff9faf2d16fc0b7cab96659cef5e4eea0", + "0xec9f04f090f443596129248d8675aab78e5275c56691444604751a0bb5da443e", + "0x52d8fe33aab98f680b3b7d56f501621a5516d3999bf4b1804b4ec0e845f87ee4", + "0x22dce4da35077c2efdb94c41c6ec7e17c1a3604c3c7b70041728a96c3d533851", + "0x706284df96499696a8c20c7a685493663b149af04afb5635fb831bdb20de256c", + "0xcfd7fa6c9a27e3b9c1f124522c87841a22105c561224de3c1d7a5e441f980c94", + "0x562458d2c5b55b9fe6116ef5cf165aebcc40d86863efb5036d42f1f86a804e73", + "0x05fffdd643f1eefb8083d7c2acdbbd13e076134e05c0ca6bed8049bc747403ec", + "0x1f1d7cb9e496d998ea6f8bdeb31e977dffc942987157f571cfb38037b8585bba", + "0xaac332309b32eb92fd347871dc513987c06b984ac00feecbc686029cd548ed56", + "0x64c449079ba124feb488948f3b17f6e68207992d71cc4a383563510503414932", + "0x0aa5215822bdc1f3151756079fb5435df2abbeeecaae1050d33af6fa1ab37a87", + "0xceddb86f1882bd3e196856e9a43d95a37ef115a4a2d2a86166ae827c7b0e8f0e", + "0x3f368b92f5217f872d9a38c14e5791b72b3b25730962514677e2c069bc04de94", + "0x9ef75df3e9b2e97208b2c4d0917ba6de03b437ccba8e580b9f4023a1c753a354", + "0xaa662f12ed9e399bdfa0e81b7f52c217029166b483a1ee492328d596d95e55c8", + "0xbaee3ebcc9a9de22b3d4067d905beb6c75ec7715d06a426dfba366da9d9b12dc", + "0x4fd3b9baa9f53e6edaa14c9d69f0cf2f0010d9ead83963d96b87b7505b97e83b", + "0x808d62434ef0cbd193a3ec3cdc60f79ffb797ea07d53b98ba1afaa8497cdf7e6", + "0x1da441a4ef8e75eab531c5fadee15bd1a60e93043e6f5b5264912d760ccfd79f", + "0xea233791cf501a1b6d172ecea7ed1e2fcc39555b597fa3ef86f8b63ceffef6cc", + "0x57e04235e51c579d0a7fbf74d469c6a74403cbd09ee56f168a74a3c1fc5940f5", + "0x46d051393b825130670a2d56872467b02033a8eb479d466c6522fc466020e76b", + "0xd9c313e7ac54bf497a315c8af6dc1f3751e10a97dab570b04f80811208f0c2d0", + "0x7219321803c2a129ef429886035bfbc27dd64fd50515c38a7c43bcd184a68380", + "0x140c4deb5543c31c49296e68bbca9d7c10799ff293e05ee130982a6d9f3d4638", + "0x2cb5aac917f6c1519a7cb3094953d9851d5498b954b62b05045ef0fb93924419", + "0x1aaaf2699d5ac7bd2124f3509fb2148dc1c93b940c517eb9d4417b6a6a911a21", + "0xb454286ea98d62faba2a2e531f6e2a42a61e23ea3274605f8e2c776697085dea", + "0x100a6c25a0221361db912b4a491a001032a3cac6909f8d805ef82251f635aaf3", + "0x08a834de8f3ca2dc5f7075f0ef5246f6d824ea4577a3d238b2458676896a846c", + "0x6c0878c40a466520a5b86a06670ff0e1ce97512205ae8c22995d0bc48d9ad222", + "0x6835b4bb12bae675af54580a1fc57f266c050748a583f8b6145306fd3bf86cb9", + "0xa66940592c705e99bccb61c82e6112cc75aad73b605aa09280edeb065718a043", + "0xc565e42a728c1a0211ebce7b5ce9b8088e74ba9b254ff339611806c239dc72f6", + "0xc691d8ad39fab8e168266f1d502f02f269c7f44ddd055dcee529136cce2b835e", + "0x34bd34e5e476acfdef9f3c260a8d6f9d4236e58a9fe60aae99c38f8fbd465b38", + "0x9bf9269591e17668d01181d6a0d71ac17b494340e47034ec5f40f91f0bde9f58", + "0x3f3b051eea4259b90aa1063772ebf6e05563c7de791707bc8e35cc5ae561d110", + "0x7021c2db5c4df7a546d99750bc905b1a9f846afc688b7a033653feb8a9afc12c", + "0xfc7b212e599b58ff35eaa80b49ead63215ea826dcb3edc4df7500334cb929935", + "0x6cf11be5e7c9b94e24ab241b7552fb5bb089ef9b3dcd62bdba020b0332d4cc05", + "0x9353b5f84c414f0274732975cd3449a7ba55aba6665b5cdca14650e6387ffb3c", + "0xa4717f0fecb6a35c60e9669c8a754c1c2d41f6144cefac52531f9870fe0351ef", + "0xae685fc22226cfb05373350506f1f2072406b3d391a4b57ea5c467a9286ddc3c", + "0xd91482bd0e080649387aa580e255d77c197c1734a692296b27470d8f20d971cc", + "0xbe97061686e83466182be54cfdc721637ef26e99b247ea68b814aeef0123f076", + "0x8bc0768fa4670eb28beaea6ebe20a7acc0f23832154b61515bdebc9e6e5aae61", + "0x9570703dace2ff11a3e8d61552baaf3e5e812eca124f42210f1300ccb2116158", + "0x21a68948d1014f8e541adead6c9d0e73f003dbb3cdc145cbfcdaadb1ab0449c9", + "0xad51740caef4a8c01223fe11d7346852ed0873b38a65fe3ab1948e5946e6a8c4", + "0xf5b3e50890db272ac29b8fed050b89a3c1260563466cbde8aa6d50ab66c28a54", + "0x635e873d51779460b6b4dc2683ca229826e5a40ba0f5963a0a27d02eb0370cb9", + "0x13302c3e93380ebbf6b54be15f792f0878396dfd9e8da75689e4dec5f30ca85c", + "0xffb0746ad72d53240895bbdb07d1cc5a94bcf4e6422c0dbe7b2b3fff57587271", + "0x1cef16d47f2975e4517a9bead7df47d7e0db677c68d80e50edca3a81f493cdb9", + "0x50824f81d7ccbdadfdf5fc4b082d920d1416d6f3e6dae3a347e71993a2565ecd", + "0x10707c02efc13e50e5b1a9217ba2602ec77dee3817385d145674eceaa21d2892", + "0xa281eb9159884095b5d3584b67bb7db899464fa176cc90800ed8ccf23eccb4c7", + "0x2f63567e75786960025334d3772571f6fe1ff411b6bf867c84c1455f3954ef13", + "0xe1d9eb8d78fb1365f28d4112b14f3d5575a68f1160813f0d0a2a1faae3266d1c", + "0x7a7dd4036031fe92e19c41af52f5c039fa3c12430d5b79111c568681b640a2a0", + "0x509e93ce350453b61b502de0f87fed794b0d77bb6878225122eee67a1414320f", + "0x679778b1f6732382d834000d24a94223b69a0a88b56d0c070b659fb2daed668c", + "0x49963e1807e7f45e132a7e3d2cf7c10fa0e1c36aae866a9641cc801ee8d261aa", + "0xa1124f9bf0d2b0ef671ddcfca3a66a86545cac8ca9ecc82631480ca091ccea94", + "0x9ec43a9de16fc83ddf5022891c6f5593796122b9f9c72803373c62888c5f9198", + "0x5af071f137c5584bc1766ef4ef092fdd8f4a3a3a64ebaca50b169a22e32d2542", + "0x5b3ada30dc686e15bac396821debd08d8a96fe1450e5180170241cd6527b4bbd", + "0xe56f8e15e3f74d77427424811c6d03b2bc98f010750c6bc83c34b8eb94bee0d1", + "0x5dbe293dc9f09c20091e29ec20249a9b1e52e28ec863afce106f03a75b88b111", + "0xd61adfaf9d822c3d8e981725a42113a13abeb8f887f16e0ae021cb23d7255a2f", + "0x1efdd0a60ad05c11faecde65b02f3ba3fb85bce685a9b89ee4e6a94ddde4b7d5", + "0x60613e04232a203fe161398acf4346652a9b6b9a07837fcc06f53a950136d911", + "0x1b9f0c43d87ba4efaf7781da46f52a6eff60b8c9ca6d81dbe02bf6774fa80047", + "0x41aab71c01968d0cb73fad35b9839f6ba2e8d807852ac9c6f1220d5aef866f74", + "0x67ca5da2f269bfea45e0ec5037bcb1e467d5938eff17760f6b3c5ef74448af69", + "0xc16c2d3a36275d3123d5d95b6ace3bf131af1e6e07de185a8f4e335c5a3cfc1d", + "0xa70dd20159272a4d8e5efe456500a1f710a271b690334e98862a24d31d4427f4", + "0xeb932d05a4e57bd9cbe363a96cc616d0aed481298cb38183bafbaed9384ed27e", + "0xad772cc01c6537fddff8eacd182680e1e8b0d203bbbbc317a4ad9c1e7c1e4b71", + "0x81d7acf3f3760b06a68257654e4b0c466883e3198c61ad71decae53963435817", + "0x33cbfe14923923214b2047d445696b34251f70d53005e84f43e383fa1dd791fe", + "0x8a74d3f3c775f619f9225388fb5172b187141a8ed35ad794c40b2d278e6a388c", + "0x9db16af2961834b804e6330a9f587512c92a137b8656bc5baffb227686fea9db", + "0xa23c0d4f859ad30a4b7d3863ad16926faf41b4623e6adf9c7f2a59815890f4ee", + "0x97da87b047a43970a8e537ed5cb15c0f28885812262e8119c659a3d1a92f8aab", + "0xe0a2d92c83b8ab1bfaad4bd1e717fb5dda967c001ec7662815042a3544bef441", + "0xc70983fb6257a34bd43862c405023db2112f0b1c4a11aebc23ba17eee3ecd1e5", + "0x05798069ba546f61fec26ddc4b260fcadad3a84d612900ee2afc84e10dd13358", + "0x1d12ca65d3a55ecdc19fa4135e47bf470bc6ca85fa6639eeeabe951d9d0ddfa2", + "0xd47f4b22fc0326df733607783934b1be3818fe057afe802216178a450f507c17", + "0x4d71d9619222c0c4ebd0fb25da7e53358ddf4ab2cbd962ad88b37fbb331442ce", + "0x2be4b69114e307d117df01cb568d35f79588ea70e9016f865f641614691cf7c8", + "0xa87d1304e2462cabcf90207b81a058ae766273007821ac98b718467792eff05c", + "0xd94b7d41761d34a27c5cf565f0e92fbb65ccc3e8aeb5b1c1d9d233b032f071ba", + "0x6079df72e53c3f1793bcf5a4d22ed2035e31662d45bfd210c4bdee475335039f", + "0x85506dcffd6342df61e673ac01219c58198558bcaf7759eb2e4b19925ddae8e6", + "0x6a19a7212075395bba890eeaf4709c7025af6ef3087ca86671da478c7e49ed83", + "0x62c52d8ad2b6c000462358d31c652b280bce3676f103d7182fd3646a7f007604", + "0xa600ffa0e6d161287d9b9bfb13ee9dba74699e542aede1278d5344e6688f0382", + "0x7404c9ba05ab64a8e88847dc725b132b627686f4531248ebdd76dc76d42a8b36", + "0xff0198b39d39660cb3c74d455b4019ae0f23fb181378c207bbcb3b79587b8558", + "0xf47db7ef987a8cc32dd3f61b44e6812c940592337c056570d265e1604ef49f4b", + "0xfbf7eeb0951ed5c4704fff2e5d121b831637a86472e32c24a7b85e9daed5e1e5", + "0xdc560bf4b2d849ecb777a4d2d8a3b3bfd12c1a4a295531573fd1d493af34042c", + "0xce32751e3958436d8aa727ab6f89d1354cd0373f288b40395e9105aa905a1713", + "0xdfb4595b9c8bce6108ed0b550f920fd098f6757a3e64734fa97fd5a640c962d8", + "0xfc557009bbfc0b2a47eb486002568e963a32eb664f7a55d81335ef6efa79c804", + "0x9dd310e9b00e69b7d0b0d91db5095065c78bc91f2321df8b5622a490ef940626", + "0xd4ca936ec7acd0d54c6efd71cc6c808573482f2510175ac6251f1cffd7a12ade", + "0x465a05fb5c4c66d0bfa64097c705eccb50bafe9d2ba223ee69111b16c2014c02", + "0x634d4372ed9478b3afaaeb35e316f71cc5d371548260eefe273c236501d5616e", + "0x16ebd07c2e0032fb1c3722df3647e74650b7c1c81f4e7084149a30524846ccf3", + "0x32ee5ef340cf87e26642d11d619eff9ab9e5a1518815b9897b6a95007e2b7572", + "0x47ed528e27c42d8a4100a84957ef81a4784c0272f5e3cb6a68212af492a844fd", + "0xcc376aa2c1b0b49f96bde6390d5ec296fe7d5671d6bb5b5df31cdff2eb5f08f6", + "0xdde8938b019a5e587a28eaf579b5e21892bfc3475ce75112c4f1d9a5ef65dad7", + "0xd0b4c6d8ca3d95851c34e729d9228cfb0f4c4efa7fdcac3d96ea4e4d3e0c0189", + "0xb441266ed512646050c73207c3d88869ccceb7584f3325125a5511d5b05bf5e2", + "0xf05a1a620f1179a6ebe9281fac034638620155bf9260bba7df47d59b54789bd6", + "0xdba9596e7229cee4c339fbd182b0ebd076309e3c8d3653060a94dff252ceca19", + "0x30142242a511348d48171bd65aa191fea095446cefc49967fc7ac88964efb4c9", + "0xed1b743e8baa487193935a6d974a7c417cd42fb761007e5ef168f35486cdc2d2", + "0xfe54e8161aa159b9873dfd4f2d3b7bfd5cc70c4625855b70348684c7a19acdb6", + "0x7993784b62dec4dbdc595450f114290152676cb6938fca76e956968367e34519", + "0x2efca2f1900c2ae1f572342a077afd97fccde2b2305ee0b60fbce8240d6779eb", + "0x99ec617f5f447a4608d5bd96ca375a33a15894270ce22091b60f308298ac51e3", + "0xa38427232204d3f8e58dacb6495799a6c21e60746d26a438d8504dadab3a9bbc", + "0x8c39c623cd06d598ef78e2c46f7506523ab9ae5fba5a7273366ce9a3d9bb977f", + "0x9e15df3655d1a3acc064309382a41e0f7db24925ebf1df51e23e0693d9b119b1", + "0x69b4a6a1cdae2b0f84a18b712286ee304995f6073b6c81fe7ee544ab1d17539f", + "0xe395574bbbc54fbc2e3dc7f363abb34dc760bc2f6fa92c980d26d5c9df5681f5", + "0x1f863b9112535a87fa2e28cecbe0af5c22dbeb41558b93cac0dead527affb06c", + "0x78229983620efa77087391d04057e1971b2ecde2c9f9d959f769e18c1e07a8c5", + "0xcb72a2403046e54d6babc6cb9e2db5f79f09a9c45f983dcf595dae3fece77570", + "0x5267de76947667220d218ec4d1c3db31213d991e59cd0f8e4e547197e4f99205", + "0x55b03de02f92b3210a614f8d0eed98e056a348dce7dc03dc46dec5f7ffa942df", + "0xc2e6b807b1baf078a962a9bf2d92f91c0b326cce0ba6ff59c834b812e55278cb", + "0x94073fbeb062a2fc6f1a0450776b598b1a26aaabb1c1b07e79ba0a816f63ea26", + "0x2521e9b0d16b0129ae594dbea0a2fdc115c379c6c754933ae4dbd20091e8d148", + "0xd2e288fcb68b22fb80e5591bca2524d7a21eef199c3c333a80218a4eb698550c", + "0xc92539e422408c2bbf932556b096d90cea0caeb81e29c2c92552d156c2bf8399", + "0x5ffcc95004131253c4b32e34f7e1db552938b092f7343f501e15554cebe914e4", + "0xea70a44b30ed6d5a7e8e9f85eb8b70aaa05320489054faa40e15989e01ba789e", + "0xcccead6845a28d610af1674a474bd77a5042ce93f682f0c4e879cb0c3e836320", + "0x3ee01f8d3f6948da18f0212ee7c990bdc2ba2eedd020d29461d9d558ac9155c8", + "0xc5aec3935dcbf93026bcd8e24632e405b56ba1ab003cddc169b41372ea6d3a59", + "0x1a9e0622cb0658017749353e3167f38bb1961c4088442f124c1ceee2dab52945", + "0x2628f184beb5baff725a1918ad222900d41a1c3911eca1f272b484fe103ed4d8", + "0x2a03c227d307eb99185eab66ad4fe4b77ac1a0245ec28bf4d87702092461c275", + "0x4664e5b9b20927813f129a23414f319628243cf2ec6d93b0779f0bab5c602803", + "0xdb8978d3303d1c40d51e1608a24102af93c15ef7a82bb3fa8f9a1ffcccf87bf9", + "0xbe63631e76bae0c7eb4ab34abae21f9c827638954578ab93e823d9db8212c08a", + "0xfcb959859a8eed19f6cfabce408e5207206e8e0f96924328355a279f9fe9779a", + "0xc1f2e02c014167d9456a985c669121d543e39a8957aaf328ec1779de2803ee99", + "0x3261a5631dc254f335cfe69cb835f61e11caaf9b0299f0701ebbfd0470755313", + "0x02d30a73d3a7fec6c2567e1f2861113428fae47abcf76167ec432da20515134b", + "0x312e3cc2897aa8eb766bb4d0a91e160884153c90c266d03bb6efed08c4f48cc1", + "0x00f196dae3153faa0b4ce1bb9b3122f76cf1c1398fb43f8aba95037b8a6d797d", + "0x8e4bb4443854630bf0835c3644270462d9b7e8f3fa409e2c8c420010c8dcf0f6", + "0x3ad0e8f5abb1238702bbd95556ac9a9018f4a4ce107bb2d87b7ebc76b0b723ea", + "0x5c78e87df5d32db813c9e89d4934a18490f9ec5e4f2e5e66941db9e6c8dd1129", + "0xac6749f8a149d465b9d98dda8283425ae7e27eacd803baf2babd9254d2da0e97", + "0xf68f70077a1f7d69e5afbc259adbd51fd97cb78e45a38bcd698922ca0f2c17bc", + "0xc6b1279ce5d96648642dfff31d3bf3d989de50143a69dced098f883f2d58ad36", + "0xc4655ffd7482e52531cef2edc1f259f384d69a3920f699f6443e92386a0b63f0", + "0x28ea7302f04d4ff4b2c40fc150908ffc34403d7e5d756be4e980983e08a72db4", + "0x87d6de7a3cfb49ba01d006bfc051c5d22c2671eb67bf3af87291d34bf84dd328", + "0xd156e6fefece7a5613122c24733683863b9a20f7fae1cd022b093c9dfb53b366", + "0x5501015e22d6086647d60e44df262d70d4d8921648bcf366e8442cfd8421e83c", + "0xfe520098dd0cb9422d83d4a562c099bf8445c25e93b3b9a410319f0300b710dd", + "0xbac6ee3d851c6d574004c6645647b2ffa6a3519f13f3ff9529e5924288815a5e", + "0x3fbbb9d0516549cb952f1be5ab6e69d60ef1a8369cfa4d22152d006d886eb604", + "0xbc1843d922c2e0ccd1403a0da02b4f758fad4f02bb09ab823560308826149cf9", + "0x9ec0d3d14623babe08dbba627c2d478ab34a0a0f46984e528499b86755bab02e", + "0x98715273786d911f75085819b301792d241d005934e2d93e8e689c8a5cebc5f0", + "0x0c25dafe9a23ad5d17e97f23782e11152f548c73a0ff58fba9b3a64aa26cfacb", + "0x7a8fc37c03b6ce7d275c2a4160e883787df5010892fd6ffad54dfdd70a97168f", + "0x342816670945437b66e0a12d5eae2d284176a54cee727a5cff6f5fac83845864", + "0x40f472f8737a813a879eb762f085ea5966934e1a4562b212b11612b5fac059f4", + "0x865b00c472ef94d6d9b038f328aeb2eab1e81cbd2da3c4720257c8b4b8b41e76", + "0xe94ee97f38d8989ab6bbd137ed9bad8529c543910e5a328b01fd5571ed63199f", + "0x57ac21373529bdcb22c053797736b9b600737d91ccaf296ea761bdb9d425ed74", + "0x4c56a968ab57aa36196bca9841e308e4ecf366b21891cfeeeb4a7741caf00bdd", + "0x79e087e68abf35a76d839a0792932730441d2f57506fe7db72b9b91b3fbb50d9", + "0xad2df80333074a637b0afdf1dca51759ebb10d7d443adf507f41a99863b2c7ef", + "0xbdc6c77a8ee0b979cfa93d42e4b87c9aee8b0c19e6f19206008a5d1083909478", + "0x369810909434600983003d17fd321e7e73dc4b8ad0e73d925caf499f2b836690", + "0x4d3749a7865675e8a3ecf2b1af4b7c3250a311ca8d20449e71d6d8ffa33a7536", + "0x7286924c10b2db63e61041976ca7c6bd3d6b1ddc69eac4dac03427e0460333fc", + "0x33edb799e39ee239790c7d3a6349218284a61847a235f9b6978accddbb57467c", + "0x0f131efecd5a1deeb5267f4f99e64ad2dc84532f7698802fe500daa8c306c1e6", + "0x96f48183924cca8948eeb08c3c5320aeceaba747c7f7ccc321cf17ec0704ffd6", + "0x87a8c9e79f17968814cc145bdb1325a2b5740cff68f1ef7fc7ae42f20729287a", + "0x3c9d17093214572bfe4e6438528163d7b6e24228dd15ec1986924f07e8b9e197", + "0xe9c033c63af4230d352ee370bcddbcf79a284e113ff5b8f559d5d958a6648f2a", + "0x331c86081b46499c6c0b23304f562afdfa467ae8b390e22718f2abd96dbb6c2f", + "0xf783b03698791d07c2ce40bcd9f69e6f04a4041cecdc85e17b96e6673f57d9d2", + "0xb886c566152b6f0fb43d8eaae97d8f6698caaca12845f63e6b98872d7be91429", + "0x70abce391cbeb52597c5cd3b3668e33aded768c797a1c27d22ef827c3c82e516", + "0x37b6b2d24a95cf8837b6345b7646e48942b1dfc26bbe8a0026715501e56d1d71", + "0x95d0f6f51d5efafcd395e79b83facd5886c4cd68fd725d68305a8bd3e73fa818", + "0x839db36c5e8d539cd87c2fad2221a95728d201e27aa0f21e48c61a4d50088e6e", + "0x85370ab2418ca50bd86694bebf26c9fd59f7b737282375f1a53c06d1aecdacdf", + "0x42270a3434074b79bf19b043bd5cb7a819d5639461edd5eddc24b336fdb39428", + "0x105f93a4dbaef09de92dcb0fde88051d7cc267ed11ee0433c2840ccea459fc81", + "0x2b97bb02b8447cab790dd30d312471385d233b89dd135c0fa59ed763f7f1a5dd", + "0x39d6aebdd41ddb3937963660a188b9e840166fb249c2859cb442588ddaeaa2f8", + "0x635d327dcea329de7bae55e025d4fee8470ffac2ecc8a87cb2a796b822cfbfdc", + "0x53b87772eb46bcb5dc54ee6f2fe0c8ec1384bf13e02057cf2fc551c657a961c9", + "0x9cf06b583c647f8c5e875c6d0cba5ffff00052620c39d49a04095cec4d4c8c51", + "0x917634c039976e153be529547de0799bfb23b733c5edc42e1e54b3e6ebe55d11", + "0x108e5ff2b56ae17fe3dc92203f454fda904dd4e15f4732397fba95f38b632f98", + "0x4bd32df511cab41fdcd3a502704c74f3c7b0eccd352b82b4c3c28b0a844fdff0", + "0xd8e04779971d970f01a77212d1ee2b8926d12194ecfb756f9f83b524c072abfd", + "0x1f0226a32fd46224ee3d9b7424df992847a711660fa1777ee8ec699a255a3046", + "0x9dbdd6b26f1fa61ae7fa8c31bcb259c754e2827d6c6f6e7a604ea84f54770255", + "0xaa59f69dc2ac48f6e2b06cbf95e68ab1d0971ef6ea4274ac4e24263d01a2d0de", + "0x217ab35702c7c959e994c09f9a8bbd939b9711c3a6c4a57d03b02d615561cd13", + "0x8016f4e0ab60e64c8ece505bc77fd8ae9a73e663200615679692057588706ae7", + "0x1ab438e4d7e7ac9e9157c2a43fcd730f7b3bc70676a302784d22dc6e9d7cc1e8", + "0x902a3b829ef54cd702094667296ff452eff0aabd04f76046cc799331da7296b1", + "0x80d14802bae3c50cda30a6830db5122e72f7dcc67544d33857e1153a49bdd710", + "0xaa73faa4c36e080065a0640acfa4cdf16de65fe6aa1b0ed74d20ab01ef675b32", + "0xf129f354afb67cda78b4f05e531e0553b512f8238278a7388a8ea2a26d4fd5fb", + "0x8ac7e8a496a2c3465ce049ed69c0f1a671714369856d705c1037cbd193106dab", + "0x0167c76291a52cd70b1302ef3bca9e8449d071761c1e5520219d70344e0b39c5", + "0x0796256c466d0f1a706462c642813620e7acb3ba0e17b606bd464edd52e0b491", + "0xf9e68a276fb7585b978ccd0a5d4cb07851fab909fe223e1534897574745ac585", + "0x215b53c58f116b3d45669d5257644b866639eede3eebdef04e171d9415247eb7", + "0x69425708be100d1e7402bea70be42a2dc981ff3a4d7c8c5c859283c06d1283c9", + "0xfb0b4c899f6081eb3e2b4bd4d32554c0c34199731d3f80976ac3885cd62ca5d5", + "0xe07304905487800ca8bc3357236b5b4971ccc884612d4c3a0fa903ca4ea399ae", + "0xfc0e4e84ccf10d44f338d76dfd0562cd47db6758dc7f3eb08006dbcd577c5dbd", + "0xd198d19f531de16e174f85a4cf6d3d2d0f326de398f027223f34534c9a6e8634", + "0xf5f6dd24e48fe4b37a5098700dea861fea66c835e81269ec20b911fa821abc8d", + "0x6930e75f5170de31a5cb2f899db422feb51f080f83f49be83951eecb5f913793", + "0x5a8d5ffc0944ebfa1273e0162e766fdb34fada198583876f0931e331ac7164c8", + "0xc6a5ae3002cccdc6bc302c68ce171dd83c385444ab5c04c66b19bf67255e298c", + "0x05c8c483696d2aaf79f985706ff9e84c9ad08defe8399531aa0fb3d32fea316b", + "0xc226d5d5d4df247a1e5cec4fa6fe43605e9ecd27bb07b9c220c4b6ad5a4e70ad", + "0x312cca0e8c4b55bb84176a54926d1366dd5928d9859f1d2ad2991e0fd9624b79", + "0xd0aac977184cfbdf53ee96ffb2e0bbcb85a202b5c6ea02f9989972c70120468c", + "0xdb3b8102d9a9a363174e138b292ca67020f31fc819cb15c5cb9ee34ccf2d2f8f", + "0x1a50ef2cef7ee171832dd9e9162125e51e6ae7c27d08753c30c4a03cc68cd473", + "0x292ef1d673e8441c3850d68ce27faeb572083864ec22f09220cb9f4fe32d560d", + "0x0cd5290d348d7462f747030cbd8a38636f1549023f8f6379c244b91420312ab5", + "0x2a35347668b072eb67d478dfe9146822e77ac78abb4b69cf57478a87c4f5b794", + "0x70d10e3336ea822d3385352737397cdc660ee71e07158fc1ffd711d249daa841", + "0x1f9d182b5e755e9c0ab2f77a9f302b01241c4d235b5b717237b96247a9157141", + "0x93ef750e15a936c2fd6f047e65affabcc2c0b5bdf3cfb160402dd0696329a654", + "0x17c7f10a273615b0f8df2044396e3f0aa33b46ad053bf6ec6dbc32273e66c4b7", + "0xc249c69c4c2d40dd9d0a7fde388824ff734f3b8c2868d1e824a52b32dc05e58c", + "0xc1c1f0f9ff1c472a7e84ae89f8da22575df60fa7f9479fc3638f2f0d02509010", + "0xb563144ab0b85113b0e30109cfbde500c28faafaf922c81939dcf9f1ea469752", + "0x80f88663065d058d2db7e55df1af8035c810e36a6589f4b1989794bb32e337c6", + "0x25905f6b1188bb66393a10ee044c6bc197627d83301f766f4900d36cbdbdf8e3", + "0xb73cbb759230184289722513df452814de312c90f8726e77b129b6e37e5e803f", + "0xff19c1a15bf598da49fc91d04c7401c88b4aab08fa926e467779fb14d8f8002b", + "0x71d46f2c6a4d7291a9906df0beb183d495248599e40c41da6ad30ca3fe37f43c", + "0x5a00726405d2db913571b141053892aa41faf26644c6788c16c8f417df49ede2", + "0xbb046094f514ccd722d224a2bc4b6b473c760224a7b36ba09a21f149cc244e1d", + "0x8b0d483f156f390376c526acc219070a9c393df731b7115753e934af20940621", + "0xead2c2100390e48bf720d19378964dfc1d0071e28c1d799b2d5d529b118290e8", + "0xa4169df4e2f8662b43845598c58a591e6fd17574c0d567d7b702d3f12d4b74e7", + "0xe14c4be058238b81d8025fa71abb580aeaf52d4cc3aa4f05bd5b24be77479fe8", + "0x81e58c707025a640a9b014046559ee7f827142474606ac24ccbd61557b0a7745", + "0xc1717626f785ffd170697d0bd148226d1916f16461796dee609f59ee5eed3423", + "0xdbe52fc3e71b136881136693f3a318d9e3257e6a0384d17768cba6c84b1e3ec3", + "0x7596e35148892b5831e2111a168ea56a59ede2f2222a08f8d82fd235f09cb267", + "0x130fdf1383873279e44ba21c7d1d6f962ab3d71031270a0e5f57f12f90eedcde", + "0x0d52be29476a3b4ec79a432554198255be617f50ddfa6d614ff5b73302c44067", + "0x3f1edff4b943e5fa15bddad5ab9e3248db0335359af255fd6efb66c8b63bce69", + "0xad9909d1fdd9e1de3e6cbca641e42a87e3fa254a0498085790b3e44e6ee42045", + "0xaa166286f4e1799f9ed1033861eb8b2117810d08dcb29cc3f7a3fdcb05989780", + "0x11401b423d204a1df2e918882c3f795e9cd1695ad0badd77532bd2512eb7d1a8", + "0xa738bfb7ad265db50854afc6d8988d5342ba77d7021ad5d5a45efd582b6b6bec", + "0x25051016399b94cef771f16cef661de81bca5f3803c96c602dac42d395679c15", + "0xeec18e2c9d76a98455ea4e50f744926a13b9ac8c6d0f575128787cd134ade901", + "0xaa4a38ed3e461643c1acc765ed8f27262eae8ed1dfd6659c4e4e1ea080f42363", + "0x42760a8066850088424917edca117faf1df6a05221216479aaead8ba11286400", + "0xb3503c3841ccf8bc2853eaa618435036b976c9e77d1e1081a5fceb036091f9d4", + "0xcf5979cabf525d5b6cc1199358688fe0bde640f6ed95dd7c30a6f42a38337cc2", + "0x713df6a565efbb13da4161b545908ac4255af1ce8ab229146ed00954b3c58e4b", + "0x9ff3a78a18a59687eb99e54ac79df1ac920a3361b3b5416dbe95126f8de3074b", + "0xbaa888556f1a519b1b1acd01b4ebcd9132dd55bfec1bef0ffae9408152333fce", + "0x5ced4fedd95a4742ee250948c233f59587eb1624e3adcfb6662f9d81b5517bad", + "0xac1d2706dd82b142b8a629b42ea5c4f13286af59d24f21b3bc36ebdb4eaaeeb6", + "0x1d99ca18dd1d872a4be8ed45385d0898215041f54e7c8e7f3252ca212b4eba3a", + "0x1dc60cc7789fb6b25c3d27868ac49136e09f6bfeb09a20061781ef14cb7c670e", + "0xaec01b8047a0693e78b6ed445396dfe6dea247997ad32747896ba0e30a20d2ea", + "0x977779b6e2da8fde03c1151537d2e03facfd217650e862c3fef07af71f34b507", + "0xa1634dc9c2bdb48762a7bf7b41b74a2e8d4d731b15792044cff1ac3b416fb28b", + "0xc36b6333c28344a360214708798c125adb5e2cf8a2145a216e303186b85a8f91", + "0x1196ee872385c8fea747eba6f5b4fc6f30817714e86c28b657c24593ded2e0ef", + "0x8dc3ccff642a29b46266eee8782b9a9ebcb171ba154c5dca0ca5f73fe24969b0", + "0xa9dbea651bb7a362e526744229b3e1807705ceb492a8e4bc54a9a1f36102a9c3", + "0x0bc82693277412688a6577a6bc95ce99504a1a50904f49b4b4588538f506fbf9", + "0x8df943b0847f1de48f76d6dcaec5cc7b0d7d839ec5e6c8c887f6e5cd785f53cd", + "0x92f4a5577743eb6c34134fa7867cc7d8836fdfd4000abec8cbf1460d136054cc", + "0x047f5f8332e788d1b6be8a3ecbebffa80ad6df670cf4eb4e76a6f22c5781ac14", + "0x392652a55a85300848f43879d9a45d8b7fe5897467743d51a9208b2ac0dc029d", + "0xfa2e6a2cdf4949028be0772f9513169815fa9af20c53ce188680f09f57efa671", + "0x0b86c1c1e683a9e6debddb8ef516b16fb15709b87dcd780ad6cd7f9b9080f4d8", + "0xc8e942935b64b294ff66d4fddc51fc83b0097772bca50140e738d4c034b09cb4", + "0x0b783f8b64650bad1753e4f86fd66b99d7ad03d2da0460bf44965a1f443b70d9", + "0x8a9aa339e78f09ad3d2ffe3999c22684d519219b787ac3cc64c772d1e6508392", + "0xb8a2303cb9d927badda947a962311c699a290545b597f0d242f669392076facf", + "0x34a1bd076dd55dc6eb2e675c5231b3cc8f2a197194c86242c9c5c052a6859d28", + "0x0623254a886ba8bb191d3340e9705ae52e71df2717c6e84bd07a759d1f415d91", + "0x37d451749a48d1cf4780f28360c5445d3b749d8b24f065db07b8df89facab6b9", + "0xd73f2404b935580681cd7f6060b17ff569f7419196e67596f101b6b1d1d913e3", + "0x45029ea3cd0d90900c46df72e6b182bba69ecac1a9289a4719b2f6008f11ffd0", + "0x23315337a4609580ca1835f370575bbe025d2ba5447b61e583119757debfe35a", + "0x581bb3ed8dac28e597d89e9a211bce6b011a4b6dabf001597b68e5e8c6ab7c8f", + "0xb71f91dc1a2eae9ff7e0aacbdcd3d8a77302437ba0e9d327790c5b92c7603ac2", + "0xde661510c4713c64961a0ce9db1eaaecfa509e66446998450178c0afb4f5a670", + "0x9070334bbe9fbda52e42939155c43daa239833ed2d952eaa5eb4d5fa8d56b708", + "0x7dc07b309fa5e188f2e417525e9228b80f84c6c36ac00cd3e49defa0e0146e15", + "0x2e9ecefa3e28f4b31b876e5d9214877ac00be6e7eb65a26990fdd5a2799dec54", + "0x6c4b8dc62fdb63d5da2e1387a50759e82f00f7b3cb9c4306d98fa1a4630e0136", + "0x1244fa807ba8ff8a27b88ea1146c3386e96995ab1d7b0f491efedb89a2400028", + "0x7b18bd023a26e920b03e517b3399304c2d277045d2bc62ea7ca0ff8dff1e453c", + "0xa71afca6a9475974486a698a897c34cd6b5a7dec8023c62bf252f60b3d63c306", + "0x4162c46dcf1961704d020fb0bbee7f9c0ea85f4dfc58d6db2c09f5ef0df543ec", + "0x651d2fdf296254f97528a2f7b2d2395438b1f58ed11f4d1cc076f1fd04912824", + "0xc2705774d530011afebc9430c39aaa28e27962427e46164822bfd6da9948887e", + "0x9c88eb61fae9cc442bb10503b32a439b771f8ed67d626c4980ccb3d53cd24fde", + "0x8f86c85d3df630b1f292217035ede6ab978d9388fb6bfff402419c3de0a8406e", + "0xf8946728a1deb862861627606bbfb887e66d743d47fe03048b9b1799e083c5b3", + "0x023cc1ee86a5dc550b934e28e668e3de2c0a925c9c0dc9fcabec34d33da07a75", + "0xa40e3c2eb6531a40239499165490be2d6a986f356c3e50c4449a81a9ee037df2", + "0xe85b21c59987f25bad5ae1ee09dadf22ab33530cd907ed72819ebade1e2b84f7", + "0x9acd8cc33e4e79adffd4fd50fab9ba6025822f2510b165d547c3bdc037cb7629", + "0xb07c7c23039d83efb37b63873d4c7dabcb4e9265bad35f9a1667114159cbefe9", + "0x3b470afc97f674222850a489a3c845a1c68384c88c03ee3946ceb90924c7554e", + "0x669492bc00a496fcfa5920c9617f74170242d2382c4cd231d22e48e991b12687", + "0x0e4a605fed37c87fe9bb0de8ee63f571785aa3da8767093cda45da51414a38ea", + "0x5a25cabd5470cf246164f60ca6c963a3960550e684ca051958c2f768af92e227", + "0xf6dc542a83245efdddccc4527ce125c5e4409045afb2e57e11941d4d5c21015d", + "0xca22cafbdd6ce48b7cd3700090a5b9ce0dcc267a16e5a6e55df4bcbf681f7e88", + "0x9d89784fcd3cd9a0fe85b82d2329a1561d46026abf132289126d001cd6507bdb", + "0x7fe02ef1e87c7b1294501dcf0fb97fcf5b8f2b131ea00b3559dba67feb7431e1", + "0x0c5870d20c5e086520c1a4fe39d09933da794f49b5e4db186b7fba5f55751334", + "0xa6664e2bafcc0b548a41c272568d2a3ffc0328f64c3f4ac80e3c0dca18253ebe", + "0x539fc6955f7ceb8b9b662534e98512be388ed59e3e3b2fc21226569c3a85f272", + "0x1f4a0c45d47e378f8c0cbe4603e6e8ef3131ca7cbd4a732a4c5a081bab3cb381", + "0x1be1bc472e060fbaeedee56fe03a42cd74afef7321904c64ca7d384ecdf39be2", + "0x3a74f2b96cd47864ee7b113651a176c328c23059e9b8f8bc2111a071895d2bb8", + "0xdc05d7314a2fe10122a1a4f037b96e960ce344202328932e8f069d3801881606", + "0xf5b2462912f2a53b8261d4f63e788289213ca566ca915f59969c79b6698aac80", + "0x8febf165b4673b4762bfc7d1c4f8a82cdc5649065f080bf00e843a0ae3f3dd53", + "0x1ed2f84e593f6356522b0bd4606209b1291518a7ff708d21ad8765572292f3ad", + "0xb7af3b32db199c91881f8b7d23f53376c310cc1cee191cd62a1878a229dbef3b", + "0xd5711bb07409bb27c5fb8164cb2860c0d6583e5f5f5882c6e6e74b0cfca540a0", + "0xa8d7cc512c42b6028121f6114b974163f687ac19a5c71b1c25789a7ba8f38236", + "0x72f3aa7c612ff18149497e90fdc03e766686e37209573a3e5bf144a9a010192e", + "0x6950075793f3170d754bc05fdb31856d6d15fa389281c7e4f73d8c597b1aa4da", + "0x34f1a8805f65b0a09f1e5523a53d35cfc12dfdecc22e47efc80ce209d40dd514", + "0xc348d949ce4bd0299853e6d616dc292a8d33485ad93924f7b9ce64666594a44a", + "0x0f828822e7a2250d0b8f2b819ff27631f5d50a3168874ba1c1922babce345fe5", + "0x92c5275a7bb840f9ea612340bca5275dee489cc7e2b13e6037ed49b3606ec01e", + "0x29e227f64c8446f49611f9d2dbe04b8328b8165193b5a0a2ad8c337e60d7ae74", + "0x4032647c4576c6e4f23dcf87377e7a403ccccb4785e276d404bc8e6fd66aebf4", + "0x971070530b371733bf83599364270fde641d64155807d36c8ec79e73e3c990ac", + "0x52d8cb01d3999e01141667df6f11143754e7cdc1b12f5b5bbe5e16f51af1acce", + "0xdd821e13bef48af8e79041e7a5e28db421502e98aa41382d2a89480dadd0e7e5", + "0xa785dea19433b90dac8703f0b075df9d3c91394826e6b8b89abd806f5cec6ce0", + "0xe82804babcdbf1af8f6fac1dd0076550928c372d0a9dda8c0560a6f378e2c970", + "0x1dd41ff3d620b1ae3725debcb26edec36cc219292bf651fe9305a0fd08523042", + "0x9e2d84e8a10b32fae0b29b150f747041b8eed743d2e3026991c31c607839ba09", + "0x79ca039f12ab21e7ecb6d6629a501515d94a56a3c24d669474624603a0ed0c90", + "0x7cd387f75eadccb5aea925124377d09be0e7b4a9af6463dd649213c5af521236", + "0x31fa2bb5eb784c0dcbdeedc7d439704bd44294ec2bb1b4f49e6bf508381ed521", + "0xd0772b6dccbe61b5b2cbec0a95a9542fb9b89e9a75b8324e05855039c2914dcc", + "0xddcb84f63b7469935bd4f6ec405ecd619a5539c89c2cd28250065ba9b4984838", + "0xd866486a928c2a69b054339b5e57bde41149c63e6e16c066046e3fe8018cba2b", + "0x7246af9a036f7b773bff1b2f9b388618402738e6bcd03c354816c507aa7fdebe", + "0xd16bd03e80088d51f007a7068697e19cc91a0daa96816ab336135b0e1bda7e1a", + "0x3571d1fe22f56864df7584f73958b5cf9336b6afe6702cc4ec9d1f097c4fc58d", + "0x74e19b61d2a511e2b067662bb61bf93241bf538d74face662561a5d170c8c2ad", + "0x01720ba8bf55fe1caac98a1cc5843f24a1376bbd08cf630c9a39fe219ec31b68", + "0xe2d0a0e01f6557e5ea96808c0cdb7618d36bb5bdbbd1d9e2fbffc07672a120cd", + "0x0ff2e856f17849a4349c70aa6fe2c04d7fffcc6e41860774210c2c2a0208f2c0", + "0xfbe09f759660388a823894be477df3491bb6c51ef7df038dbf12ab9c122b358f", + "0x9e610db00a109f0b4a4cbb094b88680f62dfe5d3526bc83377645cfcf6c03b18", + "0xe7460e14d9b5365c3b1306eaca86ffe4f996f07909c16bfbd731443d91df1931", + "0xe7c05451729b5eb5b61a3f159d522424fefa1b30f3929366289a89b714f59609", + "0x28055b2961079028d017758cd43b12e4046fca9a1ef53e09c3a4e0da3f8ff197", + "0xac65523c531d9ca6551cb6b9336d1e78671c7aeee7208f30548b3c010d79b15a", + "0x3c6939d2ef02c1c6e9aaf6aa1119fd4fa2682b71d5b010708a59144641b794ae", + "0x40cc42a031994649aa861a544d6fb7c02aabd574a5b14d26e7802d5cf2574e36", + "0x054cfeb8044d5dffd1577bf0e45dcdc53d15c308cadcc4d022d3c0dbc292efc2", + "0x337dd5519a0f33011f3d27da8e1d2cf43dc249597f199d5388cefa6200e9e3b6", + "0x3263b6e7d5c31f7873fe32542124bf2b11ce9520c629bc8b277e1dc9152717cf", + "0xce5e58922cf860beff17177cea7aa6c0e789233ba1b15cfaab6896c45dab7e3e", + "0x7b5bd2a6e19812524fc1c1c9c6ee8b970ddc3684b4a5bc3fe865dc28726032f3", + "0xbb76c2c12be46fb4a8d18e15817f9e77547acea67f71cd3bf0f13ebcf674080c", + "0x300838c866e4c8ec4e7d130a3191f3122795c26757ebeac2d51eb69f19319624", + "0x53b73eb4f155c5f126802db8f2a64ba08d93972743f3308454be1c0c68c7f4e5", + "0x4e0de18b8bb30adcd9770ee1cab2e0fb45225737e382b4376b08d4e64fab577e", + "0x3a6ca6bdeee957b6ed7297760bbcf53bc5b9945ef1fecfe8c9dbc077926d519a", + "0x014dea0c5dfe7db3b67349ebed21bae42f40f02857456827c72ace435b6b8632", + "0xa0b1b3f7f3883d34cb1ee9789c36b607ada517c526eea23193a786d72196ee1d", + "0x2bc8ee35c612ac2a9c9e5b97d6d3b9c458f7d8825c89c2d593faba38ca116357", + "0x6d61cf0212c61b9c608d7b0a5b2395e9ff41a815f429ed05abecfe350fa5c22b", + "0xcd284b589d6f3ea56a8eac1f7e17d4932c809ebe955300c3b1da554f7d0998cc", + "0x56b3afb245b853cb2cd2a9e6b938819db181b7541003fc298347b646cd0bd894", + "0xe24a047cf216f0837c52bfaccbcf4810026bc374618465d94480d5d222c37ec4", + "0x5e80313f3a14f41e63ae80192b79456d742e0a43d89e505d938e5d0b164a2b6c", + "0xcacdae3d23fd91db005624bd007f1f0c9bc48ee212e6ca2aab8b189b687b9f0d", + "0x2a0f603aeadf258feaf46805767fd42a61ccc3f031f42f131c4548875a887ba5", + "0xf90ac12554e9929db35620b33a5b61cef0cea7209a83f9ab44937dddb4c96bb3", + "0x1a4eb8628a48f763284900ffbd01107879f41c9479bc76c139db520d34295fc4", + "0xe0b600503c7f112ccc29a447ccd1c85285a304b403aaf0d227b3a7c7ffa4d9b8", + "0x1ecc791b207e1d79e10a9252fcb35591b0cabf71910eb50bde734ff7a364945c", + "0x7dc509f4b620ccc2de77ee7064b910a831a577008b8f099b76c2c9382c4ab31a", + "0xe94bf1b965b4a10ea548653cfccc63720c9945b3f02785b650c9ed26047855c6", + "0x19001b2e4a67c28e925ee2656aa6b8918c3b6d785101f4810ac9ba46cbd80d0a", + "0x717a34a0113fba177f11307a4b06f467fe4bff06f1bb38fea0c272ccd9256db6", + "0x1f8815eb7335b0a2b0b4d0cabc9f9fd97ec2fca78a69fe7c048ca540cdd303e3", + "0x56897445682734394c0e6923826b78222719c51dc288529d2ad2ffede4649f34", + "0x3c059f0c0e1809877da2fc06b1384e1ab651dee6b373980b0c5c64da57dc137e", + "0x7a0a2968b2b0458e653fda06a611c892ea1983ca852e31d916415244f06142a7", + "0x4711f167a6332b0dcd27e4530a498d2d5585dbad9b6a5d5e71d4dd07ad57adce", + "0xbdc064506c9f16e3a9607e7864ad1b4471c1fc9e0be5f98aefc5a330a33ba805", + "0x16d54ff57301af6239313e4b98e163d1a23ce6a0aa82d08e989edd31b24ba999", + "0x225a99bdb550da94a9a4717ae178f7def59f799ef36fe9d392a31a344ef6fe4a", + "0x3e502698ef85c6246dd7040f311f277f705bc028644a873df537b80b98d1fea1", + "0xe6969b55177b17b69d45c8e569fa83d00a75723ce5ba8a4b5ca67202ac5c353c", + "0x4358581c44a2caf58f64b86802c3729cf77f2b14df54c18ceac805b219440b0e", + "0xab33a0104b936b5e1be1e9d197619872eda67745ecd61f864149ff6932acfc3c", + "0x9da92be95e0f0d0e284bd8d2d3ee01b53b60482878b1434726df51e270fdf603", + "0x9543a4c4fcbe9d86084fc4b9431cfb8124919413c03f83e8666f2ec6376f0982", + "0x7ede3504ac4981e29634f703ac85e69ab389df3ee6f6ae62f6721b500fdddd20", + "0xe2ccb0b4c4114f266c9cbb387d255ee86971496aecfb57bd98f7ff1808384e06", + "0x971d50027dcde0cc2443d898438b181c772699bc7d4ed5d501258c4a8ba32de7", + "0x449ebd55963c7777e5d5523521810f69a5d4bcd6b20f558a2a5f904646dea0a0", + "0x5379acbafaa3c16ee514482e0497d4f3938399788f207adc9a77312c11d4aeb9", + "0x704ed53672d490277a0fe111fcd7790cd2fb53d94ef9d65196e315d788e38f60", + "0xfb0ff7818c21bd9883af9e04f5a2b9e5bb43173c8f791972d410d302b5dbf674", + "0x80a5bdb23c110c6acf90e6efc194eabf88d054cf1f27588ca77fbec650878544", + "0xdecf2911a31b325760b1df7fc9d9df80f28a6bca798f5503b2f73f93a4404a38", + "0x5bf29b9b96265b010a33a4bc05967edfac53c6fb3e8a8000d8c60fa869a8e8f0", + "0x24e0a4762cac65712ea029233970aded11c859dc4a5abf9c673664c35078ac1f", + "0x68327c02f690d8edd22330efefdb6233e2c8bbcb0c0ec4905694b1833adec387", + "0xbef7609a716a8d2623ead6eb31daebfbd9421816c467a4f80d027ba7dc1902cd", + "0xed29b3bc58c2dac4b2874e34dcbb83e32fff33b28437260d17edefa4ea1cbdbd", + "0x1c11469afb27568d93adc3d9af95075530067a6411b06431016efc05b021e6c3", + "0x1c1b432281eaea836c78fc78edc7ba02b3a5d6451a13c556fb46b682b02504c6", + "0xeebaab0904bfa1331f72dbc02e73b05303b4a71f2bea6b8e1b9855dd9b2d67d0", + "0xad36e72940ba9dfab81721c33d05bad5b412c774026a76ca0caaa8c6819e2f4d", + "0x5101be8446b66c40c7c375a663001070c6aaac7ccb559bc088e773f3370e8d97", + "0x3be827089ad34a73b9f6f8bbe1c7c414cdbcafc6573f6d987c3fe3e39f8fc043", + "0x16d5eca9c07ad9a133cf54c455d27030121482a1db142988d71770d083090dd5", + "0x4c2f8374663d94c4677d199b463f16916d307430ca39d36650be11e8dfe39c91", + "0xc26e2080ec735af4b67f9058e2289477ad970625d2e8cd7c4724d3844ee68936", + "0x49b9428a3cfb02fab5ecd3b603a68df495e36219f5c5a7335237137c9855c70f", + "0x55a4f76f8dc95a2a84666954727057845eb0ecf6ee456295739255c8fef23b81", + "0xe2efe0ae812195d68c6f8f846ad0fb90240984a444a2b2b5ba1096e8d299c96c", + "0x585d1f644a9802cb9a742d373a711616ff5ab0f3ba0a5f685d3dea11b041d289", + "0xaf87cda7cde3ff36e1a4a0a3a90e42052a72983f21331d78aba1e4c681eeb591", + "0x4f2cc01d0e07e9634505030847ed039ddbe4138ea4b2425e7b24188043b6fdfe", + "0x13a10286bc58803a4dbbd59c59dbf3c9ebb605d4ed0417a525fe30575331f4cd", + "0x9b54f33798b2d69512c527b1e92017351ea98f7edd956a1744d7ae00acdd096e", + "0xd5d636fd588c85c54d6f797ffa674e526caf5dab6e4e87f26c70c4462eef6c8c", + "0x47a182d7f196f6cd6f8b8818a9be457ce06fe8b93ef53c5669c756b23a07c5f1", + "0x2cebac7f3796b470e9c75693b1a8596bdbd2a89de862ab60ece1957d7b5383f3", + "0x7ce7e3078c683ec1573b2cd41b0b5fc62c28af48a23454b177699fec9ab322de", + "0x7d4f2be3a45bad9abc61edcbba9d86234f0460145e358dc6566ef623c50b91f2", + "0xfdaba3ce59b5e7ccd1f4a9e84bdd5feeb2b135603ffa49b86a7ce89eac635ce6", + "0x8c72f673640ed0564c3de1280414dabeb89cfe0ce6f49ebb81c3d7f0b1e6d55a", + "0xacacfcbe5ae3d3a9d1b3886bf8ec26bff6f84a23ae5dae8820ea138edb974c3b", + "0x3f2339582dc6834395622db187e6798edbcbe2f2e8458c2216779c1bb14d45dc", + "0x73a444fa697c736d392cd6d2b347d98734f5329d5910520419f391a443fdbd44", + "0xe03bb06673dd6d6e82f2d21c71053e62d3b1dd649d5e7a38150b83b0f085a473", + "0xc68461b94228db05a62a234ad0569aefbf31fa59fdba3d144c3a619d05fea871", + "0xb44575ebdc05026549326e837692dd60253155f001c7fa6f789568b7a136e8db", + "0xad0159409b99c1dead470cd92b3a9d4bfe25266d7400595c93f9276d8d580312", + "0x545c4abba819ad9a1d719991a5a0ca289932466fbc62471250e6c9148727a02e", + "0x5fa8b86faf4cec2e9de78f071822dc0af0198fcec23e1693e35ebb765d97d12c", + "0x2159886570715c7aa819fafea2166c045832707f76958fe456cf7af5ce8d73b6", + "0xff22db024b0e036d81383646db787cb0b1aeb713dc3387b788fd43a283a4a27c", + "0x7f229da8a815b51cdeb7b3662b7c902238b540ded6f224ce5568514032832ec3", + "0xa5e57b07a872a68d2cf2ee6fe73baeffdd4b5c3a423d2a819e67dd73dd36fb83", + "0xf0ad72ee27fb47af398972ea5ee5d07ff21091a0ee610a015da1f677ac04beeb", + "0xdbca73f967cd079e0c863e9be4194acfd63857fa71ab93c3d4c44dec0f88f9f8", + "0x29f4dafd87f712ebbe677193aa86ac807dc933cf0ab895c95feb8c19a46a78c8", + "0xef79cedefe4aab625ea24882c8e5493ac4540ddfa7ec8ac72d06d6c264a2a43f", + "0x377ad1711a2818e94eff19e349d34a5a7c0eaf3ad514b918efa58d48980f8dc7", + "0xca40524371fd62f82dfc73b74acd6f103bad8e81c22dcfe2c3b56d0941a2bf03", + "0x14f6e3daa8495585abf5030e856f742b63e2c3b8fab950fbcf61438d203b3481", + "0xfab710e7caecd295113ae04e2da94fd089d0cf2ed1bb804fc961bbda414fc78a", + "0x6a4ea10fee2a5029011fe25fc6788d1ffd6cdaeca4105b146745883ca457f7f2", + "0x3d16f801b58a8a0362178a2de3667967ac8e8e5600dec667098c56534e95c51e", + "0xe6b91400dbbe1279d8001c9ebbb951b85ae815e0812b3d706a257fd7cafc72a9", + "0x833f7223f1f9c216001b67fc3c5869c012ac7bdadf07a750bf5d504b8da9dac8", + "0x1dadfa642e018d46c90e4c9b45e7d22f964c713c829f28e7dd94456efb5ba769", + "0x9b0b0f0f9255c2ff2b0c0d9b70baea541997a2981b3e1cec904420c02c8e68f9", + "0x0ab920eab62b4a0fa9751d42b4656be510a8724337fe0adf54224cfea0b0e3b9", + "0x1669cc89308825fbcf62478c1d6d4a979d730bde70c1512afc0926e0d4e23929", + "0x66b011d44e8e971ad3063722cf5d6238c519d57c0a94c760e5c307a3158e4161", + "0x0a4ac475f2b54e24784b10b18df0086a92c407e2474479357baccd46086ea81c", + "0x988a166c64baeb21ff5ade5d2c563ef93ad0452c67015a1c472b2fc14944fcb7", + "0xac583c02f23326514085d3b816973c5907541f1efdb31373b399a67807ad1322", + "0x51d7e2b08d025386fb4b335b0d0e2d07f55b9208fff10d3a362832dc6a7547e0", + "0x6c4e553f3ce7b7c80cbce8d3c107cdcb8a7b4c89ebca8f1057e526552f1c979c", + "0x870d63c54b37873abfc8b0c8cc7bfa2b41261f77550251ab59a8f304417dbcd5", + "0x6db3c454f0583e94ba43aeca2c4ef413f80555eaef5829b1c4c1708d63d3b4e6", + "0x6cc1ddaf69d050d9b492d559de84c69232e43b7607cb6807933b1801cb4beea4", + "0xc7c0aa117b17ceef132579c731956b015ebaf3e802b85ee0a6c825f124a4451e", + "0x8bf5ba7ba1184ca6aa5f6915e418e455bb096403d43746ade9b5895fa8d0e69a", + "0x13bb12782984d634332842ce7b72a981a17bdd34ee6acd9adbf65844b96d7b48", + "0x88a59590e8e1366ec65ddf718dedbb5540a06317613a7dbe130c4a570f7f2963", + "0x8a89daffb49834fc7f2341d00151f952ef7d1a7299ab92b3fc926e442d9dad74", + "0x78afc35edc10009ad9fa1b51bb7774a48d7e53a960ebdd8818e51899fd8f5cc5", + "0x0e25764281bb700a43644ed3455c279969b80f5c537f4096934413a7904863a0", + "0xdad129d76c4fe2fc61c1af14ed7556321989efaef6824aee0436216504a36e1a", + "0x9e4fc1c9dea1e18cc4147cfc52cab7eaa90930a2b393a442238a8c5378cd4274", + "0x08c8c7dc91c967fdb900953d543b4975ec90b8def04eadcf7885c555c782ba5f", + "0x07d599a0c521f72463b80cbb534bf4dc605bf345dc1c5de1db13b55486d382d7", + "0x420c5f035c465ba9127bc832eb0f757814a6769dd9fce22b28f4a3a3e9cdfd33", + "0x2dc76172b77b50b249a5a5b9d5e23595b3310aff6199d7335eb94881d8d24906", + "0xd2fbcd5e757bd9eec8698e53088491d63b36854d315d278d1a2bd81988485077", + "0x3544b07abaf58fa8c4aa0dd1f0060c11e0de7cc1ed04b18f5f90cc196d3c99b3", + "0xe238c7374ba22d723699269c9c943eba814aa1afdb95d5e00707b3cac06a5f2a", + "0x1cfadf02760942304c47e07d07a7acbdfe7417c62d330b5802f598a7f550863f", + "0x65ad9de6d69c6e80c1cabd34f49c4c9d74b5986ecdf2e3bac30833a599cb792c", + "0x27f8b2a3a019abec3e4487fb353bd9ec0ac11a160c6c3a83df6ca959d404aa6d", + "0x6c814f0081795e7cdcf730b0807a3c91c7c656132d0d9ec2d9e39f1bb8f57526", + "0xec686e5d76bb74cc369ce26db62b742235bcf6ad7e7c5ef6872d62c45bdfd5d7", + "0x09941fefe99a62e910b1a0ab5751c36eef7d21b1740f2b9e25d814af27169649", + "0xc0cf4f22b4e05e192421baa0af9c888bd976239e70046a62cfb5b018d9205378", + "0x6c45ab7adedfa0a6a133d288a7b8ba2d213fce73124d78b0fa12e1360d930714", + "0x85872e50c368df9ce35b61d5363ce8db27f123661ae528334c6424a953197d00", + "0x6869696612636971deda05c67f663242977351aaaea43d9cdb718be5948f080b", + "0x291097a53461b3ec1740b0b61c129d827f0cf731e16defcfede2d7a544bf52f2", + "0x438259d8150e73fc0d2ec553a2143e1fa5d3e53e27b0533ca20ab37991050b4b", + "0xb1889369c5a7f3385258a7d63dcbe5b05ae2e2ff4ff1e5cf82e5b582a02e895b", + "0x3b03ee5f95e9588caaf54878d8b6c746dbeea3e695bf768651fd3c8e3255cade", + "0x60443bf8bbbec8f21d35a3d16c5cdafec1dd3bdf4b9c447bbeda74fd92655efd", + "0x61bbd3649fd7f9bdab23d6693135ec6dcf07adf1560d9bda68cbc97ae4917b42", + "0xc019e34634d76e06d2984f7201c445cf6fa3f72f3164c148de2b1827eed0b6b9", + "0x3031e3e27af9bcca0902254143e3a440d40dfed6bd69ee5095387347559fd231", + "0x6600ccda7d374610e0c8d0b7fb012bf5cb59966aa0d93f65850db3c6e4544bab", + "0x8e692bc730330a2f4bacebaae77983a1831372e64fb9578d42701a305f972ddf", + "0xb504ec0ea7de6f102f2b59f698d9f7a63893fa352fbe7d17bf05f9c0e0c7c0ea", + "0x8e8d3763f75dfb8c07fc5f609bd6becf34b6a19cadcf52a593cca1098bb2e56e", + "0xa30d9cca760ef7f64b647573f17adefe0da9694567c0948c677024388ff51617", + "0x61a0157d34d3474a167146c9dee2870b409cd9f96c9d2e530764a296b3b33d0d", + "0x625183a74036771889d7177b16cb7bc6982b1a68814c5140b4a31157ff953a2b", + "0x9c1fe65834f3733fef1fc14c47fbcbb270c01384975490ec7a483b5a29ab6a7d", + "0xf334351dae09bcd536fcf96d031457d0c1158d422adb8980b194da88670ffcbb", + "0xa9a92557684b04bfda34805c6588e1cb9fa44d7c73803c28a12a4cce0e46d222", + "0x9e5c9a5df1dfb47ea6cf46f0421492ed1613039789ab91d237ce65a1ef6826ec", + "0xc3fe546f606cee75b2c28ad343ae67da95b99b507742aa1814fcf472a8874bed", + "0x73a429e5ad90697799123575999fa28922436600934689457b0b5ae787e3aa20", + "0xbd8ce8cb98c7f263a6b8cb909b671782cb57ee111180f565c988bd97c9369ce1", + "0x45a0254dd0944f5419fa6a658a124de3a8fdf53dd799d2ff71fb1256b6648273", + "0x598cba26ab789de29b9043f53d02872d6fa2fc86df238d54786b14e4ad8bcbe9" ] }, "nodes": [