From e9259652d51349f3925122979bd7bec25e419d3b Mon Sep 17 00:00:00 2001 From: David Palm Date: Tue, 15 May 2018 08:47:02 +0200 Subject: [PATCH] Use rlp from crates Move the rlp out of tree and use the crate from crates.io. Part of issue #8620. --- Cargo.lock | 56 ++-- Cargo.toml | 2 +- ethcore/Cargo.toml | 2 +- ethcore/light/Cargo.toml | 2 +- ethcore/private-tx/Cargo.toml | 2 +- ethcore/sync/Cargo.toml | 2 +- ethcore/transaction/Cargo.toml | 2 +- ethcore/types/Cargo.toml | 2 +- ethcore/vm/Cargo.toml | 2 +- ipfs/Cargo.toml | 2 +- local-store/Cargo.toml | 2 +- miner/Cargo.toml | 2 +- rpc/Cargo.toml | 2 +- util/error/Cargo.toml | 2 +- util/journaldb/Cargo.toml | 2 +- util/memorydb/Cargo.toml | 2 +- util/network-devp2p/Cargo.toml | 2 +- util/network/Cargo.toml | 2 +- util/patricia_trie/Cargo.toml | 2 +- util/rlp/Cargo.toml | 13 - util/rlp/LICENSE-APACHE2 | 201 --------------- util/rlp/LICENSE-MIT | 19 -- util/rlp/README.md | 8 - util/rlp/benches/rlp.rs | 103 -------- util/rlp/license-header | 7 - util/rlp/src/error.rs | 49 ---- util/rlp/src/impls.rs | 285 --------------------- util/rlp/src/lib.rs | 101 -------- util/rlp/src/rlpin.rs | 406 ----------------------------- util/rlp/src/stream.rs | 382 --------------------------- util/rlp/src/traits.rs | 30 --- util/rlp/tests/tests.rs | 426 ------------------------------- util/rlp_compress/Cargo.toml | 2 +- util/rlp_derive/Cargo.toml | 2 +- util/trie-standardmap/Cargo.toml | 2 +- util/triehash/Cargo.toml | 2 +- util/version/Cargo.toml | 2 +- whisper/Cargo.toml | 2 +- 38 files changed, 53 insertions(+), 2081 deletions(-) delete mode 100644 util/rlp/Cargo.toml delete mode 100644 util/rlp/LICENSE-APACHE2 delete mode 100644 util/rlp/LICENSE-MIT delete mode 100644 util/rlp/README.md delete mode 100644 util/rlp/benches/rlp.rs delete mode 100644 util/rlp/license-header delete mode 100644 util/rlp/src/error.rs delete mode 100644 util/rlp/src/impls.rs delete mode 100644 util/rlp/src/lib.rs delete mode 100644 util/rlp/src/rlpin.rs delete mode 100644 util/rlp/src/stream.rs delete mode 100644 util/rlp/src/traits.rs delete mode 100644 util/rlp/tests/tests.rs diff --git a/Cargo.lock b/Cargo.lock index b4d6bd315f2..cb431367443 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -252,7 +252,7 @@ dependencies = [ "ethjson 0.1.0", "heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "keccak-hash 0.1.0", - "rlp 0.2.1", + "rlp 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "rlp_derive 0.1.0", "rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -558,7 +558,7 @@ dependencies = [ "patricia-trie 0.1.0", "rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "rayon 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rlp 0.2.1", + "rlp 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "rlp_compress 0.1.0", "rlp_derive 0.1.0", "rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -643,7 +643,7 @@ dependencies = [ "patricia-trie 0.1.0", "plain_hasher 0.1.0", "rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "rlp 0.2.1", + "rlp 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "rlp_derive 0.1.0", "serde 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", @@ -692,7 +692,7 @@ dependencies = [ "parking_lot 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)", "price-info 1.12.0", "rayon 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rlp 0.2.1", + "rlp 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "trace-time 0.1.0", "transaction-pool 1.12.0", @@ -709,7 +709,7 @@ dependencies = [ "ethereum-types 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "ethkey 0.3.0", "ipnetwork 0.12.7 (registry+https://github.com/rust-lang/crates.io-index)", - "rlp 0.2.1", + "rlp 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "snappy 0.1.0 (git+https://github.com/paritytech/rust-snappy)", ] @@ -737,7 +737,7 @@ dependencies = [ "parking_lot 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)", "path 0.1.0", "rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "rlp 0.2.1", + "rlp 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "rust-crypto 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", @@ -774,7 +774,7 @@ dependencies = [ "parking_lot 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)", "patricia-trie 0.1.0", "rand 0.3.20 (registry+https://github.com/rust-lang/crates.io-index)", - "rlp 0.2.1", + "rlp 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "rlp_derive 0.1.0", "rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", @@ -883,7 +883,7 @@ dependencies = [ "parking_lot 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)", "plain_hasher 0.1.0", "rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "rlp 0.2.1", + "rlp 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -901,7 +901,7 @@ dependencies = [ "evm 0.1.0", "heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "keccak-hash 0.1.0", - "rlp 0.2.1", + "rlp 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "unexpected 0.1.0", ] @@ -1352,7 +1352,7 @@ dependencies = [ "memorydb 0.1.1", "parking_lot 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)", "plain_hasher 0.1.0", - "rlp 0.2.1", + "rlp 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "util-error 0.1.0", ] @@ -1650,7 +1650,7 @@ dependencies = [ "heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "keccak-hash 0.1.0", "plain_hasher 0.1.0", - "rlp 0.2.1", + "rlp 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1866,7 +1866,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "num-integer 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.3.20 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2013,7 +2013,7 @@ dependencies = [ "pretty_assertions 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "regex 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", "registrar 0.0.1", - "rlp 0.2.1", + "rlp 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "rpassword 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "rpc-cli 1.4.0", "rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2137,7 +2137,7 @@ dependencies = [ "jsonrpc-core 8.0.1 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.11)", "jsonrpc-http-server 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.11)", "multihash 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rlp 0.2.1", + "rlp 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "unicase 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2152,7 +2152,7 @@ dependencies = [ "kvdb 0.1.0", "kvdb-memorydb 0.1.0", "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", - "rlp 0.2.1", + "rlp 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2222,7 +2222,7 @@ dependencies = [ "patricia-trie 0.1.0", "pretty_assertions 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "rlp 0.2.1", + "rlp 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2351,7 +2351,7 @@ name = "parity-version" version = "1.12.0" dependencies = [ "ethcore-bytes 0.1.0", - "rlp 0.2.1", + "rlp 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "target_info 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "toml 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2387,7 +2387,7 @@ dependencies = [ "ordered-float 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "rlp 0.2.1", + "rlp 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2444,7 +2444,7 @@ dependencies = [ "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", "memorydb 0.1.1", "rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "rlp 0.2.1", + "rlp 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "trie-standardmap 0.1.0", "triehash 0.1.0", ] @@ -2762,7 +2762,8 @@ dependencies = [ [[package]] name = "rlp" -version = "0.2.1" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "byteorder 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "elastic-array 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2776,7 +2777,7 @@ version = "0.1.0" dependencies = [ "elastic-array 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rlp 0.2.1", + "rlp 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2784,7 +2785,7 @@ name = "rlp_derive" version = "0.1.0" dependencies = [ "quote 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rlp 0.2.1", + "rlp 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "syn 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2974,7 +2975,7 @@ name = "shell32-sys" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -3473,7 +3474,7 @@ dependencies = [ "ethcore-bytes 0.1.0", "ethereum-types 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "keccak-hash 0.1.0", - "rlp 0.2.1", + "rlp 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3483,7 +3484,7 @@ dependencies = [ "elastic-array 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", "ethereum-types 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "keccak-hash 0.1.0", - "rlp 0.2.1", + "rlp 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "trie-standardmap 0.1.0", ] @@ -3598,7 +3599,7 @@ dependencies = [ "error-chain 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "ethereum-types 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "kvdb 0.1.0", - "rlp 0.2.1", + "rlp 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -3633,7 +3634,7 @@ dependencies = [ "keccak-hash 0.1.0", "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", "patricia-trie 0.1.0", - "rlp 0.2.1", + "rlp 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3973,6 +3974,7 @@ dependencies = [ "checksum regex-syntax 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ad890a5eef7953f55427c50575c680c42841653abd2b028b68cd223d157f62db" "checksum relay 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1576e382688d7e9deecea24417e350d3062d97e32e45d70b1cde65994ff1489a" "checksum ring 0.12.1 (git+https://github.com/paritytech/ring)" = "" +"checksum rlp 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "89db7f8dfdd5eb7ab3ac3ece7a07fd273a680b4b224cb231181280e8996f9f0b" "checksum rocksdb 0.4.5 (git+https://github.com/paritytech/rust-rocksdb)" = "" "checksum rocksdb-sys 0.3.0 (git+https://github.com/paritytech/rust-rocksdb)" = "" "checksum rpassword 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b273c91bd242ca03ad6d71c143b6f17a48790e61f21a6c78568fa2b6774a24a4" diff --git a/Cargo.toml b/Cargo.toml index de1a78bf4fa..727bdbe929c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -46,7 +46,7 @@ ethereum-types = "0.3" node-filter = { path = "ethcore/node_filter" } ethkey = { path = "ethkey" } node-health = { path = "dapps/node-health" } -rlp = { path = "util/rlp" } +rlp= "0.2.2" rpc-cli = { path = "rpc_cli" } parity-hash-fetch = { path = "hash-fetch" } parity-ipfs-api = { path = "ipfs" } diff --git a/ethcore/Cargo.toml b/ethcore/Cargo.toml index 71c84a293f9..8c16c1ef94c 100644 --- a/ethcore/Cargo.toml +++ b/ethcore/Cargo.toml @@ -48,7 +48,7 @@ parity-machine = { path = "../machine" } parking_lot = "0.5" rayon = "1.0" rand = "0.4" -rlp = { path = "../util/rlp" } +rlp= "0.2.2" rlp_compress = { path = "../util/rlp_compress" } rlp_derive = { path = "../util/rlp_derive" } kvdb = { path = "../util/kvdb" } diff --git a/ethcore/light/Cargo.toml b/ethcore/light/Cargo.toml index 3853ad910ff..f4aa2321e4e 100644 --- a/ethcore/light/Cargo.toml +++ b/ethcore/light/Cargo.toml @@ -20,7 +20,7 @@ hashdb = { path = "../../util/hashdb" } heapsize = "0.4" vm = { path = "../vm" } plain_hasher = { path = "../../util/plain_hasher" } -rlp = { path = "../../util/rlp" } +rlp= "0.2.2" rlp_derive = { path = "../../util/rlp_derive" } smallvec = "0.4" futures = "0.1" diff --git a/ethcore/private-tx/Cargo.toml b/ethcore/private-tx/Cargo.toml index 0fa11aec84b..4048022fee1 100644 --- a/ethcore/private-tx/Cargo.toml +++ b/ethcore/private-tx/Cargo.toml @@ -27,7 +27,7 @@ log = "0.3" parking_lot = "0.5" patricia-trie = { path = "../../util/patricia_trie" } rand = "0.3" -rlp = { path = "../../util/rlp" } +rlp= "0.2.2" rlp_derive = { path = "../../util/rlp_derive" } rustc-hex = "1.0" serde = "1.0" diff --git a/ethcore/sync/Cargo.toml b/ethcore/sync/Cargo.toml index cf163cc7bd5..e52092cbd04 100644 --- a/ethcore/sync/Cargo.toml +++ b/ethcore/sync/Cargo.toml @@ -17,7 +17,7 @@ ethcore-transaction = { path = "../transaction" } ethcore = { path = ".." } ethereum-types = "0.3" plain_hasher = { path = "../../util/plain_hasher" } -rlp = { path = "../../util/rlp" } +rlp= "0.2.2" rustc-hex = "1.0" keccak-hash = { path = "../../util/hash" } triehash = { path = "../../util/triehash" } diff --git a/ethcore/transaction/Cargo.toml b/ethcore/transaction/Cargo.toml index 79e7282c388..30a4f1fb7b7 100644 --- a/ethcore/transaction/Cargo.toml +++ b/ethcore/transaction/Cargo.toml @@ -10,7 +10,7 @@ ethkey = { path = "../../ethkey" } evm = { path = "../evm" } heapsize = "0.4" keccak-hash = { path = "../../util/hash" } -rlp = { path = "../../util/rlp" } +rlp= "0.2.2" unexpected = { path = "../../util/unexpected" } ethereum-types = "0.3" diff --git a/ethcore/types/Cargo.toml b/ethcore/types/Cargo.toml index 92cc74551d3..87efffda913 100644 --- a/ethcore/types/Cargo.toml +++ b/ethcore/types/Cargo.toml @@ -5,7 +5,7 @@ version = "0.1.0" authors = ["Parity Technologies "] [dependencies] -rlp = { path = "../../util/rlp" } +rlp= "0.2.2" rlp_derive = { path = "../../util/rlp_derive" } ethcore-bytes = { path = "../../util/bytes" } ethereum-types = "0.3" diff --git a/ethcore/vm/Cargo.toml b/ethcore/vm/Cargo.toml index c5d31f58e61..8d604ee5d32 100644 --- a/ethcore/vm/Cargo.toml +++ b/ethcore/vm/Cargo.toml @@ -11,5 +11,5 @@ patricia-trie = { path = "../../util/patricia_trie" } log = "0.3" common-types = { path = "../types" } ethjson = { path = "../../json" } -rlp = { path = "../../util/rlp" } +rlp= "0.2.2" keccak-hash = { path = "../../util/hash" } diff --git a/ipfs/Cargo.toml b/ipfs/Cargo.toml index 9c7b5f3b003..ae366642ecb 100644 --- a/ipfs/Cargo.toml +++ b/ipfs/Cargo.toml @@ -11,7 +11,7 @@ ethcore-bytes = { path = "../util/bytes" } ethereum-types = "0.3" jsonrpc-core = { git = "https://github.com/paritytech/jsonrpc.git", branch = "parity-1.11" } jsonrpc-http-server = { git = "https://github.com/paritytech/jsonrpc.git", branch = "parity-1.11" } -rlp = { path = "../util/rlp" } +rlp= "0.2.2" cid = "0.2" multihash = "0.7" unicase = "2.0" diff --git a/local-store/Cargo.toml b/local-store/Cargo.toml index 6d09eb76f69..19f5f8a2aaf 100644 --- a/local-store/Cargo.toml +++ b/local-store/Cargo.toml @@ -10,7 +10,7 @@ ethcore-io = { path = "../util/io" } ethcore-transaction = { path = "../ethcore/transaction" } kvdb = { path = "../util/kvdb" } log = "0.3" -rlp = { path = "../util/rlp" } +rlp= "0.2.2" serde = "1.0" serde_derive = "1.0" serde_json = "1.0" diff --git a/miner/Cargo.toml b/miner/Cargo.toml index 707352484e2..10cf2b200bc 100644 --- a/miner/Cargo.toml +++ b/miner/Cargo.toml @@ -28,7 +28,7 @@ log = "0.3" parking_lot = "0.5" price-info = { path = "../price-info" } rayon = "1.0" -rlp = { path = "../util/rlp" } +rlp= "0.2.2" trace-time = { path = "../util/trace-time" } transaction-pool = { path = "../transaction-pool" } diff --git a/rpc/Cargo.toml b/rpc/Cargo.toml index 731544a55f2..04f786b37f1 100644 --- a/rpc/Cargo.toml +++ b/rpc/Cargo.toml @@ -60,7 +60,7 @@ parity-reactor = { path = "../util/reactor" } parity-updater = { path = "../updater" } parity-version = { path = "../util/version" } patricia-trie = { path = "../util/patricia_trie" } -rlp = { path = "../util/rlp" } +rlp= "0.2.2" stats = { path = "../util/stats" } vm = { path = "../ethcore/vm" } diff --git a/util/error/Cargo.toml b/util/error/Cargo.toml index d9da3e5c516..36e8350be94 100644 --- a/util/error/Cargo.toml +++ b/util/error/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" authors = ["Parity Technologies "] [dependencies] -rlp = { path = "../rlp" } +rlp= "0.2.2" kvdb = { path = "../kvdb" } ethereum-types = "0.3" error-chain = { version = "0.11", default-features = false } diff --git a/util/journaldb/Cargo.toml b/util/journaldb/Cargo.toml index dea70bd6a43..4ad3e5ce992 100644 --- a/util/journaldb/Cargo.toml +++ b/util/journaldb/Cargo.toml @@ -15,7 +15,7 @@ log = "0.3" memorydb = { path = "../memorydb" } parking_lot = "0.5" plain_hasher = { path = "../plain_hasher" } -rlp = { path = "../rlp" } +rlp= "0.2.2" util-error = { path = "../error" } [dev-dependencies] diff --git a/util/memorydb/Cargo.toml b/util/memorydb/Cargo.toml index 41c41bb628e..ee658c84031 100644 --- a/util/memorydb/Cargo.toml +++ b/util/memorydb/Cargo.toml @@ -12,4 +12,4 @@ ethereum-types = "0.3" keccak-hash = { version = "0.1.0", path = "../hash" } hashdb = { version = "0.1.1", path = "../hashdb" } plain_hasher = { path = "../plain_hasher" } -rlp = { version = "0.2.1", path = "../rlp" } +rlp= "0.2.2" diff --git a/util/network-devp2p/Cargo.toml b/util/network-devp2p/Cargo.toml index f4889fe26d4..11bddcde98f 100644 --- a/util/network-devp2p/Cargo.toml +++ b/util/network-devp2p/Cargo.toml @@ -26,7 +26,7 @@ ethcore-logger = { path ="../../logger" } ethcore-network = { path = "../network" } ethereum-types = "0.3" ethkey = { path = "../../ethkey" } -rlp = { path = "../rlp" } +rlp= "0.2.2" path = { path = "../path" } ipnetwork = "0.12.6" keccak-hash = { path = "../hash" } diff --git a/util/network/Cargo.toml b/util/network/Cargo.toml index f7131da0388..736bb2fb59a 100644 --- a/util/network/Cargo.toml +++ b/util/network/Cargo.toml @@ -13,5 +13,5 @@ ethcore-io = { path = "../io" } ethereum-types = "0.3" ethkey = { path = "../../ethkey" } ipnetwork = "0.12.6" -rlp = { path = "../rlp" } +rlp= "0.2.2" snappy = { git = "https://github.com/paritytech/rust-snappy" } diff --git a/util/patricia_trie/Cargo.toml b/util/patricia_trie/Cargo.toml index 48b06b21463..3f3b5593407 100644 --- a/util/patricia_trie/Cargo.toml +++ b/util/patricia_trie/Cargo.toml @@ -13,7 +13,7 @@ ethcore-bytes = { version = "0.1.0", path = "../bytes" } ethereum-types = "0.3" keccak-hash = { version = "0.1.0", path = "../hash" } hashdb = { version = "0.1.1", path = "../hashdb" } -rlp = { version = "0.2.1", path = "../rlp" } +rlp= "0.2.2" triehash = { version = "0.1.0", path = "../triehash" } memorydb = { version = "0.1.0", path = "../memorydb" } ethcore-logger = { version = "1.9.0", path = "../../logger" } diff --git a/util/rlp/Cargo.toml b/util/rlp/Cargo.toml deleted file mode 100644 index 3bde7206ff8..00000000000 --- a/util/rlp/Cargo.toml +++ /dev/null @@ -1,13 +0,0 @@ -[package] -description = "Recursive-length prefix encoding, decoding, and compression" -repository = "https://github.com/paritytech/parity" -license = "MIT/Apache-2.0" -name = "rlp" -version = "0.2.1" -authors = ["Parity Technologies "] - -[dependencies] -elastic-array = "0.10" -ethereum-types = "0.3" -rustc-hex = "1.0" -byteorder = "1.0" diff --git a/util/rlp/LICENSE-APACHE2 b/util/rlp/LICENSE-APACHE2 deleted file mode 100644 index 16fe87b06e8..00000000000 --- a/util/rlp/LICENSE-APACHE2 +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - -TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - -1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - -2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - -3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - -4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - -5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - -6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - -7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - -8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - -9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - -END OF TERMS AND CONDITIONS - -APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - -Copyright [yyyy] [name of copyright owner] - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. diff --git a/util/rlp/LICENSE-MIT b/util/rlp/LICENSE-MIT deleted file mode 100644 index cd8fdd2b9c6..00000000000 --- a/util/rlp/LICENSE-MIT +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (c) 2015-2017 Parity Technologies - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/util/rlp/README.md b/util/rlp/README.md deleted file mode 100644 index f4007a88445..00000000000 --- a/util/rlp/README.md +++ /dev/null @@ -1,8 +0,0 @@ -# RLP - -Recursive-length-prefix encoding, decoding, and compression in Rust. - -## License - -Unlike most parts of Parity, which fall under the GPLv3, this package is dual-licensed under MIT/Apache2 at the user's choice. -Find the associated license files in this directory as `LICENSE-MIT` and `LICENSE-APACHE2` respectively. diff --git a/util/rlp/benches/rlp.rs b/util/rlp/benches/rlp.rs deleted file mode 100644 index 6aeabaf5de1..00000000000 --- a/util/rlp/benches/rlp.rs +++ /dev/null @@ -1,103 +0,0 @@ -// Copyright 2015-2017 Parity Technologies -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -//! benchmarking for rlp -//! should be started with: -//! ```bash -//! multirust run nightly cargo bench -//! ``` - -#![feature(test)] - -extern crate test; -extern crate ethcore_bigint as bigint; -extern crate rlp; - -use test::Bencher; -use bigint::prelude::U256; -use rlp::{RlpStream, Rlp}; - -#[bench] -fn bench_stream_u64_value(b: &mut Bencher) { - b.iter(|| { - // u64 - let mut stream = RlpStream::new(); - stream.append(&0x1023456789abcdefu64); - let _ = stream.out(); - }); -} - -#[bench] -fn bench_decode_u64_value(b: &mut Bencher) { - b.iter(|| { - // u64 - let data = vec![0x88, 0x10, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef]; - let rlp = Rlp::new(&data); - let _: u64 = rlp.as_val(); - }); -} - -#[bench] -fn bench_stream_u256_value(b: &mut Bencher) { - b.iter(|| { - // u256 - let mut stream = RlpStream::new(); - let uint: U256 = "8090a0b0c0d0e0f00910203040506077000000000000000100000000000012f0".into(); - stream.append(&uint); - let _ = stream.out(); - }); -} - -#[bench] -fn bench_decode_u256_value(b: &mut Bencher) { - b.iter(|| { - // u256 - let data = vec![0xa0, 0x80, 0x90, 0xa0, 0xb0, 0xc0, 0xd0, 0xe0, 0xf0, 0x09, 0x10, 0x20, - 0x30, 0x40, 0x50, 0x60, 0x77, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x12, 0xf0]; - let rlp = Rlp::new(&data); - let _ : U256 = rlp.as_val(); - }); -} - -#[bench] -fn bench_stream_nested_empty_lists(b: &mut Bencher) { - b.iter(|| { - // [ [], [[]], [ [], [[]] ] ] - let mut stream = RlpStream::new_list(3); - stream.begin_list(0); - stream.begin_list(1).begin_list(0); - stream.begin_list(2).begin_list(0).begin_list(1).begin_list(0); - let _ = stream.out(); - }); -} - -#[bench] -fn bench_decode_nested_empty_lists(b: &mut Bencher) { - b.iter(|| { - // [ [], [[]], [ [], [[]] ] ] - let data = vec![0xc7, 0xc0, 0xc1, 0xc0, 0xc3, 0xc0, 0xc1, 0xc0]; - let rlp = Rlp::new(&data); - let _v0: Vec = rlp.at(0).as_list(); - let _v1: Vec = rlp.at(1).at(0).as_list(); - let nested_rlp = rlp.at(2); - let _v2a: Vec = nested_rlp.at(0).as_list(); - let _v2b: Vec = nested_rlp.at(1).at(0).as_list(); - }); -} - -#[bench] -fn bench_stream_1000_empty_lists(b: &mut Bencher) { - b.iter(|| { - let mut stream = RlpStream::new_list(1000); - for _ in 0..1000 { - stream.begin_list(0); - } - let _ = stream.out(); - }); -} diff --git a/util/rlp/license-header b/util/rlp/license-header deleted file mode 100644 index 03df169c8be..00000000000 --- a/util/rlp/license-header +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright 2015-2017 Parity Technologies -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. diff --git a/util/rlp/src/error.rs b/util/rlp/src/error.rs deleted file mode 100644 index 7aef6cfbf72..00000000000 --- a/util/rlp/src/error.rs +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright 2015-2017 Parity Technologies -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use std::fmt; -use std::error::Error as StdError; - -#[derive(Debug, PartialEq, Eq, Clone)] -/// Error concerning the RLP decoder. -pub enum DecoderError { - /// Data has additional bytes at the end of the valid RLP fragment. - RlpIsTooBig, - /// Data has too few bytes for valid RLP. - RlpIsTooShort, - /// Expect an encoded list, RLP was something else. - RlpExpectedToBeList, - /// Expect encoded data, RLP was something else. - RlpExpectedToBeData, - /// Expected a different size list. - RlpIncorrectListLen, - /// Data length number has a prefixed zero byte, invalid for numbers. - RlpDataLenWithZeroPrefix, - /// List length number has a prefixed zero byte, invalid for numbers. - RlpListLenWithZeroPrefix, - /// Non-canonical (longer than necessary) representation used for data or list. - RlpInvalidIndirection, - /// Declared length is inconsistent with data specified after. - RlpInconsistentLengthAndData, - /// Declared length is invalid and results in overflow - RlpInvalidLength, - /// Custom rlp decoding error. - Custom(&'static str), -} - -impl StdError for DecoderError { - fn description(&self) -> &str { - "builder error" - } -} - -impl fmt::Display for DecoderError { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - fmt::Debug::fmt(&self, f) - } -} diff --git a/util/rlp/src/impls.rs b/util/rlp/src/impls.rs deleted file mode 100644 index 573f2c0781e..00000000000 --- a/util/rlp/src/impls.rs +++ /dev/null @@ -1,285 +0,0 @@ -// Copyright 2015-2017 Parity Technologies -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use std::{cmp, mem, str}; -use byteorder::{ByteOrder, BigEndian}; -use bigint::{U128, U256, H64, H128, H160, H256, H512, H520, Bloom}; -use traits::{Encodable, Decodable}; -use stream::RlpStream; -use {Rlp, DecoderError}; - -pub fn decode_usize(bytes: &[u8]) -> Result { - match bytes.len() { - l if l <= mem::size_of::() => { - if bytes[0] == 0 { - return Err(DecoderError::RlpInvalidIndirection); - } - let mut res = 0usize; - for i in 0..l { - let shift = (l - 1 - i) * 8; - res = res + ((bytes[i] as usize) << shift); - } - Ok(res) - } - _ => Err(DecoderError::RlpIsTooBig), - } -} - -impl Encodable for bool { - fn rlp_append(&self, s: &mut RlpStream) { - if *self { - s.encoder().encode_value(&[1]); - } else { - s.encoder().encode_value(&[0]); - } - } -} - -impl Decodable for bool { - fn decode(rlp: &Rlp) -> Result { - rlp.decoder().decode_value(|bytes| { - match bytes.len() { - 0 => Ok(false), - 1 => Ok(bytes[0] != 0), - _ => Err(DecoderError::RlpIsTooBig), - } - }) - } -} - -impl<'a> Encodable for &'a [u8] { - fn rlp_append(&self, s: &mut RlpStream) { - s.encoder().encode_value(self); - } -} - -impl Encodable for Vec { - fn rlp_append(&self, s: &mut RlpStream) { - s.encoder().encode_value(self); - } -} - -impl Decodable for Vec { - fn decode(rlp: &Rlp) -> Result { - rlp.decoder().decode_value(|bytes| { - Ok(bytes.to_vec()) - }) - } -} - -impl Encodable for Option where T: Encodable { - fn rlp_append(&self, s: &mut RlpStream) { - match *self { - None => { - s.begin_list(0); - }, - Some(ref value) => { - s.begin_list(1); - s.append(value); - } - } - } -} - -impl Decodable for Option where T: Decodable { - fn decode(rlp: &Rlp) -> Result { - let items = rlp.item_count()?; - match items { - 1 => rlp.val_at(0).map(Some), - 0 => Ok(None), - _ => Err(DecoderError::RlpIncorrectListLen), - } - } -} - -impl Encodable for u8 { - fn rlp_append(&self, s: &mut RlpStream) { - if *self != 0 { - s.encoder().encode_value(&[*self]); - } else { - s.encoder().encode_value(&[]); - } - } -} - -impl Decodable for u8 { - fn decode(rlp: &Rlp) -> Result { - rlp.decoder().decode_value(|bytes| { - match bytes.len() { - 1 if bytes[0] != 0 => Ok(bytes[0]), - 0 => Ok(0), - 1 => Err(DecoderError::RlpInvalidIndirection), - _ => Err(DecoderError::RlpIsTooBig), - } - }) - } -} - -macro_rules! impl_encodable_for_u { - ($name: ident, $func: ident, $size: expr) => { - impl Encodable for $name { - fn rlp_append(&self, s: &mut RlpStream) { - let leading_empty_bytes = self.leading_zeros() as usize / 8; - let mut buffer = [0u8; $size]; - BigEndian::$func(&mut buffer, *self); - s.encoder().encode_value(&buffer[leading_empty_bytes..]); - } - } - } -} - -macro_rules! impl_decodable_for_u { - ($name: ident) => { - impl Decodable for $name { - fn decode(rlp: &Rlp) -> Result { - rlp.decoder().decode_value(|bytes| { - match bytes.len() { - 0 | 1 => u8::decode(rlp).map(|v| v as $name), - l if l <= mem::size_of::<$name>() => { - if bytes[0] == 0 { - return Err(DecoderError::RlpInvalidIndirection); - } - let mut res = 0 as $name; - for i in 0..l { - let shift = (l - 1 - i) * 8; - res = res + ((bytes[i] as $name) << shift); - } - Ok(res) - } - _ => Err(DecoderError::RlpIsTooBig), - } - }) - } - } - } -} - -impl_encodable_for_u!(u16, write_u16, 2); -impl_encodable_for_u!(u32, write_u32, 4); -impl_encodable_for_u!(u64, write_u64, 8); - -impl_decodable_for_u!(u16); -impl_decodable_for_u!(u32); -impl_decodable_for_u!(u64); - -impl Encodable for usize { - fn rlp_append(&self, s: &mut RlpStream) { - (*self as u64).rlp_append(s); - } -} - -impl Decodable for usize { - fn decode(rlp: &Rlp) -> Result { - u64::decode(rlp).map(|value| value as usize) - } -} - -macro_rules! impl_encodable_for_hash { - ($name: ident) => { - impl Encodable for $name { - fn rlp_append(&self, s: &mut RlpStream) { - s.encoder().encode_value(self); - } - } - } -} - -macro_rules! impl_decodable_for_hash { - ($name: ident, $size: expr) => { - impl Decodable for $name { - fn decode(rlp: &Rlp) -> Result { - rlp.decoder().decode_value(|bytes| match bytes.len().cmp(&$size) { - cmp::Ordering::Less => Err(DecoderError::RlpIsTooShort), - cmp::Ordering::Greater => Err(DecoderError::RlpIsTooBig), - cmp::Ordering::Equal => { - let mut t = [0u8; $size]; - t.copy_from_slice(bytes); - Ok($name(t)) - } - }) - } - } - } -} - -impl_encodable_for_hash!(H64); -impl_encodable_for_hash!(H128); -impl_encodable_for_hash!(H160); -impl_encodable_for_hash!(H256); -impl_encodable_for_hash!(H512); -impl_encodable_for_hash!(H520); -impl_encodable_for_hash!(Bloom); - -impl_decodable_for_hash!(H64, 8); -impl_decodable_for_hash!(H128, 16); -impl_decodable_for_hash!(H160, 20); -impl_decodable_for_hash!(H256, 32); -impl_decodable_for_hash!(H512, 64); -impl_decodable_for_hash!(H520, 65); -impl_decodable_for_hash!(Bloom, 256); - -macro_rules! impl_encodable_for_uint { - ($name: ident, $size: expr) => { - impl Encodable for $name { - fn rlp_append(&self, s: &mut RlpStream) { - let leading_empty_bytes = $size - (self.bits() + 7) / 8; - let mut buffer = [0u8; $size]; - self.to_big_endian(&mut buffer); - s.encoder().encode_value(&buffer[leading_empty_bytes..]); - } - } - } -} - -macro_rules! impl_decodable_for_uint { - ($name: ident, $size: expr) => { - impl Decodable for $name { - fn decode(rlp: &Rlp) -> Result { - rlp.decoder().decode_value(|bytes| { - if !bytes.is_empty() && bytes[0] == 0 { - Err(DecoderError::RlpInvalidIndirection) - } else if bytes.len() <= $size { - Ok($name::from(bytes)) - } else { - Err(DecoderError::RlpIsTooBig) - } - }) - } - } - } -} - -impl_encodable_for_uint!(U256, 32); -impl_encodable_for_uint!(U128, 16); - -impl_decodable_for_uint!(U256, 32); -impl_decodable_for_uint!(U128, 16); - -impl<'a> Encodable for &'a str { - fn rlp_append(&self, s: &mut RlpStream) { - s.encoder().encode_value(self.as_bytes()); - } -} - -impl Encodable for String { - fn rlp_append(&self, s: &mut RlpStream) { - s.encoder().encode_value(self.as_bytes()); - } -} - -impl Decodable for String { - fn decode(rlp: &Rlp) -> Result { - rlp.decoder().decode_value(|bytes| { - match str::from_utf8(bytes) { - Ok(s) => Ok(s.to_owned()), - // consider better error type here - Err(_err) => Err(DecoderError::RlpExpectedToBeData), - } - }) - } -} diff --git a/util/rlp/src/lib.rs b/util/rlp/src/lib.rs deleted file mode 100644 index b416b1c25b0..00000000000 --- a/util/rlp/src/lib.rs +++ /dev/null @@ -1,101 +0,0 @@ -// Copyright 2015-2017 Parity Technologies -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -//! Recursive Length Prefix serialization crate. -//! -//! Allows encoding, decoding, and view onto rlp-slice -//! -//!# What should you use when? -//! -//!### Use `encode` function when: -//! * You want to encode something inline. -//! * You do not work on big set of data. -//! * You want to encode whole data structure at once. -//! -//!### Use `decode` function when: -//! * You want to decode something inline. -//! * You do not work on big set of data. -//! * You want to decode whole rlp at once. -//! -//!### Use `RlpStream` when: -//! * You want to encode something in portions. -//! * You encode a big set of data. -//! -//!### Use `Rlp` when: -//! * You need to handle data corruption errors. -//! * You are working on input data. -//! * You want to get view onto rlp-slice. -//! * You don't want to decode whole rlp at once. - -extern crate byteorder; -extern crate ethereum_types as bigint; -extern crate elastic_array; -extern crate rustc_hex; - -mod traits; -mod error; -mod rlpin; -mod stream; -mod impls; - -use std::borrow::Borrow; -use elastic_array::ElasticArray1024; - -pub use error::DecoderError; -pub use traits::{Decodable, Encodable}; -pub use rlpin::{Rlp, RlpIterator, PayloadInfo, Prototype}; -pub use stream::RlpStream; - -/// The RLP encoded empty data (used to mean "null value"). -pub const NULL_RLP: [u8; 1] = [0x80; 1]; -/// The RLP encoded empty list. -pub const EMPTY_LIST_RLP: [u8; 1] = [0xC0; 1]; - -/// Shortcut function to decode trusted rlp -/// -/// ```rust -/// extern crate rlp; -/// -/// fn main () { -/// let data = vec![0x83, b'c', b'a', b't']; -/// let animal: String = rlp::decode(&data).expect("could not decode"); -/// assert_eq!(animal, "cat".to_owned()); -/// } -/// ``` -pub fn decode(bytes: &[u8]) -> Result where T: Decodable { - let rlp = Rlp::new(bytes); - rlp.as_val() -} - -pub fn decode_list(bytes: &[u8]) -> Vec where T: Decodable { - let rlp = Rlp::new(bytes); - rlp.as_list().expect("trusted rlp should be valid") -} - -/// Shortcut function to encode structure into rlp. -/// -/// ```rust -/// extern crate rlp; -/// -/// fn main () { -/// let animal = "cat"; -/// let out = rlp::encode(&animal).into_vec(); -/// assert_eq!(out, vec![0x83, b'c', b'a', b't']); -/// } -/// ``` -pub fn encode(object: &E) -> ElasticArray1024 where E: Encodable { - let mut stream = RlpStream::new(); - stream.append(object); - stream.drain() -} - -pub fn encode_list(object: &[K]) -> ElasticArray1024 where E: Encodable, K: Borrow { - let mut stream = RlpStream::new(); - stream.append_list(object); - stream.drain() -} diff --git a/util/rlp/src/rlpin.rs b/util/rlp/src/rlpin.rs deleted file mode 100644 index a55b4f79071..00000000000 --- a/util/rlp/src/rlpin.rs +++ /dev/null @@ -1,406 +0,0 @@ -// Copyright 2015-2017 Parity Technologies -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use std::cell::Cell; -use std::fmt; -use rustc_hex::ToHex; -use impls::decode_usize; -use {Decodable, DecoderError}; - -/// rlp offset -#[derive(Copy, Clone, Debug)] -struct OffsetCache { - index: usize, - offset: usize, -} - -impl OffsetCache { - fn new(index: usize, offset: usize) -> OffsetCache { - OffsetCache { - index: index, - offset: offset, - } - } -} - -#[derive(Debug)] -/// RLP prototype -pub enum Prototype { - /// Empty - Null, - /// Value - Data(usize), - /// List - List(usize), -} - -/// Stores basic information about item -pub struct PayloadInfo { - /// Header length in bytes - pub header_len: usize, - /// Value length in bytes - pub value_len: usize, -} - -fn calculate_payload_info(header_bytes: &[u8], len_of_len: usize) -> Result { - let header_len = 1 + len_of_len; - match header_bytes.get(1) { - Some(&0) => return Err(DecoderError::RlpDataLenWithZeroPrefix), - None => return Err(DecoderError::RlpIsTooShort), - _ => (), - } - if header_bytes.len() < header_len { return Err(DecoderError::RlpIsTooShort); } - let value_len = decode_usize(&header_bytes[1..header_len])?; - Ok(PayloadInfo::new(header_len, value_len)) -} - -impl PayloadInfo { - fn new(header_len: usize, value_len: usize) -> PayloadInfo { - PayloadInfo { - header_len: header_len, - value_len: value_len, - } - } - - /// Total size of the RLP. - pub fn total(&self) -> usize { self.header_len + self.value_len } - - /// Create a new object from the given bytes RLP. The bytes - pub fn from(header_bytes: &[u8]) -> Result { - match header_bytes.first().cloned() { - None => Err(DecoderError::RlpIsTooShort), - Some(0...0x7f) => Ok(PayloadInfo::new(0, 1)), - Some(l @ 0x80...0xb7) => Ok(PayloadInfo::new(1, l as usize - 0x80)), - Some(l @ 0xb8...0xbf) => { - let len_of_len = l as usize - 0xb7; - calculate_payload_info(header_bytes, len_of_len) - } - Some(l @ 0xc0...0xf7) => Ok(PayloadInfo::new(1, l as usize - 0xc0)), - Some(l @ 0xf8...0xff) => { - let len_of_len = l as usize - 0xf7; - calculate_payload_info(header_bytes, len_of_len) - }, - // we cant reach this place, but rust requires _ to be implemented - _ => { unreachable!(); } - } - } -} - -/// Data-oriented view onto rlp-slice. -/// -/// This is an immutable structure. No operations change it. -/// -/// Should be used in places where, error handling is required, -/// eg. on input -#[derive(Debug)] -pub struct Rlp<'a> { - bytes: &'a [u8], - offset_cache: Cell, - count_cache: Cell>, -} - -impl<'a> Clone for Rlp<'a> { - fn clone(&self) -> Rlp<'a> { - Rlp { - bytes: self.bytes, - offset_cache: self.offset_cache.clone(), - count_cache: self.count_cache.clone(), - } - } -} - -impl<'a> fmt::Display for Rlp<'a> { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - match self.prototype() { - Ok(Prototype::Null) => write!(f, "null"), - Ok(Prototype::Data(_)) => write!(f, "\"0x{}\"", self.data().unwrap().to_hex()), - Ok(Prototype::List(len)) => { - write!(f, "[")?; - for i in 0..len-1 { - write!(f, "{}, ", self.at(i).unwrap())?; - } - write!(f, "{}", self.at(len - 1).unwrap())?; - write!(f, "]") - }, - Err(err) => write!(f, "{:?}", err) - } - } -} - -impl<'a, 'view> Rlp<'a> where 'a: 'view { - pub fn new(bytes: &'a [u8]) -> Rlp<'a> { - Rlp { - bytes: bytes, - offset_cache: Cell::new(OffsetCache::new(usize::max_value(), 0)), - count_cache: Cell::new(None) - } - } - - pub fn as_raw(&'view self) -> &'a [u8] { - self.bytes - } - - pub fn prototype(&self) -> Result { - // optimize? && return appropriate errors - if self.is_data() { - Ok(Prototype::Data(self.size())) - } else if self.is_list() { - self.item_count().map(Prototype::List) - } else { - Ok(Prototype::Null) - } - } - - pub fn payload_info(&self) -> Result { - BasicDecoder::payload_info(self.bytes) - } - - pub fn data(&'view self) -> Result<&'a [u8], DecoderError> { - let pi = BasicDecoder::payload_info(self.bytes)?; - Ok(&self.bytes[pi.header_len..(pi.header_len + pi.value_len)]) - } - - pub fn item_count(&self) -> Result { - match self.is_list() { - true => match self.count_cache.get() { - Some(c) => Ok(c), - None => { - let c = self.iter().count(); - self.count_cache.set(Some(c)); - Ok(c) - } - }, - false => Err(DecoderError::RlpExpectedToBeList), - } - } - - pub fn size(&self) -> usize { - match self.is_data() { - // TODO: No panic on malformed data, but ideally would Err on no PayloadInfo. - true => BasicDecoder::payload_info(self.bytes).map(|b| b.value_len).unwrap_or(0), - false => 0 - } - } - - pub fn at(&'view self, index: usize) -> Result, DecoderError> { - if !self.is_list() { - return Err(DecoderError::RlpExpectedToBeList); - } - - // move to cached position if its index is less or equal to - // current search index, otherwise move to beginning of list - let c = self.offset_cache.get(); - let (mut bytes, to_skip) = match c.index <= index { - true => (Rlp::consume(self.bytes, c.offset)?, index - c.index), - false => (self.consume_list_payload()?, index), - }; - - // skip up to x items - bytes = Rlp::consume_items(bytes, to_skip)?; - - // update the cache - self.offset_cache.set(OffsetCache::new(index, self.bytes.len() - bytes.len())); - - // construct new rlp - let found = BasicDecoder::payload_info(bytes)?; - Ok(Rlp::new(&bytes[0..found.header_len + found.value_len])) - } - - pub fn is_null(&self) -> bool { - self.bytes.len() == 0 - } - - pub fn is_empty(&self) -> bool { - !self.is_null() && (self.bytes[0] == 0xc0 || self.bytes[0] == 0x80) - } - - pub fn is_list(&self) -> bool { - !self.is_null() && self.bytes[0] >= 0xc0 - } - - pub fn is_data(&self) -> bool { - !self.is_null() && self.bytes[0] < 0xc0 - } - - pub fn is_int(&self) -> bool { - if self.is_null() { - return false; - } - - match self.bytes[0] { - 0...0x80 => true, - 0x81...0xb7 => self.bytes[1] != 0, - b @ 0xb8...0xbf => self.bytes[1 + b as usize - 0xb7] != 0, - _ => false - } - } - - pub fn iter(&'view self) -> RlpIterator<'a, 'view> { - self.into_iter() - } - - pub fn as_val(&self) -> Result where T: Decodable { - T::decode(self) - } - - pub fn as_list(&self) -> Result, DecoderError> where T: Decodable { - self.iter().map(|rlp| rlp.as_val()).collect() - } - - pub fn val_at(&self, index: usize) -> Result where T: Decodable { - self.at(index)?.as_val() - } - - pub fn list_at(&self, index: usize) -> Result, DecoderError> where T: Decodable { - self.at(index)?.as_list() - } - - pub fn decoder(&self) -> BasicDecoder { - BasicDecoder::new(self.clone()) - } - - /// consumes first found prefix - fn consume_list_payload(&self) -> Result<&'a [u8], DecoderError> { - let item = BasicDecoder::payload_info(self.bytes)?; - let bytes = Rlp::consume(self.bytes, item.header_len)?; - Ok(bytes) - } - - /// consumes fixed number of items - fn consume_items(bytes: &'a [u8], items: usize) -> Result<&'a [u8], DecoderError> { - let mut result = bytes; - for _ in 0..items { - let i = BasicDecoder::payload_info(result)?; - result = Rlp::consume(result, i.header_len + i.value_len)?; - } - Ok(result) - } - - - /// consumes slice prefix of length `len` - fn consume(bytes: &'a [u8], len: usize) -> Result<&'a [u8], DecoderError> { - match bytes.len() >= len { - true => Ok(&bytes[len..]), - false => Err(DecoderError::RlpIsTooShort), - } - } -} - -/// Iterator over rlp-slice list elements. -pub struct RlpIterator<'a, 'view> where 'a: 'view { - rlp: &'view Rlp<'a>, - index: usize, -} - -impl<'a, 'view> IntoIterator for &'view Rlp<'a> where 'a: 'view { - type Item = Rlp<'a>; - type IntoIter = RlpIterator<'a, 'view>; - - fn into_iter(self) -> Self::IntoIter { - RlpIterator { - rlp: self, - index: 0, - } - } -} - -impl<'a, 'view> Iterator for RlpIterator<'a, 'view> { - type Item = Rlp<'a>; - - fn next(&mut self) -> Option> { - let index = self.index; - let result = self.rlp.at(index).ok(); - self.index += 1; - result - } -} - -pub struct BasicDecoder<'a> { - rlp: Rlp<'a> -} - -impl<'a> BasicDecoder<'a> { - pub fn new(rlp: Rlp<'a>) -> BasicDecoder<'a> { - BasicDecoder { - rlp: rlp - } - } - - /// Return first item info. - fn payload_info(bytes: &[u8]) -> Result { - let item = PayloadInfo::from(bytes)?; - match item.header_len.checked_add(item.value_len) { - Some(x) if x <= bytes.len() => Ok(item), - _ => Err(DecoderError::RlpIsTooShort), - } - } - - pub fn decode_value(&self, f: F) -> Result - where F: Fn(&[u8]) -> Result { - - let bytes = self.rlp.as_raw(); - - match bytes.first().cloned() { - // RLP is too short. - None => Err(DecoderError::RlpIsTooShort), - // Single byte value. - Some(l @ 0...0x7f) => Ok(f(&[l])?), - // 0-55 bytes - Some(l @ 0x80...0xb7) => { - let last_index_of = 1 + l as usize - 0x80; - if bytes.len() < last_index_of { - return Err(DecoderError::RlpInconsistentLengthAndData); - } - let d = &bytes[1..last_index_of]; - if l == 0x81 && d[0] < 0x80 { - return Err(DecoderError::RlpInvalidIndirection); - } - Ok(f(d)?) - }, - // Longer than 55 bytes. - Some(l @ 0xb8...0xbf) => { - let len_of_len = l as usize - 0xb7; - let begin_of_value = 1 as usize + len_of_len; - if bytes.len() < begin_of_value { - return Err(DecoderError::RlpInconsistentLengthAndData); - } - let len = decode_usize(&bytes[1..begin_of_value])?; - - let last_index_of_value = begin_of_value.checked_add(len) - .ok_or(DecoderError::RlpInvalidLength)?; - if bytes.len() < last_index_of_value { - return Err(DecoderError::RlpInconsistentLengthAndData); - } - Ok(f(&bytes[begin_of_value..last_index_of_value])?) - } - // We are reading value, not a list! - _ => Err(DecoderError::RlpExpectedToBeData) - } - } -} - -#[cfg(test)] -mod tests { - use {Rlp, DecoderError}; - - #[test] - fn test_rlp_display() { - use rustc_hex::FromHex; - let data = "f84d0589010efbef67941f79b2a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a0c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470".from_hex().unwrap(); - let rlp = Rlp::new(&data); - assert_eq!(format!("{}", rlp), "[\"0x05\", \"0x010efbef67941f79b2\", \"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421\", \"0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470\"]"); - } - - #[test] - fn length_overflow() { - let bs = [0xbf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe5]; - let rlp = Rlp::new(&bs); - let res: Result = rlp.as_val(); - assert_eq!(Err(DecoderError::RlpInvalidLength), res); - } -} diff --git a/util/rlp/src/stream.rs b/util/rlp/src/stream.rs deleted file mode 100644 index 000b6e15bcb..00000000000 --- a/util/rlp/src/stream.rs +++ /dev/null @@ -1,382 +0,0 @@ -// Copyright 2015-2017 Parity Technologies -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use std::borrow::Borrow; -use byteorder::{ByteOrder, BigEndian}; -use elastic_array::{ElasticArray16, ElasticArray1024}; -use traits::Encodable; - -#[derive(Debug, Copy, Clone)] -struct ListInfo { - position: usize, - current: usize, - max: Option, -} - -impl ListInfo { - fn new(position: usize, max: Option) -> ListInfo { - ListInfo { - position: position, - current: 0, - max: max, - } - } -} - -/// Appendable rlp encoder. -pub struct RlpStream { - unfinished_lists: ElasticArray16, - buffer: ElasticArray1024, - finished_list: bool, -} - -impl Default for RlpStream { - fn default() -> Self { - RlpStream::new() - } -} - -impl RlpStream { - /// Initializes instance of empty `Stream`. - pub fn new() -> Self { - RlpStream { - unfinished_lists: ElasticArray16::new(), - buffer: ElasticArray1024::new(), - finished_list: false, - } - } - - /// Initializes the `Stream` as a list. - pub fn new_list(len: usize) -> Self { - let mut stream = RlpStream::new(); - stream.begin_list(len); - stream - } - - /// Appends value to the end of stream, chainable. - /// - /// ```rust - /// extern crate rlp; - /// use rlp::*; - /// - /// fn main () { - /// let mut stream = RlpStream::new_list(2); - /// stream.append(&"cat").append(&"dog"); - /// let out = stream.out(); - /// assert_eq!(out, vec![0xc8, 0x83, b'c', b'a', b't', 0x83, b'd', b'o', b'g']); - /// } - /// ``` - pub fn append<'a, E>(&'a mut self, value: &E) -> &'a mut Self where E: Encodable { - self.finished_list = false; - value.rlp_append(self); - if !self.finished_list { - self.note_appended(1); - } - self - } - - /// Appends list of values to the end of stream, chainable. - pub fn append_list<'a, E, K>(&'a mut self, values: &[K]) -> &'a mut Self where E: Encodable, K: Borrow { - self.begin_list(values.len()); - for value in values { - self.append(value.borrow()); - } - self - } - - /// Appends value to the end of stream, but do not count it as an appended item. - /// It's useful for wrapper types - pub fn append_internal<'a, E>(&'a mut self, value: &E) -> &'a mut Self where E: Encodable { - value.rlp_append(self); - self - } - - /// Declare appending the list of given size, chainable. - /// - /// ```rust - /// extern crate rlp; - /// use rlp::*; - /// - /// fn main () { - /// let mut stream = RlpStream::new_list(2); - /// stream.begin_list(2).append(&"cat").append(&"dog"); - /// stream.append(&""); - /// let out = stream.out(); - /// assert_eq!(out, vec![0xca, 0xc8, 0x83, b'c', b'a', b't', 0x83, b'd', b'o', b'g', 0x80]); - /// } - /// ``` - pub fn begin_list(&mut self, len: usize) -> &mut RlpStream { - self.finished_list = false; - match len { - 0 => { - // we may finish, if the appended list len is equal 0 - self.buffer.push(0xc0u8); - self.note_appended(1); - self.finished_list = true; - }, - _ => { - // payload is longer than 1 byte only for lists > 55 bytes - // by pushing always this 1 byte we may avoid unnecessary shift of data - self.buffer.push(0); - - let position = self.buffer.len(); - self.unfinished_lists.push(ListInfo::new(position, Some(len))); - }, - } - - // return chainable self - self - } - - - /// Declare appending the list of unknown size, chainable. - pub fn begin_unbounded_list(&mut self) -> &mut RlpStream { - self.finished_list = false; - // payload is longer than 1 byte only for lists > 55 bytes - // by pushing always this 1 byte we may avoid unnecessary shift of data - self.buffer.push(0); - let position = self.buffer.len(); - self.unfinished_lists.push(ListInfo::new(position, None)); - // return chainable self - self - } - - /// Apends null to the end of stream, chainable. - /// - /// ```rust - /// extern crate rlp; - /// use rlp::*; - /// - /// fn main () { - /// let mut stream = RlpStream::new_list(2); - /// stream.append_empty_data().append_empty_data(); - /// let out = stream.out(); - /// assert_eq!(out, vec![0xc2, 0x80, 0x80]); - /// } - /// ``` - pub fn append_empty_data(&mut self) -> &mut RlpStream { - // self push raw item - self.buffer.push(0x80); - - // try to finish and prepend the length - self.note_appended(1); - - // return chainable self - self - } - - /// Appends raw (pre-serialised) RLP data. Use with caution. Chainable. - pub fn append_raw<'a>(&'a mut self, bytes: &[u8], item_count: usize) -> &'a mut RlpStream { - // push raw items - self.buffer.append_slice(bytes); - - // try to finish and prepend the length - self.note_appended(item_count); - - // return chainable self - self - } - - /// Appends raw (pre-serialised) RLP data. Checks for size oveflow. - pub fn append_raw_checked<'a>(&'a mut self, bytes: &[u8], item_count: usize, max_size: usize) -> bool { - if self.estimate_size(bytes.len()) > max_size { - return false; - } - self.append_raw(bytes, item_count); - true - } - - /// Calculate total RLP size for appended payload. - pub fn estimate_size<'a>(&'a self, add: usize) -> usize { - let total_size = self.buffer.len() + add; - let mut base_size = total_size; - for list in &self.unfinished_lists[..] { - let len = total_size - list.position; - if len > 55 { - let leading_empty_bytes = (len as u64).leading_zeros() as usize / 8; - let size_bytes = 8 - leading_empty_bytes; - base_size += size_bytes; - } - } - base_size - } - - - /// Returns current RLP size in bytes for the data pushed into the list. - pub fn len<'a>(&'a self) -> usize { - self.estimate_size(0) - } - - /// Clear the output stream so far. - /// - /// ```rust - /// extern crate rlp; - /// use rlp::*; - /// - /// fn main () { - /// let mut stream = RlpStream::new_list(3); - /// stream.append(&"cat"); - /// stream.clear(); - /// stream.append(&"dog"); - /// let out = stream.out(); - /// assert_eq!(out, vec![0x83, b'd', b'o', b'g']); - /// } - pub fn clear(&mut self) { - // clear bytes - self.buffer.clear(); - - // clear lists - self.unfinished_lists.clear(); - } - - /// Returns true if stream doesnt expect any more items. - /// - /// ```rust - /// extern crate rlp; - /// use rlp::*; - /// - /// fn main () { - /// let mut stream = RlpStream::new_list(2); - /// stream.append(&"cat"); - /// assert_eq!(stream.is_finished(), false); - /// stream.append(&"dog"); - /// assert_eq!(stream.is_finished(), true); - /// let out = stream.out(); - /// assert_eq!(out, vec![0xc8, 0x83, b'c', b'a', b't', 0x83, b'd', b'o', b'g']); - /// } - pub fn is_finished(&self) -> bool { - self.unfinished_lists.len() == 0 - } - - /// Get raw encoded bytes - pub fn as_raw(&self) -> &[u8] { - //&self.encoder.bytes - &self.buffer - } - - /// Streams out encoded bytes. - /// - /// panic! if stream is not finished. - pub fn out(self) -> Vec { - match self.is_finished() { - //true => self.encoder.out().into_vec(), - true => self.buffer.into_vec(), - false => panic!() - } - } - - /// Try to finish lists - fn note_appended(&mut self, inserted_items: usize) -> () { - if self.unfinished_lists.len() == 0 { - return; - } - - let back = self.unfinished_lists.len() - 1; - let should_finish = match self.unfinished_lists.get_mut(back) { - None => false, - Some(ref mut x) => { - x.current += inserted_items; - match x.max { - Some(ref max) if x.current > *max => panic!("You cannot append more items then you expect!"), - Some(ref max) => x.current == *max, - _ => false, - } - } - }; - - if should_finish { - let x = self.unfinished_lists.pop().unwrap(); - let len = self.buffer.len() - x.position; - self.encoder().insert_list_payload(len, x.position); - self.note_appended(1); - } - self.finished_list = should_finish; - } - - pub fn encoder(&mut self) -> BasicEncoder { - BasicEncoder::new(self) - } - - /// Drain the object and return the underlying ElasticArray. - pub fn drain(self) -> ElasticArray1024 { - match self.is_finished() { - true => self.buffer, - false => panic!() - } - } - - /// Finalize current ubnbound list. Panics if no unbounded list has been opened. - pub fn complete_unbounded_list(&mut self) { - let list = self.unfinished_lists.pop().expect("No open list."); - if list.max.is_some() { - panic!("List type mismatch."); - } - let len = self.buffer.len() - list.position; - self.encoder().insert_list_payload(len, list.position); - self.note_appended(1); - } -} - -pub struct BasicEncoder<'a> { - buffer: &'a mut ElasticArray1024, -} - -impl<'a> BasicEncoder<'a> { - fn new(stream: &'a mut RlpStream) -> Self { - BasicEncoder { - buffer: &mut stream.buffer - } - } - - fn insert_size(&mut self, size: usize, position: usize) -> u8 { - let size = size as u32; - let leading_empty_bytes = size.leading_zeros() as usize / 8; - let size_bytes = 4 - leading_empty_bytes as u8; - let mut buffer = [0u8; 4]; - BigEndian::write_u32(&mut buffer, size); - self.buffer.insert_slice(position, &buffer[leading_empty_bytes..]); - size_bytes as u8 - } - - /// Inserts list prefix at given position - fn insert_list_payload(&mut self, len: usize, pos: usize) { - // 1 byte was already reserved for payload earlier - match len { - 0...55 => { - self.buffer[pos - 1] = 0xc0u8 + len as u8; - }, - _ => { - let inserted_bytes = self.insert_size(len, pos); - self.buffer[pos - 1] = 0xf7u8 + inserted_bytes; - } - }; - } - - /// Pushes encoded value to the end of buffer - pub fn encode_value(&mut self, value: &[u8]) { - match value.len() { - // just 0 - 0 => self.buffer.push(0x80u8), - // byte is its own encoding if < 0x80 - 1 if value[0] < 0x80 => self.buffer.push(value[0]), - // (prefix + length), followed by the string - len @ 1 ... 55 => { - self.buffer.push(0x80u8 + len as u8); - self.buffer.append_slice(value); - } - // (prefix + length of length), followed by the length, followd by the string - len => { - self.buffer.push(0); - let position = self.buffer.len(); - let inserted_bytes = self.insert_size(len, position); - self.buffer[position - 1] = 0xb7 + inserted_bytes; - self.buffer.append_slice(value); - } - } - } -} diff --git a/util/rlp/src/traits.rs b/util/rlp/src/traits.rs deleted file mode 100644 index 1596009e75f..00000000000 --- a/util/rlp/src/traits.rs +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2015-2017 Parity Technologies -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -//! Common RLP traits -use elastic_array::ElasticArray1024; -use {DecoderError, Rlp, RlpStream}; - -/// RLP decodable trait -pub trait Decodable: Sized { - /// Decode a value from RLP bytes - fn decode(rlp: &Rlp) -> Result; -} - -/// Structure encodable to RLP -pub trait Encodable { - /// Append a value to the stream - fn rlp_append(&self, s: &mut RlpStream); - - /// Get rlp-encoded bytes for this instance - fn rlp_bytes(&self) -> ElasticArray1024 { - let mut s = RlpStream::new(); - self.rlp_append(&mut s); - s.drain() - } -} diff --git a/util/rlp/tests/tests.rs b/util/rlp/tests/tests.rs deleted file mode 100644 index 041c267667d..00000000000 --- a/util/rlp/tests/tests.rs +++ /dev/null @@ -1,426 +0,0 @@ -// Copyright 2015-2017 Parity Technologies -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern crate ethereum_types as bigint; -extern crate rlp; - -use std::{fmt, cmp}; -use bigint::{U256, H160}; -use rlp::{Encodable, Decodable, Rlp, RlpStream, DecoderError}; - -#[test] -fn rlp_at() { - let data = vec![0xc8, 0x83, b'c', b'a', b't', 0x83, b'd', b'o', b'g']; - { - let rlp = Rlp::new(&data); - assert!(rlp.is_list()); - let animals: Vec = rlp.as_list().unwrap(); - assert_eq!(animals, vec!["cat".to_owned(), "dog".to_owned()]); - - let cat = rlp.at(0).unwrap(); - assert!(cat.is_data()); - assert_eq!(cat.as_raw(), &[0x83, b'c', b'a', b't']); - assert_eq!(cat.as_val::().unwrap(), "cat".to_owned()); - - let dog = rlp.at(1).unwrap(); - assert!(dog.is_data()); - assert_eq!(dog.as_raw(), &[0x83, b'd', b'o', b'g']); - assert_eq!(dog.as_val::().unwrap(), "dog".to_owned()); - - let cat_again = rlp.at(0).unwrap(); - assert!(cat_again.is_data()); - assert_eq!(cat_again.as_raw(), &[0x83, b'c', b'a', b't']); - assert_eq!(cat_again.as_val::().unwrap(), "cat".to_owned()); - } -} - -#[test] -fn rlp_at_err() { - let data = vec![0xc8, 0x83, b'c', b'a', b't', 0x83, b'd', b'o']; - { - let rlp = Rlp::new(&data); - assert!(rlp.is_list()); - - let cat_err = rlp.at(0).unwrap_err(); - assert_eq!(cat_err, DecoderError::RlpIsTooShort); - - let dog_err = rlp.at(1).unwrap_err(); - assert_eq!(dog_err, DecoderError::RlpIsTooShort); - } -} - -#[test] -fn rlp_iter() { - let data = vec![0xc8, 0x83, b'c', b'a', b't', 0x83, b'd', b'o', b'g']; - { - let rlp = Rlp::new(&data); - let mut iter = rlp.iter(); - - let cat = iter.next().unwrap(); - assert!(cat.is_data()); - assert_eq!(cat.as_raw(), &[0x83, b'c', b'a', b't']); - - let dog = iter.next().unwrap(); - assert!(dog.is_data()); - assert_eq!(dog.as_raw(), &[0x83, b'd', b'o', b'g']); - - let none = iter.next(); - assert!(none.is_none()); - - let cat_again = rlp.at(0).unwrap(); - assert!(cat_again.is_data()); - assert_eq!(cat_again.as_raw(), &[0x83, b'c', b'a', b't']); - } -} - -struct ETestPair(T, Vec) where T: Encodable; - -fn run_encode_tests(tests: Vec>) - where T: Encodable -{ - for t in &tests { - let res = rlp::encode(&t.0); - assert_eq!(&res[..], &t.1[..]); - } -} - -struct VETestPair(Vec, Vec) where T: Encodable; - -fn run_encode_tests_list(tests: Vec>) - where T: Encodable -{ - for t in &tests { - let res = rlp::encode_list(&t.0); - assert_eq!(&res[..], &t.1[..]); - } -} - -#[test] -fn encode_u16() { - let tests = vec![ - ETestPair(0u16, vec![0x80u8]), - ETestPair(0x100, vec![0x82, 0x01, 0x00]), - ETestPair(0xffff, vec![0x82, 0xff, 0xff]), - ]; - run_encode_tests(tests); -} - -#[test] -fn encode_u32() { - let tests = vec![ - ETestPair(0u32, vec![0x80u8]), - ETestPair(0x10000, vec![0x83, 0x01, 0x00, 0x00]), - ETestPair(0xffffff, vec![0x83, 0xff, 0xff, 0xff]), - ]; - run_encode_tests(tests); -} - -#[test] -fn encode_u64() { - let tests = vec![ - ETestPair(0u64, vec![0x80u8]), - ETestPair(0x1000000, vec![0x84, 0x01, 0x00, 0x00, 0x00]), - ETestPair(0xFFFFFFFF, vec![0x84, 0xff, 0xff, 0xff, 0xff]), - ]; - run_encode_tests(tests); -} - -#[test] -fn encode_u256() { - let tests = vec![ETestPair(U256::from(0u64), vec![0x80u8]), - ETestPair(U256::from(0x1000000u64), vec![0x84, 0x01, 0x00, 0x00, 0x00]), - ETestPair(U256::from(0xffffffffu64), - vec![0x84, 0xff, 0xff, 0xff, 0xff]), - ETestPair(("8090a0b0c0d0e0f00910203040506077000000000000\ - 000100000000000012f0").into(), - vec![0xa0, 0x80, 0x90, 0xa0, 0xb0, 0xc0, 0xd0, 0xe0, 0xf0, - 0x09, 0x10, 0x20, 0x30, 0x40, 0x50, 0x60, 0x77, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x12, 0xf0])]; - run_encode_tests(tests); -} - -#[test] -fn encode_str() { - let tests = vec![ETestPair("cat", vec![0x83, b'c', b'a', b't']), - ETestPair("dog", vec![0x83, b'd', b'o', b'g']), - ETestPair("Marek", vec![0x85, b'M', b'a', b'r', b'e', b'k']), - ETestPair("", vec![0x80]), - ETestPair("Lorem ipsum dolor sit amet, consectetur adipisicing elit", - vec![0xb8, 0x38, b'L', b'o', b'r', b'e', b'm', b' ', b'i', - b'p', b's', b'u', b'm', b' ', b'd', b'o', b'l', b'o', - b'r', b' ', b's', b'i', b't', b' ', b'a', b'm', b'e', - b't', b',', b' ', b'c', b'o', b'n', b's', b'e', b'c', - b't', b'e', b't', b'u', b'r', b' ', b'a', b'd', b'i', - b'p', b'i', b's', b'i', b'c', b'i', b'n', b'g', b' ', - b'e', b'l', b'i', b't'])]; - run_encode_tests(tests); -} - -#[test] -fn encode_address() { - let tests = vec![ - ETestPair(H160::from("ef2d6d194084c2de36e0dabfce45d046b37d1106"), - vec![0x94, 0xef, 0x2d, 0x6d, 0x19, 0x40, 0x84, 0xc2, 0xde, - 0x36, 0xe0, 0xda, 0xbf, 0xce, 0x45, 0xd0, 0x46, - 0xb3, 0x7d, 0x11, 0x06]) - ]; - run_encode_tests(tests); -} - -/// Vec (Bytes) is treated as a single value -#[test] -fn encode_vector_u8() { - let tests = vec![ - ETestPair(vec![], vec![0x80]), - ETestPair(vec![0u8], vec![0]), - ETestPair(vec![0x15], vec![0x15]), - ETestPair(vec![0x40, 0x00], vec![0x82, 0x40, 0x00]), - ]; - run_encode_tests(tests); -} - -#[test] -fn encode_vector_u64() { - let tests = vec![ - VETestPair(vec![], vec![0xc0]), - VETestPair(vec![15u64], vec![0xc1, 0x0f]), - VETestPair(vec![1, 2, 3, 7, 0xff], vec![0xc6, 1, 2, 3, 7, 0x81, 0xff]), - VETestPair(vec![0xffffffff, 1, 2, 3, 7, 0xff], vec![0xcb, 0x84, 0xff, 0xff, 0xff, 0xff, 1, 2, 3, 7, 0x81, 0xff]), - ]; - run_encode_tests_list(tests); -} - -#[test] -fn encode_vector_str() { - let tests = vec![VETestPair(vec!["cat", "dog"], - vec![0xc8, 0x83, b'c', b'a', b't', 0x83, b'd', b'o', b'g'])]; - run_encode_tests_list(tests); -} - -struct DTestPair(T, Vec) where T: Decodable + fmt::Debug + cmp::Eq; - -struct VDTestPair(Vec, Vec) where T: Decodable + fmt::Debug + cmp::Eq; - -fn run_decode_tests(tests: Vec>) where T: Decodable + fmt::Debug + cmp::Eq { - for t in &tests { - let res : Result = rlp::decode(&t.1); - assert!(res.is_ok()); - let res = res.unwrap(); - assert_eq!(&res, &t.0); - } -} - -fn run_decode_tests_list(tests: Vec>) where T: Decodable + fmt::Debug + cmp::Eq { - for t in &tests { - let res: Vec = rlp::decode_list(&t.1); - assert_eq!(res, t.0); - } -} - -/// Vec (Bytes) is treated as a single value -#[test] -fn decode_vector_u8() { - let tests = vec![ - DTestPair(vec![], vec![0x80]), - DTestPair(vec![0u8], vec![0]), - DTestPair(vec![0x15], vec![0x15]), - DTestPair(vec![0x40, 0x00], vec![0x82, 0x40, 0x00]), - ]; - run_decode_tests(tests); -} - -#[test] -fn decode_untrusted_u8() { - let tests = vec![ - DTestPair(0x0u8, vec![0x80]), - DTestPair(0x77u8, vec![0x77]), - DTestPair(0xccu8, vec![0x81, 0xcc]), - ]; - run_decode_tests(tests); -} - -#[test] -fn decode_untrusted_u16() { - let tests = vec![ - DTestPair(0x100u16, vec![0x82, 0x01, 0x00]), - DTestPair(0xffffu16, vec![0x82, 0xff, 0xff]), - ]; - run_decode_tests(tests); -} - -#[test] -fn decode_untrusted_u32() { - let tests = vec![ - DTestPair(0x10000u32, vec![0x83, 0x01, 0x00, 0x00]), - DTestPair(0xffffffu32, vec![0x83, 0xff, 0xff, 0xff]), - ]; - run_decode_tests(tests); -} - -#[test] -fn decode_untrusted_u64() { - let tests = vec![ - DTestPair(0x1000000u64, vec![0x84, 0x01, 0x00, 0x00, 0x00]), - DTestPair(0xFFFFFFFFu64, vec![0x84, 0xff, 0xff, 0xff, 0xff]), - ]; - run_decode_tests(tests); -} - -#[test] -fn decode_untrusted_u256() { - let tests = vec![DTestPair(U256::from(0u64), vec![0x80u8]), - DTestPair(U256::from(0x1000000u64), vec![0x84, 0x01, 0x00, 0x00, 0x00]), - DTestPair(U256::from(0xffffffffu64), - vec![0x84, 0xff, 0xff, 0xff, 0xff]), - DTestPair(("8090a0b0c0d0e0f00910203040506077000000000000\ - 000100000000000012f0").into(), - vec![0xa0, 0x80, 0x90, 0xa0, 0xb0, 0xc0, 0xd0, 0xe0, 0xf0, - 0x09, 0x10, 0x20, 0x30, 0x40, 0x50, 0x60, 0x77, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x12, 0xf0])]; - run_decode_tests(tests); -} - -#[test] -fn decode_untrusted_str() { - let tests = vec![DTestPair("cat".to_owned(), vec![0x83, b'c', b'a', b't']), - DTestPair("dog".to_owned(), vec![0x83, b'd', b'o', b'g']), - DTestPair("Marek".to_owned(), - vec![0x85, b'M', b'a', b'r', b'e', b'k']), - DTestPair("".to_owned(), vec![0x80]), - DTestPair("Lorem ipsum dolor sit amet, consectetur adipisicing elit" - .to_owned(), - vec![0xb8, 0x38, b'L', b'o', b'r', b'e', b'm', b' ', b'i', - b'p', b's', b'u', b'm', b' ', b'd', b'o', b'l', b'o', - b'r', b' ', b's', b'i', b't', b' ', b'a', b'm', b'e', - b't', b',', b' ', b'c', b'o', b'n', b's', b'e', b'c', - b't', b'e', b't', b'u', b'r', b' ', b'a', b'd', b'i', - b'p', b'i', b's', b'i', b'c', b'i', b'n', b'g', b' ', - b'e', b'l', b'i', b't'])]; - run_decode_tests(tests); -} - -#[test] -fn decode_untrusted_address() { - let tests = vec![ - DTestPair(H160::from("ef2d6d194084c2de36e0dabfce45d046b37d1106"), - vec![0x94, 0xef, 0x2d, 0x6d, 0x19, 0x40, 0x84, 0xc2, 0xde, - 0x36, 0xe0, 0xda, 0xbf, 0xce, 0x45, 0xd0, 0x46, - 0xb3, 0x7d, 0x11, 0x06]) - ]; - run_decode_tests(tests); -} - -#[test] -fn decode_untrusted_vector_u64() { - let tests = vec![ - VDTestPair(vec![], vec![0xc0]), - VDTestPair(vec![15u64], vec![0xc1, 0x0f]), - VDTestPair(vec![1, 2, 3, 7, 0xff], vec![0xc6, 1, 2, 3, 7, 0x81, 0xff]), - VDTestPair(vec![0xffffffff, 1, 2, 3, 7, 0xff], vec![0xcb, 0x84, 0xff, 0xff, 0xff, 0xff, 1, 2, 3, 7, 0x81, 0xff]), - ]; - run_decode_tests_list(tests); -} - -#[test] -fn decode_untrusted_vector_str() { - let tests = vec![VDTestPair(vec!["cat".to_owned(), "dog".to_owned()], - vec![0xc8, 0x83, b'c', b'a', b't', 0x83, b'd', b'o', b'g'])]; - run_decode_tests_list(tests); -} - -#[test] -fn test_rlp_data_length_check() -{ - let data = vec![0x84, b'c', b'a', b't']; - let rlp = Rlp::new(&data); - - let as_val: Result = rlp.as_val(); - assert_eq!(Err(DecoderError::RlpInconsistentLengthAndData), as_val); -} - -#[test] -fn test_rlp_long_data_length_check() -{ - let mut data: Vec = vec![0xb8, 255]; - for _ in 0..253 { - data.push(b'c'); - } - - let rlp = Rlp::new(&data); - - let as_val: Result = rlp.as_val(); - assert_eq!(Err(DecoderError::RlpInconsistentLengthAndData), as_val); -} - -#[test] -fn test_the_exact_long_string() -{ - let mut data: Vec = vec![0xb8, 255]; - for _ in 0..255 { - data.push(b'c'); - } - - let rlp = Rlp::new(&data); - - let as_val: Result = rlp.as_val(); - assert!(as_val.is_ok()); -} - -#[test] -fn test_rlp_2bytes_data_length_check() -{ - let mut data: Vec = vec![0xb9, 2, 255]; // 512+255 - for _ in 0..700 { - data.push(b'c'); - } - - let rlp = Rlp::new(&data); - - let as_val: Result = rlp.as_val(); - assert_eq!(Err(DecoderError::RlpInconsistentLengthAndData), as_val); -} - -#[test] -fn test_rlp_nested_empty_list_encode() { - let mut stream = RlpStream::new_list(2); - stream.append_list(&(Vec::new() as Vec)); - stream.append(&40u32); - assert_eq!(stream.drain()[..], [0xc2u8, 0xc0u8, 40u8][..]); -} - -#[test] -fn test_rlp_list_length_overflow() { - let data: Vec = vec![0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00]; - let rlp = Rlp::new(&data); - let as_val: Result = rlp.val_at(0); - assert_eq!(Err(DecoderError::RlpIsTooShort), as_val); -} - -#[test] -fn test_rlp_stream_size_limit() { - for limit in 40 .. 270 { - let item = [0u8; 1]; - let mut stream = RlpStream::new(); - while stream.append_raw_checked(&item, 1, limit) {} - assert_eq!(stream.drain().len(), limit); - } -} - -#[test] -fn test_rlp_stream_unbounded_list() { - let mut stream = RlpStream::new(); - stream.begin_unbounded_list(); - stream.append(&40u32); - stream.append(&41u32); - assert!(!stream.is_finished()); - stream.complete_unbounded_list(); - assert!(stream.is_finished()); -} - diff --git a/util/rlp_compress/Cargo.toml b/util/rlp_compress/Cargo.toml index d5f85425f23..8f0bde3a00e 100644 --- a/util/rlp_compress/Cargo.toml +++ b/util/rlp_compress/Cargo.toml @@ -4,6 +4,6 @@ version = "0.1.0" authors = ["Parity Technologies "] [dependencies] -rlp = { path = "../rlp" } +rlp= "0.2.2" elastic-array = "0.10" lazy_static = "1.0" diff --git a/util/rlp_derive/Cargo.toml b/util/rlp_derive/Cargo.toml index bb488cc29e6..9eb2daeb3d2 100644 --- a/util/rlp_derive/Cargo.toml +++ b/util/rlp_derive/Cargo.toml @@ -12,4 +12,4 @@ syn = "0.13" quote = "0.5" [dev-dependencies] -rlp = { path = "../rlp" } +rlp= "0.2.2" diff --git a/util/trie-standardmap/Cargo.toml b/util/trie-standardmap/Cargo.toml index 1177f30752c..f89e58ee29c 100644 --- a/util/trie-standardmap/Cargo.toml +++ b/util/trie-standardmap/Cargo.toml @@ -8,4 +8,4 @@ description = "Standard test map for profiling tries" ethcore-bytes = { path = "../bytes" } ethereum-types = "0.3" keccak-hash = { path = "../hash" } -rlp = { path = "../rlp" } +rlp= "0.2.2" diff --git a/util/triehash/Cargo.toml b/util/triehash/Cargo.toml index ee42b9d8253..9d0faa96bc3 100644 --- a/util/triehash/Cargo.toml +++ b/util/triehash/Cargo.toml @@ -7,7 +7,7 @@ license = "GPL-3.0" [dependencies] elastic-array = "0.10" -rlp = { version = "0.2.1", path = "../rlp" } +rlp= "0.2.2" ethereum-types = "0.3" keccak-hash = { version = "0.1", path = "../hash" } diff --git a/util/version/Cargo.toml b/util/version/Cargo.toml index 297211b2bd0..c55d948ba95 100644 --- a/util/version/Cargo.toml +++ b/util/version/Cargo.toml @@ -23,7 +23,7 @@ kovan = 6600000 [dependencies] ethcore-bytes = { path = "../bytes" } -rlp = { path = "../rlp" } +rlp= "0.2.2" target_info = "0.1" [build-dependencies] diff --git a/whisper/Cargo.toml b/whisper/Cargo.toml index ed370e38a2d..098267e3822 100644 --- a/whisper/Cargo.toml +++ b/whisper/Cargo.toml @@ -17,7 +17,7 @@ mem = { path = "../util/mem" } ordered-float = "0.5" parking_lot = "0.5" rand = "0.4" -rlp = { path = "../util/rlp" } +rlp= "0.2.2" serde = "1.0" serde_derive = "1.0" serde_json = "1.0"